Exemplo n.º 1
0
 public function indexAction()
 {
     // Set the root directory
     $webdavPath = Phprojekt::getInstance()->getConfig()->webdavPath;
     if (Phprojekt_Auth::isLoggedIn()) {
         $project = new Project_Models_Project();
         $project = $project->find(1);
         $rootDirectory = new WebDAV_Models_ProjectDirectory($project);
     } else {
         // Some clients seem to send some queries without http auth. We need the dummy to serve those.
         $rootDirectory = new WebDAV_Models_EmptyDir();
     }
     // The server object is responsible for making sense out of the WebDAV protocol
     $server = new Sabre_DAV_Server($rootDirectory);
     $server->setBaseUri($this->view->baseUrl('index.php/WebDAV/index/index/'));
     // The lock manager is reponsible for making sure users don't overwrite each others changes.
     // Change 'data' to a different directory, if you're storing your data somewhere else.
     $lockBackend = new Sabre_DAV_Locks_Backend_File($webdavPath . 'data/locks');
     $lockPlugin = new Sabre_DAV_Locks_Plugin($lockBackend);
     $server->addPlugin($lockPlugin);
     // Authentication
     $authBackend = new WebDAV_Helper_Auth();
     $authPlugin = new Sabre_DAV_Auth_Plugin($authBackend, 'WebDAV');
     $server->addPlugin($authPlugin);
     // All we need to do now, is to fire up the server
     $server->exec();
 }
Exemplo n.º 2
0
 public function routeShutdown(Zend_Controller_Request_Abstract $request)
 {
     /* Redirect to the upgrade controller if an upgrade is neccessary */
     if (Phprojekt_Auth::isLoggedIn() && ($request->getModuleName() != 'Core' || $request->getControllerName() != 'Upgrade') && ($request->getControllerName() != 'Login' || $request->getActionName() != 'logout')) {
         $migration = new Phprojekt_Migration($this->_extensions);
         if ($migration->needsUpgrade()) {
             $this->_request->setModuleName('Core');
             $this->_request->setControllerName('Upgrade');
             $this->_request->setActionName('index');
         }
     }
 }
Exemplo n.º 3
0
 /**
  * Trying a login with a valid user and its password
  * This try has to log in the user
  */
 public function testLogin()
 {
     $tmp = Phprojekt_Auth::login('Test', 'test');
     $this->assertTrue($tmp);
     /* logged in needs to be true */
     $this->assertTrue(Phprojekt_Auth::isLoggedIn());
 }
Exemplo n.º 4
0
 /**
  * Trying a login with a valid user and its password
  * This try has to log in the user
  */
 public function testLogin()
 {
     try {
         $tmp = Phprojekt_Auth::login('david', 'test');
     } catch (Phprojekt_Auth_Exception $error) {
         $this->fail($error->getMessage() . " " . $error->getCode());
     }
     $this->assertTrue($tmp);
     /* logged in needs to be true */
     $this->assertTrue(Phprojekt_Auth::isLoggedIn());
 }
Exemplo n.º 5
0
 /**
  * Init function.
  *
  * Checks if it is a logged user, if not,
  * is redirected to the login form or throws an exception.
  *
  * The function sets up the helper and cleans all the variables.
  *
  * @throws Phprojekt_PublishedException If the user is not logged in and the request is a POST.
  *
  * @return void
  */
 public function init()
 {
     $isLoggedIn = true;
     try {
         Phprojekt_Auth::isLoggedIn();
         // Check the CSRF token
         $this->checkCsrfToken();
     } catch (Phprojekt_Auth_UserNotLoggedInException $error) {
         // User not logged in, display login page
         // If is a GET, show the index page with isLogged false
         // If is a POST, send message in json format
         if (!$this->getFrontController()->getRequest()->isGet()) {
             throw new Phprojekt_PublishedException($error->message, 500);
         }
         $isLoggedIn = false;
     }
     // This is a work around as we cannot set this in the front
     $this->_helper->viewRenderer->setNoRender();
     $this->view->clearVars();
     $this->view->isLoggedIn = $isLoggedIn;
 }
Exemplo n.º 6
0
 /**
  * Standard action.
  *
  * The function sets up the template index.phtml and renders it.
  *
  * @return void
  */
 public function indexAction()
 {
     $language = Phprojekt_Auth::getRealUser()->getSetting("language", Phprojekt::getInstance()->getConfig()->language);
     $this->view->language = $language;
     $this->view->compressedDojo = (bool) Phprojekt::getInstance()->getConfig()->compressedDojo;
     $this->view->frontendMsg = (bool) Phprojekt::getInstance()->getConfig()->frontendMessages;
     // Since the time for re-starting a poll to the server is in milliseconds, a multiple of 1000 is needed here.
     $this->view->pollingLoop = Phprojekt::getInstance()->getConfig()->pollingLoop * 1000;
     if (Phprojekt_Auth::isLoggedIn()) {
         $this->render('index');
     } else {
         $this->render('login');
     }
 }