/** * 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(); } }
/** * If in edit mode create a new post object, else create an empty post object * * @access private */ private function get_post() { if ((VRequest::action() == 'edit' || VRequest::action() == 'to_update') && VRequest::id()) { try { $this->_post = new Post(VRequest::id()); $this->_action = 'to_update'; } catch (Exception $e) { $this->_action_msg = ActionMessages::custom_wrong($e->getMessage()); $this->_post = new Post(); $this->_action = 'to_insert'; } } else { $this->_post = new Post(); $this->_action = 'to_insert'; } }
/** * Display pagination * * @access private */ private function display_pagination() { if ($this->_max > 1) { $link = null; if (VRequest::filter(false)) { $link = '&filter=true&date=' . VRequest::date() . '&category=' . VRequest::category() . '&type=' . $this->_view_type; } elseif (!empty($this->_search)) { $link = '&search=' . $this->_search; } elseif (VGet::author()) { $link = '&author=' . VGet::author; } else { $link = '&type=' . $this->_view_type; } Html::pagination($this->_page, $this->_max, $link, 'Medias'); } }
/** * Method that permits to delete one or more comments at a time * * @access private */ private function delete() { if ((isset($_POST['empty']) || VRequest::action() == 'delete') && $this->_user['delete_content']) { if (isset($_POST['empty']) && VPost::comment_status() && in_array(VPost::comment_status(), array('spam', 'trash'))) { $to_delete['table'] = 'comment'; $to_delete['condition_columns'][':status'] = 'comment_status'; $to_delete['condition_values'][':status'] = VPost::comment_status(); $to_delete['value_types'][':status'] = 'str'; $global_result = $this->_db->delete($to_delete); } elseif (VPost::action() == 'delete' && VPost::comment_id()) { $results = array(); $global_result = true; foreach (VPost::comment_id() as $id) { try { $comment = new Comment(); $comment->_id = $id; $comment->delete(); unset($comment); array_push($results, true); } catch (Exception $e) { array_push($results, false); } } foreach ($results as $result) { if ($result !== true) { $global_result = false; } } } elseif (VGet::action() == 'delete' && VGet::comment_id()) { try { $comment = new Comment(); $comment->_id = VGet::comment_id(); $comment->delete(); $global_result = true; } catch (Exception $e) { $global_result = false; } } if (isset($global_result)) { $this->_action_msg = ActionMessages::deleted($global_result); } } elseif ((isset($POST['empty']) || VRequest::action() == 'delete') && $this->_user['delete_content'] === false) { $this->_action_msg = ActionMessages::action_no_perm(); } }
/** * Display pagination * * @access private */ private function display_pagination() { if ($this->_max > 1) { $link = null; if (VRequest::filter(false)) { $link = '&filter=true&date=' . VRequest::date() . '&category=' . VRequest::category(); } elseif (!empty($this->_search)) { $link = '&search=' . $this->_search; } Html::pagination($this->_page, $this->_max, $link, 'Albums'); } }