/** * Standard modular UI/actualiser to edit an entry. * * @return tempcode The UI */ function __ed() { $id = mixed(); // Define type as mixed $id = $this->non_integer_id ? get_param('id', false, true) : strval(get_param_integer('id')); $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); if ($this->second_stage_preview && get_param_integer('preview', 0) == 1) { return $this->preview_intercept($title); } if (method_exists($this, 'get_submitter')) { list($submitter, $date_and_time) = $this->get_submitter($id); if (!is_null($date_and_time) && addon_installed('points')) { $reverse = post_param_integer('reverse_point_transaction', 0); if ($reverse == 1) { $points_test = $GLOBALS['SITE_DB']->query_select('gifts', array('*'), array('date_and_time' => $date_and_time, 'gift_to' => $submitter, 'gift_from' => $GLOBALS['FORUM_DRIVER']->get_guest_id())); if (array_key_exists(0, $points_test)) { $amount = $points_test[0]['amount']; $sender_id = $points_test[0]['gift_from']; $recipient_id = $points_test[0]['gift_to']; $GLOBALS['SITE_DB']->query_delete('gifts', array('id' => $points_test[0]['id']), '', 1); if (!is_guest($sender_id)) { $_sender_gift_points_used = point_info($sender_id); $sender_gift_points_used = array_key_exists('gift_points_used', $_sender_gift_points_used) ? $_sender_gift_points_used['gift_points_used'] : 0; $GLOBALS['FORUM_DRIVER']->set_custom_field($sender_id, 'gift_points_used', strval($sender_gift_points_used - $amount)); } require_code('points'); $temp_points = point_info($recipient_id); $GLOBALS['FORUM_DRIVER']->set_custom_field($recipient_id, 'points_gained_given', strval((array_key_exists('points_gained_given', $temp_points) ? $temp_points['points_gained_given'] : 0) - $amount)); } } } } else { $submitter = NULL; } breadcrumb_set_parents(array_merge($GLOBALS['BREADCRUMB_SET_PARENTS'], array(array('_SELF:_SELF:_e' . $this->type_code . ':' . $id, strpos($doing, ' ') !== false ? protect_from_escaping($doing) : do_lang_tempcode($doing))))); $delete = post_param_integer('delete', 0); if ($delete == 1 || $delete == 2) { if (!is_null($this->permissions_require)) { check_delete_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); } $doing = 'DELETE_' . $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_DELETE', escape_html($catalogue_title)); } elseif ($this->type_code == 'c') { $doing = do_lang('CATALOGUE_GENERIC_DELETE_CATEGORY', escape_html($catalogue_title)); } } $title = get_page_title($doing); $test = $this->handle_confirmations($title); if (!is_null($test)) { return $test; } $this->delete_actualisation($id); // Delete custom fields if ($this->has_tied_catalogue()) { require_code('fields'); delete_form_custom_fields($this->award_type, $id); } /*if ((!is_null($this->redirect_type)) || ((!is_null(get_param('redirect',NULL))))) No - resource is gone now, and redirect would almost certainly try to take us back there { $url=(($this->redirect_type=='!') || (is_null($this->redirect_type)))?get_param('redirect'):build_url(array('page'=>'_SELF','type'=>$this->redirect_type),'_SELF'); return redirect_screen($title,$url,do_lang_tempcode('SUCCESS')); }*/ clear_ocp_autosave(); $description = is_null($this->do_next_description) ? do_lang_tempcode('SUCCESS') : $this->do_next_description; return $this->do_next_manager($title, $description, NULL); } else { 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); } $test = $this->handle_confirmations($title); if (!is_null($test)) { return $test; } if ($this->user_facing && !is_null($this->permissions_require) && array_key_exists('validated', $_POST)) { if (!has_specific_permission(get_member(), 'bypass_validation_' . $this->permissions_require . 'range_content', $this->permission_page_name, array($this->permissions_cat_require, is_null($this->permissions_cat_name) ? '' : post_param($this->permissions_cat_name), $this->permissions_cat_require_b, is_null($this->permissions_cat_name_b) ? '' : post_param($this->permissions_cat_name_b)))) { $_POST['validated'] = '0'; } } if (!is_null($this->upload)) { require_code('uploads'); } $description = $this->edit_actualisation($id); if (!is_null($this->new_id)) { $id = $this->new_id; } // Save custom fields if ($this->has_tied_catalogue()) { require_code('fields'); save_form_custom_fields($this->award_type, $id); } if ($this->output_of_action_is_confirmation && !is_null($description)) { return $description; } if (is_null($description)) { $description = do_lang_tempcode('SUCCESS'); } if (addon_installed('awards')) { if (!is_null($this->award_type)) { require_code('awards'); handle_award_setting($this->award_type, $id); } } if ($this->user_facing) { if ($this->check_validation && post_param_integer('validated', 0) == 0) { require_code('submit'); if ($this->send_validation_request) { $edit_url = build_url(array('page' => '_SELF', 'type' => '_e' . $this->type_code, 'id' => $id, 'validated' => 1), '_SELF', NULL, false, false, true); if (addon_installed('unvalidated')) { send_validation_request($doing, $this->table, $this->non_integer_id, $id, $edit_url); } } $description->attach(paragraph(do_lang_tempcode('SUBMIT_UNVALIDATED'))); } } } if (!is_null($this->redirect_type) || !is_null(get_param('redirect', NULL))) { $url = $this->redirect_type == '!' || is_null($this->redirect_type) ? make_string_tempcode(get_param('redirect')) : build_url(array('page' => '_SELF', 'type' => $this->redirect_type), '_SELF'); return redirect_screen($title, $url, do_lang_tempcode('SUCCESS')); } clear_ocp_autosave(); decache('main_awards'); return $this->do_next_manager($title, $description, $id); }
/** * The actualiser to add an author. * * @return tempcode The UI */ function __ad() { $title = get_page_title('DEFINE_AUTHOR'); $author = post_param('author', get_param('author')); if (!has_edit_author_permission(get_member(), $author)) { access_denied('SPECIFIC_PERMISSION', 'edit_midrange_content'); } if ($author == '') { $forum_handle_string = post_param('forum_handle', strval(get_member())); $author = is_numeric($forum_handle_string) ? $GLOBALS['FORUM_DRIVER']->get_username(intval($forum_handle_string)) : $forum_handle_string; if (is_null($author)) { $author = do_lang('UNKNOWN'); } } $_forum_handle = post_param('forum_handle', NULL); if ($_forum_handle == '') { $_forum_handle = NULL; } if (!is_null($_forum_handle)) { $forum_handle = is_numeric($_forum_handle) ? intval($_forum_handle) : $GLOBALS['FORUM_DRIVER']->get_member_from_username($_forum_handle); } else { $forum_handle = NULL; } if (post_param_integer('delete', 0) == 1) { if (!has_delete_author_permission(get_member(), $author)) { access_denied('SPECIFIC_PERMISSION', 'delete_midrange_content'); } delete_author($author); $author = NULL; require_code('fields'); if (has_tied_catalogue('author')) { delete_form_custom_fields('author', $author); } } else { $_url = post_param('url'); if (strpos($_url, '@') !== false && strpos($_url, 'mailto:') === false) { $_url = 'mailto:' . $_url; } $url = strpos($_url, 'mailto:') === false ? fixup_protocolless_urls($_url) : $_url; add_author($author, $url, $forum_handle, post_param('description'), post_param('skills'), post_param('meta_keywords', ''), post_param('meta_description', '')); require_code('fields'); if (has_tied_catalogue('author')) { save_form_custom_fields('author', $author); } if (addon_installed('awards')) { require_code('awards'); handle_award_setting('author', $author); } } breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('AUTHOR_MANAGE')))); return $this->do_next_manager($title, do_lang_tempcode('SUCCESS'), $author); }
/** * The actualiser to edit a topic. * * @return tempcode The UI */ function _edit_topic() { $topic_id = get_param_integer('id'); $cascading = post_param_integer('cascading', fractional_edit() ? INTEGER_MAGIC_NULL : 0); $pinned = post_param_integer('pinned', fractional_edit() ? INTEGER_MAGIC_NULL : 0); $sunk = post_param_integer('sunk', fractional_edit() ? INTEGER_MAGIC_NULL : 0); $open = post_param_integer('open', fractional_edit() ? INTEGER_MAGIC_NULL : 0); $validated = post_param_integer('validated', fractional_edit() ? INTEGER_MAGIC_NULL : 0); $title = post_param('title'); require_code('ocf_topics_action'); require_code('ocf_topics_action2'); ocf_edit_topic($topic_id, post_param('description', STRING_MAGIC_NULL), post_param('emoticon', STRING_MAGIC_NULL), $validated, $open, $pinned, $sunk, $cascading, post_param('reason', STRING_MAGIC_NULL), $title); require_code('fields'); if (has_tied_catalogue('topic')) { save_form_custom_fields('topic', strval($topic_id)); } if (addon_installed('awards')) { require_code('awards'); handle_award_setting('topic', strval($topic_id)); } return $this->redirect_to('EDIT_TOPIC', $topic_id); }
/** * The actualiser for editing a CEDI page. * * @return tempcode The UI. */ function _edit_page() { $_id = get_param_cedi_chain('id'); $id = intval($_id[0]); if (!has_category_access(get_member(), 'seedy_page', strval($id))) { access_denied('CATEGORY_ACCESS'); } if (post_param_integer('delete', 0) == 1) { $title = get_page_title('CEDI_DELETE_PAGE'); check_delete_permission('cat_low', NULL, array('seedy_page', $id)); cedi_delete_page($id); require_code('fields'); if (has_tied_catalogue('seedy_page')) { delete_form_custom_fields('seedy_page', strval($id)); } require_code('autosave'); clear_ocp_autosave(); $_url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF'); $url = $_url->evaluate(); } else { $title = get_page_title('CEDI_EDIT_PAGE'); check_edit_permission('cat_low', NULL, array('seedy_page', $id)); require_code('permissions2'); set_category_permissions_from_environment('seedy_page', strval($id), 'cms_cedi'); cedi_edit_page($id, post_param('title'), post_param('post'), post_param('notes', ''), post_param_integer('hide_posts', 0), post_param('meta_keywords', ''), post_param('meta_description', '')); require_code('fields'); if (has_tied_catalogue('seedy_page')) { save_form_custom_fields('seedy_page', strval($id)); } require_code('autosave'); clear_ocp_autosave(); if (addon_installed('awards')) { require_code('awards'); handle_award_setting('seedy_page', strval($id)); } $url = get_param('redirect'); } // Show it worked / Refresh return redirect_screen($title, $url, do_lang_tempcode('SUCCESS')); }