Exemplo n.º 1
0
 /**
  * Overwrite checkAuthentication.
  * We don't use the normal authentication. Instead, we have to authenticate the user based on httpauth data.
  */
 public function checkAuthentication()
 {
     try {
         if (array_key_exists('PHP_AUTH_USER', $_SERVER)) {
             Phprojekt_Auth::login($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
             $_SERVER['PHP_AUTH_USER'] = strtolower(Phprojekt_Auth::getRealUser()->username);
         }
     } catch (Phprojekt_Auth_Exception $e) {
         // We have to delete the stack trace here because we need to avoid logging the user's password.
         // This would be done because of Phprojekt_Auth::login($user, $password)
         throw new Phprojekt_Auth_Exception($e->getMessage(), $e->getCode());
     }
 }
Exemplo n.º 2
0
 /**
  * Index.
  *
  * If the user is an admin and we need upgrades, print a form.
  * Else, print a message depending on the situation.
  */
 public function indexAction()
 {
     $config = Phprojekt::getInstance()->getConfig();
     $language = Phprojekt_Auth::getRealUser()->getSetting("language", $config->language);
     $this->view->language = $language;
     $this->view->compressedDojo = (bool) $config->compressedDojo;
     $this->view->frontendMsg = (bool) $config->frontendMessages;
     $this->view->newVersion = Phprojekt::getVersion();
     $extensions = new Phprojekt_Extensions(PHPR_CORE_PATH);
     $migration = new Phprojekt_Migration($extensions);
     if ($migration->needsUpgrade()) {
         if (!Phprojekt_Auth::isAdminUser()) {
             $this->render('upgradeLocked');
         } else {
             $this->view->modules = $migration->getModulesNeedingUpgrade();
             $this->render('upgrade');
         }
     } else {
         $this->render('upgradeIdle');
     }
 }
Exemplo n.º 3
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');
     }
 }
Exemplo n.º 4
0
 /**
  * Save the settings into the table.
  *
  * @param array   $params $_POST fields.
  * @param integer $userId The user ID, if is not setted, the current user is used.
  *
  * @return void
  */
 public function setSettings($params, $userId = 0)
 {
     if (!$userId) {
         $userId = Phprojekt_Auth::getUserId();
     }
     if (empty($params['password'])) {
         $password = Phprojekt_Auth::getRealUser()->getSetting('password', $userId);
     } else {
         $password = Phprojekt_Auth::cryptString($params['password']);
     }
     $namespace = new Zend_Session_Namespace(Phprojekt_Setting::IDENTIFIER . $userId);
     $fields = $this->getFieldDefinition(Phprojekt_ModelInformation_Default::ORDERING_FORM);
     foreach ($fields as $data) {
         foreach ($params as $key => $value) {
             if ($key == $data['key'] && $key != 'oldValue' && $key != 'confirmValue') {
                 if ($key == 'proxies') {
                     if (count($value) === 1 && $value[0] === "") {
                         $value = array();
                     }
                     $proxyTable = new Phprojekt_Auth_ProxyTable();
                     $proxyTable->setProxyIdsForUserId($value);
                 } else {
                     $setting = new Phprojekt_Setting();
                     $setting->setModule('User');
                     if ($key == 'password') {
                         $value = $password;
                     }
                     $where = sprintf('user_id = %d AND key_value = %s AND module_id = %d', (int) $userId, $setting->_db->quote($key), 0);
                     $record = $setting->fetchAll($where);
                     if (isset($record[0])) {
                         $record[0]->keyValue = $key;
                         $record[0]->value = $value;
                         $record[0]->save();
                     } else {
                         $setting->userId = $userId;
                         $setting->moduleId = 0;
                         $setting->keyValue = $key;
                         $setting->value = $value;
                         $setting->identifier = 'Core';
                         $setting->save();
                     }
                     $namespace->{$key} = $value;
                 }
                 break;
             }
         }
     }
 }