diff --git a/src/Controller/AppController.php b/src/Controller/AppController.php deleted file mode 100755 index 9dbc0e5..0000000 --- a/src/Controller/AppController.php +++ /dev/null @@ -1,98 +0,0 @@ -. - * - * - * @author AVERWAY LTD - * @license GNU/GPLv3 or later; https://www.gnu.org/licenses/gpl.html - * @copyright 2017 AVERWAY LTD - * - * SophiMail is a registered trademark of AVERWAY LTD - * - */ -namespace App\Controller; - -use Cake\Controller\Controller; -use Cake\Event\Event; -use Cake\Core\Configure; - -/** - * Application Controller - * - * Add your application-wide methods in the class below, your controllers - * will inherit them. - * - * @link http://book.cakephp.org/3.0/en/controllers.html#the-app-controller - */ -class AppController extends Controller -{ - - /** - * Initialization hook method. - * - * Use this method to add common initialization code like loading components. - * - * e.g. `$this->loadComponent('Security');` - * - * @return void - */ - public function initialize() - { - parent::initialize(); - - $this->loadComponent('RequestHandler'); - $this->loadComponent('Flash'); - $this->loadComponent('CakeDC/Users.UsersAuth'); - $this->loadComponent('Global'); - - } - - /* - public function beforeFilter(Event $event) - { - $this->Security->config('unlockedActions', ['register']); - } - */ - - /** - * Before render callback. - * - * @param \Cake\Event\Event $event The beforeRender event. - * @return void - */ - public function beforeRender(Event $event) - { - if (!array_key_exists('_serialize', $this->viewVars) && - in_array($this->response->type(), ['application/json', 'application/xml']) - ) { - $this->set('_serialize', true); - } - } - - public function beforeFilter(Event $event){ - if ($this->Global->_UserDomainDatasourceExists()) { - Configure::write('_domain', $this->Global->_getDomain()); - Configure::write('_datasource', $this->Global->_getDatasource()); - } else { - $this->Global->_deleteParams(); - } - } -} diff --git a/src/Controller/Component/GlobalComponent.php b/src/Controller/Component/GlobalComponent.php deleted file mode 100755 index 599f50e..0000000 --- a/src/Controller/Component/GlobalComponent.php +++ /dev/null @@ -1,83 +0,0 @@ -. - * - * - * @author AVERWAY LTD - * @license GNU/GPLv3 or later; https://www.gnu.org/licenses/gpl.html - * @copyright 2017 AVERWAY LTD - * - * SophiMail is a registered trademark of AVERWAY LTD - * - */ -namespace App\Controller\Component; - -use Cake\Controller\Component; -use Cake\ORM\TableRegistry; -use Cake\Core\Configure; - -class GlobalComponent extends Component -{ - - public function _deleteParams() { - $this->request->session()->delete('Auth.User.datasource'); - $this->request->session()->delete('Auth.User.domain'); - Configure::delete('_domain'); - Configure::delete('_datasource'); - } - - - public function _getDomain() { - if ($this->_UserDomainExists()) { - $results = TableRegistry::get('Shards')->get($this->request->session()->read('Auth.User.domain')); - return $results['domain']; - } - - return false; - } - - - public function _getDatasource() { - if ($this->_DomainDatasourceExists()) { - $results = TableRegistry::get('Accounts')->get($this->request->session()->read('Auth.User.datasource')); - return $results['datasource']; - } - - return false; - } - - - public function _UserDomainExists() { - if (($this->request->session()->read('Auth.User.id')) && ($this->request->session()->read('Auth.User.domain'))) - return TableRegistry::get('UsersShards')->exists(['user_id' => $this->request->session()->read('Auth.User.id'), 'shard_id' => $this->request->session()->read('Auth.User.domain')]); - } - - - public function _DomainDatasourceExists() { - if (($this->request->session()->read('Auth.User.datasource')) && ($this->request->session()->read('Auth.User.domain'))) - return TableRegistry::get('ShardsAccounts')->exists(['account_id' => $this->request->session()->read('Auth.User.datasource'), 'shard_id' => $this->request->session()->read('Auth.User.domain')]); - } - - - public function _UserDomainDatasourceExists() { - return (($this->_UserDomainExists()) && ($this->_DomainDatasourceExists())); - } -}