/** * 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) { $order = 0; // Actualiser if (post_param('submitting_settings_tab', NULL) !== NULL) { require_code('ocf_members_action2'); $is_ldap = ocf_is_ldap_member($member_id_of); $is_httpauth = ocf_is_httpauth_member($member_id_of); $is_remote = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_password_compat_scheme') == 'remote'; if ($is_ldap || $is_httpauth || $is_remote || $member_id_of != $member_id_viewing && !has_specific_permission($member_id_viewing, 'assume_any_member')) { $password = NULL; } else { $password = post_param('edit_password'); if ($password == '') { $password = NULL; } else { $password_confirm = trim(post_param('password_confirm')); if ($password != $password_confirm) { warn_exit(make_string_tempcode(escape_html(do_lang('PASSWORD_MISMATCH')))); } } } $custom_fields = ocf_get_all_custom_fields_match($GLOBALS['FORUM_DRIVER']->get_members_groups($member_id_of), $member_id_of != $member_id_viewing && !has_specific_permission($member_id_viewing, 'view_any_profile_field') ? 1 : NULL, $member_id_of != $member_id_viewing ? NULL : 1, $member_id_of != $member_id_viewing ? NULL : 1); $actual_custom_fields = ocf_read_in_custom_fields($custom_fields, $member_id_of); $pt_allow = array_key_exists('pt_allow', $_POST) ? implode(',', $_POST['pt_allow']) : ''; $tmp_groups = $GLOBALS['OCF_DRIVER']->get_usergroup_list(true, true); $all_pt_allow = ''; foreach (array_keys($tmp_groups) as $key) { if ($key != db_get_first_id()) { if ($all_pt_allow != '') { $all_pt_allow .= ','; } $all_pt_allow .= strval($key); } } if ($pt_allow == $all_pt_allow) { $pt_allow = '*'; } $pt_rules_text = post_param('pt_rules_text', NULL); if (has_specific_permission($member_id_viewing, 'member_maintenance')) { $validated = post_param_integer('validated', 0); $primary_group = $is_ldap || !has_specific_permission($member_id_viewing, 'assume_any_member') ? NULL : post_param_integer('primary_group', NULL); $is_perm_banned = post_param_integer('is_perm_banned', 0); $old_is_perm_banned = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_is_perm_banned'); if ($old_is_perm_banned != $is_perm_banned) { if ($is_perm_banned == 1) { ocf_ban_member($member_id_of); } else { ocf_unban_member($member_id_of); } } $highlighted_name = post_param_integer('highlighted_name', 0); if (has_specific_permission($member_id_viewing, 'probate_members')) { $on_probation_until = get_input_date('on_probation_until'); $current__on_probation_until = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id_of, 'm_on_probation_until'); if ((is_null($on_probation_until) || $on_probation_until <= time()) && $current__on_probation_until > time()) { log_it('STOP_PROBATION', strval($member_id_of), $GLOBALS['FORUM_DRIVER']->get_username($member_id_of)); } elseif (!is_null($on_probation_until) && $on_probation_until > time() && $current__on_probation_until <= time()) { log_it('START_PROBATION', strval($member_id_of), $GLOBALS['FORUM_DRIVER']->get_username($member_id_of)); } elseif (!is_null($on_probation_until) && $current__on_probation_until > $on_probation_until && $on_probation_until > time() && $current__on_probation_until > time()) { log_it('REDUCE_PROBATION', strval($member_id_of), $GLOBALS['FORUM_DRIVER']->get_username($member_id_of)); } elseif (!is_null($on_probation_until) && $current__on_probation_until < $on_probation_until && $on_probation_until > time() && $current__on_probation_until > time()) { log_it('EXTEND_PROBATION', strval($member_id_of), $GLOBALS['FORUM_DRIVER']->get_username($member_id_of)); } } else { $on_probation_until = NULL; } } else { $validated = NULL; $primary_group = NULL; $highlighted_name = NULL; $on_probation_until = NULL; } if (has_actual_page_access($member_id_viewing, 'admin_ocf_join') || has_specific_permission($member_id_of, 'rename_self')) { $username = $is_ldap || $is_remote ? NULL : post_param('edit_username', NULL); } else { $username = NULL; } $email = post_param('email_address', NULL); if (!is_null($email)) { $email = trim($email); } $theme = post_param('theme', NULL); if ($is_remote) { $preview_posts = NULL; $zone_wide = NULL; $auto_monitor_contrib_content = NULL; $views_signatures = NULL; $timezone = NULL; } else { $preview_posts = post_param_integer('preview_posts', 0); $zone_wide = post_param_integer('zone_wide', 0); $auto_monitor_contrib_content = NULL; //post_param_integer('auto_monitor_contrib_content',0); Moved to notifications tab $views_signatures = post_param_integer('views_signatures', 0); $timezone = post_param('timezone', get_site_timezone()); } ocf_edit_member($member_id_of, $email, $preview_posts, post_param_integer('dob_day', -1), post_param_integer('dob_month', -1), post_param_integer('dob_year', -1), $timezone, $primary_group, $actual_custom_fields, $theme, post_param_integer('reveal_age', 0), $views_signatures, $auto_monitor_contrib_content, post_param('language', NULL), post_param_integer('allow_emails', 0), post_param_integer('allow_emails_from_staff', 0), $validated, $username, $password, $zone_wide, $highlighted_name, $pt_allow, $pt_rules_text, $on_probation_until); if (!array_key_exists('secondary_groups', $_POST)) { $_POST['secondary_groups'] = array(); } require_code('ocf_groups_action2'); $members_groups = $GLOBALS['OCF_DRIVER']->get_members_groups($member_id_of); $group_count = $GLOBALS['FORUM_DB']->query_value('f_groups', 'COUNT(*)'); $groups = list_to_map('id', $GLOBALS['FORUM_DB']->query_select('f_groups', array('*'), $group_count > 200 ? array('g_is_private_club' => 0) : NULL)); foreach ($_POST['secondary_groups'] as $group_id) { $group = $groups[intval($group_id)]; if ($group['g_hidden'] == 1 && !in_array($group['id'], $members_groups) && !has_specific_permission($member_id_viewing, 'see_hidden_groups')) { continue; } if (!in_array($group['id'], $members_groups) && (has_specific_permission($member_id_viewing, 'assume_any_member') || $group['g_open_membership'] == 1)) { ocf_add_member_to_group($member_id_of, $group['id']); } } foreach ($members_groups as $group_id) { if (!in_array(strval($group_id), $_POST['secondary_groups'])) { ocf_member_leave_group($group_id, $member_id_of); } } $GLOBALS['FORUM_DB']->query('DELETE FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_member_known_login_ips WHERE i_member_id=' . strval($member_id_of) . ' AND ' . db_string_not_equal_to('i_val_code', '')); // So any re-confirms can happen if (addon_installed('awards')) { require_code('awards'); handle_award_setting('member', strval($member_id_of)); } attach_message(do_lang_tempcode('SUCCESS_SAVE'), 'inform'); } if ($leave_to_ajax_if_possible) { return NULL; } // UI $title = do_lang_tempcode('SETTINGS'); $myrow = $GLOBALS['FORUM_DRIVER']->get_member_row($member_id_of); if (is_null($myrow)) { warn_exit(do_lang_tempcode('USER_NO_EXIST')); } require_code('ocf_members_action2'); list($fields, $hidden) = ocf_get_member_fields_settings(false, $member_id_of, NULL, $myrow['m_email_address'], $myrow['m_preview_posts'], $myrow['m_dob_day'], $myrow['m_dob_month'], $myrow['m_dob_year'], get_users_timezone($member_id_of), $myrow['m_theme'], $myrow['m_reveal_age'], $myrow['m_views_signatures'], $myrow['m_auto_monitor_contrib_content'], $myrow['m_language'], $myrow['m_allow_emails'], $myrow['m_allow_emails_from_staff'], $myrow['m_validated'], $myrow['m_primary_group'], $myrow['m_username'], $myrow['m_is_perm_banned'], '', $myrow['m_zone_wide'], $myrow['m_highlighted_name'], $myrow['m_pt_allow'], get_translated_text($myrow['m_pt_rules_text'], $GLOBALS['FORUM_DB']), $myrow['m_on_probation_until']); // Awards? if (addon_installed('awards')) { require_code('awards'); $fields->attach(get_award_fields('member', strval($member_id_of))); } $redirect = get_param('redirect', NULL); if (!is_null($redirect)) { $hidden->attach(form_input_hidden('redirect', $redirect)); } $hidden->attach(form_input_hidden('submitting_settings_tab', '1')); $javascript = "\n\t\t\tvar form=document.getElementById('email_address').form;\n\t\t\tform.prior_profile_edit_submit=form.onsubmit;\n\t\t\tform.onsubmit=function()\n\t\t\t\t{\n\t\t\t\t\tif (typeof form.elements['edit_password']!='undefined')\n\t\t\t\t\t{\n\t\t\t\t\t\tif ((form.elements['password_confirm']) && (form.elements['password_confirm'].value!=form.elements['edit_password'].value))\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\twindow.fauxmodal_alert('" . php_addslashes(do_lang('PASSWORD_MISMATCH')) . "');\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (typeof form.prior_profile_edit_submit!='undefined' && form.prior_profile_edit_submit) return form.prior_profile_edit_submit();\n\t\t\t\t\treturn true;\n\t\t\t\t};\n\t\t"; $text = ''; return array($title, $fields, $text, $javascript, $order, $hidden); }
/** * Standard modular UI to edit an entry. * * @return tempcode The UI */ function _ed() { $doing = 'EDIT_' . $this->lang_type; if ($this->catalogue && get_param('catalogue_name', '') != '') { $catalogue_title = get_translated_text($GLOBALS['SITE_DB']->query_value('catalogues', 'c_title', array('c_name' => get_param('catalogue_name')))); if ($this->type_code == 'd') { $doing = do_lang('CATALOGUE_GENERIC_EDIT', escape_html($catalogue_title)); } elseif ($this->type_code == 'c') { $doing = do_lang('CATALOGUE_GENERIC_EDIT_CATEGORY', escape_html($catalogue_title)); } } $title = get_page_title($doing); //$submit_name=(strpos($doing,' ')!==false)?protect_from_escaping($doing):do_lang($doing); //if (!is_null($this->edit_submit_name)) $submit_name=$this->edit_submit_name; $submit_name = do_lang_tempcode('SAVE'); //$test=$this->choose_catalogue($title); //if (!is_null($test)) return $test; $id = mixed(); // Define type as mixed $id = $this->non_integer_id ? get_param('id', false, true) : strval(get_param_integer('id')); $map = array('page' => '_SELF', 'type' => '__e' . $this->type_code, 'id' => $id); if (get_param('catalogue_name', '') != '') { $map['catalogue_name'] = get_param('catalogue_name'); } if (!is_null(get_param('redirect', NULL))) { $map['redirect'] = get_param('redirect'); } if (!is_null(get_param('continue', NULL))) { $map['continue'] = get_param('continue'); } if (!is_null($this->upload) || $this->possibly_some_kind_of_upload) { $map['uploading'] = 1; } $post_url = build_url($map, '_SELF'); if (multi_lang() && has_actual_page_access(get_member(), 'admin_lang') && user_lang() != get_site_default_lang()) { require_code('lang2'); $switch_url = get_self_url(false, false, array('keep_lang' => get_site_default_lang())); attach_message(do_lang_tempcode('lang:EDITING_CONTENT_IN_LANGUAGE_STAFF', escape_html(lookup_language_full_name(user_lang())), escape_html(lookup_language_full_name(get_site_default_lang())), escape_html($switch_url->evaluate())), 'warn'); } if (method_exists($this, 'get_submitter')) { list($submitter, $date_and_time) = $this->get_submitter($id); } else { $submitter = NULL; $date_and_time = NULL; } if (!is_null($this->permissions_require)) { check_edit_permission($this->permissions_require, $submitter, array($this->permissions_cat_require, is_null($this->permissions_cat_name) ? NULL : $this->get_cat($id), $this->permissions_cat_require_b, is_null($this->permissions_cat_name_b) ? NULL : $this->get_cat_b($id)), $this->permission_page_name); } if (!is_null($this->permissions_cat_require) && !has_category_access(get_member(), $this->permissions_cat_require, $this->get_cat($id))) { access_denied('CATEGORY_ACCESS'); } if (!is_null($this->permissions_cat_require_b) && !has_category_access(get_member(), $this->permissions_cat_require_b, $this->get_cat_b($id))) { access_denied('CATEGORY_ACCESS'); } $bits = $this->fill_in_edit_form($id); $delete_fields = new ocp_tempcode(); $all_delete_fields_given = false; $fields2 = new ocp_tempcode(); if (is_array($bits)) { $fields = $bits[0]; $hidden = $bits[1]; if (array_key_exists(2, $bits) && !is_null($bits[2])) { $delete_fields = $bits[2]; } if (array_key_exists(3, $bits) && !is_null($bits[3])) { $this->edit_text = $bits[3]; } if (array_key_exists(4, $bits) && $bits[4]) { $all_delete_fields_given = true; } if (array_key_exists(5, $bits) && !is_null($bits[5])) { $this->posting_form_text = $bits[5]; } if (array_key_exists(6, $bits) && !is_null($bits[6])) { $fields2 = $bits[6]; } if (array_key_exists(7, $bits)) { $this->posting_form_text_parsed = $bits[7]; } } else { $fields = $bits; $hidden = new ocp_tempcode(); } // Add in custom fields if ($this->has_tied_catalogue()) { require_code('fields'); $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('MORE')))); append_form_custom_fields($this->award_type, $id, $fields, $hidden); } // SEO? if (!is_null($this->seo_type)) { require_code('seo2'); $fields2->attach(seo_get_fields($this->seo_type, $id)); } // Awards? if (addon_installed('awards')) { if (!is_null($this->award_type)) { require_code('awards'); $fields2->attach(get_award_fields($this->award_type, $id)); } } // Action fields / deletion options $delete_permission = true; if (!is_null($this->permissions_require)) { $delete_permission = has_delete_permission($this->permissions_require, get_member(), $submitter, is_null($this->permission_page_name) ? get_page_name() : $this->permission_page_name, array($this->permissions_cat_require, is_null($this->permissions_cat_name) ? NULL : $this->get_cat($id), $this->permissions_cat_require_b, is_null($this->permissions_cat_name_b) ? NULL : $this->get_cat_b($id))); } $may_delete = (!method_exists($this, 'may_delete_this') || $this->may_delete_this($id)) && (!is_numeric($id) || intval($id) >= db_get_first_id() + $this->protect_first) && $delete_permission; // Deletion options $action_fields = new ocp_tempcode(); if ($may_delete) { if (!$all_delete_fields_given) { $action_fields->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE'), 'delete', false)); } if (addon_installed('points') && !is_null($submitter) && !is_null($date_and_time)) { $points_test = $GLOBALS['SITE_DB']->query_value_null_ok('gifts', 'id', array('date_and_time' => $date_and_time, 'gift_to' => $submitter, 'gift_from' => $GLOBALS['FORUM_DRIVER']->get_guest_id())); if (!is_null($points_test)) { require_lang('points'); $action_fields->attach(form_input_tick(do_lang_tempcode('REVERSE_TITLE'), do_lang_tempcode('REVERSE_TITLE_DESCRIPTION'), 'reverse_point_transaction', false)); } } $action_fields->attach($delete_fields); } if (!$this->appended_actions_already && !$action_fields->is_empty()) { $fields2->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ACTIONS')))); } $fields2->attach($action_fields); if (!is_object($this->edit_text)) { $this->edit_text = make_string_tempcode(is_null($this->edit_text) ? '' : $this->edit_text); } if (!is_null($this->upload)) { if ($this->upload == 'image') { require_code('images'); $max = floatval(get_max_image_size()) / floatval(1024 * 1024); if ($max < 3.0) { require_code('files2'); $config_url = get_upload_limit_config_url(); $this->edit_text->attach(paragraph(do_lang_tempcode(is_null($config_url) ? 'MAXIMUM_UPLOAD' : 'MAXIMUM_UPLOAD_STAFF', escape_html($max > 10.0 ? integer_format(intval($max)) : float_format($max)), escape_html(is_null($config_url) ? '' : $config_url)))); } } else { require_code('files2'); $max = floatval(get_max_file_size()) / floatval(1024 * 1024); if ($max < 30.0) { $config_url = get_upload_limit_config_url(); $this->edit_text->attach(paragraph(do_lang_tempcode(is_null($config_url) ? 'MAXIMUM_UPLOAD' : 'MAXIMUM_UPLOAD_STAFF', escape_html($max > 10.0 ? integer_format(intval($max)) : float_format($max)), escape_html(is_null($config_url) ? '' : $config_url)))); } } } if (get_param('type', '_ed') == '_edit_catalogue') { require_javascript('javascript_catalogues'); // Existing fields $field_count = 0; $c_name = get_param('id', false, true); $rows = $GLOBALS['SITE_DB']->query_select('catalogue_fields', array('*'), array('c_name' => $c_name), 'ORDER BY cf_order'); $fields_existing = new ocp_tempcode(); foreach ($rows as $i => $myrow) { $name = get_translated_text($myrow['cf_name']); $description = get_translated_text($myrow['cf_description']); $prefix = 'existing_field_' . strval($myrow['id']) . '_'; list($_fields_existing, $_fields_hidden) = $this->get_field_fields($i == 0 && substr($c_name, 0, 1) != '_', count($rows) + 10, $prefix, $field_count, $name, $description, $myrow['cf_type'], $myrow['cf_defines_order'], $myrow['cf_visible'], $myrow['cf_searchable'], $myrow['cf_default'], $myrow['cf_required'], $myrow['cf_put_in_category'], $myrow['cf_put_in_search']); if (!is_ecommerce_catalogue($c_name) || $i > 9) { $_fields_existing->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ACTIONS')))); $_fields_existing->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE'), $prefix . 'delete', false)); } $temp = do_template('FORM_FIELD_SET_GROUPER', array('_GUID' => '1492d973db45cbecff892ad4ac1af28f' . get_class($this), 'NAME' => $name, 'ID' => 'FIELD_' . strval($i + 1), 'FIELDS' => $_fields_existing->evaluate())); $fields_existing->attach($temp); $hidden->attach($_fields_hidden); $field_count++; } // New field $fields_new = new ocp_tempcode(); for ($i = 0; $i < 5; $i++) { list($_fields_new, $_fields_hidden) = $this->get_field_fields(false, count($rows) + 10, 'new_field_' . strval($i) . '_', $field_count); $temp = do_template('FORM_FIELD_SET_GROUPER', array('_GUID' => '8b9a632eafae003ccc6b007eefb0ce3d' . get_class($this), 'NAME' => do_lang_tempcode('NEW_FIELD', strval($i + 1)), 'ID' => 'NEW_FIELD_' . strval($i + 1), 'FIELDS' => $_fields_new->evaluate())); $fields_new->attach($temp); $hidden->attach($_fields_hidden); $field_count++; } $fields->attach($fields2); return do_template('CATALOGUE_EDITING_SCREEN', array('_GUID' => '584d7dc7c2c13939626102374f13f508' . get_class($this), 'HIDDEN' => $hidden, 'TITLE' => $title, 'TEXT' => $this->add_text, 'URL' => $post_url, 'FIELDS' => $fields->evaluate(), 'FIELDS_EXISTING' => $fields_existing->evaluate(), 'FIELDS_NEW' => $fields_new->evaluate(), 'SUBMIT_NAME' => $submit_name, 'JAVASCRIPT' => $this->javascript)); } list($warning_details, $ping_url) = handle_conflict_resolution(); if (!is_null($this->posting_form_title)) { $posting_form = get_posting_form($submit_name, $this->posting_form_text, $post_url, $hidden, $fields, $this->posting_form_title, '', $fields2, $this->posting_form_text_parsed, $this->javascript, NULL, $this->posting_field_required); return do_template('POSTING_SCREEN', array('_GUID' => '841b9af3aa80bcab86b907e4b942786a' . get_class($this), 'PREVIEW' => $this->do_preview, 'TITLE' => $title, 'SEPARATE_PREVIEW' => $this->second_stage_preview, 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'TEXT' => $this->add_text, 'POSTING_FORM' => $posting_form->evaluate(), 'JAVASCRIPT' => $this->javascript)); } else { $fields->attach($fields2); return do_template('FORM_SCREEN', array('_GUID' => '2d70be34595a16c6f170d966b894bfe2' . get_class($this), 'PREVIEW' => $this->do_preview, 'SEPARATE_PREVIEW' => $this->second_stage_preview, 'TITLE' => $title, 'SKIP_VALIDATION' => $this->skip_validation, 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'HIDDEN' => $hidden, 'TEXT' => $this->edit_text, 'URL' => $post_url, 'FIELDS' => $fields->evaluate(), 'SUBMIT_NAME' => $submit_name, 'JAVASCRIPT' => $this->javascript)); } }
/** * The UI to edit a topic. * * @return tempcode The UI */ function edit_topic() { $topic_id = get_param_integer('id'); $topic_info = $GLOBALS['FORUM_DB']->query_select('f_topics', array('*'), array('id' => $topic_id), '', 1); if (!array_key_exists(0, $topic_info)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $forum_id = $topic_info[0]['t_forum_id']; $personal_topic = is_null($forum_id); $this->handle_topic_breadcrumbs($forum_id, $topic_id, $topic_info[0]['t_cache_first_title'], do_lang_tempcode('EDIT_TOPIC')); $this->check_has_mod_access($topic_id); $post_url = build_url(array('page' => '_SELF', 'type' => '_edit_topic', 'id' => $topic_id), '_SELF'); // Certain aspects relating to the posting system $fields = new ocp_tempcode(); $fields->attach(form_input_line(do_lang_tempcode('TITLE'), '', 'title', $topic_info[0]['t_cache_first_title'], false)); if (get_option('is_on_topic_descriptions') == '1' && !$GLOBALS['FORUM_DRIVER']->topic_is_threaded($topic_id)) { $fields->attach(form_input_line(do_lang_tempcode('DESCRIPTION'), '', 'description', $topic_info[0]['t_description'], false)); } $fields->attach(form_input_line(do_lang_tempcode('REASON'), do_lang_tempcode('DESCRIPTION_REASON'), 'reason', '', false)); if (get_option('is_on_topic_emoticons') == '1') { $fields->attach($this->choose_topic_emoticon($topic_info[0]['t_emoticon'])); } $options = array(); $hidden_fields = new ocp_tempcode(); if (ocf_may_moderate_forum($forum_id, get_member())) { $moderation_options = array(array(do_lang_tempcode('OPEN'), 'open', $topic_info[0]['t_is_open'] == 1, do_lang_tempcode('DESCRIPTION_OPEN')), array(do_lang_tempcode('PINNED'), 'pinned', $topic_info[0]['t_pinned'] == 1, do_lang_tempcode('DESCRIPTION_PINNED'))); if (addon_installed('unvalidated')) { if ($topic_info[0]['t_validated'] == 0) { $topic_info[0]['t_validated'] = get_param_integer('validated', 0); if ($topic_info[0]['t_validated'] == 1) { attach_message(do_lang_tempcode('WILL_BE_VALIDATED_WHEN_SAVING')); } } $moderation_options[] = array(do_lang_tempcode('VALIDATED'), 'validated', $topic_info[0]['t_validated'] == 1, do_lang_tempcode('DESCRIPTION_VALIDATED')); } if (get_value('disable_sunk') !== '1') { $moderation_options[] = array(do_lang_tempcode('SUNK'), 'sunk', $topic_info[0]['t_sunk'] == 1, do_lang_tempcode('DESCRIPTION_SUNK')); } if (!$personal_topic) { $options[] = array(do_lang_tempcode('CASCADING'), 'cascading', $topic_info[0]['t_cascading'] == 1, do_lang_tempcode('DESCRIPTION_CASCADING')); } } else { $moderation_options = array(); $hidden_fields->attach(form_input_hidden('validated', '1')); } $fields->attach(form_input_various_ticks($options, '')); if (count($moderation_options) != 0) { $fields->attach(form_input_various_ticks($moderation_options, '', NULL, do_lang_tempcode('MODERATION_OPTIONS'))); } require_code('fields'); if (has_tied_catalogue('topic')) { append_form_custom_fields('topic', strval($topic_id), $fields, $hidden_fields); } // Awards? if (addon_installed('awards')) { require_code('awards'); $fields->attach(get_award_fields('topic', strval($topic_id))); } $title = get_page_title('EDIT_TOPIC'); $submit_name = do_lang_tempcode('SAVE'); return do_template('FORM_SCREEN', array('_GUID' => '071b6747a1df1cf8e72f8f542422aa5b', 'STAFF_HELP_URL' => brand_base_url() . '/docs' . strval(ocp_version()) . '/pg/tut_mod', 'HIDDEN' => $hidden_fields, 'TITLE' => $title, 'FIELDS' => $fields, 'TEXT' => '', 'SUBMIT_NAME' => $submit_name, 'URL' => $post_url)); }
/** * The UI to add an author. * * @return tempcode The UI */ function _ad() { global $NON_CANONICAL_PARAMS; $NON_CANONICAL_PARAMS[] = 'author'; $author = get_param('author', $GLOBALS['FORUM_DRIVER']->get_username(get_member())); if (!has_edit_author_permission(get_member(), $author)) { if (get_author_id_from_name($author) == get_member()) { access_denied('SPECIFIC_PERMISSION', 'set_own_author_profile'); } access_denied('SPECIFIC_PERMISSION', 'edit_midrange_content'); } $rows = $GLOBALS['SITE_DB']->query_select('authors', array('description', 'url', 'skills', 'forum_handle'), array('author' => $author), '', 1); if (array_key_exists(0, $rows)) { $myrow = $rows[0]; $description = get_translated_text($myrow['description']); $url = $myrow['url']; $skills = get_translated_text($myrow['skills']); $handle = $myrow['forum_handle']; $may_delete = true; } else { $description = ''; if (get_forum_type() == 'ocf') { require_code('ocf_members'); require_lang('ocf'); $info = ocf_get_all_custom_fields_match_member(get_member()); if (array_key_exists(do_lang('DEFAULT_CPF_SELF_DESCRIPTION_NAME'), $info)) { $description = $info[do_lang('DEFAULT_CPF_SELF_DESCRIPTION_NAME')]['RENDERED']; if (is_object($description)) { $description = $description->evaluate(); } } } $url = ''; $skills = ''; $handle = NULL; $may_delete = false; } if (is_null($handle)) { $handle = $GLOBALS['FORUM_DRIVER']->get_member_from_username($author); if (!is_null($handle)) { $handle = strval($handle); } } if ($author == '' || is_null($handle)) { $title = get_page_title('DEFINE_AUTHOR'); } else { $title = get_page_title('_DEFINE_AUTHOR', true, array(escape_html($author))); } $post_url = build_url(array('page' => '_SELF', 'type' => '__ad', 'author' => $author), '_SELF'); $submit_name = do_lang_tempcode('SAVE'); $fields = new ocp_tempcode(); $hidden = new ocp_tempcode(); require_code('form_templates'); if (is_null($handle)) { $fields->attach(form_input_line(do_lang_tempcode('AUTHOR'), do_lang_tempcode('DESCRIPTION_NAME'), 'author', $author, true)); } $fields->attach(form_input_line(do_lang_tempcode('AUTHOR_URL'), do_lang_tempcode('DESCRIPTION_AUTHOR_URL'), 'url', $url, false)); $fields->attach(form_input_line_comcode(do_lang_tempcode('SKILLS'), do_lang_tempcode('DESCRIPTION_SKILLS'), 'skills', $skills, false)); $fields->attach(form_input_text_comcode(do_lang_tempcode('DESCRIPTION'), do_lang_tempcode('DESCRIPTION_MEMBER_DESCRIPTION'), 'description', $description, false)); if (has_specific_permission(get_member(), 'edit_midrange_content', 'cms_authors')) { $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => !is_null($handle), 'TITLE' => do_lang_tempcode('ADVANCED')))); $fields->attach(form_input_username(do_lang_tempcode('MEMBER_ID'), do_lang_tempcode('DESCRIPTION_MEMBER_ID'), 'forum_handle', is_null($handle) ? '' : $GLOBALS['FORUM_DRIVER']->get_username(intval($handle)), false)); } else { $hidden->attach(form_input_hidden('forum_handle', $handle)); } require_code('fields'); if (has_tied_catalogue('author')) { append_form_custom_fields('author', $author, $fields, $hidden); } require_code('seo2'); $fields->attach(seo_get_fields('authors', $author)); // Awards? if (addon_installed('awards')) { require_code('awards'); $fields->attach(get_award_fields('author', $author)); } if ($may_delete) { $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ACTIONS')))); $fields->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE'), 'delete', false)); } breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('AUTHOR_MANAGE')))); return do_template('FORM_SCREEN', array('_GUID' => '1d71c934e3e23fe394f5611191089630', 'PREVIEW' => true, 'HIDDEN' => $hidden, 'TITLE' => $title, 'TEXT' => '', 'FIELDS' => $fields, 'URL' => $post_url, 'SUBMIT_NAME' => $submit_name)); }
/** * 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)); }
/** * The UI for editing a CEDI page. * * @return tempcode The UI. */ function edit_page() { $title = get_page_title('CEDI_EDIT_PAGE'); $__id = get_param('id', '', true); if ($__id == '' || strpos($__id, '/') !== false) { $_id = get_param_cedi_chain('id'); $id = intval($_id[0]); } else { $id = intval($__id); } check_edit_permission('cat_low', NULL, array('seedy_page', $id)); if (!has_category_access(get_member(), 'seedy_page', strval($id))) { access_denied('CATEGORY_ACCESS'); } $pages = $GLOBALS['SITE_DB']->query_select('seedy_pages', array('*'), array('id' => $id), '', 1); if (!array_key_exists(0, $pages)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $page = $pages[0]; $page_title = get_translated_text($page['title']); $description = get_translated_text($page['description']); $_description = get_translated_tempcode($page['description']); $redir_url = get_param('redirect', NULL); if (is_null($redir_url)) { $_redir_url = build_url(array('page' => 'cedi', 'type' => 'misc', 'id' => get_param('id', false, true) == strval(db_get_first_id()) ? NULL : get_param('id', false, true)), get_module_zone('cedi')); $redir_url = $_redir_url->evaluate(); } $edit_url = build_url(array('page' => '_SELF', 'redirect' => $redir_url, 'id' => get_param('id', false, true), 'type' => '_edit_page'), '_SELF'); list($fields, $fields2, $hidden) = $this->get_page_fields($page_title, $page['notes'], $page['hide_posts'], $id); require_code('seo2'); $fields2->attach(seo_get_fields('seedy_page', strval($id))); if (addon_installed('awards')) { // Awards? require_code('awards'); $fields2->attach(get_award_fields('seedy_page', strval($id))); } if (has_delete_permission('cat_low', get_member(), NULL, NULL, array('seedy_page', $id)) && $id != db_get_first_id()) { $fields2->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ACTIONS')))); $fields2->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE'), 'delete', false)); } $restore_from = get_param_integer('restore_from', -1); if ($restore_from != -1) { $description = $GLOBALS['SITE_DB']->query_value('translate_history', 'text_original', array('id' => $restore_from, 'lang_id' => $page['description'])); // Double selection to stop hacking $_description = NULL; } $posting_form = get_posting_form(do_lang('SAVE'), $description, $edit_url, new ocp_tempcode(), $fields, do_lang_tempcode('PAGE_TEXT'), '', $fields2, $_description, NULL, NULL, false); // Revision history $revision_history = new ocp_tempcode(); $revisions = $GLOBALS['SITE_DB']->query_select('translate_history', array('*'), array('lang_id' => $page['description']), 'ORDER BY action_time DESC'); $last_description = $description; foreach ($revisions as $revision) { $time = $revision['action_time']; $date = get_timezoned_date($time); $editor = $GLOBALS['FORUM_DRIVER']->get_username($revision['action_member']); $restore_url = build_url(array('page' => '_SELF', 'type' => 'edit_page', 'id' => get_param('id', false, true), 'restore_from' => $revision['id']), '_SELF'); $size = strlen($revision['text_original']); require_code('diff'); if (function_exists('diff_simple_2')) { $rendered_diff = diff_simple_2($revision['text_original'], $last_description); $last_description = $revision['text_original']; $revision_history->attach(do_template('REVISION_HISTORY_LINE', array('_GUID' => 'a46de8a930ecfb814695a50b1c4931ac', 'RENDERED_DIFF' => $rendered_diff, 'EDITOR' => $editor, 'DATE' => $date, 'DATE_RAW' => strval($time), 'RESTORE_URL' => $restore_url, 'URL' => '', 'SIZE' => clean_file_size($size)))); } } if (!$revision_history->is_empty() && $restore_from == -1) { $revision_history = do_template('REVISION_HISTORY_WRAP', array('_GUID' => '1fc38d9d7ec57af110759352446e533d', 'CONTENT' => $revision_history)); } elseif (!$revision_history->is_empty()) { $revision_history = do_template('REVISION_RESTORE'); } list($warning_details, $ping_url) = handle_conflict_resolution(); $tree = cedi_breadcrumbs(get_param('id', false, true), NULL, true, true); breadcrumb_add_segment($tree, do_lang_tempcode('CEDI_EDIT_PAGE')); breadcrumb_set_parents(array(array('_SELF:_SELF:edit_page', do_lang_tempcode('CHOOSE')))); return do_template('POSTING_SCREEN', array('_GUID' => 'de53b8902ab1431e0d2d676f7d5471d3', 'PING_URL' => $ping_url, 'WARNING_DETAILS' => $warning_details, 'REVISION_HISTORY' => $revision_history, 'POSTING_FORM' => $posting_form, 'HIDDEN' => $hidden, 'TITLE' => $title, 'TEXT' => paragraph(do_lang_tempcode('CEDI_EDIT_PAGE_TEXT')))); }