/**
  * Gets called on a authenication request. This method should check sessions or simmilar to
  * verify that the user has access to the backend.
  *
  * This method should return true if the current request is authenicated or false if it's not.
  *
  * @param ManagerEngine $man ManagerEngine reference that the plugin is assigned to.
  * @return bool true/false if the user is authenticated.
  */
 function ActualonAuthenticate(&$man)
 {
     $config =& $man->getConfig();
     // Support both old and new format
     $loggedInKey = isset($config['SessionAuthenticator.logged_in_key']) ? $config['SessionAuthenticator.logged_in_key'] : $config["authenticator.session.logged_in_key"];
     $userKey = isset($config['SessionAuthenticator.user_key']) ? $config['SessionAuthenticator.user_key'] : $config["authenticator.session.user_key"];
     $pathKey = isset($config['SessionAuthenticator.path_key']) ? $config['SessionAuthenticator.path_key'] : $config["authenticator.session.path_key"];
     $rootPathKey = isset($config['SessionAuthenticator.rootpath_key']) ? $config['SessionAuthenticator.rootpath_key'] : $config["authenticator.session.rootpath_key"];
     $configPrefix = (isset($config['SessionAuthenticator.config_prefix']) ? $config['SessionAuthenticator.config_prefix'] : "mcmanager") . ".";
     // Switch path
     if (isset($_SESSION[$pathKey])) {
         $config['filesystem.path'] = $_SESSION[$pathKey];
     }
     // Switch root
     if (isset($_SESSION[$rootPathKey])) {
         $config['filesystem.rootpath'] = $_SESSION[$rootPathKey];
     }
     $user = isset($_SESSION[$userKey]) ? $_SESSION[$userKey] : "";
     $user = preg_replace('/[\\\\\\/:]/i', '', $user);
     // Override by prefix
     foreach ($_SESSION as $key => $value) {
         if (strpos($key, $configPrefix) === 0) {
             $config[substr($key, strlen($configPrefix))] = $value;
         }
     }
     foreach ($config as $key => $value) {
         // Skip replaceing {$user} in true/false stuff
         if ($value === true || $value === false) {
             continue;
         }
         $value = str_replace('${user}', $user, $value);
         $config[$key] = $value;
     }
     return isset($_SESSION[$loggedInKey]) && checkBool($_SESSION[$loggedInKey]);
 }
Exemple #2
0
 /**
  * Gets called after any authenication is performed and verified. This method can be used
  * to override config options or add custom filesystems.
  *
  * @param ManagerEngine $man ManagerEngine reference that the plugin is assigned to.
  * @return bool true/false if the execution of the event chain should continue.
  */
 function onInit(&$man)
 {
     $config = $man->getConfig();
     // Override option
     $config['somegroup.someoption'] = true;
     return true;
 }
 /**
  * Gets called on a authenication request. This method should check sessions or simmilar to
  * verify that the user has access to the backend.
  *
  * This method should return true if the current request is authenicated or false if it's not.
  *
  * @param ManagerEngine $man ManagerEngine reference that the plugin is assigned to.
  * @return bool true/false if the user is authenticated.
  */
 function onAuthenticate(&$man)
 {
     global $moozCMS;
     $config =& $man->getConfig();
     $moozCMSConfig = $moozCMS->getConfig();
     // Override with CMS options
     $prefix = $man->getType() == 'fm' ? 'filemanager' : 'imagemanager';
     foreach ($moozCMSConfig as $key => $value) {
         if (strpos($key, $prefix . '.') === 0) {
             $config[preg_replace('/^' . $prefix . '\\./', '', $key)] = $value;
         }
     }
     return $moozCMS->isAuthenticated();
 }