function testEditPosts() { $this->establish_admin_session(); // Test the forum edits ocf_edit_post($post_id = $this->post_id, $validated = 1, $title = 'take care', $post = 'the post editing', $skip_sig = 0, $is_emphasised = 0, $intended_solely_for = NULL, $show_as_edited = 1, $mark_as_unread = 0, $reason = 'Nothing'); // Test the forum was actually created $this->assertTrue('take care' == $GLOBALS['FORUM_DB']->query_value('f_posts', 'p_title ', array('id' => $this->post_id))); }
/** * The actualiser to edit a post. * * @return tempcode The UI */ function _edit_post() { require_code('attachments2'); if (post_param_integer('delete', 0) == 1) { return $this->_delete_post(); } $post_id = post_param_integer('post_id'); $post_details = $GLOBALS['FORUM_DB']->query_select('f_posts', array('*'), array('id' => $post_id), '', 1); if (!array_key_exists(0, $post_details)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $forum_id = $post_details[0]['p_cache_forum_id']; $intended_solely_for = post_param_integer('intended_solely_for', -1); if ($intended_solely_for == -1) { $intended_solely_for = NULL; } $validated = post_param_integer('validated', 0); if (!is_null($forum_id) && !has_specific_permission(get_member(), 'bypass_validation_lowrange_content', 'topics', array('forums', $forum_id))) { $validated = 0; } $old_validated = $post_details[0]['p_validated']; require_code('ocf_posts_action'); require_code('ocf_posts_action2'); require_code('ocf_posts_action3'); $topic_id = ocf_edit_post($post_id, $validated, post_param('title', ''), post_param('post'), post_param_integer('skip_sig', 0), post_param_integer('is_emphasised', 0), $intended_solely_for, post_param_integer('show_as_edited', 0) == 1, post_param_integer('mark_as_unread', 0) == 1, post_param('reason')); require_code('fields'); if (has_tied_catalogue('post')) { save_form_custom_fields('post', strval($post_id)); } if ($old_validated != $validated) { if ($validated == 1) { ocf_validate_post($post_id); } } if (addon_installed('awards')) { require_code('awards'); handle_award_setting('post', strval($post_id)); } require_code('autosave'); clear_ocp_autosave(); // Show it worked / Refresh $url = get_param('redirect', NULL); if (!is_null($url)) { return redirect_screen(get_page_title('EDIT_POST'), $url, do_lang_tempcode('SUCCESS')); } return $this->redirect_to('EDIT_POST', $topic_id, NULL, $post_id); }
/** * Update the spacer post of a comment topic, after an edit. * * @param boolean Whether this resource allows comments (if not, this function does nothing - but it's nice to move out this common logic into the shared function) * @param ID_TEXT The type (download, etc) that this commenting is for * @param ID_TEXT The ID of the type that this commenting is for * @param mixed The URL to where the commenting will pass back to (to put into the comment topic header) (URLPATH or Tempcode) * @param ?string The title to where the commenting will pass back to (to put into the comment topic header) (NULL: don't know, but not first post so not important) * @param ?string The name of the forum to use (NULL: default comment forum) * @param ?AUTO_LINK ID of spacer post (NULL: unknown) */ function update_spacer_post($allow_comments, $content_type, $content_id, $content_url, $content_title, $forum = NULL, $post_id = NULL) { if (get_option('is_on_comments') == '0' || !$allow_comments) { return; } if (get_forum_type() != 'ocf') { return; } $home_link = is_null($content_title) ? new ocp_tempcode() : hyperlink($content_url, escape_html($content_title)); if (is_null($forum)) { $forum = get_option('comments_forum_name'); } if (!is_integer($forum)) { $forum_id = $GLOBALS['FORUM_DRIVER']->forum_id_from_name($forum); if (is_null($forum_id)) { return; } } else { $forum_id = (int) $forum; } $content_title = strip_comcode($content_title); if (is_null($post_id)) { $topic_id = $GLOBALS['FORUM_DRIVER']->find_topic_id_for_topic_identifier($forum_id, $content_type . '_' . $content_id); if (is_null($topic_id)) { return; } $post_id = $GLOBALS['FORUM_DB']->query_value_null_ok('f_posts', 'MIN(id)', array('p_topic_id' => $topic_id)); if (is_null($post_id)) { return; } } else { $topic_id = $GLOBALS['FORUM_DB']->query_value('f_posts', 'p_topic_id', array('id' => $post_id)); } $spacer_title = is_null($content_title) ? $content_type . '_' . $content_id : $content_title . ' (#' . $content_type . '_' . $content_id . ')'; $spacer_post = '[semihtml]' . do_lang('SPACER_POST', $home_link->evaluate(), '', '', get_site_default_lang()) . '[/semihtml]'; if (get_forum_type() == 'ocf') { require_code('ocf_posts_action3'); ocf_edit_post($post_id, 1, is_null($content_title) ? $spacer_title : $content_title, $spacer_post, 0, 0, NULL, false, false, '', false); require_code('ocf_topics_action2'); ocf_edit_topic($topic_id, do_lang('COMMENT') . ': #' . $content_type . '_' . $content_id, NULL, NULL, NULL, NULL, NULL, NULL, '', NULL, $home_link->evaluate(), false); } }
/** * The actualiser to revert an edited post. * * @return tempcode The UI */ function revert() { check_specific_permission('restore_content_history'); $title = get_page_title('POST_HISTORY'); $id = get_param_integer('h_id'); $post = $GLOBALS['FORUM_DB']->query_select('f_post_history', array('*'), array('id' => $id), '', 1); if (!array_key_exists(0, $post)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $post = $post[0]; $post2 = $GLOBALS['FORUM_DB']->query_select('f_posts', array('*'), array('id' => $post['h_post_id']), '', 1); if (!array_key_exists(0, $post2)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $post2 = $post2[0]; require_code('ocf_posts_action'); require_code('ocf_posts_action2'); require_code('ocf_posts_action3'); ocf_edit_post($post['h_post_id'], $post2['p_validated'], $post2['p_title'], $post['h_before'], 0, $post2['p_is_emphasised'], $post2['p_intended_solely_for'], false, false, do_lang('REVERT_HISTORY_POST')); $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF', NULL, true); return redirect_screen($title, $url, do_lang_tempcode('SUCCESS')); }