/** * 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(); } }