コード例 #1
0
	public static function GetFolderModel($chatId)
	{
		if (!self::Enabled())
			return false;

		$folderModel = false;

		$result = Im\ChatTable::getById($chatId);
		if (!$chat = $result->fetch())
			return false;

		$folderId = intval($chat['DISK_FOLDER_ID']);
		if ($folderId > 0)
		{
			$folderModel = \Bitrix\Disk\Folder::getById($folderId);
			if (!$folderModel || $folderModel->getStorageId() != self::GetStorageId())
			{
				$folderId = 0;
			}
		}

		if (!$folderId)
		{
			$driver = \Bitrix\Disk\Driver::getInstance();
			$storageModel = self::GetStorage();
			if (!$storageModel)
			{
				return false;
			}

			$rightsManager = $driver->getRightsManager();
			$fullAccessTaskId = $rightsManager->getTaskIdByName($rightsManager::TASK_FULL);

			$accessCodes = array();
			$accessCodes[] = Array(
				'ACCESS_CODE' => 'AU',
				'TASK_ID' => $fullAccessTaskId,
				'NEGATIVE' => 1
			);

			$chatRelation = CIMChat::GetRelationById($chatId);
			foreach ($chatRelation as $relation)
			{
				$accessCodes[] = Array(
					'ACCESS_CODE' => 'U'.$relation['USER_ID'],
					'TASK_ID' => $fullAccessTaskId
				);
			}

			$folderModel = $storageModel->addFolder(array('NAME' => 'chat'.$chatId, 'CREATED_BY' => self::GetUserId()), $accessCodes);
			if ($folderModel)
				Im\ChatTable::update($chatId, Array('DISK_FOLDER_ID' => $folderModel->getId()));
		}

		return $folderModel;
	}
コード例 #2
0
ファイル: im_disk.php プロジェクト: webgksupport/alpina
 public static function GetFolderModel($chatId)
 {
     if (!self::Enabled()) {
         return false;
     }
     $folderModel = false;
     $result = IM\ChatTable::getById($chatId);
     if (!($chat = $result->fetch())) {
         return false;
     }
     $folderId = intval($chat['DISK_FOLDER_ID']);
     $chatType = $chat['TYPE'];
     if ($folderId > 0) {
         $folderModel = \Bitrix\Disk\Folder::getById($folderId);
         if (!$folderModel || $folderModel->getStorageId() != self::GetStorageId()) {
             $folderId = 0;
         }
     }
     if (!$folderId) {
         $driver = \Bitrix\Disk\Driver::getInstance();
         $storageModel = self::GetStorage();
         if (!$storageModel) {
             return false;
         }
         $rightsManager = $driver->getRightsManager();
         $fullAccessTaskId = $rightsManager->getTaskIdByName($rightsManager::TASK_FULL);
         $accessCodes = array();
         $accessCodes[] = array('ACCESS_CODE' => 'AU', 'TASK_ID' => $fullAccessTaskId, 'NEGATIVE' => 1);
         $chatRelation = CIMChat::GetRelationById($chatId);
         if ($chatType == IM_MESSAGE_OPEN) {
             $departmentCode = self::GetTopDepartmentCode();
             if ($departmentCode) {
                 $accessCodes[] = array('ACCESS_CODE' => $departmentCode, 'TASK_ID' => $fullAccessTaskId);
             }
             $users = CIMContactList::GetUserData(array('ID' => array_keys($chatRelation), 'DEPARTMENT' => 'N', 'SHOW_ONLINE' => 'N'));
             foreach ($users['users'] as $userData) {
                 if ($userData['extranet']) {
                     $accessCodes[] = array('ACCESS_CODE' => 'U' . $userData['id'], 'TASK_ID' => $fullAccessTaskId);
                 }
             }
         } else {
             foreach ($chatRelation as $relation) {
                 $accessCodes[] = array('ACCESS_CODE' => 'U' . $relation['USER_ID'], 'TASK_ID' => $fullAccessTaskId);
             }
         }
         $folderModel = $storageModel->addFolder(array('NAME' => 'chat' . $chatId, 'CREATED_BY' => self::GetUserId()), $accessCodes);
         if ($folderModel) {
             IM\ChatTable::update($chatId, array('DISK_FOLDER_ID' => $folderModel->getId()));
         }
     }
     return $folderModel;
 }
コード例 #3
0
ファイル: baseobject.php プロジェクト: DarneoStudio/bitrix
 /**
  * Returns folder by id.
  * @param int $id Id of object.
  * @return Disk\Folder
  * @throws RestException
  */
 protected function getFolderById($id)
 {
     $folder = Disk\Folder::getById($id, array('STORAGE'));
     if (!$folder) {
         throw new RestException("Could not find entity with id '{$id}'.", RestException::ERROR_NOT_FOUND);
     }
     return $folder;
 }