protected function checkPermissions() { $securityContext = $this->file->getStorage()->getCurrentUserSecurityContext(); if (!$this->file->canRead($securityContext)) { $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_DOWNLOAD_CONTROLLER_ERROR_BAD_RIGHTS'), self::ERROR_BAD_RIGHTS))); if (Desktop::getDiskVersion()) { $this->sendJsonErrorResponse(); } //general for user we show simple message $this->sendResponse(Loc::getMessage('DISK_DOWNLOAD_CONTROLLER_ERROR_BAD_RIGHTS')); } }
protected function checkUpdatePermissions() { $securityContext = $this->file->getStorage()->getCurrentUserSecurityContext(); if (!$this->file->canUpdate($securityContext)) { $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_DOC_CONTROLLER_ERROR_BAD_RIGHTS'), self::ERROR_BAD_RIGHTS))); $this->sendJsonErrorResponse(); } }
private function processGridActions($gridId) { $postAction = 'action_button_' . $gridId; if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST[$postAction]) && check_bitrix_sessid()) { if ($_POST[$postAction] == 'delete') { if (empty($_POST['ID'])) { return; } if (!$this->file->canDelete($this->file->getStorage()->getCurrentUserSecurityContext()) || !$this->file->canRestore($this->file->getStorage()->getCurrentUserSecurityContext())) { return; } foreach ($_POST['ID'] as $targetId) { /** @var Version $version */ $version = Version::loadById($targetId); if (!$version) { continue; } $version->delete(); } } } }
/** * Runs index by file. * @param File $file Target file. * @throws \Bitrix\Main\ArgumentNullException * @throws \Bitrix\Main\LoaderException * @return void */ public function indexFile(File $file) { if (!Loader::includeModule('search')) { return; } //here we place configuration by Module (Options). Example, we can deactivate index for big files in Disk. if (!Configuration::allowIndexFiles()) { return; } $storage = $file->getStorage(); if (!$storage) { return; } if (!$storage->getProxyType()->canIndexBySearch()) { return; } $searchData = array('LAST_MODIFIED' => $file->getUpdateTime() ?: $file->getCreateTime(), 'TITLE' => $file->getName(), 'PARAM1' => $file->getStorageId(), 'PARAM2' => $file->getParentId(), 'SITE_ID' => $storage->getSiteId() ?: SITE_ID, 'URL' => $this->getDetailUrl($file), 'PERMISSIONS' => $this->getSimpleRights($file), 'BODY' => $this->getFileContent($file)); if ($storage->getProxyType() instanceof Group) { $searchData['PARAMS'] = array('socnet_group' => $storage->getEntityId(), 'entity' => 'socnet_group'); } /** @noinspection PhpDynamicAsStaticMethodCallInspection */ CSearch::index(Driver::INTERNAL_MODULE_ID, $this->getItemId($file), $searchData, true); }
private function notifySonetGroup(File $fileModel) { //todo create NotifyManager, which provides notify (not only group) if (!Loader::includeModule('socialnetwork')) { return; } $storage = $fileModel->getStorage(); if (!$storage->getProxyType() instanceof Group) { return; } $groupId = (int) $storage->getEntityId(); if ($groupId <= 0) { return; } $fileUrl = Driver::getInstance()->getUrlManager()->getPathFileDetail($fileModel); $fileCreatedBy = $fileModel->getCreatedBy(); $fileName = $fileModel->getName(); /** @noinspection PhpDynamicAsStaticMethodCallInspection */ \CSocNetSubscription::notifyGroup(array('LOG_ID' => false, 'GROUP_ID' => array($groupId), 'NOTIFY_MESSAGE' => '', 'FROM_USER_ID' => $fileCreatedBy, 'URL' => $fileUrl, 'MESSAGE' => Loc::getMessage('DISK_FOLDER_MODEL_IM_NEW_FILE', array('#TITLE#' => '<a href="#URL#" class="bx-notifier-item-action">' . $fileName . '</a>')), 'MESSAGE_OUT' => Loc::getMessage('DISK_FOLDER_MODEL_IM_NEW_FILE', array('#TITLE#' => $fileName)) . ' (#URL#)', 'EXCLUDE_USERS' => array($fileCreatedBy))); }