Beispiel #1
0
 /**
  * Send scheduled group announcements
  *
  * @param   object   $job  \Components\Cron\Models\Job
  * @return  boolean
  */
 public function sendGroupAnnouncements(\Components\Cron\Models\Job $job)
 {
     // Get all announcements that are not yet sent but want to be mailed
     $announcements = \Hubzero\Item\Announcement::all()->whereEquals('email', 1)->whereEquals('sent', 0)->whereEquals('state', 1)->whereEquals('scope', 'group')->rows();
     include_once dirname(dirname(__DIR__)) . DS . 'groups' . DS . 'announcements' . DS . 'announcements.php';
     // Loop through each announcement
     foreach ($announcements as $announcement) {
         // check to see if we can send
         if ($announcement->inPublishWindow()) {
             // get all group members
             $group = \Hubzero\User\Group::getInstance($announcement->get('scope_id'));
             if (plgGroupsAnnouncements::send($announcement, $group)) {
                 // mark as sent
                 $announcement->set('sent', 1);
                 $announcement->save();
             }
         }
     }
     return true;
 }
 /**
  * Display a list of all announcements
  *
  * @return  string  HTML
  */
 private function _list()
 {
     //build array of filters
     $filters = array('search' => strtolower(Request::getVar('q', '')), 'scope' => 'group', 'scope_id' => $this->group->get('gidNumber'), 'state' => 1);
     // Find announcements
     $model = \Hubzero\Item\Announcement::all()->whereEquals('scope', 'group')->whereEquals('scope_id', $this->group->get('gidNumber'))->whereEquals('state', \Hubzero\Item\Announcement::STATE_PUBLISHED);
     if ($filters['search']) {
         $model->whereLike('content', $filters['search']);
     }
     // Only get published announcements for members
     if ($this->authorized != 'manager') {
         $model->whereEquals('publish_up', '0000-00-00 00:00:00', 1)->orWhere('publish_up', '<=', Date::toSql(), 1)->resetDepth()->whereEquals('publish_down', '0000-00-00 00:00:00', 1)->orWhere('publish_down', '>=', Date::toSql(), 1);
     }
     $rows = $model->ordered()->paginated()->rows();
     $this->total = $rows->count();
     // Create view and assign data
     $view = $this->view('default', 'browse')->set('option', $this->option)->set('authorized', $this->authorized)->set('group', $this->group)->set('name', $this->_name)->set('filters', $filters)->set('rows', $rows)->setError($this->getErrors());
     // Display list of announcements
     return $view->loadTemplate();
 }