Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/inc/apiv2/common/AbstractModelAPI.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1526,6 +1526,9 @@ protected function updateToManyRelationship(Request $request, array $data, array
if ($relationKey == null) {
throw new HttpError("Relation does not exist!");
}
if ($relation["readonly"] === true) {
throw new HttpError("This relationship is readonly");
}

$relationType = $relation['relationType'];
$features = $this->getFeaturesOther($relationType);
Expand Down Expand Up @@ -1593,7 +1596,10 @@ public function postToManyRelationshipLink(Request $request, Response $response,
$relation = $this->getToManyRelationships()[$args['relation']];
$relationKey = $relation['relationKey'];
if ($relationKey == null) {
throw new HttpError("Relation does not exist!");
throw new HttpError('Relation does not exist!');
}
if ($relation['readonly'] === true) {
throw new HttpError('This relationship is readonly');
}

// check if the object queried exists
Expand Down
1 change: 1 addition & 0 deletions src/inc/apiv2/model/taskwrappers.routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public static function getToManyRelationships(): array {

'relationType' => Task::class,
'relationKey' => Task::TASK_WRAPPER_ID,
'readonly' => true // Not allowed to change tasks of a taskwrapper
],
];
}
Expand Down
5 changes: 5 additions & 0 deletions src/inc/utils/TaskUtils.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1140,6 +1140,11 @@ public static function deleteTask($task) {
$qF = new QueryFilter(Chunk::TASK_ID, $task->getId(), "=");
Factory::getChunkFactory()->massDeletion([Factory::FILTER => $qF]);
Factory::getTaskFactory()->delete($task);
$taskWrapper = Factory::getTaskWrapperFactory()->get($task->getTaskWrapperId());
// If last task of taskwrapper has been deleted, delete taskwrapper aswell
if (count(self::getTasksOfWrapper($taskWrapper->getId())) === 0) {
Factory::getTaskWrapperFactory()->delete($taskWrapper);
}
LockUtils::deleteLockFile($task->getId());
}

Expand Down