Beispiel #1
0
 /**
  * You have to specify the action and module so we know what to do with this instance
  *
  * @param string $action The action to load.
  * @param string $module The module to load.
  */
 public function __construct($action, $module)
 {
     // grab stuff from the reference and store them in this object (for later/easy use)
     $this->tpl = Spoon::get('template');
     $this->setModule($module);
     $this->setAction($action);
     $this->loadConfig();
     // is the requested action possible? If not we throw an exception. We don't redirect because that could trigger a redirect loop
     if (!in_array($this->getAction(), $this->config->getPossibleActions())) {
         throw new BackendException('This is an invalid action (' . $this->getAction() . ').');
     }
 }
Beispiel #2
0
 /**
  * Load the config file for the requested module.
  * In the config file we have to find dissabled actions, the constructor will read the folder and set possible actions
  * Other configurations will be stored in it also.
  */
 public function loadConfig()
 {
     // check if module path is not yet defined
     if (!defined('BACKEND_MODULE_PATH')) {
         // build path for core
         if ($this->getModule() == 'core') {
             define('BACKEND_MODULE_PATH', BACKEND_PATH . '/' . $this->getModule());
         } else {
             define('BACKEND_MODULE_PATH', BACKEND_MODULES_PATH . '/' . $this->getModule());
         }
     }
     // check if the config is present? If it isn't present there is a huge problem, so we will stop our code by throwing an error
     if (!SpoonFile::exists(BACKEND_MODULE_PATH . '/config.php')) {
         throw new BackendException('The configfile for the module (' . $this->getModule() . ') can\'t be found.');
     }
     // build config-object-name
     $configClassName = 'Backend' . SpoonFilter::toCamelCase($this->getModule() . '_config');
     // require the config file, we validated before for existence.
     require_once BACKEND_MODULE_PATH . '/config.php';
     // validate if class exists (aka has correct name)
     if (!class_exists($configClassName)) {
         throw new BackendException('The config file is present, but the classname should be: ' . $configClassName . '.');
     }
     // create config-object, the constructor will do some magic
     $this->config = new $configClassName($this->getModule());
     // set action
     $action = $this->config->getDefaultAction() !== null ? $this->config->getDefaultAction() : 'index';
     // require the model if it exists
     if (SpoonFile::exists(BACKEND_MODULES_PATH . '/' . $this->config->getModule() . '/engine/model.php')) {
         require_once BACKEND_MODULES_PATH . '/' . $this->config->getModule() . '/engine/model.php';
     }
 }
Beispiel #3
0
 /**
  * Check if all required settings have been set
  *
  * @param string $module The module.
  */
 public function __construct($module)
 {
     parent::__construct($module);
     $this->loadEngineFiles();
     $url = Spoon::exists('url') ? Spoon::get('url') : null;
     // do the client ID check if we're not in the settings page
     if ($url != null && !in_array($url->getAction(), array('settings', 'import_groups', 'link_account', 'load_client_info'))) {
         $this->checkForAccount();
         $this->checkForClientID();
         $this->checkForGroups();
     }
 }
Beispiel #4
0
 /**
  * Check if all required settings have been set
  *
  * @return	void
  * @param	string $module	The module.
  */
 public function __construct($module)
 {
     // parent construct
     parent::__construct($module);
     // load additional engine files
     $this->loadEngineFiles();
     // get url object reference
     $url = Spoon::exists('url') ? Spoon::get('url') : null;
     // do the client ID check if we're not in the settings page
     if ($url != null && $url->getAction() != 'settings' && $url->getAction() != 'import_groups' && strpos($url->getQueryString(), 'link_account') === false && strpos($url->getQueryString(), 'load_client_info') === false) {
         // check for CM account
         $this->checkForAccount();
         // check for client ID
         $this->checkForClientID();
         // check for groups
         $this->checkForGroups();
     }
 }
Beispiel #5
0
 /**
  * Check if all required settings have been set
  *
  * @param string $module The module.
  */
 public function __construct($module)
 {
     parent::__construct($module);
     $error = false;
     $action = Spoon::exists('url') ? Spoon::get('url')->getAction() : null;
     // analytics session token
     if (BackendModel::getModuleSetting('analytics', 'session_token') === null) {
         $error = true;
     }
     // analytics table id
     if (BackendModel::getModuleSetting('analytics', 'table_id') === null) {
         $error = true;
     }
     // missing settings, so redirect to the index-page to show a message (except on the index- and settings-page)
     if ($error && $action != 'settings' && $action != 'index') {
         SpoonHTTP::redirect(BackendModel::createURLForAction('index'));
     }
 }