/** * Allows user to edit a personal calendar event * * @param array $A Record to display * @return string HTML for event editor * */ function editpersonalevent($A) { global $_CONF, $_CAJP_CONF, $LANG_CALJP_1; $ja = $_CONF['language'] == 'japanese_utf-8'; $cal_templates = COM_newTemplate($_CONF['path'] . 'plugins/calendarjp/templates/'); $cal_templates->set_file('form', 'editpersonalevent' . ($ja ? '_ja' : '') . '.thtml'); $cal_templates->set_var('lang_title', $LANG_CALJP_1[28]); $title = stripslashes($A['title']); $title = str_replace('{', '{', $title); $title = str_replace('}', '}', $title); $title = str_replace('"', '"', $title); $cal_templates->set_var('event_title', $title); $cal_templates->set_var('lang_eventtype', $LANG_CALJP_1[37]); $type_options = CALENDARJP_eventTypeList($A['event_type']); $cal_templates->set_var('type_options', $type_options); // Handle start date/time $cal_templates->set_var('lang_startdate', $LANG_CALJP_1[21]); $cal_templates->set_var('lang_starttime', $LANG_CALJP_1[30]); $A['startdate'] = $A['datestart'] . ' ' . $A['timestart']; $start_month = date('n', strtotime($A['startdate'])); $month_options = CALENDARJP_getMonthFormOptions($start_month); $cal_templates->set_var('startmonth_options', $month_options); $start_day = date('j', strtotime($A['startdate'])); $day_options = COM_getDayFormOptions($start_day); $cal_templates->set_var('startday_options', $day_options); $start_year = date('Y', strtotime($A['startdate'])); $year_options = COM_getYearFormOptions($start_year); $cal_templates->set_var('startyear_options', $year_options); if (isset($_CAJP_CONF['hour_mode']) && $_CAJP_CONF['hour_mode'] == 24) { $start_hour = date('H', strtotime($A['startdate'])); $hour_options = COM_getHourFormOptions($start_hour, 24); $cal_templates->set_var('starthour_options', $hour_options); } else { $start_hour = date('g', strtotime($A['startdate'])); $hour_options = COM_getHourFormOptions($start_hour); $cal_templates->set_var('starthour_options', $hour_options); } $startmin = intval(date('i', strtotime($A['startdate'])) / 15) * 15; $cal_templates->set_var('startminute_options', COM_getMinuteFormOptions($startmin, 15)); $ampm = date('a', strtotime($A['startdate'])); $cal_templates->set_var('startampm_selection', CALENDARJP_getAmPmFormSelection('startampm_selection', $ampm)); // Handle end date/time $cal_templates->set_var('lang_enddate', $LANG_CALJP_1[18]); $cal_templates->set_var('lang_endtime', $LANG_CALJP_1[29]); $A['enddate'] = $A['dateend'] . ' ' . $A['timeend']; $end_month = date('n', strtotime($A['enddate'])); $month_options = CALENDARJP_getMonthFormOptions($end_month); $cal_templates->set_var('endmonth_options', $month_options); $end_day = date('j', strtotime($A['enddate'])); $day_options = COM_getDayFormOptions($end_day); $cal_templates->set_var('endday_options', $day_options); $end_year = date('Y', strtotime($A['enddate'])); $year_options = COM_getYearFormOptions($end_year); $cal_templates->set_var('endyear_options', $year_options); if (isset($_CAJP_CONF['hour_mode']) && $_CAJP_CONF['hour_mode'] == 24) { $end_hour = date('H', strtotime($A['enddate'])); $hour_options = COM_getHourFormOptions($end_hour, 24); $cal_templates->set_var('endhour_options', $hour_options); } else { $end_hour = date('g', strtotime($A['enddate'])); $hour_options = COM_getHourFormOptions($end_hour); $cal_templates->set_var('endhour_options', $hour_options); } $endmin = intval(date('i', strtotime($A['enddate'])) / 15) * 15; $cal_templates->set_var('endminute_options', COM_getMinuteFormOptions($endmin, 15)); $ampm = date('a', strtotime($A['enddate'])); $cal_templates->set_var('endampm_selection', CALENDARJP_getAmPmFormSelection('endampm_selection', $ampm)); $cal_templates->set_var('lang_alldayevent', $LANG_CALJP_1[31]); if ($A['allday'] == 1) { $cal_templates->set_var('allday_checked', 'checked="checked"'); } else { $cal_templates->set_var('allday_checked', ''); } $cal_templates->set_var('lang_tail_year', $LANG_CALJP_1['tail_year']); $cal_templates->set_var('lang_tail_month', $LANG_CALJP_1['tail_month']); $cal_templates->set_var('lang_tail_day', $LANG_CALJP_1['tail_day']); $cal_templates->set_var('lang_location', $LANG_CALJP_1[39]); $cal_templates->set_var('event_location', stripslashes($A['location'])); $cal_templates->set_var('lang_addressline1', $LANG_CALJP_1[32]); $cal_templates->set_var('event_address1', stripslashes($A['address1'])); $cal_templates->set_var('lang_addressline2', $LANG_CALJP_1[33]); $cal_templates->set_var('event_address2', stripslashes($A['address2'])); $cal_templates->set_var('lang_city', $LANG_CALJP_1[34]); $cal_templates->set_var('event_city', stripslashes($A['city'])); $cal_templates->set_var('lang_state', $LANG_CALJP_1[35]); $cal_templates->set_var('state_options', ''); $cal_templates->set_var('event_state', stripslashes($A['state'])); $cal_templates->set_var('lang_zipcode', $LANG_CALJP_1[36]); $cal_templates->set_var('event_zipcode', $A['zipcode']); $cal_templates->set_var('lang_link', $LANG_CALJP_1[43]); $cal_templates->set_var('event_url', $A['url']); $cal_templates->set_var('lang_description', $LANG_CALJP_1[5]); $cal_templates->set_var('event_description', COM_nl2br(stripslashes($A['description']))); $cal_templates->set_var('lang_htmlnotallowed', $LANG_CALJP_1[44]); $cal_templates->set_var('lang_submit', $LANG_CALJP_1[45]); $cal_templates->set_var('lang_delete', $LANG_CALJP_1[51]); $cal_templates->set_var('eid', $A['eid']); $cal_templates->set_var('uid', $A['uid']); if (isset($_CAJP_CONF['hour_mode']) && $_CAJP_CONF['hour_mode'] == 24) { $cal_templates->set_var('hour_mode', 24); } else { $cal_templates->set_var('hour_mode', 12); } $cal_templates->set_var('gltoken_name', CSRF_TOKEN); $cal_templates->set_var('gltoken', SEC_createToken()); return $cal_templates->parse('output', 'form'); }
/** * Shows event editor * * @param string $mode Indicates if this is a submission or a regular entry * @param array $A array holding the event's details * @param string $msg an optional error message to display * @return string HTML for event editor or error message * */ function CALENDARJP_editEvent($mode, $A, $msg = '') { global $_CONF, $_GROUPS, $_TABLES, $_USER, $_CAJP_CONF, $LANG_CALJP_1, $LANG_CALJP_ADMIN, $LANG10, $LANG12, $LANG24, $LANG_ACCESS, $LANG_ADMIN, $MESSAGE, $_SCRIPTS; // Loads jQuery UI datepicker and timepicker-addon $_SCRIPTS->setJavaScriptLibrary('jquery.ui.slider'); $_SCRIPTS->setJavaScriptLibrary('jquery.ui.datepicker'); $_SCRIPTS->setJavaScriptLibrary('jquery-ui-i18n'); $_SCRIPTS->setJavaScriptLibrary('jquery-ui-timepicker-addon'); $_SCRIPTS->setJavaScriptLibrary('jquery-ui-timepicker-addon-i18n'); $_SCRIPTS->setJavaScriptFile('datetimepicker', '/javascript/datetimepicker.js'); // Add JavaScript $_SCRIPTS->setJavaScriptFile('postmode_control', '/javascript/postmode_control.js'); $langCode = COM_getLangIso639Code(); $toolTip = $MESSAGE[118]; $imgUrl = $_CONF['site_url'] . '/images/calendar.png'; $_SCRIPTS->setJavaScript("jQuery(function () {" . " geeklog.hour_mode = {$_CONF['hour_mode']};" . " geeklog.datetimepicker.options.stepMinute = 15;" . " geeklog.datetimepicker.set('start', '{$langCode}', '{$toolTip}', '{$imgUrl}');" . " geeklog.datetimepicker.set('end', '{$langCode}', '{$toolTip}', '{$imgUrl}');" . "});", TRUE, TRUE); $retval = ''; if (!empty($msg)) { $retval .= COM_showMessageText($msg, $LANG_CALJP_ADMIN[2]); } $ja = $_CONF['language'] == 'japanese_utf-8'; $event_templates = COM_newTemplate($_CONF['path'] . 'plugins/calendarjp/templates/admin'); $advanced_editor = $_CONF['advanced_editor'] && $_USER['advanced_editor'] && $_CAJP_CONF['advanced_editor']; if ($advanced_editor) { $event_templates->set_file('editor', 'eventeditor_advanced' . ($ja ? '_ja' : '') . '.thtml'); } else { $event_templates->set_file('editor', 'eventeditor' . ($ja ? '_ja' : '') . '.thtml'); } $allowed = ''; foreach (array('plaintext', 'html') as $pm) { $allowed .= COM_allowedHTML('calendarjp.edit', false, 1, $pm); } $allowed .= COM_allowedAutotags(); $event_templates->set_var('lang_allowed_html', $allowed); $event_templates->set_var('lang_postmode', $LANG_CALJP_ADMIN[3]); $event_templates->set_var('lang_expandhelp', $LANG24[67]); $event_templates->set_var('lang_reducehelp', $LANG24[68]); $event_templates->set_var('lang_toolbar', $LANG24[70]); $event_templates->set_var('toolbar1', $LANG24[71]); $event_templates->set_var('toolbar2', $LANG24[72]); $event_templates->set_var('toolbar3', $LANG24[73]); $event_templates->set_var('toolbar4', $LANG24[74]); $event_templates->set_var('toolbar5', $LANG24[75]); $event_templates->set_var('change_editormode', 'onchange="change_editmode(this);"'); if ($advanced_editor) { if ($A['postmode'] == 'adveditor') { $event_templates->set_var('show_texteditor', 'none'); $event_templates->set_var('show_htmleditor', ''); } else { $event_templates->set_var('show_texteditor', ''); $event_templates->set_var('show_htmleditor', 'none'); } } if ($advanced_editor) { // Setup Advanced Editor COM_setupAdvancedEditor('/calendarjp/adveditor.js', 'calendarjp.edit'); } if ($mode != 'editsubmission' and !empty($A['eid'])) { // Get what level of access user has to this object $access = SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']); if ($access == 0 or $access == 2) { // Uh, oh! User doesn't have access to this object $retval .= COM_showMessageText($LANG_CALJP_ADMIN[17], $LANG_ACCESS['accessdenied']); COM_accessLog("User {$_USER['username']} tried to illegally submit or edit event {$eid}."); return $retval; } } else { if (empty($A['owner_id'])) { $A['owner_id'] = $_USER['uid']; } if (isset($_GROUPS['Calendarjp Admin'])) { $A['group_id'] = $_GROUPS['Calendarjp Admin']; } else { $A['group_id'] = SEC_getFeatureGroup('calendarjp.edit'); } SEC_setDefaultPermissions($A, $_CAJP_CONF['default_permissions']); $access = 3; } // ------------------------------>> /* if ($mode == 'editsubmission') { $event_templates->set_var('post_options', COM_optionList($_TABLES['postmodes'],'code,name','plaintext')); } else { if (!isset ($A['postmode'])) { $A['postmode'] = $_CONF['postmode']; } $event_templates->set_var('post_options', COM_optionList($_TABLES['postmodes'],'code,name',$A['postmode'])); } */ // ------------------------------|| if ($mode == 'editsubmission') { $post_options = COM_optionList($_TABLES['postmodes'], 'code,name', 'plaintext'); } else { if (!isset($A['postmode'])) { $A['postmode'] = $_CAJP_CONF['postmode']; } $post_options = COM_optionList($_TABLES['postmodes'], 'code,name', $A['postmode']); if ($advanced_editor) { if ($A['postmode'] == 'adveditor') { $post_options .= '<option value="adveditor" selected="selected">' . $LANG24[86] . '</option>'; } else { $post_options .= '<option value="adveditor">' . $LANG24[86] . '</option>'; } } if ($_CAJP_CONF['wikitext_editor']) { if ($A['postmode'] == 'wikitext') { $post_options .= '<option value="wikitext" selected="selected">' . $LANG24[88] . '</option>'; } else { $post_options .= '<option value="wikitext">' . $LANG24[88] . '</option>'; } } } $event_templates->set_var('post_options', $post_options); // ------------------------------<< $token = SEC_createToken(); $retval .= COM_startBlock($LANG_CALJP_ADMIN[1], '', COM_getBlockTemplate('_admin_block', 'header')); $retval .= SEC_getTokenExpiryNotice($token); if (!empty($A['eid'])) { $delbutton = '<input type="submit" value="' . $LANG_ADMIN['delete'] . '" name="mode"%s' . XHTML . '>'; $jsconfirm = ' onclick="return confirm(\'' . $MESSAGE[76] . '\');"'; $event_templates->set_var('delete_option', sprintf($delbutton, $jsconfirm)); $event_templates->set_var('delete_option_no_confirmation', sprintf($delbutton, '')); if ($mode == 'editsubmission') { $event_templates->set_var('submission_option', '<input type="hidden" name="type" value="submission"' . XHTML . '>'); } } else { // new event $A['eid'] = COM_makesid(); $A['title'] = ''; $A['description'] = ''; $A['url'] = ''; $A['hits'] = 0; // in case a start date/time has been passed from the calendar, // pick it up for the end date/time if (empty($A['dateend'])) { $A['dateend'] = $A['datestart']; } if (empty($A['timeend'])) { $A['timeend'] = $A['timestart']; } $A['event_type'] = ''; $A['location'] = ''; $A['address1'] = ''; $A['address2'] = ''; $A['city'] = ''; $A['state'] = ''; $A['zipcode'] = ''; $A['allday'] = 0; } $event_templates->set_var('lang_eventid', $LANG_CALJP_ADMIN[34]); $event_templates->set_var('event_id', $A['eid']); $event_templates->set_var('lang_eventtitle', $LANG_ADMIN['title']); $A['title'] = str_replace('{', '{', $A['title']); $A['title'] = str_replace('}', '}', $A['title']); $A['title'] = str_replace('"', '"', $A['title']); $event_templates->set_var('event_title', stripslashes($A['title'])); $event_templates->set_var('lang_eventtype', $LANG_CALJP_1[37]); $event_templates->set_var('lang_editeventtypes', $LANG12[50]); $event_templates->set_var('type_options', CALENDARJP_eventTypeList($A['event_type'])); $event_templates->set_var('lang_eventurl', $LANG_CALJP_ADMIN[4]); $event_templates->set_var('max_url_length', 255); $event_templates->set_var('event_url', $A['url']); $event_templates->set_var('lang_includehttp', $LANG_CALJP_ADMIN[9]); $event_templates->set_var('lang_eventstartdate', $LANG_CALJP_ADMIN[5]); //$event_templates->set_var('event_startdate', $A['datestart']); $event_templates->set_var('lang_starttime', $LANG_CALJP_1[30]); // Combine date/time for easier manipulation $A['datestart'] = trim($A['datestart'] . ' ' . $A['timestart']); if (empty($A['datestart'])) { // ------------------------------>> // $start_stamp = time (); // ------------------------------|| if (!empty($A['month']) && !empty($A['day']) && !empty($A['year']) && !empty($A['hour'])) { $start_stamp = mktime($A['hour'], 0, 0, $A['month'], $A['day'], $A['year']); } else { $start_stamp = time(); } // ------------------------------<< } else { $start_stamp = strtotime($A['datestart']); } $A['dateend'] = trim($A['dateend'] . ' ' . $A['timeend']); if (empty($A['dateend'])) { // $end_stamp = time (); $end_stamp = $start_stamp; } else { $end_stamp = strtotime($A['dateend']); } $start_month = date('m', $start_stamp); $start_day = date('d', $start_stamp); $start_year = date('Y', $start_stamp); $end_month = date('m', $end_stamp); $end_day = date('d', $end_stamp); $end_year = date('Y', $end_stamp); $start_hour = date('H', $start_stamp); $start_minute = intval(date('i', $start_stamp) / 15) * 15; if ($start_hour >= 12) { $startampm = 'pm'; } else { $startampm = 'am'; } $start_hour_24 = $start_hour % 24; if ($start_hour > 12) { $start_hour = $start_hour - 12; } else { if ($start_hour == 0) { $start_hour = 12; } } $end_hour = date('H', $end_stamp); $end_minute = intval(date('i', $end_stamp) / 15) * 15; if ($end_hour >= 12) { $endampm = 'pm'; } else { $endampm = 'am'; } $end_hour_24 = $end_hour % 24; if ($end_hour > 12) { $end_hour = $end_hour - 12; } else { if ($end_hour == 0) { $end_hour = 12; } } $month_options = CALENDARJP_getMonthFormOptions($start_month); $event_templates->set_var('startmonth_options', $month_options); $month_options = CALENDARJP_getMonthFormOptions($end_month); $event_templates->set_var('endmonth_options', $month_options); $day_options = COM_getDayFormOptions($start_day); $event_templates->set_var('startday_options', $day_options); $day_options = COM_getDayFormOptions($end_day); $event_templates->set_var('endday_options', $day_options); $year_options = COM_getYearFormOptions($start_year); $event_templates->set_var('startyear_options', $year_options); $year_options = COM_getYearFormOptions($end_year); $event_templates->set_var('endyear_options', $year_options); if (isset($_CAJP_CONF['hour_mode']) && $_CAJP_CONF['hour_mode'] == 24) { $hour_options = COM_getHourFormOptions($start_hour_24, 24); $event_templates->set_var('starthour_options', $hour_options); $hour_options = COM_getHourFormOptions($end_hour_24, 24); $event_templates->set_var('endhour_options', $hour_options); $event_templates->set_var('hour_mode', 24); } else { $hour_options = COM_getHourFormOptions($start_hour); $event_templates->set_var('starthour_options', $hour_options); $hour_options = COM_getHourFormOptions($end_hour); $event_templates->set_var('endhour_options', $hour_options); $event_templates->set_var('hour_mode', 12); } $event_templates->set_var('startampm_selection', CALENDARJP_getAmPmFormSelection('start_ampm', $startampm)); $event_templates->set_var('endampm_selection', CALENDARJP_getAmPmFormSelection('end_ampm', $endampm)); $event_templates->set_var('startminute_options', COM_getMinuteFormOptions($start_minute, 15)); $event_templates->set_var('endminute_options', COM_getMinuteFormOptions($end_minute, 15)); $event_templates->set_var('lang_enddate', $LANG12[13]); $event_templates->set_var('lang_eventenddate', $LANG_CALJP_ADMIN[6]); $event_templates->set_var('event_enddate', $A['dateend']); $event_templates->set_var('lang_enddate', $LANG12[13]); $event_templates->set_var('lang_endtime', $LANG_CALJP_1[29]); $event_templates->set_var('lang_alldayevent', $LANG_CALJP_1[31]); if ($A['allday'] == 1) { $event_templates->set_var('allday_checked', 'checked="checked"'); } $event_templates->set_var('lang_location', $LANG12[51]); $event_templates->set_var('event_location', stripslashes($A['location'])); $event_templates->set_var('lang_addressline1', $LANG12[44]); $event_templates->set_var('event_address1', stripslashes($A['address1'])); $event_templates->set_var('lang_addressline2', $LANG12[45]); $event_templates->set_var('event_address2', stripslashes($A['address2'])); $event_templates->set_var('lang_city', $LANG12[46]); $event_templates->set_var('event_city', stripslashes($A['city'])); $event_templates->set_var('lang_state', $LANG12[47]); $event_templates->set_var('state_options', ''); $event_templates->set_var('event_state', stripslashes($A['state'])); $event_templates->set_var('lang_zipcode', $LANG12[48]); $event_templates->set_var('event_zipcode', $A['zipcode']); $event_templates->set_var('lang_eventlocation', $LANG_CALJP_ADMIN[7]); $event_templates->set_var('event_location', stripslashes($A['location'])); $event_templates->set_var('lang_eventdescription', $LANG_CALJP_ADMIN[8]); $event_templates->set_var('event_description', stripslashes($A['description'])); $event_templates->set_var('lang_hits', $LANG10[30]); $event_templates->set_var('hits', COM_numberFormat($A['hits'])); $event_templates->set_var('lang_save', $LANG_ADMIN['save']); $event_templates->set_var('lang_cancel', $LANG_ADMIN['cancel']); $event_templates->set_var('lang_tail_year', $LANG_CALJP_ADMIN['tail_year']); $event_templates->set_var('lang_tail_month', $LANG_CALJP_ADMIN['tail_month']); $event_templates->set_var('lang_tail_day', $LANG_CALJP_ADMIN['tail_day']); // user access info $event_templates->set_var('lang_accessrights', $LANG_ACCESS['accessrights']); $event_templates->set_var('lang_owner', $LANG_ACCESS['owner']); $ownername = COM_getDisplayName($A['owner_id']); $event_templates->set_var('owner_username', DB_getItem($_TABLES['users'], 'username', "uid = {$A['owner_id']}")); $event_templates->set_var('owner_name', $ownername); $event_templates->set_var('owner', $ownername); $event_templates->set_var('owner_id', $A['owner_id']); $event_templates->set_var('lang_group', $LANG_ACCESS['group']); $event_templates->set_var('group_dropdown', SEC_getGroupDropdown($A['group_id'], $access)); $event_templates->set_var('lang_permissions', $LANG_ACCESS['permissions']); $event_templates->set_var('lang_permissionskey', $LANG_ACCESS['permissionskey']); $event_templates->set_var('lang_perm_key', $LANG_ACCESS['permissionskey']); $event_templates->set_var('permissions_editor', SEC_getPermissionsHTML($A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon'])); $event_templates->set_var('lang_permissions_msg', $LANG_ACCESS['permmsg']); $event_templates->set_var('gltoken_name', CSRF_TOKEN); $event_templates->set_var('gltoken', $token); $event_templates->parse('output', 'editor'); $retval .= $event_templates->finish($event_templates->get_var('output')); $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')); return $retval; }