Пример #1
0
 function tearDown()
 {
     if (!ocf_delete_posts_topic($topic_id = $this->topic_id, $posts = array($this->post_id), $reason = 'Nothing')) {
         ocf_delete_topic($this->topic_id);
     }
     parent::tearDown();
 }
Пример #2
0
 /**
  * The actualiser for deleting a post.
  *
  * @return tempcode		The UI
  */
 function _delete_post()
 {
     $post_id = either_param_integer('id', NULL);
     if (is_null($post_id)) {
         $post_id = either_param_integer('post_id');
     }
     $reason = post_param('reason');
     require_code('ocf_posts_action');
     require_code('ocf_posts_action2');
     require_code('ocf_posts_action3');
     if (has_specific_permission(get_member(), 'mass_delete_from_ip') && post_param_integer('post_all', 0) == 1) {
         $post_rows = $GLOBALS['FORUM_DB']->query_select('f_posts', array('p_ip_address', 'p_time', 'p_topic_id'), array('id' => $post_id));
         if (!array_key_exists(0, $post_rows)) {
             warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
         }
         $ip = $post_rows[0]['p_ip_address'];
         $time = $post_rows[0]['p_time'];
         $topic_id = $post_rows[0]['p_topic_id'];
         $posts = $GLOBALS['FORUM_DB']->query('SELECT id,p_topic_id,p_title FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts WHERE p_time>' . strval($time - 60 * 60 * 24) . ' AND p_time<' . strval($time + 60 * 60 * 24) . ' AND ' . db_string_equal_to('p_ip_address', $ip));
         $post_id = post_param_integer('id', NULL);
         if (is_null($post_id)) {
             $post_id = get_param_integer('id');
             $post_url = build_url(array('page' => '_SELF', 'type' => get_param('type')), '_SELF', NULL, true);
             $hidden = new ocp_tempcode();
             $hidden->attach(form_input_hidden('id', strval($post_id)));
             $hidden->attach(form_input_hidden('reason', post_param('reason')));
             $stuff = new ocp_tempcode();
             foreach ($posts as $post) {
                 if (!$stuff->is_empty()) {
                     $stuff->attach(do_lang_tempcode('LIST_SEP'));
                 }
                 $url = $GLOBALS['FORUM_DRIVER']->post_url($post['id'], $post['p_topic_id']);
                 if ($post['p_title'] != '') {
                     $stuff->attach(hyperlink($url, $post['p_title'], true, true));
                 } else {
                     $stuff->attach(hyperlink($url, '#' . strval($post['id']), true, true));
                 }
             }
             return do_template('YESNO_SCREEN', array('TITLE' => get_page_title('DELETE_POSTS'), 'TEXT' => do_lang_tempcode('CONFIRM_DELETE', $stuff), 'URL' => $post_url, 'HIDDEN' => $hidden));
         }
         foreach ($posts as $post) {
             require_code('fields');
             if (has_tied_catalogue('post')) {
                 delete_form_custom_fields('post', $post['id']);
             }
             ocf_delete_posts_topic($post['p_topic_id'], array($post['id']), $reason);
         }
         return $this->redirect_to('DELETE_POSTS_FROM_IP', $topic_id);
     }
     $topic_id = $GLOBALS['FORUM_DB']->query_value_null_ok('f_posts', 'p_topic_id', array('id' => $post_id));
     if (is_null($topic_id)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $_topic_info = $GLOBALS['FORUM_DB']->query_select('f_topics', array('t_cache_first_title', 't_cache_first_post_id', 't_forum_id'), array('id' => $topic_id), '', 1);
     $current_title = $_topic_info[0]['t_cache_first_title'];
     $deleted_all = ocf_delete_posts_topic($topic_id, array($post_id), $reason);
     if ($_topic_info[0]['t_cache_first_post_id'] == $post_id) {
         $_topic_info2 = $GLOBALS['FORUM_DB']->query_select('f_topics', array('t_cache_first_title', 't_cache_first_post_id'), array('id' => $topic_id), '', 1);
         if (array_key_exists(0, $_topic_info2)) {
             if ($_topic_info2[0]['t_cache_first_title'] == do_lang('NO_TOPIC_TITLE', strval($topic_id))) {
                 $GLOBALS['FORUM_DB']->query_update('f_posts', array('p_title' => $current_title), array('id' => $_topic_info2[0]['t_cache_first_post_id']), '', 1);
             }
         }
     }
     require_code('fields');
     if (has_tied_catalogue('post')) {
         delete_form_custom_fields('post', strval($post_id));
     }
     if ($deleted_all) {
         return $this->redirect_to_forum('DELETE_POST', $_topic_info[0]['t_forum_id']);
     }
     return $this->redirect_to('DELETE_POST', $topic_id);
 }