summaryrefslogtreecommitdiff
path: root/app/Model/UserNotification.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-03-27 15:32:29 -0400
committerFrederic Guillot <fred@kanboard.net>2016-03-27 15:32:29 -0400
commitf11fccd0d78ab037e77cd973a9168eedcb609fc2 (patch)
treeb98b3e8fb4b7c6a5161503877b81fb4ca1237eeb /app/Model/UserNotification.php
parent9ba44a01dbb187f4c931e1ba838e2bad258d34f4 (diff)
Fix bad unique constraints in Mysql table user_has_notifications
Diffstat (limited to 'app/Model/UserNotification.php')
-rw-r--r--app/Model/UserNotification.php19
1 files changed, 8 insertions, 11 deletions
diff --git a/app/Model/UserNotification.php b/app/Model/UserNotification.php
index e8a967ac..7795da2e 100644
--- a/app/Model/UserNotification.php
+++ b/app/Model/UserNotification.php
@@ -117,23 +117,20 @@ class UserNotification extends Base
*/
public function saveSettings($user_id, array $values)
{
- $this->db->startTransaction();
+ $types = empty($values['notification_types']) ? array() : array_keys($values['notification_types']);
- if (isset($values['notifications_enabled']) && $values['notifications_enabled'] == 1) {
+ if (! empty($types)) {
$this->enableNotification($user_id);
-
- $filter = empty($values['notifications_filter']) ? UserNotificationFilter::FILTER_BOTH : $values['notifications_filter'];
- $projects = empty($values['notification_projects']) ? array() : array_keys($values['notification_projects']);
- $types = empty($values['notification_types']) ? array() : array_keys($values['notification_types']);
-
- $this->userNotificationFilter->saveFilter($user_id, $filter);
- $this->userNotificationFilter->saveSelectedProjects($user_id, $projects);
- $this->userNotificationType->saveSelectedTypes($user_id, $types);
} else {
$this->disableNotification($user_id);
}
- $this->db->closeTransaction();
+ $filter = empty($values['notifications_filter']) ? UserNotificationFilter::FILTER_BOTH : $values['notifications_filter'];
+ $project_ids = empty($values['notification_projects']) ? array() : array_keys($values['notification_projects']);
+
+ $this->userNotificationFilter->saveFilter($user_id, $filter);
+ $this->userNotificationFilter->saveSelectedProjects($user_id, $project_ids);
+ $this->userNotificationType->saveSelectedTypes($user_id, $types);
}
/**