Example #1
0
 public function addRelation()
 {
     $this->checkAccessToken();
     $this->params = $this->require_params(array('groupId', 'userId', 'type'));
     $this->groupModel->setGroupId($this->params['groupId'])->addRelation($GLOBALS['userId'], $this->params['userId'], $this->params['type']);
     #补充对应联系人的信息
     $this->userModel->createEvent($GLOBALS['userId'], $this->params['userId'], $this->getEventContentByRelationType($this->params['type'], $this->params['groupId']));
     F::rest()->show_result();
 }
Example #2
0
 /**
  * 给联系人生成一则事件
  *
  * @access public
  * @param string evnet
  * @param int id
  * @return void
  */
 public function createEventForContact()
 {
     $this->checkAccessToken();
     $this->params = $this->require_params(array('id', 'event'));
     $this->params['photo'] = F::request('photo', '');
     $this->params['systemEvent'] = F::request('systemEvent', 0);
     if ($this->params['photo']) {
         $this->params['event'] .= ' #图片 ';
     }
     $userId = $this->params['id'];
     $this->params['event'] = str_replace('#', '#', $this->params['event']);
     $this->params['event'] = str_replace('#r', '#R', $this->params['event']);
     $this->params['event'] = str_replace('@', '@', $this->params['event']);
     #书写对应事件
     preg_match_all('/#([^#^\\s^:]{1,})([\\s\\:\\,\\;]{0,1})/', $this->params['event'], $result);
     #针对来访,需要追加相应房间的事件
     $hadVisterTag = FALSE;
     $projectTag = '';
     $roomTagArray = array();
     foreach ($result[1] as $value) {
         $this->userModel->bindTag($userId, $value);
         if ($value == '来访') {
             $hadVisterTag = TRUE;
         }
         if (preg_match('/^R\\d{1,}/', $value)) {
             $roomTagArray[] = $value;
         }
         if ($this->isProjectTag($value)) {
             $projectTag = $value;
         }
     }
     if ($hadVisterTag && $projectTag) {
         #存在来访标签
         $this->groupModel = F::load_model('group', array());
         #获取当前操作联系人姓名
         $contactInfo = $this->userModel->get($this->params['id']);
         $contactName = $contactInfo[0]['nickname'];
         foreach ($roomTagArray as $roomTagArrayIndex) {
             $groupName = $projectTag . ' ' . str_replace('R', '', $roomTagArrayIndex);
             $groupId = $this->groupModel->getGroupIdByName($groupName);
             if ($groupId) {
                 #创建来访事件
                 $event = '#来访 ' . $contactName . '来访看房';
                 $this->groupModel->setGroupId($groupId)->createEvent($GLOBALS['userId'], $event);
             } else {
                 #todo 房间不存在
             }
         }
     }
     $eventContent = $this->params['event'];
     $eventType = $this->params['systemEvent'] ? self::SYSTEM_EVENT : self::USER_EVENT;
     $this->userModel->createEvent($GLOBALS['userId'], $userId, $eventContent, $this->params['photo'], $eventType);
     $this->userLog($GLOBALS['userId'], __CLASS__ . '/' . __FUNCTION__, serialize($this->params));
     F::rest()->show_result();
 }
Example #3
0
 public function createEvent($createUserId, $event, $photo = '')
 {
     if ($photo) {
         $event .= ' #图片';
     }
     #生成事件信息
     $this->userModel = F::load_model('user', array());
     $eventId = $this->userModel->createEvent($createUserId, $this->id, $event, $photo, self::GROUP_EVENT_TYPE);
     #绑定tag信息
     $this->bindTagByString($event, $eventId);
     return $eventId;
 }
 /**
  * 更新联系人信息
  * 
  * @access public
  * @return void
  */
 public function update()
 {
     $this->checkAccessToken();
     $this->params = $this->require_params(array('id'));
     $userId = $this->params['id'];
     unset($this->params['id']);
     unset($this->params['accessToken']);
     unset($this->params['r']);
     $this->returnData = $this->contactModel->getContactProfile($userId);
     unset($this->returnData['id']);
     unset($this->returnData['tagList']);
     unset($this->returnData['acctionList']);
     $requestTagArray = array();
     foreach ($this->params as $key => $value) {
         if ($key == 'username' && $value != $this->returnData['username']) {
             if ($this->returnData['username']) {
                 $this->params['update'] = 1;
                 $this->params['updateParam'][] = array('姓名', $value);
             } else {
                 $this->params['add'] = 1;
                 $this->params['addParam'][] = array('姓名', $value);
             }
         }
         if ($key == 'phoneNum' && $value != $this->returnData['phoneNum']) {
             if ($this->returnData['username']) {
                 $this->params['update'] = 1;
                 $this->params['updateParam'][] = array('手机号', $value);
             } else {
                 $this->params['add'] = 1;
                 $this->params['addParam'][] = array('手机号', $value);
             }
         }
         if ($key != 'username' && $key != 'phoneNum') {
             $requestTagArray[] = $this->tagModel->getUserProfileName($key);
         }
         if (!isset($this->returnData['userProfile'][$key]) && $key != 'username' && $key != 'phoneNum') {
             $this->params['add'] = 1;
             $this->params['addParam'][] = array($this->tagModel->getUserProfileName($key), $value);
         }
         if (isset($this->returnData['userProfile'][$key]['value']) && $value != $this->returnData['userProfile'][$key]['value']) {
             $this->params['update'] = 1;
             $this->params['updateParam'][] = array($this->returnData['userProfile'][$key][$key], $value);
         }
     }
     $this->params['add'] = $this->params['add'] ? $this->params['add'] : 0;
     $this->params['update'] = $this->params['update'] ? $this->params['update'] : 0;
     $this->contactModel->update($userId, $this->params);
     if ($this->params['add']) {
         $addEventContent = '新增信息';
         foreach ($this->params['addParam'] as $addIndex) {
             $addEventContent .= ' ' . '#' . $addIndex[0] . ' ' . $addIndex[1];
         }
     }
     if ($this->params['update']) {
         $updateEventContent = '更新信息';
         foreach ($this->params['updateParam'] as $updateIndex) {
             $updateEventContent .= ' ' . '#' . $updateIndex[0] . ' ' . $updateIndex[1];
         }
     }
     $this->userModel->createEvent($GLOBALS['userId'], $userId, $addEventContent . ' ' . $updateEventContent, '', self::SYSTEM_EVENT);
     foreach ($requestTagArray as $value) {
         $this->userModel->bindTag($userId, $value);
     }
     $this->userLog($GLOBALS['userId'], __CLASS__ . '/' . __FUNCTION__, serialize($this->params));
     F::rest()->show_result();
 }