Esempio n. 1
0
 /**
  * Returns a list of all the users the current user has proxy rights on
  *
  * Returns a list of all the users with:
  * <pre>
  *  - id      => id of user.
  *  - display => Display for the user.
  *  - current => True or false if is the current user.
  * </pre>
  *
  * The return is in JSON format.
  *
  * @return void
  */
 public function jsonGetProxyableUsersAction()
 {
     $current = Phprojekt_Auth_Proxy::getEffectiveUserId();
     $proxyTable = new Phprojekt_Auth_ProxyTable();
     $proxyUserIds = $proxyTable->getProxyableUsersForUserId();
     $data = array();
     foreach ($proxyUserIds as $user) {
         $data['data'][] = array('id' => (int) $user->id, 'display' => $user->displayName, 'current' => $current == $user->id);
     }
     Phprojekt_Converter_Json::echoConvert($data, Phprojekt_ModelInformation_Default::ORDERING_LIST);
 }
Esempio n. 2
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;
             }
         }
     }
 }