Author: Tijs Verkoyen (tijs@sumocoders.be)
Author: Dave Lens (dave.lens@netlash.com)
Author: Davy Hellemans (davy.hellemans@netlash.com)
Author: Dieter Vanden Eynde (dieter.vandeneynde@netlash.com)
Inheritance: extends Backend\Core\Engine\Base\Object
コード例 #1
0
ファイル: Url.php プロジェクト: forkcms/forkcms
 /**
  * Process a regular request
  *
  * @param string $module The requested module.
  * @param string $action The requested action.
  * @param string $language The requested language.
  */
 private function processRegularRequest($module, $action, $language)
 {
     // the person isn't logged in? or the module doesn't require authentication
     if (!Authentication::isLoggedIn() && !Authentication::isAllowedModule($module)) {
         // redirect to login
         $this->redirect('/' . NAMED_APPLICATION . '/' . $language . '/authentication?querystring=' . rawurlencode('/' . $this->getQueryString()));
     } elseif (Authentication::isLoggedIn() && !Authentication::isAllowedModule($module)) {
         // the person is logged in, but doesn't have access to our action
         // if the module is the dashboard redirect to the first allowed module
         if ($module == 'Dashboard') {
             // require navigation-file
             require_once Navigation::getCacheDirectory() . 'navigation.php';
             // loop the navigation to find the first allowed module
             foreach ($navigation as $value) {
                 // split up chunks
                 list($module, $action) = explode('/', $value['url']);
                 // user allowed?
                 if (Authentication::isAllowedModule($module)) {
                     // redirect to the page
                     $this->redirect('/' . NAMED_APPLICATION . '/' . $language . '/' . $value['url']);
                 } else {
                     if (array_key_exists('children', $value)) {
                         foreach ($value['children'] as $subItem) {
                             // split up chunks
                             list($module, $action) = explode('/', $subItem['url']);
                             // user allowed?
                             if (Authentication::isAllowedModule($module)) {
                                 $finder = new Finder();
                                 $files = $finder->files()->name('*.php')->in(BACKEND_MODULES_PATH . '/' . \SpoonFilter::toCamelCase($module) . '/Actions');
                                 foreach ($files as $file) {
                                     $moduleAction = mb_substr($file->getFilename(), 0, -4);
                                     if (Authentication::isAllowedAction($moduleAction, $module)) {
                                         $this->redirect('/' . NAMED_APPLICATION . '/' . $language . '/' . $module . '/' . $moduleAction);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         // the user doesn't have access, redirect to error page
         $this->redirect('/' . NAMED_APPLICATION . '/' . $language . '/error?type=module-not-allowed&querystring=' . rawurlencode('/' . $this->getQueryString()), 307);
     } elseif (!Authentication::isAllowedAction($action, $module)) {
         // the user hasn't access, redirect to error page
         $this->redirect('/' . NAMED_APPLICATION . '/' . $language . '/error?type=action-not-allowed&querystring=' . rawurlencode('/' . $this->getQueryString()), 307);
     } else {
         // set the working language, this is not the interface language
         BackendLanguage::setWorkingLanguage($language);
         $this->setLocale();
         $this->setModule($module);
         $this->setAction($action);
     }
 }
コード例 #2
0
ファイル: Model.php プロジェクト: forkcms/forkcms
 /**
  * Clear all applications cache.
  *
  * Note: we do not need to rebuild anything, the core will do this when noticing the cache files are missing.
  */
 public static function clearCache()
 {
     $finder = new Finder();
     $filesystem = new Filesystem();
     foreach ($finder->files()->name('*.php')->name('*.js')->in(BACKEND_CACHE_PATH . '/Locale')->in(FRONTEND_CACHE_PATH . '/Navigation')->in(FRONTEND_CACHE_PATH . '/Locale') as $file) {
         $filesystem->remove($file->getRealPath());
     }
     $filesystem->remove(Navigation::getCacheDirectory() . 'navigation.php');
 }