Example #1
0
/**
 * Get the tempcode for the form to add a banner, with the information passed along to it via the parameters already added in.
 *
 * @param  boolean			Whether to simplify the banner interface (for the point-store buy process)
 * @param  ID_TEXT			The name of the banner
 * @param  URLPATH			The URL to the banner image
 * @param  URLPATH			The URL to the site the banner leads to
 * @param  SHORT_TEXT		The caption of the banner
 * @param  LONG_TEXT			Any notes associated with the banner
 * @param  integer			The banners "importance modulus"
 * @range  1 max
 * @param  ?integer			The number of hits the banner may have (NULL: not applicable for this banner type)
 * @range  0 max
 * @param  SHORT_INTEGER	The type of banner (0=permanent, 1=campaign, 2=default)
 * @set    0 1 2
 * @param  ?TIME				The banner expiry date (NULL: never expires)
 * @param  ?ID_TEXT			The username of the banners submitter (NULL: current member)
 * @param  BINARY				Whether the banner has been validated
 * @param  ID_TEXT			The banner type (can be anything, where blank means 'normal')
 * @param  SHORT_TEXT		The title text for the banner (only used for text banners, and functions as the 'trigger text' if the banner type is shown inline)
 * @return tempcode			The input field tempcode
 */
function get_banner_form_fields($simplified = false, $name = '', $image_url = '', $site_url = '', $caption = '', $notes = '', $importancemodulus = 3, $campaignremaining = 50, $the_type = 1, $expiry_date = NULL, $submitter = NULL, $validated = 1, $b_type = '', $title_text = '')
{
    require_code('images');
    $fields = new ocp_tempcode();
    require_code('form_templates');
    $fields->attach(form_input_codename(do_lang_tempcode('CODENAME'), do_lang_tempcode('DESCRIPTION_BANNER_NAME'), 'name', $name, true));
    $fields->attach(form_input_line(do_lang_tempcode('DESTINATION_URL'), do_lang_tempcode('DESCRIPTION_BANNER_URL'), 'site_url', $site_url, false));
    // Blank implies iframe
    if (!$simplified) {
        $types = nice_get_banner_types($b_type);
        if ($types->is_empty()) {
            warn_exit(do_lang_tempcode('NO_CATEGORIES'));
        }
        $fields->attach(form_input_list(do_lang_tempcode('_BANNER_TYPE'), do_lang_tempcode('_DESCRIPTION_BANNER_TYPE'), 'b_type', $types, NULL, false, false));
    } else {
        $fields->attach(form_input_hidden('b_type', $b_type));
    }
    if (has_specific_permission(get_member(), 'full_banner_setup')) {
        $fields->attach(form_input_username(do_lang_tempcode('OWNER'), do_lang_tempcode('DESCRIPTION_SUBMITTER'), 'submitter', is_null($submitter) ? $GLOBALS['FORUM_DRIVER']->get_username(get_member()) : $submitter, false));
    }
    if (get_value('disable_staff_notes') !== '1') {
        $fields->attach(form_input_text(do_lang_tempcode('NOTES'), do_lang_tempcode('DESCRIPTION_NOTES'), 'notes', $notes, false));
    }
    if (has_specific_permission(get_member(), 'bypass_validation_midrange_content', 'cms_banners')) {
        if ($validated == 0) {
            $validated = get_param_integer('validated', 0);
            if ($validated == 1) {
                attach_message(do_lang_tempcode('WILL_BE_VALIDATED_WHEN_SAVING'));
            }
        }
        if (addon_installed('unvalidated')) {
            $fields->attach(form_input_tick(do_lang_tempcode('VALIDATED'), do_lang_tempcode('DESCRIPTION_VALIDATED'), 'validated', $validated == 1));
        }
    }
    $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('SOURCE_MEDIA'))));
    $fields->attach(form_input_upload(do_lang_tempcode('UPLOAD'), do_lang_tempcode('DESCRIPTION_UPLOAD_BANNER'), 'file', false, NULL, NULL, true, str_replace(' ', '', get_option('valid_images') . ',swf')));
    $fields->attach(form_input_line(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('IMAGE_URL')), do_lang_tempcode('DESCRIPTION_URL_BANNER'), 'image_url', $image_url, false));
    $fields->attach(form_input_line_comcode(do_lang_tempcode('BANNER_TITLE_TEXT'), do_lang_tempcode('DESCRIPTION_BANNER_TITLE_TEXT'), 'title_text', $title_text, false));
    $fields->attach(form_input_line_comcode(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_BANNER_DESCRIPTION'), 'caption', $caption, false));
    $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('DEPLOYMENT_DETERMINATION'))));
    if (has_specific_permission(get_member(), 'full_banner_setup')) {
        $radios = new ocp_tempcode();
        $radios->attach(form_input_radio_entry('the_type', strval(BANNER_PERMANENT), $the_type == BANNER_PERMANENT, do_lang_tempcode('BANNER_PERMANENT')));
        $radios->attach(form_input_radio_entry('the_type', strval(BANNER_CAMPAIGN), $the_type == BANNER_CAMPAIGN, do_lang_tempcode('BANNER_CAMPAIGN')));
        $radios->attach(form_input_radio_entry('the_type', strval(BANNER_DEFAULT), $the_type == BANNER_DEFAULT, do_lang_tempcode('BANNER_DEFAULT')));
        $fields->attach(form_input_radio(do_lang_tempcode('DEPLOYMENT_AGREEMENT'), do_lang_tempcode('DESCRIPTION_BANNER_TYPE'), 'the_type', $radios));
        $fields->attach(form_input_integer(do_lang_tempcode('HITS_ALLOCATED'), do_lang_tempcode('DESCRIPTION_HITS_ALLOCATED'), 'campaignremaining', $campaignremaining, false));
        $total_importance = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT SUM(importance_modulus) FROM ' . get_table_prefix() . 'banners WHERE ' . db_string_not_equal_to('name', $name));
        if (is_null($total_importance)) {
            $total_importance = 0;
        }
        $fields->attach(form_input_integer(do_lang_tempcode('IMPORTANCE_MODULUS'), do_lang_tempcode('DESCRIPTION_IMPORTANCE_MODULUS', strval($total_importance), strval($importancemodulus)), 'importancemodulus', $importancemodulus, true));
    }
    $fields->attach(form_input_date(do_lang_tempcode('EXPIRY_DATE'), do_lang_tempcode('DESCRIPTION_EXPIRY_DATE'), 'expiry_date', true, is_null($expiry_date), true, $expiry_date, 2));
    return $fields;
}
Example #2
0
 /**
  * The UI to choose a language.
  *
  * @param  tempcode		The title to show when choosing a language
  * @param  boolean		Whether to also choose a language file
  * @param  boolean		Whether the user may add a language
  * @param  mixed			Text message to show (Tempcode or string)
  * @param  boolean		Whether to provide an N/A choice
  * @param  ID_TEXT		The name of the parameter for specifying language
  * @return tempcode		The UI
  */
 function choose_lang($title, $choose_lang_file = false, $add_lang = false, $text = '', $provide_na = true, $param_name = 'lang')
 {
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/language';
     $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_intl';
     require_code('form_templates');
     $langs = new ocp_tempcode();
     if ($provide_na) {
         $langs->attach(form_input_list_entry('', false, do_lang_tempcode('NA')));
     }
     $langs->attach(nice_get_langs(NULL, $add_lang));
     $fields = form_input_list(do_lang_tempcode('LANGUAGE'), do_lang_tempcode('DESCRIPTION_LANGUAGE'), $param_name, $langs, NULL, false, false);
     $javascript = '';
     if ($add_lang) {
         $fields->attach(form_input_codename(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('LANGUAGE')), do_lang_tempcode('DESCRIPTION_NEW_LANG'), 'lang_new', '', false));
         $javascript .= 'standardAlternateFields(\'lang\',\'lang_new\');';
     }
     if ($choose_lang_file) {
         $lang_files = new ocp_tempcode();
         $lang_files->attach(form_input_list_entry('', false, do_lang_tempcode('NA_EM')));
         $lang_files->attach(nice_get_lang_files());
         $fields->attach(form_input_list(do_lang_tempcode('LANGUAGE_FILE'), do_lang_tempcode('DESCRIPTION_LANGUAGE_FILE'), 'lang_file', $lang_files, NULL, true));
         $fields->attach(form_input_line(do_lang_tempcode('ALT_FIELD', do_lang('SEARCH')), '', 'search', '', false));
         $javascript .= 'standardAlternateFields(\'lang_file\',\'search\');';
     }
     $post_url = get_self_url(false, false, NULL, false, true);
     return do_template('FORM_SCREEN', array('_GUID' => 'ee6bdea3661cb4736173cac818a769e5', 'GET' => true, 'SKIP_VALIDATION' => true, 'HIDDEN' => '', 'SUBMIT_NAME' => do_lang_tempcode('CHOOSE'), 'TITLE' => $title, 'FIELDS' => $fields, 'URL' => $post_url, 'TEXT' => $text, 'JAVASCRIPT' => $javascript));
 }
 /**
  * Get tempcode for a custom comcode tag adding/editing form.
  *
  * @param  SHORT_TEXT	The title (name) of the custom comcode tag
  * @param  LONG_TEXT		The description of the tag
  * @param  BINARY			Whether the tag is enabled
  * @param  ID_TEXT		The actual tag code
  * @param  LONG_TEXT		What to replace the tag with
  * @param  LONG_TEXT		Example usage
  * @param  SHORT_TEXT	Comma-separated list of accepted parameters
  * @param  BINARY			Whether it is a dangerous tag
  * @param  BINARY			Whether it is a block tag
  * @param  BINARY			Whether it is a textual tag
  * @return tempcode		The input fields
  */
 function get_form_fields($title = '', $description = '', $enabled = 1, $tag = 'this', $replace = '<span class="example" style="color: {color}">{content}</span>', $example = '[this color="red"]blah[/this]', $parameters = 'color=black', $dangerous_tag = 0, $block_tag = 0, $textual_tag = 1)
 {
     $fields = new ocp_tempcode();
     require_code('comcode_text');
     $fields->attach(form_input_codename(do_lang_tempcode('COMCODE_TAG'), do_lang_tempcode('DESCRIPTION_COMCODE_TAG'), 'tag', $tag, true, NULL, MAX_COMCODE_TAG_LOOK_AHEAD_LENGTH));
     $fields->attach(form_input_line(do_lang_tempcode('TITLE'), do_lang_tempcode('DESCRIPTION_TAG_TITLE'), 'title', $title, true));
     $fields->attach(form_input_line(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_DESCRIPTION'), 'description', $description, true));
     $fields->attach(form_input_text(do_lang_tempcode('COMCODE_REPLACE'), do_lang_tempcode('DESCRIPTION_COMCODE_REPLACE'), 'replace', $replace, true));
     $fields->attach(form_input_line(do_lang_tempcode('PARAMETERS'), do_lang_tempcode('DESCRIPTION_COMCODE_PARAMETERS'), 'parameters', $parameters, false));
     $fields->attach(form_input_tick(do_lang_tempcode('DANGEROUS_TAG'), do_lang_tempcode('DESCRIPTION_DANGEROUS_TAG'), 'dangerous_tag', $dangerous_tag == 1));
     $fields->attach(form_input_tick(do_lang_tempcode('BLOCK_TAG'), do_lang_tempcode('DESCRIPTION_BLOCK_TAG'), 'block_tag', $block_tag == 1));
     $fields->attach(form_input_tick(do_lang_tempcode('TEXTUAL_TAG'), do_lang_tempcode('DESCRIPTION_TEXTUAL_TAG'), 'textual_tag', $textual_tag == 1));
     $fields->attach(form_input_line(do_lang_tempcode('EXAMPLE'), do_lang_tempcode('DESCRIPTION_COMCODE_EXAMPLE'), 'example', $example, true));
     $fields->attach(form_input_tick(do_lang_tempcode('ENABLED'), '', 'enabled', $enabled == 1));
     return $fields;
 }
Example #4
0
 /**
  * The UI to edit a zone.
  *
  * @return tempcode		The UI
  */
 function _edit_zone()
 {
     $title = get_page_title('EDIT_ZONE');
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/zones';
     $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_structure';
     $zone = get_param('id', '');
     // '' needed for short URLs
     if ($zone == '/') {
         $zone = '';
     }
     $rows = $GLOBALS['SITE_DB']->query_select('zones', array('*'), array('zone_name' => $zone), '', 1);
     if (!array_key_exists(0, $rows)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $row = $rows[0];
     $header_text = get_translated_text($row['zone_header_text']);
     list($fields, $hidden, $javascript) = $this->get_form_fields(false, get_translated_text($row['zone_title']), $row['zone_default_page'], $header_text, $row['zone_theme'], $row['zone_wide'], $row['zone_require_session'], $row['zone_displayed_in_menu'], $zone);
     $hidden->attach(form_input_hidden('zone', $zone));
     $no_delete_zones = get_forum_type() == 'ocf' ? array('', 'adminzone', 'forum') : array('', 'adminzone');
     $no_rename_zones = array('', 'adminzone', 'forum');
     $no_rename = in_array($zone, $no_rename_zones) || get_file_base() != get_custom_file_base();
     if ($no_rename) {
         $hidden->attach(form_input_hidden('new_zone', $zone));
     } else {
         $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ACTIONS'))));
         $rename_label = 'DESCRIPTION_ZONE_RENAME';
         if (in_array($zone, array('site', 'cms', 'collaboration'))) {
             $rename_label = 'DESCRIPTION_ZONE_RENAME_DEFAULT_ZONE';
         }
         $fields->attach(form_input_codename(do_lang_tempcode('CODENAME'), do_lang_tempcode($rename_label), 'new_zone', $zone, true));
     }
     if (!in_array($zone, $no_delete_zones) && get_file_base() == get_custom_file_base()) {
         if ($no_rename) {
             $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ACTIONS'))));
         }
         $fields->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE'), 'delete', false));
     }
     $map = array('page' => '_SELF', 'type' => '__edit');
     $url = get_param('redirect', NULL);
     if (!is_null($url)) {
         $map['redirect'] = $url;
     }
     $post_url = build_url($map, '_SELF');
     $submit_name = do_lang_tempcode('SAVE');
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('ZONES')), array('_SELF:_SELF:edit_zone', do_lang_tempcode('CHOOSE'))));
     return do_template('FORM_SCREEN', array('_GUID' => '54a578646aed86da06f30c459c9586c2', 'JAVASCRIPT' => $javascript, 'HIDDEN' => $hidden, 'SUBMIT_NAME' => $submit_name, 'TITLE' => $title, 'FIELDS' => $fields, 'URL' => $post_url, 'TEXT' => ''));
 }
Example #5
0
 /**
  * The UI for the add-new-page wizard (choose zone, page name).
  *
  * @return tempcode		The UI
  */
 function page_wizard()
 {
     $zone = get_param('zone', 'site');
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/addpagewizard';
     $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_comcode_pages';
     $title = get_page_title('PAGE_WIZARD_STEP', true, array(integer_format(1), integer_format(3)));
     require_code('form_templates');
     require_code('zones2');
     require_code('zones3');
     $fields = new ocp_tempcode();
     $fields->attach(form_input_list(do_lang_tempcode('ZONE'), do_lang_tempcode('MENU_ZONE'), 'zone', nice_get_zones($zone), NULL, true));
     $fields->attach(form_input_codename(do_lang_tempcode('CODENAME'), do_lang_tempcode('DESCRIPTION_PAGE_NAME'), 'name', '', true));
     $post_url = build_url(array('page' => '_SELF', 'type' => '_pagewizard'), '_SELF', NULL, false, true);
     $submit_name = do_lang_tempcode('PROCEED');
     //		breadcrumb_set_parents(array(array('_SELF:_SELF:misc',do_lang_tempcode('PAGES'))));
     breadcrumb_set_self(do_lang_tempcode('PAGE_WIZARD'));
     return do_template('FORM_SCREEN', array('_GUID' => '4c982255f035472282b5a3740d8df82d', 'SKIP_VALIDATION' => true, 'TITLE' => $title, 'HIDDEN' => '', 'TEXT' => '', 'FIELDS' => $fields, 'URL' => $post_url, 'SUBMIT_NAME' => $submit_name));
 }
Example #6
0
 /**
  * The UI to choose a menu to edit / create a new menu.
  *
  * @return tempcode		The UI
  */
 function get_menu_name()
 {
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/menus';
     $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_menus';
     $title = get_page_title('MENU_MANAGEMENT');
     require_code('form_templates');
     $rows = $GLOBALS['SITE_DB']->query_select('menu_items', array('DISTINCT i_menu'), NULL, 'ORDER BY i_menu');
     $list = form_input_list_entry('', false, do_lang_tempcode('NA_EM'));
     foreach ($rows as $row) {
         $list->attach(form_input_list_entry($row['i_menu']));
     }
     $fields = new ocp_tempcode();
     $fields->attach(form_input_list(do_lang_tempcode('EXISTING'), do_lang_tempcode('EXISTING_MENU'), 'id', $list, NULL, true, false));
     $fields->attach(form_input_codename(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('NEW')), do_lang_tempcode('NEW_MENU'), 'id_new', '', false));
     $map = array('page' => '_SELF', 'type' => 'edit', 'wide' => 1);
     if (get_param('redirect', '!') != '!') {
         $map['redirect'] = get_param('redirect');
     }
     $post_url = build_url($map, '_SELF', NULL, false, true);
     $submit_name = do_lang_tempcode('CHOOSE');
     $javascript = 'standardAlternateFields(\'id\',\'id_new\');';
     return do_template('FORM_SCREEN', array('_GUID' => 'f3c04ea3fb5e429210c5e33e5a2f2092', 'GET' => true, 'SKIP_VALIDATION' => true, 'TITLE' => $title, 'HIDDEN' => '', 'TEXT' => do_lang_tempcode('CHOOSE_EDIT_LIST'), 'FIELDS' => $fields, 'URL' => $post_url, 'SUBMIT_NAME' => $submit_name, 'JAVASCRIPT' => $javascript));
 }
Example #7
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));
 }
Example #8
0
 /**
  * The UI to edit a page.
  *
  * @return tempcode		The UI
  */
 function _ed()
 {
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/comcode_page_edit';
     require_lang('menus');
     $GLOBALS['HELPER_PANEL_TEXT'] = comcode_lang_string('DOC_WRITING');
     $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_comcode_pages';
     $simple_add = get_param_integer('simple_add', 0) == 1;
     $lang = choose_language(get_page_title($simple_add ? 'COMCODE_PAGE_ADD' : 'COMCODE_PAGE_EDIT'), true);
     if (is_object($lang)) {
         return $lang;
     }
     if (addon_installed('page_management')) {
         // Add to menu
         if (get_param('menu', STRING_MAGIC_NULL) != STRING_MAGIC_NULL && has_actual_page_access(get_member(), 'admin_sitetree')) {
             require_code('menus2');
             add_menu_item_simple(get_param('menu'), NULL, get_param('title'), get_param('page_link'), 0, 0, false);
         }
     }
     // Work out what we're editing, and where it's coming from (support for two pagelink specifying parameters for destination, with addition of restore_from to override source if different from destination)
     $page_link = filter_naughty(get_param('page_link', ''));
     if ($page_link == '') {
         $page_link = get_param('page_link_2');
     }
     if (strpos($page_link, ':') === false) {
         $page_link = ':' . $page_link;
     }
     $page_link_parts = explode(':', $page_link);
     if (count($page_link_parts) != 2) {
         warn_exit(do_lang_tempcode('ZONE_COLON_FILE'));
     }
     $zone = $page_link_parts[0];
     if ($zone != '' && !file_exists(get_file_base() . '/' . $zone . '/pages')) {
         warn_exit(do_lang_tempcode('NO_SUCH_ZONE'));
     }
     $file = $page_link_parts[1];
     require_code('type_validation');
     if (!is_alphanumeric($file, true)) {
         warn_exit(do_lang_tempcode('BAD_CODENAME'));
     }
     $resource_owner = $GLOBALS['SITE_DB']->query_value_null_ok('comcode_pages', 'p_submitter', array('the_zone' => $zone, 'the_page' => $file));
     check_edit_permission('high', $resource_owner);
     if (is_null($resource_owner)) {
         check_submit_permission('high');
     }
     $restore_from = $this->find_comcode_page($lang, $file, $zone);
     // Check no redirects in our way
     if (addon_installed('redirects_editor')) {
         $test = $GLOBALS['SITE_DB']->query_value_null_ok('redirects', 'r_to_zone', array('r_from_page' => $file, 'r_from_zone' => $zone));
         if (!is_null($test)) {
             $redirect_url = build_url(array('page' => 'admin_redirects'), get_module_zone('admin_redirects'));
             attach_message(do_lang_tempcode('BLOCKING_REDIRECT_IN_PLACE', escape_html($redirect_url->evaluate())), 'notice');
         }
     }
     $title = get_page_title($simple_add || $file == '' ? 'COMCODE_PAGE_ADD' : '_COMCODE_PAGE_EDIT', true, array(escape_html($zone), escape_html($file)));
     if (!$simple_add && $file != '') {
         breadcrumb_set_self(do_lang_tempcode('COMCODE_PAGE_EDIT'));
     }
     if (!has_actual_page_access(get_member(), $file, $zone)) {
         access_denied('PAGE_ACCESS');
     }
     // Default file contents
     $contents = post_param('new', '');
     $parsed = NULL;
     if ($contents == '') {
         $file_base = strpos($restore_from, 'comcode_custom/') ? get_custom_file_base() : get_file_base();
         if (!is_file($file_base . '/' . $restore_from)) {
             $file_base = get_file_base();
         }
         if (is_file($file_base . '/' . $restore_from)) {
             $contents = file_get_contents($file_base . '/' . $restore_from, FILE_TEXT);
             if (is_null(get_param('restore_from', NULL))) {
                 $string_index = $GLOBALS['SITE_DB']->query_value_null_ok('cached_comcode_pages', 'string_index', array('the_zone' => $zone, 'the_page' => $file));
                 if (!is_null($string_index)) {
                     $parsed = get_translated_tempcode($string_index, NULL, $lang);
                 }
             }
             $new = false;
         } elseif (get_param('title', '') != '') {
             $page_pretty_title = get_param('title', '');
             $contents = '[title]' . $page_pretty_title . "[/title]\n\n" . do_lang('PAGE_DEFAULT_TEXT');
             $new = true;
         } else {
             $contents = '[title]' . do_lang('PAGE_DEFAULT_TITLE') . "[/title]\n\n";
             $new = true;
         }
         if ($new && get_option('is_on_comcode_page_children') == '1') {
             $contents .= chr(10) . chr(10) . '[block]main_comcode_page_children[/block]';
         }
     } else {
         $new = false;
     }
     $map = array('page' => '_SELF', 'type' => '__ed', 'wide' => 1);
     if ($simple_add) {
         $map['simple_add'] = '1';
     }
     $post_url = build_url($map, '_SELF');
     // Revision history
     $filesarray = $this->get_comcode_revisions($zone, 'comcode_custom/' . $lang, $file . '.txt');
     rsort($filesarray);
     $i = 0;
     $revision_history = new ocp_tempcode();
     $max = intval(get_option('number_revisions_show'));
     $last_path = $file_base . '/' . $restore_from;
     if (is_file($last_path)) {
         foreach ($filesarray as $iterator => $stuff) {
             list($filepath, $time) = $stuff;
             // Find who did the revision
             $editor = $GLOBALS['SITE_DB']->query_value_null_ok('adminlogs', 'the_user', array('date_and_time' => $time, 'the_type' => 'COMCODE_PAGE_EDIT', 'param_a' => $file));
             if (has_specific_permission(get_member(), 'view_revision_history') || $editor == get_member()) {
                 if (is_null($editor)) {
                     $editor = do_lang('UNKNOWN');
                 } else {
                     $editor = $GLOBALS['FORUM_DRIVER']->get_username($editor);
                     if (is_null($editor)) {
                         $editor = do_lang('UNKNOWN');
                     }
                 }
                 $old_file = (strpos($filepath, '_custom/') ? get_custom_file_base() : get_file_base()) . '/' . $filepath;
                 $size = filesize($old_file);
                 $date = get_timezoned_date($time);
                 $url = get_custom_base_url() . '/' . $zone . '/' . 'pages/comcode_custom/' . $lang . '/' . $file . '.txt.' . strval($time);
                 $restore_url = build_url(array('page' => '_SELF', 'type' => '_ed', 'page_link' => $zone . ':' . $file, 'restore_from' => zone_black_magic_filterer($zone . ($zone != '' ? '/' : '') . 'pages/comcode_custom/' . $lang . '/' . $file . '.txt.' . strval($time), true)), '_SELF');
                 require_code('diff');
                 if (function_exists('diff_simple')) {
                     $rendered_diff = diff_simple($old_file, $last_path);
                     $last_path = $old_file;
                     if ($rendered_diff == '' && $iterator == 0) {
                         continue;
                     }
                     // the version records are often saved on create not replace
                     $revision_history->attach(do_template('REVISION_HISTORY_LINE', array('_GUID' => '57e2c81fd621d1c8d6e283a5a4991001', 'REFERENCE_POINT_EXACT' => true, 'RENDERED_DIFF' => $rendered_diff, 'EDITOR' => $editor, 'DATE' => $date, 'DATE_RAW' => strval($time), 'RESTORE_URL' => $restore_url, 'URL' => $url, 'SIZE' => clean_file_size($size))));
                     $i++;
                 }
                 if ($i == $max) {
                     break;
                 }
             }
         }
         if (strpos($restore_from, '/comcode_custom/') !== false && zone_black_magic_filterer($zone . '/' . 'pages/comcode/' . $lang . '/' . $file . '.txt', true) != $restore_from && is_file(zone_black_magic_filterer(get_file_base() . '/' . $zone . '/' . 'pages/comcode/' . $lang . '/' . $file . '.txt'))) {
             $url = get_base_url() . '/' . $zone . '/' . 'pages/comcode/' . $lang . '/' . $file . '.txt';
             $size = filesize(zone_black_magic_filterer(get_file_base() . '/' . $zone . '/' . 'pages/comcode/' . $lang . '/' . $file . '.txt'));
             $restore_url = build_url(array('page' => '_SELF', 'type' => '_ed', 'page_link' => $zone . ':' . $file, 'restore_from' => $zone . ($zone == '' ? '' : '/') . 'pages/comcode/' . $lang . '/' . $file . '.txt'), '_SELF');
             require_code('diff');
             if (function_exists('diff_simple')) {
                 $rendered_diff = diff_simple(zone_black_magic_filterer(get_file_base() . '/' . $zone . '/' . 'pages/comcode/' . $lang . '/' . $file . '.txt'), $last_path);
                 $revision_history->attach(do_template('REVISION_HISTORY_LINE', array('_GUID' => 'ed0b29f26cf93d4d6e0348a7e75d259d', 'REFERENCE_POINT_EXACT' => true, 'RENDERED_DIFF' => $rendered_diff, 'RESTORE_URL' => $restore_url, 'URL' => $url, 'SIZE' => clean_file_size($size))));
                 $i++;
             }
         }
     }
     if (!$revision_history->is_empty() && get_param('restore_from', '') == '') {
         $revision_history = do_template('REVISION_HISTORY_WRAP', array('_GUID' => '2349ee62cae037ec3cf1766403c92b39', 'CONTENT' => $revision_history));
     } elseif (!$revision_history->is_empty()) {
         $revision_history = do_template('REVISION_RESTORE');
     }
     $meta_keywords = post_param('meta_keywords', '');
     $meta_description = post_param('meta_description', '');
     if ($meta_keywords == '' && $meta_description == '') {
         list($meta_keywords, $meta_description) = seo_meta_get_for('comcode_page', $zone . ':' . $file);
     }
     $hidden_fields = new ocp_tempcode();
     if (addon_installed('page_management') && has_actual_page_access(get_member(), 'adminzone')) {
         $delete_url = build_url(array('page' => 'admin_sitetree', 'type' => '_delete', 'page__' . $file => 1, 'zone' => $zone), get_module_zone('admin_sitetree'));
     } else {
         $delete_url = new ocp_tempcode();
     }
     $fields = new ocp_tempcode();
     $fields2 = new ocp_tempcode();
     require_code('form_templates');
     if (addon_installed('page_management')) {
         if (has_actual_page_access(get_member(), 'admin_sitetree')) {
             if ($simple_add) {
                 $hidden_fields->attach(form_input_hidden('title', $file));
             } else {
                 $fields->attach(form_input_codename(do_lang_tempcode('CODENAME'), do_lang_tempcode('DESCRIPTION_CODENAME'), 'title', $file, true));
             }
         }
     }
     $rows = $GLOBALS['SITE_DB']->query_select('comcode_pages', array('*'), array('the_zone' => $zone, 'the_page' => $file));
     if (array_key_exists(0, $rows)) {
         $validated = $rows[0]['p_validated'] == 1;
         $parent_page = $rows[0]['p_parent_page'];
         $show_as_edit = $rows[0]['p_show_as_edit'] == 1;
         $owner = $rows[0]['p_submitter'];
     } else {
         global $NON_CANONICAL_PARAMS;
         $NON_CANONICAL_PARAMS[] = 'parent_page';
         $validated = true;
         $parent_page = get_param('parent_page', '');
         $show_as_edit = false;
         $owner = get_member();
     }
     $_pages = find_all_pages($zone, 'comcode/' . $lang, 'txt', false, NULL, FIND_ALL_PAGES__NEWEST);
     $_pages += find_all_pages($zone, 'comcode_custom/' . $lang, 'txt', false, NULL, FIND_ALL_PAGES__NEWEST);
     $_pages += find_all_pages($zone, 'comcode/' . get_site_default_lang(), 'txt', false, NULL, FIND_ALL_PAGES__NEWEST);
     $_pages += find_all_pages($zone, 'comcode_custom/' . get_site_default_lang(), 'txt', false, NULL, FIND_ALL_PAGES__NEWEST);
     ksort($_pages);
     $pages = form_input_list_entry('', false, do_lang_tempcode('NA_EM'));
     foreach (array_keys($_pages) as $page) {
         if (!is_string($page)) {
             $page = strval($page);
         }
         if ($page != $file) {
             $pages->attach(form_input_list_entry($page, $parent_page == $page));
         }
     }
     if (!$simple_add) {
         if (!$validated) {
             $validated = get_param_integer('validated', 0) == 1;
         }
         if (has_specific_permission(get_member(), 'bypass_validation_highrange_content')) {
             if (addon_installed('unvalidated')) {
                 $fields2->attach(form_input_tick(do_lang_tempcode('VALIDATED'), do_lang_tempcode('DESCRIPTION_VALIDATED'), 'validated', $validated));
             }
         }
         if (!$new) {
             if ($delete_url->is_empty()) {
                 $fields2->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE'), 'delete', false));
             }
         }
     } else {
         $hidden_fields->attach(form_input_hidden('validated', '1'));
     }
     if (get_option('is_on_comcode_page_children') == '1') {
         $fields2->attach(form_input_list(do_lang_tempcode('PARENT_PAGE'), do_lang_tempcode('DESCRIPTION_PARENT_PAGE'), 'parent_page', $pages, NULL, false, false));
     }
     if (!$simple_add) {
         $fields2->attach(form_input_tick(do_lang_tempcode('SHOW_AS_EDITED'), do_lang_tempcode('DESCRIPTION_SHOW_AS_EDITED'), 'show_as_edit', $show_as_edit));
         if ($GLOBALS['FORUM_DRIVER']->is_super_admin(get_member())) {
             $fields2->attach(form_input_username(do_lang_tempcode('OWNER'), do_lang_tempcode('DESCRIPTION_OWNER'), 'owner', $GLOBALS['FORUM_DRIVER']->get_username($owner), true));
         }
         $fields2->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('SEO'), 'SECTION_HIDDEN' => true, 'HELP' => get_option('show_docs') == '0' ? NULL : protect_from_escaping(symbol_tempcode('URLISE_LANG', array(do_lang('TUTORIAL_ON_THIS'), brand_base_url() . '/docs' . strval(ocp_version()) . '/pg/tut_seo', 'tut_seo', '1'))))));
         $fields2->attach(form_input_line_multi(do_lang_tempcode('KEYWORDS'), do_lang_tempcode('DESCRIPTION_META_KEYWORDS'), 'meta_keywords[]', array_map('trim', explode(',', preg_replace('#,+#', ',', $meta_keywords))), 0));
         $fields2->attach(form_input_line(do_lang_tempcode('META_DESCRIPTION'), do_lang_tempcode('DESCRIPTION_META_DESCRIPTION'), 'meta_description', $meta_description, false));
     }
     // Awards?
     if (addon_installed('awards')) {
         require_code('awards');
         $fields2->attach(get_award_fields('comcode_page', $zone . ':' . $file));
     }
     require_code('permissions2');
     $fields2->attach(get_page_permissions_for_environment($zone, $file));
     $hidden_fields->attach(form_input_hidden('file', $file));
     $hidden_fields->attach(form_input_hidden('lang', $lang));
     $hidden_fields->attach(form_input_hidden('zone', $zone));
     $hidden_fields->attach(form_input_hidden('redirect', get_param('redirect', '')));
     $posting_form = get_posting_form(do_lang($simple_add ? 'COMCODE_PAGE_ADD' : 'SAVE'), $contents, $post_url, $hidden_fields, $fields, do_lang_tempcode('COMCODE_PAGE'), '', $fields2, $parsed, NULL, NULL, false);
     $export_url = build_url(array('page' => '_SELF', 'type' => 'export', 'page_link' => $page_link, 'export' => $restore_from, 'lang' => $lang), '_SELF');
     $text = new ocp_tempcode();
     if (addon_installed('points')) {
         $login_url = build_url(array('page' => 'login', 'type' => 'misc', 'redirect' => get_self_url(true, true)), get_module_zone('login'));
         $_login_url = escape_html($login_url->evaluate());
         if (is_guest() && (get_forum_type() != 'ocf' || has_actual_page_access(get_member(), 'join'))) {
             $text->attach(paragraph(do_lang_tempcode('NOT_LOGGED_IN_NO_CREDIT', $_login_url)));
         }
     }
     list($warning_details, $ping_url) = handle_conflict_resolution($page_link);
     if (!$simple_add) {
         breadcrumb_set_parents(array(array('_SELF:_SELF:misc:lang=' . $lang, do_lang_tempcode('CHOOSE'))));
     }
     return do_template('COMCODE_EDIT_SCREEN', array('_GUID' => 'ec1d773684757f5bf6f39cf931555bf2', 'NEW' => $new, 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'TEXT' => $text, 'TITLE' => $title, 'DELETE_URL' => $delete_url, 'ZONE' => $zone, 'FILE' => $file, 'EXPORT_URL' => $export_url, 'POSTING_FORM' => $posting_form, 'REVISION_HISTORY' => $revision_history));
 }
Example #9
0
 /**
  * UI for a theme wizard step (choose colour).
  *
  * @return tempcode		The UI
  */
 function step1()
 {
     $title = get_page_title('_THEMEWIZARD', true, array(integer_format(1), integer_format(4)));
     $post_url = build_url(array('page' => '_SELF', 'type' => 'step2'), '_SELF', array('keep_theme_seed', 'keep_theme_dark', 'keep_theme_source', 'keep_theme_algorithm'), false, true);
     $text = do_lang_tempcode('THEMEWIZARD_1_DESCRIBE');
     $submit_name = do_lang_tempcode('PROCEED');
     require_code('form_templates');
     $source_theme = get_param('source_theme', 'default');
     $hidden = new ocp_tempcode();
     if (count(find_all_themes()) == 1) {
         $hidden->attach(form_input_hidden('source_theme', $source_theme));
     } else {
         $themes = nice_get_themes($source_theme, true);
     }
     $fields = new ocp_tempcode();
     $fields->attach(form_input_codename(do_lang_tempcode('NEW_THEME'), do_lang_tempcode('DESCRIPTION_NAME'), 'themename', get_param('themename', ''), true));
     $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => false, 'TITLE' => do_lang_tempcode('PARAMETERS'))));
     $fields->attach(form_input_colour(do_lang_tempcode('SEED_COLOUR'), do_lang_tempcode('DESCRIPTION_SEED_COLOUR'), 'seed', '#' . get_param('seed', find_theme_seed('default')), true));
     if (count(find_all_themes()) != 1) {
         $fields->attach(form_input_list(do_lang_tempcode('SOURCE_THEME'), do_lang_tempcode('DESCRIPTION_SOURCE_THEME'), 'source_theme', $themes, NULL, true));
     }
     $radios = new ocp_tempcode();
     $radios->attach(form_input_radio_entry('algorithm', 'equations', $source_theme == 'default', do_lang_tempcode('THEMEGEN_ALGORITHM_EQUATIONS')));
     $radios->attach(form_input_radio_entry('algorithm', 'hsv', $source_theme != 'default', do_lang_tempcode('THEMEGEN_ALGORITHM_HSV')));
     $fields->attach(form_input_radio(do_lang_tempcode('THEMEGEN_ALGORITHM'), do_lang_tempcode('DESCRIPTION_THEMEGEN_ALGORITHM'), 'algorithm', $radios, true));
     $fields->attach(form_input_tick(do_lang_tempcode('DARK_THEME'), do_lang_tempcode('DESCRIPTION_DARK_THEME'), 'dark', get_param_integer('dark', 0) == 1));
     $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('ADVANCED'))));
     $fields->attach(form_input_tick(do_lang_tempcode('INHERIT_CSS'), do_lang_tempcode('DESCRIPTION_INHERIT_CSS'), 'inherit_css', get_param_integer('inherit_css', 0) == 1));
     breadcrumb_set_self(do_lang_tempcode('THEMEWIZARD'));
     require_javascript('javascript_ajax');
     $script = find_script('snippet');
     $javascript = "\n\t\t\tvar form=document.getElementById('main_form');\n\t\t\tform.elements['source_theme'].onchange=function() {\n\t\t\t\tvar default_theme=(form.elements['source_theme'].options[form.elements['source_theme'].selectedIndex].value=='default');\n\t\t\t\tform.elements['algorithm'][0].checked=default_theme;\n\t\t\t\tform.elements['algorithm'][1].checked=!default_theme;\n\t\t\t}\n\t\t\tform.old_submit=form.onsubmit;\n\t\t\tform.onsubmit=function()\n\t\t\t\t{\n\t\t\t\t\tdocument.getElementById('submit_button').disabled=true;\n\t\t\t\t\tvar url='" . addslashes($script) . "?snippet=exists_theme&name='+window.encodeURIComponent(form.elements['themename'].value);\n\t\t\t\t\tif (!do_ajax_field_test(url))\n\t\t\t\t\t{\n\t\t\t\t\t\tdocument.getElementById('submit_button').disabled=false;\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\tdocument.getElementById('submit_button').disabled=false;\n\t\t\t\t\tif (typeof form.old_submit!='undefined' && form.old_submit) return form.old_submit();\n\t\t\t\t\treturn true;\n\t\t\t\t};\n\t\t";
     return do_template('FORM_SCREEN', array('_GUID' => '98963f4d7ff60744382f937e6cc5acbf', 'GET' => true, 'SKIP_VALIDATION' => true, 'TITLE' => $title, 'JAVASCRIPT' => $javascript, 'FIELDS' => $fields, 'URL' => $post_url, 'TEXT' => $text, 'SUBMIT_NAME' => $submit_name, 'HIDDEN' => $hidden));
 }
Example #10
0
 /**
  * Get tempcode for a catalogue adding/editing form.
  *
  * @param  ID_TEXT			The name of the catalogue
  * @param  SHORT_TEXT		The human readable name/title of the catalogue
  * @param  LONG_TEXT			The description
  * @param  SHORT_INTEGER	The display type
  * @param  BINARY				Whether the catalogue uses a hierarchy
  * @param  LONG_TEXT			Admin notes
  * @param  integer			How many points are given to a member that submits to the catalogue
  * @param  BINARY				Whether the catalogue is an eCommerce catalogue
  * @param  ID_TEXT			How to send view reports
  * @set    never daily weekly monthly quarterly
  * @return array				A tuple: the tempcode for the visible fields, and the tempcode for the hidden fields, ..., and action fields
  */
 function get_form_fields($name = '', $title = '', $description = '', $display_type = 0, $is_tree = 1, $notes = '', $submit_points = 0, $ecommerce = 0, $send_view_reports = 'never')
 {
     $fields = new ocp_tempcode();
     $hidden = new ocp_tempcode();
     require_code('form_templates');
     if ($name == '') {
         $name = get_param('id', '');
     }
     $tied_to_content_type = substr($name, 0, 1) == '_' && (file_exists(get_file_base() . '/sources_custom/hooks/systems/awards/' . substr($name, 1) . '.php') || file_exists(get_file_base() . '/sources/hooks/systems/awards/' . substr($name, 1) . '.php'));
     if ($tied_to_content_type) {
         $content_type = substr($name, 1);
         require_code('hooks/systems/awards/' . $content_type);
         $ob = object_factory('Hook_awards_' . $content_type);
         $info = $ob->info();
         $title = do_lang('CUSTOM_FIELDS_FOR', $info['title']->evaluate());
         $hidden->attach(form_input_hidden('title', $title));
         $hidden->attach(form_input_hidden('name', $name));
         $hidden->attach(form_input_hidden('description', ''));
         $hidden->attach(form_input_hidden('notes', ''));
         $hidden->attach(form_input_hidden('auto_fill', ''));
         $hidden->attach(form_input_hidden('display_type', '0'));
         $hidden->attach(form_input_hidden('submit_points', '0'));
         $hidden->attach(form_input_hidden('send_view_reports', 'never'));
         attach_message(do_lang_tempcode('EDITING_CUSTOM_FIELDS_HELP', $info['title']));
         $actions = new ocp_tempcode();
     } else {
         $fields->attach(form_input_line(do_lang_tempcode('TITLE'), do_lang_tempcode('DESCRIPTION_TITLE'), 'title', $title, true));
         $fields->attach(form_input_codename(do_lang_tempcode('CODENAME'), do_lang_tempcode('DESCRIPTION_CODENAME'), 'name', $name, true));
         $fields->attach(form_input_text_comcode(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_CATALOGUE_DESCRIPTION'), 'description', $description, false));
         $display_types = new ocp_tempcode();
         $display_types->attach(form_input_list_entry(strval(0), $display_type == 0, do_lang_tempcode('DT_MAPS')));
         $display_types->attach(form_input_list_entry(strval(1), $display_type == 1, do_lang_tempcode('DT_LIST')));
         $display_types->attach(form_input_list_entry(strval(2), $display_type == 2, do_lang_tempcode('DT_MATRIX')));
         $fields->attach(form_input_list(do_lang_tempcode('DISPLAY_TYPE'), do_lang_tempcode('DESCRIPTION_DISPLAY_TYPE'), 'display_type', $display_types));
         if (addon_installed('shopping')) {
             if ($ecommerce == 1) {
                 if (get_forum_type() != 'ocf') {
                     warn_exit(do_lang_tempcode('NO_OCF'));
                 }
             }
             $fields->attach(form_input_tick(do_lang_tempcode('CAT_ECOMMERCE'), do_lang_tempcode('DESCRIPTION_CAT_ECOMMERCE'), 'ecommerce', $ecommerce == 1));
         }
         $fields->attach(form_input_tick(do_lang_tempcode('IS_TREE'), do_lang_tempcode('DESCRIPTION_IS_TREE'), 'is_tree', $is_tree == 1));
         if ($name == '') {
             $fields->attach(form_input_line(do_lang_tempcode('AUTO_FILL'), do_lang_tempcode('DESCRIPTION_AUTO_FILL'), 'auto_fill', '', false, NULL, 10000));
         }
         $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => $notes == '' && $submit_points == 0 && $send_view_reports == 'never', 'TITLE' => do_lang_tempcode('ADVANCED'))));
         if (get_value('disable_staff_notes') !== '1') {
             $fields->attach(form_input_text(do_lang_tempcode('NOTES'), do_lang_tempcode('DESCRIPTION_NOTES'), 'notes', $notes, false));
         }
         if (addon_installed('points')) {
             $fields->attach(form_input_integer(do_lang_tempcode('SUBMIT_POINTS'), do_lang_tempcode('DESCRIPTION_SUBMIT_POINTS'), 'submit_points', $submit_points, false));
         }
         $view_report_types = new ocp_tempcode();
         $view_report_types->attach(form_input_list_entry('never', $send_view_reports == 'never', do_lang_tempcode('VR_NEVER')));
         $view_report_types->attach(form_input_list_entry('daily', $send_view_reports == 'daily', do_lang_tempcode('VR_DAILY')));
         $view_report_types->attach(form_input_list_entry('weekly', $send_view_reports == 'weekly', do_lang_tempcode('VR_WEEKLY')));
         $view_report_types->attach(form_input_list_entry('monthly', $send_view_reports == 'monthly', do_lang_tempcode('VR_MONTHLY')));
         $view_report_types->attach(form_input_list_entry('quarterly', $send_view_reports == 'quarterly', do_lang_tempcode('VR_QUARTERLY')));
         $fields->attach(form_input_list(do_lang_tempcode('VIEW_REPORTS'), do_lang_tempcode('DESCRIPTION_VIEW_REPORTS'), 'send_view_reports', $view_report_types));
         // Permissions
         $fields->attach($this->get_permission_fields($name, NULL, $name == ''));
         $actions = new ocp_tempcode();
         if ($name != '' && get_value('disable_cat_cat_perms') !== '1') {
             $actions->attach(form_input_tick(do_lang_tempcode('RESET_CATEGORY_PERMISSIONS'), do_lang_tempcode('DESCRIPTION_RESET_CATEGORY_PERMISSIONS'), 'reset_category_permissions', false));
         }
         if ($name == '') {
             $actions->attach(form_input_tick(do_lang_tempcode('ADD_TO_MENU'), do_lang_tempcode('DESCRIPTION_ADD_TO_MENU'), 'add_to_menu', true));
         }
     }
     return array($fields, $hidden, NULL, NULL, false, NULL, $actions);
 }
Example #11
0
 /**
  * Get tempcode for a gallery adding/editing form.
  *
  * @param  ID_TEXT			The gallery codename
  * @param  SHORT_TEXT		The full human-readeable name of the gallery
  * @param  LONG_TEXT			The description of the gallery
  * @param  SHORT_TEXT		Teaser text for the gallery
  * @param  LONG_TEXT			Hidden notes associated with the gallery
  * @param  ID_TEXT			The parent gallery (blank: no parent)
  * @param  BINARY				Whether images may be put in this gallery
  * @param  BINARY				Whether videos may be put in this gallery
  * @param  BINARY				Whether the gallery serves as a container for automatically created member galleries
  * @param  ?BINARY			Whether the gallery uses the flow mode interface (NULL: pick statistically based on current usage of other galleries)
  * @param  ?URLPATH			The representative image of the gallery (NULL: none)
  * @param  ?URLPATH			Watermark (NULL: none)
  * @param  ?URLPATH			Watermark (NULL: none)
  * @param  ?URLPATH			Watermark (NULL: none)
  * @param  ?URLPATH			Watermark (NULL: none)
  * @param  ?BINARY			Whether rating is allowed (NULL: decide statistically, based on existing choices)
  * @param  ?SHORT_INTEGER	Whether comments are allowed (0=no, 1=yes, 2=review style) (NULL: decide statistically, based on existing choices)
  * @return array				A pair: the tempcode for the visible fields, and the tempcode for the hidden fields
  */
 function get_form_fields($name = '', $fullname = '', $description = '', $teaser = '', $notes = '', $parent_id = '', $accept_images = 1, $accept_videos = 1, $is_member_synched = 0, $flow_mode_interface = NULL, $rep_image = NULL, $watermark_top_left = NULL, $watermark_top_right = NULL, $watermark_bottom_left = NULL, $watermark_bottom_right = NULL, $allow_rating = NULL, $allow_comments = NULL)
 {
     list($allow_rating, $allow_comments, ) = $this->choose_feedback_fields_statistically($allow_rating, $allow_comments, 1);
     global $NON_CANONICAL_PARAMS;
     $NON_CANONICAL_PARAMS[] = 'cat';
     $NON_CANONICAL_PARAMS[] = 'validated';
     if (is_null($flow_mode_interface)) {
         $cnt = $GLOBALS['SITE_DB']->query_value('galleries', 'COUNT(*)');
         if ($cnt < 5000) {
             $flow_mode_interface = intval(round($GLOBALS['SITE_DB']->query_value('galleries', 'AVG(flow_mode_interface)')));
             // Determine default based on what is 'the norm' currently. Sometimes maths is beautiful :)
         } else {
             $flow_mode_interface = intval(round($GLOBALS['SITE_DB']->query_value('galleries', 'AVG(flow_mode_interface)', array('parent_id' => 'root'))));
             // Determine default based on what is 'the norm' currently. Sometimes maths is beautiful :)
         }
     }
     $fields = new ocp_tempcode();
     require_code('form_templates');
     $fields->attach(form_input_line(do_lang_tempcode('TITLE'), do_lang_tempcode('DESCRIPTION_TITLE'), 'fullname', $fullname, true));
     if ($name != 'root') {
         $fields->attach(form_input_codename(do_lang_tempcode('CODENAME'), do_lang_tempcode('DESCRIPTION_CODENAME'), 'name', $name, true));
     }
     $fields->attach(form_input_text_comcode(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_DESCRIPTION'), 'description', $description, false));
     if ($parent_id == '') {
         $parent_id = get_param('cat', '');
     }
     if ($name != 'root') {
         $fields->attach(form_input_tree_list(do_lang_tempcode('PARENT'), do_lang_tempcode('DESCRIPTION_PARENT'), 'parent_id', NULL, 'choose_gallery', array('filter' => 'only_conventional_galleries', 'purity' => true, 'addable_filter' => true), true, $parent_id));
     }
     $fields->attach(form_input_various_ticks(array(array(do_lang_tempcode('ACCEPT_IMAGES'), 'accept_images', $accept_images == 1, do_lang_tempcode('DESCRIPTION_ACCEPT_IMAGES')), array(do_lang_tempcode('ACCEPT_VIDEOS'), 'accept_videos', $accept_videos == 1, do_lang_tempcode('DESCRIPTION_ACCEPT_VIDEOS'))), new ocp_tempcode(), NULL, do_lang_tempcode('ACCEPTED_MEDIA_TYPES')));
     $fields->attach(form_input_tick(do_lang_tempcode('FLOW_MODE_INTERFACE'), do_lang_tempcode('DESCRIPTION_FLOW_MODE_INTERFACE'), 'flow_mode_interface', $flow_mode_interface == 1));
     $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => $rep_image == '' && $teaser == '' && $is_member_synched == 0, 'TITLE' => do_lang_tempcode('ADVANCED'))));
     $fields->attach(form_input_upload(do_lang_tempcode('REPRESENTATIVE_IMAGE'), do_lang_tempcode('DESCRIPTION_REPRESENTATIVE_IMAGE_GALLERY'), 'rep_image', false, $rep_image, NULL, true, str_replace(' ', '', get_option('valid_images'))));
     // Only show tease option if tease block being used
     $teaser_shows = false;
     $zones = find_all_zones(false, true);
     $pages = array();
     foreach ($zones as $_zone) {
         $pages[$_zone[0]] = find_all_pages_wrap($_zone[0], true);
     }
     foreach ($pages as $zone => $under) {
         foreach ($under as $filename => $type) {
             if (substr(strtolower($filename), -4) == '.txt') {
                 $matches = array();
                 $contents = file_get_contents(zone_black_magic_filterer((substr($type, 0, 15) == 'comcode_custom/' ? get_custom_file_base() : get_file_base()) . '/' . ($zone == '' ? '' : $zone . '/') . 'pages/' . $type . '/' . $filename));
                 $fallback = get_file_base() . '/' . ($zone == '' ? '' : $zone . '/') . 'pages/comcode/' . fallback_lang() . '/' . $filename;
                 if (file_exists($fallback)) {
                     $contents .= file_get_contents($fallback);
                 }
                 if (preg_match('#\\[block[^\\]]*\\]main_gallery_tease\\[/block\\]#', $contents, $matches) != 0) {
                     $teaser_shows = true;
                 }
             }
         }
     }
     if ($teaser_shows) {
         $fields->attach(form_input_line_comcode(do_lang_tempcode('TEASER'), do_lang_tempcode('DESCRIPTION_TEASER'), 'teaser', $teaser, false));
     }
     $fields->attach(form_input_tick(do_lang_tempcode('IS_MEMBER_SYNCHED'), do_lang_tempcode('DESCRIPTION_IS_MEMBER_SYNCHED_GALLERY'), 'is_member_synched', $is_member_synched == 1));
     $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => is_null($watermark_top_left) && is_null($watermark_top_right) && is_null($watermark_bottom_left) && is_null($watermark_bottom_right), 'TITLE' => do_lang_tempcode('WATERMARKING'))));
     $fields->attach(form_input_upload(do_lang_tempcode('_WATERMARK', do_lang_tempcode('TOP_LEFT')), do_lang_tempcode('_DESCRIPTION_WATERMARK', do_lang_tempcode('TOP_LEFT')), 'watermark_top_left', false, $watermark_top_left, NULL, true, str_replace(' ', '', get_option('valid_images'))));
     $fields->attach(form_input_upload(do_lang_tempcode('_WATERMARK', do_lang_tempcode('TOP_RIGHT')), do_lang_tempcode('_DESCRIPTION_WATERMARK', do_lang_tempcode('TOP_RIGHT')), 'watermark_top_right', false, $watermark_top_right, NULL, true, str_replace(' ', '', get_option('valid_images'))));
     $fields->attach(form_input_upload(do_lang_tempcode('_WATERMARK', do_lang_tempcode('BOTTOM_LEFT')), do_lang_tempcode('_DESCRIPTION_WATERMARK', do_lang_tempcode('BOTTOM_LEFT')), 'watermark_bottom_left', false, $watermark_bottom_left, NULL, true, str_replace(' ', '', get_option('valid_images'))));
     $fields->attach(form_input_upload(do_lang_tempcode('_WATERMARK', do_lang_tempcode('BOTTOM_RIGHT')), do_lang_tempcode('_DESCRIPTION_WATERMARK', do_lang_tempcode('BOTTOM_RIGHT')), 'watermark_bottom_right', false, $watermark_bottom_right, NULL, true, str_replace(' ', '', get_option('valid_images'))));
     $hidden = new ocp_tempcode();
     handle_max_file_size($hidden, 'image');
     require_code('feedback2');
     $fields->attach(feedback_fields($allow_rating == 1, $allow_comments == 1, NULL, false, $notes, $allow_comments == 2, true));
     // Permissions
     $fields->attach($this->get_permission_fields($name, NULL, $name == ''));
     return array($fields, $hidden);
 }
Example #12
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)
  * @param  boolean		Whether this is for a new entry
  * @return ?tempcode		The Tempcode for the input field (NULL: skip the field - it's not input)
  */
 function get_field_inputter($_cf_name, $_cf_description, $field, $actual_value, $new)
 {
     if (is_null($actual_value)) {
         $actual_value = '';
     }
     // Plug anomaly due to unusual corruption
     return form_input_codename($_cf_name, $_cf_description, 'field_' . strval($field['id']), $actual_value, $field['cf_required'] == 1);
 }
Example #13
0
 /**
  * The UI to take details on a manually triggered transaction.
  *
  * @return tempcode	The UI.
  */
 function trigger()
 {
     $title = get_page_title('MANUAL_TRANSACTION');
     require_code('form_templates');
     $fields = new ocp_tempcode();
     // Choose product
     $item_name = get_param('item_name', NULL);
     if (is_null($item_name)) {
         breadcrumb_set_self(do_lang_tempcode('PRODUCT'));
         breadcrumb_set_parents(array(array('_SELF:_SELF:ecom_usage', do_lang_tempcode('ECOMMERCE'))));
         $products = find_all_products();
         $list = new ocp_tempcode();
         foreach ($products as $product => $details) {
             $list->attach(form_input_list_entry($product, do_lang('CUSTOM_PRODUCT_' . $product, NULL, NULL, NULL, NULL, false) == get_param('product', NULL), $details[4]));
         }
         $fields->attach(form_input_list(do_lang_tempcode('PRODUCT'), '', 'item_name', $list));
         $submit_name = do_lang('CHOOSE');
         return do_template('FORM_SCREEN', array('TITLE' => $title, 'SUBMIT_NAME' => $submit_name, 'FIELDS' => $fields, 'TEXT' => '', 'URL' => get_self_url(), 'GET' => true, 'HIDDEN' => ''));
     }
     breadcrumb_set_parents(array(array('_SELF:_SELF:ecom_usage', do_lang_tempcode('ECOMMERCE')), array('_SELF:_SELF:trigger', do_lang_tempcode('PRODUCT'))));
     $post_url = build_url(array('page' => '_SELF', 'type' => '_trigger', 'redirect' => get_param('redirect', NULL)), '_SELF');
     $text = do_lang('MANUAL_TRANSACTION_TEXT');
     $submit_name = do_lang('MANUAL_TRANSACTION');
     $product_ob = find_product($item_name);
     // To work out key
     if (post_param_integer('got_purchase_key_dependencies', 0) == 0) {
         $needed_fields = method_exists($product_ob, 'get_needed_fields') ? $product_ob->get_needed_fields($item_name) : NULL;
         if (!is_null($needed_fields)) {
             $submit_name = do_lang('PROCEED');
             $extra_hidden = new ocp_tempcode();
             $extra_hidden->attach(form_input_hidden('got_purchase_key_dependencies', '1'));
             if (is_array($needed_fields)) {
                 $extra_hidden->attach($needed_fields[0]);
             }
             return do_template('FORM_SCREEN', array('TITLE' => $title, 'SUBMIT_NAME' => $submit_name, 'FIELDS' => is_array($needed_fields) ? $needed_fields[1] : $needed_fields, 'TEXT' => '', 'URL' => get_self_url(), 'HIDDEN' => $extra_hidden));
         }
     }
     $default_purchase_id = get_param('id', NULL);
     if (is_null($default_purchase_id)) {
         if (method_exists($product_ob, 'set_needed_fields')) {
             $default_purchase_id = $product_ob->set_needed_fields($item_name);
         } else {
             $default_purchase_id = strval(get_member());
         }
     }
     // Remaining fields, customised for product chosen
     if (method_exists($product_ob, 'get_identifier_manual_field_inputter')) {
         $f = $product_ob->get_identifier_manual_field_inputter($item_name);
         if (!is_null($f)) {
             $fields->attach($f);
         }
     } else {
         $fields->attach(form_input_codename(do_lang_tempcode('IDENTIFIER'), do_lang('MANUAL_TRANSACTION_IDENTIFIER'), 'purchase_id', $default_purchase_id, false));
     }
     $fields->attach(form_input_text(do_lang_tempcode('NOTES'), do_lang('TRANSACTION_NOTES'), 'memo', '', false));
     $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('ADVANCED'))));
     $fields->attach(form_input_float(do_lang_tempcode('AMOUNT'), do_lang_tempcode('MONEY_AMOUNT_DESCRIPTION', ecommerce_get_currency_symbol()), 'amount', NULL, false));
     $hidden = new ocp_tempcode();
     $hidden->attach(form_input_hidden('item_name', $item_name));
     return do_template('FORM_SCREEN', array('_GUID' => '990d955cb14b6681685ec9e1d1448d9d', 'TITLE' => $title, 'SUBMIT_NAME' => $submit_name, 'FIELDS' => $fields, 'TEXT' => $text, 'URL' => $post_url, 'HIDDEN' => $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);
}