Beispiel #1
0
 public function put($id, $update, $before = null, $after = null, $put_style = 'default')
 {
     $loginApi = new KUser_loginApi();
     $uid = $loginApi->iGetLoginUid();
     if (!$uid || $uid != $id) {
         throw new Exception('修改密码失败', 1);
     }
     switch ($put_style) {
         case 'passwd':
             if (!preg_match('/^[_0-9a-z]{4,16}$/i', $update['newpasswd'])) {
                 throw new Exception('登录密码只能使用字母,数字和下划线,4-16个字符', 2);
             }
             if (false === $loginApi->bChangePassword($uid, $update['oldpasswd'], $update['newpasswd'], $errno)) {
                 throw new Exception('旧密码输入错误', 3);
             }
             break;
         case 'profile':
             if ('' == $update['nickname']) {
                 throw new Exception('请输入昵称', 4);
             }
             $baseinfoApi = new KUser_baseinfoApi();
             $baseinfoApi->bUpdateNickname($uid, $update['nickname']);
             break;
     }
     return array('key' => $id);
 }