/** * Move an item one down or own up int he ordering * * @param string $move Direction to move * @return void */ protected function reorderTask($move = 'down') { // Check for request forgeries Request::checkToken(['get', 'post']); // Incoming $id = Request::getVar('id', array()); $id = $id[0]; $pid = Request::getInt('event', 0); // Ensure we have an ID to work with if (!$id) { App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_EVENTS_PAGE_NO_ID'), 'error'); return; } // Ensure we have a parent ID to work with if (!$pid) { App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_EVENTS_PAGE_NO_EVENT_ID'), 'error'); return; } // Get the element moving down - item 1 $page1 = new Page($this->database); $page1->load($id); // Get the element directly after it in ordering - item 2 $page2 = clone $page1; $page2->getNeighbor($this->_task); switch ($move) { case 'up': // Switch places: give item 1 the position of item 2, vice versa $orderup = $page2->ordering; $orderdn = $page1->ordering; $page1->ordering = $orderup; $page2->ordering = $orderdn; break; case 'down': // Switch places: give item 1 the position of item 2, vice versa $orderup = $page1->ordering; $orderdn = $page2->ordering; $page1->ordering = $orderdn; $page2->ordering = $orderup; break; } // Save changes $page1->store(); $page2->store(); // Redirect App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&id[]=' . $pid, false)); }
/** * Process event registration * * @return void */ public function processTask() { // Get some needed info $offset = $this->offset; $year = $this->year; $month = $this->month; $day = $this->day; $option = $this->_option; // Incoming $id = Request::getInt('id', 0, 'post'); // Ensure we have an ID if (!$id) { App::redirect(Route::url('index.php?option=' . $this->_option)); return; } // Load event $event = new Event($this->database); $event->load($id); $this->event = $event; // Ensure we have an event if (!$event->title) { App::redirect(Route::url('index.php?option=' . $this->_option)); return; } $auth = true; if ($this->config->getCfg('adminlevel')) { $auth = $this->_authorize(); } $bits = explode('-', $event->publish_up); $eyear = $bits[0]; $emonth = $bits[1]; $edbits = explode(' ', $bits[2]); $eday = $edbits[0]; $page = new Page($this->database); $page->alias = $this->_task; // Get the pages for this workshop $pages = $page->loadPages($event->id); // Set the page title Document::setTitle(Lang::txt(strtoupper($this->_name)) . ': ' . Lang::txt('EVENTS_REGISTER') . ': ' . stripslashes($event->title)); // Set the pathway if (Pathway::count() <= 0) { Pathway::append(Lang::txt(strtoupper($this->_name)), 'index.php?option=' . $this->_option); } Pathway::append($eyear, 'index.php?option=' . $this->_option . '&year=' . $eyear); Pathway::append($emonth, 'index.php?option=' . $this->_option . '&year=' . $eyear . '&month=' . $emonth); Pathway::append($eday, 'index.php?option=' . $this->_option . '&year=' . $eyear . '&month=' . $emonth . '&day=' . $eday); Pathway::append(stripslashes($event->title), 'index.php?option=' . $this->_option . '&task=details&id=' . $event->id); Pathway::append(Lang::txt('EVENTS_REGISTER'), 'index.php?option=' . $this->_option . '&task=details&id=' . $event->id . '&page=register'); // Incoming $register = Request::getVar('register', NULL, 'post'); $arrival = Request::getVar('arrival', NULL, 'post'); $departure = Request::getVar('departure', NULL, 'post'); $dietary = Request::getVar('dietary', NULL, 'post'); $bos = Request::getVar('bos', NULL, 'post'); $dinner = Request::getVar('dinner', NULL, 'post'); $disability = Request::getVar('disability', NULL, 'post'); $race = Request::getVar('race', NULL, 'post'); if ($register) { $register = array_map('trim', $register); $register = array_map(array('\\Hubzero\\Utility\\Sanitize', 'stripAll'), $register); $validemail = $this->_validEmail($register['email']); } if ($arrival) { $arrival = array_map('trim', $arrival); $arrival = array_map(array('\\Hubzero\\Utility\\Sanitize', 'stripAll'), $arrival); } if ($departure) { $departure = array_map('trim', $departure); $departure = array_map(array('\\Hubzero\\Utility\\Sanitize', 'stripAll'), $departure); } if ($dietary) { $dietary = array_map('trim', $dietary); $dietary = array_map(array('\\Hubzero\\Utility\\Sanitize', 'stripAll'), $dietary); } // check to make sure this is the only time registering if (Respondent::checkUniqueEmailForEvent($register['email'], $event->id) > 0) { $this->setError(Lang::txt('EVENTS_EVENT_REGISTRATION_PREVIOUS')); $validemail = 0; } if ($register['firstname'] && $register['lastname'] && $validemail == 1) { $email = $event->email; $subject = Lang::txt('EVENTS_EVENT_REGISTRATION') . ': ' . $event->title; $hub = array('email' => $register['email'], 'name' => Config::get('sitename') . ' ' . Lang::txt('EVENTS_EVENT_REGISTRATION')); $eview = new \Hubzero\Component\View(array('name' => 'register', 'layout' => 'email')); $eview->option = $this->_option; $eview->sitename = Config::get('sitename'); $eview->register = $register; $eview->race = $race; $eview->dietary = $dietary; $eview->disability = $disability; $eview->arrival = $arrival; $eview->departure = $departure; $eview->dinner = $dinner; $eview->bos = $bos; $message = $eview->loadTemplate(); $message = str_replace("\n", "\r\n", $message); // check to see if event manager email is configured if ($email != "" || $email != NULL || !isset($email)) { // one for the event manager $this->_sendEmail($hub, $email, $subject, $message); } // one for the attendee $this->_sendEmail($hub, $register['email'], $subject, $message); $this->_log($register); $this->view->setLayout('thanks'); } else { $this->view->setLayout('default'); } $this->view->setName('register'); $this->view->state = 'open'; $this->view->option = $this->_option; $this->view->title = Lang::txt(strtoupper($this->_name)) . ': ' . Lang::txt('EVENTS_REGISTER'); $this->view->task = $this->_task; $this->view->year = $year; $this->view->month = $month; $this->view->day = $day; $this->view->offset = $offset; $this->view->event = $event; $this->view->authorized = $auth; $this->view->page = $page; $this->view->pages = $pages; $this->view->register = $register; $this->view->arrival = $arrival; $this->view->departure = $departure; if ($this->getError()) { $this->view->setError($this->getError()); } $this->view->display(); }
/** * Remove one or more entries for an event * * @return void */ public function removeTask() { // 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; } // Instantiate an event object $event = new Event($this->database); // Instantiate a page object $ep = new Page($this->database); // Instantiate a respondent object $er = new Respondent(array()); // Loop through the IDs and unpublish the event foreach ($ids as $id) { // Instantiate an event tags object $rt = new Tags($id); // Delete tags on this event $rt->removeAll(); // Delete the event $event->delete($id); // Delete any associated pages $ep->deletePages($id); // Delete any associated respondents $er->deleteRespondents($id); } // Redirect App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_EVENTS_CAL_LANG_REMOVED')); }