/**
  * Display a list of all announcements
  *
  * @return     string HTML
  */
 private function _list()
 {
     // Get course members based on their status
     // Note: this needs to happen *after* any potential actions ar performed above
     $view = $this->view('default', 'browse');
     //vars for view
     $view->authorized = $this->authorized;
     $view->option = $this->option;
     $view->group = $this->group;
     $view->name = $this->_name;
     //build array of filters
     $view->filters = array();
     $view->filters['search'] = Request::getVar('q', '');
     $view->filters['limit'] = Request::getInt('limit', $this->params->get('display_limit', 50));
     $view->filters['start'] = Request::getInt('limitstart', 0);
     $view->filters['start'] = $view->filters['limit'] == 0 ? 0 : $view->filters['start'];
     $view->filters['scope'] = 'group';
     $view->filters['scope_id'] = $this->group->get('gidNumber');
     $view->filters['state'] = 1;
     //$view->filters['sticky']    = 0;
     //only get published announcements for members
     if ($view->authorized != 'manager') {
         $view->filters['published'] = 1;
     }
     //create new announcement Object
     $hubzeroAnnouncement = new \Hubzero\Item\Announcement($this->database);
     $view->total = $hubzeroAnnouncement->count($view->filters);
     $view->rows = $hubzeroAnnouncement->find($view->filters);
     //get any errors
     foreach ($this->getErrors() as $error) {
         $view->setError($error);
     }
     //display list of announcements
     return $view->loadTemplate();
 }
Beispiel #2
0
 /**
  * Send scheduled group announcements
  *
  * @param   object   $job  \Components\Cron\Models\Job
  * @return  boolean
  */
 public function sendGroupAnnouncements(\Components\Cron\Models\Job $job)
 {
     $database = App::get('db');
     // get hubzero announcement object
     $hubzeroAnnouncement = new \Hubzero\Item\Announcement($database);
     // get all announcements that are not yet sent but want to be mailed
     $announcements = $hubzeroAnnouncement->find(array('email' => 1, 'sent' => 0));
     // loop through each announcement
     foreach ($announcements as $announcement) {
         // load the announcement object
         $hubzeroAnnouncement->load($announcement->id);
         // check to see if we can send
         if ($hubzeroAnnouncement->announcementPublishedForDate()) {
             // email announcement
             $hubzeroAnnouncement->emailAnnouncement();
             // mark as sent
             $hubzeroAnnouncement->sent = 1;
             $hubzeroAnnouncement->save($hubzeroAnnouncement);
         }
     }
     return true;
 }