Пример #1
0
 protected function getUserGroupWithStorage()
 {
     if (!\CBXFeatures::isFeatureEnabled("Workgroups")) {
         return array();
     }
     if (!Loader::includeModule('socialnetwork')) {
         return array();
     }
     $userId = $this->getUser()->getId();
     $currentPossibleUserGroups = $currentUserGroups = array();
     $cache = Cache::createInstance();
     $cacheTtl = defined('BX_COMP_MANAGED_CACHE') ? 3153600 : 3600 * 4;
     $cachePath = "/disk/uf/{$userId}";
     if ($cache->initCache($cacheTtl, 'group_storage_list_' . SITE_ID . '_' . $userId, $cachePath)) {
         list($currentUserGroups) = $cache->getVars();
     } else {
         $cache->startDataCache();
         $taggedCache = Application::getInstance()->getTaggedCache();
         $taggedCache->startTagCache($cachePath);
         $diskSecurityContext = new DiskSecurityContext($userId);
         $storages = Storage::getReadableList($diskSecurityContext, array('filter' => array('STORAGE.ENTITY_TYPE' => ProxyType\Group::className())));
         foreach ($storages as $storage) {
             $currentPossibleUserGroups[$storage->getEntityId()] = $storage;
         }
         unset($storage);
         $query = \CSocNetUserToGroup::getList(array('GROUP_NAME' => 'ASC'), array('USER_ID' => $userId, 'GROUP_ID' => array_keys($currentPossibleUserGroups)), false, false, array('GROUP_ID', 'GROUP_NAME', 'GROUP_ACTIVE', 'GROUP_CLOSED', 'ROLE'));
         while ($row = $query->getNext()) {
             if ($row['GROUP_ACTIVE'] == 'Y' && $row['GROUP_CLOSED'] == 'N' && $row['ROLE'] != SONET_ROLES_BAN && $row['ROLE'] != SONET_ROLES_REQUEST && isset($currentPossibleUserGroups[$row['GROUP_ID']])) {
                 $taggedCache->registerTag("sonet_features_G_{$row['GROUP_ID']}");
                 $taggedCache->registerTag("sonet_group_{$row['GROUP_ID']}");
                 $currentUserGroups[$row['GROUP_ID']] = array('STORAGE' => $currentPossibleUserGroups[$row['GROUP_ID']], 'NAME' => $row['GROUP_NAME']);
             }
         }
         $taggedCache->registerTag("sonet_user2group_U{$userId}");
         $taggedCache->endTagCache();
         $cache->endDataCache(array($currentUserGroups));
     }
     return $currentUserGroups;
 }
Пример #2
0
 protected function getUserGroupWithStorage()
 {
     if (!\CBXFeatures::isFeatureEnabled("Workgroups")) {
         return array();
     }
     if (!Loader::includeModule('socialnetwork')) {
         return array();
     }
     $userId = $this->getUser()->getId();
     $currentPossibleUserGroups = $currentUserGroups = array();
     $diskSecurityContext = new DiskSecurityContext($this->getUser()->getId());
     $storages = Storage::getReadableList($diskSecurityContext, array('filter' => array('STORAGE.ENTITY_TYPE' => ProxyType\Group::className())));
     foreach ($storages as $storage) {
         $currentPossibleUserGroups[$storage->getEntityId()] = $storage;
     }
     unset($storage);
     $query = \CSocNetUserToGroup::getList(array('GROUP_NAME' => 'ASC'), array('USER_ID' => $userId, 'GROUP_ID' => array_keys($currentPossibleUserGroups)), false, false, array('GROUP_ID', 'GROUP_NAME', 'GROUP_ACTIVE', 'GROUP_CLOSED', 'ROLE'));
     while ($row = $query->getNext()) {
         if ($row['GROUP_ACTIVE'] == 'Y' && $row['GROUP_CLOSED'] == 'N' && $row['ROLE'] != SONET_ROLES_BAN && $row['ROLE'] != SONET_ROLES_REQUEST && isset($currentPossibleUserGroups[$row['GROUP_ID']])) {
             $currentUserGroups[$row['GROUP_ID']] = array('STORAGE' => $currentPossibleUserGroups[$row['GROUP_ID']], 'NAME' => $row['GROUP_NAME']);
         }
     }
     return $currentUserGroups;
 }