/** * Get the tempcode for the form to add a banner, with the information passed along to it via the parameters already added in. * * @param boolean Whether to simplify the banner interface (for the point-store buy process) * @param ID_TEXT The name of the banner * @param URLPATH The URL to the banner image * @param URLPATH The URL to the site the banner leads to * @param SHORT_TEXT The caption of the banner * @param LONG_TEXT Any notes associated with the banner * @param integer The banners "importance modulus" * @range 1 max * @param ?integer The number of hits the banner may have (NULL: not applicable for this banner type) * @range 0 max * @param SHORT_INTEGER The type of banner (0=permanent, 1=campaign, 2=default) * @set 0 1 2 * @param ?TIME The banner expiry date (NULL: never expires) * @param ?ID_TEXT The username of the banners submitter (NULL: current member) * @param BINARY Whether the banner has been validated * @param ID_TEXT The banner type (can be anything, where blank means 'normal') * @param SHORT_TEXT The title text for the banner (only used for text banners, and functions as the 'trigger text' if the banner type is shown inline) * @return tempcode The input field tempcode */ function get_banner_form_fields($simplified = false, $name = '', $image_url = '', $site_url = '', $caption = '', $notes = '', $importancemodulus = 3, $campaignremaining = 50, $the_type = 1, $expiry_date = NULL, $submitter = NULL, $validated = 1, $b_type = '', $title_text = '') { require_code('images'); $fields = new ocp_tempcode(); require_code('form_templates'); $fields->attach(form_input_codename(do_lang_tempcode('CODENAME'), do_lang_tempcode('DESCRIPTION_BANNER_NAME'), 'name', $name, true)); $fields->attach(form_input_line(do_lang_tempcode('DESTINATION_URL'), do_lang_tempcode('DESCRIPTION_BANNER_URL'), 'site_url', $site_url, false)); // Blank implies iframe if (!$simplified) { $types = nice_get_banner_types($b_type); if ($types->is_empty()) { warn_exit(do_lang_tempcode('NO_CATEGORIES')); } $fields->attach(form_input_list(do_lang_tempcode('_BANNER_TYPE'), do_lang_tempcode('_DESCRIPTION_BANNER_TYPE'), 'b_type', $types, NULL, false, false)); } else { $fields->attach(form_input_hidden('b_type', $b_type)); } if (has_specific_permission(get_member(), 'full_banner_setup')) { $fields->attach(form_input_username(do_lang_tempcode('OWNER'), do_lang_tempcode('DESCRIPTION_SUBMITTER'), 'submitter', is_null($submitter) ? $GLOBALS['FORUM_DRIVER']->get_username(get_member()) : $submitter, 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)); } if (has_specific_permission(get_member(), 'bypass_validation_midrange_content', 'cms_banners')) { 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_VALIDATED'), 'validated', $validated == 1)); } } $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('SOURCE_MEDIA')))); $fields->attach(form_input_upload(do_lang_tempcode('UPLOAD'), do_lang_tempcode('DESCRIPTION_UPLOAD_BANNER'), 'file', false, NULL, NULL, true, str_replace(' ', '', get_option('valid_images') . ',swf'))); $fields->attach(form_input_line(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('IMAGE_URL')), do_lang_tempcode('DESCRIPTION_URL_BANNER'), 'image_url', $image_url, false)); $fields->attach(form_input_line_comcode(do_lang_tempcode('BANNER_TITLE_TEXT'), do_lang_tempcode('DESCRIPTION_BANNER_TITLE_TEXT'), 'title_text', $title_text, false)); $fields->attach(form_input_line_comcode(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_BANNER_DESCRIPTION'), 'caption', $caption, false)); $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('DEPLOYMENT_DETERMINATION')))); if (has_specific_permission(get_member(), 'full_banner_setup')) { $radios = new ocp_tempcode(); $radios->attach(form_input_radio_entry('the_type', strval(BANNER_PERMANENT), $the_type == BANNER_PERMANENT, do_lang_tempcode('BANNER_PERMANENT'))); $radios->attach(form_input_radio_entry('the_type', strval(BANNER_CAMPAIGN), $the_type == BANNER_CAMPAIGN, do_lang_tempcode('BANNER_CAMPAIGN'))); $radios->attach(form_input_radio_entry('the_type', strval(BANNER_DEFAULT), $the_type == BANNER_DEFAULT, do_lang_tempcode('BANNER_DEFAULT'))); $fields->attach(form_input_radio(do_lang_tempcode('DEPLOYMENT_AGREEMENT'), do_lang_tempcode('DESCRIPTION_BANNER_TYPE'), 'the_type', $radios)); $fields->attach(form_input_integer(do_lang_tempcode('HITS_ALLOCATED'), do_lang_tempcode('DESCRIPTION_HITS_ALLOCATED'), 'campaignremaining', $campaignremaining, false)); $total_importance = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT SUM(importance_modulus) FROM ' . get_table_prefix() . 'banners WHERE ' . db_string_not_equal_to('name', $name)); if (is_null($total_importance)) { $total_importance = 0; } $fields->attach(form_input_integer(do_lang_tempcode('IMPORTANCE_MODULUS'), do_lang_tempcode('DESCRIPTION_IMPORTANCE_MODULUS', strval($total_importance), strval($importancemodulus)), 'importancemodulus', $importancemodulus, true)); } $fields->attach(form_input_date(do_lang_tempcode('EXPIRY_DATE'), do_lang_tempcode('DESCRIPTION_EXPIRY_DATE'), 'expiry_date', true, is_null($expiry_date), true, $expiry_date, 2)); return $fields; }
/** * The UI for choosing members to merge. * * @return tempcode The UI */ function gui() { $title = get_page_title('MERGE_MEMBERS'); breadcrumb_set_parents(array(array('_SEARCH:admin_ocf_join:menu', do_lang_tempcode('MEMBERS')))); $fields = new ocp_tempcode(); require_code('form_templates'); $fields->attach(form_input_username(do_lang_tempcode('FROM'), do_lang_tempcode('DESCRIPTION_MEMBER_FROM'), 'from', '', true)); $fields->attach(form_input_username(do_lang_tempcode('TO'), do_lang_tempcode('DESCRIPTION_MEMBER_TO'), 'to', '', true)); $submit_name = do_lang_tempcode('MERGE_MEMBERS'); $post_url = build_url(array('page' => '_SELF', 'type' => 'actual'), '_SELF'); $text = do_lang_tempcode('MERGE_MEMBERS_TEXT'); return do_template('FORM_SCREEN', array('_GUID' => '6f6b18d90bbe9550303ab41be0a26dcb', 'SKIP_VALIDATION' => true, 'TITLE' => $title, 'URL' => $post_url, 'FIELDS' => $fields, 'HIDDEN' => '', 'TEXT' => $text, 'SUBMIT_NAME' => $submit_name)); }
/** * Standard actualisation stage of pointstore item purchase. * * @return tempcode The UI */ function action_done() { $class = str_replace('hook_pointstore_', '', strtolower(get_class($this))); $title = get_page_title('OCGIFTS_TITLE'); require_code('form_templates'); $fields = new ocp_tempcode(); $fields->attach(form_input_username(do_lang_tempcode('TO_USERNAME'), do_lang_tempcode('MEMBER_TO_GIVE'), 'username', get_param('username', ''), true)); $fields->attach(form_input_text(do_lang_tempcode('GIFT_MESSAGE'), do_lang_tempcode('DESCRIPTION_GIFT_MESSAGE'), 'gift_message', '', true)); $fields->attach(form_input_tick(do_lang_tempcode('ANONYMOUS'), do_lang_tempcode('DESCRIPTION_ANONYMOUS'), 'anonymous', false)); $submit_name = do_lang_tempcode('SEND_GIFT'); $text = paragraph(do_lang_tempcode('CHOOSE_MEMBER')); $post_url = build_url(array('page' => 'pointstore', 'type' => 'action_done2', 'id' => 'ocgifts', 'gift' => get_param('gift', 0)), '_SEARCH'); return do_template('FORM_SCREEN', array('SKIP_VALIDATION' => true, 'STAFF_HELP_URL' => '', 'HIDDEN' => '', 'TITLE' => $title, 'FIELDS' => $fields, 'TEXT' => $text, 'SUBMIT_NAME' => $submit_name, 'URL' => $post_url)); }
function get_referrer_field() { require_lang('referrals'); $by_url = get_param('keep_referrer', ''); if ($by_url != '') { if (is_numeric($by_url)) { $by_url = $GLOBALS['FORUM_DRIVER']->get_username($by_url); if (is_null($by_url)) { $by_url = ''; } } } $field = form_input_username(do_lang_tempcode('TYPE_REFERRER'), do_lang_tempcode('DESCRIPTION_TYPE_REFERRER'), 'referrer', $by_url, false, true); return $field; }
/** * The UI to make a normal topic a Private Topic. * * @return tempcode The UI */ function make_personal() { $topic_id = get_param_integer('id'); $this->check_has_mod_access($topic_id); $topic_info = $GLOBALS['FORUM_DB']->query_select('f_topics', array('*'), array('id' => $topic_id), '', 1); if (!array_key_exists(0, $topic_info)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $a = $topic_info[0]['t_cache_first_username']; $b = $GLOBALS['FORUM_DRIVER']->get_username(get_member()); $title = get_page_title('MAKE_PERSONAL'); $text = do_lang_tempcode('MAKE_PERSONAL_DESCRIPTION'); $submit_name = do_lang_tempcode('MAKE_PERSONAL'); $post_url = build_url(array('page' => '_SELF', 'type' => '_make_personal'), '_SELF'); $fields = new ocp_tempcode(); $hidden = form_input_hidden('id', strval($topic_id)); $fields->attach(form_input_username(do_lang_tempcode('FROM'), '', 'a', $a, true)); $fields->attach(form_input_username(do_lang_tempcode('TO'), '', 'b', $b, true)); return do_template('FORM_SCREEN', array('STAFF_HELP_URL' => brand_base_url() . '/docs' . strval(ocp_version()) . '/pg/tut_correspondance', 'HIDDEN' => $hidden, 'TITLE' => $title, 'TEXT' => $text, 'URL' => $post_url, 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name)); }
/** * The UI to manage who is blocked. * * @return tempcode The UI */ function blocking_interface() { if (is_guest()) { access_denied('NOT_AS_GUEST'); } $title = get_page_title('MEMBER_BLOCKING'); require_code('form_templates'); $fields = new ocp_tempcode(); $blocked = $GLOBALS['SITE_DB']->query_select('chat_blocking', array('member_blocked'), array('member_blocker' => get_member())); $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('EXISTING_BLOCKS'), 'HELP' => count($blocked) != 0 ? new ocp_tempcode() : do_lang_tempcode('NONE_EM')))); foreach ($blocked as $row) { $username = $GLOBALS['FORUM_DRIVER']->get_username($row['member_blocked']); if (!is_null($username)) { $fields->attach(form_input_tick(do_lang_tempcode('BLOCK_THEM', escape_html($username)), do_lang_tempcode('_BLOCK_MEMBER', $username), 'block_' . strval($row['member_blocked']), true)); } } $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ADD_BLOCK')))); $fields->attach(form_input_username(do_lang_tempcode('USERNAME'), do_lang_tempcode('BLOCK_MEMBER_MANUAL'), 'username', '', false)); /*if ($fields->is_empty()) { inform_exit(do_lang_tempcode('NOBODY_BLOCKED_YET')); }*/ $post_url = build_url(array('page' => '_SELF', 'type' => 'blocking_set'), '_SELF'); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('CHAT_LOBBY')))); return do_template('FORM_SCREEN', array('_GUID' => '74e0700f4d2b52d71a0cbf8eb3045ecf', 'TITLE' => $title, 'HIDDEN' => '', 'SKIP_VALIDATION' => true, 'TEXT' => do_lang_tempcode('ABOUT_BLOCKING'), 'SUBMIT_NAME' => do_lang_tempcode('PROCEED'), 'FIELDS' => $fields, 'URL' => $post_url)); }
/** * The UI and actualisation for: accepting code if it is correct (and not ''), and setting password to something random, emailing it * * @return tempcode The UI */ function step3() { $title = get_page_title('RESET_PASSWORD'); $code = get_param('code', ''); if ($code == '') { require_code('form_templates'); $fields = new ocp_tempcode(); $fields->attach(form_input_username(do_lang_tempcode('USERNAME'), '', 'username', NULL, true)); $fields->attach(form_input_integer(do_lang_tempcode('CODE'), '', 'code', NULL, true)); $submit_name = do_lang_tempcode('PROCEED'); return do_template('FORM_SCREEN', array('_GUID' => '6e4db5c6f3c75faa999251339533d22a', 'TITLE' => $title, 'GET' => true, 'SKIP_VALIDATION' => true, 'HIDDEN' => '', 'URL' => get_self_url(false, false, NULL, false, true), 'FIELDS' => $fields, 'TEXT' => do_lang_tempcode('MISSING_CONFIRM_CODE'), 'SUBMIT_NAME' => $submit_name)); } $username = get_param('username', NULL); if (!is_null($username)) { $username = trim($username); $member = $GLOBALS['FORUM_DRIVER']->get_member_from_username($username); if (is_null($member)) { warn_exit(do_lang_tempcode('PASSWORD_RESET_ERROR_2')); } } else { $member = get_param_integer('member'); } $correct_code = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member, 'm_password_change_code'); if ($correct_code == '') { $_reset_url = build_url(array('page' => '_SELF', 'username' => $GLOBALS['FORUM_DRIVER']->get_username($member)), '_SELF'); $reset_url = $_reset_url->evaluate(); warn_exit(do_lang_tempcode('PASSWORD_ALREADY_RESET', escape_html($reset_url), get_site_name())); } if ($code != $correct_code) { $test = $GLOBALS['SITE_DB']->query_value_null_ok('adminlogs', 'date_and_time', array('the_type' => 'RESET_PASSWORD', 'param_a' => strval($member), 'param_b' => $code)); if (!is_null($test)) { warn_exit(do_lang_tempcode('INCORRECT_PASSWORD_RESET_CODE')); } log_hack_attack_and_exit('HACK_ATTACK_PASSWORD_CHANGE'); } $email = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member, 'm_email_address'); $new_password = get_rand_password(); // Send password in mail $_login_url = build_url(array('page' => 'login', 'username' => $GLOBALS['FORUM_DRIVER']->get_username($member)), get_module_zone('login'), NULL, false, false, true); $login_url = $_login_url->evaluate(); $message = do_lang('MAIL_NEW_PASSWORD', comcode_escape($new_password), $login_url, get_site_name()); require_code('mail'); mail_wrap(do_lang('RESET_PASSWORD'), $message, array($email), $GLOBALS['FORUM_DRIVER']->get_username($member), '', '', 3, NULL, false, NULL, false, false, false, 'MAIL', true); if (get_value('no_password_hashing') === '1') { $password_compatibility_scheme = 'plain'; $new = $new_password; } else { $password_compatibility_scheme = ''; $salt = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member, 'm_pass_salt'); $new = md5($salt . md5($new_password)); } unset($_GET['code']); $GLOBALS['FORUM_DB']->query_update('f_members', array('m_validated_email_confirm_code' => '', 'm_password_compat_scheme' => $password_compatibility_scheme, 'm_password_change_code' => '', 'm_pass_hash_salted' => $new), array('id' => $member), '', 1); return inform_screen($title, do_lang_tempcode('NEW_PASSWORD_MAILED', escape_html($email))); }
/** * 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 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 * @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) { if (is_null($actual_value)) { $actual_value = ''; } // Plug anomaly due to unusual corruption if ($actual_value == '') { if ($field['cf_default'] == '!') { $actual_value = $GLOBALS['FORUM_DRIVER']->get_username(get_member()); } } else { $actual_value = $GLOBALS['FORUM_DRIVER']->get_username(intval($actual_value)); } return form_input_username($_cf_name, $_cf_description, 'field_' . strval($field['id']), $actual_value, $field['cf_required'] == 1); }
/** * The UI for managing temporary usergroup memberships. * * @return tempcode The UI */ function group_member_timeouts() { $title = get_page_title('GROUP_MEMBER_TIMEOUTS'); if (!cron_installed()) { attach_message(do_lang_tempcode('CRON_NEEDED_TO_WORK', escape_html(brand_base_url() . '/docs' . strval(ocp_version()) . '/pg/tut_configuration')), 'warn'); } $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/usergroups_temp'; breadcrumb_set_parents(array(array('_SEARCH:admin_ocf_join:menu', do_lang_tempcode('MEMBERS')))); require_code('form_templates'); require_code('templates_results_table'); $start = get_param_integer('start', 0); $max = get_param_integer('max', 100); $max_rows = $GLOBALS[get_forum_type() == 'ocf' ? 'FORUM_DB' : 'SITE_DB']->query_value('f_group_member_timeouts', 'COUNT(*)'); $fields_title = results_field_title(array(do_lang_tempcode('USERNAME'), do_lang_tempcode('_USERGROUP'), do_lang_tempcode('TIME'))); $timeouts = $GLOBALS[get_forum_type() == 'ocf' ? 'FORUM_DB' : 'SITE_DB']->query_select('f_group_member_timeouts', array('member_id', 'group_id', 'timeout'), NULL, '', $max, $start); $usergroups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(); $tfields = new ocp_tempcode(); foreach ($timeouts as $timeout) { $tfields->attach(results_entry(array($GLOBALS['FORUM_DRIVER']->get_username($timeout['member_id']), isset($usergroups[$timeout['group_id']]) ? $usergroups[$timeout['group_id']] : do_lang('UNKNOWN'), display_time_period($timeout['timeout'] - time())), true)); } $results_table = results_table(do_lang('GROUP_MEMBER_TIMEOUTS'), $start, 'start', $max, 'max', $max_rows, $fields_title, $tfields); $fields = new ocp_tempcode(); $fields->attach(form_input_username(do_lang_tempcode('USERNAME'), '', 'username', '', true)); $_usergroups = new ocp_tempcode(); foreach ($usergroups as $uid => $name) { if ($uid != db_get_first_id()) { $_usergroups->attach(form_input_list_entry($uid, false, $name)); } } require_lang('dates'); $fields->attach(form_input_list(do_lang_tempcode('_USERGROUP'), '', 'group_id', $_usergroups, NULL, false, true)); $fields->attach(form_input_integer(do_lang_tempcode('_MINUTES'), do_lang_tempcode('DESCRIPTION_GROUPMT_MINUTES'), 'num_minutes', 60, true)); $post_url = build_url(array('page' => '_SELF', 'type' => '_group_member_timeouts'), '_SELF'); $submit_name = do_lang_tempcode('ADD'); $form = do_template('FORM', array('TABINDEX' => strval(get_form_field_tabindex()), 'HIDDEN' => '', 'TEXT' => '', 'FIELDS' => $fields, 'URL' => $post_url, 'SUBMIT_NAME' => $submit_name)); return do_template('RESULTS_TABLE_SCREEN', array('TITLE' => $title, 'RESULTS_TABLE' => $results_table, 'FORM' => $form)); }
/** * Get tempcode for a adding/editing form. * * @param ?GROUP The usergroup being edited (NULL: adding, not editing, and let's choose the current member) * @param SHORT_TEXT The usergroup name * @param ?ID_TEXT The username of the usergroup leader (NULL: none picked yet) * @param BINARY Whether members may join this usergroup without requiring any special permission * @return tempcode The input fields */ function get_form_fields($id = NULL, $name = '', $group_leader = NULL, $open_membership = 1) { if (is_null($group_leader)) { $group_leader = $GLOBALS['FORUM_DRIVER']->get_username(get_member()); } $fields = new ocp_tempcode(); require_code('form_templates'); $fields->attach(form_input_line(do_lang_tempcode('NAME'), do_lang_tempcode('DESCRIPTION_USERGROUP_TITLE'), 'name', $name, true)); $fields->attach(form_input_username(do_lang_tempcode('GROUP_LEADER'), do_lang_tempcode('DESCRIPTION_GROUP_LEADER'), 'group_leader', $group_leader, false)); $fields->attach(form_input_tick(do_lang_tempcode('OPEN_MEMBERSHIP'), do_lang_tempcode('OPEN_MEMBERSHIP_DESCRIPTION'), 'open_membership', $open_membership == 1)); return $fields; }
/** * Get form fields for adding/editing a chatroom. * * @param boolean Whether the room is being made as a private room by the current member * @param SHORT_TEXT The room name * @param LONG_TEXT The welcome message * @param SHORT_TEXT The owner username * @param LONG_TEXT The comma-separated list of users that may access it (blank: no restriction) * @param LONG_TEXT The comma-separated list of usergroups that may access it (blank: no restriction) * @param LONG_TEXT The comma-separated list of users that may NOT access it (blank: no restriction) * @param LONG_TEXT The comma-separated list of usergroups that may NOT access it (blank: no restriction) * @return tempcode The fields */ function get_chatroom_fields($is_made_by_me = false, $room_name = '', $welcome = '', $username = '', $allow2 = '', $allow2_groups = '', $disallow2 = '', $disallow2_groups = '') { require_code('form_templates'); $fields = new ocp_tempcode(); $fields->attach(form_input_line(do_lang_tempcode('ROOM_NAME'), do_lang_tempcode('DESCRIPTION_ROOM_NAME'), 'room_name', $room_name, true)); $fields->attach(form_input_line_comcode(do_lang_tempcode('WELCOME_MESSAGE'), do_lang_tempcode('DESCRIPTION_WELCOME_MESSAGE'), 'c_welcome', $welcome, false)); if (!$is_made_by_me) { $fields->attach(form_input_username(do_lang_tempcode('ROOM_OWNER'), do_lang_tempcode('DESCRIPTION_ROOM_OWNER'), 'room_owner', $username, false)); } $langs = find_all_langs(); if (count($langs) > 1) { $fields->attach(form_input_list(do_lang_tempcode('ROOM_LANG'), do_lang_tempcode('DESCRIPTION_ROOM_LANG'), 'room_lang', nice_get_langs())); } require_lang('permissions'); $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => $allow2 == '' && $allow2_groups == '' && !$is_made_by_me, 'TITLE' => do_lang_tempcode($is_made_by_me ? 'PERMISSIONS' : 'LOWLEVEL_PERMISSIONS')))); $fields->attach(form_input_username_multi(do_lang_tempcode('ALLOW_LIST'), do_lang_tempcode('DESCRIPTION_ALLOW_LIST'), 'allow_list', array_map(array($GLOBALS['FORUM_DRIVER'], 'get_username'), $allow2 == '' ? array() : array_map('intval', explode(',', $allow2))), 0, true)); if (!$is_made_by_me || get_option('group_private_chatrooms') == '1') { $usergroup_list = new ocp_tempcode(); $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(true); foreach ($groups as $key => $val) { if ($key != db_get_first_id()) { if (get_forum_type() == 'ocf') { require_code('ocf_groups2'); $num_members = ocf_get_group_members_raw_count($key); if ($num_members >= 1 && $num_members <= 6) { $group_members = ocf_get_group_members_raw($key); $group_member_usernames = ''; foreach ($group_members as $group_member) { if ($group_member_usernames != '') { $group_member_usernames = do_lang('LIST_SEP'); } $group_member_usernames .= $GLOBALS['FORUM_DRIVER']->get_username($group_member); } $val = do_lang('GROUP_MEMBERS_SPECIFIC', $val, $group_member_usernames); } else { $val = do_lang('GROUP_MEMBERS', $val, number_format($num_members)); } } $usergroup_list->attach(form_input_list_entry(strval($key), $allow2_groups == '*' || count(array_intersect(array($key), $allow2_groups == '' ? array() : explode(',', $allow2_groups))) != 0, $val)); } } $fields->attach(form_input_multi_list(do_lang_tempcode('ALLOW_LIST_GROUPS'), do_lang_tempcode($is_made_by_me ? 'DESCRIPTION_ALLOW_LIST_GROUPS_SIMPLE' : 'DESCRIPTION_ALLOW_LIST_GROUPS'), 'allow_list_groups', $usergroup_list)); } $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => $disallow2 == '' && $disallow2_groups == '', 'TITLE' => do_lang_tempcode('ADVANCED')))); $fields->attach(form_input_username_multi(do_lang_tempcode('DISALLOW_LIST'), do_lang_tempcode('DESCRIPTION_DISALLOW_LIST'), 'disallow_list', array_map(array($GLOBALS['FORUM_DRIVER'], 'get_username'), $disallow2 == '' ? array() : array_map('intval', explode(',', $disallow2))), 0, true)); if (!$is_made_by_me || get_option('group_private_chatrooms') == '1') { $usergroup_list = new ocp_tempcode(); $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(true); foreach ($groups as $key => $val) { if ($key != db_get_first_id()) { if (get_forum_type() == 'ocf') { require_code('ocf_groups2'); $num_members = ocf_get_group_members_raw_count($key); if ($num_members >= 1 && $num_members <= 6) { $group_members = ocf_get_group_members_raw($key); $group_member_usernames = ''; foreach ($group_members as $group_member) { if ($group_member_usernames != '') { $group_member_usernames = do_lang('LIST_SEP'); } $group_member_usernames .= $GLOBALS['FORUM_DRIVER']->get_username($group_member); } $val = do_lang('GROUP_MEMBERS_SPECIFIC', $val, $group_member_usernames); } else { $val = do_lang('GROUP_MEMBERS', $val, number_format($num_members)); } } $usergroup_list->attach(form_input_list_entry(strval($key), $disallow2_groups == '*' || count(array_intersect(array($key), $disallow2_groups == '' ? array() : explode(',', $disallow2_groups))) != 0, $val)); } } $fields->attach(form_input_multi_list(do_lang_tempcode('DISALLOW_LIST_GROUPS'), do_lang_tempcode('DESCRIPTION_DISALLOW_LIST_GROUPS'), 'disallow_list_groups', $usergroup_list)); } return $fields; }
/** * The UI to edit a page. * * @return tempcode The UI */ function _ed() { $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/comcode_page_edit'; require_lang('menus'); $GLOBALS['HELPER_PANEL_TEXT'] = comcode_lang_string('DOC_WRITING'); $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_comcode_pages'; $simple_add = get_param_integer('simple_add', 0) == 1; $lang = choose_language(get_page_title($simple_add ? 'COMCODE_PAGE_ADD' : 'COMCODE_PAGE_EDIT'), true); if (is_object($lang)) { return $lang; } if (addon_installed('page_management')) { // Add to menu if (get_param('menu', STRING_MAGIC_NULL) != STRING_MAGIC_NULL && has_actual_page_access(get_member(), 'admin_sitetree')) { require_code('menus2'); add_menu_item_simple(get_param('menu'), NULL, get_param('title'), get_param('page_link'), 0, 0, false); } } // Work out what we're editing, and where it's coming from (support for two pagelink specifying parameters for destination, with addition of restore_from to override source if different from destination) $page_link = filter_naughty(get_param('page_link', '')); if ($page_link == '') { $page_link = get_param('page_link_2'); } if (strpos($page_link, ':') === false) { $page_link = ':' . $page_link; } $page_link_parts = explode(':', $page_link); if (count($page_link_parts) != 2) { warn_exit(do_lang_tempcode('ZONE_COLON_FILE')); } $zone = $page_link_parts[0]; if ($zone != '' && !file_exists(get_file_base() . '/' . $zone . '/pages')) { warn_exit(do_lang_tempcode('NO_SUCH_ZONE')); } $file = $page_link_parts[1]; require_code('type_validation'); if (!is_alphanumeric($file, true)) { warn_exit(do_lang_tempcode('BAD_CODENAME')); } $resource_owner = $GLOBALS['SITE_DB']->query_value_null_ok('comcode_pages', 'p_submitter', array('the_zone' => $zone, 'the_page' => $file)); check_edit_permission('high', $resource_owner); if (is_null($resource_owner)) { check_submit_permission('high'); } $restore_from = $this->find_comcode_page($lang, $file, $zone); // Check no redirects in our way if (addon_installed('redirects_editor')) { $test = $GLOBALS['SITE_DB']->query_value_null_ok('redirects', 'r_to_zone', array('r_from_page' => $file, 'r_from_zone' => $zone)); if (!is_null($test)) { $redirect_url = build_url(array('page' => 'admin_redirects'), get_module_zone('admin_redirects')); attach_message(do_lang_tempcode('BLOCKING_REDIRECT_IN_PLACE', escape_html($redirect_url->evaluate())), 'notice'); } } $title = get_page_title($simple_add || $file == '' ? 'COMCODE_PAGE_ADD' : '_COMCODE_PAGE_EDIT', true, array(escape_html($zone), escape_html($file))); if (!$simple_add && $file != '') { breadcrumb_set_self(do_lang_tempcode('COMCODE_PAGE_EDIT')); } if (!has_actual_page_access(get_member(), $file, $zone)) { access_denied('PAGE_ACCESS'); } // Default file contents $contents = post_param('new', ''); $parsed = NULL; if ($contents == '') { $file_base = strpos($restore_from, 'comcode_custom/') ? get_custom_file_base() : get_file_base(); if (!is_file($file_base . '/' . $restore_from)) { $file_base = get_file_base(); } if (is_file($file_base . '/' . $restore_from)) { $contents = file_get_contents($file_base . '/' . $restore_from, FILE_TEXT); if (is_null(get_param('restore_from', NULL))) { $string_index = $GLOBALS['SITE_DB']->query_value_null_ok('cached_comcode_pages', 'string_index', array('the_zone' => $zone, 'the_page' => $file)); if (!is_null($string_index)) { $parsed = get_translated_tempcode($string_index, NULL, $lang); } } $new = false; } elseif (get_param('title', '') != '') { $page_pretty_title = get_param('title', ''); $contents = '[title]' . $page_pretty_title . "[/title]\n\n" . do_lang('PAGE_DEFAULT_TEXT'); $new = true; } else { $contents = '[title]' . do_lang('PAGE_DEFAULT_TITLE') . "[/title]\n\n"; $new = true; } if ($new && get_option('is_on_comcode_page_children') == '1') { $contents .= chr(10) . chr(10) . '[block]main_comcode_page_children[/block]'; } } else { $new = false; } $map = array('page' => '_SELF', 'type' => '__ed', 'wide' => 1); if ($simple_add) { $map['simple_add'] = '1'; } $post_url = build_url($map, '_SELF'); // Revision history $filesarray = $this->get_comcode_revisions($zone, 'comcode_custom/' . $lang, $file . '.txt'); rsort($filesarray); $i = 0; $revision_history = new ocp_tempcode(); $max = intval(get_option('number_revisions_show')); $last_path = $file_base . '/' . $restore_from; if (is_file($last_path)) { foreach ($filesarray as $iterator => $stuff) { list($filepath, $time) = $stuff; // Find who did the revision $editor = $GLOBALS['SITE_DB']->query_value_null_ok('adminlogs', 'the_user', array('date_and_time' => $time, 'the_type' => 'COMCODE_PAGE_EDIT', 'param_a' => $file)); if (has_specific_permission(get_member(), 'view_revision_history') || $editor == get_member()) { if (is_null($editor)) { $editor = do_lang('UNKNOWN'); } else { $editor = $GLOBALS['FORUM_DRIVER']->get_username($editor); if (is_null($editor)) { $editor = do_lang('UNKNOWN'); } } $old_file = (strpos($filepath, '_custom/') ? get_custom_file_base() : get_file_base()) . '/' . $filepath; $size = filesize($old_file); $date = get_timezoned_date($time); $url = get_custom_base_url() . '/' . $zone . '/' . 'pages/comcode_custom/' . $lang . '/' . $file . '.txt.' . strval($time); $restore_url = build_url(array('page' => '_SELF', 'type' => '_ed', 'page_link' => $zone . ':' . $file, 'restore_from' => zone_black_magic_filterer($zone . ($zone != '' ? '/' : '') . 'pages/comcode_custom/' . $lang . '/' . $file . '.txt.' . strval($time), true)), '_SELF'); require_code('diff'); if (function_exists('diff_simple')) { $rendered_diff = diff_simple($old_file, $last_path); $last_path = $old_file; if ($rendered_diff == '' && $iterator == 0) { continue; } // the version records are often saved on create not replace $revision_history->attach(do_template('REVISION_HISTORY_LINE', array('_GUID' => '57e2c81fd621d1c8d6e283a5a4991001', 'REFERENCE_POINT_EXACT' => true, 'RENDERED_DIFF' => $rendered_diff, 'EDITOR' => $editor, 'DATE' => $date, 'DATE_RAW' => strval($time), 'RESTORE_URL' => $restore_url, 'URL' => $url, 'SIZE' => clean_file_size($size)))); $i++; } if ($i == $max) { break; } } } if (strpos($restore_from, '/comcode_custom/') !== false && zone_black_magic_filterer($zone . '/' . 'pages/comcode/' . $lang . '/' . $file . '.txt', true) != $restore_from && is_file(zone_black_magic_filterer(get_file_base() . '/' . $zone . '/' . 'pages/comcode/' . $lang . '/' . $file . '.txt'))) { $url = get_base_url() . '/' . $zone . '/' . 'pages/comcode/' . $lang . '/' . $file . '.txt'; $size = filesize(zone_black_magic_filterer(get_file_base() . '/' . $zone . '/' . 'pages/comcode/' . $lang . '/' . $file . '.txt')); $restore_url = build_url(array('page' => '_SELF', 'type' => '_ed', 'page_link' => $zone . ':' . $file, 'restore_from' => $zone . ($zone == '' ? '' : '/') . 'pages/comcode/' . $lang . '/' . $file . '.txt'), '_SELF'); require_code('diff'); if (function_exists('diff_simple')) { $rendered_diff = diff_simple(zone_black_magic_filterer(get_file_base() . '/' . $zone . '/' . 'pages/comcode/' . $lang . '/' . $file . '.txt'), $last_path); $revision_history->attach(do_template('REVISION_HISTORY_LINE', array('_GUID' => 'ed0b29f26cf93d4d6e0348a7e75d259d', 'REFERENCE_POINT_EXACT' => true, 'RENDERED_DIFF' => $rendered_diff, 'RESTORE_URL' => $restore_url, 'URL' => $url, 'SIZE' => clean_file_size($size)))); $i++; } } } if (!$revision_history->is_empty() && get_param('restore_from', '') == '') { $revision_history = do_template('REVISION_HISTORY_WRAP', array('_GUID' => '2349ee62cae037ec3cf1766403c92b39', 'CONTENT' => $revision_history)); } elseif (!$revision_history->is_empty()) { $revision_history = do_template('REVISION_RESTORE'); } $meta_keywords = post_param('meta_keywords', ''); $meta_description = post_param('meta_description', ''); if ($meta_keywords == '' && $meta_description == '') { list($meta_keywords, $meta_description) = seo_meta_get_for('comcode_page', $zone . ':' . $file); } $hidden_fields = new ocp_tempcode(); if (addon_installed('page_management') && has_actual_page_access(get_member(), 'adminzone')) { $delete_url = build_url(array('page' => 'admin_sitetree', 'type' => '_delete', 'page__' . $file => 1, 'zone' => $zone), get_module_zone('admin_sitetree')); } else { $delete_url = new ocp_tempcode(); } $fields = new ocp_tempcode(); $fields2 = new ocp_tempcode(); require_code('form_templates'); if (addon_installed('page_management')) { if (has_actual_page_access(get_member(), 'admin_sitetree')) { if ($simple_add) { $hidden_fields->attach(form_input_hidden('title', $file)); } else { $fields->attach(form_input_codename(do_lang_tempcode('CODENAME'), do_lang_tempcode('DESCRIPTION_CODENAME'), 'title', $file, true)); } } } $rows = $GLOBALS['SITE_DB']->query_select('comcode_pages', array('*'), array('the_zone' => $zone, 'the_page' => $file)); if (array_key_exists(0, $rows)) { $validated = $rows[0]['p_validated'] == 1; $parent_page = $rows[0]['p_parent_page']; $show_as_edit = $rows[0]['p_show_as_edit'] == 1; $owner = $rows[0]['p_submitter']; } else { global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'parent_page'; $validated = true; $parent_page = get_param('parent_page', ''); $show_as_edit = false; $owner = get_member(); } $_pages = find_all_pages($zone, 'comcode/' . $lang, 'txt', false, NULL, FIND_ALL_PAGES__NEWEST); $_pages += find_all_pages($zone, 'comcode_custom/' . $lang, 'txt', false, NULL, FIND_ALL_PAGES__NEWEST); $_pages += find_all_pages($zone, 'comcode/' . get_site_default_lang(), 'txt', false, NULL, FIND_ALL_PAGES__NEWEST); $_pages += find_all_pages($zone, 'comcode_custom/' . get_site_default_lang(), 'txt', false, NULL, FIND_ALL_PAGES__NEWEST); ksort($_pages); $pages = form_input_list_entry('', false, do_lang_tempcode('NA_EM')); foreach (array_keys($_pages) as $page) { if (!is_string($page)) { $page = strval($page); } if ($page != $file) { $pages->attach(form_input_list_entry($page, $parent_page == $page)); } } if (!$simple_add) { if (!$validated) { $validated = get_param_integer('validated', 0) == 1; } if (has_specific_permission(get_member(), 'bypass_validation_highrange_content')) { if (addon_installed('unvalidated')) { $fields2->attach(form_input_tick(do_lang_tempcode('VALIDATED'), do_lang_tempcode('DESCRIPTION_VALIDATED'), 'validated', $validated)); } } if (!$new) { if ($delete_url->is_empty()) { $fields2->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE'), 'delete', false)); } } } else { $hidden_fields->attach(form_input_hidden('validated', '1')); } if (get_option('is_on_comcode_page_children') == '1') { $fields2->attach(form_input_list(do_lang_tempcode('PARENT_PAGE'), do_lang_tempcode('DESCRIPTION_PARENT_PAGE'), 'parent_page', $pages, NULL, false, false)); } if (!$simple_add) { $fields2->attach(form_input_tick(do_lang_tempcode('SHOW_AS_EDITED'), do_lang_tempcode('DESCRIPTION_SHOW_AS_EDITED'), 'show_as_edit', $show_as_edit)); if ($GLOBALS['FORUM_DRIVER']->is_super_admin(get_member())) { $fields2->attach(form_input_username(do_lang_tempcode('OWNER'), do_lang_tempcode('DESCRIPTION_OWNER'), 'owner', $GLOBALS['FORUM_DRIVER']->get_username($owner), true)); } $fields2->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('SEO'), 'SECTION_HIDDEN' => true, 'HELP' => get_option('show_docs') == '0' ? NULL : protect_from_escaping(symbol_tempcode('URLISE_LANG', array(do_lang('TUTORIAL_ON_THIS'), brand_base_url() . '/docs' . strval(ocp_version()) . '/pg/tut_seo', 'tut_seo', '1')))))); $fields2->attach(form_input_line_multi(do_lang_tempcode('KEYWORDS'), do_lang_tempcode('DESCRIPTION_META_KEYWORDS'), 'meta_keywords[]', array_map('trim', explode(',', preg_replace('#,+#', ',', $meta_keywords))), 0)); $fields2->attach(form_input_line(do_lang_tempcode('META_DESCRIPTION'), do_lang_tempcode('DESCRIPTION_META_DESCRIPTION'), 'meta_description', $meta_description, false)); } // Awards? if (addon_installed('awards')) { require_code('awards'); $fields2->attach(get_award_fields('comcode_page', $zone . ':' . $file)); } require_code('permissions2'); $fields2->attach(get_page_permissions_for_environment($zone, $file)); $hidden_fields->attach(form_input_hidden('file', $file)); $hidden_fields->attach(form_input_hidden('lang', $lang)); $hidden_fields->attach(form_input_hidden('zone', $zone)); $hidden_fields->attach(form_input_hidden('redirect', get_param('redirect', ''))); $posting_form = get_posting_form(do_lang($simple_add ? 'COMCODE_PAGE_ADD' : 'SAVE'), $contents, $post_url, $hidden_fields, $fields, do_lang_tempcode('COMCODE_PAGE'), '', $fields2, $parsed, NULL, NULL, false); $export_url = build_url(array('page' => '_SELF', 'type' => 'export', 'page_link' => $page_link, 'export' => $restore_from, 'lang' => $lang), '_SELF'); $text = new ocp_tempcode(); if (addon_installed('points')) { $login_url = build_url(array('page' => 'login', 'type' => 'misc', 'redirect' => get_self_url(true, true)), get_module_zone('login')); $_login_url = escape_html($login_url->evaluate()); if (is_guest() && (get_forum_type() != 'ocf' || has_actual_page_access(get_member(), 'join'))) { $text->attach(paragraph(do_lang_tempcode('NOT_LOGGED_IN_NO_CREDIT', $_login_url))); } } list($warning_details, $ping_url) = handle_conflict_resolution($page_link); if (!$simple_add) { breadcrumb_set_parents(array(array('_SELF:_SELF:misc:lang=' . $lang, do_lang_tempcode('CHOOSE')))); } return do_template('COMCODE_EDIT_SCREEN', array('_GUID' => 'ec1d773684757f5bf6f39cf931555bf2', 'NEW' => $new, 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'TEXT' => $text, 'TITLE' => $title, 'DELETE_URL' => $delete_url, 'ZONE' => $zone, 'FILE' => $file, 'EXPORT_URL' => $export_url, 'POSTING_FORM' => $posting_form, 'REVISION_HISTORY' => $revision_history)); }
/** * Get the tempcode for a author/username input line. * * @param mixed A human intelligible name for this input field * @param mixed A description for this input field * @param ID_TEXT The name which this input field is for * @param ?string The default value for this input field (NULL: blank) * @param boolean Whether this is a required input field * @param ?integer The tab index of the field (NULL: not specified) * @return tempcode The input field */ function form_input_author($pretty_name, $description, $name, $default, $required, $tabindex = NULL) { if (!addon_installed('authors')) { return form_input_username($pretty_name, $description, $name, $default, $required, true, $tabindex); } if (is_null($default)) { $default = ''; } $default = filter_form_field_default($name, $default); require_javascript('javascript_ajax'); require_javascript('javascript_ajax_people_lists'); $tabindex = get_form_field_tabindex($tabindex); $_description = new ocp_tempcode(); $_description->attach($description); if (has_js()) { $_description->attach(do_template('FORM_DESCRIP_SEP')); $keep = symbol_tempcode('KEEP'); $extra = do_template('HYPERLINK_POPUP_WINDOW', array('_GUID' => 'fb25dc4777a166c143a1bc32ff0c3239', 'URL' => find_script('authors') . '?field_name=' . urlencode($name) . $keep->evaluate(), 'TITLE' => do_lang_tempcode('AUTHOR'), 'CAPTION' => do_lang_tempcode('BROWSE_SENTENCE'))); $_description->attach($extra); } $_required = $required ? '_required' : ''; $input = do_template('FORM_SCREEN_INPUT_AUTHOR', array('TABINDEX' => strval($tabindex), 'REQUIRED' => $_required, 'NAME' => $name, 'DEFAULT' => $default)); return _form_input($name, $pretty_name, $_description, $input, $required, false, $tabindex); }
/** * Get a form for entering a booking. * * @param ?array Details of the booking (NULL: new). * @param ?MEMBER Who the booking is for (NULL: current member). * @return array Tuple: form fields, hidden fields. */ function get_form_fields($details = NULL, $member_id = NULL) { $hidden = new ocp_tempcode(); $fields = new ocp_tempcode(); if (is_null($details)) { $bookable_id = get_param_integer('bookable_id', NULL); if (is_null($bookable_id)) { // Form to choose bookable @ob_end_clean(); $bookables = $GLOBALS['SITE_DB']->query_select('bookable', array('*'), NULL, 'ORDER BY sort_order'); if (count($bookables) == 0) { inform_exit(do_lang_tempcode('NO_CATEGORIES')); } $bookables_list = new ocp_tempcode(); foreach ($bookables as $bookable) { $bookables_list->attach(form_input_list_entry(strval($bookable['id']), false, get_translated_text($bookable['title']))); } $fields = form_input_list(do_lang_tempcode('BOOKABLE'), '', 'bookable_id', $bookables_list, NULL, true); $post_url = get_self_url(false, false, NULL, false, true); $submit_name = do_lang_tempcode('PROCEED'); $hidden = build_keep_post_fields(); $title = get_page_title('ADD_BOOKING'); $tpl = do_template('FORM_SCREEN', array('TARGET' => '_self', 'GET' => true, 'SKIP_VALIDATION' => true, 'HIDDEN' => $hidden, 'TITLE' => $title, 'TEXT' => '', 'URL' => $post_url, 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name)); $echo = globalise($tpl, NULL, '', true); $echo->evaluate_echo(); exit; } $details = array('bookable_id' => $bookable_id, 'start_day' => get_param_integer('day', intval(date('d'))), 'start_month' => get_param_integer('month', intval(date('m'))), 'start_year' => get_param_integer('year', intval(date('Y'))), 'end_day' => get_param_integer('day', intval(date('d'))), 'end_month' => get_param_integer('month', intval(date('m'))), 'end_year' => get_param_integer('year', intval(date('Y'))), 'quantity' => 1, 'notes' => '', 'supplements' => array()); } if (is_null($member_id)) { $member_id = get_member(); } $_bookable = $GLOBALS['SITE_DB']->query_select('bookable', array('*'), array('id' => $details['bookable_id']), '', 1); if (!array_key_exists(0, $_bookable)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $bookable = $_bookable[0]; $fields->attach(form_input_date(do_lang_tempcode('FROM'), '', 'bookable_' . strval($details['bookable_id']) . '_date_from', false, false, false, array(0, 0, $details['start_month'], $details['start_day'], $details['start_year']), 10, NULL, NULL, NULL, true, get_server_timezone())); if ($bookable['dates_are_ranges'] == 1) { $fields->attach(form_input_date(do_lang_tempcode('TO'), '', 'bookable_' . strval($details['bookable_id']) . '_date_to', false, false, false, array(0, 0, $details['end_month'], $details['end_day'], $details['end_year']), 10, NULL, NULL, NULL, true, get_server_timezone())); } $fields->attach(form_input_integer(do_lang_tempcode('QUANTITY'), '', 'bookable_' . strval($details['bookable_id']) . '_quantity', $details['quantity'], true)); $fields->attach(form_input_text(do_lang_tempcode('NOTES'), '', 'bookable_' . strval($details['bookable_id']) . '_notes', $details['notes'], false)); $member_directory_url = build_url(array('page' => 'members'), get_module_zone('members')); $fields->attach(form_input_username(do_lang_tempcode('BOOKING_FOR'), do_lang_tempcode('DESCRIPTION_BOOKING_FOR', escape_html($member_directory_url->evaluate())), 'username', $GLOBALS['FORUM_DRIVER']->get_username($member_id), true, false)); $supplement_rows = $GLOBALS['SITE_DB']->query_select('bookable_supplement a JOIN ' . get_table_prefix() . 'bookable_supplement_for b ON a.id=b.supplement_id', array('a.*'), array('bookable_id' => $details['bookable_id']), 'ORDER BY sort_order'); foreach ($supplement_rows as $supplement_row) { $quantity = 0; $notes = ''; if (array_key_exists($supplement_row['id'], $details['supplements'])) { $quantity = $details['supplements'][$supplement_row['id']]['quantity']; $notes = $details['supplements'][$supplement_row['id']]['notes']; } $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('SUPPLEMENT', escape_html(get_translated_text($supplement_row['title'])))))); if ($supplement_row['supports_quantities'] == 1) { $fields->attach(form_input_integer(do_lang_tempcode('QUANTITY'), '', 'bookable_' . strval($details['bookable_id']) . '_supplement_' . strval($supplement_row['id']) . '_quantity', $quantity, true)); } else { $fields->attach(form_input_tick(get_translated_text($supplement_row['title']), '', 'bookable_' . strval($details['bookable_id']) . '_supplement_' . strval($supplement_row['id']) . '_quantity', $quantity == 1)); } $fields->attach(form_input_text(do_lang_tempcode('NOTES'), '', 'bookable_' . strval($details['bookable_id']) . '_supplement_' . strval($supplement_row['id']) . '_notes', $notes, false)); } return array($fields, $hidden); }
/** * The UI to search for a member (with regard to viewing their point profile). * * @return tempcode The UI */ function points_search_form() { $GLOBALS['FEED_URL'] = find_script('backend') . '?mode=points&filter='; $title = get_page_title('USER_POINT_FIND'); $post_url = build_url(array('page' => '_SELF', 'type' => '_search'), '_SELF', NULL, false, true); require_code('form_templates'); if (!is_guest()) { $username = $GLOBALS['FORUM_DRIVER']->get_username(get_member()); } else { $username = ''; } $fields = form_input_username(do_lang_tempcode('USERNAME'), '', 'membername', $username, true, false); $submit_name = do_lang_tempcode('SEARCH'); $text = new ocp_tempcode(); $text->attach(paragraph(do_lang_tempcode('POINTS_SEARCH_FORM'))); $text->attach(paragraph(do_lang_tempcode('WILDCARD'))); return do_template('FORM_SCREEN', array('_GUID' => 'e5ab8d5d599093d1a550cb3b3e56d2bf', 'GET' => true, 'SKIP_VALIDATION' => true, 'HIDDEN' => '', 'TITLE' => $title, 'URL' => $post_url, 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name, 'TEXT' => $text)); }
/** * UI to add an invoice. * * @return tempcode The interface. */ function ad() { $title = get_page_title('CREATE_INVOICE'); breadcrumb_set_parents(array(array('_SEARCH:admin_ecommerce:ecom_usage', do_lang_tempcode('ECOMMERCE')), array('_SELF:_SELF:misc', do_lang_tempcode('INVOICES')))); require_code('form_templates'); $to = get_param('to', ''); $products = find_all_products(); $list = new ocp_tempcode(); foreach ($products as $product => $details) { if ($details[0] == PRODUCT_INVOICE) { $text = do_lang_tempcode('CUSTOM_PRODUCT_' . $product); if ($details[1] != '?') { $text->attach(escape_html(' (' . $details[1] . ' ' . get_option('currency') . ')')); } $list->attach(form_input_list_entry($product, false, $text)); } } if ($list->is_empty()) { inform_exit(do_lang_tempcode('NOTHING_TO_INVOICE_FOR')); } $fields = new ocp_tempcode(); $fields->attach(form_input_list(do_lang_tempcode('PRODUCT'), '', 'product', $list)); $fields->attach(form_input_username(do_lang_tempcode('USERNAME'), do_lang_tempcode('DESCRIPTION_INVOICE_FOR'), 'to', $to, true)); $fields->attach(form_input_float(do_lang_tempcode('AMOUNT'), do_lang_tempcode('INVOICE_AMOUNT_TEXT', escape_html(get_option('currency'))), 'amount', NULL, false)); $fields->attach(form_input_line(do_lang_tempcode('INVOICE_SPECIAL'), do_lang_tempcode('DESCRIPTION_INVOICE_SPECIAL'), 'special', '', false)); $fields->attach(form_input_text(do_lang_tempcode('INVOICE_NOTE'), do_lang_tempcode('DESCRIPTION_INVOICE_NOTE'), 'note', '', false)); $post_url = build_url(array('page' => '_SELF', 'type' => '_ad'), '_SELF'); $submit_name = do_lang_tempcode('CREATE_INVOICE'); return do_template('FORM_SCREEN', array('HIDDEN' => '', 'TITLE' => $title, 'URL' => $post_url, 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name, 'TEXT' => do_lang_tempcode('DESCRIPTION_INVOICE_PAGE'))); }
/** * Get tempcode for a adding/editing form. * * @param ?GROUP The usergroup being edited (NULL: adding, not editing) * @param SHORT_TEXT The usergroup name * @param BINARY Whether this is a default usergroup * @param BINARY Whether members of the usergroup are super-administrators * @param BINARY Whether members of the usergroup are super-moderators * @param ID_TEXT The username of the usergroup leader * @param SHORT_TEXT The default title for members with this as their primary usergroup * @param URLPATH The usergroup rank image * @param ?GROUP The target for promotion from this usergroup (NULL: no promotion prospects) * @param ?integer The point threshold upon which promotion occurs (NULL: no promotion prospects) * @param integer The number of seconds between submission flood controls * @param integer The number of seconds between access flood controls * @param integer The number of gift points members of this usergroup get when they start * @param integer The number of gift points members of this usergroup get per-day * @param integer The number of megabytes members can upload per day * @param integer The maximum number of attachments members of this usergroup may have per post * @param integer The maximum avatar width members of this usergroup may have * @param integer The maximum avatar height members of this usergroup may have * @param integer The maximum post length members of this usergroup may have * @param integer The maximum signature length members of this usergroup may have * @param BINARY Whether to lock out unverified IP addresses until e-mail confirmation * @param BINARY Whether the usergroup is presented for joining at joining (implies anyone may be in the usergroup, but only choosable at joining) * @param BINARY Whether the name and membership of the usergroup is hidden * @param ?integer The display order this usergroup will be given, relative to other usergroups. Lower numbered usergroups display before higher numbered usergroups (NULL: last). * @param BINARY Whether the rank image will not be shown for secondary membership * @param BINARY Whether members may join this usergroup without requiring any special permission * @param BINARY Whether this usergroup is a private club. Private clubs may be managed in the CMS zone, and do not have any special permissions - except over their own associated forum. * @return array A pair: The input fields, Hidden fields */ function get_form_fields($id = NULL, $name = '', $is_default = 0, $is_super_admin = 0, $is_super_moderator = 0, $group_leader = '', $title = '', $rank_image = '', $promotion_target = NULL, $promotion_threshold = NULL, $flood_control_submit_secs = 0, $flood_control_access_secs = 0, $gift_points_base = 25, $gift_points_per_day = 1, $max_daily_upload_mb = 5, $max_attachments_per_post = 20, $max_avatar_width = 80, $max_avatar_height = 80, $max_post_length_comcode = 40000, $max_sig_length_comcode = 1000, $enquire_on_new_ips = 0, $is_presented_at_install = 0, $group_is_hidden = 0, $order = NULL, $rank_image_pri_only = 1, $open_membership = 0, $is_private_club = 0) { if (is_null($group_leader)) { $group_leader = ''; } $fields = new ocp_tempcode(); $hidden = new ocp_tempcode(); require_code('form_templates'); $fields->attach(form_input_line(do_lang_tempcode('NAME'), do_lang_tempcode('DESCRIPTION_USERGROUP_TITLE'), 'name', $name, true)); if (addon_installed('ocf_clubs') && !is_null($id)) { $fields->attach(form_input_tick(do_lang_tempcode('IS_PRIVATE_CLUB'), do_lang_tempcode('IS_PRIVATE_CLUB_DESCRIPTION'), 'is_private_club', $is_private_club == 1)); } $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => $title == '' && $group_leader == '', 'TITLE' => do_lang_tempcode('ADVANCED')))); $fields->attach(form_input_line(do_lang_tempcode('TITLE'), do_lang_tempcode('DESCRIPTION_GROUP_TITLE'), 'title', $title, false)); $fields->attach(form_input_username(do_lang_tempcode('GROUP_LEADER'), do_lang_tempcode('DESCRIPTION_GROUP_LEADER'), 'group_leader', $group_leader, false)); $rows = $GLOBALS['FORUM_DB']->query_select('f_groups', array('id', 'g_name', 'g_is_super_admin'), array('g_is_private_club' => 0)); $orderlist = new ocp_tempcode(); $group_count = $GLOBALS['FORUM_DB']->query_value('f_groups', 'COUNT(*)'); $num_groups = $GLOBALS['FORUM_DB']->query_value('f_groups', 'COUNT(*)', $group_count > 200 ? array('g_is_private_club' => 0) : NULL); if (is_null($id)) { $num_groups++; } for ($i = 0; $i < $num_groups; $i++) { $orderlist->attach(form_input_list_entry(strval($i), $i === $order || is_null($id) && $i == $num_groups - 1, integer_format($i + 1))); } $fields->attach(form_input_list(do_lang_tempcode('ORDER'), do_lang_tempcode('USERGROUP_DISPLAY_ORDER_DESCRIPTION'), 'order', $orderlist)); $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('JOINING')))); if (is_null($id) || $id != db_get_first_id()) { $fields->attach(form_input_tick(do_lang_tempcode('IS_PRESENTED_AT_INSTALL'), do_lang_tempcode('DESCRIPTION_IS_PRESENTED_AT_INSTALL'), 'is_presented_at_install', $is_presented_at_install == 1)); $fields->attach(form_input_tick(do_lang_tempcode('DEFAULT_GROUP'), do_lang_tempcode('DESCRIPTION_IS_DEFAULT_GROUP'), 'is_default', $is_default == 1)); } $fields->attach(form_input_tick(do_lang_tempcode('OPEN_MEMBERSHIP'), do_lang_tempcode('OPEN_MEMBERSHIP_DESCRIPTION'), 'open_membership', $open_membership == 1)); $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('RANK')))); if (addon_installed('points')) { $promotion_target_groups = form_input_list_entry('-1', false, do_lang_tempcode('NA_EM')); foreach ($rows as $group) { if ($group['id'] != $id && $group['id'] != db_get_first_id()) { $promotion_target_groups->attach(form_input_list_entry(strval($group['id']), $group['id'] == $promotion_target, get_translated_text($group['g_name'], $GLOBALS['FORUM_DB']))); } } $fields->attach(form_input_list(do_lang_tempcode('PROMOTION_TARGET'), do_lang_tempcode('DESCRIPTION_PROMOTION_TARGET'), 'promotion_target', $promotion_target_groups)); $fields->attach(form_input_integer(do_lang_tempcode('PROMOTION_THRESHOLD'), do_lang_tempcode('DESCRIPTION_PROMOTION_THRESHOLD'), 'promotion_threshold', $promotion_threshold, false)); } if (get_base_url() == get_forum_base_url()) { handle_max_file_size($hidden, 'image'); $fields->attach(form_input_upload(do_lang_tempcode('RANK_IMAGE'), do_lang_tempcode('DESCRIPTION_RANK_IMAGE'), 'file', false, NULL, NULL, true, str_replace(' ', '', get_option('valid_images')))); } require_code('themes2'); $ids = get_all_image_ids_type('ocf_rank_images', false, $GLOBALS['FORUM_DB']); $fields->attach(form_input_picture_choose_specific(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('STOCK')), do_lang_tempcode('DESCRIPTION_ALTERNATE_STOCK'), 'theme_img_code', $ids, NULL, $rank_image, NULL, true, $GLOBALS['FORUM_DB'])); $fields->attach(form_input_tick(do_lang_tempcode('RANK_IMAGE_PRI_ONLY'), do_lang_tempcode('RANK_IMAGE_PRI_ONLY_DESCRIPTION'), 'rank_image_pri_only', $rank_image_pri_only == 1)); $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('BENEFITS')))); $sa_descrip = do_lang_tempcode('DESCRIPTION_IS_SUPER_ADMIN'); if ($is_super_admin == 1) { $sa_descrip->attach(do_lang_tempcode('DESCRIPTION_IS_SUPER_ADMIN_B')); } $fields->attach(form_input_tick(do_lang_tempcode('SUPER_ADMIN'), $sa_descrip, 'is_super_admin', $is_super_admin == 1)); $fields->attach(form_input_tick(do_lang_tempcode('SUPER_MODERATOR'), do_lang_tempcode('DESCRIPTION_IS_SUPER_MODERATOR'), 'is_super_moderator', $is_super_moderator == 1)); if (addon_installed('points')) { $fields->attach(form_input_integer(do_lang_tempcode('GIFT_POINTS_BASE'), do_lang_tempcode('DESCRIPTION_GIFT_POINTS_BASE'), 'gift_points_base', $gift_points_base, true)); $fields->attach(form_input_integer(do_lang_tempcode('GIFT_POINTS_PER_DAY'), do_lang_tempcode('DESCRIPTION_GIFT_POINTS_PER_DAY'), 'gift_points_per_day', $gift_points_per_day, true)); } require_lang('security'); $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('SECURITY')))); $fields->attach(form_input_tick(do_lang_tempcode('HIDDEN_USERGROUP'), do_lang_tempcode('DESCRIPTION_GROUP_HIDDEN'), 'hidden', $group_is_hidden == 1)); $fields->attach(form_input_tick(do_lang_tempcode('ENQUIRE_ON_NEW_IPS'), do_lang_tempcode('DESCRIPTION_ENQUIRE_ON_NEW_IPS'), 'enquire_on_new_ips', $enquire_on_new_ips == 1)); $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('RESTRICTIONS')))); $fields->attach(form_input_integer(do_lang_tempcode('MAX_ATTACHMENTS_PER_POST'), do_lang_tempcode('DESCRIPTION_MAX_ATTACHMENTS_PER_POST'), 'max_attachments_per_post', $max_attachments_per_post, true)); $fields->attach(form_input_integer(do_lang_tempcode('MAX_DAILY_UPLOAD_MB'), do_lang_tempcode('DESCRIPTION_MAX_DAILY_UPLOAD_MB'), 'max_daily_upload_mb', $max_daily_upload_mb, true)); if (addon_installed('ocf_member_avatars')) { $fields->attach(form_input_integer(do_lang_tempcode('MAX_AVATAR_WIDTH'), do_lang_tempcode('DESCRIPTION_MAX_AVATAR_WIDTH'), 'max_avatar_width', $max_avatar_width, true)); $fields->attach(form_input_integer(do_lang_tempcode('MAX_AVATAR_HEIGHT'), do_lang_tempcode('DESCRIPTION_MAX_AVATAR_HEIGHT'), 'max_avatar_height', $max_avatar_height, true)); } $fields->attach(form_input_integer(do_lang_tempcode('MAX_POST_LENGTH_COMCODE'), do_lang_tempcode('DESCRIPTION_MAX_POST_LENGTH_COMCODE'), 'max_post_length_comcode', $max_post_length_comcode, true)); if (addon_installed('ocf_signatures')) { $fields->attach(form_input_integer(do_lang_tempcode('MAX_SIG_LENGTH_COMCODE'), do_lang_tempcode('DESCRIPTION_MAX_SIG_LENGTH_COMCODE'), 'max_sig_length_comcode', $max_sig_length_comcode, true)); } $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('FLOOD_CONTROL')))); $fields->attach(form_input_integer(do_lang_tempcode('FLOOD_CONTROL_ACCESS_SECS'), do_lang_tempcode('DESCRIPTION_FLOOD_CONTROL_ACCESS_SECS'), 'flood_control_access_secs', $flood_control_access_secs, true)); $fields->attach(form_input_integer(do_lang_tempcode('FLOOD_CONTROL_SUBMIT_SECS'), do_lang_tempcode('DESCRIPTION_FLOOD_CONTROL_SUBMIT_SECS'), 'flood_control_submit_secs', $flood_control_submit_secs, true)); $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ACTIONS')))); $copy_members_from_groups = new ocp_tempcode(); foreach ($rows as $row) { if ($row['id'] != db_get_first_id() && $row['id'] != $id) { $copy_members_from_groups->attach(form_input_list_entry(strval($row['id']), false, get_translated_text($row['g_name'], $GLOBALS['FORUM_DB']))); } } $fields->attach(form_input_multi_list(do_lang_tempcode('COPY_MEMBERS_INTO'), do_lang_tempcode('DESCRIPTION_COPY_MEMBERS_INTO'), 'copy_members_into', $copy_members_from_groups)); // Take permissions from $permissions_from_groups = new ocp_tempcode(); $permissions_from_groups = form_input_list_entry('-1', false, do_lang_tempcode('NA_EM')); foreach ($rows as $group) { if ($group['id'] != $id) { $permissions_from_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('DEFAULT_PERMISSIONS_FROM'), do_lang_tempcode(is_null($id) ? 'DESCRIPTION_DEFAULT_PERMISSIONS_FROM_NEW' : 'DESCRIPTION_DEFAULT_PERMISSIONS_FROM'), 'absorb', $permissions_from_groups)); $this->appended_actions_already = true; return array($fields, $hidden); }