/** * Creates the edit form * @param integer $id Optional ID, current record used if zero * @return string HTML for edit form */ public function Edit($eid = '', $rp_id = 0, $saveaction = '') { global $_CONF, $_EV_CONF, $_TABLES, $_USER, $LANG_EVLIST, $LANG_ADMIN, $_GROUPS, $LANG_ACCESS, $_SYSTEM; // If an eid is specified and this is an object, then read the // event data- UNLESS a repeat ID is given in which case we're // editing a repeat and already have the info we need. // This probably needs to change, since we should always read event // data during construction. if (!$this->isSubmitter) { // At least submit privilege required COM_404(); } elseif ($eid != '' && $rp_id == 0 && is_object($this)) { // If an id is passed in, then read that record if (!$this->Read($eid)) { return 'Invalid object ID'; } } elseif (isset($_POST['eid']) && !empty($_POST['eid'])) { // Returning to an existing form, probably due to errors $this->SetVars($_POST); // Make sure the current user has access to this event. if (!$this->hasAccess(3)) { COM_404(); } } $T = new Template($_CONF['path'] . 'plugins/evlist/templates/'); if ($_SYSTEM['disable_jquery_slimbox']) { $T->set_file('editor', 'editor.uikit.thtml'); } else { $T->set_file('editor', 'editor.thtml'); } // Basic tabs for editing both events and instances, show up on // all edit forms //$tabs = array('ev_info', 'ev_schedule', 'ev_location', 'ev_contact',); $tabs = array('ev_info', 'ev_location', 'ev_contact'); $rp_id = (int) $rp_id; if ($rp_id > 0) { // Make sure the current user has access to this event. if (!$this->hasAccess(3)) { COM_404(); } if ($saveaction == 'savefuturerepeat') { $alert_msg = EVLIST_alertMessage($LANG_EVLIST['editing_future'], 'warning'); } else { $alert_msg = EVLIST_alertMessage($LANG_EVLIST['editing_instance'], 'info'); } //$T->clear_var('contact_section'); $T->clear_var('category_section'); $T->clear_var('permissions_editor'); // Set the static calendar name for the edit form. Can't // change it for a single instance. $cal_name = DB_getItem($_TABLES['evlist_calendars'], 'cal_name', "cal_id='" . (int) $this->cal_id . "'"); $T->set_var(array('contact_section' => 'true', 'is_repeat' => 'true', 'cal_name' => $cal_name)); // Override our dates & times with those from the repeat. // $rp_id is passed when this is called from class evRepeat. // Maybe that should pass in the repeat's data instead to avoid // another DB lookup. An array of values could be used. $Rep = DB_fetchArray(DB_query("SELECT * \n FROM {$_TABLES['evlist_repeat']}\n WHERE rp_id='{$rp_id}'"), false); if ($Rep) { $this->date_start1 = $Rep['rp_date_start']; $this->date_end1 = $Rep['rp_date_end']; $this->time_start1 = $Rep['rp_time_start1']; $this->time_end1 = $Rep['rp_time_end1']; $this->time_start2 = $Rep['rp_time_start2']; $this->time_end2 = $Rep['rp_time_end2']; } } else { // Editing the main event record if ($this->id != '' && $this->recurring == 1) { $alert_msg = EVLIST_alertMessage($LANG_EVLIST['editing_series'], 'error'); } if ($this->isAdmin) { $tabs[] = 'ev_perms'; // Add permissions tab, event edit only $T->set_var('permissions_editor', 'true'); } $T->set_var(array('contact_section' => 'true', 'category_section' => 'true', 'upcoming_chk' => $this->show_upcoming ? EVCHECKED : '')); } $action_url = EVLIST_URL . '/event.php'; $delaction = 'delevent'; if (isset($_GET['from']) && $_GET['from'] == 'admin') { $cancel_url = EVLIST_ADMIN_URL . '/index.php'; } else { $cancel_url = EVLIST_URL . '/index.php'; } switch ($saveaction) { case 'saverepeat': case 'savefuturerepeat': case 'saveevent': break; case 'moderate': // Approving a submission $saveaction = 'approve'; $delaction = 'disapprove'; $action_url = EVLIST_ADMIN_URL . '/index.php'; $cancel_url = $_CONF['site_admin_url'] . '/moderation.php'; break; default: $saveaction = 'saveevent'; break; } $retval = ''; //$recinterval = ''; $recweekday = ''; $ownerusername = DB_getItem($_TABLES['users'], 'username', "uid='{$this->owner_id}'"); $retval .= COM_startBlock($LANG_EVLIST['event_editor']); $summary = $this->Detail->summary; $full_description = $this->Detail->full_description; $location = $this->Detail->location; if (($this->isAdmin || $_EV_CONF['allow_html'] == '1' && $_USER['uid'] > 1) && $A['postmode'] == 'html') { $postmode = '2'; //html } else { $postmode = '1'; //plaintext $summary = htmlspecialchars(COM_undoClickableLinks(COM_undoSpecialChars($this->Detail->summary))); $full_description = htmlspecialchars(COM_undoClickableLinks(COM_undoSpecialChars($this->Detail->full_description))); $location = htmlspecialchars(COM_undoClickableLinks(COM_undoSpecialChars($this->Detail->location))); } $starthour2 = ''; $startminute2 = ''; $endhour2 = ''; $endminute2 = ''; if ($this->date_end1 == '' || $this->date_end1 == '0000-00-00') { $this->date_end1 = $this->date_start1; } if ($this->date_start1 != '' && $this->date_start1 != '0000-00-00') { list($startmonth1, $startday1, $startyear1, $starthour1, $startminute1) = $this->DateParts($this->date_start1, $this->time_start1); } else { list($startmonth1, $startday1, $startyear1, $starthour1, $startminute1) = $this->DateParts(date('Y-m-d', time()), date('H:i:s', time())); } // The end date can't be before the start date if ($this->date_end1 >= $this->date_start1) { list($endmonth1, $endday1, $endyear1, $endhour1, $endminute1) = $this->DateParts($this->date_end1, $this->time_end1); $days_interval = Date_Calc::dateDiff($endday1, $endmonth1, $endyear1, $startday1, $startmonth1, $startyear1); } else { $days_interval = 0; $endmonth1 = $startmonth1; $endday1 = $startday1; $endyear1 = $startyear1; $endhour1 = $starthour1; $endminute1 = $startminute1; } if ($this->recurring != '1') { $T->set_var(array('recurring_show' => ' style="display:none;"', 'format_opt' => '0')); //for ($i = 1; $i <= 6; $i++) { // $T->set_var('format' . $i . 'show', ' style="display:none;"'); //} } else { $option = empty($this->rec_data['type']) ? '0' : (int) $this->rec_data['type']; $T->set_var(array('recurring_show' => '', 'recurring_checked' => EVCHECKED, 'format_opt' => $option)); } if (isset($this->rec_data['stop']) && !empty($this->rec_data['stop'])) { $T->set_var(array('stopdate' => $this->rec_data['stop'], 'd_stopdate' => EVLIST_formattedDate($this->rec_data['stop']))); } if (!empty($this->rec_data['skip'])) { $T->set_var("skipnext{$this->rec_data['skip']}_checked", EVCHECKED); } if (!empty($this->rec_data['freq'])) { $freq = (int) $this->rec_data['freq']; if ($freq < 1) { $freq = 1; } } else { $freq = 1; } $T->set_var(array('freq_text' => $LANG_EVLIST['rec_periods'][$this->rec_data['type']] . '(s)', 'rec_freq' => $freq)); foreach ($LANG_EVLIST['rec_intervals'] as $key => $str) { $T->set_var('dom_int_txt_' . $key, $str); if (is_array($this->rec_data['interval'])) { if (in_array($key, $this->rec_data['interval'])) { $T->set_var('dom_int_chk_' . $key, EVCHECKED); } } } // Set up the recurring options needed for the current event switch ($option) { case 0: break; case EV_RECUR_MONTHLY: if (is_array($this->rec_data['listdays'])) { foreach ($this->rec_data['listdays'] as $mday) { $T->set_var('mdchk' . $mday, EVCHECKED); } } break; case EV_RECUR_WEEKLY: $T->set_var('listdays_val', COM_stripslashes($rec_data[0])); if (is_array($this->rec_data['listdays']) && !empty($this->rec_data['listdays'])) { foreach ($this->rec_data['listdays'] as $day) { $day = (int) $day; if ($day > 0 && $day < 8) { $T->set_var('daychk' . $day, EVCHECKED); } } } break; case EV_RECUR_DOM: $recweekday = $this->rec_data['weekday']; break; case EV_RECUR_DATES: $T->set_var(array('stopshow' => 'style="display:none;"', 'custom_val' => implode(',', $this->rec_data['custom']))); break; } $start1 = EVLIST_TimeSelect('start1', $this->time_start1); $start2 = EVLIST_TimeSelect('start2', $this->time_start2); $end1 = EVLIST_TimeSelect('end1', $this->time_end1); $end2 = EVLIST_TimeSelect('end2', $this->time_end2); $cal_select = COM_optionList($_TABLES['evlist_calendars'], 'cal_id,cal_name', $this->cal_id, 1, 'cal_status = 1 ' . COM_getPermSQL('AND', 0, 2)); USES_class_navbar(); $navbar = new navbar(); $cnt = 0; foreach ($tabs as $id) { $navbar->add_menuitem($LANG_EVLIST[$id], 'showhideEventDiv("' . $id . '",' . $cnt . ');return false;', true); $cnt++; } $navbar->set_selected($LANG_EVLIST['ev_info']); if ($this->AdminMode) { $action_url .= '?admin=true'; } $T->set_var(array('action_url' => $action_url, 'navbar' => $navbar->generate(), 'alert_msg' => $alert_msg, 'cancel_url' => $cancel_url, 'eid' => $this->id, 'rp_id' => $rp_id, 'title' => $this->Detail->title, 'summary' => $summary, 'description' => $full_description, 'location' => $location, 'status_checked' => $this->status == 1 ? EVCHECKED : '', 'url' => $this->Detail->url, 'street' => $this->Detail->street, 'city' => $this->Detail->city, 'province' => $this->Detail->province, 'country' => $this->Detail->country, 'postal' => $this->Detail->postal, 'contact' => $this->Detail->contact, 'email' => $this->Detail->email, 'phone' => $this->Detail->phone, 'startdate1' => $this->date_start1, 'enddate1' => $this->date_end1, 'd_startdate1' => EVLIST_formattedDate($this->date_start1), 'd_enddate1' => EVLIST_formattedDate($this->date_end1), 'start_hour_options1' => $start1['hour'], 'start_minute_options1' => $start1['minute'], 'startdate1_ampm' => $start1['ampm'], 'end_hour_options1' => $end1['hour'], 'end_minute_options1' => $end1['minute'], 'enddate1_ampm' => $end1['ampm'], 'start_hour_options2' => $start2['hour'], 'start_minute_options2' => $start2['minute'], 'startdate2_ampm' => $start2['ampm'], 'end_hour_options2' => $end2['hour'], 'end_minute_options2' => $end2['minute'], 'enddate2_ampm' => $end2['ampm'], 'recurring_format_options' => EVLIST_GetOptions($LANG_EVLIST['rec_formats'], $option), 'recurring_weekday_options' => EVLIST_GetOptions(Date_Calc::getWeekDays(), $recweekday, 1), 'dailystop_label' => sprintf($LANG_EVLIST['stop_label'], $LANG_EVLIST['day_by_date'], ''), 'monthlystop_label' => sprintf($LANG_EVLIST['stop_label'], $LANG_EVLIST['year_and_month'], $LANG_EVLIST['if_any']), 'yearlystop_label' => sprintf($LANG_EVLIST['stop_label'], $LANG_EVLIST['year'], $LANG_EVLIST['if_any']), 'listdays_label' => sprintf($LANG_EVLIST['custom_label'], $LANG_EVLIST['days_of_week'], ''), 'listdaystop_label' => sprintf($LANG_EVLIST['stop_label'], $LANG_EVLIST['date_l'], $LANG_EVLIST['if_any']), 'intervalstop_label' => sprintf($LANG_EVLIST['stop_label'], $LANG_EVLIST['year_and_month'], $LANG_EVLIST['if_any']), 'custom_label' => sprintf($LANG_EVLIST['custom_label'], $LANG_EVLIST['dates'], ''), 'datestart_note' => $LANG_EVLIST['datestart_note'], 'src' => isset($_GET['src']) && $_GET['src'] == 'a' ? '1' : '0', 'rem_status_checked' => $this->enable_reminders == 1 ? EVCHECKED : '', 'del_button' => $this->id == '' ? '' : 'true', 'saveaction' => $saveaction, 'delaction' => $delaction, 'owner_id' => $this->owner_id, 'enable_reminders' => $_EV_CONF['enable_reminders'], 'iso_lang' => EVLIST_getIsoLang(), 'hour_mode' => $_CONF['hour_mode'], 'days_interval' => $days_interval, 'display_format' => $_CONF['shortdate'], 'ts_start' => strtotime($this->date_start1), 'ts_end' => strtotime($this->date_end1), 'cal_select' => $cal_select, 'contactlink_chk' => $this->options['contactlink'] == 1 ? EVCHECKED : '', 'lat' => $this->Detail->lat, 'lng' => $this->Detail->lng, 'perm_msg' => $LANG_ACCESS['permmsg'], 'last' => $LANG_EVLIST['rec_intervals'][5], 'doc_url' => EVLIST_getDocURL('event.html'), 'mootools' => $_SYSTEM['disable_mootools'] ? '' : 'true')); if ($_EV_CONF['enable_rsvp']) { USES_evlist_class_tickettype(); $TickTypes = evTicketType::GetTicketTypes(); //$T->set_block('editor', 'Tickets', 'tTypes'); $tick_opts = ''; foreach ($TickTypes as $tick_id => $tick_obj) { // Check enabled tickets. Ticket type 1 enabled by default if (isset($this->options['tickets'][$tick_id]) || $tick_id == 1) { $checked = 'checked="checked"'; $fee = (double) $this->options['tickets'][$tick_id]['fee']; } else { $checked = ''; $fee = 0; } $tick_opts .= '<tr><td><input name="tickets[' . $tick_id . ']" type="checkbox" ' . $checked . ' value="' . $tick_id . '" /></td>' . '<td>' . $tick_obj->description . '</td>' . '<td><input type="text" name="tick_fees[' . $tick_id . ']" value="' . $fee . '" size="8" /></td></tr>' . LB; /*$T->set_var(array( 'tick_id' => $tic['id'], 'tick_desc' => $tic['description'], 'tick_fee' => $fee, 'tick_enabled' => $enabled ? 'checked="checked"' : '', ) ) ; //$T->parse('tTypes', 'Tickets', true);*/ } if ($_EV_CONF['rsvp_print'] > 0) { $rsvp_print_chk = 'rsvp_print_chk' . $this->options['rsvp_print']; $rsvp_print = 'true'; } else { $rsvp_print = ''; $rsvp_print_chk = 'no_rsvp_print'; } $T->set_var(array('enable_rsvp' => 'true', 'reg_chk' . $this->options['use_rsvp'] => EVCHECKED, 'rsvp_wait_chk' => $this->options['rsvp_waitlist'] == 1 ? EVCHECKED : '', 'max_rsvp' => $this->options['max_rsvp'], 'max_user_rsvp' => $this->options['max_user_rsvp'], 'rsvp_cutoff' => $this->options['rsvp_cutoff'], 'use_rsvp' => $this->options['use_rsvp'], 'rsvp_waitlist' => $this->options['rsvp_waitlist'], 'tick_opts' => $tick_opts, 'rsvp_print' => $rsvp_print, $rsvp_print_chk => 'checked="checked"')); } // if rsvp_enabled // Split & All-Day settings if ($this->allday == 1) { // allday, can't be split, no times $T->set_var(array('starttime1_show' => 'style="display:none;"', 'endtime1_show' => 'style="display:none;"', 'datetime2_show' => 'style="display:none;"', 'allday_checked' => EVCHECKED, 'split_checked' => '', 'split_show' => 'style="display:none;"')); } elseif ($this->split == '1') { $T->set_var(array('split_checked' => EVCHECKED, 'allday_checked' => '', 'allday_show' => 'style="display:none"')); } else { $T->set_var(array('datetime2_show' => 'style="display:none;"')); } // Category fields. If $_POST['categories'] is set, then this is a // form re-entry due to an error saving. Populate checkboxes from the // submitted form. Include the user-added category, if any. // If not from a form re-entry, get the checked categories from the // evlist_lookup table. if ($_EV_CONF['enable_categories'] == '1') { $cresult = DB_query("SELECT tc.id, tc.name\n FROM {$_TABLES['evlist_categories']} tc \n WHERE tc.status='1' ORDER BY tc.name"); while ($A = DB_fetchArray($cresult, false)) { if (isset($_POST['categories']) && is_array($_POST['categories'])) { // Coming from a form re-entry $chk = in_array($A['id'], $_POST['categories']) ? EVCHECKED : ''; } else { $chk = in_array($A['id'], $this->categories) ? EVCHECKED : ''; } $catlist .= '<input type="checkbox" name="categories[]" ' . 'value="' . $A['id'] . '" ' . $chk . ' />' . ' ' . $A['name'] . ' '; } $T->set_var('catlist', $catlist); if (isset($_POST['newcat'])) { $T->set_var('newcat', $_POST['newcat']); } if ($_USER['uid'] > 1 && $rp_id == 0) { $T->set_var('category_section', 'true'); $T->set_var('add_cat_input', 'true'); } } // Enable the post mode selector if we allow HTML and the user is // logged in, or if this user is an authorized editor if ($this->isAdmin || $_EV_CONF['allow_html'] == '1' && $_USER['uid'] > 1) { $T->set_var(array('postmode_options' => EVLIST_GetOptions($LANG_EVLIST['postmodes'], $postmode), 'allowed_html' => COM_allowedHTML('evlist.submit'))); if ($postmode == 'plaintext') { // plaintext, hide postmode selector $T->set_var('postmode_show', ' style="display:none"'); } $T->parse('event_postmode', 'edit_postmode'); } if ($this->isAdmin) { $T->set_var(array('owner_username' => COM_stripslashes($ownerusername), 'owner_dropdown' => COM_optionList($_TABLES['users'], 'uid,username', $this->owner_id, 1, "uid <> 1"), 'group_dropdown' => SEC_getGroupDropdown($this->group_id, 3))); if ($rp_id == 0) { // can only change permissions on main event $T->set_var('permissions_editor', SEC_getPermissionsHTML($this->perm_owner, $this->perm_group, $this->perm_members, $this->perm_anon)); } } else { $T->set_var('group_id', $this->group_id); } // Latitude & Longitude part of location, if Location plugin is used if ($_EV_CONF['use_locator']) { $T->set_var(array('use_locator' => 'true', 'loc_selection' => GEO_optionList())); } $T->parse('output', 'editor'); $retval .= $T->finish($T->get_var('output')); $retval .= COM_endBlock(); return $retval; }
/** * Display the common header for all calendar views. * * @param integer $year Year being displayed (required) * @param integer $month Month being displayed (require) * @param integer $day Day being displayed (required) * @param string $view View type (Optional 'year', 'month', etc.) * @param integer $cat Category (optional) * @param integer $cal Calendar ID (optional) * @param integer $range Range being displayed (optional) * @return string HTML for calendar header */ function EVLIST_calHeader($year, $month, $day, $view = 'month', $cat = 0, $cal = 0, $range = 0) { global $_CONF, $_EV_CONF, $LANG_EVLIST, $LANG_MONTH, $_TABLES; $T = new Template(EVLIST_PI_PATH . '/templates'); $T->set_file('calendar_header', 'calendar_header.thtml'); $today = new Date($_EV_CONF['_today_ts'], $_CONF['timezone']); $thisyear = $today->format('Y', true); $thismonth = $today->format('m', true); $thisday = $today->format('d', true); // Determine if the current user is allowed to add an event, and borrow // some space in $_EV_CONF to store a flag for other functions to use. $isAnon = COM_isAnonUser(); if ($isAnon && $_EV_CONF['can_add'] & EV_ANON_CAN_ADD || $_EV_CONF['can_add'] & EV_USER_CAN_ADD || SEC_hasRights('evlist.admin')) { $_EV_CONF['_can_add'] = 1; } else { $_EV_CONF['_can_add'] = 0; } $cat = (int) $cat; $type_options = COM_optionList($_TABLES['evlist_categories'], 'id,name', $cat, 1, 'status=1'); $range_options = EVLIST_GetOptions($LANG_EVLIST['ranges'], $range); // Figure out the add event link, depending on the view. if ($_EV_CONF['_can_add'] == 1) { $add_event_link = EVLIST_URL . '/event.php'; switch ($view) { case 'day': // Add the current day $T->set_var('addlink_day', $day); case 'week': case 'month': $T->set_var('addlink_month', $month); case 'year': $T->set_var('addlink_year', $year); } } else { $add_event_link = ''; } $T->set_var(array('pi_url' => EVLIST_URL, 'year' => (int) $year, 'month' => (int) $month, 'day' => (int) $day, 'thisyear' => (int) $thisyear, 'thismonth' => (int) $thismonth, 'thisday' => (int) $thisday, 'thisview' => $view, 'add_event_link' => $add_event_link, 'add_event_text' => $LANG_EVLIST['add_event'], 'event_type_select' => $type_options, 'range_options' => $range_options, 'action_url' => EVLIST_URL . '/index.php', 'iso_lang' => EVLIST_getIsoLang(), 'view' => $view, 'curdate' => sprintf("%d-%02d-%02d", $year, $month, $day), 'urlfilt_cal' => $cal, 'urlfilt_cat' => $cat, 'use_json' => $_EV_CONF['cal_tmpl'] == 'json' ? 'true' : '')); $cal_selected = isset($_GET['cal']) ? (int) $_GET['cal'] : 0; $T->set_var('cal_select', COM_optionList($_TABLES['evlist_calendars'], 'cal_id,cal_name', $cal_selected, 1, '1=1 ' . COM_getPermSQL('AND'))); if (isset($_GET['range']) && !empty($_GET['range'])) { $T->set_var('range_url', 'range=' . $_GET['range']); } if ($view == 'detail') { // Set marker to disable category/range dropdowns $T->set_var('showing_detail', 'true'); } if ($view == 'list' || $view == 'detail') { $T->set_var('event_type', $event_type); } else { // Create the jump-to-date selectors $options = ''; for ($i = 1; $i < 32; $i++) { $sel = $i == $day ? EVSELECTED : ''; $options .= "<option value=\"{$i}\" {$sel}>{$i}</option>" . LB; } $T->set_var('day_select', $options); $options = ''; for ($i = 1; $i < 13; $i++) { $sel = $i == $month ? EVSELECTED : ''; $options .= "<option value=\"{$i}\" {$sel}>{$LANG_MONTH[$i]}</option>" . LB; } $T->set_var('month_select', $options); $options = ''; $lastyear = $thisyear + 6; for ($i = $thisyear - 2; $i < $lastyear; $i++) { $sel = $i == $year ? EVSELECTED : ''; $options .= "<option value=\"{$i}\" {$sel}>{$i}</option>" . LB; } $T->set_var('year_select', $options); } $images = array('day', 'week', 'month', 'year', 'list'); $options = ''; foreach ($images as $v) { if ($v == $view) { $sel = EVSELECTED; $T->set_var($v . '_img', $v . '_on.png'); } else { $sel = ''; $T->set_var($v . '_img', $v . '_off.png'); } if ($v != 'list') { $options .= '<option value="' . $v . '" ' . $sel . ' >' . $LANG_EVLIST['periods'][$v] . '</option>' . LB; } } $T->set_var('view_select', $options); $T->parse('output', 'calendar_header'); return $T->finish($T->get_var('output')); }