/** * @param $id * @return Version|null */ protected static function getVersionById($id) { if (!isset(static::$loadedVersions[$id])) { static::$loadedVersions[$id] = Version::loadById($id, array('OBJECT.STORAGE')); } return static::$loadedVersions[$id]; }
/** * Returns version model. * @see isSpecificVersion() * @return Version|null */ public function getVersion() { if (!$this->versionId) { return null; } if (isset($this->version) && $this->versionId == $this->version->getId()) { return $this->version; } $this->version = Version::loadById($this->versionId); return $this->version; }
protected function initializeVersion($versionId) { $this->version = Version::loadById($versionId, array('OBJECT.STORAGE')); if (!$this->version) { $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_DOC_CONTROLLER_ERROR_COULD_NOT_FIND_FILE'), self::ERROR_COULD_NOT_FIND_FILE))); $this->sendJsonErrorResponse(); } $this->file = $this->version->getObject(); if (!$this->file) { $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_DOC_CONTROLLER_ERROR_COULD_NOT_FIND_VERSION'), self::ERROR_COULD_NOT_FIND_VERSION))); $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(); } } } }