public function update() { $this->checkAccessToken(); $this->params = $this->require_params(array('id', 'name')); $this->groupModel->setGroupId($this->params['id'])->update($this->params, $GLOBALS['userId']); F::rest()->show_result(); }
/** * 给联系人生成一则事件 * * @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(); }
public function isEnableOpen($userId, $paramId, $type) { #读取拥有全部权限的用户列表 $levelConfig = F::load_config('levelConfig.php'); if (in_array($userId, $levelConfig)) { return TRUE; } unset($levelConfig); #获取当前用户所属项目标签 $userTag = $this->getUserTagList($userId); foreach ($userTag as $userTagIndex) { if ($userTagIndex['type'] == 2) { $userTagArray[] = $userTagIndex['tagId']; } } unset($userTag); $userTagArray = is_array($userTagArray) ? $userTagArray : array(); #获取param属于项目标签 if ($type == 3) { #群组类型 $this->groupModel = F::load_model('group', array()); $groupInfo = $this->groupModel->setGroupId($paramId)->get(); #group create user can open if ($groupInfo['createUserId'] == $userId) { return TRUE; } #拥有纳什空间的群组,全体可见 if ($groupInfo['groupProject']['name'] == '纳什空间') { return TRUE; } #群组所属项目下人员拥有查看权限 if (in_array($groupInfo['groupProject']['id'], $userTagArray)) { return TRUE; } #检查能否通过@获取临时权限 if ($this->getOpenLevelByNotice($userId, $paramId, 'group')) { return TRUE; } #检查群组拥有的项目标签,其项目类型下的成员拥有查看权限 foreach ($groupInfo['tagList'] as $groupInfoTagListIndex) { if ($groupInfoTagListIndex['type'] == 2) { $groupInfoTagListArray[] = $groupInfoTagListIndex['id']; } if ($groupInfoTagListIndex['name'] == '纳什空间') { return TRUE; } } $groupInfoTagListArray = is_array($groupInfoTagListArray) ? $groupInfoTagListArray : array(); #计算交集 $result = array_intersect($userTagArray, $groupInfoTagListArray); unset($groupInfoTagListArray); return empty($result) ? FALSE : TRUE; } else { #contact create user can open $createContactUserId = $this->getAccountCreateUserId($paramId); if ($createContactUserId == $userId) { return TRUE; } #检查能否通过@获取临时权限 if ($this->getOpenLevelByNotice($userId, $paramId, 'contact')) { return TRUE; } #联系人类型 $contactTagList = $this->getUserTagList($paramId); foreach ($contactTagList as $contactTagListIndex) { if ($contactTagListIndex['type'] == 2) { $contactTagListArray[] = $contactTagListIndex['tagId']; } } $contactTagListArray = is_array($contactTagListArray) ? $contactTagListArray : array(); #计算交集 $result = array_intersect($userTagArray, $contactTagListArray); #若联系人不存在有效的项目标签,则使用该联系人的创建者的项目标签代替之 if (empty($contactTagListArray)) { $createContactUserTag = $this->getUserTagList($createContactUserId); foreach ($createContactUserTag as $createContactUserTagIndex) { if ($createContactUserTagIndex['type'] == 2) { $createContactUserTagArray[] = $createContactUserTagIndex['tagId']; } if ($createContactUserTagIndex['tagName'] == '纳什空间') { return TRUE; } } $result = is_array($createContactUserTagArray) ? $createContactUserTagArray : array(); } unset($contactTagListArray); return empty($result) ? FALSE : TRUE; } }