예제 #1
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();
 }
예제 #2
0
 public function checkGroupName()
 {
     $this->params = $this->require_params(array('name'));
     $this->returnData = $this->groupModel->getGroupIdByName($this->params['name']);
     F::rest()->show_result($this->returnData ? FALSE : TRUE);
 }