Exemple #1
0
 public function initialize()
 {
     // check if user is logged in
     $authentication = Authentication::getInstance();
     $request = Request::getInstance();
     if ($authentication->isLogin() && !$authentication->isRole(SystemUser::ROLE_BACKEND)) {
         $this->log->info("Failed access for " . $authentication->getUserName() . " (not enough privileges for admin section) from " . $request->getValue('REMOTE_ADDR', Request::SERVER));
         throw new Exception('Access denied');
     }
     // check if admin section is restricted by ip-addresses
     $ip_allow = $this->director->getConfig()->admin_section_ip_allow;
     if ($ip_allow) {
         $ips = explode(",", $ip_allow);
         if (!in_array($request->getValue('REMOTE_ADDR', Request::SERVER), $ips)) {
             $this->log->info("Failed access for " . $authentication->getUserName() . " (ip not in list for admin access) from " . $request->getValue('REMOTE_ADDR', Request::SERVER));
             throw new Exception('Access denied');
         }
     }
     // create tree object
     $treefile = Director::getConfigPath() . $this->director->getConfig()->admin_menu;
     $useLogin = $this->director->getConfig()->dsn;
     $this->tree = new AdminTree($treefile, $useLogin);
     $this->tree->setPrefix($this->urlPrefix);
     // check if path is set. is not, get the startpage path
     $path = $request->getPath();
     $currentId = $this->tree->isSiteRoot() ? $this->tree->getStartNodeId() : $this->tree->getIdFromPath($path);
     // current id does not exist. try to search login pages
     if (!$currentId && $this->tree->pathExists($path)) {
         $this->tree->setCurrentIdExists($this->tree->getIdFromPath($path, Tree::TREE_ORIGINAL));
     }
     $this->tree->setCurrentId($currentId);
 }
Exemple #2
0
 /**
  * handle post delete functions
  * this function removes the extension files
  *
  * @param array filtered values for insertion
  * @return void
  * @see DbConnector::handlePostDelete
  */
 protected function handlePostDelete($id, $values)
 {
     $className = $values['classname'];
     $configFile = Director::getConfigPath() . strtolower($className) . ".ini";
     if (file_exists($configFile)) {
         unlink($configFile);
     }
     $extensionPath = $this->getExtensionPath($className);
     Utils::removeRecursive($extensionPath);
 }