Example #1
0
 /**
  * View details of an event
  *
  * @return     void
  */
 public function detailsTask()
 {
     // 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, 'request');
     // Load event
     $row = new Event($this->database);
     $row->load($id);
     // Ensure we have an event
     if (!$row || !$row->id) {
         App::abort(404, Lang::txt('EVENTS_CAL_LANG_NO_EVENTFOR') . ' ' . Lang::txt('EVENTS_CAL_LANG_THIS_DAY'));
     }
     //is this a group rescricted event
     if ($row->scope == 'group') {
         $group = \Hubzero\User\Group::getInstance($row->scope_id);
         //if we have a group and we are a member
         if (is_object($group)) {
             //redirect to group calendar
             $redirect = Route::url('index.php?option=com_groups&cn=' . $group->get('cn') . '&active=calendar&action=details&event_id=' . $row->id, false);
             App::redirect($redirect);
             return;
         } else {
             App::abort(404, Lang::txt('EVENTS_CAL_LANG_NO_EVENTFOR') . ' ' . Lang::txt('EVENTS_CAL_LANG_THIS_DAY'));
             return;
         }
     }
     $event_up = new EventsDate($row->publish_up);
     $row->start_date = Html::getDateFormat($event_up->year, $event_up->month, $event_up->day, 0);
     $row->start_time = defined('_CAL_USE_STD_TIME') && _CAL_USE_STD_TIME == 'YES' ? $event_up->get12hrTime() : $event_up->get24hrTime();
     $event_down = new EventsDate($row->publish_down);
     $row->stop_date = Html::getDateFormat($event_down->year, $event_down->month, $event_down->day, 0);
     $row->stop_time = defined('_CAL_USE_STD_TIME') && _CAL_USE_STD_TIME == 'YES' ? $event_down->get12hrTime() : $event_down->get24hrTime();
     // Kludge for overnight events, advance the displayed stop_date by 1 day when an overnighter is detected
     if ($row->stop_time < $row->start_time) {
         $event_down->addDays(1);
     }
     // Get time zone name (i.e. not just offset - ex: '-5')
     //$row->time_zone = Html::getTimeZoneName($row->time_zone);
     // Parse http and mailto
     $alphadigit = "([a-z]|[A-Z]|[0-9])";
     // Adresse
     $row->adresse_info = preg_replace("/(mailto:\\/\\/)?((-|{$alphadigit}|\\.)+)@((-|{$alphadigit}|\\.)+)(\\.{$alphadigit}+)/i", "<a href=\"mailto:\$2@\$5\$8\">\$2@\$5\$8</a>", $row->adresse_info);
     $row->adresse_info = preg_replace("/(http:\\/\\/|https:\\/\\/)((-|{$alphadigit}|\\.)+)(\\.{$alphadigit}+)/i", "<a href=\"\$1\$2\$5\$8\">\$1\$2\$5\$8</a>", $row->adresse_info);
     // Contact
     $row->contact_info = stripslashes(strip_tags($row->contact_info));
     if (substr($row->contact_info, 0, strlen('mailto:')) == 'mailto:') {
         $row->contact_info = '<a href="mailto:' . $this->obfuscate(substr($row->contact_info, strlen('mailto:'))) . '">' . $this->obfuscate(substr($row->contact_info, strlen('mailto:'))) . '</a>';
     } else {
         if (preg_match("/^[_\\.\\%0-9a-zA-Z-]+@([0-9a-zA-Z-]+\\.)+[a-zA-Z]{2,6}\$/i", $row->contact_info)) {
             $row->contact_info = '<a href="mailto:' . $this->obfuscate($row->contact_info) . '">' . $this->obfuscate($row->contact_info) . '</a>';
         }
     }
     //$row->contact_info = preg_replace("/(mailto:\/\/)?((-|$alphadigit|\.)+)@((-|$alphadigit|\.)+)(\.$alphadigit+)/i", "<a href=\"mailto:$2@$5$8\">$2@$5$8</a>", $row->contact_info);
     $row->contact_info = preg_replace("/(http:\\/\\/|https:\\/\\/)((-|{$alphadigit}|\\.)+)(\\.{$alphadigit}+)/i", "<a href=\"\$1\$2\$5\$8\">\$1\$2\$5\$8</a>", $row->contact_info);
     $fields = $this->config->getCfg('fields');
     if (!empty($fields)) {
         for ($i = 0, $n = count($fields); $i < $n; $i++) {
             // Explore the text and pull out all matches
             array_push($fields[$i], self::parseTag($row->content, $fields[$i][0]));
             // Clean the original text of any matches
             $row->content = str_replace('<ef:' . $fields[$i][0] . '>' . end($fields[$i]) . '</ef:' . $fields[$i][0] . '>', '', $row->content);
         }
         $row->content = trim($row->content);
     }
     $bits = explode('-', $row->publish_up);
     $eyear = $bits[0];
     $emonth = $bits[1];
     $edbits = explode(' ', $bits[2]);
     $eday = $edbits[0];
     // Everyone has access unless restricted to admins in the configuration
     $authorized = true;
     $auth = true;
     if (User::isGuest()) {
         $auth = false;
     }
     if ($this->config->getCfg('adminlevel')) {
         $auth = $this->_authorize();
     }
     // Get a list of categories
     $categories = $this->_getCategories();
     // Get tags on this event
     $rt = new Tags($row->id);
     $tags = $rt->render();
     // Set the page title
     Document::setTitle(Lang::txt(strtoupper($this->_name)) . ': ' . Lang::txt(strtoupper($this->_name) . '_' . strtoupper($this->_task)) . ': ' . stripslashes($row->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($row->title), 'index.php?option=' . $this->_option . '&task=details&id=' . $row->id);
     // Incoming
     $alias = Request::getVar('page', '');
     // Load the current page
     $page = new Page($this->database);
     if ($alias) {
         $page->loadFromAlias($alias, $row->id);
     }
     // Get the pages for this workshop
     $pages = $page->loadPages($row->id);
     if ($alias) {
         Pathway::append(stripslashes($page->title), 'index.php?option=' . $this->_option . '&task=details&id=' . $row->id . '&page=' . $page->alias);
     }
     // Build the HTML
     $this->view->setLayout('default')->setName('details');
     if (Request::getVar('no_html', 0)) {
         $this->view->setLayout('modal');
     }
     $this->view->option = $this->_option;
     $this->view->title = Lang::txt(strtoupper($this->_name)) . ': ' . Lang::txt(strtoupper($this->_name) . '_' . strtoupper($this->_task));
     $this->view->task = $this->_task;
     $this->view->year = $eyear;
     $this->view->month = $emonth;
     $this->view->day = $eday;
     $this->view->row = $row;
     $this->view->authorized = $authorized;
     $this->view->fields = $fields;
     $this->view->config = $this->config;
     $this->view->categories = $categories;
     $this->view->offset = $offset;
     $this->view->tags = $tags;
     $this->view->auth = $auth;
     $this->view->page = $page;
     $this->view->pages = $pages;
     foreach ($this->getErrors() as $error) {
         $this->view->setError($error);
     }
     $this->view->display();
 }