<?php


// TODO: in order to activate the debug we will have to extra login with a token.

namespace Modules\Utils\Debug;

/**
 * Manages debug actions and session config. It is also used for cleaning up junk data in updaterVars after a failed update.
 * Access [PATH_TO_TINA]/disp.php?module=Utils/Debug/&debug=1 - to activate the debug.
 */
class Controller extends \App\Mvc\ControllerAbstract
{

	/**
	 * (non-PHPdoc)
	 * @see \App\Mvc\Controller\Window\PaginatedListing\PaginatedListing::initialize()
	 */
	protected function initialize()
	{
		parent::initialize();

		$this->actionsCfg['index'] = ['authType'=>'none', 'checkSection' => false, 'checkOption'=>false];

		// hide userTrail in db
		\App\UserTrail::getInstance()->storeTrail(false);

	}


	protected function actionIndex(array $R)
	{

		// activate the DEBUG
		if (isset($R['debug'])) {
			global $S;
			$S['_engine']['showDebugs'] = (bool)$R['debug'];
		}

		// clean updater vars on invalid update and mismatched kit ids with LIDIA
		if (SHOW_DEBUGS and $R['cleanUpdaterVars']) {
			$updaterVarsObj = \App\Config\UpdaterVars::getAdmin();
			$updaterVarsObj->delete('currentIdInstanceKit');
			$updaterVarsObj->delete('currentIdProductVersionPatch');
			$updaterVarsObj->save();
		}

		return new \Engine\Mvc\Response\None();

	}


}

