protected function deleteNonRecursive($deletedBy) { foreach ($this->getSharingsAsReal() as $sharing) { $sharing->delete($deletedBy); } //with status unreplied, declined (not approved) $success = SharingTable::deleteByFilter(array('REAL_OBJECT_ID' => $this->id)); if (!$success) { return false; } SimpleRightTable::deleteBatch(array('OBJECT_ID' => $this->id)); $success = RightTable::deleteByFilter(array('OBJECT_ID' => $this->id)); if (!$success) { return false; } DeletedLog::addFolder($this, $deletedBy, $this->errorCollection); $resultDelete = FolderTable::delete($this->id); if (!$resultDelete->isSuccess()) { return false; } if (!$this->isLink()) { //todo potential - very hard operation. foreach (Folder::getModelList(array('filter' => array('REAL_OBJECT_ID' => $this->id, '!=REAL_OBJECT_ID' => $this->id))) as $link) { $link->deleteTree($deletedBy); } unset($link); } $event = new Event(Driver::INTERNAL_MODULE_ID, "onAfterDeleteFolder", array($this->getId(), $deletedBy)); $event->send(); return true; }
/** * Get readable storages by SecurityContext. * Be careful! The method works under FolderTable and $parameters belongs to FolderTable. * @param SecurityContext $securityContext SecurityContext. * @param array $parameters Parameters to getList. * @return Storage[] */ public static function getReadableList(SecurityContext $securityContext, array $parameters = array()) { /** @var Folder[] $items */ $filter = array('=PARENT_ID' => null, '=STORAGE.MODULE_ID' => Driver::INTERNAL_MODULE_ID, '=RIGHTS_CHECK' => true); if (!empty($parameters['filter']['STORAGE.ENTITY_TYPE'])) { $filter['=STORAGE.ENTITY_TYPE'] = $parameters['filter']['STORAGE.ENTITY_TYPE']; } if (!empty($parameters['filter']['STORAGE.SITE_ID'])) { $filter['=STORAGE.SITE_ID'] = $parameters['filter']['STORAGE.SITE_ID']; } $parameters = array('with' => array('STORAGE'), 'runtime' => array(new ExpressionField('RIGHTS_CHECK', 'CASE WHEN ' . $securityContext->getSqlExpressionForList('%1$s', '%2$s') . ' THEN 1 ELSE 0 END', array('ID', 'CREATED_BY'), array('data_type' => 'boolean'))), 'filter' => $filter); $parameters = Driver::getInstance()->getRightsManager()->addRightsCheck($securityContext, $parameters, array('ID', 'CREATED_BY')); $items = Folder::getModelList($parameters); $storages = array(); foreach ($items as $item) { $item->getStorage()->setAttributes(array('ROOT_OBJECT' => $item)); $storages[] = $item->getStorage(); } unset($item); return $storages; }