/** * Delete an event * * @return void */ public function deleteTask() { // Check if they are logged in if (User::isGuest()) { $this->loginTask(); return; } // Incoming $id = Request::getInt('id', 0, 'request'); // Ensure we have an ID to work with if (!$id) { App::redirect(Route::url('index.php?option=' . $this->_option)); return; } // Load event object $event = new Event($this->database); $event->load($id); // Are they authorized to delete this event? Do they own it? Own it! if (!$this->_authorize($event->created_by) && !(User::get('id') == $event->created_by)) { App::redirect(Route::url('index.php?option=' . $this->_option)); return; } $event->state = 0; //unpublish the event $event->store(); // Delete the event /* [!] No! Don't! True record deletion should only occur on the amdin side! - zooley 10/2013 $event->delete($id); // Delete any associated pages $ep = new Page($this->database); $ep->deletePages($id); // Delete any associated respondents $er = new Respondent(array()); $er->deleteRespondents($id); // Delete tags on this event $rt = new EventsModelTags($id); $rt->removeAll(); // Load the event's category and update the count $category = new Category($this->database); $category->updateCount($event->catid); */ // E-mail subject line $subject = '[' . Config::get('sitename') . ' ' . Lang::txt('EVENTS') . '] - ' . Lang::txt('EVENTS_EVENT_DELETED'); // Build the message to be e-mailed $eview = new View(array('name' => 'emails', 'layout' => 'deleted')); $eview->option = $this->_option; $eview->sitename = Config::get('sitename'); $eview->user = User::getInstance(); $eview->event = $event; $message = $eview->loadTemplate(); $message = str_replace("\n", "\r\n", $message); // Send the e-mail $this->_sendMail(Config::get('sitename'), Config::get('mailfrom'), $subject, $message); // Go back to the default front page App::redirect(Route::url('index.php?option=' . $this->_option)); }
/** * Set the event type * * @return void */ public function settypeTask() { // Incoming $ids = Request::getVar('id', array()); if (!is_array($ids)) { $ids = array(); } // Make sure we have an ID if (empty($ids)) { App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false)); return; } switch (strtolower(Request::getVar('type', 'event'))) { case 'announcement': $v = 1; break; case 'event': default: $v = 0; break; } // Loop through the IDs and publish the event foreach ($ids as $id) { // Instantiate an event object $event = new Event($this->database); $event->load($id); $event->announcement = $v; if (!$event->store()) { throw new Exception($event->getError(), 500); } } // Redirect App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false)); }