/** * 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(); } }
/** * Method that permits to delete one or more categories * * @access private */ private function delete() { if (VPost::delete(false) && $this->_user['delete_content']) { if (VPost::category_id()) { try { foreach (VPost::category_id() as $id) { $cat = new Category(); $cat->_id = $id; $cat->read('_name'); $cat->read('_type'); $type = $cat->_type; if ($this->check_usage($id, $type)) { throw new Exception('Can\'t delete ' . $cat->_name . ' because it\'s used!'); } $cat->delete(); $this->check_empty($type); } Session::monitor_activity('deleted ' . count(VPost::category_id()) . ' category(ies)'); $result = true; } catch (Exception $e) { $result = $e->getMessage(); } $this->_action_msg = ActionMessages::deleted($result); } } elseif (VGet::action() == 'delete' && VGet::id()) { try { $cat = new Category(); $cat->_id = VGet::id(); $cat->read('_name'); $cat->read('_type'); $type = $cat->_type; if ($this->check_usage(VGet::id(), $type)) { throw new Exception('Can\'t delete ' . ucwords($cat->_name) . ' because it\'s used!'); } $cat->delete(); $this->check_empty($type); Session::monitor_activity('deleted a category'); $result = true; } catch (Exception $e) { $result = $e->getMessage(); } $this->_action_msg = ActionMessages::deleted($result); } elseif ((VPost::delete(false) || VGet::action() == 'delete' && VGet::id()) && !$this->_user['delete_content']) { $this->_action_msg = ActionMessages::action_no_perm(); } }
/** * 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(); } }
/** * Delete all registered activity * * @access private */ private function delete() { if (VPost::reset(false) && $this->_user['delete_content']) { try { $this->_db->query('TRUNCATE TABLE ' . DB_PREFIX . 'activity'); $result = true; } catch (Exception $e) { $result = $e->getMessage(); } $this->_action_msg = ActionMessages::deleted($result); } elseif (VPost::reset(false) && !$this->_user['delete_content']) { $this->_action_msg = ActionMessages::action_no_perm(); } }
/** * Delete links * * @access private */ private function delete() { if (VPost::delete(false) && VPost::link_id() && $this->_user['delete_content']) { try { foreach (VPost::link_id() as $id) { $link = new Link(); $link->_id = $id; $link->delete(); $this->_action_msg = ActionMessages::deleted($link->_result_action); } Session::monitor_activity('deleted ' . count(VPost::link_id()) . ' link(s)'); } catch (Exception $e) { $this->_action_msg = ActionMessages::custom_wrong($e->getMessage()); } } elseif (VGet::action() == 'delete' && VGet::id() && $this->_user['delete_content']) { try { $link = new Link(); $link->_id = Vget::id(); $link->delete(); Session::monitor_activity('deleted a link'); $this->_action_msg = ActionMessages::deleted($link->_result_action); } catch (Exception $e) { $this->_action_msg = ActionMessages::custom_wrong($e->getMessage()); } } elseif ((VPost::delete(false) || VGet::action() == 'delete') && $this->_user['delete_content'] === false) { $this->_action_msg = ActionMessages::action_no_perm(); } }
/** * Delete medias from database and on hard drive * * @access private */ private function delete() { if ($this->_user['delete_content'] && VPost::delete(false) && VPost::media_id()) { $results = array(); $global_result = true; foreach (VPost::media_id() as $id) { try { $media = new Media(); $media->_id = $id; $media->read('_permalink'); $path = $media->_permalink; $media->delete(); unset($media); HandleMedia::delete(PATH . $path); $this->_db->query('DELETE FROM `' . DB_PREFIX . 'comment` WHERE comment_rel_id = ' . $id . ' AND comment_rel_type = "media"'); if (VPost::type() == 'alien') { $to_update['table'] = 'media'; $to_update['columns'] = array(':attach' => 'media_attachment'); $to_update['condition_columns'] = array(':ca' => 'media_attachment'); $to_update['column_values'] = array(':attach' => null, ':ca' => $id); $to_update['value_types'] = array(':attach' => 'null', ':ca' => 'int'); $this->_db->update($to_update); } array_push($results, true); } catch (Exception $e) { array_push($results, false); } } foreach ($results as $result) { if ($result !== true) { $global_result = false; } } Session::monitor_activity('deleted ' . count(VPost::media_id()) . ' file(s)'); $this->_action_msg = ActionMessages::deleted($global_result); } elseif ($this->_user['delete_content'] && VGet::action() == 'delete' && VGet::id()) { try { $media = new Media(); $media->_id = VGet::id(); $media->read('_permalink'); $path = $media->_permalink; $media->delete(); unset($media); HandleMedia::delete(PATH . $path); $this->_db->query('DELETE FROM `' . DB_PREFIX . 'comment` WHERE comment_rel_id = ' . VGet::id() . ' AND comment_rel_type = "media"'); if (VGet::type() == 'alien') { $to_update['table'] = 'media'; $to_update['columns'] = array(':attach' => 'media_attachment'); $to_update['condition_columns'] = array(':ca' => 'media_attachment'); $to_update['column_values'] = array(':attach' => null, ':ca' => VGet::id()); $to_update['value_types'] = array(':attach' => 'null', ':ca' => 'int'); $this->_db->update($to_update); } Session::monitor_activity('deleted a file'); $result = true; } catch (Exception $e) { error_log($e->getMessage(), 0); $result = false; } $this->_action_msg = ActionMessages::deleted($result); } elseif (!$this->_user['delete_content'] && (VPost::delete(false) || VGet::action() == 'delete')) { $this->_action_msg = ActionMessages::action_no_perm(); } }
/** * Delete files on hard drive and metadata in database * * @access private */ private function delete() { if (VPost::apply_action(false) && VPost::action() == 'delete' && $this->_user['delete_content']) { if (VPost::album_id()) { try { foreach (VPost::album_id() as $id) { $album = new Media(); $album->_id = $id; $album->read('_permalink'); $to_read['table'] = 'media'; $to_read['columns'] = array('MEDIA_ID'); $to_read['condition_columns'][':id'] = 'media_album'; $to_read['condition_select_types'][':id'] = '='; $to_read['condition_values'][':id'] = $id; $to_read['value_types'][':id'] = 'int'; $ids = $this->_db->read($to_read); if (!empty($ids)) { foreach ($ids as $pid) { $pic = new Media(); $pic->_id = $pid['MEDIA_ID']; $pic->read('_permalink'); $permalink = $pic->_permalink; HandleMedia::delete(PATH . $permalink); $pic->delete(); } } $permalink = $album->_permalink; HandleMedia::delete(PATH . $permalink . 'cover.png'); @rmdir(PATH . $permalink); $album->delete(); $this->_db->query('DELETE FROM `' . DB_PREFIX . 'comment` WHERE comment_rel_id = ' . $id . ' AND comment_rel_type = "media"'); } Session::monitor_activity('deleted ' . count(VPost::album_id()) . ' album(s)'); $result = true; } catch (Exception $e) { $result = $e->getMessage(); } $this->_action_msg = ActionMessages::deleted($result); } } elseif (VGet::action() == 'delete' && VGet::id() && $this->_user['delete_content']) { try { $pic = new Media(); $pic->_id = VGet::id(); $pic->read('_permalink'); $permalink = $pic->_permalink; HandleMedia::delete(PATH . $permalink); $pic->delete(); $this->_db->query('DELETE FROM `' . DB_PREFIX . 'comment` WHERE comment_rel_id = ' . VGet::id() . ' AND comment_rel_type = "media"'); Session::monitor_activity('deleted a picture of an album'); $result = true; } catch (Exception $e) { $result = $e->getMessage(); } $this->_action_msg = ActionMessages::deleted($result); } elseif (VPost::delete_pics(false)) { if (VPost::picture_id()) { try { foreach (VPost::picture_id() as $id) { $pic = new Media(); $pic->_id = $id; $pic->read('_permalink'); $permalink = $pic->_permalink; HandleMedia::delete(PATH . $permalink); $pic->delete(); } Session::monitor_activity('deleted ' . count(VPost::picture_id(array())) . ' picture(s) of an album'); $result = true; } catch (Exception $e) { $result = $e->getMessage(); } } } elseif ((VPost::apply_action(false) && VPost::action() == 'delete' || VGet::action() == 'delete' || VPost::delete_pics(false)) && !$this->_user['delete_content']) { $this->_action_msg = ActionMessages::action_no_perm(); } }
/** * Delete a plugin * * @access private */ private function delete() { if (VPost::delete(false) && VPost::plg_id() && $this->_user['delete_content']) { try { $plg = new Setting(VPost::plg_id()); $plg->_data = json_decode($plg->_data, true); foreach ($plg->_data['admin'] as $file) { File::delete('includes/' . $plg->_data['namespace'] . '/' . $file); } foreach ($plg->_data['site'] as $file) { File::delete(PATH . 'includes/' . $file); } foreach ($plg->_data['library'] as $file) { File::delete('library/' . $plg->_data['namespace'] . '/' . $file); } foreach ($plg->_data['uninstall'] as $query) { $this->_db->query(str_replace('{{prefix}}', DB_PREFIX, $query)); } File::delete(PATH . 'css/' . $plg->_data['namespace'] . '.css', false); $plg->delete(); $result = true; } catch (Exception $e) { $result = $e->getMessage(); } $this->_action_msg = ActionMessages::deleted($result); } elseif (VPost::delete(false) && !$this->_user['delete_content']) { $this->_action_msg = ActionMessages::action_no_perm(); } }
/** * Delete a role * * @access private */ private function delete() { if (VGet::action(false) == 'delete' && !in_array(VGet::role(), array('administrator', 'editor', 'author')) && $this->_user['delete_content']) { try { $to_read['table'] = 'user'; $to_read['columns'] = array('USER_ID'); $to_read['condition_columns'][':r'] = 'user_role'; $to_read['condition_select_types'][':r'] = '='; $to_read['condition_values'][':r'] = VGet::role(); $to_read['value_types'][':r'] = 'str'; $users = $this->_db->read($to_read); if (!empty($users)) { throw new Exception('Can\'t delete the role "' . ucfirst(VGet::role()) . '" because a user is using it!'); } $to_read = null; $to_read['table'] = 'setting'; $to_read['columns'] = array('SETTING_ID'); $to_read['condition_columns'][':t'] = 'setting_type'; $to_read['condition_select_types'][':t'] = '='; $to_read['condition_values'][':t'] = 'role'; $to_read['value_types'][':t'] = 'str'; $to_read['condition_types'][':n'] = 'AND'; $to_read['condition_columns'][':n'] = 'setting_name'; $to_read['condition_select_types'][':n'] = '='; $to_read['condition_values'][':n'] = VGet::role(); $to_read['value_types'][':n'] = 'str'; $role = $this->_db->read($to_read); $role = new Setting($role[0]['SETTING_ID']); $role->delete(); $to_read = null; $to_read['table'] = 'setting'; $to_read['columns'] = array('SETTING_ID'); $to_read['condition_columns'][':t'] = 'setting_type'; $to_read['condition_select_types'][':t'] = '='; $to_read['condition_values'][':t'] = 'all_roles'; $to_read['value_types'][':t'] = 'str'; $roles = $this->_db->read($to_read); $roles = new Setting($roles[0]['SETTING_ID']); $array = json_decode($roles->_data, true); foreach ($array as $key => $value) { if ($value == VGet::role()) { unset($array[$key]); } } $roles->_data = json_encode($array); $roles->update('_data', 'str'); $result = true; } catch (Exception $e) { $result = $e->getMessage(); } $this->_action_msg = ActionMessages::deleted($result); } elseif (VGet::action(false) == 'delete' && !$this->_user['delete_content']) { $this->_action_msg = ActionMessages::action_no_perm(); } }