Ejemplo n.º 1
0
 public function seach()
 {
     $this->params['name'] = F::request('name', '');
     $this->params['seachType'] = F::request('type', 0);
     //         $this->returnData = $this->params['seachType'] == 0 ? $this->contactModel->seach($this->params['name']) : $this->contactModel->seachAll($this->params['name']);
     $this->returnData = $this->contactModel->seach($this->params['name']);
     F::rest()->show_result($this->returnData);
 }
Ejemplo n.º 2
0
 /**
  * 注册新的联系人
  *
  * @access public
  * @param string phoneNum
  * @param string username
  * @param string event
  * @return void
  */
 public function createV2()
 {
     $this->checkAccessToken();
     $this->params = $this->require_params(array('phoneNum', 'username', 'event'));
     $this->params['systemEvent'] = F::request('systemEvent', 0);
     //if (!FValidator::phone($this->params['phoneNum'])) throw new Exception('手机号格式非法', 100);
     #检查手机是否已经注册
     $userId = $this->contactModel->getContactIdByPhoneNum($this->params['phoneNum']);
     if (!$userId) {
         #生成一个新的账户
         $userId = $this->userModel->create($this->params['phoneNum'], $this->params['username'], self::OWNER_ACCOUNT, $GLOBALS['userId']);
         #更新用户昵称
         $this->userModel->updateUserProfile($userId, $this->params['username']);
     }
     #书写对应事件
     preg_match_all('/#([^#^\\s^:]{1,})([\\s\\:\\,\\;]{0,1})/', $this->params['event'], $result);
     foreach ($result[1] as $value) {
         $this->userModel->bindTag($userId, $value);
     }
     $eventType = $this->params['systemEvent'] ? self::SYSTEM_EVENT : self::USER_EVENT;
     $this->userModel->createEvent($GLOBALS['userId'], $userId, $this->params['event'], '', $eventType);
     $this->userLog($GLOBALS['userId'], __CLASS__ . '/' . __FUNCTION__, serialize($this->params));
     F::rest()->show_result($userId);
 }