Exemplo n.º 1
0
 /**
  * Mark an entry as deleted
  *
  * @return     string HTML
  */
 private function _delete()
 {
     //verify were authorized
     if ($this->authorized != 'manager') {
         $this->setError(Lang::txt('PLG_GROUPS_ANNOUNCEMENTS_ONLY_MANAGERS_CAN_DELETE'));
         return $this->_list();
     }
     // Incoming
     $id = Request::getInt('id', 0);
     //announcement model
     $announcement = new \Hubzero\Item\Announcement($this->database);
     $announcement->load($id);
     //load created by user profile
     $profile = \Hubzero\User\Profile::getInstance($announcement->created_by);
     //make sure we are the one who created it
     if ($announcement->created_by != User::get('id')) {
         $this->setError(Lang::txt('PLG_GROUPS_ANNOUNCEMENTS_ONLY_MANAGER_CAN_DELETE', $profile->get('name')));
         return $this->_list();
     }
     //set to deleted state
     $announcement->archive();
     //attempt to delete announcement
     if (!$announcement->save($announcement)) {
         $this->setError(Lang::txt('PLG_GROUPS_ANNOUNCEMENTS_UNABLE_TO_DELETE'));
         return $this->_list();
     }
     App::redirect(Route::url('index.php?option=' . $this->option . '&cn=' . $this->group->get('cn') . '&active=announcements'), Lang::txt('PLG_GROUPS_ANNOUNCEMENTS_SUCCESSFULLY_DELETED'), 'success');
     return;
 }
Exemplo n.º 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;
 }