Exemple #1
0
 /**
  * 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()));
 }
 /**
  * Get tempcode for adding/editing form.
  *
  * @param  SHORT_TEXT	The name of the custom profile field
  * @param  LONG_TEXT		The description of the field
  * @param  LONG_TEXT		The default value of the field
  * @param  BINARY			Whether the field is publicly viewable
  * @param  BINARY			Whether the field may be viewed by the owner
  * @param  BINARY			Whether the owner may set the value of the field
  * @param  BINARY			Whether the field is encrypted
  * @param  ID_TEXT		The type of the field
  * @set    short_text long_text short_trans long_trans integer upload picture url list tick
  * @param  BINARY			Whether the field is required to be filled in
  * @param  BINARY			Whether the field is to be shown on the join form
  * @param  BINARY			Whether the field is shown in posts
  * @param  BINARY			Whether the field is shown in post previews
  * @param  ?integer		The order the field is given relative to the order of the other custom profile fields (NULL: last)
  * @param  LONG_TEXT  	The usergroups that this field is confined to (comma-separated list).
  * @param  BINARY			Whether the field is locked
  * @return array			A pair: the tempcode for the visible fields, and the tempcode for the hidden fields
  */
 function get_form_fields($name = '', $description = '', $default = '', $public_view = 1, $owner_view = 1, $owner_set = 1, $encrypted = 0, $type = 'long_text', $required = 0, $show_on_join_form = 0, $show_in_posts = 0, $show_in_post_previews = 0, $order = NULL, $only_group = '', $locked = 0)
 {
     $fields = new ocp_tempcode();
     $hidden = new ocp_tempcode();
     require_code('form_templates');
     require_code('encryption');
     require_lang('fields');
     if ($locked == 0) {
         $fields->attach(form_input_line(do_lang_tempcode('NAME'), do_lang_tempcode('DESCRIPTION_NAME'), 'name', $name, true));
     } else {
         $hidden->attach(form_input_hidden('name', $name));
     }
     $fields->attach(form_input_line_comcode(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_DESCRIPTION'), 'description', $description, false));
     $fields->attach(form_input_line(do_lang_tempcode('DEFAULT_VALUE'), do_lang_tempcode('DESCRIPTION_DEFAULT_VALUE_CPF'), 'default', $default, false, NULL, 10000));
     $fields->attach(form_input_tick(do_lang_tempcode('OWNER_VIEW'), do_lang_tempcode('DESCRIPTION_OWNER_VIEW'), 'owner_view', $owner_view == 1));
     $fields->attach(form_input_tick(do_lang_tempcode('OWNER_SET'), do_lang_tempcode('DESCRIPTION_OWNER_SET'), 'owner_set', $owner_set == 1));
     $fields->attach(form_input_tick(do_lang_tempcode('PUBLIC_VIEW'), do_lang_tempcode('DESCRIPTION_PUBLIC_VIEW'), 'public_view', $public_view == 1));
     if (is_encryption_enabled() && $name == '') {
         $fields->attach(form_input_tick(do_lang_tempcode('ENCRYPTED'), do_lang_tempcode('DESCRIPTION_ENCRYPTED'), 'encrypted', $encrypted == 1));
     }
     require_code('fields');
     $type_list = nice_get_field_type($type, $name != '');
     $fields->attach(form_input_list(do_lang_tempcode('TYPE'), do_lang_tempcode('DESCRIPTION_FIELD_TYPE'), 'type', $type_list));
     $fields->attach(form_input_tick(do_lang_tempcode('REQUIRED'), do_lang_tempcode('DESCRIPTION_REQUIRED'), 'required', $required == 1));
     $fields->attach(form_input_tick(do_lang_tempcode('SHOW_ON_JOIN_FORM'), do_lang_tempcode('DESCRIPTION_SHOW_ON_JOIN_FORM'), 'show_on_join_form', $show_on_join_form == 1));
     $orderlist = new ocp_tempcode();
     $num_cpfs = $GLOBALS['FORUM_DB']->query_value('f_custom_fields', 'COUNT(*)');
     if ($name == '') {
         $num_cpfs++;
     }
     $selected_one = false;
     for ($i = 0; $i < (is_null($order) ? $num_cpfs : max($num_cpfs, $order)); $i++) {
         $selected = $i === $order || $name == '' && $i == $num_cpfs - 1;
         if ($selected) {
             $selected_one = true;
         }
         $orderlist->attach(form_input_list_entry(strval($i), $selected, integer_format($i + 1)));
     }
     if (!$selected_one) {
         $orderlist->attach(form_input_list_entry(strval($order), true, integer_format($order + 1)));
     }
     $fields->attach(form_input_list(do_lang_tempcode('ORDER'), do_lang_tempcode('DESCRIPTION_FIELD_ORDER'), 'order', $orderlist));
     $fields->attach(form_input_tick(do_lang_tempcode('SHOW_IN_POSTS'), do_lang_tempcode('DESCRIPTION_SHOW_IN_POSTS'), 'show_in_posts', $show_in_posts == 1));
     $fields->attach(form_input_tick(do_lang_tempcode('SHOW_IN_POST_PREVIEWS'), do_lang_tempcode('DESCRIPTION_SHOW_IN_POST_PREVIEWS'), 'show_in_post_previews', $show_in_post_previews == 1));
     $rows = $GLOBALS['FORUM_DB']->query_select('f_groups', array('id', 'g_name', 'g_is_super_admin'), array('g_is_private_club' => 0));
     if ($locked == 0) {
         $groups = new ocp_tempcode();
         //$groups=form_input_list_entry('-1',false,do_lang_tempcode('_ALL'));
         foreach ($rows as $group) {
             if ($group['id'] != db_get_first_id()) {
                 $groups->attach(form_input_list_entry(strval($group['id']), count(array_intersect(array($group['id']), explode(',', $only_group))) != 0, get_translated_text($group['g_name'], $GLOBALS['FORUM_DB'])));
             }
         }
         $fields->attach(form_input_multi_list(do_lang_tempcode('GROUP'), do_lang_tempcode('DESCRIPTION_FIELD_ONLY_GROUP'), 'only_group', $groups));
     } else {
         $hidden->attach(form_input_hidden('only_group', ''));
     }
     return array($fields, $hidden);
 }
 /**
  * The UI for choosing delurk criteria.
  *
  * @return tempcode		The UI
  */
 function delurk()
 {
     $title = get_page_title('DELETE_LURKERS');
     breadcrumb_set_parents(array(array('_SEARCH:admin_ocf_join:menu', do_lang_tempcode('MEMBERS'))));
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/deletelurkers';
     require_code('form_templates');
     require_lang('ocf_lurkers');
     $hidden = new ocp_tempcode();
     $_max_posts = get_value('delurk__max_posts');
     $_max_points = get_value('delurk__max_points');
     $_max_logged_actions = get_value('delurk__max_logged_actions');
     $_min_days_since_login = get_value('delurk__min_days_since_login');
     $_min_days_since_join = get_value('delurk__min_days_since_join');
     $_usergroups = get_value('delurk__usergroups');
     if (is_null($_max_posts)) {
         $max_posts = 2;
     } else {
         $max_posts = intval($_max_posts);
     }
     if (is_null($_max_points)) {
         $max_points = 150;
     } else {
         $max_points = intval($_max_points);
     }
     if (is_null($_max_logged_actions)) {
         $max_logged_actions = 2;
     } else {
         $max_logged_actions = intval($_max_logged_actions);
     }
     if (is_null($_min_days_since_login)) {
         $min_days_since_login = 60;
     } else {
         $min_days_since_login = intval($_min_days_since_login);
     }
     if (is_null($_min_days_since_join)) {
         $min_days_since_join = 90;
     } else {
         $min_days_since_join = intval($_min_days_since_join);
     }
     if (is_null($_usergroups)) {
         $usergroups = array();
     } else {
         $temp = explode(',', $_usergroups);
         $usergroups = array();
         foreach ($temp as $t) {
             $usergroups[] = intval($t);
         }
     }
     $fields = new ocp_tempcode();
     $fields->attach(form_input_integer(do_lang_tempcode('DELURK_MAX_POSTS'), do_lang_tempcode('DELURK_MAX_POSTS_DESCRIPTION'), 'max_posts', $max_posts, true));
     if (addon_installed('points')) {
         $fields->attach(form_input_integer(do_lang_tempcode('DELURK_MAX_POINTS'), do_lang_tempcode('DELURK_MAX_POINTS_DESCRIPTION'), 'max_points', $max_points, true));
     } else {
         $hidden->attach(form_input_hidden('max_points', '0'));
     }
     $fields->attach(form_input_integer(do_lang_tempcode('DELURK_MAX_LOGGED_ACTIONS'), do_lang_tempcode('DELURK_MAX_LOGGED_ACTIONS_DESCRIPTION'), 'max_logged_actions', $max_logged_actions, true));
     $fields->attach(form_input_integer(do_lang_tempcode('DELURK_MIN_DAYS_SINCE_LOGIN'), do_lang_tempcode('DELURK_MIN_DAYS_SINCE_LOGIN_DESCRIPTION'), 'min_days_since_login', $min_days_since_login, true));
     $fields->attach(form_input_integer(do_lang_tempcode('DELURK_MIN_DAYS_SINCE_JOIN'), do_lang_tempcode('DELURK_MIN_DAYS_SINCE_JOIN_DESCRIPTION'), 'min_days_since_join', $min_days_since_join, true));
     $groups = new ocp_tempcode();
     $group_count = $GLOBALS['FORUM_DB']->query_value('f_groups', 'COUNT(*)');
     $rows = $GLOBALS['FORUM_DB']->query_select('f_groups', array('id', 'g_name'), $group_count > 200 ? array('g_is_private_club' => 0) : NULL);
     foreach ($rows as $row) {
         if ($row['id'] != db_get_first_id()) {
             $groups->attach(form_input_list_entry(strval($row['id']), in_array($row['id'], $usergroups), get_translated_text($row['g_name'], $GLOBALS['FORUM_DB'])));
         }
     }
     $fields->attach(form_input_multi_list(do_lang_tempcode('EXCEPT_IN_USERGROUPS'), do_lang_tempcode('DELURK_USERGROUPS_DESCRIPTION'), 'usergroups', $groups));
     $submit_name = do_lang_tempcode('PROCEED');
     $post_url = build_url(array('page' => '_SELF', 'type' => '_delurk'), '_SELF');
     $text = do_lang_tempcode('CHOOSE_DELURK_CRITERIA');
     return do_template('FORM_SCREEN', array('_GUID' => 'f911fc5be2865bdd065abf7c636530d4', 'TITLE' => $title, 'HIDDEN' => $hidden, 'FIELDS' => $fields, 'URL' => $post_url, 'TEXT' => $text, 'SUBMIT_NAME' => $submit_name));
 }
Exemple #4
0
 /**
  * Standard modular render function for profile tabs edit hooks.
  *
  * @param  MEMBER			The ID of the member who is being viewed
  * @param  MEMBER			The ID of the member who is doing the viewing
  * @param  boolean		Whether to leave the tab contents NULL, if tis hook supports it, so that AJAX can load it later
  * @return ?array			A tuple: The tab title, the tab body text (may be blank), the tab fields, extra Javascript (may be blank) the suggested tab order, hidden fields (optional) (NULL: if $leave_to_ajax_if_possible was set)
  */
 function render_tab($member_id_of, $member_id_viewing, $leave_to_ajax_if_possible = false)
 {
     $title = do_lang_tempcode('PRIVACY');
     $order = 60;
     require_lang('ocf_privacy');
     // Actualiser
     $_cpf_fields = post_param('cpf_fields', NULL);
     if ($_cpf_fields !== NULL) {
         $cpf_fields = explode(',', $_cpf_fields);
         foreach ($cpf_fields as $_field_id) {
             $field_id = intval($_field_id);
             if (get_value('simplify_privacy_options') === '1') {
                 $_view = post_param('privacy_' . strval($field_id), NULL);
                 $guests_view = $_view == 'guests' ? 1 : 0;
                 $members_view = $_view == 'guests' || $_view == 'members' ? 1 : 0;
                 $friends_view = $_view == 'guests' || $_view == 'members' || $_view == 'friends' ? 1 : 0;
                 $groups_view = '';
             } else {
                 $_guests_view = post_param('guests_' . strval($field_id), NULL);
                 //$_members_view=post_param('members_'.strval($field_id),NULL);
                 $_friends_view = post_param('friends_' . strval($field_id), NULL);
                 $_groups_view = post_param('groups_' . strval($field_id), NULL);
                 $_members_view = $_groups_view == 'all' ? 1 : 0;
                 $guests_view = !is_null($_guests_view) ? 1 : 0;
                 $members_view = !is_null($_members_view) ? 1 : 0;
                 $friends_view = !is_null($_friends_view) ? 1 : 0;
                 $groups_view = !is_null($_groups_view) ? $_groups_view : '';
             }
             $cpf_permissions = $GLOBALS['FORUM_DB']->query_select('f_member_cpf_perms', array('*'), array('member_id' => $member_id_of, 'field_id' => $field_id));
             //if there are permissions saved already
             if (array_key_exists(0, $cpf_permissions) && $cpf_permissions[0]['field_id'] == $field_id) {
                 $GLOBALS['FORUM_DB']->query_update('f_member_cpf_perms', array('guest_view' => $guests_view, 'member_view' => $members_view, 'friend_view' => $friends_view, 'group_view' => $groups_view), array('member_id' => $member_id_of, 'field_id' => $field_id), '', 1);
             } else {
                 //insert the custom permissions the user chose
                 $GLOBALS['FORUM_DB']->query_insert('f_member_cpf_perms', array('guest_view' => $guests_view, 'member_view' => $members_view, 'friend_view' => $friends_view, 'group_view' => $groups_view, 'member_id' => $member_id_of, 'field_id' => $field_id));
             }
         }
         attach_message(do_lang_tempcode('SUCCESS_SAVE'), 'inform');
     }
     if ($leave_to_ajax_if_possible) {
         return NULL;
     }
     // UI fields
     $member_cpfs = ocf_get_custom_fields_member($member_id_of);
     require_javascript('javascript_multi');
     $fields = new ocp_tempcode();
     require_code('form_templates');
     require_code('themes2');
     $tmp_groups = $GLOBALS['OCF_DRIVER']->get_usergroup_list(true);
     $cpf_ids = array();
     foreach ($member_cpfs as $cpf_id => $cpf) {
         if (preg_replace('#^((\\s)|(<br\\s*/?' . '>)|(&nbsp;))*#', '', $cpf) === '' && count($member_cpfs) > 15) {
             continue;
         }
         // If there are lots of CPFs, and this one seems to have a blank name, skip it (likely corrupt data)
         $cpf_ids[] = $cpf_id;
         // Look up the details for this field
         $cpf_data = $GLOBALS['FORUM_DB']->query_select('f_custom_fields', array('*'), array('id' => $cpf_id));
         if (!array_key_exists(0, $cpf_data)) {
             continue;
         }
         if ($cpf_data[0]['cf_public_view'] == 0) {
             continue;
         }
         // Work out current settings for this field
         $cpf_permissions = $GLOBALS['FORUM_DB']->query_select('f_member_cpf_perms', array('*'), array('member_id' => $member_id_of, 'field_id' => $cpf_id));
         if (!array_key_exists(0, $cpf_permissions)) {
             $view_by_guests = true;
             $view_by_members = true;
             $view_by_friends = true;
             $view_by_groups = array('all');
         } else {
             $view_by_guests = $cpf_permissions[0]['guest_view'] == 1;
             $view_by_members = $cpf_permissions[0]['member_view'] == 1;
             $view_by_friends = $cpf_permissions[0]['friend_view'] == 1;
             $view_by_groups = strlen($cpf_permissions[0]['group_view']) > 0 ? array_map('intval', explode(',', $cpf_permissions[0]['group_view'])) : array();
             if (count($view_by_groups) == count($tmp_groups) || $view_by_members) {
                 $view_by_groups = array('all');
             }
         }
         // Work out the CPF name
         $cpf_title = get_translated_text($cpf_data[0]['cf_name'], $GLOBALS['FORUM_DB']);
         if (substr($cpf_title, 0, 4) == 'ocp_') {
             $_cpf_title = do_lang('SPECIAL_CPF__' . $cpf_title, NULL, NULL, NULL, NULL, false);
             if (!is_null($_cpf_title)) {
                 $cpf_title = $_cpf_title;
             }
         }
         // Show privacy options for this field
         if (get_value('simplify_privacy_options') === '1') {
             $privacy_options = new ocp_tempcode();
             $privacy_options->attach(form_input_list_entry('guests', $view_by_guests, do_lang_tempcode('VISIBLE_TO_GUESTS')));
             $privacy_options->attach(form_input_list_entry('members', $view_by_members && !$view_by_guests, do_lang_tempcode('VISIBLE_TO_MEMBERS')));
             $privacy_options->attach(form_input_list_entry('friends', $view_by_friends && !$view_by_members && !$view_by_guests, do_lang_tempcode('VISIBLE_TO_FRIENDS')));
             $privacy_options->attach(form_input_list_entry('staff', !$view_by_friends && !$view_by_members && !$view_by_guests, do_lang_tempcode('VISIBLE_TO_STAFF')));
             $fields->attach(form_input_list(do_lang_tempcode('WHO_CAN_SEE_YOUR', escape_html($cpf_title)), '', 'privacy_' . strval($cpf_id), $privacy_options));
         } else {
             $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('WHO_CAN_SEE_YOUR', escape_html($cpf_title)))));
             $fields->attach(form_input_tick(do_lang_tempcode('GUESTS'), do_lang_tempcode('DESCRIPTION_VISIBLE_TO_GUESTS'), 'guests_' . strval($cpf_id), $view_by_guests));
             //$fields->attach(form_input_tick(do_lang_tempcode('MEMBERS'),do_lang_tempcode('DESCRIPTION_VISIBLE_TO_MEMBERS'),'members_'.strval($cpf_id),$view_by_members));	Same as 'all' in groups
             $fields->attach(form_input_tick(do_lang_tempcode('FRIENDS'), do_lang_tempcode('DESCRIPTION_VISIBLE_TO_FRIENDS'), 'friends_' . strval($cpf_id), $view_by_friends));
             $groups = new ocp_tempcode();
             $groups->attach(form_input_list_entry('all', $view_by_groups == array('all'), do_lang_tempcode('_ALL')));
             foreach ($tmp_groups as $gr_key => $group) {
                 if ($group == get_option('probation_usergroup')) {
                     continue;
                 }
                 $current_group_view = @in_array($gr_key, $view_by_groups);
                 // @ is due to mixed key types, and ocProducts type strictness
                 $groups->attach(form_input_list_entry(strval($gr_key), $current_group_view, $group));
             }
             $fields->attach(form_input_multi_list(do_lang_tempcode('GROUPS'), do_lang_tempcode('DESCRIPTION_VISIBLE_TO_GROUPS'), 'groups_' . strval($cpf_id), $groups));
         }
     }
     // What is being edited (so we don't need to work it out again in the actualiser)
     $cpfs_hidden = form_input_hidden('cpf_fields', implode(',', $cpf_ids));
     // UI
     $text = do_template('OCF_CPF_PERMISSIONS_TAB', array('_GUID' => 'dbdac6ca3bc752b54d2a24a4c6e69c7c', 'FIELDS' => $fields));
     $javascript = '';
     return array($title, $fields, $text, $javascript, $order, $cpfs_hidden);
 }
Exemple #5
0
 /**
  * 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)
  * @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)
 {
     $default = $field['cf_default'];
     $list = $default == '' ? array() : explode('|', $default);
     $_list = new ocp_tempcode();
     $exploded = explode(chr(10), $actual_value);
     if ($field['cf_required'] == 0 && ($actual_value == '' || is_null($actual_value)) && !in_array('', $list)) {
         $_list->attach(form_input_list_entry('', $actual_value == '' || is_null($actual_value), do_lang_tempcode('NA_EM')));
     }
     foreach ($list as $l) {
         $_list->attach(form_input_list_entry($l, in_array($l, $exploded)));
     }
     return form_input_multi_list($_cf_name, $_cf_description, 'field_' . strval($field['id']), $_list, NULL, 5, $field['cf_required'] == 1);
 }
Exemple #6
0
 /**
  * The UI to choose a template to edit.
  *
  * @return tempcode		The UI
  */
 function edit_templates()
 {
     $title = get_page_title('EDIT_TEMPLATES');
     $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_markup';
     $GLOBALS['HELPER_PANEL_TEXT'] = comcode_lang_string('DOC_TEMPLATES');
     require_javascript('javascript_ajax');
     $theme = get_param('theme', '');
     if ($theme == '') {
         return $this->choose_theme($title);
     }
     //if ((get_file_base()!=get_custom_file_base()) && ($theme=='default')) warn_exit(do_lang_tempcode('SHARED_INSTALL_PROHIBIT'));
     $filesarray = $this->get_template_files_array($theme);
     require_code('form_templates');
     $temp = form_input_list_entry('', false, do_lang_tempcode('NA_EM'));
     $files = '';
     $stub = '';
     foreach ($filesarray as $file) {
         if (!is_null($GLOBALS['CURRENT_SHARE_USER']) && strpos($file, 'BANNER_TYPED') !== false) {
             continue;
         }
         $new_stub = dirname($file);
         if ($stub != $new_stub) {
             $temp = form_input_list_entry('!' . $new_stub, false, $new_stub . ':', true, true);
             $files .= $temp->evaluate();
             // XHTMLXHTML
             $stub = $new_stub;
         }
         $_file = substr($file, strrpos($file, '/') + 1);
         $temp = form_input_list_entry($_file, false, basename($file));
         $files .= $temp->evaluate();
         // XHTMLXHTML
     }
     $fields = new ocp_tempcode();
     $fields->attach(form_input_multi_list(do_lang_tempcode('EXISTING'), '', 'f0file', make_string_tempcode($files), NULL, 35));
     $fields->attach(form_input_line(do_lang_tempcode('SEARCH'), do_lang_tempcode('DESCRIPTION_TEMPLATES_SEARCH'), 'search', '', false));
     $fields->attach(form_input_codename(do_lang_tempcode('NEW'), do_lang_tempcode('NEW_TEMPLATE'), 'f0file2', '', false));
     $post_url = build_url(array('page' => '_SELF', 'type' => '_edit_templates', 'theme' => $theme), '_SELF');
     $edit_form = do_template('FORM', array('_GUID' => 'b26747b4a29281baf83b31167c63582a', 'GET' => true, 'HIDDEN' => '', 'TEXT' => '', 'URL' => $post_url, 'FIELDS' => $fields, 'SUBMIT_NAME' => do_lang_tempcode('CHOOSE'), 'JAVASCRIPT' => 'standardAlternateFields(\'f0file\',\'f0file2\',\'search\');'));
     list($warning_details, $ping_url) = handle_conflict_resolution('');
     // Intentionally blank, because only one person should edit any of all templates at any time (because they depend on each other)
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('MANAGE_THEMES'))));
     breadcrumb_set_self(do_lang_tempcode('CHOOSE'));
     return do_template('TEMPLATE_MANAGE_SCREEN', array('_GUID' => '529cd009f85a84f60b7934b5e969c55b', 'THEME' => $theme, 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'TITLE' => $title, 'EDIT_FORM' => $edit_form));
 }
Exemple #7
0
 /**
  * The UI to import into a gallery.
  *
  * @return tempcode		The UI
  */
 function _gimp()
 {
     $cat = get_param('name', 'root');
     check_specific_permission('mass_import');
     if (substr($cat, 0, 7) != 'member_') {
         $test = $GLOBALS['SITE_DB']->query_value_null_ok('galleries', 'name', array('name' => $cat));
         if (is_null($test)) {
             warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
         }
     }
     $title = get_page_title('GALLERY_IMPORT');
     require_code('form_templates');
     require_lang('trackbacks');
     // To choose to batch import from an attached tar or zip file (zip file only supported if zip module running on php install)
     $post_url = build_url(array('page' => '_SELF', 'type' => '__gimp', 'cat' => $cat, 'uploading' => 1, 'redirect' => get_param('redirect', NULL)), '_SELF');
     $fields = new ocp_tempcode();
     $supported = 'tar';
     if (function_exists('zip_open') || get_option('unzip_cmd') != '') {
         $supported .= ', zip';
     }
     $fields->attach(form_input_upload_multi(do_lang_tempcode('UPLOAD'), do_lang_tempcode('DESCRIPTION_ARCHIVE_MEDIA', escape_html($supported), escape_html(str_replace(',', ', ', get_option('valid_images') . ',' . get_allowed_video_file_types()))), 'file', true, NULL, NULL, true, str_replace(' ', '', get_option('valid_images') . ',' . $supported)));
     $hidden = new ocp_tempcode();
     handle_max_file_size($hidden);
     if (get_option('is_on_gd') == '1') {
         if ($this->has_at_least_one_watermark($cat)) {
             $fields->attach(form_input_tick(do_lang_tempcode('WATERMARK'), do_lang_tempcode('DESCRIPTION_WATERMARK'), 'watermark', true));
         }
     }
     // Feedback
     require_code('feedback2');
     $fields->attach(feedback_fields(true, true, true, false, ''));
     // Max upload limit
     require_code('files2');
     $max = floatval(get_max_file_size()) / floatval(1024 * 1024);
     if ($max < 30.0) {
         $config_url = get_upload_limit_config_url();
         $text = paragraph(do_lang_tempcode(is_null($config_url) ? 'MAXIMUM_UPLOAD' : 'MAXIMUM_UPLOAD_STAFF', escape_html($max > 10.0 ? integer_format(intval($max)) : float_format($max)), escape_html(is_null($config_url) ? '' : $config_url)));
     } else {
         $text = new ocp_tempcode();
     }
     // Show form
     $hidden->attach(form_input_hidden('test', '1'));
     $form = do_template('FORM', array('_GUID' => '05de2bc134ed0b1ab703ac8bfbfabce4', 'TABINDEX' => strval(get_form_field_tabindex()), 'FIELDS' => $fields, 'SUBMIT_NAME' => do_lang_tempcode('BATCH_IMPORT_ARCHIVE_CONTENTS'), 'URL' => $post_url, 'TEXT' => $text, 'HIDDEN' => $hidden));
     // Orphaned upload form
     // To choose to batch import what already exists in gallery directory, but is orphaned
     $orphaned_content = new ocp_tempcode();
     if ($GLOBALS['FORUM_DRIVER']->is_staff(get_member()) && $GLOBALS['SITE_DB']->query_value('images', 'COUNT(*)') + $GLOBALS['SITE_DB']->query_value('videos', 'COUNT(*)') < 4000) {
         require_code('images');
         $there = array();
         $_dir = opendir(get_custom_file_base() . '/uploads/galleries/');
         while (false !== ($file = readdir($_dir))) {
             if ($file != 'index.html' && !is_dir(get_custom_file_base() . '/uploads/galleries/' . $file) && (is_image($file) || is_video($file))) {
                 $there[$file] = filemtime(get_custom_file_base() . '/uploads/galleries/' . $file);
             }
         }
         closedir($_dir);
         $_dir = @opendir(get_custom_file_base() . '/uploads/galleries/' . filter_naughty($cat));
         if ($_dir !== false) {
             while (false !== ($file = readdir($_dir))) {
                 if ($file != 'index.html' && !is_dir(get_custom_file_base() . '/uploads/galleries/' . $cat . '/' . $file) && (is_image($file) || is_video($file))) {
                     $there[$cat . '/' . $file] = filemtime(get_custom_file_base() . '/uploads/galleries/' . $cat . '/' . $file);
                 }
             }
             closedir($_dir);
         }
         if (count($there) != 0) {
             asort($there);
             $test1 = collapse_1d_complexity('url', $GLOBALS['SITE_DB']->query_select('images', array('url')));
             $test2 = collapse_1d_complexity('url', $GLOBALS['SITE_DB']->query_select('videos', array('url')));
             arsort($there);
             $temp_keys = array_keys($there);
             $last_time = $there[$temp_keys[0]];
             foreach ($there as $file => $time) {
                 if (!in_array('uploads/galleries/' . str_replace('%2F', '/', rawurlencode($file)), $test1) && !in_array('uploads/galleries/' . str_replace('%2F', '/', rawurlencode($file)), $test2)) {
                     $orphaned_content->attach(form_input_list_entry($file, $time >= $last_time - 60 * 60 * 3 || strpos($file, '/') !== false, $file));
                 }
             }
         }
         $add_url = build_url(array('page' => '_SELF', 'type' => 'ss'), '_SELF');
         if (!$orphaned_content->is_empty()) {
             $fields_2 = new ocp_tempcode();
             $hidden_2 = new ocp_tempcode();
             if (get_param_integer('keep_de_orphan', 0) == 1) {
                 $cats = nice_get_gallery_tree($cat, NULL, false, false, false, false, NULL, true);
                 $fields_2->attach(form_input_list(do_lang_tempcode('GALLERY'), '', 'cat', $cats));
             } else {
                 $hidden_2->attach(form_input_hidden('cat', $cat));
             }
             $fields_2->attach(form_input_multi_list(do_lang_tempcode('ENTRIES'), '', 'files', $orphaned_content));
             if ($this->has_at_least_one_watermark($cat)) {
                 $fields_2->attach(form_input_various_ticks(array(array(do_lang_tempcode('WATERMARK'), 'watermark', true, ''), array(do_lang_tempcode('ALLOW_RATING'), 'allow_rating', true, ''), array(do_lang_tempcode('ALLOW_COMMENTS'), 'allow_comments', true, ''), array(do_lang_tempcode('ALLOW_REVIEWS'), 'allow_reviews', false, ''), array(do_lang_tempcode('ALLOW_TRACKBACKS'), 'allow_trackbacks', true, '')), '', NULL, do_lang_tempcode('OPTIONS')));
             }
             $radios = new ocp_tempcode();
             $radios->attach(form_input_radio_entry('type', 'sa', true, do_lang_tempcode('ADD_GALLERY_SELECTION')));
             $radios->attach(form_input_radio_entry('type', 'sd', false, do_lang_tempcode('DELETE_GALLERY_SELECTION')));
             $fields_2->attach(form_input_radio(do_lang_tempcode('ACTION'), '', 'type', $radios, true));
             // Feedback
             require_code('feedback2');
             $fields_2->attach(feedback_fields(true, true, true, false, ''));
             $form2 = do_template('FORM', array('SECONDARY_FORM' => true, 'TABINDEX' => strval(get_form_field_tabindex()), 'FIELDS' => $fields_2, 'SUBMIT_NAME' => do_lang_tempcode('PROCEED'), 'URL' => $add_url, 'TEXT' => '', 'HIDDEN' => $hidden_2));
         } else {
             $form2 = new ocp_tempcode();
         }
     } else {
         $form2 = new ocp_tempcode();
     }
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('MANAGE_GALLERIES')), array('_SELF:_SELF:gimp', do_lang_tempcode('GALLERY'))));
     breadcrumb_set_self(do_lang_tempcode('UPLOAD'));
     return do_template('GALLERY_IMPORT_SCREEN', array('_GUID' => '607c819ff751268294e5e590a0d41533', 'TITLE' => $title, 'FORM2' => $form2, 'FORM' => $form));
 }
Exemple #8
0
/**
 * 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;
}
 /**
  * Interface to import/export.
  *
  * @return tempcode	The interface.
  */
 function ui()
 {
     $title = get_page_title('XML_DATA_MANAGEMENT');
     require_code('form_templates');
     $import_url = build_url(array('page' => '_SELF', 'type' => '_import'), '_SELF');
     $import_fields = new ocp_tempcode();
     $import_fields->attach(form_input_huge(do_lang_tempcode('XML_DATA'), '', 'xml', '', true));
     $import_form = do_template('FORM', array('TABINDEX' => strval(get_form_field_tabindex()), 'URL' => $import_url, 'HIDDEN' => '', 'TEXT' => do_lang_tempcode('XML_IMPORT_TEXT'), 'FIELDS' => $import_fields, 'SUBMIT_NAME' => do_lang_tempcode('IMPORT')));
     $all_tables = find_all_xml_tables();
     $export_url = build_url(array('page' => '_SELF', 'type' => '_export'), '_SELF');
     $export_fields = new ocp_tempcode();
     $nice_tables = new ocp_tempcode();
     foreach ($all_tables as $table) {
         $nice_tables->attach(form_input_list_entry($table));
     }
     $export_fields->attach(form_input_multi_list(do_lang_tempcode('TABLES'), do_lang_tempcode('DESCRIPTION_TABLES'), 'tables', $nice_tables, NULL, 15));
     $export_fields->attach(form_input_tick(do_lang_tempcode('EXPORT_WITH_COMCODE_XML'), do_lang_tempcode('DESCRIPTION_EXPORT_WITH_COMCODE_XML'), 'comcode_xml', false));
     $export_form = do_template('FORM', array('TABINDEX' => strval(get_form_field_tabindex()), 'URL' => $export_url, 'HIDDEN' => '', 'TEXT' => do_lang_tempcode('XML_EXPORT_TEXT'), 'FIELDS' => $export_fields, 'SUBMIT_NAME' => do_lang_tempcode('EXPORT')));
     return do_template('XML_STORAGE_SCREEN', array('TITLE' => $title, 'IMPORT_FORM' => $import_form, 'EXPORT_FORM' => $export_form));
 }
Exemple #10
0
/**
 * Shows an HTML page for making block Comcode.
 */
function block_helper_script()
{
    require_lang('comcode');
    require_lang('blocks');
    require_code('zones2');
    require_code('zones3');
    check_specific_permission('comcode_dangerous');
    $title = get_page_title('BLOCK_HELPER');
    require_code('form_templates');
    require_all_lang();
    $type_wanted = get_param('block_type', 'main');
    $type = get_param('type', 'step1');
    $content = new ocp_tempcode();
    if ($type == 'step1') {
        // Find what addons all our block files are in, and icons if possible
        $hooks = find_all_hooks('systems', 'addon_registry');
        $hook_keys = array_keys($hooks);
        $hook_files = array();
        foreach ($hook_keys as $hook) {
            $path = get_file_base() . '/sources_custom/hooks/systems/addon_registry/' . filter_naughty_harsh($hook) . '.php';
            if (!file_exists($path)) {
                $path = get_file_base() . '/sources/hooks/systems/addon_registry/' . filter_naughty_harsh($hook) . '.php';
            }
            $hook_files[$hook] = file_get_contents($path);
        }
        unset($hook_keys);
        $addon_icons = array();
        $addons_blocks = array();
        foreach ($hook_files as $addon_name => $hook_file) {
            $matches = array();
            if (preg_match('#function get_file_list\\(\\)\\s*\\{([^\\}]*)\\}#', $hook_file, $matches) != 0) {
                if (!defined('HIPHOP_PHP')) {
                    $addon_files = eval($matches[1]);
                } else {
                    require_code('hooks/systems/addon_registry/' . $addon_name);
                    $hook_ob = object_factory('Hook_addon_registry_' . $addon_name);
                    $addon_files = $hook_ob->get_file_list();
                }
                foreach ($addon_files as $file) {
                    if (substr($file, 0, 31) == 'themes/default/images/bigicons/' && !array_key_exists($addon_name, $addon_icons)) {
                        $addon_icons[$addon_name] = find_theme_image('bigicons/' . basename($file, '.png'), false, true);
                    }
                    if (substr($file, 0, 21) == 'sources_custom/blocks/' || substr($file, 0, 15) == 'sources/blocks/') {
                        if ($addon_name == 'staff_messaging') {
                            $addon_name = 'core_feedback_features';
                        }
                        $addons_blocks[basename($file, '.php')] = $addon_name;
                    }
                }
            }
        }
        // Find where blocks have been used
        $block_usage = array();
        $zones = find_all_zones(false, true);
        foreach ($zones as $_zone) {
            $zone = $_zone[0];
            $pages = find_all_pages_wrap($zone, true);
            foreach ($pages 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);
                    $num_matches = preg_match_all('#\\[block[^\\]]*\\](.*)\\[/block\\]#U', $contents, $matches);
                    for ($i = 0; $i < $num_matches; $i++) {
                        $block_used = $matches[1][$i];
                        if (!array_key_exists($block_used, $block_usage)) {
                            $block_usage[$block_used] = array();
                        }
                        $block_usage[$block_used][] = $zone . ':' . basename($filename, '.txt');
                    }
                }
            }
        }
        // Show block list
        $links = new ocp_tempcode();
        $blocks = find_all_blocks();
        $dh = @opendir(get_file_base() . '/sources_custom/miniblocks');
        if ($dh !== false) {
            while (($file = readdir($dh)) !== false) {
                if (substr($file, -4) == '.php' && preg_match('#^[\\w\\-]*$#', substr($file, 0, strlen($file) - 4)) != 0) {
                    $blocks[substr($file, 0, strlen($file) - 4)] = 'sources_custom';
                }
            }
            closedir($dh);
        }
        $block_types = array();
        $block_types_icon = array();
        $keep = symbol_tempcode('KEEP');
        foreach (array_keys($blocks) as $block) {
            if (array_key_exists($block, $addons_blocks)) {
                $addon_name = $addons_blocks[$block];
                $addon_icon = array_key_exists($addon_name, $addon_icons) ? $addon_icons[$addon_name] : NULL;
                $addon_name = preg_replace('#^core\\_#', '', $addon_name);
            } else {
                $addon_name = NULL;
                $addon_icon = NULL;
            }
            $this_block_type = is_null($addon_name) || strpos($addon_name, 'block') !== false || $addon_name == 'core' ? substr($block, 0, strpos($block, '_') === false ? strlen($block) : strpos($block, '_')) : $addon_name;
            if (!array_key_exists($this_block_type, $block_types)) {
                $block_types[$this_block_type] = new ocp_tempcode();
            }
            if (!is_null($addon_icon)) {
                $block_types_icon[$this_block_type] = $addon_icon;
            }
            $block_description = do_lang('BLOCK_' . $block . '_DESCRIPTION', NULL, NULL, NULL, NULL, false);
            $block_use = do_lang('BLOCK_' . $block . '_USE', NULL, NULL, NULL, NULL, false);
            if (is_null($block_description)) {
                $block_description = '';
            }
            if (is_null($block_use)) {
                $block_use = '';
            }
            $descriptiont = $block_description == '' && $block_use == '' ? new ocp_tempcode() : do_lang_tempcode('BLOCK_HELPER_1X', $block_description, $block_use);
            $url = find_script('block_helper') . '?type=step2&block=' . urlencode($block) . '&field_name=' . get_param('field_name') . $keep->evaluate();
            if (get_param('utheme', '') != '') {
                $url .= '&utheme=' . get_param('utheme');
            }
            $url .= '&block_type=' . $type_wanted;
            $link_caption = do_lang_tempcode('NICE_BLOCK_NAME', escape_html(cleanup_block_name($block)), $block);
            $usage = array_key_exists($block, $block_usage) ? $block_usage[$block] : array();
            $block_types[$this_block_type]->attach(do_template('BLOCK_HELPER_BLOCK_CHOICE', array('USAGE' => $usage, 'DESCRIPTION' => $descriptiont, 'URL' => $url, 'LINK_CAPTION' => $link_caption)));
        }
        /*if (array_key_exists($type_wanted,$block_types)) We don't do this now, as we structure by addon name
        		{
        			$x=$block_types[$type_wanted];
        			unset($block_types[$type_wanted]);
        			$block_types=array_merge(array($type_wanted=>$x),$block_types);
        		}*/
        ksort($block_types);
        // We sort now instead
        $move_after = $block_types['adminzone_frontpage'];
        unset($block_types['adminzone_frontpage']);
        $block_types['adminzone_frontpage'] = $move_after;
        foreach ($block_types as $block_type => $_links) {
            switch ($block_type) {
                case 'side':
                case 'main':
                case 'bottom':
                    $type_title = do_lang_tempcode('BLOCKS_TYPE_' . $block_type);
                    $img = NULL;
                    break;
                default:
                    $type_title = do_lang_tempcode('BLOCKS_TYPE_ADDON', escape_html(cleanup_block_name($block_type)));
                    $img = array_key_exists($block_type, $block_types_icon) ? $block_types_icon[$block_type] : NULL;
                    break;
            }
            $links->attach(do_template('BLOCK_HELPER_BLOCK_GROUP', array('IMG' => $img, 'TITLE' => $type_title, 'LINKS' => $_links)));
        }
        $content = do_template('BLOCK_HELPER_START', array('_GUID' => 'd2d6837cdd8b19d80ea95ab9f5d09c9a', 'GET' => true, 'TITLE' => $title, 'LINKS' => $links));
    } elseif ($type == 'step2') {
        require_code('comcode_text');
        $defaults = parse_single_comcode_tag(get_param('parse_defaults', '', true), 'block');
        $block = trim(get_param('block'));
        $title = get_page_title('_BLOCK_HELPER', true, array(escape_html($block)));
        $fields = new ocp_tempcode();
        $parameters = get_block_parameters($block);
        $parameters[] = 'failsafe';
        $parameters[] = 'cache';
        $parameters[] = 'quick_cache';
        if (!isset($defaults['cache'])) {
            $defaults['cache'] = block_cache_default($block);
        }
        if (is_null($parameters)) {
            $parameters = array();
        }
        $advanced_ind = do_lang('BLOCK_IND_ADVANCED');
        $param_classes = array('normal' => array(), 'advanced' => array());
        foreach ($parameters as $parameter) {
            $param_class = 'normal';
            if ($parameter == 'cache' || $parameter == 'quick_cache' || $parameter == 'failsafe' || strpos(do_lang('BLOCK_' . $block . '_PARAM_' . $parameter), $advanced_ind) !== false) {
                $param_class = 'advanced';
            }
            $param_classes[$param_class][] = $parameter;
        }
        foreach ($param_classes as $param_class => $parameters) {
            if (count($parameters) == 0) {
                if ($param_class == 'normal') {
                    $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => false, 'TITLE' => do_lang_tempcode('PARAMETERS'), 'HELP' => protect_from_escaping(paragraph(do_lang_tempcode('BLOCK_HELPER_NO_PARAMETERS'), '', 'nothing_here')))));
                }
                continue;
            }
            if ($param_class == 'advanced') {
                $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('ADVANCED'))));
            }
            foreach ($parameters as $parameter) {
                $matches = array();
                switch ($parameter) {
                    case 'quick_cache':
                    case 'cache':
                    case 'failsafe':
                        $description = do_lang('BLOCK_PARAM_' . $parameter);
                        break;
                    default:
                        $description = do_lang('BLOCK_' . $block . '_PARAM_' . $parameter);
                        break;
                }
                $description = str_replace(do_lang('BLOCK_IND_STRIPPABLE_1'), '', $description);
                $description = trim(str_replace(do_lang('BLOCK_IND_ADVANCED'), '', $description));
                // Work out default value for field
                $default = '';
                if (preg_match('#' . do_lang('BLOCK_IND_DEFAULT') . ': ["\']([^"]*)["\']#Ui', $description, $matches) != 0) {
                    $default = $matches[1];
                    $has_default = true;
                    $description = preg_replace('#\\s*' . do_lang('BLOCK_IND_DEFAULT') . ': ["\']([^"]*)["\'](?-U)\\.?(?U)#Ui', '', $description);
                } else {
                    $has_default = false;
                }
                if (isset($defaults[$parameter])) {
                    $default = $defaults[$parameter];
                    $has_default = true;
                }
                // Show field
                if ($block . ':' . $parameter == 'side_stored_menu:type') {
                    $matches = array();
                    $dh = opendir(get_file_base() . '/themes/default/templates/');
                    $options = array();
                    while (($file = readdir($dh)) !== false) {
                        if (preg_match('^MENU\\_([a-z]+)\\.tpl$^', $file, $matches) != 0) {
                            $options[] = $matches[1];
                        }
                    }
                    closedir($dh);
                    $dh = opendir(get_custom_file_base() . '/themes/default/templates_custom/');
                    while (($file = readdir($dh)) !== false) {
                        if (preg_match('^MENU\\_([a-z]+)\\.tpl$^', $file, $matches) != 0 && !file_exists(get_file_base() . '/themes/default/templates/' . $file)) {
                            $options[] = $matches[1];
                        }
                    }
                    closedir($dh);
                    sort($options);
                    $list = new ocp_tempcode();
                    foreach ($options as $option) {
                        $list->attach(form_input_list_entry($option, $has_default && $option == $default));
                    }
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($block . ':' . $parameter == 'side_stored_menu:param') {
                    $list = new ocp_tempcode();
                    $rows = $GLOBALS['SITE_DB']->query_select('menu_items', array('DISTINCT i_menu'), NULL, 'ORDER BY i_menu');
                    foreach ($rows as $row) {
                        $list->attach(form_input_list_entry($row['i_menu'], $has_default && $row['i_menu'] == $default));
                    }
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($block . ':' . $parameter == 'side_shoutbox:param') {
                    $list = new ocp_tempcode();
                    $rows = $GLOBALS['SITE_DB']->query_select('chat_rooms', array('id', 'room_name'), array('is_im' => 0), '', 100);
                    foreach ($rows as $row) {
                        $list->attach(form_input_list_entry(strval($row['id']), $has_default && strval($row['id']) == $default, $row['room_name']));
                    }
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($block . ':' . $parameter == 'main_poll:param') {
                    $list = new ocp_tempcode();
                    $rows = $GLOBALS['SITE_DB']->query_select('poll', array('id', 'question'), NULL, 'ORDER BY id DESC', 100);
                    $list->attach(form_input_list_entry('', false, do_lang('NA')));
                    foreach ($rows as $row) {
                        $list->attach(form_input_list_entry(strval($row['id']), $has_default && strval($row['id']) == $default, get_translated_text($row['question'])));
                    }
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($block . ':' . $parameter == 'main_awards:param') {
                    $list = new ocp_tempcode();
                    $rows = $GLOBALS['SITE_DB']->query_select('award_types', array('id', 'a_title'));
                    foreach ($rows as $row) {
                        $list->attach(form_input_list_entry(strval($row['id']), $has_default && strval($row['id']) == $default, get_translated_text($row['a_title'])));
                    }
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($parameter == 'zone' || $parameter == 'param' && $block == 'main_as_zone_access') {
                    $list = new ocp_tempcode();
                    $list->attach(form_input_list_entry('_SEARCH', $default == ''));
                    $list->attach(nice_get_zones($default == '' ? NULL : $default));
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif (($parameter == 'forum' || $parameter == 'param' && in_array($block, array('main_forum_topics'))) && get_forum_type() == 'ocf') {
                    require_code('ocf_forums');
                    require_code('ocf_forums2');
                    if (!addon_installed('ocf_forum')) {
                        warn_exit(do_lang_tempcode('NO_FORUM_INSTALLED'));
                    }
                    $list = ocf_get_forum_tree_secure(NULL, NULL, true, explode(',', $default));
                    $fields->attach(form_input_multi_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list));
                } elseif ($parameter == 'param' && in_array($block, array('side_root_galleries', 'main_gallery_tease', 'main_gallery_embed', 'main_image_fader'))) {
                    require_code('galleries');
                    $list = nice_get_gallery_tree($default);
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($parameter == 'param' && in_array($block, array('main_download_category'))) {
                    require_code('downloads');
                    $list = nice_get_download_category_tree($default == '' ? NULL : intval($default));
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($parameter == 'param' && in_array($block, array('main_contact_catalogues')) || $parameter == 'catalogue' && in_array($block, array('main_recent_cc_entries'))) {
                    require_code('catalogues');
                    $list = nice_get_catalogues($default, false);
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($parameter == 'param' && in_array($block, array('main_cc_embed')) && $GLOBALS['SITE_DB']->query_value('catalogue_categories', 'COUNT(*)') < 500) {
                    $list = new ocp_tempcode();
                    $categories = $GLOBALS['SITE_DB']->query_select('catalogue_categories', array('id', 'cc_title', 'c_name'), NULL, 'ORDER BY c_name,id');
                    $last_cat = mixed();
                    foreach ($categories as $cat) {
                        if (is_null($last_cat) || $cat['c_name'] != $last_cat) {
                            $list->attach(form_input_list_entry($cat['c_name'], $has_default && $cat['c_name'] == $default, $cat['c_name'], false, true));
                            $last_cat = $cat['c_name'];
                        }
                        $list->attach(form_input_list_entry(strval($cat['id']), $has_default && strval($cat['id']) == $default, get_translated_text($cat['cc_title'])));
                    }
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($parameter == 'param' && in_array($block, array('main_banner_wave', 'main_topsites'))) {
                    require_code('banners');
                    $list = nice_get_banner_types($default);
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($parameter == 'param' && in_array($block, array('main_newsletter_signup'))) {
                    $list = new ocp_tempcode();
                    $rows = $GLOBALS['SITE_DB']->query_select('newsletters', array('id', 'title'));
                    foreach ($rows as $newsletter) {
                        $list->attach(form_input_list_entry(strval($newsletter['id']), $has_default && strval($newsletter['id']) == $default, get_translated_text($newsletter['title'])));
                    }
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif ($parameter == 'filter' && in_array($block, array('bottom_news', 'main_news', 'side_news', 'side_news_archive'))) {
                    require_code('news');
                    $list = nice_get_news_categories($default == '' ? -1 : intval($default));
                    $fields->attach(form_input_multi_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list));
                } elseif ($parameter == 'font') {
                    $fonts = array();
                    $dh = opendir(get_file_base() . '/data/fonts');
                    while ($f = readdir($dh)) {
                        if (substr($f, -4) == '.ttf') {
                            $fonts[] = substr($f, 0, strlen($f) - 4);
                        }
                    }
                    closedir($dh);
                    $dh = opendir(get_custom_file_base() . '/data_custom/fonts');
                    while ($f = readdir($dh)) {
                        if (substr($f, -4) == '.ttf') {
                            $fonts[] = substr($f, 0, strlen($f) - 4);
                        }
                    }
                    closedir($dh);
                    $fonts = array_unique($fonts);
                    sort($fonts);
                    $list = new ocp_tempcode();
                    foreach ($fonts as $font) {
                        $list->attach(form_input_list_entry($font, $font == $default));
                    }
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif (preg_match('#' . do_lang('BLOCK_IND_EITHER') . ' (.+)#i', $description, $matches) != 0) {
                    $description = preg_replace('# \\(' . do_lang('BLOCK_IND_EITHER') . '.*\\)#U', '', $description);
                    $list = new ocp_tempcode();
                    $matches2 = array();
                    $num_matches = preg_match_all('#\'([^\']*)\'="([^"]*)"#', $matches[1], $matches2);
                    if ($num_matches != 0) {
                        for ($i = 0; $i < $num_matches; $i++) {
                            $list->attach(form_input_list_entry($matches2[1][$i], $matches2[1][$i] == $default, $matches2[2][$i]));
                        }
                    } else {
                        $num_matches = preg_match_all('#\'([^\']*)\'#', $matches[1], $matches2);
                        for ($i = 0; $i < $num_matches; $i++) {
                            $list->attach(form_input_list_entry($matches2[1][$i], $matches2[1][$i] == $default));
                        }
                    }
                    $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                } elseif (preg_match('#\\(' . do_lang('BLOCK_IND_HOOKTYPE') . ': \'([^\'/]*)/([^\'/]*)\'\\)#i', $description, $matches) != 0) {
                    $description = preg_replace('#\\s*\\(' . do_lang('BLOCK_IND_HOOKTYPE') . ': \'([^\'/]*)/([^\'/]*)\'\\)#i', '', $description);
                    $list = new ocp_tempcode();
                    $hooks = find_all_hooks($matches[1], $matches[2]);
                    ksort($hooks);
                    if ($default == '' && $has_default) {
                        $list->attach(form_input_list_entry('', true));
                    }
                    foreach (array_keys($hooks) as $hook) {
                        if ($block == 'side_tag_cloud') {
                            if (substr($hook, -1) == 'y') {
                                $hook .= ',' . substr($hook, 0, strlen($hook) - 1) . 'ies';
                            } elseif (substr($hook, -1) != 's' && $hook != 'quiz') {
                                $hook .= ',' . $hook . 's';
                            }
                        }
                        $list->attach(form_input_list_entry($hook, $hook == $default));
                    }
                    if ($block == 'main_search' && $parameter == 'limit_to' || $block == 'side_tag_cloud') {
                        $fields->attach(form_input_multi_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, 0));
                    } else {
                        $fields->attach(form_input_list(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $list, NULL, false, false));
                    }
                } elseif (($default == '0' || $default == '1' || strpos($description, '\'0\'') !== false || strpos($description, '\'1\'') !== false) && do_lang('BLOCK_IND_WHETHER') != '' && strpos(strtolower($description), do_lang('BLOCK_IND_WHETHER')) !== false) {
                    $fields->attach(form_input_tick(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $default == '1'));
                } elseif (do_lang('BLOCK_IND_NUMERIC') != '' && strpos($description, do_lang('BLOCK_IND_NUMERIC')) !== false) {
                    $fields->attach(form_input_integer(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $default == '' ? NULL : intval($default), false));
                } else {
                    $fields->attach(form_input_line(ucwords(str_replace('_', ' ', $parameter)), escape_html($description), $parameter, $default, false));
                }
            }
        }
        $keep = symbol_tempcode('KEEP');
        $post_url = find_script('block_helper') . '?type=step3&field_name=' . get_param('field_name') . $keep->evaluate();
        if (get_param('utheme', '') != '') {
            $post_url .= '&utheme=' . get_param('utheme');
        }
        $post_url .= '&block_type=' . $type_wanted;
        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');
        }
        $block_description = do_lang('BLOCK_' . $block . '_DESCRIPTION', NULL, NULL, NULL, NULL, false);
        if (is_null($block_description)) {
            $block_description = '';
        }
        $block_use = do_lang('BLOCK_' . $block . '_USE', NULL, NULL, NULL, NULL, false);
        if (is_null($block_use)) {
            $block_use = '';
        }
        if ($block_description == '' && $block_use == '') {
            $text = new ocp_tempcode();
        } else {
            $text = do_lang_tempcode('BLOCK_HELPER_2', escape_html(cleanup_block_name($block)), escape_html($block_description), escape_html($block_use));
        }
        $hidden = form_input_hidden('block', $block);
        $content = do_template('FORM_SCREEN', array('_GUID' => '270058349d048a8be6570bba97c81fa2', 'TITLE' => $title, 'TARGET' => '_self', 'SKIP_VALIDATION' => true, 'FIELDS' => $fields, 'URL' => $post_url, 'TEXT' => $text, 'SUBMIT_NAME' => $submit_name, 'HIDDEN' => $hidden, 'PREVIEW' => true, 'THEME' => $GLOBALS['FORUM_DRIVER']->get_theme()));
        if ($fields->is_empty()) {
            $type = 'step3';
        }
    }
    if ($type == 'step3') {
        require_javascript('javascript_posting');
        require_javascript('javascript_editing');
        $field_name = get_param('field_name');
        $bparameters = '';
        $bparameters_xml = '';
        $bparameters_tempcode = '';
        $block = trim(either_param('block'));
        $parameters = get_block_parameters($block);
        $parameters[] = 'failsafe';
        $parameters[] = 'cache';
        $parameters[] = 'quick_cache';
        if (in_array('param', $parameters)) {
            $_parameters = array('param');
            unset($parameters[array_search('param', $parameters)]);
            $parameters = array_merge($_parameters, $parameters);
        }
        foreach ($parameters as $parameter) {
            $value = post_param($parameter, NULL);
            if (is_null($value)) {
                if (post_param_integer('tick_on_form__' . $parameter, NULL) === NULL) {
                    continue;
                }
                // If not on form, continue, otherwise must be 0
                $value = '0';
            }
            if ($value != '' && ($parameter != 'failsafe' || $value == '1') && ($parameter != 'cache' || $value != block_cache_default($block)) && ($parameter != 'quick_cache' || $value == '1')) {
                if ($parameter == 'param') {
                    $bparameters .= '="' . str_replace('"', '\\"', $value) . '"';
                } else {
                    $bparameters .= ' ' . $parameter . '="' . str_replace('"', '\\"', $value) . '"';
                }
                $bparameters_xml = '<blockParam key="' . escape_html($parameter) . '" val="' . escape_html($value) . '" />';
                $bparameters_tempcode .= ',' . $parameter . '=' . str_replace(',', '\\,', $value);
            }
        }
        $comcode = '[block' . $bparameters . ']' . $block . '[/block]';
        $comcode_xml = '<block>' . $bparameters_xml . $block . '</block>';
        $tempcode = '{$BLOCK,block=' . $block . $bparameters_tempcode . '}';
        if ($type_wanted == 'template') {
            $comcode = $tempcode;
        }
        // This is what will be written in
        $comcode_semihtml = comcode_to_tempcode($comcode, NULL, false, 60, NULL, NULL, true, false, false);
        $content = do_template('BLOCK_HELPER_DONE', array('_GUID' => '575d6c8120d6001c8156560be518f296', 'TITLE' => $title, 'FIELD_NAME' => $field_name, 'BLOCK' => $block, 'COMCODE_XML' => $comcode_xml, 'COMCODE' => $comcode, 'COMCODE_SEMIHTML' => $comcode_semihtml));
    }
    global $EXTRA_HEAD;
    if (!isset($EXTRA_HEAD)) {
        $EXTRA_HEAD = new ocp_tempcode();
    }
    $EXTRA_HEAD->attach('<meta name="robots" content="noindex" />');
    // XHTMLXHTML
    $echo = do_template('POPUP_HTML_WRAP', array('TITLE' => do_lang_tempcode('BLOCK_HELPER'), 'CONTENT' => $content));
    $echo->handle_symbol_preprocessing();
    $echo->evaluate_echo();
}
Exemple #11
0
 /**
  * Get a form for entering a bookable black.
  *
  * @param  ?array		Details of the black (NULL: new).
  * @param  ?array		List of bookables this is for (NULL: new).
  * @return array		Tuple: form fields, hidden fields.
  */
 function get_form_fields($details = NULL, $bookables = NULL)
 {
     if (is_null($bookables)) {
         $bookables = array();
     }
     if (is_null($details)) {
         $details = array('blacked_from_day' => intval(date('d')), 'blacked_from_month' => intval(date('m')), 'blacked_from_year' => intval(date('Y')), 'blacked_to_day' => intval(date('d')), 'blacked_to_month' => intval(date('m')), 'blacked_to_year' => intval(date('Y')), 'blacked_explanation' => NULL);
         $bookables = collapse_1d_complexity('id', $GLOBALS['SITE_DB']->query_select('bookable', array('id')));
     }
     $hidden = new ocp_tempcode();
     $hidden->attach(form_input_hidden('timezone', get_server_timezone()));
     $fields = new ocp_tempcode();
     $fields->attach(form_input_date(do_lang_tempcode('BLACKED_FROM'), do_lang_tempcode('DESCRIPTION_BLACKED_FROM'), 'blacked_from', false, false, false, array(0, 0, $details['blacked_from_month'], $details['blacked_from_day'], $details['blacked_from_year']), 10, NULL, NULL, NULL, true, get_server_timezone()));
     $fields->attach(form_input_date(do_lang_tempcode('BLACKED_TO'), do_lang_tempcode('DESCRIPTION_BLACKED_TO'), 'blacked_to', false, false, false, array(0, 0, $details['blacked_to_month'], $details['blacked_to_day'], $details['blacked_to_year']), 10, NULL, NULL, NULL, true, get_server_timezone()));
     $fields->attach(form_input_text(do_lang_tempcode('BLACKED_EXPLANATION'), do_lang_tempcode('DESCRIPTION_BLACKED_EXPLANATION'), 'blacked_explanation', is_null($details['blacked_explanation']) ? '' : get_translated_text($details['blacked_explanation']), true));
     $_bookables = new ocp_tempcode();
     $all_bookables = $GLOBALS['SITE_DB']->query_select('bookable', array('id', 'title'), NULL, 'ORDER BY sort_order');
     foreach ($all_bookables as $s) {
         $_bookables->attach(form_input_list_entry(strval($s['id']), in_array($s['id'], $bookables), get_translated_text($s['title'])));
     }
     $fields->attach(form_input_multi_list(do_lang_tempcode('BOOKABLES'), do_lang_tempcode('DESCRIPTION_BLACKED_BOOKABLES'), 'bookables', $_bookables));
     return array($fields, $hidden);
 }
/**
 * 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 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);
 }