From 14713b0ec7ed93ca45578da069ad4e19a7d8addf Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 28 May 2016 19:48:22 -0400 Subject: Rename all models --- app/Model/ProjectNotificationModel.php | 67 ++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 app/Model/ProjectNotificationModel.php (limited to 'app/Model/ProjectNotificationModel.php') diff --git a/app/Model/ProjectNotificationModel.php b/app/Model/ProjectNotificationModel.php new file mode 100644 index 00000000..aeeee4cd --- /dev/null +++ b/app/Model/ProjectNotificationModel.php @@ -0,0 +1,67 @@ +projectModel->getById($project_id); + + $types = array_merge( + $this->projectNotificationTypeModel->getHiddenTypes(), + $this->projectNotificationTypeModel->getSelectedTypes($project_id) + ); + + foreach ($types as $type) { + $this->projectNotificationTypeModel->getType($type)->notifyProject($project, $event_name, $event_data); + } + } + + /** + * Save settings for the given project + * + * @access public + * @param integer $project_id + * @param array $values + */ + public function saveSettings($project_id, array $values) + { + $this->db->startTransaction(); + + $types = empty($values['notification_types']) ? array() : array_keys($values['notification_types']); + $this->projectNotificationTypeModel->saveSelectedTypes($project_id, $types); + + $this->db->closeTransaction(); + } + + /** + * Read user settings to display the form + * + * @access public + * @param integer $project_id + * @return array + */ + public function readSettings($project_id) + { + return array( + 'notification_types' => $this->projectNotificationTypeModel->getSelectedTypes($project_id), + ); + } +} -- cgit v1.2.3