/**
  * 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();
     }
 }
 /**
  * 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();
     }
 }
 /**
  * Delete a template
  *
  * Current and main template will raise an error
  *
  * @access	private
  */
 private function delete()
 {
     if (VPost::delete(false) && VPost::tpl_id() && $this->_user['delete_content']) {
         try {
             $tpl = new Setting(VPost::tpl_id());
             $tpl->_data = json_decode($tpl->_data, true);
             if ($tpl->_data['namespace'] == $this->_setting->_data) {
                 throw new Exception('Template currently used, action aborted');
             }
             if ($tpl->_data['namespace'] == 'main' || $tpl->_data['namespace'] == 'bobcat') {
                 throw new Exception('Default template can\'t be deleted, action aborted');
             }
             foreach ($tpl->_data['files'] as $file) {
                 File::delete(PATH . 'includes/templates/' . $tpl->_data['namespace'] . '/' . $file);
             }
             $tpl->delete();
             $result = true;
         } catch (Exception $e) {
             $result = $e->getMessage();
         }
         $this->_action_msg = ActionMessages::template_deleted($result);
     } elseif (VPost::delete(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 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();
     }
 }