/** * 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('AVATAR'); $order = 20; // Actualiser if (post_param_integer('submitting_avatar_tab', 0) == 1) { require_code('uploads'); if (has_specific_permission($member_id_viewing, 'own_avatars')) { if (!(is_swf_upload(true) && array_key_exists('avatar_file', $_FILES) || array_key_exists('avatar_file', $_FILES) && is_uploaded_file($_FILES['avatar_file']['tmp_name']))) { $urls = array(); $stock = post_param('avatar_alt_url', ''); if ($stock == '') { $stock = post_param('avatar_stock', NULL); if (!is_null($stock)) { $urls[0] = $stock == '' ? '' : find_theme_image($stock, false, true); } else { $urls[0] = ''; } // None } else { if (url_is_local($stock) && !$GLOBALS['FORUM_DRIVER']->is_super_admin($member_id_viewing)) { $old = $GLOBALS['FORUM_DB']->query_value('f_members', 'm_avatar_url', array('id' => $member_id_of)); if ($old != $stock) { access_denied('ASSOCIATE_EXISTING_FILE'); } } $urls[0] = $stock; // URL } } else { // We have chosen an upload. Note that we will not be looking at alt_url at this point, even though it is specified below for canonical reasons $urls = get_url('avatar_alt_url', 'avatar_file', file_exists(get_custom_file_base() . '/uploads/avatars') ? 'uploads/avatars' : 'uploads/ocf_avatars', 0, OCP_UPLOAD_IMAGE, false, '', '', false, true); if ((get_base_url() != get_forum_base_url() || array_key_exists('on_msn', $GLOBALS['SITE_INFO']) && $GLOBALS['SITE_INFO']['on_msn'] == '1') && $urls[0] != '' && url_is_local($urls[0])) { $urls[0] = get_custom_base_url() . '/' . $urls[0]; } } $avatar_url = $urls[0]; } else { $stock = post_param('avatar_stock'); $avatar_url = $stock == '' ? '' : find_theme_image($stock, false, true); } require_code('ocf_members_action'); require_code('ocf_members_action2'); ocf_member_choose_avatar($avatar_url, $member_id_of); attach_message(do_lang_tempcode('SUCCESS_SAVE'), 'inform'); } if ($leave_to_ajax_if_possible) { return NULL; } // UI fields $avatar_url = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_avatar_url'); require_javascript('javascript_multi'); $fields = new ocp_tempcode(); require_code('form_templates'); require_code('themes2'); $ids = get_all_image_ids_type('ocf_default_avatars', true); $found_it = false; foreach ($ids as $id) { $pos = strpos($avatar_url, '/' . $id); $selected = $pos !== false; if ($selected) { $found_it = true; } } $hidden = new ocp_tempcode(); if (has_specific_permission($member_id_viewing, 'own_avatars')) { $javascript = 'standardAlternateFields(\'avatar_file\',\'avatar_alt_url\',\'avatar_stock*\',true);'; $fields->attach(form_input_upload(do_lang_tempcode('UPLOAD'), do_lang_tempcode('DESCRIPTION_UPLOAD'), 'avatar_file', false, NULL, NULL, true, str_replace(' ', '', get_option('valid_images')))); handle_max_file_size($hidden, 'image'); $fields->attach(form_input_line(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('URL')), do_lang_tempcode('DESCRIPTION_ALTERNATE_URL'), 'avatar_alt_url', $found_it ? '' : $avatar_url, false)); $fields->attach(form_input_picture_choose_specific(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('STOCK')), do_lang_tempcode('DESCRIPTION_ALTERNATE_STOCK'), 'avatar_stock', $ids, $avatar_url, NULL, NULL, true)); } else { $javascript = ''; $fields->attach(form_input_picture_choose_specific(do_lang_tempcode('STOCK'), '', 'avatar_stock', $ids, $avatar_url, NULL, NULL, true)); } if ($avatar_url != '') { if (url_is_local($avatar_url)) { $avatar_url = get_complex_base_url($avatar_url) . '/' . $avatar_url; } $avatar = do_template('OCF_TOPIC_POST_AVATAR', array('_GUID' => '50a5902f3ab7e384d9cf99577b222cc8', 'AVATAR' => $avatar_url)); } else { $avatar = do_lang_tempcode('NONE_EM'); } $width = ocf_get_member_best_group_property($member_id_of, 'max_avatar_width'); $height = ocf_get_member_best_group_property($member_id_of, 'max_avatar_height'); $text = do_template('OCF_EDIT_AVATAR_TAB', array('_GUID' => 'dbdac6ca3bc752b54d2a24a4c6e69c7c', 'MEMBER_ID' => strval($member_id_of), 'USERNAME' => $GLOBALS['FORUM_DRIVER']->get_username($member_id_of), 'AVATAR' => $avatar, 'WIDTH' => integer_format($width), 'HEIGHT' => integer_format($height))); $hidden = new ocp_tempcode(); $hidden->attach(form_input_hidden('submitting_avatar_tab', '1')); return array($title, $fields, $text, $javascript, $order, $hidden); }
/** * Get tempcode for a dropdown to choose a theme from the themes present. * * @param ?ID_TEXT The currently selected image ID (NULL: none selected) * @param ?string An SQL where clause (including the WHERE), that filters the query somehow (NULL: none) * @param boolean Whether to show IDs as the list entry captions, rather than paths * @param boolean Whether to include images not yet used (i.e not in theme_images map yet) * @return tempcode Tempcode for a list selection of theme images * @param string Only include images under this path. Including a trailing slash unless you specifically want to filter allowing filename stubs as well as paths (blank: no limitation) */ function nice_get_theme_images($it = NULL, $filter = NULL, $do_id = false, $include_all = false, $under = '') { $out = new ocp_tempcode(); if (!$include_all) { $rows = $GLOBALS['SITE_DB']->query('SELECT id,path FROM ' . get_table_prefix() . 'theme_images WHERE ' . db_string_equal_to('theme', $GLOBALS['FORUM_DRIVER']->get_theme()) . ' ' . $filter . ' ORDER BY path'); foreach ($rows as $myrow) { $id = $myrow['id']; if (substr($id, 0, strlen($under)) != $under) { continue; } $selected = $id == $it; $out->attach(form_input_list_entry($id, $selected, $do_id ? $id : $myrow['path'])); } } else { $rows = get_all_image_ids_type($under, true); foreach ($rows as $id) { if (substr($id, 0, strlen($under)) != $under) { continue; } $selected = $id == $it; $out->attach(form_input_list_entry($id, $selected)); } } return $out; }
/** * Add a member. * * @param SHORT_TEXT The username. * @param SHORT_TEXT The password. * @param SHORT_TEXT The e-mail address. * @param ?array A list of usergroups (NULL: default/current usergroups). * @param ?integer Day of date of birth (NULL: unknown). * @param ?integer Month of date of birth (NULL: unknown). * @param ?integer Year of date of birth (NULL: unknown). * @param array A map of custom field values (field-id=>value). * @param ?ID_TEXT The member timezone (NULL: auto-detect). * @param ?GROUP The member's primary (NULL: default). * @param BINARY Whether the profile has been validated. * @param ?TIME When the member joined (NULL: now). * @param ?TIME When the member last visited (NULL: now). * @param ID_TEXT The member's default theme. * @param ?URLPATH The URL to the member's avatar (blank: none) (NULL: choose one automatically). * @param LONG_TEXT The member's signature (blank: none). * @param BINARY Whether the member is permanently banned. * @param BINARY Whether posts are previewed before they are made. * @param BINARY Whether the member's age may be shown. * @param SHORT_TEXT The member's title (blank: get from primary). * @param URLPATH The URL to the member's photo (blank: none). * @param URLPATH The URL to the member's photo thumbnail (blank: none). * @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 member's 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 LONG_TEXT Personal notes of the member. * @param ?IP The member's IP address (NULL: IP address of current user). * @param SHORT_TEXT The code required before the account becomes active (blank: already entered). * @param boolean Whether to check details for correctness. * @param ?ID_TEXT The compatibility scheme that the password operates in (blank: none) (NULL: none [meaning normal ocPortal salted style] or plain, depending on whether passwords are encrypted). * @param SHORT_TEXT The password salt (blank: password compatibility scheme does not use a salt / auto-generate). * @param BINARY Whether the member likes to view zones without menus, when a choice is available. * @param ?TIME The time the member last made a submission (NULL: set to now). * @param ?AUTO_LINK Force an ID (NULL: don't force an ID) * @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. * @return AUTO_LINK The ID of the new member. */ function ocf_make_member($username, $password, $email_address, $secondary_groups, $dob_day, $dob_month, $dob_year, $custom_fields, $timezone = NULL, $primary_group = NULL, $validated = 1, $join_time = NULL, $last_visit_time = NULL, $theme = '', $avatar_url = NULL, $signature = '', $is_perm_banned = 0, $preview_posts = 0, $reveal_age = 1, $title = '', $photo_url = '', $photo_thumb_url = '', $views_signatures = 1, $auto_monitor_contrib_content = NULL, $language = NULL, $allow_emails = 1, $allow_emails_from_staff = 1, $personal_notes = '', $ip_address = NULL, $validated_email_confirm_code = '', $check_correctness = true, $password_compatibility_scheme = NULL, $salt = '', $zone_wide = 1, $last_submit_time = NULL, $id = NULL, $highlighted_name = 0, $pt_allow = '*', $pt_rules_text = '') { if (is_null($auto_monitor_contrib_content)) { $auto_monitor_contrib_content = get_value('no_auto_notifications') === '1' ? 0 : 1; } if (is_null($password_compatibility_scheme)) { if (get_value('no_password_hashing') === '1') { $password_compatibility_scheme = 'plain'; } else { $password_compatibility_scheme = ''; } } if (is_null($language)) { $language = ''; } if (is_null($signature)) { $signature = ''; } if (is_null($title)) { $title = ''; } if (is_null($timezone)) { $timezone = get_site_timezone(); } if (is_null($allow_emails)) { $allow_emails = 1; } if (is_null($allow_emails_from_staff)) { $allow_emails_from_staff = 1; } if (is_null($personal_notes)) { $personal_notes = ''; } if (is_null($avatar_url)) { if ($GLOBALS['IN_MINIKERNEL_VERSION'] == 1 || !addon_installed('ocf_member_avatars')) { $avatar_url = ''; } else { if (get_option('random_avatars') == '1' && !running_script('stress_test_loader')) { require_code('themes2'); $codes = get_all_image_ids_type('ocf_default_avatars/default_set', false, $GLOBALS['FORUM_DB']); shuffle($codes); $results = array(); foreach ($codes as $code) { if (strpos($code, 'ocp_fanatic') !== false) { continue; } $count = $GLOBALS['FORUM_DB']->query_value_null_ok_full('SELECT SUM(m_cache_num_posts) FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE ' . db_string_equal_to('m_avatar_url', find_theme_image($code, false, true))); if (is_null($count)) { $count = 0; } $results[$code] = $count; } @asort($results); // @'d as type checker fails for some odd reason $found_avatars = array_keys($results); $avatar_url = find_theme_image(array_shift($found_avatars), true, true); } if (is_null($avatar_url)) { $GLOBALS['SITE_DB']->query_delete('theme_images', array('id' => 'ocf_default_avatars/default', 'path' => '')); // In case failure cached, gets very confusing $avatar_url = find_theme_image('ocf_default_avatars/default', true, true); if (is_null($avatar_url)) { $avatar_url = ''; } } } } if ($check_correctness) { if (!in_array($password_compatibility_scheme, array('ldap', 'httpauth'))) { ocf_check_name_valid($username, NULL, $password_compatibility_scheme == '' ? $password : NULL); } if (!function_exists('has_actual_page_access') || !has_actual_page_access(get_member(), 'admin_ocf_join')) { require_code('type_validation'); if (!is_valid_email_address($email_address) && $email_address != '') { warn_exit(do_lang_tempcode('_INVALID_EMAIL_ADDRESS', escape_html($email_address))); } } } require_code('ocf_members'); require_code('ocf_groups'); if (is_null($last_submit_time)) { $last_submit_time = time(); } if (is_null($join_time)) { $join_time = time(); } if (is_null($last_visit_time)) { $last_visit_time = time(); } if (is_null($primary_group)) { $primary_group = get_first_default_group(); // This is members } if (is_null($secondary_groups)) { $secondary_groups = ocf_get_all_default_groups(false); } foreach ($secondary_groups as $_g_id => $g_id) { if ($g_id == $primary_group) { unset($secondary_groups[$_g_id]); } } if (is_null($ip_address)) { $ip_address = get_ip_address(); } if ($password_compatibility_scheme == '' && get_value('no_password_hashing') === '1') { $password_compatibility_scheme = 'plain'; $salt = ''; } if ($salt == '' && $password_compatibility_scheme == '') { $salt = produce_salt(); $password_salted = md5($salt . md5($password)); } else { $password_salted = $password; } // Supplement custom field values given with defaults, and check constraints $all_fields = list_to_map('id', ocf_get_all_custom_fields_match($secondary_groups)); require_code('fields'); foreach ($all_fields as $field) { $field_id = $field['id']; if (array_key_exists($field_id, $custom_fields)) { if ($check_correctness && $field[array_key_exists('cf_show_on_join_form', $field) ? 'cf_show_on_join_form' : 'cf_required'] == 0 && $field['cf_owner_set'] == 0 && !has_actual_page_access(get_member(), 'admin_ocf_join')) { access_denied('I_ERROR'); } } else { $custom_fields[$field_id] = ''; } } if (!addon_installed('unvalidated')) { $validated = 1; } $map = array('m_username' => $username, 'm_pass_hash_salted' => $password_salted, 'm_pass_salt' => $salt, 'm_theme' => $theme, 'm_avatar_url' => $avatar_url, 'm_validated' => $validated, 'm_validated_email_confirm_code' => $validated_email_confirm_code, 'm_cache_num_posts' => 0, 'm_cache_warnings' => 0, 'm_max_email_attach_size_mb' => 5, 'm_join_time' => $join_time, 'm_timezone_offset' => $timezone, 'm_primary_group' => $primary_group, 'm_last_visit_time' => $last_visit_time, 'm_last_submit_time' => $last_submit_time, 'm_signature' => insert_lang_comcode($signature, 4, $GLOBALS['FORUM_DB']), 'm_is_perm_banned' => $is_perm_banned, 'm_preview_posts' => $preview_posts, 'm_notes' => $personal_notes, 'm_dob_day' => $dob_day, 'm_dob_month' => $dob_month, 'm_dob_year' => $dob_year, 'm_reveal_age' => $reveal_age, 'm_email_address' => $email_address, 'm_title' => $title, 'm_photo_url' => $photo_url, 'm_photo_thumb_url' => $photo_thumb_url, 'm_views_signatures' => $views_signatures, 'm_auto_monitor_contrib_content' => $auto_monitor_contrib_content, 'm_highlighted_name' => $highlighted_name, 'm_pt_allow' => $pt_allow, 'm_pt_rules_text' => insert_lang_comcode($pt_rules_text, 4, $GLOBALS['FORUM_DB']), 'm_language' => $language, 'm_ip_address' => $ip_address, 'm_zone_wide' => $zone_wide, 'm_allow_emails' => $allow_emails, 'm_allow_emails_from_staff' => $allow_emails_from_staff, 'm_password_change_code' => '', 'm_password_compat_scheme' => $password_compatibility_scheme, 'm_on_probation_until' => NULL); if (!is_null($id)) { $map['id'] = $id; } $member_id = $GLOBALS['FORUM_DB']->query_insert('f_members', $map, true); if ($check_correctness) { // If it was an invite/recommendation, award the referrer if (addon_installed('recommend')) { $inviter = $GLOBALS['FORUM_DB']->query_value_null_ok('f_invites', 'i_inviter', array('i_email_address' => $email_address), 'ORDER BY i_time'); if (!is_null($inviter)) { if (addon_installed('points')) { require_code('points2'); require_lang('recommend'); system_gift_transfer(do_lang('RECOMMEND_SITE_TO', $username, get_site_name()), intval(get_option('points_RECOMMEND_SITE')), $inviter); } if (addon_installed('chat')) { require_code('chat2'); buddy_add($inviter, $member_id); buddy_add($member_id, $inviter); } } } } $value = mixed(); // Store custom fields $row = array('mf_member_id' => $member_id); $all_fields_types = collapse_2d_complexity('id', 'cf_type', $all_fields); foreach ($custom_fields as $field_num => $value) { if (!array_key_exists($field_num, $all_fields_types)) { continue; } // Trying to set a field we're not allowed to (doesn't apply to our group) $ob = get_fields_hook($all_fields_types[$field_num]); list(, , $storage_type) = $ob->get_field_value_row_bits($all_fields[$field_num]); if (strpos($storage_type, '_trans') !== false) { $value = insert_lang($value, 3, $GLOBALS['FORUM_DB']); } $row['field_' . strval($field_num)] = $value; } // Set custom field row $all_fields_regardless = $GLOBALS['FORUM_DB']->query_select('f_custom_fields', array('id', 'cf_type')); foreach ($all_fields_regardless as $field) { if (!array_key_exists('field_' . strval($field['id']), $row)) { $ob = get_fields_hook($field['cf_type']); list(, , $storage_type) = $ob->get_field_value_row_bits($field); $value = ''; if (strpos($storage_type, '_trans') !== false) { $value = insert_lang($value, 3, $GLOBALS['FORUM_DB']); } $row['field_' . strval($field['id'])] = $value; } } $GLOBALS['FORUM_DB']->query_insert('f_member_custom_fields', $row); // Any secondary work foreach ($secondary_groups as $g) { if ($g != $primary_group) { $GLOBALS['FORUM_DB']->query_delete('f_group_members', array('gm_member_id' => $member_id, 'gm_group_id' => $g), '', 1); $GLOBALS['FORUM_DB']->query_insert('f_group_members', array('gm_group_id' => $g, 'gm_member_id' => $member_id, 'gm_validated' => 1)); } } if ($check_correctness) { if (function_exists('decache')) { decache('side_stats'); } } return $member_id; }
/** * Get tempcode for a post template adding/editing form. * * @param SHORT_TEXT The emoticon code * @param SHORT_TEXT The theme image code * @param integer The relevance level of the emoticon * @range 0 4 * @param BINARY Whether the emoticon is usable as a topic emoticon * @param BINARY Whether this may only be used by privileged members * @return array A pair: The input fields, Hidden fields */ function get_form_fields($code = ':-]', $theme_img_code = '', $relevance_level = 1, $use_topics = 1, $is_special = 0) { $fields = new ocp_tempcode(); $hidden = new ocp_tempcode(); $fields->attach(form_input_line(do_lang_tempcode('CODE'), do_lang_tempcode('DESCRIPTION_EMOTICON_CODE'), 'code', $code, true)); if (get_base_url() == get_forum_base_url()) { $fields->attach(form_input_upload(do_lang_tempcode('UPLOAD'), do_lang_tempcode('DESCRIPTION_UPLOAD'), 'file', false, NULL, NULL, true, str_replace(' ', '', get_option('valid_images')))); handle_max_file_size($hidden, 'image'); } require_code('themes2'); $ids = get_all_image_ids_type('ocf_emoticons', 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, $theme_img_code, NULL, true, $GLOBALS['FORUM_DB'])); $list = new ocp_tempcode(); for ($i = 0; $i <= 4; $i++) { $list->attach(form_input_list_entry(strval($i), $i == $relevance_level, do_lang_tempcode('EMOTICON_RELEVANCE_LEVEL_' . strval($i)))); } $fields->attach(form_input_list(do_lang_tempcode('RELEVANCE_LEVEL'), do_lang_tempcode('DESCRIPTION_RELEVANCE_LEVEL'), 'relevance_level', $list)); $fields->attach(form_input_tick(do_lang_tempcode('USE_TOPICS'), do_lang_tempcode('DESCRIPTION_USE_TOPICS'), 'use_topics', $use_topics == 1)); $fields->attach(form_input_tick(do_lang_tempcode('EMOTICON_IS_SPECIAL'), do_lang_tempcode('DESCRIPTION_EMOTICON_IS_SPECIAL'), 'is_special', $is_special == 1)); return array($fields, $hidden); }
/** * Get tempcode for a zone adding/editing form. * * @param boolean Whether the zone editor will be used * @param SHORT_TEXT The zone title * @param ID_TEXT The zones default page * @param SHORT_TEXT The header text * @param ?ID_TEXT The theme (NULL: no override) * @param BINARY Whether the zone is wide * @param BINARY Whether the zone requires a session for pages to be used * @param BINARY Whether the zone in displayed in the menu coded into some themes * @param ?ID_TEXT Name of the zone (NULL: unknown) * @return array A tuple: The tempcode for the fields, hidden fields, and extra Javascript */ function get_form_fields($in_zone_editor = false, $title = '', $default_page = 'start', $header_text = '', $theme = NULL, $wide = 0, $require_session = 0, $displayed_in_menu = 1, $zone = NULL) { require_lang('permissions'); $javascript = ''; $fields = ''; $hidden = new ocp_tempcode(); require_code('form_templates'); $fields .= static_evaluate_tempcode(form_input_line(do_lang_tempcode('TITLE'), do_lang_tempcode('DESCRIPTION_TITLE'), 'title', $title, true)); $fields .= static_evaluate_tempcode(form_input_line(do_lang_tempcode('DEFAULT_PAGE'), do_lang_tempcode('DESCRIPTION_DEFAULT_PAGE'), 'default_page', $default_page, true)); $fields .= static_evaluate_tempcode(form_input_line(do_lang_tempcode('HEADER_TEXT'), do_lang_tempcode('DESCRIPTION_HEADER_TEXT'), 'header_text', $header_text, false)); $list = ''; $list .= static_evaluate_tempcode(form_input_list_entry('0', $wide == 0, do_lang_tempcode('NO'))); $list .= static_evaluate_tempcode(form_input_list_entry('1', $wide == 1, do_lang_tempcode('YES'))); $list .= static_evaluate_tempcode(form_input_list_entry('-1', is_null($wide), do_lang_tempcode('RELY_FORUMS'))); $fields .= static_evaluate_tempcode(form_input_list(do_lang_tempcode('WIDE'), do_lang_tempcode('DESCRIPTION_WIDE'), 'wide', make_string_tempcode($list))); $fields .= static_evaluate_tempcode(form_input_tick(do_lang_tempcode('DISPLAYED_IN_MENU'), do_lang_tempcode('DESCRIPTION_DISPLAYED_IN_MENU'), 'displayed_in_menu', $displayed_in_menu == 1)); // Theme require_code('themes2'); $entries = nice_get_themes($theme, false, true); $fields .= static_evaluate_tempcode(form_input_list(do_lang_tempcode('THEME'), do_lang_tempcode(get_forum_type() == 'ocf' ? '_DESCRIPTION_THEME_OCF' : '_DESCRIPTION_THEME', substr(preg_replace('#[^A-Za-z\\d]#', '_', get_site_name()), 0, 80)), 'theme', $entries)); $fields .= static_evaluate_tempcode(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('ADVANCED')))); $fields .= static_evaluate_tempcode(form_input_tick(do_lang_tempcode('REQUIRE_SESSION'), do_lang_tempcode('DESCRIPTION_REQUIRE_SESSION'), 'require_session', $require_session == 1)); if (!$in_zone_editor && !is_null($zone) && addon_installed('zone_logos')) { // Logos handle_max_file_size($hidden, 'image'); require_code('themes2'); $themes = find_all_themes(); foreach ($themes as $theme => $theme_name) { $fields .= static_evaluate_tempcode(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => true, 'TITLE' => do_lang_tempcode('THEME_LOGO', escape_html($theme_name))))); $fields .= static_evaluate_tempcode(form_input_upload(do_lang_tempcode('IMAGE'), do_lang_tempcode('DESCRIPTION_UPLOAD'), 'logo_upload_' . $theme, false, NULL, NULL, true, str_replace(' ', '', get_option('valid_images')))); require_code('themes2'); $ids = get_all_image_ids_type('logo', false, NULL, $theme); $current_logo = 'logo/' . $zone . '-logo'; if (!in_array($current_logo, $ids)) { $current_logo = 'logo/-logo'; } foreach ($ids as $id) { $test = find_theme_image($id, true, false, $theme); if ($test == '') { $test = find_theme_image($id, false, false, 'default'); } if ($test == '' && $id == $current_logo) { $current_logo = $ids[0]; } } $fields .= static_evaluate_tempcode(form_input_picture_choose_specific(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('STOCK')), do_lang_tempcode('DESCRIPTION_ALTERNATE_STOCK'), 'logo_select_' . $theme, $ids, NULL, $current_logo, NULL, true, NULL, $theme)); $javascript .= 'standardAlternateFields(\'logo_upload_' . $theme . '\',\'logo_select_' . $theme . '*\');'; } } if ($zone !== '') { $fields .= static_evaluate_tempcode(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('PERMISSIONS')))); // Permissions $admin_groups = $GLOBALS['FORUM_DRIVER']->get_super_admin_groups(); $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true); foreach ($groups as $id => $name) { if (in_array($id, $admin_groups)) { continue; } $perhaps = is_null($zone) ? true : $GLOBALS['SITE_DB']->query_value_null_ok('group_zone_access', 'zone_name', array('zone_name' => $zone, 'group_id' => $id)); $fields .= static_evaluate_tempcode(form_input_tick(do_lang_tempcode('ACCESS_FOR', escape_html($name)), do_lang_tempcode('DESCRIPTION_ACCESS_FOR', escape_html($name)), 'access_' . strval($id), !is_null($perhaps))); } } return array(make_string_tempcode($fields), $hidden, $javascript); }
/** * The UI to select a theme image to edit. * * @return tempcode The UI */ function manage_images() { $title = get_page_title('MANAGE_THEME_IMAGES'); if (function_exists('set_time_limit')) { @set_time_limit(300); } $lang = choose_language($title, true, true); if (is_object($lang)) { return $lang; } $theme = get_param('theme', ''); if ($theme == '') { return $this->choose_theme($title, true); } //if ((get_file_base()!=get_custom_file_base()) && ($theme=='default')) warn_exit(do_lang_tempcode('SHARED_INSTALL_PROHIBIT')); require_code('themes3'); regen_theme_images($theme, array($lang => 1)); if ($theme != 'default') { regen_theme_images('default', array($lang => 1), $theme); } // Choose image to edit require_code('form_templates'); /*$where_map=array('theme'=>$theme); if ($lang!='') $where_map['lang']=$lang; $images=$GLOBALS['SITE_DB']->query_select('theme_images',array('DISTINCT id'),$where_map); $list=''; foreach ($images as $row) { $temp=form_input_list_entry($row['id'],false); $list.=$temp->evaluate(); // XHTMLXHTML } $fields=form_input_huge_list(do_lang_tempcode('CODENAME'),'','id',make_string_tempcode($list),NULL,true,true,725);*/ require_code('themes2'); $ids = get_all_image_ids_type('', true, $GLOBALS['SITE_DB'], $theme, false, true); // The final 'true' stops new theme images being detected, as we know regen_theme_images did that (and more conservatively - it won't scan images_custom dirs for NEW codes which an unbridled get_all_image_ids_type call would) $fields = form_input_picture_choose_specific(do_lang_tempcode('IMAGE'), '', 'id', $ids, NULL, NULL, NULL, false, NULL, $theme, $lang, true); $hidden = form_input_hidden('theme', $theme); $post_url = build_url(array('page' => '_SELF', 'type' => 'edit_image', 'lang' => $lang), '_SELF'); $edit_form = do_template('FORM', array('_GUID' => '48b3218750fcea21e0bf3be31ae58296', 'HIDDEN' => $hidden, 'TEXT' => do_lang_tempcode('CHOOSE_EDIT_LIST'), 'GET' => true, 'URL' => $post_url, 'FIELDS' => $fields, 'SUBMIT_NAME' => do_lang_tempcode('CHOOSE'))); $add_url = build_url(array('page' => '_SELF', 'type' => 'add_image', 'theme' => $theme, 'lang' => $lang), '_SELF'); breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('MANAGE_THEMES')))); breadcrumb_set_self(do_lang_tempcode('CHOOSE')); return do_template('THEME_IMAGE_MANAGE_SCREEN', array('_GUID' => '4e760b0aa59b1bbb6fcf289c0b93ec46', 'ADD_URL' => $add_url, 'TITLE' => $title, 'FORM' => $edit_form)); }
/** * Get form inputter. * * @param string The field name * @param string The field description * @param array The field details * @param ?string The actual current value of the field (NULL: none) * @param boolean Whether this is for a new entry * @return ?tempcode The Tempcode for the input field (NULL: skip the field - it's not input) */ function get_field_inputter($_cf_name, $_cf_description, $field, $actual_value, $new) { $ids = get_all_image_ids_type(substr($field['cf_type'], 3), true); return form_input_picture_choose_specific($_cf_name, $_cf_description, 'field_' . strval($field['id']), $ids, NULL, $actual_value, NULL, $field['cf_required'] == 0); }
/** * Get tempcode for a news category adding/editing form. * * @param SHORT_TEXT The title of the news category * @param SHORT_TEXT The news category image * @param LONG_TEXT Notes relating to the news category * @param ?MEMBER The owner of the news category (NULL: public) * @param ?AUTO_LINK The ID of this news category (NULL: we haven't added it yet) * @return array A pair: The input fields, Hidden fields */ function get_form_fields($title = '', $img = '', $notes = '', $owner = NULL, $category_id = NULL) { $fields = 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 (get_base_url() == get_forum_base_url()) { $fields->attach(form_input_upload(do_lang_tempcode('IMAGE'), do_lang_tempcode('DESCRIPTION_UPLOAD'), 'file', false, NULL, NULL, true, str_replace(' ', '', get_option('valid_images')))); handle_max_file_size($hidden, 'image'); } require_code('themes2'); $ids = get_all_image_ids_type('newscats'); $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, $img, NULL, true)); if (!is_null($owner)) { $owner_username = $GLOBALS['FORUM_DRIVER']->get_username($owner); if (is_null($owner_username)) { $owner_username = do_lang('UNKNOWN'); } $fields->attach(form_input_line(do_lang_tempcode('OWNER'), do_lang_tempcode('DESCRIPTION_OWNER'), 'owner', $owner_username, true)); } if (get_value('disable_staff_notes') !== '1') { $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => $notes == '', 'TITLE' => do_lang_tempcode('ADVANCED')))); $fields->attach(form_input_text(do_lang_tempcode('NOTES'), do_lang_tempcode('DESCRIPTION_NOTES'), 'notes', $notes, false)); } $fields->attach($this->get_permission_fields(is_null($category_id) ? '' : strval($category_id), NULL, $title == '')); return array($fields, $hidden); }
/** * Get tempcode for a post template adding/editing form. * * @param ?AUTO_LINK ID of category (NULL: new category) * @param SHORT_TEXT The title * @param SHORT_TEXT The theme image code * @param URLPATH URL to external feed to associate with this event type * @return array A pair: The input fields, Hidden fields */ function get_form_fields($id = NULL, $title = '', $logo = '', $external_feed = '') { $fields = new ocp_tempcode(); $hidden = new ocp_tempcode(); $fields->attach(form_input_line(do_lang_tempcode('TITLE'), do_lang_tempcode('DESCRIPTION_TITLE'), 'title', $title, true)); require_code('themes2'); $ids = get_all_image_ids_type('calendar'); $fields->attach(form_input_upload(do_lang_tempcode('UPLOAD'), do_lang_tempcode('DESCRIPTION_UPLOAD'), 'file', false, NULL, NULL, true, str_replace(' ', '', get_option('valid_images')))); $fields->attach(form_input_picture_choose_specific(do_lang_tempcode('ALT_FIELD', do_lang_tempcode('STOCK')), do_lang_tempcode('DESCRIPTION_ALTERNATE_STOCK'), 'theme_img_code', $ids, NULL, $logo, NULL, true)); handle_max_file_size($hidden, 'image'); if (addon_installed('syndication_blocks')) { $fields->attach(form_input_line(do_lang_tempcode('EXTERNAL_FEED'), do_lang_tempcode('DESCRIPTION_EXTERNAL_FEED'), 'external_feed', $external_feed, false)); } else { $hidden->attach(form_input_hidden('external_feed', $external_feed)); } // Permissions $fields->attach($this->get_permission_fields(is_null($id) ? NULL : strval($id), NULL, $title == '')); 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); }