classes/announcement/AnnouncementDAO.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00016 // $Id$
00017 
00018 import('announcement.Announcement');
00019 import('announcement.PKPAnnouncementDAO');
00020 
00021 class AnnouncementDAO extends PKPAnnouncementDAO {
00022 
00023    function &getAnnouncementsByConferenceId($conferenceId, $schedConfId = 0, $rangeInfo = null) {
00024       $conferenceArgs = array(ASSOC_TYPE_CONFERENCE, $conferenceId);
00025       if($schedConfId == -1) {
00026          $schedConfDAO =& DAORegistry::getDAO('SchedConfDAO');
00027          $schedConfs = $schedConfDAO->getSchedConfsByConferenceId($conferenceId);
00028          $schedConfArgs = array();
00029          while (!$schedConfs->eof()) {
00030             $schedConf =& $schedConfs->next();        
00031             $schedConfArgs[] = ASSOC_TYPE_SCHED_CONF;
00032             $schedConfArgs[] = $schedConf->getId();
00033          }
00034       } else {
00035          $schedConfArgs = array(ASSOC_TYPE_SCHED_CONF, $schedConfId);
00036       }
00037 
00038       $result =& $this->retrieveRange(
00039          'SELECT *
00040          FROM announcements
00041          WHERE (assoc_type = ? AND assoc_id = ?)' .
00042             (count($schedConfArgs) ? str_repeat(' OR (assoc_type = ? AND assoc_id = ?)', count($schedConfArgs)/2):'') .
00043          ' ORDER BY announcement_id DESC',
00044          array_merge($conferenceArgs, $schedConfArgs),
00045          $rangeInfo
00046       );
00047 
00048       $returner = new DAOResultFactory($result, $this, '_returnAnnouncementFromRow');
00049       return $returner;
00050    }
00051 
00052    function &getAnnouncementsNotExpiredByConferenceId($conferenceId, $schedConfId = 0, $rangeInfo = null) {
00053 
00054       $conferenceArgs = array(ASSOC_TYPE_CONFERENCE, $conferenceId);
00055       if($schedConfId == -1) {
00056          $schedConfDAO =& DAORegistry::getDAO('SchedConfDAO');
00057          $schedConfs = $schedConfDAO->getSchedConfsByConferenceId($conferenceId);
00058          $schedConfArgs = array();
00059          while (!$schedConfs->eof()) {
00060             $schedConf =& $schedConfs->next();        
00061             $schedConfArgs[] = ASSOC_TYPE_SCHED_CONF;
00062             $schedConfArgs[] = $schedConf->getId();
00063          }
00064       } else {
00065          $schedConfArgs = array(ASSOC_TYPE_SCHED_CONF, $schedConfId);
00066       }
00067 
00068       $result =& $this->retrieveRange(
00069          'SELECT *
00070          FROM announcements
00071          WHERE (assoc_type = ? AND assoc_id = ?)' .
00072             (count($schedConfArgs) ? str_repeat(' OR (assoc_type = ? AND assoc_id = ?)', count($schedConfArgs)/2):'') .
00073             ' AND (date_expire IS NULL OR date_expire > CURRENT_DATE)
00074             ORDER BY announcement_id DESC',
00075          array_merge($conferenceArgs, $schedConfArgs),
00076          $rangeInfo
00077       );
00078 
00079       $returner = new DAOResultFactory($result, $this, '_returnAnnouncementFromRow');
00080       return $returner;
00081    }  
00082    
00083    function &getNumAnnouncementsNotExpiredByConferenceId($conferenceId, $schedConfId = 0, $numAnnouncements, $rangeInfo = null) {
00084       $conferenceArgs = array(ASSOC_TYPE_CONFERENCE, $conferenceId);
00085       if($schedConfId == -1) {
00086          $schedConfDAO =& DAORegistry::getDAO('SchedConfDAO');
00087          $schedConfs = $schedConfDAO->getSchedConfsByConferenceId($conferenceId);
00088          $schedConfArgs = array();
00089          while (!$schedConfs->eof()) {
00090             $schedConf =& $schedConfs->next();        
00091             $schedConfArgs[] = ASSOC_TYPE_SCHED_CONF;
00092             $schedConfArgs[] = $schedConf->getId();
00093          }
00094       } else {
00095          $schedConfArgs = array(ASSOC_TYPE_SCHED_CONF, $schedConfId);
00096       }
00097 
00098       $result =& $this->retrieveRange(
00099          'SELECT *
00100          FROM announcements
00101          WHERE (assoc_type = ? AND assoc_id = ?)' .
00102             (count($schedConfArgs) ? str_repeat(' OR (assoc_type = ? AND assoc_id = ?)', count($schedConfArgs)/2):'') .
00103             ' AND (date_expire IS NULL OR date_expire > CURRENT_DATE)
00104             ORDER BY announcement_id DESC LIMIT ?',
00105          array_merge($conferenceArgs, $schedConfArgs, array($numAnnouncements)),
00106          $rangeInfo
00107       );
00108 
00109       $returner = new DAOResultFactory($result, $this, '_returnAnnouncementFromRow');
00110       return $returner;
00111    }  
00112 }
00113 
00114 ?>

Generated on 25 Jul 2013 for Open Conference Systems by  doxygen 1.4.7