Exemple #1
0
 /**
  * Adds link on folder in folder.
  * @param Folder $sourceFolder Original folder.
  * @param array $data Contains additional fields (CREATED_BY, NAME, etc).
  * @param array $rights Rights (@see \Bitrix\Disk\RightsManager).
  * @param bool  $generateUniqueName Generates unique name for object in directory.
  * @throws \Bitrix\Main\ArgumentException
  * @return FolderLink|null
  */
 public function addSubFolderLink(Folder $sourceFolder, array $data, array $rights = array(), $generateUniqueName = false)
 {
     $this->errorCollection->clear();
     $data = $this->prepareDataForAddLink($sourceFolder, $data, $generateUniqueName);
     if (!$data) {
         return null;
     }
     $fileLinkModel = FolderLink::add($data, $this->errorCollection);
     if (!$fileLinkModel) {
         return null;
     }
     Driver::getInstance()->getRightsManager()->setAsNewLeaf($fileLinkModel, $rights);
     return $fileLinkModel;
 }
Exemple #2
0
 protected function getSnapshotFromLinks(array $folderLinks, $version)
 {
     $response = array();
     $sc = $this->storage->getCurrentUserSecurityContext();
     foreach ($folderLinks as $link) {
         $modelLink = FolderLink::buildFromArray(array('ID' => $link['extra']['id'], 'NAME' => $link['name'], 'TYPE' => ObjectTable::TYPE_FOLDER, 'STORAGE_ID' => $link['extra']['iblockId'], 'REAL_OBJECT_ID' => $link['extra']['linkSectionId'], 'PARENT_ID' => $link['extra']['sectionId'], 'UPDATE_TIME' => DateTime::createFromTimestamp(CWebDavDiskDispatcher::convertFromExternalVersion($link['version'])), 'CREATED_BY' => $link['createdBy'], 'UPDATED_BY' => $link['updatedBy']));
         $filter = array('TYPE' => ObjectTable::TYPE_FILE);
         if ($version > 0 && self::compareVersion($link['version'], $version . '000')) {
             $filter['>=UPDATE_TIME'] = DateTime::createFromTimestamp($version);
         }
         $code = Folder::CODE_FOR_UPLOADED_FILES;
         $parameters = array('filter' => $filter);
         $parameters['runtime'] = array(new ExpressionField('NOT_UPLOADED', "CASE WHEN NOT EXISTS(SELECT 'x' FROM b_disk_object_path pp INNER JOIN b_disk_object oo ON oo.ID = pp.PARENT_ID AND oo.CODE = '{$code}' WHERE pp.OBJECT_ID = %1\$s AND pp.PARENT_ID = oo.ID AND oo.STORAGE_ID = %2\$s) THEN 1 ELSE 0 END", array('PARENT_ID', 'STORAGE_ID')));
         $parameters['filter']['NOT_UPLOADED'] = true;
         foreach ($modelLink->getDescendants($sc, $parameters) as $item) {
             /** @var File $item */
             $format = $this->formatFileToResponse($item);
             if ($format) {
                 $response[] = $format;
             }
         }
         unset($item);
     }
     return $response;
 }
Exemple #3
0
 protected static function getClassNameModel(array $row)
 {
     if (!isset($row['ID'])) {
         throw new ArgumentTypeException('Invalid ID');
     }
     if (!isset($row['TYPE'])) {
         throw new ArgumentTypeException('Invalid TYPE');
     }
     if (empty($row['REAL_OBJECT_ID']) || $row['REAL_OBJECT_ID'] == $row['ID']) {
         if ($row['TYPE'] == ObjectTable::TYPE_FILE) {
             return File::className();
         }
         return Folder::className();
     }
     if ($row['TYPE'] == ObjectTable::TYPE_FILE) {
         return FileLink::className();
     }
     return FolderLink::className();
 }