示例#1
0
 /**
  * Gets fields which Externalizer or Internalizer should modify.
  * @return array
  */
 public function getFieldsForMap()
 {
     return array('ENTITY_TYPE' => array('IN' => function ($externalValue) {
         switch ($externalValue) {
             case 'user':
                 return ProxyType\User::className();
             case 'group':
                 return ProxyType\Group::className();
             case 'common':
                 return ProxyType\Common::className();
         }
         return null;
     }, 'OUT' => function ($internalValue) {
         switch ($internalValue) {
             case ProxyType\User::className():
                 return 'user';
             case ProxyType\Group::className():
                 return 'group';
             case ProxyType\Common::className():
                 return 'common';
             case ProxyType\RestApp::className():
                 return 'restapp';
         }
         return null;
     }));
 }
示例#2
0
 protected function processActionGetListStorage()
 {
     $this->checkRequiredPostParams(array('proxyType'));
     if ($this->errorCollection->hasErrors()) {
         $this->sendJsonErrorResponse();
     }
     $proxyTypePost = $this->request->getPost('proxyType');
     $diskSecurityContext = $this->getSecurityContextByUser($this->getUser());
     $siteId = null;
     $siteDir = null;
     if ($this->request->getPost('siteId')) {
         $siteId = $this->request->getPost('siteId');
     }
     if ($this->request->getPost('siteDir')) {
         $siteDir = rtrim($this->request->getPost('siteDir'), '/');
     }
     $result = array();
     $filterReadableList = array();
     $checkSiteId = false;
     if ($proxyTypePost == 'user') {
         $result['TITLE'] = Loc::getMessage('DISK_AGGREGATOR_USER_TITLE');
         $filterReadableList = array('STORAGE.ENTITY_TYPE' => ProxyType\User::className());
     } elseif ($proxyTypePost == 'group') {
         $checkSiteId = true;
         $result['TITLE'] = Loc::getMessage('DISK_AGGREGATOR_GROUP_TITLE');
         $filterReadableList = array('STORAGE.ENTITY_TYPE' => ProxyType\Group::className());
     }
     foreach (Storage::getReadableList($diskSecurityContext, array('filter' => $filterReadableList)) as $storage) {
         if ($checkSiteId) {
             $groupObject = CSocNetGroup::getList(array(), array('ID' => $storage->getEntityId()), false, false, array('SITE_ID'));
             $group = $groupObject->fetch();
             if (!empty($group) && $group['SITE_ID'] != $siteId) {
                 continue;
             }
         }
         $proxyType = $storage->getProxyType();
         $result['DATA'][] = array("TITLE" => $proxyType->getEntityTitle(), "URL" => $siteDir . $proxyType->getBaseUrlFolderList(), "ICON" => $proxyType->getEntityImageSrc(64, 64));
     }
     if (!empty($result['DATA'])) {
         Collection::sortByColumn($result['DATA'], array('TITLE' => SORT_ASC));
         $this->sendJsonSuccessResponse(array('listStorage' => $result['DATA'], 'title' => $result['TITLE']));
     } else {
         $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_AGGREGATOR_ERROR_COULD_NOT_FIND_DATA'))));
         $this->sendJsonErrorResponse();
     }
 }
示例#3
0
 /**
  * Returns storage by user id.
  * If storage doesn't exist returns null.
  *
  * @param integer $userId Id of user.
  * @return null|Storage
  * @throws \Bitrix\Main\ArgumentException
  * @throws \Bitrix\Main\SystemException
  */
 public function getStorageByUserId($userId)
 {
     return Storage::load(array('MODULE_ID' => self::INTERNAL_MODULE_ID, 'ENTITY_TYPE' => ProxyType\User::className(), 'ENTITY_ID' => (int) $userId), array('ROOT_OBJECT'));
 }
 protected function generateEmptyUserStorages()
 {
     if ($this->isStepFinished(__METHOD__)) {
         return;
     }
     $proxyType = $this->sqlHelper->forSql(ProxyType\User::className());
     $result = $this->connection->query("\n\t\t\t\tSELECT u.ID\n\t\t\t\tFROM b_user u\n\t\t\t\tWHERE NOT EXISTS(SELECT 'x' FROM b_disk_storage s WHERE u.ID=s.ENTITY_ID AND s.ENTITY_TYPE='{$proxyType}')\n\t\t");
     while ($user = $result->fetch()) {
         Driver::getInstance()->addUserStorage($user['ID']);
     }
     //
     /*
     if($this->getIblockWithUserFiles() as $iblock)
     {
     
     	INSERT INTO b_disk_storage()
     	SELECT ID,
     	FROM b_user
     	WHERE NOT EXISTS(SELECT 'x' FROM b_disk_storage WHERE u.ID=st.ENTITY_ID)
     
     	INSERT INTO b_disk_object()
     	SELECT
     	FROM b_disk_storage
     	WHERE
     
     	INSERT INTO b_disk_path()
     	SELECT
     	FROM
     
     	INSERT INTO b_disk_right()
     	SELECT
     	FROM
     
     	INSERT INTO b_disk_simple_right()
     	SELECT
     	FROM
     
     }
     */
     $this->setStepFinished(__METHOD__);
 }