Ignore:
Timestamp:
Oct 24, 2013, 6:21:24 PM (11 years ago)
Author:
mistic100
Message:

feature 2976: can change user status and level
fix saving problem of groups.is_default value
use WS_PARAM_OPTIONAL when possible (TODO: use for old methods)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/ws_functions.inc.php

    r25117 r25118  
    32173217    array(
    32183218      'name' => $params['name'],
    3219       'is_default' => $params['is_default'],
     3219      'is_default' => boolean_to_string($params['is_default']),
    32203220      )
    32213221    );
     
    33133313  if ($params['is_default'] !== null)
    33143314  {
    3315     $updates['is_default'] = $params['is_default'];
     3315    $updates['is_default'] = boolean_to_string($params['is_default']);
    33163316  }
    33173317 
     
    35553555function ws_users_setInfo($params, &$service)
    35563556{
    3557   global $conf;
     3557  global $conf, $user;
    35583558 
    35593559  include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
     
    35643564  }
    35653565 
    3566   $updates = array();
     3566  $updates = $updates_infos = array();
    35673567  $params = array_map('trim', $params);
    35683568 
     
    35933593  {
    35943594    $updates[ $conf['user_fields']['password'] ] = $conf['password_hash']($params['password']);
     3595  }
     3596 
     3597  if (!empty($params['status']))
     3598  {
     3599    if ( $params['status'] == 'webmaster' and !is_webmaster() )
     3600    {
     3601      return new PwgError(403, 'Only webmasters can grant "webmaster" status');
     3602    }
     3603    if ( $user['id'] == $params['user_id'] )
     3604    {
     3605      $params['status'] = $user['status'];
     3606    }
     3607    if ( $conf['guest_id'] == $params['user_id'] )
     3608    {
     3609      $params['status'] = 'guest';
     3610    }
     3611    $updates_infos['status'] = $params['status'];
     3612  }
     3613 
     3614  if ($params['level'] !== null)
     3615  {
     3616    if ( !in_array($params['level'], $conf['available_permission_levels']) )
     3617    {
     3618      return new PwgError(WS_ERR_INVALID_PARAM, 'Invalid level');
     3619    }
     3620    $updates_infos['level'] = $params['level'];
    35953621  }
    35963622 
     
    36003626    array($conf['user_fields']['id'] => $params['user_id'])
    36013627    );
     3628   
     3629  single_update(
     3630    USER_INFOS_TABLE,
     3631    $updates_infos,
     3632    array('user_id' => $params['user_id'])
     3633    );
    36023634
    36033635  return $service->invoke('pwg.users.getList', array('user_id' => $params['user_id']));
Note: See TracChangeset for help on using the changeset viewer.