• Main Page
  • Modules
  • Classes
  • Files
  • File List

classes/press/NotificationStatusDAO.inc.php

00001 <?php
00002 
00016 class NotificationStatusDAO extends DAO {
00020    function NotificationStatusDAO() {
00021       parent::DAO();
00022    }
00023 
00024    function &getPressNotifications($userId) {
00025       $returner = array();
00026 
00027       $result =& $this->retrieve(
00028          'SELECT p.press_id AS press_id, n.press_id AS notification FROM presses p LEFT JOIN notification_status n ON p.press_id = n.press_id AND n.user_id = ? ORDER BY p.seq',
00029          $userId
00030       );
00031 
00032       while (!$result->EOF) {
00033          $row =& $result->GetRowAssoc(false);
00034          $returner[$row['press_id']] = $row['notification'];
00035          $result->MoveNext();
00036       }
00037 
00038       $result->Close();
00039       unset($result);
00040 
00041       return $returner;
00042    }
00043 
00050    function setPressNotifications($pressId, $userId, $notificationStatus) {
00051       return $this->update(
00052          ($notificationStatus ? 'INSERT INTO notification_status (user_id, press_id) VALUES (?, ?)':
00053          'DELETE FROM notification_status WHERE user_id = ? AND press_id = ?'),
00054          array($userId, $pressId)
00055       );
00056    }
00057 
00062    function deleteNotificationStatusByPress($pressId) {
00063       return $this->update(
00064          'DELETE FROM notification_status WHERE press_id = ?', $pressId
00065       );
00066    }
00067 
00072    function deleteNotificationStatusByUserId($userId) {
00073       return $this->update(
00074          'DELETE FROM notification_status WHERE user_id = ?', $userId
00075       );
00076    }
00077 
00083    function &getNotifiableUsersByPressId($pressId) {
00084       $userDao =& DAORegistry::getDAO('UserDAO');
00085 
00086       $result =& $this->retrieve(
00087          'SELECT u.* FROM users u, notification_status n WHERE u.user_id = n.user_id AND n.press_id = ?',
00088          $pressId
00089       );
00090 
00091       $returner = new DAOResultFactory($result, $userDao, '_returnUserFromRow');
00092       return $returner;
00093    }
00094 
00100    function getNotifiableUsersCount($pressId) {
00101       $userDao =& DAORegistry::getDAO('UserDAO');
00102 
00103       $result =& $this->retrieve(
00104          'SELECT count(*) FROM notification_status n WHERE n.press_id = ?',
00105          $pressId
00106       );
00107 
00108       $returner = $result->fields[0];
00109 
00110       $result->Close();
00111       unset($result);
00112 
00113       return $returner;
00114    }
00115 }
00116 
00117 ?>

Generated on Mon Sep 17 2012 13:58:55 for Open Monograph Press by  doxygen 1.7.1