/** * 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 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')); }
/** * Standard aed_module delete actualiser. * * @param ID_TEXT The entry being deleted */ function delete_actualisation($_id) { $id = intval($_id); $rows = $GLOBALS['SITE_DB']->query_select('iotd', array('is_current', 'submitter'), array('id' => $id)); if (!array_key_exists(0, $rows)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $is_current = $rows[0]['is_current']; $submitter = $rows[0]['submitter']; check_delete_permission($is_current == 1 ? 'high' : 'mid', $submitter); delete_iotd(intval($id)); }
/** * Standard aed_module delete actualiser. * * @param ID_TEXT The entry being deleted */ function delete_actualisation($_id) { $id = intval($_id); $rows = $GLOBALS['SITE_DB']->query_select('calendar_events', array('*'), array('id' => $id), '', 1); if (!array_key_exists(0, $rows)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $event = $rows[0]; check_delete_permission($event['e_is_public'] == 1 ? 'mid' : 'low', $event['e_submitter']); delete_calendar_event($id); }