Пример #1
0
 /**
  * Changes user data for both containers.
  *
  * @param  array auth user data and perm type
  * @param int permission user id
  * @return int|bool affected rows on success or false otherwise
  *
  * @access public
  */
 function updateUser($data, $permUserId)
 {
     if (!is_object($this->auth) || !is_object($this->perm)) {
         $this->stack->push(LIVEUSER_ADMIN_ERROR, 'exception', array('msg' => 'Perm and/or Auth container not set.'));
         return false;
     }
     $permData = $this->perm->getUsers(array('fields' => array('auth_user_id', 'auth_container_name'), 'filters' => array('perm_user_id' => $permUserId), 'select' => 'row'));
     if (!$permData) {
         $this->stack->push(LIVEUSER_ADMIN_ERROR, 'exception', array('msg' => 'Could not find user in the permission backend'));
         return false;
     }
     $updateData = array();
     if (array_key_exists('perm_type', $data)) {
         $updateData['perm_type'] = $data['perm_type'];
         unset($data['perm_type']);
     }
     $this->setAdminAuthContainer($permData['auth_container_name']);
     $filters = array('auth_user_id' => $permData['auth_user_id']);
     $result = $this->auth->updateUser($data, $filters);
     if ($result === false) {
         return false;
     }
     if (array_key_exists('auth_user_id', $data) && $permData['auth_user_id'] != $data['auth_user_id']) {
         $updateData['auth_user_id'] = $data['auth_user_id'];
     }
     if (empty($updateData)) {
         return $result;
     }
     $filters = array('perm_user_id' => $permUserId);
     return $this->perm->updateUser($updateData, $filters);
 }