/** * 获取联系人的相关信息 * * @access public * @return array */ public function getContactProfile() { $this->checkAccessToken(); $this->params = $this->require_params(array('phoneNum')); $this->params['id'] = F::request('id', 0); if ($this->params['id']) { $userId = $this->params['id']; } else { $userId = $this->userModel->getUserIdByUsername($this->params['phoneNum']); if (!$userId) { throw new Exception('用户不存在', 101); } } #判定查看权限 $openEnable = $this->userModel->isEnableOpen($GLOBALS['userId'], $userId, 1); if ($openEnable) { $this->returnData = $this->contactModel->getContactProfile($userId); } else { $this->returnData = array(); } F::rest()->show_result($this->returnData); }
/** * 生成一则事件纪录 * * @access public * @param string content 事件内容 * @param string phoneNum 手机号 * @return void * @todo 针对@和#内容处理 */ public function createEvent() { #参数检查 $this->checkAccessToken(); $this->params = $this->require_params(array('content', 'phoneNum')); //if (!FValidator::phone($this->params['phoneNum'])) throw new Exception('手机号格式非法', 100); #手机号是合法账户 $userId = $this->userModel->getUserIdByUsername($this->params['phoneNum']); if (!$userId) { throw new Exception('用户不存在', 101); } #书写对应事件 preg_match_all('/#([^#^\\s^:]{1,})([\\s\\:\\,\\;]{0,1})/', $this->params['content'], $result); foreach ($result[1] as $value) { $this->userModel->bindTag($userId, $value); } #生成事件 $this->returnData = $this->userModel->createEvent($GLOBALS['userId'], $userId, $this->params['content']); $this->userLog($GLOBALS['userId'], __CLASS__ . '/' . __FUNCTION__, serialize($this->params)); F::rest()->show_result(); }