Ejemplo n.º 1
0
 public static function addMember($tid, $uid)
 {
     $member = new MaTeamMember();
     $member->ctime = MyTool::now();
     $member->mtime = $member->ctime;
     $member->flag = 0;
     $member->deleted = 0;
     $member->tid = $tid;
     $member->uid = $uid;
     return $member;
 }
Ejemplo n.º 2
0
 public function setAction($field)
 {
     MyTool::simpleView($this);
     $field = @trim($field);
     if (!array_key_exists($field, self::$FIELDS)) {
         return $this->onError(MyConst::STATUS_INVALID_PARAM, 'invalid param');
     }
     if (!MyTool::loginAuth($this)) {
         return $this->onError(MyConst::STATUS_NOT_LOGIN, 'must login first');
     }
     $uid = MyTool::getCookie($this, MyConst::COOKIE_UID);
     $user = $this->getUserInfo($uid);
     if (empty($user)) {
         return $this->onError(MyConst::STATUS_INVALID_USER, 'unknown user id');
     }
     $value = MyTool::get($this, MyConst::FIELD_VALUE);
     if (MyTool::eq($field, MyConst::FIELD_OPEN)) {
         $value = MyTool::eq($value, '1') ? 1 : 0;
     }
     $value2 = null;
     if (MyTool::eq($user->{$field}, $value)) {
         return $this->onError(MyConst::STATUS_OK, 'nothing changed');
     }
     if (MyTool::eq($field, MyConst::FIELD_PASSWORD)) {
         if (!MyTool::isPassword($value)) {
             return $this->onError(MyConst::STATUS_INVALID_PASSWORD, 'invalid password');
         }
         $value2 = MyTool::get($this, MyConst::FIELD_VALUE2);
         if (0 !== strcasecmp($user->{$field}, $value2)) {
             return $this->onError(MyConst::STATUS_WRONG_PASSWORD, 'current password wrong');
         }
     } else {
         if (MyTool::eq($field, MyConst::FIELD_EMAIL)) {
             if (!MyTool::isEmail($value)) {
                 return $this->onError(MyConst::STATUS_INVALID_EMAIL, 'wrong email address');
             }
         } else {
             if (MyTool::eq($field, MyConst::FIELD_PHONE)) {
                 if (!MyTool::isPhone($value)) {
                     return $this->onError(MyConst::STATUS_INVALID_PHONE, 'wrong phone number');
                 }
             }
         }
     }
     $user->{$field} = $value;
     $user->mtime = MyTool::now();
     if (true !== $user->update()) {
         return $this->onError(MyConst::STATUS_DB, 'update user information failed');
     }
     MyTool::setVar($this, MyConst::FIELD_STATUS, MyConst::STATUS_OK);
     return true;
 }
Ejemplo n.º 3
0
 public static function convertJsonToLeader($json)
 {
     $leader = new MaTeamLeader();
     if (!self::fill($json, $leader, MyConst::FIELD_NAME)) {
         return false;
     }
     if (!self::fill($json, $leader, MyConst::FIELD_PIC)) {
         return false;
     }
     if (!self::fill($json, $leader, MyConst::FIELD_ROLE)) {
         return false;
     }
     if (!self::fill($json, $team, MyConst::FIELD_INTRO)) {
         return false;
     }
     $team->mtime = MyTool::now();
     $team->ctime = $team->mtime;
     $team->deleted = 0;
     return $team;
 }
Ejemplo n.º 4
0
 public static function convert($json)
 {
     $user = new MaUser();
     // user name, required
     if (!isset($json->name)) {
         return false;
     }
     $user->name = @trim($json->name);
     if (empty($user->name)) {
         return false;
     }
     // user password, required
     if (!isset($json->password)) {
         return false;
     }
     $user->password = @trim($json->password);
     if (empty($user->password)) {
         return false;
     }
     // user phone number, required
     if (!isset($json->phone)) {
         return false;
     }
     $user->phone = @trim($json->phone);
     if (empty($user->phone)) {
         return false;
     }
     // user email, required
     if (!isset($json->email)) {
         return false;
     }
     $user->email = @trim($json->email);
     if (empty($user->email)) {
         return false;
     }
     // user company or school or institude, required
     if (!isset($json->email)) {
         return false;
     }
     $user->company = @trim($json->company);
     if (empty($user->company)) {
         return false;
     }
     // user job position or title, required
     if (!isset($json->job)) {
         return false;
     }
     $user->job = @trim($json->job);
     if (empty($user->job)) {
         return false;
     }
     // searchable or not
     $user->open = 0;
     if (isset($json->open)) {
         $user->open = @intval(@trim($json->open));
         if ($user->open != 0) {
             $user->open = 1;
         }
     } else {
         $user->open = 0;
     }
     // user weibo account or uri, optional
     if (isset($json->weibo)) {
         $user->weibo = @trim($json->weibo);
     }
     // user weixin account or uri, required
     if (!isset($json->weixin)) {
         return false;
     }
     $user->weixin = @trim($json->weixin);
     if (empty($user->weixin)) {
         return false;
     }
     // user linkedin account or uri, required
     if (!isset($json->linkedin)) {
         return false;
     }
     $user->linkedin = @trim($json->linkedin);
     if (empty($user->linkedin)) {
         return false;
     }
     // user github account or uri, required
     if (isset($json->github)) {
         $user->github = @trim($json->github);
     }
     // user head pic uri, optional
     if (isset($json->pic)) {
         $user->pic = @trim($json->pic);
     }
     $user->mtime = MyTool::now();
     $user->ctime = MyTool::now();
     $user->status = 0;
     $user->deleted = 0;
     return $user;
 }