From 472f94efee77d8f47ece4ead7d36ee02e5df3e56 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 17 Oct 2015 12:30:05 -0400 Subject: Move webhook to project notification type --- app/Model/ProjectNotificationType.php | 57 +++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 app/Model/ProjectNotificationType.php (limited to 'app/Model/ProjectNotificationType.php') diff --git a/app/Model/ProjectNotificationType.php b/app/Model/ProjectNotificationType.php new file mode 100644 index 00000000..d8568589 --- /dev/null +++ b/app/Model/ProjectNotificationType.php @@ -0,0 +1,57 @@ +db + ->table(self::TABLE) + ->eq('project_id', $project_id) + ->asc('notification_type') + ->findAllByColumn('notification_type'); + + return array_merge($this->getHiddenTypes(), $selectedTypes); + } + + /** + * 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); + } +} -- cgit v1.2.3