/** * Get a form field for editing a forum multi code, set up with a default of the given forum multi code. * * @param SHORT_TEXT The multi code. * @return tempcode The form field. */ function ocf_get_forum_multi_code_field($forum_multi_code) { require_code('form_templates'); if ($forum_multi_code != '') { $selected = array_map('intval', explode(',', substr($forum_multi_code, 1))); $type = $forum_multi_code[0]; } else { $selected = NULL; $type = '+'; } require_code('ocf_forums2'); $list = ocf_get_forum_tree_secure(NULL, NULL, true, $selected); return form_input_all_and_not(do_lang_tempcode('SECTION_FORUMS'), do_lang_tempcode('USE_IN_ALL_FORUMS'), 'forum_multi_code', $list, $type); }
/** * Get the form fields for an event input form. * * @param ?AUTO_LINK The event type (NULL: default) * @param ?integer The year the event starts at (NULL: default) * @param ?integer The month the event starts at (NULL: default) * @param ?integer The day the event starts at (NULL: default) * @param ?integer The hour the event starts at (NULL: default) * @param ?integer The minute the event starts at (NULL: default) * @param SHORT_TEXT The title of the event * @param LONG_TEXT The full text describing the event * @param SHORT_TEXT The recurrence code * @param ?integer The number of recurrences (NULL: none/infinite) * @param BINARY Whether to segregate the comment-topics/rating/trackbacks per-recurrence * @param BINARY Whether it is a public event * @param integer The priority * @range 1 5 * @param ?integer The year the event ends at (NULL: not a multi day event) * @param ?integer The month the event ends at (NULL: not a multi day event) * @param ?integer The day the event ends at (NULL: not a multi day event) * @param ?integer The hour the event ends at (NULL: not a multi day event) * @param ?integer The minute the event ends at (NULL: not a multi day event) * @param ?ID_TEXT The timezone for the event (NULL: current user's timezone) * @param BINARY Whether the time should be presented in the viewer's own timezone * @param BINARY Whether the event is validated * @param ?BINARY Whether rating is allowed (NULL: decide statistically, based on existing choices) * @param ?SHORT_INTEGER Whether comments are allowed (0=no, 1=yes, 2=review style) (NULL: decide statistically, based on existing choices) * @param ?BINARY Whether trackbacks are allowed (NULL: decide statistically, based on existing choices) * @param LONG_TEXT Notes * @return array A tuple of: (fields, hidden-fields, delete-fields, edit-text, whether all delete fields are specified, posting form text, more fields) */ function get_form_fields($type = NULL, $start_year = NULL, $start_month = NULL, $start_day = NULL, $start_hour = NULL, $start_minute = NULL, $title = '', $content = '', $recurrence = 'none', $recurrences = NULL, $seg_recurrences = 0, $is_public = 1, $priority = 3, $end_year = NULL, $end_month = NULL, $end_day = NULL, $end_hour = NULL, $end_minute = NULL, $timezone = NULL, $do_timezone_conv = 0, $validated = 1, $allow_rating = NULL, $allow_comments = NULL, $allow_trackbacks = NULL, $notes = '') { list($allow_rating, $allow_comments, $allow_trackbacks) = $this->choose_feedback_fields_statistically($allow_rating, $allow_comments, $allow_trackbacks); unset($content); if (is_null($timezone) || $timezone == '') { $timezone = get_users_timezone(); } require_code('form_templates'); if (is_null($type)) { global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'date'; $NON_CANONICAL_PARAMS[] = 'e_type'; $NON_CANONICAL_PARAMS[] = 'validated'; $date = get_param('date', ''); $start_hour = NULL; $start_minute = NULL; if ($date != '') { $date2 = explode(' ', $date); $exploded = explode('-', $date2[0]); //if (count($exploded)!=3) warn_exit(do_lang_tempcode('INTERNAL_ERROR')); $start_year = intval($exploded[0]); $start_month = intval($exploded[1]); $start_day = intval($exploded[2]); if (array_key_exists(1, $date2)) { $exploded = explode(':', $date2[1]); //if (count($exploded)!=2) warn_exit(do_lang_tempcode('INTERNAL_ERROR')); $start_hour = intval($exploded[0]); $start_minute = intval($exploded[1]); } } else { list($start_year, $start_month, $start_day) = array(NULL, NULL, NULL); } $type = get_param_integer('e_type', -1); if ($type == -1) { $type = NULL; } $adding = true; } else { $adding = false; } if (is_null($type)) { $type = db_get_first_id() + 1; } if (is_null($start_month)) { $start_year = intval(date('Y')); $start_month = intval(date('m')); $start_day = intval(date('d')); $start_hour = NULL; $start_minute = NULL; } if ((is_null($end_year) || is_null($end_month) || is_null($end_day)) && $adding) { $end_year = NULL; //$start_year; $end_month = NULL; //$start_month; $end_day = NULL; //$start_day; $end_hour = NULL; $end_minute = NULL; } $fields = new ocp_tempcode(); $hidden = new ocp_tempcode(); $fields->attach(form_input_line(do_lang_tempcode('TITLE'), do_lang_tempcode('DESCRIPTION_TITLE'), 'title', $title, true)); //$fields->attach(form_input_text_comcode(do_lang_tempcode('EVENT_TEXT'),do_lang_tempcode('DESCRIPTION_EVENT_TEXT'),'content',$content,false)); // Type $type_list = nice_get_event_types($type); $fields->attach(form_input_list(do_lang_tempcode('TYPE'), do_lang_tempcode('DESCRIPTION_EVENT_TYPE'), 'type', $type_list)); // Dates $fields->attach(form_input_tick(do_lang_tempcode('ALL_DAY_EVENT'), do_lang_tempcode('DESCRIPTION_ALL_DAY_EVENT'), 'all_day_event', is_null($start_hour))); $fields->attach(form_input_date(do_lang_tempcode('DATE_TIME'), '', 'start', false, false, true, array(is_null($start_minute) ? find_timezone_start_minute_in_utc($timezone, $start_year, $start_month, $start_day) : $start_minute, is_null($start_hour) ? find_timezone_start_hour_in_utc($timezone, $start_year, $start_month, $start_day) : $start_hour, $start_month, $start_day, $start_year), 120, intval(date('Y')) - 100, NULL, NULL, true, $timezone, get_param('date', '') == '')); $fields->attach(form_input_date(do_lang_tempcode('END_DATE_AND_TIME'), do_lang_tempcode('DESCRIPTION_END_DATE_AND_TIME'), 'end', true, is_null($end_year), true, array(is_null($end_minute) ? find_timezone_end_minute_in_utc($timezone, $end_year, $end_month, $end_day) : $end_minute, is_null($end_hour) ? find_timezone_end_hour_in_utc($timezone, $end_year, $end_month, $end_day) : $end_hour, $end_month, $end_day, $end_year), 120, intval(date('Y')) - 100, NULL, NULL, true, $timezone)); if ($validated == 0) { $validated = get_param_integer('validated', 0); } if (has_some_cat_specific_permission(get_member(), 'bypass_validation_' . $this->permissions_require . 'range_content', NULL, $this->permissions_cat_require)) { if (addon_installed('unvalidated')) { $fields->attach(form_input_tick(do_lang_tempcode('VALIDATED'), do_lang_tempcode('DESCRIPTION_VALIDATED'), 'validated', $validated == 1)); } } $fields2 = new ocp_tempcode(); $fields2->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('ADVANCED')))); // More date stuff $list = ''; foreach (get_timezone_list() as $_timezone => $timezone_nice) { $list .= static_evaluate_tempcode(form_input_list_entry($_timezone, $_timezone == $timezone, $timezone_nice)); } $fields2->attach(form_input_list(do_lang_tempcode('EVENT_TIMEZONE'), do_lang_tempcode('DESCRIPTION_EVENT_TIMEZONE'), 'timezone', make_string_tempcode($list))); $fields2->attach(form_input_tick(do_lang_tempcode('DO_TIMEZONE_CONV'), do_lang_tempcode('DESCRIPTION_DO_TIMEZONE_CONV'), 'do_timezone_conv', $do_timezone_conv == 1)); if (has_specific_permission(get_member(), 'add_public_events')) { $fields2->attach(form_input_tick(do_lang_tempcode('IS_PUBLIC'), do_lang_tempcode('DESCRIPTION_IS_PUBLIC'), 'is_public', $is_public == 1)); } // Priority $priority_list = new ocp_tempcode(); $priority_list->attach(form_input_list_entry('1', $priority == 1, do_lang_tempcode('PRIORITY_1'))); $priority_list->attach(form_input_list_entry('2', $priority == 2, do_lang_tempcode('PRIORITY_2'))); $priority_list->attach(form_input_list_entry('3', $priority == 3, do_lang_tempcode('PRIORITY_3'))); $priority_list->attach(form_input_list_entry('4', $priority == 4, do_lang_tempcode('PRIORITY_4'))); $priority_list->attach(form_input_list_entry('5', $priority == 5, do_lang_tempcode('PRIORITY_5'))); $fields2->attach(form_input_list(do_lang_tempcode('PRIORITY'), '', 'priority', $priority_list)); // Recurrence $fields2->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('RECURRENCE')))); if (strpos($recurrence, ' ') === false) { $recurrence_main = $recurrence; $recurrence_pattern = ''; } else { list($recurrence_main, $recurrence_pattern) = explode(' ', $recurrence); } $radios = form_input_radio_entry('recurrence', 'none', true, do_lang_tempcode('NA_EM')); $radios->attach(form_input_radio_entry('recurrence', 'daily', $recurrence_main == 'daily', do_lang_tempcode('DAILY'))); $radios->attach(form_input_radio_entry('recurrence', 'weekly', $recurrence_main == 'weekly', do_lang_tempcode('WEEKLY'))); $radios->attach(form_input_radio_entry('recurrence', 'monthly', $recurrence_main == 'monthly', do_lang_tempcode('MONTHLY'))); $radios->attach(form_input_radio_entry('recurrence', 'yearly', $recurrence_main == 'yearly', do_lang_tempcode('YEARLY'))); $fields2->attach(form_input_radio(do_lang_tempcode('RECURRENCE'), do_lang_tempcode('DESCRIPTION_RECURRENCE'), 'recurrence', $radios)); // xth_dotw_of_monthly $fields2->attach(form_input_line(do_lang_tempcode('RECURRENCE_PATTERN'), do_lang_tempcode('DESCRIPTION_RECURRENCE_PATTERN'), 'recurrence_pattern', $recurrence_pattern, false)); $fields2->attach(form_input_integer(do_lang_tempcode('RECURRENCES'), do_lang_tempcode('DESCRIPTION_RECURRENCES'), 'recurrences', $recurrences, false)); $fields2->attach(form_input_tick(do_lang_tempcode('SEG_RECURRENCES'), do_lang_tempcode('DESCRIPTION_SEG_RECURRENCES'), 'seg_recurrences', $seg_recurrences == 1)); if ($adding && cron_installed()) { $fields2->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('REMINDERS')))); $fields2->attach(form_input_tick(do_lang_tempcode('SIGN_UP_REMINDER'), do_lang_tempcode('DESCRIPTION_SIGN_UP_REMINDER'), 'sign_up_reminder', true)); if (has_specific_permission(get_member(), 'add_public_events')) { $usergroup_list = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(true); if (get_forum_type() == 'ocf') { unset($usergroup_list[db_get_first_id()]); } $t_usergroup_list = new ocp_tempcode(); foreach ($usergroup_list as $id => $name) { $t_usergroup_list->attach(form_input_list_entry(strval($id), false, $name)); } $fields2->attach(form_input_all_and_not(do_lang_tempcode('SIGN_UP_REMINDER_GROUPS'), do_lang_tempcode('DESCRIPTION_SIGN_UP_REMINDER_GROUPS'), 'sign_up_reminder_groups', $t_usergroup_list)); } $fields2->attach(form_input_float(do_lang_tempcode('REMINDER_TIME'), do_lang_tempcode('DESCRIPTION_REMINDER_TIME'), 'hours_before', 1.0, true)); } require_code('feedback2'); $fields2->attach(feedback_fields($allow_rating == 1, $allow_comments == 1, $allow_trackbacks == 1, false, $notes, $allow_comments == 2)); $fields2->attach(get_syndication_option_fields()); return array($fields, $hidden, NULL, NULL, true, NULL, $fields2); }