/** * 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 create a new topic. * * @param boolean Whether a new Private Topic is being created * @param ?MEMBER The member ID being whispered too (NULL: N/A) * @param string Theme image code * @param ?tempcode Text of screen (NULL: none) * @return tempcode The UI */ function new_topic($personal_topic = false, $member_id = NULL, $img_path = '', $text = NULL) { if (!$personal_topic) { $forum_id = get_param_integer('id'); } else { $forum_id = NULL; } // Breadcrumbs etc if ($personal_topic) { check_specific_permission('use_pt'); breadcrumb_set_parents(array(array('_SEARCH:forumview:pt', do_lang_tempcode('PERSONAL_TOPICS')))); $username = mixed(); $username = $member_id == get_member() ? false : $GLOBALS['FORUM_DRIVER']->get_username($member_id); if (is_null($username)) { warn_exit(do_lang_tempcode('USER_NO_EXIST')); } $staff_help_url = brand_base_url() . '/docs' . strval(ocp_version()) . '/pg/tut_correspondance'; } else { if (!is_null($forum_id)) { if (!has_category_access(get_member(), 'forums', strval($forum_id))) { access_denied('CATEGORY_ACCESS'); } // Can happen if trying to reply to a stated whisper made to you in a forum you don't have access to } $staff_help_url = NULL; $tree = ocf_forum_breadcrumbs($forum_id, NULL, NULL, false); breadcrumb_add_segment($tree, do_lang_tempcode('ADD_TOPIC')); } $hidden_fields = new ocp_tempcode(); $specialisation = new ocp_tempcode(); global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'quote'; // Where to post to $map = array('page' => '_SELF', 'type' => '_add_reply'); $redirect = get_param('redirect', ''); if ($redirect != '') { $map['redirect'] = $redirect; } $post_url = build_url($map, '_SELF'); // Title $specialisation->attach(form_input_line(do_lang_tempcode('TITLE'), '', 'title', post_param('title', ''), true, 1)); // Where it goes to if ($personal_topic) { if ($member_id == get_member()) { $specialisation->attach(form_input_username_multi(do_lang_tempcode('TO'), '', 'to_member_id_', array(), 1, true, 1)); check_specific_permission('use_pt'); } else { $hidden_fields->attach(form_input_hidden('member_id', strval($member_id))); } $threaded = false; } else { $hidden_fields->attach(form_input_hidden('forum_id', strval($forum_id))); $_threaded = $GLOBALS['FORUM_DB']->query_value_null_ok('f_forums', 'f_is_threaded', array('id' => $forum_id)); if (is_null($_threaded)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $threaded = $_threaded == 1; } // Description if (get_option('is_on_topic_descriptions') == '1' && !$threaded) { $specialisation->attach(form_input_line(do_lang_tempcode('DESCRIPTION'), '', 'description', post_param('description', ''), false, 2)); } // Set up some post details $post = post_param('post', ''); $quote = get_param_integer('quote', -1); if ($quote != -1) { $_postdetails = $this->attach_quotes(array($quote)); $post = $_postdetails->evaluate(); } if (!$personal_topic) { list($post_templates, $post2) = $this->post_templates($forum_id); if ($post == '') { $post = $post2; } $specialisation->attach($post_templates); } if (get_option('is_on_topic_emoticons') == '1') { $specialisation->attach($this->choose_topic_emoticon($img_path)); } if (is_guest()) { $specialisation->attach(form_input_line(do_lang_tempcode('GUEST_NAME'), new ocp_tempcode(), 'poster_name_if_guest', do_lang('GUEST'), true)); } /*if (has_specific_permission(get_member(),'decide_comment_type')) Threaded topics not implemented (yet?) { $topic_types=new ocp_tempcode(); $topic_types->attach(form_input_list_entry('0',get_option('threaded_topics_default')=='0',do_lang_tempcode('LINEAR_TOPIC'))); $topic_types->attach(form_input_list_entry('1',get_option('threaded_topics_default')=='1',do_lang_tempcode('THREADED_TOPIC'))); $specialisation->attach(form_input_list(do_lang_tempcode('TOPIC_TYPE'),do_lang_tempcode('DESCRIPTION_TOPIC_TYPE'),'topic_type',do_lang('GUEST'),$topic_types)); } else { $hidden_fields->attach(form_input_hidden('topic_type',get_option('threaded_topics_default'))); }*/ // Various kinds of tick options if (!$personal_topic && ocf_may_moderate_forum($forum_id, get_member())) { $moderation_options = array(array(do_lang_tempcode('OPEN'), 'open', true, do_lang_tempcode('DESCRIPTION_OPEN')), array(do_lang_tempcode('EMPHASISED'), 'is_emphasised', false, do_lang_tempcode('DESCRIPTION_EMPHASISED')), array(do_lang_tempcode('PINNED'), 'pinned', false, do_lang_tempcode('DESCRIPTION_PINNED'))); if (addon_installed('unvalidated')) { $moderation_options[] = array(do_lang_tempcode('VALIDATED'), 'validated', true, do_lang_tempcode('DESCRIPTION_VALIDATED')); } if (get_value('disable_sunk') !== '1') { $moderation_options[] = array(do_lang_tempcode('SUNK'), 'sunk', false, do_lang_tempcode('DESCRIPTION_SUNK')); } if (!$personal_topic) { $moderation_options[] = array(do_lang_tempcode('CASCADING'), 'cascading', false, do_lang_tempcode('DESCRIPTION_CASCADING')); } } else { $hidden_fields->attach(form_input_hidden('open', '1')); $hidden_fields->attach(form_input_hidden('validated', '1')); $moderation_options = array(); } $hidden_fields->attach(form_input_hidden('from_url', get_self_url(true))); $options = array(); if (!is_guest()) { if (get_value('disable_skip_sig') !== '1') { if (addon_installed('ocf_signatures')) { $options[] = array(do_lang_tempcode('SKIP_SIGNATURE'), 'skip_sig', false, do_lang_tempcode('DESCRIPTION_SKIP_SIGNATURE')); } } if (get_option('is_on_anonymous_posts') == '1') { $options[] = array(do_lang_tempcode('_MAKE_ANONYMOUS_POST'), 'anonymous', false, do_lang_tempcode('MAKE_ANONYMOUS_POST_DESCRIPTION')); } } $options[] = array(do_lang_tempcode('ADD_TOPIC_POLL'), 'add_poll', false, do_lang_tempcode('DESCRIPTION_ADD_TOPIC_POLL')); $specialisation2 = new ocp_tempcode(); if (count($options) == 1) { $specialisation->attach(form_input_tick(do_lang_tempcode('ADD_TOPIC_POLL'), do_lang_tempcode('DESCRIPTION_ADD_TOPIC_POLL'), 'add_poll', false)); } else { $specialisation2->attach(form_input_various_ticks($options, '')); } if (count($moderation_options) != 0) { $specialisation2->attach(form_input_various_ticks($moderation_options, '', NULL, do_lang_tempcode('MODERATION_OPTIONS'))); } // Custom fields? require_code('fields'); if (has_tied_catalogue('topic')) { append_form_custom_fields('topic', NULL, $specialisation, $hidden_fields); } if (has_tied_catalogue('post')) { append_form_custom_fields('post', NULL, $specialisation, $hidden_fields); } if (is_null($text)) { $text = new ocp_tempcode(); } // CAPTCHA? if (addon_installed('captcha')) { require_code('captcha'); if (use_captcha()) { $specialisation->attach(form_input_captcha()); $text->attach(paragraph(do_lang_tempcode('FORM_TIME_SECURITY'))); } } // Note about points? 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))); } } // Needs validating? if (!is_null($forum_id) && !has_specific_permission(get_member(), 'bypass_validation_midrange_content', 'topics', array('forums', $forum_id))) { $text->attach(paragraph(do_lang_tempcode('WILL_NEED_VALIDATING'))); } // Awards? if (addon_installed('awards')) { require_code('awards'); $specialisation->attach(get_award_fields('topic')); $specialisation->attach(get_award_fields('post')); } // Render form $posting_form = get_posting_form(do_lang($personal_topic ? 'ADD_PERSONAL_TOPIC' : 'ADD_TOPIC'), $post, $post_url, $hidden_fields, $specialisation, NULL, '', $specialisation2, NULL, $this->_post_javascript() . (function_exists('captcha_ajax_check') ? captcha_ajax_check() : '')); // Work out title to show if (!$personal_topic) { $forum_name = $GLOBALS['FORUM_DB']->query_value_null_ok('f_forums', 'f_name', array('id' => $forum_id)); if (is_null($forum_name)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } } if ($personal_topic) { if ($username === false) { $title = do_lang_tempcode('_ADD_PERSONAL_TOPIC_UNKNOWN'); } else { $title = do_lang_tempcode('_ADD_PERSONAL_TOPIC', escape_html($username)); } } else { $title = do_lang_tempcode('_ADD_TOPIC', escape_html($forum_name)); } $_title = get_page_title($title, false); return do_template('POSTING_SCREEN', array('_GUID' => 'ba5308fe0a8f9f9a24988209423a3a16', 'STAFF_HELP_URL' => $staff_help_url, 'TEXT' => $text, 'TITLE' => $_title, 'POSTING_FORM' => $posting_form)); }
/** * 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 = strval(get_member()); } } $usernames = array(); foreach (explode(chr(10), $actual_value) as $actual_value) { $usernames[] = $GLOBALS['FORUM_DRIVER']->get_username(intval($actual_value)); } return form_input_username_multi($_cf_name, $_cf_description, 'field_' . strval($field['id']), $usernames, $field['cf_required'] == 1 ? 1 : 0, true); }