114 $session = $this->authHelper->getSession();
123 $session = $this->authHelper->getSession();
200 public function copyUpload($uploadId, $newFolderId, $isCopy)
202 if (! is_numeric($newFolderId) || $newFolderId <= 0) {
205 if (!$this->folderDao->isFolderAccessible($newFolderId, $this->getUserId())) {
206 throw new HttpForbiddenException(
"Folder is not accessible.");
208 if (!$this->uploadPermissionDao->isAccessible($uploadId, $this->getGroupId())) {
209 throw new HttpForbiddenException(
"Upload is not accessible.");
211 $uploadContentId = $this->folderDao->getFolderContentsId($uploadId,
212 $this->folderDao::MODE_UPLOAD);
214 $contentMove = $this->
getPlugin(
'content_move');
216 $errors = $contentMove->copyContent([$uploadContentId], $newFolderId, $isCopy);
217 if (empty($errors)) {
218 $action = $isCopy ?
"copied" :
"moved";
219 $info =
new Info(202,
"Upload $uploadId will be $action to folder $newFolderId",
222 $info =
new Info(202,
"Exceptions occurred: $errors",
241 $plugin = plugin_find($pluginName);
243 throw new \UnexpectedValueException(
244 "Unable to find plugin " . $pluginName);
266 $tokenValidity = $this->authHelper->getMaxTokenValidity();
268 if (strtotime($tokenExpire) < strtotime(
"tomorrow") ||
269 ! preg_match(
"/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/",
271 strtotime($tokenExpire) > strtotime(
"+$tokenValidity days")) {
273 "The token should have at least 1 day and max $tokenValidity days " .
274 "of validity and should follow YYYY-MM-DD format.");
277 "Invalid token scope, allowed only " .
279 } elseif (empty($tokenName) || strlen($tokenName) > 40) {
281 "The token name must be a valid string of max 40 character length");
307 if (empty($clientName) || strlen($clientName) > 40) {
309 "The client name must be a valid string of max 40 character length");
311 $sql =
"SELECT 1 FROM personal_access_tokens " .
312 "WHERE user_fk = $1 AND client_id = $2;";
313 $rows = $this->dbHelper->getDbManager()->getSingleRow($sql, [
Contains the constants and helpers for authentication of user.
Provides helper methods for REST api.
Provides helper methods to access database for REST api.
Provides various DAO helper functions for REST api.
validateTokenRequest($tokenExpire, $tokenName, $tokenScope)
Check if the token request contains valid parameters.
getPlugin($pluginName)
A safe wrapper around plugin_find.
validateNewOauthClient($userId, $clientName, $clientScope, $clientId)
Check if the new oauth client is valid.
__construct(UploadPermissionDao $uploadPermissionDao, UploadDao $uploadDao, UserDao $userDao, FolderDao $folderDao, DbHelper $dbHelper, AuthHelper $authHelper, JobDao $jobDao, ShowJobsDao $showJobDao)
RestHelper constructor.
Different type of infos provided by REST.
Info model to contain general error and return values.