<commit_before><?php

namespace Backend\Modules\Agenda\Actions;

/*
 * This file is part of Fork CMS.
 *
 * For the full copyright and license information, please view the license
 * file that was distributed with this source code.
 */

use Backend\Core\Engine\Base\ActionDelete as BackendBaseActionDelete;
use Backend\Core\Engine\Model as BackendModel;
use Backend\Core\Engine\Language as BL;
use Backend\Modules\Agenda\Engine\Model as BackendAgendaModel;

/**
 * This action will delete a category
 *
 * @author <NAME> <<EMAIL>>
 */
class DeleteCategory extends BackendBaseActionDelete
{
	/**
	 * Execute the action
	 */
	public function execute()
	{
		$this->id = $this->getParameter('id', 'int');

		// does the item exist
		if($this->id == null || !BackendAgendaModel::existsCategory($this->id)) {
			$this->redirect(
				BackendModel::createURLForAction('categories') . '&error=non-existing'
			);
		}

		// fetch the category
		$this->record = (array) BackendAgendaModel::getCategory($this->id);

		// delete item
		BackendAgendaModel::deleteCategory($this->id);
		BackendModel::triggerEvent($this->getModule(), 'after_delete_category', array('item' => $this->record));

		// category was deleted, so redirect
		$this->redirect(
			BackendModel::createURLForAction('categories') . '&report=deleted-category&var=' .
			urlencode($this->record['title'])
		);
	}
}
<commit_msg>Update DeleteCategory.php<commit_after><?php

namespace Backend\Modules\Team\Actions;

/*
 * This file is part of Fork CMS.
 *
 * For the full copyright and license information, please view the license
 * file that was distributed with this source code.
 */

use Backend\Core\Engine\Base\ActionDelete as BackendBaseActionDelete;
use Backend\Core\Engine\Model as BackendModel;
use Backend\Core\Engine\Language as BL;
use Backend\Modules\Team\Engine\Model as BackendTeamModel;
 
/**
 * This action will delete a category.
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 */
class DeleteCategory extends BackendBaseActionDelete
{
	/**
	 * Execute the action
	 */
	public function execute()
	{
		$this->id = $this->getParameter('id', 'int');

		// does the item exist
		if($this->id !== null && BackendTeamModel::existsCategory($this->id))
		{
			$this->record = (array) BackendTeamModel::getCategory($this->id);

			if(BackendTeamModel::deleteCategoryAllowed($this->id))
			{
				parent::execute();

				// delete item
				BackendTeamModel::deleteCategory($this->id);
				BackendModel::triggerEvent($this->getModule(), 'after_delete_category', array('item' => $this->record));

				// category was deleted, so redirect
				$this->redirect(BackendModel::createURLForAction('categories') . '&report=deleted-category&var=' . urlencode($this->record['title']));
			}
			else $this->redirect(BackendModel::createURLForAction('categories') . '&error=delete-category-not-allowed&var=' . urlencode($this->record['title']));
		}
		else $this->redirect(BackendModel::createURLForAction('categories') . '&error=non-existing');
	}
}

{'fraction_non_alphanumeric': 0.1519787163285667, 'fraction_numerical': 0.0, 'mean_word_length': 4.740458015267175, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6198011', 'n_tokens_mistral': 965, 'n_tokens_neox': 912, 'n_words': 204}