Example #1
0
 /**
  * @return Folder|null
  */
 public function getRootObject()
 {
     if (!$this->rootObjectId) {
         return null;
     }
     if (isset($this->rootObject) && $this->rootObjectId === $this->rootObject->getId()) {
         return $this->rootObject;
     }
     //todo - Storage - knows about Folder ^( Nu i pust'
     $this->rootObject = Folder::loadById($this->rootObjectId);
     return $this->rootObject;
 }
Example #2
0
 /**
  * Returns parent model.
  * If object does not have parent, then returns null.
  * @return Folder|null
  * @throws \Bitrix\Main\NotImplementedException
  */
 public function getParent()
 {
     if (!$this->parentId) {
         return null;
     }
     if (isset($this->parent) && $this->parentId === $this->parent->getId()) {
         return $this->parent;
     }
     //todo - BaseObject - knows about Folder ^( Nu i pust'
     $this->parent = Folder::loadById($this->getParentId());
     return $this->parent;
 }
Example #3
0
 protected function processActionDefault()
 {
     if (!$this->folder->canRead($this->storage->getCurrentUserSecurityContext()) || !$this->folder->canRestore($this->storage->getCurrentUserSecurityContext())) {
         $this->showAccessDenied();
         return false;
     }
     $gridId = 'folder_list';
     $this->getApplication()->setTitle($this->storage->getProxyType()->getTitleForCurrentUser());
     $this->processGridActions($gridId);
     $this->arResult = array('GRID' => $this->getGridData($gridId), 'FOLDER' => array('ID' => $this->folder->getId(), 'NAME' => $this->folder->getName(), 'IS_DELETED' => $this->folder->isDeleted(), 'CREATE_TIME' => $this->folder->getCreateTime(), 'UPDATE_TIME' => $this->folder->getUpdateTime()), 'BREADCRUMBS' => $this->getBreadcrumbs(), 'BREADCRUMBS_ROOT' => array('NAME' => Loc::getMessage('DISK_TRASHCAN_NAME'), 'LINK' => CComponentEngine::MakePathFromTemplate($this->arParams['PATH_TO_TRASHCAN_LIST'], array('TRASH_PATH' => '')), 'ID' => $this->storage->getRootObjectId()));
     $this->includeComponentTemplate();
 }
Example #4
0
 protected function processActionDefault()
 {
     $this->arResult = array('FOLDER' => array('ID' => $this->folder->getId(), 'NAME' => $this->folder->getName(), 'IS_DELETED' => $this->folder->isDeleted(), 'CREATE_TIME' => $this->folder->getCreateTime(), 'UPDATE_TIME' => $this->folder->getUpdateTime()), 'BREADCRUMBS' => $this->getBreadcrumbs());
     $this->includeComponentTemplate();
 }
Example #5
0
 protected function processActionWithDeleted()
 {
     $gridId = 'folder_list';
     $this->arResult = array('GRID' => $this->getGridData($gridId, true), 'FOLDER' => array('ID' => $this->folder->getId(), 'NAME' => $this->folder->getName(), 'IS_DELETED' => $this->folder->isDeleted(), 'CREATE_TIME' => $this->folder->getCreateTime(), 'UPDATE_TIME' => $this->folder->getUpdateTime()), 'BREADCRUMBS' => $this->getBreadcrumbs());
     $this->includeComponentTemplate();
 }
Example #6
0
 /**
  * Copies object to target folder.
  * @param Folder $targetFolder Target folder.
  * @param int    $updatedBy Id of user.
  * @param bool   $generateUniqueName Generates unique name for object in directory.
  * @return BaseObject|null
  */
 public function copyTo(Folder $targetFolder, $updatedBy, $generateUniqueName = false)
 {
     $this->errorCollection->clear();
     if ($this->getId() == $targetFolder->getId()) {
         return $this;
     }
     $newRoot = $this->copyToInternal($targetFolder, $updatedBy, $generateUniqueName);
     if (!$newRoot) {
         return null;
     }
     $mapParentToNewParent = array($this->getId() => $newRoot);
     $fakeSecurityContext = Driver::getInstance()->getFakeSecurityContext();
     foreach ($this->getDescendants($fakeSecurityContext) as $item) {
         if (!isset($mapParentToNewParent[$item->getParentId()])) {
             return null;
         }
         /** @var Folder $newParentFolder */
         $newParentFolder = $mapParentToNewParent[$item->getParentId()];
         if ($item instanceof File) {
             /** @var \Bitrix\Disk\File $item */
             $item->copyTo($newParentFolder, $updatedBy, $generateUniqueName);
         } elseif ($item instanceof Folder) {
             /** @var \Bitrix\Disk\Folder $item */
             $newFolder = $item->copyToInternal($newParentFolder, $updatedBy, $generateUniqueName);
             if (!$newFolder) {
                 continue;
             }
             $mapParentToNewParent[$item->getId()] = $newFolder;
         }
     }
     return $newRoot;
 }
Example #7
0
 /**
  * Returns path to list folder.
  * @param Folder $folder Target folder.
  * @return string
  */
 public function getPathFolderList(Folder $folder)
 {
     if ($folder->getStorage()->getRootObjectId() == $folder->getId()) {
         return $folder->getStorage()->getProxyType()->getBaseUrlFolderList();
     }
     $crumbs = implode('/', CrumbStorage::getInstance()->getByObject($folder));
     if ($crumbs) {
         $crumbs .= '/';
     }
     $crumbs .= $folder->getName();
     return $folder->getStorage()->getProxyType()->getBaseUrlFolderList() . $crumbs;
 }