diff options
Diffstat (limited to 'app/Model')
-rw-r--r-- | app/Model/Category.php | 25 | ||||
-rw-r--r-- | app/Model/Project.php | 2 |
2 files changed, 26 insertions, 1 deletions
diff --git a/app/Model/Category.php b/app/Model/Category.php index 54a0f552..cd60e7f7 100644 --- a/app/Model/Category.php +++ b/app/Model/Category.php @@ -118,7 +118,30 @@ class Category extends Base } /** - * Create a category + * Create default cetegories during project creation (transaction already started in Project::create()) + * + * @access public + * @param integer $project_id + */ + public function createDefaultCategories($project_id) + { + $categories = explode(',', $this->config->get('project_categories')); + + foreach ($categories as $category) { + + $category = trim($category); + + if (! empty($category)) { + $this->db->table(self::TABLE)->insert(array( + 'project_id' => $project_id, + 'name' => $category, + )); + } + } + } + + /** + * Create a category (run inside a transaction) * * @access public * @param array $values Form values diff --git a/app/Model/Project.php b/app/Model/Project.php index 9c0adee9..278fe6ab 100644 --- a/app/Model/Project.php +++ b/app/Model/Project.php @@ -298,6 +298,8 @@ class Project extends Base $this->projectPermission->allowUser($project_id, $user_id); } + $this->category->createDefaultCategories($project_id); + $this->db->closeTransaction(); return (int) $project_id; |