/** * Get tempcode for an IOTD adding/editing form. * * @param URLPATH The URL to the image * @param URLPATH The URL to the thumbnail * @param SHORT_TEXT The title * @param LONG_TEXT The caption * @param boolean Whether the IOTD is/will-be currently active * @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 for the IOTD * @return array A pair: the tempcode for the visible fields, and the tempcode for the hidden fields */ function get_form_fields($url = '', $thumb_url = '', $title = '', $caption = '', $current = false, $allow_rating = 1, $allow_comments = 1, $allow_trackbacks = 1, $notes = '') { list($allow_rating, $allow_comments, $allow_trackbacks) = $this->choose_feedback_fields_statistically($allow_rating, $allow_comments, $allow_trackbacks); $fields = new ocp_tempcode(); $hidden = new ocp_tempcode(); require_code('form_templates'); handle_max_file_size($hidden, 'image'); $fields->attach(form_input_line_comcode(do_lang_tempcode('TITLE'), do_lang_tempcode('DESCRIPTION_TITLE'), 'title', $title, true)); $fields->attach(form_input_upload(do_lang_tempcode('UPLOAD'), do_lang_tempcode('DESCRIPTION_UPLOAD'), 'file', false, NULL, NULL, true, str_replace(' ', '', get_option('valid_images')))); $fields->attach(form_input_line(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('URL')), do_lang_tempcode('DESCRIPTION_ALTERNATE_URL'), 'url', $url, false)); if (get_option('is_on_gd') == '0' || !function_exists('imagetypes')) { $thumb_width = get_option('thumb_width'); $fields->attach(form_input_upload(do_lang_tempcode('THUMBNAIL'), do_lang_tempcode('DESCRIPTION_THUMBNAIL', escape_html($thumb_width)), 'file2', false, NULL, NULL, true, str_replace(' ', '', get_option('valid_images')))); $fields->attach(form_input_line(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('URL')), do_lang_tempcode('DESCRIPTION_ALTERNATE_URL'), 'thumb_url', $thumb_url, false)); } $fields->attach(form_input_text_comcode(do_lang_tempcode('CAPTION'), do_lang_tempcode('DESCRIPTION_DESCRIPTION'), 'caption', $caption, false)); if (has_specific_permission(get_member(), 'choose_iotd')) { if ($caption == '') { $test = $GLOBALS['SITE_DB']->query_value_null_ok('iotd', 'is_current', array('is_current' => 1)); if (is_null($test)) { $current = true; } } $fields->attach(form_input_tick(do_lang_tempcode('IMMEDIATE_USE'), do_lang_tempcode('DESCRIPTION_IMMEDIATE_USE'), 'validated', $current)); } require_code('feedback2'); $fields->attach(feedback_fields($allow_rating == 1, $allow_comments == 1, $allow_trackbacks == 1, false, $notes, $allow_comments == 2)); return array($fields, $hidden); }
/** * The UI to add an author. * * @return tempcode The UI */ function _ad() { global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'author'; $author = get_param('author', $GLOBALS['FORUM_DRIVER']->get_username(get_member())); if (!has_edit_author_permission(get_member(), $author)) { if (get_author_id_from_name($author) == get_member()) { access_denied('SPECIFIC_PERMISSION', 'set_own_author_profile'); } access_denied('SPECIFIC_PERMISSION', 'edit_midrange_content'); } $rows = $GLOBALS['SITE_DB']->query_select('authors', array('description', 'url', 'skills', 'forum_handle'), array('author' => $author), '', 1); if (array_key_exists(0, $rows)) { $myrow = $rows[0]; $description = get_translated_text($myrow['description']); $url = $myrow['url']; $skills = get_translated_text($myrow['skills']); $handle = $myrow['forum_handle']; $may_delete = true; } else { $description = ''; if (get_forum_type() == 'ocf') { require_code('ocf_members'); require_lang('ocf'); $info = ocf_get_all_custom_fields_match_member(get_member()); if (array_key_exists(do_lang('DEFAULT_CPF_SELF_DESCRIPTION_NAME'), $info)) { $description = $info[do_lang('DEFAULT_CPF_SELF_DESCRIPTION_NAME')]['RENDERED']; if (is_object($description)) { $description = $description->evaluate(); } } } $url = ''; $skills = ''; $handle = NULL; $may_delete = false; } if (is_null($handle)) { $handle = $GLOBALS['FORUM_DRIVER']->get_member_from_username($author); if (!is_null($handle)) { $handle = strval($handle); } } if ($author == '' || is_null($handle)) { $title = get_page_title('DEFINE_AUTHOR'); } else { $title = get_page_title('_DEFINE_AUTHOR', true, array(escape_html($author))); } $post_url = build_url(array('page' => '_SELF', 'type' => '__ad', 'author' => $author), '_SELF'); $submit_name = do_lang_tempcode('SAVE'); $fields = new ocp_tempcode(); $hidden = new ocp_tempcode(); require_code('form_templates'); if (is_null($handle)) { $fields->attach(form_input_line(do_lang_tempcode('AUTHOR'), do_lang_tempcode('DESCRIPTION_NAME'), 'author', $author, true)); } $fields->attach(form_input_line(do_lang_tempcode('AUTHOR_URL'), do_lang_tempcode('DESCRIPTION_AUTHOR_URL'), 'url', $url, false)); $fields->attach(form_input_line_comcode(do_lang_tempcode('SKILLS'), do_lang_tempcode('DESCRIPTION_SKILLS'), 'skills', $skills, false)); $fields->attach(form_input_text_comcode(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_MEMBER_DESCRIPTION'), 'description', $description, false)); if (has_specific_permission(get_member(), 'edit_midrange_content', 'cms_authors')) { $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => !is_null($handle), 'TITLE' => do_lang_tempcode('ADVANCED')))); $fields->attach(form_input_username(do_lang_tempcode('MEMBER_ID'), do_lang_tempcode('DESCRIPTION_MEMBER_ID'), 'forum_handle', is_null($handle) ? '' : $GLOBALS['FORUM_DRIVER']->get_username(intval($handle)), false)); } else { $hidden->attach(form_input_hidden('forum_handle', $handle)); } require_code('fields'); if (has_tied_catalogue('author')) { append_form_custom_fields('author', $author, $fields, $hidden); } require_code('seo2'); $fields->attach(seo_get_fields('authors', $author)); // Awards? if (addon_installed('awards')) { require_code('awards'); $fields->attach(get_award_fields('author', $author)); } if ($may_delete) { $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ACTIONS')))); $fields->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE'), 'delete', false)); } breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('AUTHOR_MANAGE')))); return do_template('FORM_SCREEN', array('_GUID' => '1d71c934e3e23fe394f5611191089630', 'PREVIEW' => true, 'HIDDEN' => $hidden, 'TITLE' => $title, 'TEXT' => '', 'FIELDS' => $fields, 'URL' => $post_url, 'SUBMIT_NAME' => $submit_name)); }
/** * Get tempcode for adding/editing form. * * @param SHORT_TEXT The name of the multi moderation * @param LONG_TEXT The text to place as a post in the topic when the multi moderation is performed * @param ?AUTO_LINK Move the topic to this forum (NULL: don't move) * @param ?BINARY What to change the pin state to (NULL: don't change) * @param ?BINARY What to change the open state to (NULL: don't change) * @param ?BINARY What to change the sink state to (NULL: don't change) * @param SHORT_TEXT The forum multicode identifying where the multimoderation is applicable * @param SHORT_TEXT The title suffix * @return tempcode The input fields */ function get_form_fields($name = '', $post_text = '', $move_to = NULL, $pin_state = NULL, $open_state = NULL, $sink_state = NULL, $forum_multi_code = '*', $title_suffix = '') { require_code('ocf_forums2'); $fields = new ocp_tempcode(); $fields->attach(form_input_line(do_lang_tempcode('NAME'), do_lang_tempcode('DESCRIPTION_NAME'), 'name', $name, true)); $fields->attach(form_input_text_comcode(do_lang_tempcode('_POST'), do_lang_tempcode('DESCRIPTION_MULTI_MODERATION_POST'), 'post_text', $post_text, false)); $fields->attach(form_input_tree_list(do_lang_tempcode('DESTINATION'), do_lang_tempcode('DESCRIPTION_DESTINATION_FORUM'), 'move_to', NULL, 'choose_forum', array(), false, is_null($move_to) ? NULL : strval($move_to))); $pin_state_list = new ocp_tempcode(); $pin_state_list->attach(form_input_radio_entry('pin_state', '-1', is_null($pin_state), do_lang_tempcode('NA_EM'))); $pin_state_list->attach(form_input_radio_entry('pin_state', '0', $pin_state === 0, do_lang_tempcode('UNPIN_TOPIC'))); $pin_state_list->attach(form_input_radio_entry('pin_state', '1', $pin_state === 1, do_lang_tempcode('PIN_TOPIC'))); $fields->attach(form_input_radio(do_lang_tempcode('PIN_STATE'), do_lang_tempcode('DESCRIPTION_PIN_STATE'), 'pin_state', $pin_state_list)); $open_state_list = new ocp_tempcode(); $open_state_list->attach(form_input_radio_entry('open_state', '-1', is_null($open_state), do_lang_tempcode('NA_EM'))); $open_state_list->attach(form_input_radio_entry('open_state', '0', $open_state === 0, do_lang_tempcode('CLOSE_TOPIC'))); $open_state_list->attach(form_input_radio_entry('open_state', '1', $open_state === 1, do_lang_tempcode('OPEN_TOPIC'))); $fields->attach(form_input_radio(do_lang_tempcode('OPEN_STATE'), do_lang_tempcode('DESCRIPTION_OPEN_STATE'), 'open_state', $open_state_list)); $sink_state_list = new ocp_tempcode(); $sink_state_list->attach(form_input_radio_entry('sink_state', '-1', is_null($sink_state), do_lang_tempcode('NA_EM'))); $sink_state_list->attach(form_input_radio_entry('sink_state', '0', $sink_state === 0, do_lang_tempcode('SINK_TOPIC'))); $sink_state_list->attach(form_input_radio_entry('sink_state', '1', $sink_state === 1, do_lang_tempcode('UNSINK_TOPIC'))); $fields->attach(form_input_radio(do_lang_tempcode('SINK_STATE'), do_lang_tempcode('DESCRIPTION_SINK_STATE'), 'sink_state', $sink_state_list)); $fields->attach(ocf_get_forum_multi_code_field($forum_multi_code)); $fields->attach(form_input_line(do_lang_tempcode('TITLE_SUFFIX'), do_lang_tempcode('DESCRIPTION_TITLE_SUFFIX'), 'title_suffix', $title_suffix, false)); return $fields; }
/** * Get tempcode for a adding/editing form. * * @param SHORT_TEXT The name of the quiz * @param ?integer The number of minutes allowed for completion (NULL: NA) * @param LONG_TEXT The text shown at the start of the quiz * @param LONG_TEXT The text shown at the end of the quiz * @param LONG_TEXT The text shown at the end of the quiz on failure * @param LONG_TEXT Notes * @param integer Percentage correctness required for competition * @param ?TIME The time the quiz is opened (NULL: now) * @param ?TIME The time the quiz is closed (NULL: never) * @param integer The number of winners for this if it is a competition * @param ?integer The minimum number of hours between attempts (NULL: no restriction) * @param ID_TEXT The type * @set SURVEY COMPETITION TEST * @param BINARY Whether this is validated * @param ?string Text for questions (NULL: default) * @param integer The number of points awarded for completing/passing the quiz/test * @param ?AUTO_LINK Newsletter for which a member must be on to enter (NULL: none) * @return tempcode The form fields */ function get_form_fields($name = '', $timeout = NULL, $start_text = '', $end_text = '', $end_text_fail = '', $notes = '', $percentage = 70, $open_time = NULL, $close_time = NULL, $num_winners = 2, $redo_time = NULL, $type = 'COMPETITION', $validated = 1, $text = NULL, $points_for_passing = 0, $tied_newsletter = NULL) { if (is_null($open_time)) { $open_time = time(); } if (is_null($text)) { $text = do_lang('EXAMPLE_QUESTIONS'); } $fields = new ocp_tempcode(); $fields->attach(form_input_line(do_lang_tempcode('NAME'), do_lang_tempcode('DESCRIPTION_NAME'), 'name', $name, true)); $list = new ocp_tempcode(); $list->attach(form_input_list_entry('SURVEY', $type == 'SURVEY', do_lang_tempcode('SURVEY'))); $list->attach(form_input_list_entry('TEST', $type == 'TEST', do_lang_tempcode('TEST'))); $list->attach(form_input_list_entry('COMPETITION', $type == 'COMPETITION', do_lang_tempcode('COMPETITION'))); $fields->attach(form_input_list(do_lang_tempcode('TYPE'), do_lang_tempcode('DESCRIPTION_QUIZ_TYPE'), 'type', $list, NULL, true)); $fields->attach(form_input_huge(do_lang_tempcode('QUESTIONS'), do_lang_tempcode('IMPORT_QUESTIONS_TEXT'), 'text', $text, true)); if ($validated == 0) { global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'validated'; $validated = get_param_integer('validated', 0); if ($validated == 1) { attach_message(do_lang_tempcode('WILL_BE_VALIDATED_WHEN_SAVING')); } } if (addon_installed('unvalidated')) { $fields->attach(form_input_tick(do_lang_tempcode('VALIDATED'), do_lang_tempcode('DESCRIPTION_VALIDATED_SIMPLE'), 'validated', $validated == 1)); } $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('TEST')))); $fields->attach(form_input_integer(do_lang_tempcode('COMPLETION_PERCENTAGE'), do_lang_tempcode('DESCRIPTION_COMPLETION_PERCENTAGE'), 'percentage', $percentage, true)); $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('TEXT'), 'SECTION_HIDDEN' => true))); $fields->attach(form_input_text_comcode(do_lang_tempcode('QUIZ_START_TEXT'), do_lang_tempcode('DESCRIPTION_QUIZ_START_TEXT'), 'start_text', $start_text, false)); $fields->attach(form_input_text_comcode(do_lang_tempcode('QUIZ_END_TEXT'), do_lang_tempcode('DESCRIPTION_QUIZ_END_TEXT'), 'end_text', $end_text, false)); $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('COMPETITION')))); $fields->attach(form_input_integer(do_lang_tempcode('NUM_WINNERS'), do_lang_tempcode('DESCRIPTION_NUM_WINNERS'), 'num_winners', $num_winners, true)); $fields->attach(form_input_text_comcode(do_lang_tempcode('QUIZ_END_TEXT_FAIL'), do_lang_tempcode('DESCRIPTION_QUIZ_END_TEXT_FAIL'), 'end_text_fail', $end_text_fail, false)); $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => is_null($redo_time) && is_null($timeout) && (is_null($open_time) || $open_time <= time()) && is_null($close_time) && $points_for_passing == 0 && is_null($tied_newsletter) && $notes == '', 'TITLE' => do_lang_tempcode('ADVANCED')))); $fields->attach(form_input_integer(do_lang_tempcode('REDO_TIME'), do_lang_tempcode('DESCRIPTION_REDO_TIME'), 'redo_time', $redo_time, false)); $fields->attach(form_input_integer(do_lang_tempcode('TIMEOUT'), do_lang_tempcode('DESCRIPTION_QUIZ_TIMEOUT'), 'timeout', $timeout, false)); $fields->attach(form_input_date(do_lang_tempcode('OPEN_TIME'), do_lang_tempcode('DESCRIPTION_OPEN_TIME'), 'open_time', false, false, true, $open_time, 2)); $fields->attach(form_input_date(do_lang_tempcode('CLOSE_TIME'), do_lang_tempcode('DESCRIPTION_CLOSE_TIME'), 'close_time', true, is_null($close_time), true, is_null($close_time) ? NULL : $close_time, 2)); if (addon_installed('points')) { $fields->attach(form_input_integer(do_lang_tempcode('POINTS_FOR_COMPLETING'), do_lang_tempcode('DESCRIPTION_POINTS_FOR_COMPLETING'), 'points_for_passing', $points_for_passing, true)); } if (addon_installed('newsletter')) { $newsletters = new ocp_tempcode(); $newsletters->attach(form_input_list_entry('', false, do_lang_tempcode('NONE_EM'))); $_newsletters = $GLOBALS['SITE_DB']->query_select('newsletters', array('*'), NULL, 'ORDER BY id'); foreach ($_newsletters as $n) { $newsletters->attach(form_input_list_entry(strval($n['id']), $tied_newsletter == $n['id'], get_translated_text($n['title']))); } if (!$newsletters->is_empty()) { $fields->attach(form_input_list(do_lang_tempcode('TIED_TO_NEWSLETTER'), do_lang_tempcode('DESCRIPTION_TIED_TO_NEWSLETTER'), 'tied_newsletter', $newsletters, NULL, false, false)); } } if (get_value('disable_staff_notes') !== '1') { $fields->attach(form_input_text(do_lang_tempcode('NOTES'), do_lang_tempcode('DESCRIPTION_NOTES'), 'notes', $notes, false)); } return $fields; }
/** * The UI for editing a message. * * @return tempcode The UI. */ function chat_edit_message() { $title = get_page_title('EDIT_MESSAGE'); $id = get_param_integer('id'); $rows = $GLOBALS['SITE_DB']->query_select('chat_messages', array('*'), array('id' => $id), '', 1); if (!array_key_exists(0, $rows)) { return warn_screen($title, do_lang_tempcode('MISSING_RESOURCE')); } $myrow = $rows[0]; $room_id = $myrow['room_id']; check_chatroom_access($room_id); $room_details = $GLOBALS['SITE_DB']->query_select('chat_rooms', array('*'), array('id' => $room_id), '', 1); if (!array_key_exists(0, $room_details)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $row = $room_details[0]; $has_mod_access = has_specific_permission(get_member(), 'edit_lowrange_content', 'cms_chat', array('chat', $room_id)) || $row['room_owner'] == get_member() && has_specific_permission(get_member(), 'moderate_my_private_rooms'); if (!$has_mod_access) { access_denied('SPECIFIC_PERMISSION', 'edit_lowrange_content'); } //$post_url=build_url(array('page'=>'_SELF','type'=>'delete','id'=>$myrow['id'],'room_id'=>get_param_integer('room_id',db_get_first_id())),'_SELF'); //$edit_form=do_template('FORM',array('_GUID'=>'da2ac49bc6af253b36e2855763ad8ae3','HIDDEN'=>'','TEXT'=>paragraph(do_lang_tempcode('DESCRIPTION_DELETE_MESSAGE')),'FIELDS'=>'','SUBMIT_NAME'=>do_lang_tempcode('DELETE_MESSAGE'),'URL'=>$post_url)); $post_url = build_url(array('page' => '_SELF', 'type' => '_ed', 'id' => $myrow['id'], 'room_id' => $room_id), '_SELF'); $message = get_translated_tempcode($myrow['the_message']); require_code('form_templates'); $text_colour = $myrow['text_colour'] == '' ? get_option('chat_default_post_colour') : $myrow['text_colour']; $font_name = $myrow['font_name'] == '' ? get_option('chat_default_post_font') : $myrow['font_name']; $fields = form_input_text_comcode(do_lang_tempcode('MESSAGE'), do_lang_tempcode('DESCRIPTION_MESSAGE'), 'message', $message->evaluate(), true); $fields->attach(form_input_line(do_lang_tempcode('CHAT_OPTIONS_COLOUR_NAME'), do_lang_tempcode('CHAT_OPTIONS_COLOUR_DESCRIPTION'), 'textcolour', $text_colour, false)); //$fields->attach(do_template('EDIT_CSS_ENTRY',array('_GUID'=>'d65449d25908252cc7f34c19ee5e8747','COLOR'=>'#'.$myrow['text_colour'],'NAME'=>do_lan g_tempcode('TEXTCOLOUR'),'CONTEXT'=>do_l ang_tempcode('DESCRIPTION_TEXTCOLOUR')))); $fields->attach(form_input_line(do_lang_tempcode('CHAT_OPTIONS_TEXT_NAME'), do_lang_tempcode('CHAT_OPTIONS_TEXT_DESCRIPTION'), 'fontname', $font_name, false)); $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ACTIONS')))); $fields->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE_MESSAGE'), 'delete', false)); // $fields->attach(do_template('COLOUR_CHOOSER',array('_GUID'=>'817dbcdb419982774f86b8e5a0c5c1fe','NAME'=>$myrow['id'],'CONTEXT'=>do_l ang_tempcode('DESCRIPTION_TEXTCOLOUR'),'COLOR'=>$myrow['text_colour']))); //$edit_form->attach(do_template('FORM',array('_GUID'=>'43651e089d7ec45e1468ae57e3bf315e','HIDDEN'=>'','TEXT'=>'','FIELDS'=>$fields,'SUBMIT_NAME'=>do_lang_tempcode('EDIT_MESSAGE'),'URL'=>$post_url))); //return do_template('CHAT_PANEL',array('_GUID'=>'6278e2571f20ad1b9becd12e007caac2','TITLE'=>$title,'INTRODUCTION'=>'','CONTENT'=>$edit_form)); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('CHOOSE')), array('_SELF:_SELF:room:id=' . strval($room_id), do_lang_tempcode('CHAT_MOD_PANEL')))); return do_template('FORM_SCREEN', array('_GUID' => 'bf92ecd4d5f923f78bbed4faca6c0cb6', 'HIDDEN' => '', 'TITLE' => $title, 'TEXT' => '', 'FIELDS' => $fields, 'URL' => $post_url, 'SUBMIT_NAME' => do_lang_tempcode('SAVE'))); }
/** * Get form fields for adding/editing/finishing a member profile. * * @param boolean Whether we are only handling the essential details of a profile. * @param ?MEMBER The ID of the member we are handling (NULL: new member). * @param ?array A list of usergroups (NULL: default/current usergroups). * @param SHORT_TEXT The e-mail address. * @param BINARY Whether posts are previewed before they are made. * @param ?integer Day of date of birth (NULL: not known). * @param ?integer Month of date of birth (NULL: not known). * @param ?integer Year of date of birth (NULL: not known). * @param ?ID_TEXT The member timezone (NULL: site default). * @param ?ID_TEXT The members default theme (NULL: not known). * @param BINARY Whether the members age may be shown. * @param BINARY Whether the member sees signatures in posts. * @param ?BINARY Whether the member automatically is enabled for notifications for content they contribute to (NULL: get default from config). * @param ?LANGUAGE_NAME The members language (NULL: auto detect). * @param BINARY Whether the member allows e-mails via the site. * @param BINARY Whether the member allows e-mails from staff via the site. * @param BINARY Whether the profile has been validated. * @param ?GROUP The members primary (NULL: not known). * @param SHORT_TEXT The username. * @param BINARY Whether the member is permanently banned. * @param ID_TEXT The special type of profile this is (blank: not a special type). * @param BINARY Whether the member likes to view zones without menus, when a choice is available. * @param BINARY Whether the member username will be highlighted. * @param SHORT_TEXT Usergroups that may PT the member. * @param LONG_TEXT Rules that other members must agree to before they may start a PT with the member. * @param ?TIME When the member is on probation until (NULL: just finished probation / or effectively was never on it) * @return array A pair: The form fields, Hidden fields (both Tempcode). */ function ocf_get_member_fields_settings($mini_mode = true, $member_id = NULL, $groups = NULL, $email_address = '', $preview_posts = 0, $dob_day = NULL, $dob_month = NULL, $dob_year = NULL, $timezone = NULL, $theme = NULL, $reveal_age = 1, $views_signatures = 1, $auto_monitor_contrib_content = NULL, $language = NULL, $allow_emails = 1, $allow_emails_from_staff = 1, $validated = 1, $primary_group = NULL, $username = '', $is_perm_banned = 0, $special_type = '', $zone_wide = 1, $highlighted_name = 0, $pt_allow = '*', $pt_rules_text = '', $on_probation_until = NULL) { if (is_null($auto_monitor_contrib_content)) { $auto_monitor_contrib_content = get_value('no_auto_notifications') === '1' ? 0 : 1; } $hidden = new ocp_tempcode(); if (has_actual_page_access(get_member(), 'admin_ocf_join')) { $dob_optional = true; } else { $dob_optional = get_option('no_dob_ask') == '2'; } if ($member_id === $GLOBALS['OCF_DRIVER']->get_guest_id()) { fatal_exit(do_lang_tempcode('INTERNAL_ERROR')); } require_code('form_templates'); require_code('encryption'); if ($special_type == '' && !is_null($member_id)) { if (ocf_is_ldap_member($member_id)) { $special_type = 'ldap'; } if (ocf_is_httpauth_member($member_id)) { $special_type = 'httpauth'; } if ($GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id, 'm_password_compat_scheme') == 'remote') { $special_type = 'remote'; } } if (is_null($groups)) { $groups = is_null($member_id) ? ocf_get_all_default_groups(true) : $GLOBALS['OCF_DRIVER']->get_members_groups($member_id); } $fields = new ocp_tempcode(); // Human name / Username if ($special_type != 'ldap' && $special_type != 'remote' && $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id, 'm_password_compat_scheme') != 'facebook') { if (is_null($member_id) || has_actual_page_access(get_member(), 'admin_ocf_join') || has_specific_permission($member_id, 'rename_self')) { if (get_option('signup_fullname') == '1') { $fields->attach(form_input_line(do_lang_tempcode('NAME'), do_lang_tempcode('_DESCRIPTION_NAME'), is_null($member_id) ? 'username' : 'edit_username', $username, true)); } else { $prohibit_username_whitespace = get_option('prohibit_username_whitespace', true); if ($prohibit_username_whitespace == '1') { $fields->attach(form_input_codename(do_lang_tempcode('USERNAME'), do_lang_tempcode('DESCRIPTION_USERNAME'), is_null($member_id) ? 'username' : 'edit_username', $username, true)); } else { $fields->attach(form_input_line(do_lang_tempcode('USERNAME'), do_lang_tempcode('DESCRIPTION_USERNAME'), is_null($member_id) ? 'username' : 'edit_username', $username, true)); } } } } // Password if ($special_type == '') { if (is_null($member_id) || $member_id == get_member() || has_specific_permission(get_member(), 'assume_any_member')) { $fields->attach(form_input_password(do_lang_tempcode('PASSWORD'), do_lang_tempcode('DESCRIPTION_PASSWORD' . (!is_null($member_id) ? '_EDIT' : '')), is_null($member_id) ? 'password' : 'edit_password', $mini_mode)); $fields->attach(form_input_password(do_lang_tempcode('CONFIRM_PASSWORD'), '', 'password_confirm', $mini_mode)); } } // E-mail address if ($email_address == '') { $email_address = trim(get_param('email_address', '')); } if ($special_type != 'remote') { $fields->attach(form_input_email(do_lang_tempcode('EMAIL_ADDRESS'), get_option('skip_email_confirm_join') == '1' ? new ocp_tempcode() : do_lang_tempcode('MUST_BE_REAL_ADDRESS'), 'email_address', $email_address, !has_specific_permission(get_member(), 'member_maintenance'))); if (is_null($member_id) && $email_address == '' && get_option('skip_email_confirm_join') == '0') { $fields->attach(form_input_email(do_lang_tempcode('CONFIRM_EMAIL_ADDRESS'), '', 'email_address_confirm', '', !has_specific_permission(get_member(), 'member_maintenance'))); } } // DOB $default_time = is_null($dob_month) ? NULL : usertime_to_utctime(mktime(0, 0, 0, $dob_month, $dob_day, $dob_year)); if (get_option('no_dob_ask') != '1') { $fields->attach(form_input_date(do_lang_tempcode(get_option('no_dob_ask') == '2' ? 'BIRTHDAY' : 'DATE_OF_BIRTH'), '', 'dob', $dob_optional, false, false, $default_time, -130)); if (addon_installed('ocf_forum')) { $fields->attach(form_input_tick(do_lang_tempcode('RELATED_FIELD', do_lang_tempcode('REVEAL_AGE')), do_lang_tempcode('DESCRIPTION_REVEAL_AGE'), 'reveal_age', $reveal_age == 1)); } } // Work out what options we need to present $doing_international = get_option('allow_international') == '1' && $special_type != 'remote'; $_langs = find_all_langs(); $doing_langs = multi_lang() && $special_type != 'remote'; $doing_email_option = get_option('allow_email_disable') == '1'; $doing_email_from_staff_option = get_option('allow_email_from_staff_disable') == '1'; $unspecced_width_zone_exists = $GLOBALS['SITE_DB']->query_value_null_ok('zones', 'zone_name', array('zone_wide' => NULL)); $unspecced_theme_zone_exists = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . get_table_prefix() . 'zones WHERE ' . db_string_equal_to('zone_theme', '') . ' OR ' . db_string_equal_to('zone_theme', '-1')); $doing_wide_option = $special_type != 'remote' && !is_null($unspecced_width_zone_exists) && !$mini_mode; $doing_theme_option = $unspecced_theme_zone_exists != 0 && !$mini_mode; $doing_local_forum_options = addon_installed('ocf_forum') && $special_type != 'remote' && !$mini_mode; if ($doing_international || $doing_langs || $doing_email_option || $doing_wide_option || $doing_theme_option || $doing_local_forum_options) { $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('FORCE_OPEN' => is_null($member_id) ? true : NULL, 'TITLE' => do_lang_tempcode('SETTINGS')))); } require_lang('config'); // Timezones, if enabled if ($doing_international) { $timezone_list = nice_get_timezone_list($timezone); $fields->attach(form_input_list(do_lang_tempcode('TIME_ZONE'), do_lang_tempcode('DESCRIPTION_TIMEZONE_MEMBER'), 'timezone', $timezone_list)); } // Language choice, if we have multiple languages on site if ($doing_langs) { $lang_list = new ocp_tempcode(); $no_lang_set = is_null($language) || $language == ''; $allow_no_lang_set = get_value('allow_no_lang_selection') === '1'; if ($allow_no_lang_set) { $lang_list->attach(form_input_list_entry('', $no_lang_set, do_lang_tempcode('UNSET'))); } else { if ($no_lang_set) { $language = user_lang(); } } $lang_list->attach(nice_get_langs($language)); $fields->attach(form_input_list(do_lang_tempcode('LANGUAGE'), '', 'language', $lang_list, NULL, false, !$allow_no_lang_set)); } // Email privacy if ($doing_email_option) { $fields->attach(form_input_tick(do_lang_tempcode('ALLOW_EMAILS'), do_lang_tempcode('DESCRIPTION_ALLOW_EMAILS'), 'allow_emails', $allow_emails == 1)); } if ($doing_email_from_staff_option) { $fields->attach(form_input_tick(do_lang_tempcode('ALLOW_EMAILS_FROM_STAFF'), do_lang_tempcode('DESCRIPTION_ALLOW_EMAILS_FROM_STAFF'), 'allow_emails_from_staff', $allow_emails_from_staff == 1)); } if (!$mini_mode) { // Wide-option, if we have any zones giving a choice require_lang('zones'); if ($doing_wide_option) { $fields->attach(form_input_tick(do_lang_tempcode('WIDE'), do_lang_tempcode('DESCRIPTION_MEMBER_ZONE_WIDE'), 'zone_wide', $zone_wide == 1)); } // Theme, if we have any zones giving a choice require_code('themes2'); $entries = nice_get_themes($theme, false, false, 'RELY_SITE_DEFAULT'); require_lang('themes'); if ($doing_theme_option) { $fields->attach(form_input_list(do_lang_tempcode('THEME'), do_lang_tempcode('DESCRIPTION_THEME'), 'theme', $entries)); } // Various forum options if (addon_installed('ocf_forum')) { if ($special_type != 'remote') { if (get_option('forced_preview_option') == '1') { $fields->attach(form_input_tick(do_lang_tempcode('PREVIEW_POSTS'), do_lang_tempcode('DESCRIPTION_PREVIEW_POSTS'), 'preview_posts', $preview_posts == 1)); } if (get_value('disable_views_sigs_option') !== '1') { if (addon_installed('ocf_signatures')) { $fields->attach(form_input_tick(do_lang_tempcode('VIEWS_SIGNATURES'), do_lang_tempcode('DESCRIPTION_VIEWS_SIGNATURES'), 'views_signatures', $views_signatures == 1)); } } else { $hidden->attach(form_input_hidden('views_signatures', '1')); } //$fields->attach(form_input_tick(do_lang_tempcode('AUTO_NOTIFICATION_CONTRIB_CONTENT'),do_lang_tempcode('DESCRIPTION_AUTO_NOTIFICATION_CONTRIB_CONTENT'),'auto_monitor_contrib_content',$auto_monitor_contrib_content==1)); $usergroup_list = new ocp_tempcode(); $lgroups = $GLOBALS['OCF_DRIVER']->get_usergroup_list(true, true); foreach ($lgroups as $key => $val) { if ($key != db_get_first_id()) { $usergroup_list->attach(form_input_list_entry(strval($key), $pt_allow == '*' || count(array_intersect(array(strval($key)), explode(',', $pt_allow))) != 0, $val)); } } if (get_value('disable_pt_restrict') !== '1') { $fields->attach(form_input_multi_list(do_lang_tempcode('PT_ALLOW'), addon_installed('chat') ? do_lang_tempcode('PT_ALLOW_DESCRIPTION_CHAT') : do_lang_tempcode('PT_ALLOW_DESCRIPTION'), 'pt_allow', $usergroup_list)); $fields->attach(form_input_text_comcode(do_lang_tempcode('PT_RULES_TEXT'), do_lang_tempcode('PT_RULES_TEXT_DESCRIPTION'), 'pt_rules_text', $pt_rules_text, false)); } } } // Prepare list of usergroups, if maybe we are gonna let (a) usergroup-change field(s) $group_count = $GLOBALS['FORUM_DB']->query_value('f_groups', 'COUNT(*)'); $rows = $GLOBALS['FORUM_DB']->query_select('f_groups', array('id', 'g_name', 'g_hidden', 'g_open_membership'), $group_count > 200 ? array('g_is_private_club' => 0) : NULL, 'ORDER BY g_order'); $_groups = new ocp_tempcode(); $default_primary_group = get_first_default_group(); $current_primary_group = NULL; foreach ($rows as $group) { if ($group['id'] != db_get_first_id()) { $selected = $group['id'] == $primary_group || is_null($primary_group) && $group['id'] == $default_primary_group; if ($selected) { $current_primary_group = $group['id']; } $_groups->attach(form_input_list_entry(strval($group['id']), $selected, get_translated_text($group['g_name'], $GLOBALS['FORUM_DB']))); } } // Some admin options... if (has_specific_permission(get_member(), 'member_maintenance')) { $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('MEMBER_ACCESS')))); // Probation if (has_specific_permission(get_member(), 'probate_members')) { $fields->attach(form_input_date(do_lang_tempcode('ON_PROBATION_UNTIL'), do_lang_tempcode('DESCRIPTION_ON_PROBATION_UNTIL'), 'on_probation_until', true, is_null($on_probation_until) || $on_probation_until <= time(), true, $on_probation_until, 2)); } // Primary usergroup if ($special_type != 'ldap') { if (has_specific_permission(get_member(), 'assume_any_member')) { if (is_null($member_id) || !$GLOBALS['FORUM_DRIVER']->is_super_admin($member_id) || count($GLOBALS['FORUM_DRIVER']->member_group_query($GLOBALS['FORUM_DRIVER']->get_super_admin_groups(), 2)) > 1) { $fields->attach(form_input_list(do_lang_tempcode('PRIMARY_GROUP'), do_lang_tempcode('DESCRIPTION_PRIMARY_GROUP'), 'primary_group', $_groups)); } } } } // Secondary usergroups if ($special_type != 'ldap') { $_groups2 = new ocp_tempcode(); $members_groups = is_null($member_id) ? array() : $GLOBALS['OCF_DRIVER']->get_members_groups($member_id, false, false); foreach ($rows as $group) { if ($group['g_hidden'] == 1 && !array_key_exists($group['id'], $members_groups) && !has_specific_permission(get_member(), 'see_hidden_groups')) { continue; } if ($group['id'] != db_get_first_id() && $group['id'] != $current_primary_group && (array_key_exists($group['id'], $members_groups) || has_specific_permission(get_member(), 'assume_any_member') || $group['g_open_membership'] == 1)) { $selected = array_key_exists($group['id'], $members_groups); $_groups2->attach(form_input_list_entry(strval($group['id']), $selected, get_translated_text($group['g_name'], $GLOBALS['FORUM_DB']))); } } $sec_url = build_url(array('page' => 'groups', 'type' => 'misc'), get_module_zone('groups')); if (!$_groups2->is_empty()) { $fields->attach(form_input_multi_list(do_lang_tempcode('SECONDARY_GROUP_MEMBERSHIP'), do_lang_tempcode('DESCRIPTION_SECONDARY_GROUP', escape_html($sec_url->evaluate())), 'secondary_groups', $_groups2)); } } // Special admin options if (has_specific_permission(get_member(), 'member_maintenance')) { if ($validated == 0) { $validated = get_param_integer('validated', 0); if ($validated == 1) { attach_message(do_lang_tempcode('WILL_BE_VALIDATED_WHEN_SAVING')); } } if (addon_installed('unvalidated')) { $fields->attach(form_input_tick(do_lang_tempcode('VALIDATED'), do_lang_tempcode('DESCRIPTION_MEMBER_VALIDATED'), 'validated', $validated == 1)); } if (get_value('disable_highlight_name') !== '1') { $fields->attach(form_input_tick(do_lang_tempcode('HIGHLIGHTED_NAME'), do_lang_tempcode(addon_installed('pointstore') ? 'DESCRIPTION_HIGHLIGHTED_NAME_P' : 'DESCRIPTION_HIGHLIGHTED_NAME'), 'highlighted_name', $highlighted_name == 1)); } if (!is_null($member_id) && $member_id != get_member()) { // Can't ban someone new, and can't ban yourself $fields->attach(form_input_tick(do_lang_tempcode('_BANNED'), do_lang_tempcode('DESCRIPTION_MEMBER_BANNED'), 'is_perm_banned', $is_perm_banned == 1)); } } } return array($fields, $hidden); }
/** * Get tempcode for a gallery adding/editing form. * * @param ID_TEXT The gallery codename * @param SHORT_TEXT The full human-readeable name of the gallery * @param LONG_TEXT The description of the gallery * @param SHORT_TEXT Teaser text for the gallery * @param LONG_TEXT Hidden notes associated with the gallery * @param ID_TEXT The parent gallery (blank: no parent) * @param BINARY Whether images may be put in this gallery * @param BINARY Whether videos may be put in this gallery * @param BINARY Whether the gallery serves as a container for automatically created member galleries * @param ?BINARY Whether the gallery uses the flow mode interface (NULL: pick statistically based on current usage of other galleries) * @param ?URLPATH The representative image of the gallery (NULL: none) * @param ?URLPATH Watermark (NULL: none) * @param ?URLPATH Watermark (NULL: none) * @param ?URLPATH Watermark (NULL: none) * @param ?URLPATH Watermark (NULL: none) * @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) * @return array A pair: the tempcode for the visible fields, and the tempcode for the hidden fields */ function get_form_fields($name = '', $fullname = '', $description = '', $teaser = '', $notes = '', $parent_id = '', $accept_images = 1, $accept_videos = 1, $is_member_synched = 0, $flow_mode_interface = NULL, $rep_image = NULL, $watermark_top_left = NULL, $watermark_top_right = NULL, $watermark_bottom_left = NULL, $watermark_bottom_right = NULL, $allow_rating = NULL, $allow_comments = NULL) { list($allow_rating, $allow_comments, ) = $this->choose_feedback_fields_statistically($allow_rating, $allow_comments, 1); global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'cat'; $NON_CANONICAL_PARAMS[] = 'validated'; if (is_null($flow_mode_interface)) { $cnt = $GLOBALS['SITE_DB']->query_value('galleries', 'COUNT(*)'); if ($cnt < 5000) { $flow_mode_interface = intval(round($GLOBALS['SITE_DB']->query_value('galleries', 'AVG(flow_mode_interface)'))); // Determine default based on what is 'the norm' currently. Sometimes maths is beautiful :) } else { $flow_mode_interface = intval(round($GLOBALS['SITE_DB']->query_value('galleries', 'AVG(flow_mode_interface)', array('parent_id' => 'root')))); // Determine default based on what is 'the norm' currently. Sometimes maths is beautiful :) } } $fields = new ocp_tempcode(); require_code('form_templates'); $fields->attach(form_input_line(do_lang_tempcode('TITLE'), do_lang_tempcode('DESCRIPTION_TITLE'), 'fullname', $fullname, true)); if ($name != 'root') { $fields->attach(form_input_codename(do_lang_tempcode('CODENAME'), do_lang_tempcode('DESCRIPTION_CODENAME'), 'name', $name, true)); } $fields->attach(form_input_text_comcode(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_DESCRIPTION'), 'description', $description, false)); if ($parent_id == '') { $parent_id = get_param('cat', ''); } if ($name != 'root') { $fields->attach(form_input_tree_list(do_lang_tempcode('PARENT'), do_lang_tempcode('DESCRIPTION_PARENT'), 'parent_id', NULL, 'choose_gallery', array('filter' => 'only_conventional_galleries', 'purity' => true, 'addable_filter' => true), true, $parent_id)); } $fields->attach(form_input_various_ticks(array(array(do_lang_tempcode('ACCEPT_IMAGES'), 'accept_images', $accept_images == 1, do_lang_tempcode('DESCRIPTION_ACCEPT_IMAGES')), array(do_lang_tempcode('ACCEPT_VIDEOS'), 'accept_videos', $accept_videos == 1, do_lang_tempcode('DESCRIPTION_ACCEPT_VIDEOS'))), new ocp_tempcode(), NULL, do_lang_tempcode('ACCEPTED_MEDIA_TYPES'))); $fields->attach(form_input_tick(do_lang_tempcode('FLOW_MODE_INTERFACE'), do_lang_tempcode('DESCRIPTION_FLOW_MODE_INTERFACE'), 'flow_mode_interface', $flow_mode_interface == 1)); $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => $rep_image == '' && $teaser == '' && $is_member_synched == 0, 'TITLE' => do_lang_tempcode('ADVANCED')))); $fields->attach(form_input_upload(do_lang_tempcode('REPRESENTATIVE_IMAGE'), do_lang_tempcode('DESCRIPTION_REPRESENTATIVE_IMAGE_GALLERY'), 'rep_image', false, $rep_image, NULL, true, str_replace(' ', '', get_option('valid_images')))); // Only show tease option if tease block being used $teaser_shows = false; $zones = find_all_zones(false, true); $pages = array(); foreach ($zones as $_zone) { $pages[$_zone[0]] = find_all_pages_wrap($_zone[0], true); } foreach ($pages as $zone => $under) { foreach ($under as $filename => $type) { if (substr(strtolower($filename), -4) == '.txt') { $matches = array(); $contents = file_get_contents(zone_black_magic_filterer((substr($type, 0, 15) == 'comcode_custom/' ? get_custom_file_base() : get_file_base()) . '/' . ($zone == '' ? '' : $zone . '/') . 'pages/' . $type . '/' . $filename)); $fallback = get_file_base() . '/' . ($zone == '' ? '' : $zone . '/') . 'pages/comcode/' . fallback_lang() . '/' . $filename; if (file_exists($fallback)) { $contents .= file_get_contents($fallback); } if (preg_match('#\\[block[^\\]]*\\]main_gallery_tease\\[/block\\]#', $contents, $matches) != 0) { $teaser_shows = true; } } } } if ($teaser_shows) { $fields->attach(form_input_line_comcode(do_lang_tempcode('TEASER'), do_lang_tempcode('DESCRIPTION_TEASER'), 'teaser', $teaser, false)); } $fields->attach(form_input_tick(do_lang_tempcode('IS_MEMBER_SYNCHED'), do_lang_tempcode('DESCRIPTION_IS_MEMBER_SYNCHED_GALLERY'), 'is_member_synched', $is_member_synched == 1)); $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => is_null($watermark_top_left) && is_null($watermark_top_right) && is_null($watermark_bottom_left) && is_null($watermark_bottom_right), 'TITLE' => do_lang_tempcode('WATERMARKING')))); $fields->attach(form_input_upload(do_lang_tempcode('_WATERMARK', do_lang_tempcode('TOP_LEFT')), do_lang_tempcode('_DESCRIPTION_WATERMARK', do_lang_tempcode('TOP_LEFT')), 'watermark_top_left', false, $watermark_top_left, NULL, true, str_replace(' ', '', get_option('valid_images')))); $fields->attach(form_input_upload(do_lang_tempcode('_WATERMARK', do_lang_tempcode('TOP_RIGHT')), do_lang_tempcode('_DESCRIPTION_WATERMARK', do_lang_tempcode('TOP_RIGHT')), 'watermark_top_right', false, $watermark_top_right, NULL, true, str_replace(' ', '', get_option('valid_images')))); $fields->attach(form_input_upload(do_lang_tempcode('_WATERMARK', do_lang_tempcode('BOTTOM_LEFT')), do_lang_tempcode('_DESCRIPTION_WATERMARK', do_lang_tempcode('BOTTOM_LEFT')), 'watermark_bottom_left', false, $watermark_bottom_left, NULL, true, str_replace(' ', '', get_option('valid_images')))); $fields->attach(form_input_upload(do_lang_tempcode('_WATERMARK', do_lang_tempcode('BOTTOM_RIGHT')), do_lang_tempcode('_DESCRIPTION_WATERMARK', do_lang_tempcode('BOTTOM_RIGHT')), 'watermark_bottom_right', false, $watermark_bottom_right, NULL, true, str_replace(' ', '', get_option('valid_images')))); $hidden = new ocp_tempcode(); handle_max_file_size($hidden, 'image'); require_code('feedback2'); $fields->attach(feedback_fields($allow_rating == 1, $allow_comments == 1, NULL, false, $notes, $allow_comments == 2, true)); // Permissions $fields->attach($this->get_permission_fields($name, NULL, $name == '')); return array($fields, $hidden); }
/** * The UI for managing super debranding. * * @return tempcode The UI */ function misc() { $title = get_page_title('SUPER_DEBRAND'); require_code('form_templates'); $rebrand_name = get_value('rebrand_name'); if (is_null($rebrand_name)) { $rebrand_name = 'ocPortal'; } $rebrand_base_url = get_value('rebrand_base_url'); if (is_null($rebrand_base_url)) { $rebrand_base_url = 'http://ocportal.com'; } $company_name = get_value('company_name'); if (is_null($company_name)) { $company_name = 'ocProducts'; } $keyboard_map = file_exists(get_file_base() . '/pages/comcode/' . get_site_default_lang() . '/keymap.txt') ? file_get_contents(get_file_base() . '/pages/comcode/' . get_site_default_lang() . '/keymap.txt') : file_get_contents(get_file_base() . '/pages/comcode/' . fallback_lang() . '/keymap.txt'); if (file_exists(get_file_base() . '/pages/comcode_custom/' . get_site_default_lang() . '/keymap.txt')) { $keyboard_map = file_get_contents(get_file_base() . '/pages/comcode_custom/' . get_site_default_lang() . '/keymap.txt'); } if (file_exists(get_file_base() . '/adminzone/pages/comcode_custom/' . get_site_default_lang() . '/website.txt')) { $adminguide = file_get_contents(get_file_base() . '/adminzone/pages/comcode_custom/' . get_site_default_lang() . '/website.txt'); } else { $adminguide = do_lang('ADMINGUIDE_DEFAULT_TRAINING'); } if (file_exists(get_file_base() . '/adminzone/pages/comcode_custom/' . get_site_default_lang() . '/start.txt')) { $start_page = file_get_contents(get_file_base() . '/adminzone/pages/comcode_custom/' . get_site_default_lang() . '/start.txt'); } elseif (file_exists(get_file_base() . '/adminzone/pages/comcode/' . get_site_default_lang() . '/start.txt')) { $start_page = file_exists(get_file_base() . '/adminzone/pages/comcode/' . get_site_default_lang() . '/start.txt') ? file_get_contents(get_file_base() . '/adminzone/pages/comcode/' . get_site_default_lang() . '/start.txt') : file_get_contents(get_file_base() . '/adminzone/pages/comcode/' . fallback_lang() . '/start.txt'); } else { $start_page = do_lang('REBRAND_FRONT_PAGE'); } $fields = new ocp_tempcode(); $fields->attach(form_input_line(do_lang_tempcode('REBRAND_NAME'), do_lang_tempcode('DESCRIPTION_REBRAND_NAME'), 'rebrand_name', $rebrand_name, true)); $fields->attach(form_input_line(do_lang_tempcode('REBRAND_BASE_URL'), do_lang_tempcode('DESCRIPTION_BRAND_BASE_URL', escape_html('docs' . strval(ocp_version()))), 'rebrand_base_url', $rebrand_base_url, true)); $fields->attach(form_input_line(do_lang_tempcode('COMPANY_NAME'), '', 'company_name', $company_name, true)); $fields->attach(form_input_text_comcode(do_lang_tempcode('ADMINGUIDE'), do_lang_tempcode('DESCRIPTION_ADMINGUIDE'), 'adminguide', $adminguide, true)); $fields->attach(form_input_text_comcode(do_lang_tempcode('ADMINSTART_PAGE'), do_lang_tempcode('DESCRIPTION_ADMINSTART_PAGE'), 'start_page', $start_page, true)); $fields->attach(form_input_text_comcode(do_lang_tempcode('KEYBOARD_MAP'), '', 'keyboard_map', $keyboard_map, true)); $fields->attach(form_input_tick(do_lang_tempcode('DELETE_UN_PC'), do_lang_tempcode('DESCRIPTION_DELETE_UN_PC'), 'churchy', false)); $fields->attach(form_input_tick(do_lang_tempcode('SHOW_DOCS'), do_lang_tempcode('DESCRIPTION_SHOW_DOCS'), 'show_docs', get_option('show_docs') == '1')); $fields->attach(form_input_upload(do_lang_tempcode('FAVICON'), do_lang_tempcode('DESCRIPTION_FAVICON'), 'favicon', false, find_theme_image('favicon'), NULL, true, str_replace(' ', '', get_option('valid_images')))); $fields->attach(form_input_upload(do_lang_tempcode('APPLEICON'), do_lang_tempcode('DESCRIPTION_APPLEICON'), 'appleicon', false, find_theme_image('appleicon'), NULL, true, str_replace(' ', '', get_option('valid_images')))); if (addon_installed('ocf_avatars')) { $fields->attach(form_input_upload(do_lang_tempcode('SYSTEM_AVATAR'), do_lang_tempcode('DESCRIPTION_SYSTEM_AVATAR'), 'system_avatar', false, find_theme_image('ocf_default_avatars/default_set/ocp_fanatic'), NULL, true, str_replace(' ', '', get_option('valid_images')))); } $post_url = build_url(array('page' => '_SELF', 'type' => 'actual'), '_SELF'); $submit_name = do_lang_tempcode('SUPER_DEBRAND'); return do_template('FORM_SCREEN', array('HIDDEN' => '', 'TITLE' => $title, 'URL' => $post_url, 'FIELDS' => $fields, 'TEXT' => do_lang_tempcode('WARNING_SUPER_DEBRAND_MAJOR_CHANGES'), 'SUBMIT_NAME' => $submit_name)); }
/** * Get tempcode for a warning adding/editing form. * * @param boolean Whether it is a new warning/punishment record * @param LONG_TEXT The explanation for the warning/punishment record * @param BINARY Whether to make this a formal warning * @param ?MEMBER The member the warning is for (NULL: get from environment) * @return array A pair: the tempcode for the visible fields, and the tempcode for the hidden fields */ function get_form_fields($new = true, $explanation = '', $is_warning = 0, $member_id = NULL) { if (is_null($member_id)) { $member_id = get_param_integer('id', get_member()); } $hidden = new ocp_tempcode(); $fields = new ocp_tempcode(); require_code('form_templates'); // Information about their history, and the rules - to educate the warner/punisher if ($new) { $post_id = get_param_integer('post_id', NULL); $hidden->attach(form_input_hidden('member_id', strval($member_id))); $username = $GLOBALS['FORUM_DRIVER']->get_username($member_id); $num_warnings = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id, 'm_cache_warnings'); $_rules_url = build_url(array('page' => 'rules'), '_SEARCH'); $rules_url = $_rules_url->evaluate(); $_history_url = build_url(array('page' => '_SELF', 'type' => 'history', 'id' => $member_id), '_SELF'); $history_url = $_history_url->evaluate(); $profile_url = $GLOBALS['FORUM_DRIVER']->member_profile_url($member_id, false, true); if (is_object($profile_url)) { $profile_url = $profile_url->evaluate(); } $this->add_text = do_lang_tempcode('HAS_ALREADY_X_WARNINGS', escape_html($username), integer_format($num_warnings), array(escape_html(get_site_name()), escape_html($rules_url), escape_html($history_url), escape_html($profile_url))); } $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('MODULE_TRANS_NAME_warnings')))); $fields->attach(form_input_tick(do_lang_tempcode('WHETHER_MAKE_WARNING'), do_lang_tempcode('DESCRIPTION_WHETHER_MAKE_WARNING'), 'is_warning', $is_warning == 1)); // Punitive actions if ($new) { $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('PUNITIVE_ACTIONS')))); if (!is_null($post_id)) { $topic_id = $GLOBALS['FORUM_DB']->query_value_null_ok('f_posts', 'p_topic_id', array('id' => $post_id)); if (!is_null($topic_id)) { $forum_id = $GLOBALS['FORUM_DB']->query_value('f_topics', 't_forum_id', array('id' => $topic_id)); $hidden->attach(form_input_hidden('topic_id', strval($topic_id))); $hidden->attach(form_input_hidden('forum_id', strval($forum_id))); $silence_topic_time = NULL; //time()+60*60*24*7; $silence_forum_time = NULL; //time()+60*60*24*7; $active_until = $GLOBALS['SITE_DB']->query_value_null_ok('msp', 'active_until', array('member_id' => $member_id, 'specific_permission' => 'submit_lowrange_content', 'the_page' => '', 'module_the_name' => 'topics', 'category_name' => strval($topic_id))); if (!is_null($active_until)) { $silence_topic_time = $active_until; } $active_until = $GLOBALS['SITE_DB']->query_value_null_ok('msp', 'active_until', array('member_id' => $member_id, 'specific_permission' => 'submit_lowrange_content', 'the_page' => '', 'module_the_name' => 'forums', 'category_name' => strval($forum_id))); if (!is_null($active_until)) { $silence_forum_time = $active_until; } $fields->attach(form_input_date(do_lang_tempcode('SILENCE_FROM_TOPIC'), do_lang_tempcode('DESCRIPTION_SILENCE_FROM_TOPIC'), 'silence_from_topic', true, true, true, $silence_topic_time, 2)); $fields->attach(form_input_date(do_lang_tempcode('SILENCE_FROM_FORUM'), do_lang_tempcode('DESCRIPTION_SILENCE_FROM_FORUM'), 'silence_from_forum', true, true, true, $silence_forum_time, 2)); } } if (has_specific_permission(get_member(), 'probate_members')) { $fields->attach(form_input_integer(do_lang_tempcode('EXTEND_PROBATION'), do_lang_tempcode('DESCRIPTION_EXTEND_PROBATION'), 'probation', 0, true)); } if (addon_installed('securitylogging')) { if (has_actual_page_access(get_member(), 'admin_ipban')) { $fields->attach(form_input_tick(do_lang_tempcode('WHETHER_BANNED_IP'), do_lang_tempcode('DESCRIPTION_WHETHER_BANNED_IP'), 'banned_ip', false)); } } if (addon_installed('points')) { if (has_actual_page_access(get_member(), 'admin_points')) { require_code('points'); $num_points_currently = available_points($member_id); $fields->attach(form_input_integer(do_lang_tempcode('CHARGED_POINTS'), do_lang_tempcode('DESCRIPTION_CHARGED_POINTS', escape_html(integer_format($num_points_currently))), 'charged_points', 0, true)); } } if (has_specific_permission(get_member(), 'member_maintenance')) { $fields->attach(form_input_tick(do_lang_tempcode('BANNED_MEMBER'), do_lang_tempcode('DESCRIPTION_BANNED_MEMBER'), 'banned_member', false)); $rows = $GLOBALS['FORUM_DB']->query_select('f_groups', array('id', 'g_name'), array('g_is_private_club' => 0)); $groups = new ocp_tempcode(); $groups->attach(form_input_list_entry('-1', false, do_lang_tempcode('NA_EM'))); foreach ($rows as $group) { if ($group['id'] != db_get_first_id()) { $groups->attach(form_input_list_entry(strval($group['id']), false, get_translated_text($group['g_name'], $GLOBALS['FORUM_DB']))); } } $fields->attach(form_input_list(do_lang_tempcode('CHANGE_USERGROUP_TO'), do_lang_tempcode('DESCRIPTION_CHANGE_USERGROUP_TO'), 'changed_usergroup_from', $groups)); } } // Explanatory text $keep = symbol_tempcode('KEEP'); $load_url = find_script('warnings') . '?type=load' . $keep->evaluate(); $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('EXPLANATORY_TEXT'), 'HELP' => do_lang_tempcode('LOAD_SAVED_WARNING', escape_html($load_url))))); $fields->attach(form_input_line_comcode(do_lang_tempcode('EXPLANATION'), do_lang_tempcode('DESCRIPTION_EXPLANATION'), 'explanation', $explanation, true)); if ($new) { $message = ''; if (!is_null($post_id)) { $_postdetails_text = $GLOBALS['FORUM_DB']->query_value_null_ok('f_posts', 'p_post', array('id' => $post_id)); if (!is_null($_postdetails_text)) { $message = '[quote="' . $username . '"]' . chr(10) . get_translated_text($_postdetails_text) . chr(10) . '[/quote]'; } } $fields->attach(form_input_text_comcode(do_lang_tempcode('MESSAGE'), do_lang_tempcode('DESCRIPTION_PP_MESSAGE'), 'message', $message, false)); $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ACTIONS')))); $fields->attach(form_input_line(do_lang_tempcode('SAVE_WARNING_DETAILS'), do_lang_tempcode('DESCRIPTION_SAVE_WARNING_DETAILS'), 'save', '', false)); } return array($fields, $hidden); }
/** * Get tempcode for adding/editing form. * * @param SHORT_TEXT The title * @param LONG_TEXT The description * @param SHORT_TEXT The cost * @param integer The length * @param SHORT_TEXT The units for the length * @set y m d w * @param ?GROUP The usergroup that purchasing gains membership to (NULL: super members) * @param BINARY Whether this is applied to primary usergroup membership * @param BINARY Whether this is currently enabled * @param ?LONG_TEXT The text of the e-mail to send out when a subscription is start (NULL: default) * @param ?LONG_TEXT The text of the e-mail to send out when a subscription is ended (NULL: default) * @param ?LONG_TEXT The text of the e-mail to send out when a subscription cannot be renewed because the subproduct is gone (NULL: default) * @param ?AUTO_LINK ID of existing subscription (NULL: new) * @return array Tuple: The input fields, The hidden fields, The delete fields */ function get_form_fields($title = '', $description = '', $cost = '9.99', $length = 12, $length_units = 'm', $group_id = NULL, $uses_primary = 0, $enabled = 1, $mail_start = NULL, $mail_end = NULL, $mail_uhoh = NULL, $id = NULL) { if ($title == '' && get_forum_type() == 'ocf') { $add_usergroup_url = build_url(array('page' => 'admin_ocf_groups', 'type' => 'ad'), get_module_zone('admin_ocf_groups')); attach_message(do_lang_tempcode('ADD_USER_GROUP_FIRST', escape_html($add_usergroup_url->evaluate())), 'inform'); } if (is_null($group_id)) { $group_id = get_param_integer('group_id', db_get_first_id() + 3); } if (is_null($mail_start)) { $mail_start = do_lang('_PAID_SUBSCRIPTION_STARTED', get_option('site_name')); } if (is_null($mail_end)) { $_purchase_url = build_url(array('page' => 'purchase'), get_module_zone('purchase'), NULL, false, false, true); $purchase_url = $_purchase_url->evaluate(); $mail_end = do_lang('_PAID_SUBSCRIPTION_ENDED', get_option('site_name'), $purchase_url); } if (is_null($mail_uhoh)) { $mail_uhoh = do_lang('_PAID_SUBSCRIPTION_UHOH', get_option('site_name')); } $fields = new ocp_tempcode(); $fields->attach(form_input_line(do_lang_tempcode('TITLE'), do_lang_tempcode('DESCRIPTION_USERGROUP_SUBSCRIPTION_TITLE'), 'title', $title, true)); $fields->attach(form_input_text_comcode(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_USERGROUP_SUBSCRIPTION_DESCRIPTION'), 'description', $description, true)); $fields->attach(form_input_float(do_lang_tempcode('COST'), do_lang_tempcode('DESCRIPTION_USERGROUP_SUBSCRIPTION_COST'), 'cost', floatval($cost), true)); $list = new ocp_tempcode(); foreach (array('d', 'w', 'm', 'y') as $unit) { $list->attach(form_input_list_entry($unit, $unit == $length_units, do_lang_tempcode('LENGTH_UNIT_' . $unit))); } $fields->attach(form_input_list(do_lang_tempcode('LENGTH_UNITS'), do_lang_tempcode('DESCRIPTION_LENGTH_UNITS'), 'length_units', $list)); $list = new ocp_tempcode(); $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(); foreach ($groups as $id => $group) { $list->attach(form_input_list_entry(strval($id), $id == $group_id, $group)); } $fields->attach(form_input_integer(do_lang_tempcode('SUBSCRIPTION_LENGTH'), do_lang_tempcode('DESCRIPTION_USERGROUP_SUBSCRIPTION_LENGTH'), 'length', $length, true)); $fields->attach(form_input_list(do_lang_tempcode('GROUP'), do_lang_tempcode('DESCRIPTION_USERGROUP_SUBSCRIPTION_GROUP'), 'group_id', $list)); $fields->attach(form_input_tick(do_lang_tempcode('USES_PRIMARY'), do_lang_tempcode('DESCRIPTION_USES_PRIMARY'), 'uses_primary', $uses_primary == 1)); $fields->attach(form_input_tick(do_lang_tempcode('ENABLED'), do_lang_tempcode('DESCRIPTION_USERGROUP_SUBSCRIPTION_ENABLED'), 'enabled', $enabled == 1)); $fields->attach(form_input_text_comcode(do_lang_tempcode('MAIL_START'), do_lang_tempcode('DESCRIPTION_USERGROUP_SUBSCRIPTION_MAIL_START'), 'mail_start', $mail_start, true, NULL, true)); $fields->attach(form_input_text_comcode(do_lang_tempcode('MAIL_END'), do_lang_tempcode('DESCRIPTION_USERGROUP_SUBSCRIPTION_MAIL_END'), 'mail_end', $mail_end, true, NULL, true)); $fields->attach(form_input_text_comcode(do_lang_tempcode('MAIL_UHOH'), do_lang_tempcode('DESCRIPTION_USERGROUP_SUBSCRIPTION_MAIL_UHOH'), 'mail_uhoh', $mail_uhoh, false, NULL, true)); $delete_fields = NULL; if ($GLOBALS['SITE_DB']->query_value('subscriptions', 'COUNT(*)', array('s_type_code' => 'USERGROUP' . strval($id))) > 0) { $delete_fields = new ocp_tempcode(); $delete_fields->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE_USERGROUP_SUB_DANGER'), 'delete', false)); } return array($fields, new ocp_tempcode(), $delete_fields, NULL, !is_null($delete_fields)); }
/** * Get a form to edit/send/delete an email. * * @return tempcode The result of execution. */ function edit() { $title = get_page_title('HANDLE_QUEUED_MESSAGE'); $id = get_param_integer('id'); $fields = new ocp_tempcode(); require_code('form_templates'); $rows = $GLOBALS['SITE_DB']->query_select('logged_mail_messages', array('*'), array('id' => $id)); if (!array_key_exists(0, $rows)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $row = $rows[0]; $from_email = $row['m_from_email']; if ($from_email == '') { $from_email = get_option('staff_address'); } $from_name = $row['m_from_name']; if ($from_name == '') { $from_name = get_site_name(); } $to_email = unserialize($row['m_to_email']); if (is_string($to_email)) { $to_email = array($to_email); } if (!array_key_exists(0, $to_email)) { $to_email[0] = get_option('staff_address'); } $to_name = unserialize($row['m_to_name']); if (is_null($to_name) || $to_name == array(NULL) || $to_name == array('')) { $to_name = array(get_site_name()); } if (is_string($to_name)) { $to_name = array($to_name); } if (!array_key_exists(0, $to_name)) { $to_name[0] = get_site_name(); } $fields->attach(form_input_line_comcode(do_lang_tempcode('SUBJECT'), '', 'subject', $row['m_subject'], true)); $fields->attach(form_input_email(do_lang_tempcode('FROM_EMAIL'), '', 'from_email', $from_email, false)); $fields->attach(form_input_line(do_lang_tempcode('FROM_NAME'), '', 'from_name', $from_name, false)); $fields->attach(form_input_line_multi(do_lang_tempcode('TO_EMAIL'), '', 'to_email_', $to_email, 1)); $fields->attach(form_input_line_multi(do_lang_tempcode('TO_NAME'), '', 'to_name', $to_name, 1)); $fields->attach(form_input_text_comcode(do_lang_tempcode('MESSAGE'), '', 'message', $row['m_message'], true)); $radios = new ocp_tempcode(); $radios->attach(form_input_radio_entry('action', 'edit', true, do_lang_tempcode('EDIT'))); $radios->attach(form_input_radio_entry('action', 'send', false, do_lang_tempcode('EDIT_AND_SEND'))); $radios->attach(form_input_radio_entry('action', 'delete', false, do_lang_tempcode('DELETE'))); $fields->attach(form_input_radio(do_lang_tempcode('ACTION'), '', 'action', $radios, true)); $submit_name = do_lang_tempcode('PROCEED'); $post_url = build_url(array('page' => '_SELF', 'type' => '_edit', 'id' => $id), '_SELF'); return do_template('FORM_SCREEN', array('SKIP_VALIDATION' => true, 'HIDDEN' => '', 'TITLE' => $title, 'TEXT' => '', 'URL' => $post_url, 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name)); }
/** * Get tempcode for a post template adding/editing form. * * @param SHORT_TEXT The title (name) of the post template * @param LONG_TEXT The actual post template text * @param SHORT_TEXT Multi-code identifying forums it is applicable to * @param BINARY Whether to use as the default post for applicable forums * @return tempcode The input fields */ function get_form_fields($title = '', $text = '', $forum_multi_code = '', $use_default_forums = 0) { $fields = 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('_POST'), do_lang_tempcode('DESCRIPTION_POST_TEMPLATE_X'), 'text', $text, true)); $fields->attach(ocf_get_forum_multi_code_field($forum_multi_code)); $fields->attach(form_input_tick(do_lang_tempcode('DEFAULT'), do_lang_tempcode('USE_AS_DEFAULT_ON_APPLICABLE_FORUMS'), 'use_default_forums', $use_default_forums == 1)); return $fields; }
/** * Get tempcode for a forum adding/editing form. * * @param ?AUTO_LINK The ID of the forum being edited (NULL: adding, not editing) * @param SHORT_TEXT The name of the forum * @param LONG_TEXT The description of the forum * @param ?AUTO_LINK The ID of the category for the forum (NULL: first) * @param ?AUTO_LINK The parent forum (NULL: root) * @param ?integer The position (NULL: next) * @param BINARY Whether post counts are incremented in this forum * @param BINARY Whether subforums are ordered alphabetically (instead of manually) * @param LONG_TEXT Introductory question posed to all newcomers to the forum * @param LONG_TEXT Answer to the introductory question (or blank if it was just an 'ok') * @param SHORT_TEXT Redirection code (blank implies a normal forum, not a redirector) * @param ID_TEXT The order the topics are shown in, by default. * @param BINARY Whether the forum is threaded. * @return array A pair: The input fields, Hidden fields */ function get_form_fields($id = NULL, $name = '', $description = '', $category_id = NULL, $parent_forum = NULL, $position = NULL, $post_count_increment = 1, $order_sub_alpha = 0, $intro_question = '', $intro_answer = '', $redirection = '', $order = 'last_post', $is_threaded = 0) { if (is_null($category_id)) { $category_id = get_param_integer('category_id', db_get_first_id()); global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'category_id'; } if (is_null($parent_forum)) { global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'parent_forum'; $parent_forum = get_param_integer('parent_forum', NULL); } if (is_null($position)) { $position = $GLOBALS['FORUM_DB']->query_value_null_ok('f_forums', 'MAX(f_position)') + 1; } $fields = new ocp_tempcode(); $hidden = new ocp_tempcode(); $fields->attach(form_input_line(do_lang_tempcode('NAME'), do_lang_tempcode('DESCRIPTION_NAME'), 'name', $name, true)); $fields->attach(form_input_line_comcode(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_DESCRIPTION'), 'description', $description, false)); $list = ocf_nice_get_categories(NULL, $category_id); $fields->attach(form_input_list(do_lang_tempcode('FORUM_GROUPING'), do_lang_tempcode('DESCRIPTION_FORUM_GROUPING'), 'category_id', $list)); if (is_null($id) || !is_null($id) && $id != db_get_first_id()) { $fields->attach(form_input_tree_list(do_lang_tempcode('PARENT'), do_lang_tempcode('DESCRIPTION_PARENT_FORUM'), 'parent_forum', NULL, 'choose_forum', array(), true, is_null($parent_forum) ? '' : strval($parent_forum))); } if ($GLOBALS['FORUM_DB']->query_value('f_forums', 'COUNT(*)') > 300) { $fields->attach(form_input_integer(do_lang_tempcode('ORDER'), do_lang_tempcode('DESCRIPTION_FORUM_ORDER'), 'position', $position, true)); } else { $hidden->attach(form_input_hidden('position', strval($position))); } $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => $post_count_increment == 1 && $order_sub_alpha == 0 && $intro_question == '' && $intro_answer == '' && $redirection == '' && $order == 'last_post', 'TITLE' => do_lang_tempcode('ADVANCED')))); $fields->attach(form_input_tick(do_lang_tempcode('POST_COUNT_INCREMENT'), do_lang_tempcode('DESCRIPTION_POST_COUNT_INCREMENT'), 'post_count_increment', $post_count_increment == 1)); $fields->attach(form_input_tick(do_lang_tempcode('ORDER_SUB_ALPHA'), do_lang_tempcode('DESCRIPTION_ORDER_SUB_ALPHA'), 'order_sub_alpha', $order_sub_alpha == 1)); $fields->attach(form_input_text_comcode(do_lang_tempcode('INTRO_QUESTION'), do_lang_tempcode('DESCRIPTION_INTRO_QUESTION'), 'intro_question', $intro_question, false)); $fields->attach(form_input_line(do_lang_tempcode('INTRO_ANSWER'), do_lang_tempcode('DESCRIPTION_INTRO_ANSWER'), 'intro_answer', $intro_answer, false)); $fields->attach(form_input_line(do_lang_tempcode('REDIRECTING'), do_lang_tempcode('DESCRIPTION_FORUM_REDIRECTION'), 'redirection', $redirection, false)); $list = new ocp_tempcode(); $list->attach(form_input_list_entry('last_post', $order == 'last_post', do_lang_tempcode('FORUM_ORDER_BY_LAST_POST'))); $list->attach(form_input_list_entry('first_post', $order == 'first_post', do_lang_tempcode('FORUM_ORDER_BY_FIRST_POST'))); $list->attach(form_input_list_entry('title', $order == 'title', do_lang_tempcode('FORUM_ORDER_BY_TITLE'))); $fields->attach(form_input_list(do_lang_tempcode('TOPIC_ORDER'), do_lang_tempcode('DESCRIPTION_TOPIC_ORDER'), 'order', $list)); $fields->attach(form_input_tick(do_lang_tempcode('IS_THREADED'), do_lang_tempcode('DESCRIPTION_IS_THREADED'), 'is_threaded', $is_threaded == 1)); // Permissions $fields->attach($this->get_permission_fields(is_null($id) ? NULL : strval($id), NULL, is_null($id))); return array($fields, $hidden); }
/** * Get tempcode for a news adding/editing form. * * @param ?AUTO_LINK The primary category for the news (NULL: personal) * @param ?array A list of categories the news is in (NULL: not known) * @param SHORT_TEXT The news title * @param LONG_TEXT The news summary * @param SHORT_TEXT The name of the author * @param BINARY Whether the news 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 BINARY Whether to show the "send trackback" field * @param LONG_TEXT Notes for the video * @param URLPATH URL to the image for the news entry (blank: use cat image) * @param ?array Scheduled go-live time (NULL: N/A) * @return array A tuple of lots of info (fields, hidden fields, trailing fields) */ function get_form_fields($main_news_category = NULL, $news_category = NULL, $title = '', $news = '', $author = '', $validated = 1, $allow_rating = NULL, $allow_comments = NULL, $allow_trackbacks = NULL, $send_trackbacks = 1, $notes = '', $image = '', $scheduled = NULL) { list($allow_rating, $allow_comments, $allow_trackbacks) = $this->choose_feedback_fields_statistically($allow_rating, $allow_comments, $allow_trackbacks); global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'validated'; if (is_null($main_news_category)) { $NON_CANONICAL_PARAMS[] = 'cat'; $param_cat = get_param('cat', ''); if ($param_cat == '') { $news_category = array(); $main_news_category = NULL; } elseif (strpos($param_cat, ',') === false) { $news_category = array(); $main_news_category = intval($param_cat); } else { require_code('ocfiltering'); $news_category = ocfilter_to_idlist_using_db($param_cat, 'id', 'news_categories', 'news_categories', NULL, 'id', 'id'); $main_news_category = NULL; } $author = $GLOBALS['FORUM_DRIVER']->get_username(get_member()); } $cats1 = nice_get_news_categories($main_news_category, false, true, false, true); $cats2 = nice_get_news_categories(is_null($news_category) || count($news_category) == 0 ? array(get_param_integer('cat', NULL)) : $news_category, false, true, true, false); $fields = new ocp_tempcode(); $fields2 = new ocp_tempcode(); $hidden = new ocp_tempcode(); require_code('form_templates'); $fields->attach(form_input_line_comcode(do_lang_tempcode('TITLE'), do_lang_tempcode('DESCRIPTION_TITLE'), 'title', $title, true)); if ($validated == 0) { $validated = get_param_integer('validated', 0); if ($validated == 1) { attach_message(do_lang_tempcode('WILL_BE_VALIDATED_WHEN_SAVING')); } } if (has_some_cat_specific_permission(get_member(), 'bypass_validation_' . $this->permissions_require . 'range_content', 'cms_news', $this->permissions_cat_require)) { if (addon_installed('unvalidated')) { $fields2->attach(form_input_tick(do_lang_tempcode('VALIDATED'), do_lang_tempcode('DESCRIPTION_VALIDATED'), 'validated', $validated == 1)); } } if ($cats1->is_empty()) { warn_exit(do_lang_tempcode('NO_CATEGORIES')); } if (addon_installed('authors')) { $hidden->attach(form_input_hidden('author', $author)); } $fields2->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => (is_null($news_category) || count($news_category) == 0) && $image == '' && (is_null($news_category) || $news_category == array()), 'TITLE' => do_lang_tempcode('ADVANCED')))); $fields2->attach(form_input_text_comcode(do_lang_tempcode('BLOG_NEWS_SUMMARY'), do_lang_tempcode('DESCRIPTION_NEWS_SUMMARY'), 'news', $news, false)); if (get_value('disable_secondary_news') !== '1') { $fields2->attach(form_input_list(do_lang_tempcode('MAIN_CATEGORY'), do_lang_tempcode('DESCRIPTION_MAIN_CATEGORY'), 'main_news_category', $cats1)); } else { $fields2->attach(form_input_hidden('main_news_category', is_null($main_news_category) ? 'personal' : strval($main_news_category))); } if (get_value('disable_secondary_news') !== '1') { $fields2->attach(form_input_multi_list(do_lang_tempcode('SECONDARY_CATEGORIES'), do_lang_tempcode('DESCRIPTION_SECONDARY_CATEGORIES'), 'news_category', $cats2)); } $fields2->attach(form_input_upload(do_lang_tempcode('IMAGE'), do_lang_tempcode('DESCRIPTION_NEWS_IMAGE_OVERRIDE'), 'file', false, $image, NULL, true, str_replace(' ', '', get_option('valid_images')))); //handle_max_file_size($hidden,'image'); Attachments will add this if (addon_installed('calendar') && has_specific_permission(get_member(), 'scheduled_publication_times')) { $fields2->attach(form_input_date__scheduler(do_lang_tempcode('PUBLICATION_TIME'), do_lang_tempcode('DESCRIPTION_PUBLICATION_TIME'), 'schedule', true, true, true, $scheduled, intval(date('Y')) - 1970 + 2, 1970)); } require_code('feedback2'); $fields2->attach(feedback_fields($allow_rating == 1, $allow_comments == 1, $allow_trackbacks == 1, $send_trackbacks == 1, $notes, $allow_comments == 2)); $fields2->attach(get_syndication_option_fields()); return array($fields, $hidden, NULL, NULL, NULL, NULL, make_string_tempcode($fields2->evaluate())); }
/** * Outputs a Comcode tag helper dialog. */ function comcode_helper_script() { require_lang('comcode'); $type = get_param('type', 'step1'); list($tag_list, $custom_tag_list) = _get_details_comcode_tags(); require_code('comcode_text'); global $DANGEROUS_TAGS, $TEXTUAL_TAGS; if ($type == 'step1') { $title = get_page_title('COMCODE_TAG'); $keep = symbol_tempcode('KEEP'); $comcode_groups = ''; $groups = _get_group_tags(); $non_wysiwyg_tags = _get_non_wysiwyg_tags(); $in_wysiwyg = get_param_integer('in_wysiwyg', 0) == 1; foreach ($groups as $groupname => $grouptags) { sort($grouptags); $comcode_types = ''; foreach ($grouptags as $tag) { $custom = array_key_exists($tag, $custom_tag_list); if ($in_wysiwyg && !$custom && !in_array($tag, $non_wysiwyg_tags)) { continue; } if (array_key_exists($tag, $DANGEROUS_TAGS) && !has_specific_permission(get_member(), 'comcode_dangerous')) { continue; } if ($custom) { $description = make_string_tempcode(escape_html(is_integer($custom_tag_list[$tag]['tag_description']) ? get_translated_text($custom_tag_list[$tag]['tag_description']) : $custom_tag_list[$tag]['tag_description'])); } else { $description = do_lang_tempcode('COMCODE_TAG_' . $tag); } $url = find_script('comcode_helper') . '?type=step2&tag=' . urlencode($tag) . '&field_name=' . get_param('field_name') . $keep->evaluate(); if (get_param('utheme', '') != '') { $url .= '&utheme=' . get_param('utheme'); } $link_caption = escape_html($tag); $usage = ''; $comcode_types .= static_evaluate_tempcode(do_template('BLOCK_HELPER_BLOCK_CHOICE', array('USAGE' => $usage, 'DESCRIPTION' => $description, 'URL' => $url, 'LINK_CAPTION' => $link_caption))); } if ($comcode_types != '') { $comcode_groups .= static_evaluate_tempcode(do_template('BLOCK_HELPER_BLOCK_GROUP', array('IMG' => NULL, 'TITLE' => do_lang_tempcode('COMCODE_GROUP_' . $groupname), 'LINKS' => $comcode_types))); } } $content = do_template('BLOCK_HELPER_START', array('_GUID' => 'd2d6837cdd8b19d80ea95ab9f5d09c9a', 'GET' => true, 'TITLE' => $title, 'LINKS' => $comcode_groups)); } elseif ($type == 'step2') { require_code('form_templates'); $actual_tag = get_param('tag'); if (!isset($tag_list[$actual_tag]) && !isset($custom_tag_list[$actual_tag])) { warn_exit(do_lang_tempcode('INTERNAL_ERROR')); } $tag = $actual_tag; if ($tag == 'attachment_safe') { $tag = 'attachment'; } $title = get_page_title('_COMCODE_HELPER', true, array($tag)); $fields = new ocp_tempcode(); $fields_advanced = new ocp_tempcode(); $done_tag_contents = false; $hidden = new ocp_tempcode(); $javascript = ''; $preview = true; require_code('comcode_text'); $defaults = parse_single_comcode_tag(get_param('parse_defaults', '', true), $actual_tag); $default_embed = array_key_exists('', $defaults) ? '[semihtml]' . $defaults[''] . '[/semihtml]' : get_param('default', ''); $embed_required = true; if ($tag == 'contents') { $embed_required = false; } if (isset($custom_tag_list[$tag]['tag_description'])) { $tag_description = protect_from_escaping($custom_tag_list[$tag]['tag_description']); } else { $tag_description = protect_from_escaping(do_lang('COMCODE_TAG_' . $tag)); } if (array_key_exists($tag, $tag_list)) { $params = $tag_list[$tag]; if ($tag == 'include') { $default_embed = array_key_exists('', $defaults) ? $defaults[''] : get_param('default', ''); if (strpos($default_embed, ':') === false) { $default_embed = ':' . $default_embed; } $fields->attach(form_input_page_link(do_lang_tempcode('PAGE'), '', 'tag_contents', $default_embed, true, NULL, 'comcode')); $done_tag_contents = true; } elseif ($tag == 'concepts') { foreach ($params as $param) { $description = do_lang('COMCODE_TAG_' . $tag . '_PARAM_' . $param); $fields->attach(form_input_line_multi(ucwords(str_replace('_', ' ', $param)), protect_from_escaping($description), $param, get_defaults_multi($defaults, $param), 1)); } } elseif ($tag == 'jumping') { foreach ($params as $param) { $description = do_lang('COMCODE_TAG_' . $tag . '_PARAM_' . $param); $fields->attach(form_input_line_multi(ucwords(str_replace('_', ' ', $param)), protect_from_escaping($description), $param, get_defaults_multi($defaults, $param), 2)); } } elseif ($tag == 'shocker') { foreach ($params as $param) { $description = do_lang('COMCODE_TAG_' . $tag . '_PARAM_' . $param); if ($param == 'left' || $param == 'right') { $fields->attach(form_input_line_multi(ucwords(str_replace('_', ' ', $param)), protect_from_escaping($description), $param, get_defaults_multi($defaults, $param), 2)); } else { $fields->attach(form_input_line(ucwords(str_replace('_', ' ', $param)), protect_from_escaping($description), $param, '', false)); } } } elseif ($tag == 'random') { foreach ($params as $param) { $description = do_lang('COMCODE_TAG_' . $tag . '_PARAM_' . $param); $fields->attach(form_input_line_multi(ucwords(str_replace('_', ' ', $param)), protect_from_escaping($description), $param, get_defaults_multi($defaults, $param), $param != 'X' ? 2 : 0)); } } elseif ($tag == 'sections') { foreach ($params as $param) { if ($param == 'default') { $description = do_lang('COMCODE_TAG_' . $tag . '_PARAM_' . $param); $default = array_key_exists($param, $defaults) ? $defaults[$param] : get_param('default_' . $param, '1'); $fields->attach(form_input_integer(ucwords(str_replace('_', ' ', $param)), protect_from_escaping($description), $param, intval($default), false)); } elseif ($param == 'name') { $description = do_lang('COMCODE_TAG_' . $tag . '_PARAM_' . $param); $fields->attach(form_input_line_multi(ucwords(str_replace('_', ' ', $param)), protect_from_escaping($description), $param, get_defaults_multi($defaults, $param), 2)); } } } elseif ($tag == 'big_tabs') { foreach ($params as $param) { if ($param == 'default') { $description = do_lang('COMCODE_TAG_' . $tag . '_PARAM_' . $param); $default = array_key_exists($param, $defaults) ? $defaults[$param] : get_param('default_' . $param, '1'); $fields->attach(form_input_integer(ucwords(str_replace('_', ' ', $param)), protect_from_escaping($description), $param, intval($default), false)); } elseif ($param == 'name') { $description = do_lang('COMCODE_TAG_' . $tag . '_PARAM_' . $param); $fields->attach(form_input_line_multi(ucwords(str_replace('_', ' ', $param)), protect_from_escaping($description), $param, get_defaults_multi($defaults, $param), 2)); } elseif ($param == 'switch_time') { $description = do_lang('COMCODE_TAG_' . $tag . '_PARAM_' . $param); $default = array_key_exists($param, $defaults) ? $defaults[$param] : get_param('default_' . $param, '6000'); $fields->attach(form_input_integer(ucwords(str_replace('_', ' ', $param)), protect_from_escaping($description), $param, intval($default), false)); } } } elseif ($tag == 'tabs') { foreach ($params as $param) { if ($param == 'default') { $description = do_lang('COMCODE_TAG_' . $tag . '_PARAM_' . $param); $default = array_key_exists($param, $defaults) ? $defaults[$param] : get_param('default_' . $param, '1'); $fields->attach(form_input_integer(ucwords(str_replace('_', ' ', $param)), protect_from_escaping($description), $param, intval($default), false)); } elseif ($param == 'name') { $description = do_lang('COMCODE_TAG_' . $tag . '_PARAM_' . $param); $fields->attach(form_input_line_multi(ucwords(str_replace('_', ' ', $param)), protect_from_escaping($description), $param, get_defaults_multi($defaults, $param), 2)); } } } else { if (count($params) > 0) { require_code('form_templates'); foreach ($params as $param) { $parameter_name = do_lang('COMCODE_TAG_' . $tag . '_NAME_OF_PARAM_' . $param, NULL, NULL, NULL, NULL, false); if (is_null($parameter_name)) { $parameter_name = ucwords(str_replace('_', ' ', $param)); } $descriptiont = do_lang('COMCODE_TAG_' . $tag . '_PARAM_' . $param); $supports_comcode = strpos($descriptiont, do_lang('BLOCK_IND_SUPPORTS_COMCODE')) !== false; $descriptiont = trim(str_replace(do_lang('BLOCK_IND_SUPPORTS_COMCODE'), '', $descriptiont)); $is_advanced = strpos($descriptiont, do_lang('BLOCK_IND_ADVANCED')) !== false; $descriptiont = trim(str_replace(do_lang('BLOCK_IND_ADVANCED'), '', $descriptiont)); $default = array_key_exists($param, $defaults) ? $defaults[$param] : get_param('default_' . $param, ''); if (!array_key_exists($param, $defaults)) { $matches = array(); if (preg_match('#' . do_lang('BLOCK_IND_DEFAULT') . ': ["\']([^"]*)["\']#Ui', $descriptiont, $matches) != 0) { $default = $matches[1]; } } $descriptiont = preg_replace('#\\s*' . do_lang('BLOCK_IND_DEFAULT') . ': ["\']([^"]*)["\'](?-U)\\.?(?U)#Ui', '', $descriptiont); if ($tag == 'page' && $param == 'param' && substr_count($default, ':') == 1) { $fields->attach(form_input_page_link($parameter_name, protect_from_escaping($descriptiont), $param, $default, true, NULL)); } elseif ($tag == 'attachment' && $param == 'thumb_url' && addon_installed('filedump')) { $field = form_input_tree_list(do_lang_tempcode('THUMBNAIL'), do_lang_tempcode('COMCODE_TAG_attachment_PARAM_thumb_url'), 'thumb_url', '', 'choose_filedump_file', array('only_images' => true), false, $default, false); $fields_advanced->attach($field); } else { if (substr($descriptiont, 0, 12) == '0|1 – ') { $field = form_input_tick($parameter_name, protect_from_escaping(ucfirst(substr($descriptiont, 12))), $param, $default == '1'); } elseif (substr($descriptiont, -1) != '.' && strpos($descriptiont, '|') !== false) { $list = new ocp_tempcode(); if (substr($descriptiont, 0, 1) != '=') { $list->attach(form_input_list_entry('')); } foreach (explode('|', $descriptiont) as $item) { if (strpos($item, '=') !== false) { list($item, $label) = explode('=', $item, 2); // Simplify the choices if ($tag == 'attachment') { if ($item == 'inline_extract' && get_param_integer('is_archive', NULL) === 0) { continue; } if ($item == 'island_extract' && get_param_integer('is_archive', NULL) === 0) { continue; } if ($item == 'inline' && get_param_integer('is_image', NULL) === 0) { continue; } if ($item == 'island' && get_param_integer('is_image', NULL) === 0) { continue; } if ($item == 'code' && (get_param_integer('is_image', NULL) === 1 || get_param_integer('is_archive', NULL) === 1)) { continue; } if ($item == 'mail' && get_param('default_type', NULL) !== NULL) { continue; } } $list->attach(form_input_list_entry($item, $item == $default, protect_from_escaping($label))); } else { $list->attach(form_input_list_entry($item, $item == $default)); } } $field = form_input_list($parameter_name, '', $param, $list, NULL, false, false); } elseif ($param == 'width' || $param == 'height') { $field = form_input_integer($parameter_name, protect_from_escaping($descriptiont), $param, $default == '' ? NULL : intval($default), false); } else { if ($supports_comcode) { $field = form_input_line_comcode($parameter_name, protect_from_escaping($descriptiont), $param, $default, false); } else { $field = form_input_line($parameter_name, protect_from_escaping($descriptiont), $param, $default, false); } } if ($is_advanced) { $fields_advanced->attach($field); } else { $fields->attach($field); } } } if ($tag == 'attachment') { if (get_option('eager_wysiwyg') == '0') { $field = form_input_tick(do_lang_tempcode('COMCODE_TAG_attachment_safe'), do_lang_tempcode('COMCODE_TAG_attachment_safe_DESCRIPTION'), '_safe', $actual_tag == 'attachment_safe' || $actual_tag == 'attachment2'); $fields_advanced->attach($field); } } } } } else { $_params = $custom_tag_list[$tag]; $params = explode(',', $_params['tag_parameters']); foreach ($params as $param) { $description = new ocp_tempcode(); $fields->attach(form_input_line(preg_replace('#=.*$#', '', ucwords(str_replace('_', ' ', $param))), protect_from_escaping($description), preg_replace('#=.*$#', '', $param), preg_replace('#^.*=#U', '', $param), false)); } $tag_description = new ocp_tempcode(); $tag_description->attach(is_integer($_params['tag_description']) ? get_translated_text($_params['tag_description']) : $_params['tag_description']); $tag_description->attach(paragraph(is_integer($_params['tag_example']) ? get_translated_text($_params['tag_example']) : $_params['tag_example'])); } if ($tag == 'attachment') { if (get_option('eager_wysiwyg') == '0') { $javascript .= "document.getElementById('type').onchange=function() { document.getElementById('_safe').checked=(this.options[this.selectedIndex].value=='inline'); };"; } if ($default_embed != '' || !addon_installed('filedump')) { $hidden->attach(form_input_hidden('tag_contents', $default_embed)); $tag_description = new ocp_tempcode(); if (substr($default_embed, 0, 4) == 'new_') { $preview = NULL; } } else { $filedump_url = build_url(array('page' => 'filedump'), get_module_zone('filedump')); $fields->attach(form_input_tree_list(do_lang_tempcode('FILE'), do_lang_tempcode('COMCODE_TAG_attachment_EMBED_FILE', escape_html($filedump_url->evaluate())), 'tag_contents', '', 'choose_filedump_file', array('attachment_ready' => true), true, '', false)); } } elseif ($tag == 'sections' || $tag == 'big_tabs' || $tag == 'tabs' || $tag == 'list') { $fields->attach(form_input_text_multi(do_lang_tempcode('TAG_CONTENTS'), protect_from_escaping(do_lang('COMCODE_TAG_' . $tag . '_EMBED')), 'tag_contents', explode(',', $default_embed), 2)); } elseif (array_key_exists($tag, $TEXTUAL_TAGS) || $tag == 'menu') { if ($tag == 'menu' && $default_embed == '') { $default_embed = '-contracted section +expanded section page = URL page = URL +expanded section page = URL page = URL'; } $descriptiont = do_lang('COMCODE_TAG_' . $tag . '_EMBED'); $descriptiont = trim(str_replace(do_lang('BLOCK_IND_SUPPORTS_COMCODE'), '', $descriptiont)); $fields->attach(form_input_text_comcode(do_lang_tempcode('TAG_CONTENTS'), protect_from_escaping(do_lang('COMCODE_TAG_' . $tag . '_EMBED')), 'tag_contents', $default_embed, $embed_required, NULL, true)); } else { if (!$done_tag_contents) { $descriptiont = do_lang('COMCODE_TAG_' . $tag . '_EMBED', NULL, NULL, NULL, NULL, false); if (is_null($descriptiont)) { $descriptiont = ''; } $supports_comcode = strpos($descriptiont, do_lang('BLOCK_IND_SUPPORTS_COMCODE')) !== false; $descriptiont = trim(str_replace(do_lang('BLOCK_IND_SUPPORTS_COMCODE'), '', $descriptiont)); if ($supports_comcode) { $fields->attach(form_input_line_comcode(do_lang_tempcode('TAG_CONTENTS'), protect_from_escaping($descriptiont), 'tag_contents', $default_embed, $embed_required)); } else { $fields->attach(form_input_line(do_lang_tempcode('TAG_CONTENTS'), protect_from_escaping($descriptiont), 'tag_contents', $default_embed, $embed_required)); } } } if (!$fields_advanced->is_empty()) { $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('ADVANCED')))); $fields->attach($fields_advanced); } $keep = symbol_tempcode('KEEP'); $post_url = find_script('comcode_helper') . '?type=step3&field_name=' . get_param('field_name') . $keep->evaluate(); if (get_param('utheme', '') != '') { $post_url .= '&utheme=' . get_param('utheme'); } if (get_param('save_to_id', '') != '') { $post_url .= '&save_to_id=' . urlencode(get_param('save_to_id')); $submit_name = do_lang_tempcode('SAVE'); // Allow remove option $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => false, 'TITLE' => do_lang_tempcode('ACTIONS'), 'HELP' => ''))); $fields->attach(form_input_tick(do_lang_tempcode('REMOVE'), '', '_delete', false)); } else { $submit_name = do_lang_tempcode('USE'); } $text = $tag_description->is_empty() ? new ocp_tempcode() : do_lang_tempcode('COMCODE_HELPER_2', escape_html($tag), $tag_description); $hidden->attach(form_input_hidden('tag', $tag)); $content = do_template('FORM_SCREEN', array('_GUID' => '270058349d048a8be6570bba97c81fa2', 'TITLE' => $title, 'JAVASCRIPT' => $javascript, 'TARGET' => '_self', 'SKIP_VALIDATION' => true, 'FIELDS' => $fields, 'URL' => $post_url, 'TEXT' => $text, 'SUBMIT_NAME' => $submit_name, 'HIDDEN' => $hidden, 'PREVIEW' => $preview, 'THEME' => $GLOBALS['FORUM_DRIVER']->get_theme())); } elseif ($type == 'step3') { require_javascript('javascript_posting'); require_javascript('javascript_editing'); $field_name = get_param('field_name'); $tag = post_param('tag'); $title = get_page_title('_COMCODE_HELPER', true, array($tag)); if (get_option('eager_wysiwyg') == '0') { if ($tag == 'attachment' && post_param_integer('_safe', 0) == 1) { $tag = 'attachment_safe'; } } list($comcode, $bparameters) = _get_preview_environment_comcode($tag); if ($tag == 'sections' || $tag == 'big_tabs' || $tag == 'tabs' || $tag == 'list') { $comcode_xml = $bparameters; } else { $comcode_xml = '<' . $tag . $bparameters . '>' . post_param('tag_contents', '') . '</' . $tag . '>'; } $comcode_semihtml = comcode_to_tempcode($comcode, NULL, false, 60, NULL, NULL, true, false, false); $content = do_template('BLOCK_HELPER_DONE', array('TITLE' => $title, 'FIELD_NAME' => $field_name, 'BLOCK' => $tag, 'COMCODE_XML' => $comcode_xml, 'COMCODE' => $comcode, 'COMCODE_SEMIHTML' => $comcode_semihtml)); } $content->handle_symbol_preprocessing(); $echo = do_template('POPUP_HTML_WRAP', array('TITLE' => do_lang_tempcode('COMCODE_HELPER'), 'EXTRA_HEAD' => $GLOBALS['EXTRA_HEAD'], 'EXTRA_FOOT' => $GLOBALS['EXTRA_FOOT'], 'CONTENT' => $content)); exit($echo->evaluate()); $echo->handle_symbol_preprocessing(); $echo->evaluate_echo(); }
/** * Get form inputter. * * @param string The field name * @param string The field description * @param array The field details * @param ?string The actual current value of the field (NULL: none) * @param boolean Whether this is for a new entry * @param boolean Whether this is the last field in the catalogue * @return ?tempcode The Tempcode for the input field (NULL: skip the field - it's not input) */ function get_field_inputter($_cf_name, $_cf_description, $field, $actual_value, $new, $last = true) { if (is_null($actual_value)) { $actual_value = ''; } // Plug anomaly due to unusual corruption return form_input_text_comcode($_cf_name, $_cf_description, 'field_' . strval($field['id']), $actual_value, $field['cf_required'] == 1); }
/** * Get tempcode for a catalogue adding/editing form. * * @param ID_TEXT The name of the catalogue * @param SHORT_TEXT The human readable name/title of the catalogue * @param LONG_TEXT The description * @param SHORT_INTEGER The display type * @param BINARY Whether the catalogue uses a hierarchy * @param LONG_TEXT Admin notes * @param integer How many points are given to a member that submits to the catalogue * @param BINARY Whether the catalogue is an eCommerce catalogue * @param ID_TEXT How to send view reports * @set never daily weekly monthly quarterly * @return array A tuple: the tempcode for the visible fields, and the tempcode for the hidden fields, ..., and action fields */ function get_form_fields($name = '', $title = '', $description = '', $display_type = 0, $is_tree = 1, $notes = '', $submit_points = 0, $ecommerce = 0, $send_view_reports = 'never') { $fields = new ocp_tempcode(); $hidden = new ocp_tempcode(); require_code('form_templates'); if ($name == '') { $name = get_param('id', ''); } $tied_to_content_type = substr($name, 0, 1) == '_' && (file_exists(get_file_base() . '/sources_custom/hooks/systems/awards/' . substr($name, 1) . '.php') || file_exists(get_file_base() . '/sources/hooks/systems/awards/' . substr($name, 1) . '.php')); if ($tied_to_content_type) { $content_type = substr($name, 1); require_code('hooks/systems/awards/' . $content_type); $ob = object_factory('Hook_awards_' . $content_type); $info = $ob->info(); $title = do_lang('CUSTOM_FIELDS_FOR', $info['title']->evaluate()); $hidden->attach(form_input_hidden('title', $title)); $hidden->attach(form_input_hidden('name', $name)); $hidden->attach(form_input_hidden('description', '')); $hidden->attach(form_input_hidden('notes', '')); $hidden->attach(form_input_hidden('auto_fill', '')); $hidden->attach(form_input_hidden('display_type', '0')); $hidden->attach(form_input_hidden('submit_points', '0')); $hidden->attach(form_input_hidden('send_view_reports', 'never')); attach_message(do_lang_tempcode('EDITING_CUSTOM_FIELDS_HELP', $info['title'])); $actions = new ocp_tempcode(); } else { $fields->attach(form_input_line(do_lang_tempcode('TITLE'), do_lang_tempcode('DESCRIPTION_TITLE'), 'title', $title, true)); $fields->attach(form_input_codename(do_lang_tempcode('CODENAME'), do_lang_tempcode('DESCRIPTION_CODENAME'), 'name', $name, true)); $fields->attach(form_input_text_comcode(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_CATALOGUE_DESCRIPTION'), 'description', $description, false)); $display_types = new ocp_tempcode(); $display_types->attach(form_input_list_entry(strval(0), $display_type == 0, do_lang_tempcode('DT_MAPS'))); $display_types->attach(form_input_list_entry(strval(1), $display_type == 1, do_lang_tempcode('DT_LIST'))); $display_types->attach(form_input_list_entry(strval(2), $display_type == 2, do_lang_tempcode('DT_MATRIX'))); $fields->attach(form_input_list(do_lang_tempcode('DISPLAY_TYPE'), do_lang_tempcode('DESCRIPTION_DISPLAY_TYPE'), 'display_type', $display_types)); if (addon_installed('shopping')) { if ($ecommerce == 1) { if (get_forum_type() != 'ocf') { warn_exit(do_lang_tempcode('NO_OCF')); } } $fields->attach(form_input_tick(do_lang_tempcode('CAT_ECOMMERCE'), do_lang_tempcode('DESCRIPTION_CAT_ECOMMERCE'), 'ecommerce', $ecommerce == 1)); } $fields->attach(form_input_tick(do_lang_tempcode('IS_TREE'), do_lang_tempcode('DESCRIPTION_IS_TREE'), 'is_tree', $is_tree == 1)); if ($name == '') { $fields->attach(form_input_line(do_lang_tempcode('AUTO_FILL'), do_lang_tempcode('DESCRIPTION_AUTO_FILL'), 'auto_fill', '', false, NULL, 10000)); } $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => $notes == '' && $submit_points == 0 && $send_view_reports == 'never', 'TITLE' => do_lang_tempcode('ADVANCED')))); if (get_value('disable_staff_notes') !== '1') { $fields->attach(form_input_text(do_lang_tempcode('NOTES'), do_lang_tempcode('DESCRIPTION_NOTES'), 'notes', $notes, false)); } if (addon_installed('points')) { $fields->attach(form_input_integer(do_lang_tempcode('SUBMIT_POINTS'), do_lang_tempcode('DESCRIPTION_SUBMIT_POINTS'), 'submit_points', $submit_points, false)); } $view_report_types = new ocp_tempcode(); $view_report_types->attach(form_input_list_entry('never', $send_view_reports == 'never', do_lang_tempcode('VR_NEVER'))); $view_report_types->attach(form_input_list_entry('daily', $send_view_reports == 'daily', do_lang_tempcode('VR_DAILY'))); $view_report_types->attach(form_input_list_entry('weekly', $send_view_reports == 'weekly', do_lang_tempcode('VR_WEEKLY'))); $view_report_types->attach(form_input_list_entry('monthly', $send_view_reports == 'monthly', do_lang_tempcode('VR_MONTHLY'))); $view_report_types->attach(form_input_list_entry('quarterly', $send_view_reports == 'quarterly', do_lang_tempcode('VR_QUARTERLY'))); $fields->attach(form_input_list(do_lang_tempcode('VIEW_REPORTS'), do_lang_tempcode('DESCRIPTION_VIEW_REPORTS'), 'send_view_reports', $view_report_types)); // Permissions $fields->attach($this->get_permission_fields($name, NULL, $name == '')); $actions = new ocp_tempcode(); if ($name != '' && get_value('disable_cat_cat_perms') !== '1') { $actions->attach(form_input_tick(do_lang_tempcode('RESET_CATEGORY_PERMISSIONS'), do_lang_tempcode('DESCRIPTION_RESET_CATEGORY_PERMISSIONS'), 'reset_category_permissions', false)); } if ($name == '') { $actions->attach(form_input_tick(do_lang_tempcode('ADD_TO_MENU'), do_lang_tempcode('DESCRIPTION_ADD_TO_MENU'), 'add_to_menu', true)); } } return array($fields, $hidden, NULL, NULL, false, NULL, $actions); }
/** * Get tempcode for adding/editing form. * * @param ?AUTO_LINK The ID of the award (NULL: not added yet) * @param SHORT_TEXT The title * @param LONG_TEXT The description * @param integer How many points are given to the awardee * @param ID_TEXT The content type the award type is for * @param BINARY Whether to not show the awardee when displaying this award * @param integer The approximate time in hours between awards (e.g. 168 for a week) * @return tempcode The input fields */ function get_form_fields($id = NULL, $title = '', $description = '', $points = 0, $content_type = 'download', $hide_awardee = 0, $update_time_hours = 168) { $fields = 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('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_DESCRIPTION'), 'description', $description, true)); if (addon_installed('points')) { $fields->attach(form_input_integer(do_lang_tempcode('POINTS'), do_lang_tempcode('DESCRIPTION_AWARD_POINTS'), 'points', $points, true)); } $list = new ocp_tempcode(); $_hooks = array(); $hooks = find_all_hooks('systems', 'awards'); foreach (array_keys($hooks) as $hook) { require_code('hooks/systems/awards/' . $hook); $hook_object = object_factory('Hook_awards_' . $hook, true); if (is_null($hook_object)) { continue; } $hook_info = $hook_object->info(); if (!is_null($hook_info)) { $_hooks[$hook] = $hook_info['title']->evaluate(); } } asort($_hooks); foreach ($_hooks as $hook => $hook_title) { $list->attach(form_input_list_entry($hook, $hook == $content_type, protect_from_escaping($hook_title))); } if ($list->is_empty()) { inform_exit(do_lang_tempcode('NO_CATEGORIES')); } $fields->attach(form_input_list(do_lang_tempcode('CONTENT_TYPE'), do_lang_tempcode('DESCRIPTION_CONTENT_TYPE'), 'content_type', $list)); $fields->attach(form_input_tick(do_lang_tempcode('HIDE_AWARDEE'), do_lang_tempcode('DESCRIPTION_HIDE_AWARDEE'), 'hide_awardee', $hide_awardee == 1)); $fields->attach(form_input_integer(do_lang_tempcode('AWARD_UPDATE_TIME_HOURS'), do_lang_tempcode('DESCRIPTION_AWARD_UPDATE_TIME_HOURS'), 'update_time_hours', $update_time_hours, true)); // Permissions $fields->attach($this->get_permission_fields(is_null($id) ? NULL : strval($id), do_lang_tempcode('AWARD_PERMISSION_HELP'), false, do_lang_tempcode('GIVE_AWARD'))); return $fields; }
/** * Show a comcode parser error. * * @param boolean Whether this is being pre-parsed, to pick up errors before row insertion. * @param array Error message details to pass to do_lang, or if the first in the list is NULL, use directly * @param integer The position during parsing that the error occurred at * @param LONG_TEXT The comcode the parser error occurred in * @param boolean Whether to only check the Comcode. * @return tempcode An error message to put in the output stream (shown in certain situations, where in other situations we bomb out). */ function comcode_parse_error($preparse_mode, $_message, $pos, $comcode, $check_only = false) { //echo $comcode; require_lang('comcode'); if (is_null($_message[0])) { $message = $_message[1]; } else { if (strpos($_message[0], ':') === false) { $_message[0] = 'comcode:' . $_message[0]; } $message = call_user_func_array('do_lang_tempcode', array_map('escape_html', $_message)); } $posted = false; foreach ($_POST + $_GET as $name => $val) { if (is_array($val)) { continue; } if (is_integer($name)) { $name = strval($name); } if (post_param($name, '') == $comcode || substr($name, -7) == '_parsed') { $posted = true; } } if (!$check_only) { if ((get_page_name() == 'admin_import' || count($_POST) == 0 || !$posted) && !$preparse_mode) { $line = substr_count(substr($comcode, 0, $pos), chr(10)) + 1; $out = do_template('COMCODE_CRITICAL_PARSE_ERROR', array('LINE' => integer_format($line), 'MESSAGE' => $message, 'SOURCE' => $comcode)); // Won't parse, but we can't help it, so we will skip on return $out; } } $len = strlen($comcode); $lines = new ocp_tempcode(); $number = 1; $sofar = ''; $line = NULL; for ($i = 0; $i < $len; $i++) { $char = $comcode[$i]; if ($i == $pos) { $tmp_tpl = do_template('COMCODE_MISTAKE_ERROR'); $sofar .= $tmp_tpl->evaluate(); $line = $number; } if ($char == chr(10)) { $lines->attach(do_template('COMCODE_MISTAKE_LINE', array('_GUID' => '2022be3de10590d525f333b6ac0da37b', 'NUMBER' => integer_format($number), 'LINE' => make_string_tempcode($sofar)))); $sofar = ''; $number++; } $sofar .= escape_html($char); } if ($i == $pos) { $tmp_tpl = do_template('COMCODE_MISTAKE_ERROR'); $sofar .= $tmp_tpl->evaluate(); } $lines->attach(do_template('COMCODE_MISTAKE_LINE', array('_GUID' => 'eebfe1342f3129d4e31fc9fc1963af2b', 'NUMBER' => integer_format($number), 'LINE' => make_string_tempcode($sofar)))); if (is_null($line)) { $line = $number; } // Now, using some kind of miracle, we need to find out what parameter name blew-up. Let's look through the parameters and see what // is equal to $comcode. I'd rather not do this in a hackerish way - but the architecture was not designed for this. $name = NULL; foreach ($_POST as $key => $val) { if (!is_string($val)) { continue; } if (post_param($key) == $comcode) { $name = $key; break; } } if (is_null($name)) { if ($check_only) { foreach ($_POST as $key => $val) { if (!is_string($val)) { continue; } $val = post_param($key); if (strlen($val) > 10 && (strpos($comcode, $val) === 0 || strpos($comcode, $val) === strlen($comcode) - strlen($val))) { $name = $key; break; } } } if (is_null($name)) { warn_exit(do_lang_tempcode('COMCODE_ERROR', $message, integer_format($line))); } } if (!running_script('comcode_convert')) { $GLOBALS['HTTP_STATUS_CODE'] = '400'; if (!headers_sent()) { // NB: Very important this doesn't run on IE. IE is supposed to show error screens literally if more than 512 bytes, and this is much more (irregardless of compression) - but sometimes seems to still hide it with a "friendly" error anyway if (!browser_matches('ie') && strpos(ocp_srv('SERVER_SOFTWARE'), 'IIS') === false) { header('HTTP/1.0 400 Bad Request'); } } } // Output our error / correction form @ob_end_clean(); $hidden = build_keep_post_fields(array($name)); require_code('form_templates'); $fields = form_input_text_comcode(do_lang_tempcode('NEW'), do_lang_tempcode('COMCODE_REPLACEMENT'), $name, $comcode, true, NULL, true); $post_url = get_self_url(); $form = do_template('FORM', array('_GUID' => '207bad1252add775029b34ba36e02856', 'URL' => $post_url, 'TEXT' => '', 'HIDDEN' => $hidden, 'FIELDS' => $fields, 'SUBMIT_NAME' => do_lang_tempcode('PROCEED'))); $output = do_template('COMCODE_MISTAKE_SCREEN', array('_GUID' => '0010230e6612b0775566d07ddf54305a', 'EDITABLE' => !running_script('preview'), 'FORM' => $form, 'TITLE' => get_page_title('ERROR_OCCURRED'), 'LINE' => integer_format($line), 'MESSAGE' => $message, 'LINES' => $lines)); $echo = new ocp_tempcode(); if (!running_script('preview')) { $echo = globalise($output, NULL, '', true); $echo->handle_symbol_preprocessing(); } else { $echo->attach(do_template('STYLED_HTML_WRAP', array('TITLE' => do_lang_tempcode('PREVIEW'), 'TARGET' => '_top', 'CONTENT' => $output))); } $echo->evaluate_echo(); exit; return new ocp_tempcode(); // to trick code checker }
/** * The UI for recommending the site. * * @return tempcode The UI. */ function gui() { require_code('form_templates'); global $EXTRA_HEAD; $EXTRA_HEAD->attach('<meta name="robots" content="noindex" />'); // XHTMLXHTML global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'page_title'; $NON_CANONICAL_PARAMS[] = 'subject'; $NON_CANONICAL_PARAMS[] = 's_message'; $NON_CANONICAL_PARAMS[] = 'from'; $NON_CANONICAL_PARAMS[] = 'title'; $NON_CANONICAL_PARAMS[] = 'ocp'; $page_title = get_param('page_title', NULL, true); $submit_name = !is_null($page_title) ? make_string_tempcode($page_title) : do_lang_tempcode('SEND'); $post_url = build_url(array('page' => '_SELF', 'type' => 'actual'), '_SELF', NULL, true); $hidden = new ocp_tempcode(); $name = post_param('name', is_guest() ? '' : $GLOBALS['FORUM_DRIVER']->get_username(get_member())); $recommender_email_address = post_param('recommender_email_address', $GLOBALS['FORUM_DRIVER']->get_member_email_address(get_member())); $fields = new ocp_tempcode(); $fields->attach(form_input_line(do_lang_tempcode('YOUR_NAME'), '', 'name', $name, true)); $fields->attach(form_input_email(do_lang_tempcode('YOUR_EMAIL_ADDRESS'), '', 'recommender_email_address', $recommender_email_address, true)); $already = array(); foreach ($_POST as $key => $email_address) { if (substr($key, 0, 14) != 'email_address_') { continue; } if (get_magic_quotes_gpc()) { $email_address = stripslashes($email_address); } $already[] = $email_address; } if (is_guest()) { $fields->attach(form_input_email(do_lang_tempcode('FRIEND_EMAIL_ADDRESS'), '', 'email_address_0', array_key_exists(0, $already) ? $already[0] : '', true)); } else { $fields->attach(form_input_line_multi(do_lang_tempcode('FRIEND_EMAIL_ADDRESS'), do_lang_tempcode('THEIR_ADDRESS'), 'email_address_', $already, 1, NULL, 'email')); } if (may_use_invites() && get_forum_type() == 'ocf' && !is_guest()) { $invites = get_num_invites(get_member()); if ($invites > 0) { require_lang('ocf'); $invite = count($_POST) == 0 ? true : post_param_integer('invite', 0) == 1; $fields->attach(form_input_tick(do_lang_tempcode('USE_INVITE'), do_lang_tempcode('USE_INVITE_DESCRIPTION', $GLOBALS['FORUM_DRIVER']->is_super_admin(get_member()) ? do_lang('NA_EM') : integer_format($invites)), 'invite', $invite)); } } $message = post_param('message', NULL); $subject = get_param('subject', do_lang('RECOMMEND_MEMBER_SUBJECT', get_site_name()), true); if (is_null($message)) { $message = get_param('s_message', '', true); if ($message == '') { $from = get_param('from', NULL, true); if (!is_null($from)) { $resource_title = get_param('title', '', true); if ($resource_title == '') { $downloaded_at_link = http_download_file($from, 3000, false); if (is_string($downloaded_at_link)) { $matches = array(); if (preg_match('#\\s*<title[^>]*\\s*>\\s*(.*)\\s*\\s*<\\s*/title\\s*>#mi', $downloaded_at_link, $matches) != 0) { $resource_title = trim(str_replace('–', '-', str_replace('—', '-', @html_entity_decode($matches[1], ENT_QUOTES, get_charset())))); $resource_title = preg_replace('#^' . str_replace('#', '\\#', preg_quote(get_site_name())) . ' - #', '', $resource_title); $resource_title = preg_replace('#\\s+[^\\d\\s][^\\d\\s]?[^\\d\\s]?\\s+' . str_replace('#', '\\#', preg_quote(get_site_name())) . '$#i', '', $resource_title); } } } if ($resource_title == '') { $resource_title = do_lang('THIS'); // Could not find at all, so say 'this' } else { $subject = get_param('subject', do_lang('RECOMMEND_MEMBER_SUBJECT_SPECIFIC', get_site_name(), $resource_title), true); } $message = do_lang('FOUND_THIS_ON', get_site_name(), comcode_escape($from), comcode_escape($resource_title)); } } if (get_param_integer('ocp', 0) == 1) { $message = do_lang('RECOMMEND_OCPORTAL'); } } $text = is_null($page_title) ? do_lang_tempcode('RECOMMEND_SITE_TEXT') : new ocp_tempcode(); if (!is_null(get_param('from', NULL, true))) { if (is_null($page_title)) { $title = get_page_title('RECOMMEND_LINK'); } else { $title = get_page_title($page_title, false); } $submit_name = do_lang_tempcode('SEND'); $text = do_lang_tempcode('RECOMMEND_AUTO_TEXT', get_site_name()); $need_message = true; } else { if (is_null($page_title)) { $title = get_page_title('_RECOMMEND_SITE', true, array(escape_html(get_site_name()))); } else { $title = get_page_title($page_title, false); } $hidden->attach(form_input_hidden('wrap_message', '1')); $need_message = false; } //add an upload CSV contacts file field $_help_url = build_url(array('page' => 'recommend_help'), get_page_zone('recommend_help')); $help_url = $_help_url->evaluate(); if (get_value('disable_csv_recommend') !== '1' && !is_guest()) { $fields->attach(form_input_upload(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('UPLOAD')), do_lang_tempcode('DESCRIPTION_UPLOAD_CSV_FILE', escape_html($help_url)), 'upload', false, NULL, NULL, false)); } handle_max_file_size($hidden); $fields->attach(form_input_line(do_lang_tempcode('SUBJECT'), '', 'subject', $subject, true)); $fields->attach(form_input_text_comcode(do_lang_tempcode('MESSAGE'), do_lang_tempcode('RECOMMEND_SUP_MESSAGE'), 'message', $message, $need_message)); if (addon_installed('captcha')) { require_code('captcha'); if (use_captcha()) { $fields->attach(form_input_captcha()); $text->attach(' '); $text->attach(do_lang_tempcode('FORM_TIME_SECURITY')); } } $hidden->attach(form_input_hidden('comcode__message', '1')); if (get_value('disable_csv_recommend') !== '1' && !is_guest()) { $javascript = 'standardAlternateFields(\'upload\',\'email_address_0\');'; } else { $javascript = ''; } $javascript .= function_exists('captcha_ajax_check') ? captcha_ajax_check() : ''; return do_template('FORM_SCREEN', array('_GUID' => '08a538ca8d78597b0417f464758a59fd', 'JAVASCRIPT' => $javascript, 'SKIP_VALIDATION' => true, 'TITLE' => $title, 'HIDDEN' => $hidden, 'FIELDS' => $fields, 'URL' => $post_url, 'SUBMIT_NAME' => $submit_name, 'TEXT' => $text)); }
/** * Get the join form. * * @param tempcode URL to direct to * @param boolean Whether to handle CAPTCHA (if enabled at all) * @param boolean Whether to ask for intro messages (if enabled at all) * @param boolean Whether to check for invites (if enabled at all) * @param boolean Whether to check email-address restrictions (if enabled at all) * @return array A tuple: Necessary Javascript code, the form */ function ocf_join_form($url, $captcha_if_enabled = true, $intro_message_if_enabled = true, $invites_if_enabled = true, $one_per_email_address_if_enabled = true) { ocf_require_all_forum_stuff(); require_css('ocf'); require_code('ocf_members_action'); require_code('ocf_members_action2'); require_code('form_templates'); $hidden = new ocp_tempcode(); $hidden->attach(build_keep_post_fields()); $groups = ocf_get_all_default_groups(true); $primary_group = either_param_integer('primary_group', NULL); if ($primary_group !== NULL && !in_array($primary_group, $groups)) { // Check security $test = $GLOBALS['FORUM_DB']->query_value('f_groups', 'g_is_presented_at_install', array('id' => $primary_group)); if ($test == 1) { $groups = ocf_get_all_default_groups(false); $hidden = form_input_hidden('primary_group', strval($primary_group)); $groups[] = $primary_group; } } list($fields, $_hidden) = ocf_get_member_fields(true, NULL, $groups); $hidden->attach($_hidden); if ($intro_message_if_enabled) { $forum_id = get_option('intro_forum_id'); if ($forum_id != '') { $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('INTRODUCE_YOURSELF')))); $fields->attach(form_input_line(do_lang_tempcode('TITLE'), '', 'intro_title', do_lang('INTRO_POST_DEFAULT', '___'), false)); $fields->attach(form_input_text_comcode(do_lang_tempcode('POST_COMMENT'), do_lang_tempcode('DESCRIPTION_INTRO_POST'), 'intro_post', '', false)); } } $text = do_lang_tempcode('ENTER_PROFILE_DETAILS'); if ($captcha_if_enabled) { if (addon_installed('captcha')) { require_code('captcha'); if (use_captcha()) { $fields->attach(form_input_captcha()); $text->attach(' '); $text->attach(do_lang_tempcode('FORM_TIME_SECURITY')); } } } $submit_name = do_lang_tempcode('PROCEED'); require_javascript('javascript_ajax'); $script = find_script('username_check'); $javascript = "\n\t\tvar form=document.getElementById('username').form;\n\t\tform.elements['username'].onchange=function()\n\t\t{\n\t\t\tif (form.elements['intro_title'])\n\t\t\t\tform.elements['intro_title'].value='" . addslashes(do_lang('INTRO_POST_DEFAULT')) . "'.replace(/\\{1\\}/g,form.elements['username'].value);\n\t\t}\n\t\tform.old_submit=form.onsubmit;\n\t\tform.onsubmit=function()\n\t\t\t{\n\t\t\t\tif ((form.elements['email_address_confirm']) && (form.elements['email_address_confirm'].value!=form.elements['email_address'].value))\n\t\t\t\t{\n\t\t\t\t\twindow.fauxmodal_alert('" . php_addslashes(do_lang('EMAIL_ADDRESS_MISMATCH')) . "');\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tif ((form.elements['password_confirm']) && (form.elements['password_confirm'].value!=form.elements['password'].value))\n\t\t\t\t{\n\t\t\t\t\twindow.fauxmodal_alert('" . php_addslashes(do_lang('PASSWORD_MISMATCH')) . "');\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tdocument.getElementById('submit_button').disabled=true;\n\t\t\t\tvar url='" . addslashes($script) . "?username='******'username'].value);\n\t\t\t\tif (!do_ajax_field_test(url,'password='******'password'].value)))\n\t\t\t\t{\n\t\t\t\t\tdocument.getElementById('submit_button').disabled=false;\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t"; $script = find_script('snippet'); if ($invites_if_enabled) { if (get_option('is_on_invites') == '1') { $javascript .= "\n\t\t\t\t\turl='" . addslashes($script) . "?snippet=invite_missing&name='+window.encodeURIComponent(form.elements['email_address'].value);\n\t\t\t\t\tif (!do_ajax_field_test(url))\n\t\t\t\t\t{\n\t\t\t\t\t\tdocument.getElementById('submit_button').disabled=false;\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t"; } } if ($one_per_email_address_if_enabled) { if (get_option('one_per_email_address') == '1') { $javascript .= "\n\t\t\t\t\turl='" . addslashes($script) . "?snippet=email_exists&name='+window.encodeURIComponent(form.elements['email_address'].value);\n\t\t\t\t\tif (!do_ajax_field_test(url))\n\t\t\t\t\t{\n\t\t\t\t\t\tdocument.getElementById('submit_button').disabled=false;\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t"; } } if ($captcha_if_enabled) { if (addon_installed('captcha')) { require_code('captcha'); if (use_captcha()) { $javascript .= "\n\t\t\t\t\t\turl='" . addslashes($script) . "?snippet=captcha_wrong&name='+window.encodeURIComponent(form.elements['security_image'].value);\n\t\t\t\t\t\tif (!do_ajax_field_test(url))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdocument.getElementById('submit_button').disabled=false;\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t"; } } } $javascript .= "\n\t\t\t\tdocument.getElementById('submit_button').disabled=false;\n\t\t\t\tif (typeof form.old_submit!='undefined' && form.old_submit) return form.old_submit();\n\t\t\t\treturn true;\n\t\t\t};\n\t"; $form = do_template('FORM', array('TEXT' => '', 'HIDDEN' => $hidden, 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name, 'URL' => $url)); return array($javascript, $form); }