/** * Constructor. * Reads in the specified class, if $id is set. If $id is zero, * then a new entry is being created. * * @param string $ev_id Optional event ID * @param integer $detail Optional detail record ID for single repeat */ public function __construct($ev_id = '', $detail = 0) { global $_CONF, $_EV_CONF, $_USER; $this->isNew = true; if ($ev_id == '') { $this->id = ''; $this->recurring = 0; $this->rec_data = array(); $this->allday = 0; $this->split = 0; $this->status = 1; // assume "enabled" $this->show_upcoming = 1; // show in upcoming events by default $this->postmode = 'plaintext'; $this->hits = 0; $this->enable_reminders = 1; $this->categories = array(); $this->owner_id = $_USER['uid']; $this->group_id = 13; // Create dates & times based on individual URL parameters, // or defaults. // Start date/time defaults to now $dt = new Date('now', $_CONF['timezone']); $startday1 = isset($_GET['day']) ? (int) $_GET['day'] : ''; if ($startday1 < 1 || $startday1 > 31) { $startday1 = $dt->format('j', true); } $startmonth1 = isset($_GET['month']) ? (int) $_GET['month'] : ''; if ($startmonth1 < 1 || $startmonth1 > 12) { $startmonth1 = $dt->format('n', true); } $startyear1 = isset($_GET['year']) ? (int) $_GET['year'] : $dt->format('Y', true); $starthour1 = isset($_GET['hour']) ? (int) $_GET['hour'] : $dt->format('H', true); $startminute1 = '0'; // End date & time defaults to same day, 1 hour ahead $endday1 = $startday1; $endmonth1 = $startmonth1; $endyear1 = $startyear1; $endhour1 = $starthour1 != '' ? $starthour1 + 1 : ''; $endminute1 = '0'; // Second start & end times default to the same as the first. // They'll get reset if this ends up not being a split event. $starthour2 = $starthour1; $startminute2 = $startminute1; $endhour2 = $endhour1; $endminute2 = $endminute1; $this->date_start1 = sprintf("%4d-%02d-%02d", $startyear1, $startmonth1, $startday1); $this->time_start1 = sprintf("%02d:%02d:00", $starthour1, $startminute1); $this->time_start2 = sprintf("%02d:%02d:00", $starthour2, $startminute2); $this->date_end1 = sprintf("%4d-%02d-%02d", $endyear1, $endmonth1, $endday1); $this->time_end1 = sprintf("%02d:%02d:00", $endhour1, $endminute1); $this->time_end2 = sprintf("%02d:%02d:00", $endhour2, $endminute2); $this->perm_owner = $_EV_CONF['default_permissions'][0]; $this->perm_group = $_EV_CONF['default_permissions'][1]; $this->perm_members = $_EV_CONF['default_permissions'][2]; $this->perm_anon = $_EV_CONF['default_permissions'][3]; $this->options = array('use_rsvp' => 0, 'max_rsvp' => 0, 'rsvp_cutoff' => 0, 'rsvp_waitlist' => 0, 'ticket_types' => array(), 'contactlink' => '', 'max_user_rsvp' => 1); if ($_EV_CONF['rsvp_print'] <= 1) { // default "no" $this->options['rsvp_print'] = 0; } else { $this->options['rsvp_print'] = $_EV_CONF['rsvp_print'] - 1; } $this->Detail = new evDetail(); } else { $this->id = $ev_id; if (!$this->Read()) { $this->id = ''; } else { // Load the Detail object. May need to load a special one // if we're editing a repeat instance. if ($detail > 0 && $detail != $this->det_id) { $this->Detail = new evDetail($detail); } else { // Normal, load our own detail object $this->Detail = new evDetail($this->det_id); } } //var_dump($this);die; } $this->isAdmin = SEC_hasRights('evlist.admin') ? 1 : 0; //$this->isSubmitter = $this->isAdmin || SEC_hasRights('evlist.submit') ? // 1 : 0; $this->isSubmitter = EVLIST_canSubmit(); }
/** * Create a list of events * * @param integer $range Range indicator (upcoming, past, etc) * @param integer $category Category to limit search * @param string $block_title Title of block * @return string HTML for list page */ function EVLIST_listview($range = '', $category = '', $calendar = '', $block_title = '') { global $_CONF, $_EV_CONF, $_USER, $_TABLES, $LANG_EVLIST; EVLIST_setViewSession('list', $year, $month, $day); $retval = ''; $T = new Template(EVLIST_PI_PATH . '/templates/'); $T->set_file('index', 'index.thtml'); //if ($_EV_CONF['_can_add']) { if (EVLIST_canSubmit()) { $add_event_link = EVLIST_URL . '/event.php?edit=x'; } else { $add_event_link = ''; } $T->set_var(array('action' => EVLIST_URL . '/index.php', 'range_options' => EVLIST_GetOptions($LANG_EVLIST['ranges'], $range), 'add_event_link' => $add_event_link, 'add_event_text' => $LANG_EVLIST['add_event'], 'rangetext' => $LANG_EVLIST['ranges'][$range])); $page = empty($_GET['page']) ? 1 : (int) $_GET['page']; $opts = array('cat' => $category, 'page' => $page, 'limit' => $_EV_CONF['limit_list'], 'cal' => $calendar); switch ($range) { case 1: // past $start = EV_MIN_DATE; $end = $_EV_CONF['_today']; $opts['order'] = 'DESC'; break; case 3: //this week $start = $_EV_CONF['_today']; $end = date('Y-m-d', strtotime('+1 week', $_EV_CONF['_today_ts'])); break; case 4: //this month $start = $_EV_CONF['_today']; $end = date('Y-m-d', strtotime('+1 month', $_EV_CONF['_today_ts'])); break; case 2: //upcoming //upcoming default: $start = $_EV_CONF['_today']; $end = EV_MAX_DATE; break; } $events = EVLIST_getEvents($start, $end, $opts); if (empty($events)) { //return empty list msg $T->set_var(array('title' => '', 'block_title' => $block_title, 'empty_listmsg' => $LANG_EVLIST['no_match'])); if (!empty($range)) { $andrange = '&range=' . $range; $T->set_var('range', $range); } else { $andrange = '&range=2'; } if (!empty($category)) { $andcat = '&cat=' . $category; $T->set_var('category', $category); } else { $andcat = ''; } } else { //populate list // So we don't call SEC_hasRights inside the loop $isAdmin = SEC_hasRights('evlist.admin'); $T->set_file(array('item' => 'list_item.thtml', 'editlinks' => 'edit_links.thtml', 'category_form' => 'category_dd.thtml')); if (!empty($range)) { $andrange = '&range=' . $range; $T->set_var('range', $range); } else { $andrange = '&range=2'; } if (!empty($category)) { $andcat = '&cat=' . $category; $T->set_var('category', $category); } else { $andcat = ''; } // Track events that have been shown so we show them only once. $already_shown = array(); foreach ($events as $date => $daydata) { foreach ($daydata as $A) { if (array_key_exists($A['rp_id'], $already_shown)) { continue; } else { $already_shown[$A['rp_id']] = 1; } $titlelink = COM_buildURL(EVLIST_URL . '/event.php?eid=' . $A['rp_id'] . $timestamp . $andrange . $andcat); $titlelink = '<a href="' . $titlelink . '">' . COM_stripslashes($A['title']) . '</a>'; $summary = PLG_replaceTags(COM_stripslashes($A['summary'])); $datesummary = sprintf($LANG_EVLIST['event_begins'], EVLIST_formattedDate(strtotime($A['rp_date_start']))); $morelink = COM_buildURL(EVLIST_URL . '/event.php?eid=' . $A['rp_id'] . $timestamp . $andrange . $andcat); $morelink = '<a href="' . $morelink . '">' . $LANG_EVLIST['read_more'] . '</a>'; if (empty($A['email'])) { $contactlink = $_CONF['site_url'] . '/profiles.php?uid=' . $A['owner_id']; } else { $contactlink = 'mailto:' . EVLIST_obfuscate($A['email']); } $contactlink = '<a href="' . $contactlink . '">' . $LANG_EVLIST['ev_contact'] . '</a>'; $T->set_var(array('title' => $titlelink, 'date_summary' => $datesummary, 'summary' => $summary, 'more_link' => $morelink, 'contact_link' => $contactlink, 'contact_name' => $A['contact'], 'owner_name' => COM_getDisplayName($A['owner_id']), 'block_title' => $block_title, 'category_links' => EVLIST_getCatLinks($A['ev_id'], $andrange), 'cal_id' => $A['cal_id'], 'cal_name' => $A['cal_name'], 'cal_fgcolor' => $A['fgcolor'], 'cal_bgcolor' => $A['bgcolor'])); $T->parse('event_item', 'item', true); } } } $T->parse('output', 'index'); $retval .= $T->finish($T->get_var('output')); // Set page navigation $retval .= EVLIST_pagenav($start, $end, $category, $page, $range, $calendar); return $retval; }