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/ProjectNotificationTypeModel.php | 57 ++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 app/Model/ProjectNotificationTypeModel.php (limited to 'app/Model/ProjectNotificationTypeModel.php') diff --git a/app/Model/ProjectNotificationTypeModel.php b/app/Model/ProjectNotificationTypeModel.php new file mode 100644 index 00000000..aeec77f2 --- /dev/null +++ b/app/Model/ProjectNotificationTypeModel.php @@ -0,0 +1,57 @@ +db + ->table(self::TABLE) + ->eq('project_id', $project_id) + ->asc('notification_type') + ->findAllByColumn('notification_type'); + + return $this->filterTypes($types); + } + + /** + * Save notification types for a given project + * + * @access public + * @param integer $project_id + * @param string[] $types + * @return boolean + */ + public function saveSelectedTypes($project_id, array $types) + { + $results = array(); + $this->db->table(self::TABLE)->eq('project_id', $project_id)->remove(); + + foreach ($types as $type) { + $results[] = $this->db->table(self::TABLE)->insert(array('project_id' => $project_id, 'notification_type' => $type)); + } + + return ! in_array(false, $results, true); + } +} -- cgit v1.2.3