0) { $newRank = 0; } elseif ($newRank < 0) { error('Ranking cannot be a negative value'); } $forum = (new \Gazelle\Manager\Forum)->findByThreadId($threadId); [$oldForumId, $oldName, $minClassWrite, $posts, $threadAuthorId, $oldTitle, $oldLocked, $oldSticky, $oldRank] = $forum->threadInfoExtended($threadId); if ($minClassWrite > $LoggedUser['Class']) { error(403); } if (isset($_POST['delete'])) { if (!check_perms('site_admin_forums')) { error(403); } $forum->removeThread($threadId); $location = "forums.php?action=viewforum&forumid=$newForumId"; } else { // We are editing it if (isset($_POST['transition'])) { $transId = (int)$_POST['transition']; if ($transId < 1) { error(0); } else { // Permissions are handled inside forums.class.php $transitions = Forums::get_transitions(); if (!isset($transitions[$transId])) { error(0); } else { $transition = $transitions[$transId]; if ($transition['source'] != $oldForumId) { error(403); } $newForumId = $transition['destination']; $newSticky = $oldSticky; $locked = $oldLocked; $newRank = $oldRank; $newTitle = $oldTitle; $action = 'transitioning'; } } } if ($locked && check_perms('site_moderate_forums')) { $forum->clearUserLastRead($threadId); } $forum->editThread($threadId, $newForumId, $newSticky, $newRank, $locked, $newTitle); // topic notes and notifications $notes = []; $newName = $DB->scalar('SELECT Name FROM forums WHERE ID = ?', $newForumId); $oldUrl = "[url=" . SITE_URL . "/forums.php?action=viewforum&forumid=$oldForumId]{$oldName}[/url]"; $newUrl = "[url=" . SITE_URL . "/forums.php?action=viewforum&forumid=$newForumId]{$newName}[/url]"; switch ($action ?? null) { case 'transitioning': $notes[] = "Moved from $oldUrl to $newUrl (" . $transition['label'] . " transition)"; break; default: if ($oldTitle != $newTitle) { $notes[] = "Title edited from \"$oldTitle\" to \"$newTitle\""; } if ($oldLocked != $locked) { $notes[] = $oldLocked ? 'Unlocked' : 'Locked'; } if ($oldSticky != $newSticky) { $notes[] = $oldSticky ? 'Unstickied' : 'Stickied'; } if ($oldRank != $newRank) { $notes[] = "Ranking changed from $oldRank to $newRank"; } if ($newForumId != $oldForumId) { $notes[] = "Moved from $oldUrl to $newUrl"; } break; } if ($notes) { $forum->addThreadNote($threadId, $LoggedUser['ID'], implode("\n", $notes)); } $location = "forums.php?action=viewthread&threadid=$threadId&page=$page"; } header("Location: $location");