Beispiel #1
0
 /**
  * 获取某几个项目下的事件列表
  *
  * @access public
  * @param array $tagID 事件数组
  * @return array
  */
 public function getEventListByGroupId(array $tagId, $page, $num)
 {
     if (empty($tagId)) {
         return array();
     }
     $userId = $this->tagModel->getUserListByTadId($tagId);
     if (empty($userId)) {
         return array();
     }
     $eventListTmp = F::db()->fetch_all('SELECT event.id as eventId, user_id as userId, event.content as eventContent, create_time as createTime,
         create_user_id as createUserId, photo, type FROM `event` where create_user_id in (' . implode(',', $userId) . ') and status = 1 ORDER BY event.id desc limit ?, ?', array(($page - 1) * $num, $num));
     $eventList = array();
     foreach ($eventListTmp as $value) {
         if ($value['type'] == 3) {
             $groupModel = F::load_model('group', array('groupId' => $value['userId']));
             $groupInfo = $groupModel->get();
             $ownInfo[0]['nickname'] = $groupInfo['name'];
             $ownTagInfo = array();
             foreach ($groupInfo['tagList'] as $tagListIndex) {
                 $ownTagInfo[] = array('tagId' => $tagListIndex['id'], 'tagName' => $tagListIndex['name'], 'coler' => $tagListIndex['tagClass']);
             }
             #补充relation信息
             $ownRelation = $groupInfo['relation'];
         } else {
             #检查联系人性质,若时公司内部人员则直接跳出
             $userAccountType = $this->getAccountType($value['userId']);
             if ($userAccountType == 1 || $userAccountType == 3) {
                 continue;
             }
             $ownInfo = $this->_get($value['userId']);
             $ownTagInfo = $this->_getUserTagList($value['userId']);
             $ownRelation = array();
         }
         $createUserInfo = $this->_get($value['createUserId']);
         $praiseList = $this->_getPraiseList($value['eventId']);
         $praiseListArray = array();
         foreach ($praiseList as $praiseListIndex) {
             $praiseUserInfo = $this->_get($praiseListIndex['userId']);
             $praiseListArray[] = $praiseUserInfo[0]['nickname'];
         }
         $result = array();
         preg_match_all('/@([^@^\\s^:]{1,})([\\s\\:\\,\\;]{0,1})/', $value['eventContent'], $result);
         $noticeUserInfo = array();
         foreach ($result[0] as $noticeIndex) {
             //$noticeUserInfo[] = $noticeIndex;
             $noticeUserInfo[] = array('name' => $noticeIndex, 'userId' => $this->getUserIdByNickname(str_replace('@', '', $noticeIndex)));
         }
         $eventList[] = array('eventId' => $value['eventId'], 'eventCreateUserNickname' => $ownInfo[0]['nickname'], 'photo' => $value['photo'], 'createUserId' => $value['userId'], 'eventCreateUserId' => $value['createUserId'], 'createUserName' => $createUserInfo[0]['nickname'], 'createUserPhoto' => $createUserInfo[0]['photo'], 'eventContent' => $value['eventContent'], 'eventContantUser' => is_array($noticeUserInfo) ? $noticeUserInfo : array(), 'eventOwnInfo' => $ownTagInfo, 'time' => $this->_translateTime(strtotime($value['createTime'])), 'praise' => $praiseListArray, 'hadPraised' => $this->_hadPraise($userId, $value['eventId']), 'createUserPhoneNum' => $createUserInfo[0]['phone_num'], 'eventType' => $value['type'] == 3 ? 'group' : 'contact', 'relation' => $ownRelation, 'enable_open' => TRUE);
     }
     return $eventList;
 }