/** * Delete selected posts * * @access private */ private function delete() { if ((VRequest::action() == 'delete' && VRequest::id() || VPost::delete(false) || VPost::empty_trash(false)) && $this->_user['delete_content']) { try { $post = new Post(); if (VGet::action() == 'delete' && VGet::id()) { $post->_id = VGet::id(); $post->delete(); $this->_db->query('DELETE FROM `' . DB_PREFIX . 'comment` WHERE comment_rel_id = ' . VGet::id() . ' AND comment_rel_type = "post"'); $result = $post->_result_action; } elseif (VPost::delete(false)) { foreach (VPost::post_id() as $id) { $post->_id = $id; $post->delete(); $this->_db->query('DELETE FROM `' . DB_PREFIX . 'comment` WHERE comment_rel_id = ' . $id . ' AND comment_rel_type = "post"'); } $result = $post->_result_action; } elseif (VPost::empty_trash(false)) { $to_read['table'] = 'post'; $to_read['columns'] = array('POST_ID'); $to_read['condition_columns'][':s'] = 'post_status'; $to_read['condition_select_types'][':s'] = '='; $to_read['condition_values'][':s'] = 'trash'; $to_read['value_types'][':s'] = 'str'; $posts = $this->_db->read($to_read); foreach ($posts as $post) { $this->_db->query('DELETE FROM `' . DB_PREFIX . 'comment` WHERE comment_rel_id = ' . $post['POST_ID'] . ' AND comment_rel_type = "post"'); } $to_delete['table'] = 'post'; $to_delete['condition_columns'][':status'] = 'post_status'; $to_delete['condition_values'][':status'] = 'trash'; $to_delete['value_types'][':status'] = 'str'; $result = $this->_db->delete($to_delete); } Session::monitor_activity('deleted post(s)'); $this->_action_msg = ActionMessages::deleted($result); } catch (Exception $e) { $this->_action_msg = ActionMessages::custom_wrong($e->getMessage()); } } elseif ((VRequest::action() == 'delete' && VRequest::id() || VPost::delete(false) || VPost::empty_trash(false)) && $this->_user['delete_content'] === false) { $this->_action_msg = ActionMessages::action_no_perm(); } }