00001 <?php
00002
00015
00016
00017 class NotificationStatusDAO extends DAO {
00018 function &getSchedConfNotifications($userId) {
00019 $returner = array();
00020
00021 $result =& $this->retrieve(
00022 'SELECT j.sched_conf_id AS sched_conf_id, n.sched_conf_id AS notification FROM sched_confs j LEFT JOIN notification_status n ON j.sched_conf_id = n.sched_conf_id AND n.user_id = ? ORDER BY j.seq',
00023 $userId
00024 );
00025
00026 while (!$result->EOF) {
00027 $row =& $result->GetRowAssoc(false);
00028 $returner[$row['sched_conf_id']] = $row['notification'];
00029 $result->moveNext();
00030 }
00031
00032 $result->Close();
00033 unset($result);
00034
00035 return $returner;
00036 }
00037
00044 function setSchedConfNotifications($schedConfId, $userId, $notificationStatus) {
00045 return $this->update(
00046 ($notificationStatus?'INSERT INTO notification_status (user_id, sched_conf_id) VALUES (?, ?)':
00047 'DELETE FROM notification_status WHERE user_id = ? AND sched_conf_id = ?'),
00048 array($userId, $schedConfId)
00049 );
00050 }
00051
00056 function deleteNotificationStatusBySchedConf($schedConfId) {
00057 return $this->update(
00058 'DELETE FROM notification_status WHERE sched_conf_id = ?', $schedConfId
00059 );
00060 }
00061
00066 function deleteNotificationStatusByUserId($userId) {
00067 return $this->update(
00068 'DELETE FROM notification_status WHERE user_id = ?', $userId
00069 );
00070 }
00071
00077 function &getNotifiableUsersBySchedConfId($schedConfId) {
00078 $userDao =& DAORegistry::getDAO('UserDAO');
00079
00080 $result =& $this->retrieve(
00081 'SELECT u.* FROM users u, notification_status n WHERE u.user_id = n.user_id AND n.sched_conf_id = ?',
00082 $schedConfId
00083 );
00084
00085 $returner = new DAOResultFactory($result, $userDao, '_returnUserFromRow');
00086 return $returner;
00087 }
00088
00094 function getNotifiableUsersCount($schedConfId) {
00095 $userDao =& DAORegistry::getDAO('UserDAO');
00096
00097 $result =& $this->retrieve(
00098 'SELECT count(*) FROM notification_status n WHERE n.sched_conf_id = ?',
00099 $schedConfId
00100 );
00101
00102 $returner = $result->fields[0];
00103
00104 $result->Close();
00105 unset($result);
00106
00107 return $returner;
00108 }
00109 }
00110
00111 ?>