summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-10-07 12:21:02 -0400
committerFrédéric Guillot <fred@kanboard.net>2014-10-07 12:21:02 -0400
commitf7fa47fa35cde502317fbc92ca90278541cd628a (patch)
treee10a30c42ded79de8bcee72d19e7ab9fc1b32ab9 /app
parent86928e37bced3d99f5cc2f449fb458c2344fd317 (diff)
Only send notifications to project members (#299)
Diffstat (limited to 'app')
-rw-r--r--app/Model/Notification.php28
1 files changed, 22 insertions, 6 deletions
diff --git a/app/Model/Notification.php b/app/Model/Notification.php
index 3c14caf0..4b7ae50f 100644
--- a/app/Model/Notification.php
+++ b/app/Model/Notification.php
@@ -28,6 +28,27 @@ class Notification extends Base
const TABLE = 'user_has_notifications';
/**
+ * Get a list of people with notifications enabled
+ *
+ * @access public
+ * @param integer $project_id Project id
+ * @param array $exlude_users List of user_id to exclude
+ * @return array
+ */
+ public function getUsersWithNotification($project_id, array $exclude_users = array())
+ {
+ return $this->db
+ ->table(ProjectPermission::TABLE)
+ ->columns(User::TABLE.'.id', User::TABLE.'.username', User::TABLE.'.name', User::TABLE.'.email')
+ ->join(User::TABLE, 'id', 'user_id')
+ ->eq('project_id', $project_id)
+ ->eq('notifications_enabled', '1')
+ ->neq('email', '')
+ ->notin(User::TABLE.'.id', $exclude_users)
+ ->findAll();
+ }
+
+ /**
* Get the list of users to send the notification for a given project
*
* @access public
@@ -42,12 +63,7 @@ class Notification extends Base
$exclude_users[] = $this->acl->getUserId();
}
- $users = $this->db->table(User::TABLE)
- ->columns('id', 'username', 'name', 'email')
- ->eq('notifications_enabled', '1')
- ->neq('email', '')
- ->notin('id', $exclude_users)
- ->findAll();
+ $users = $this->getUsersWithNotification($project_id, $exclude_users);
foreach ($users as $index => $user) {