code cleanup

This commit is contained in:
Uwe Steinmann 2024-03-22 10:01:19 +01:00
parent 6cb356454f
commit 7bdfd5f88f
2 changed files with 26 additions and 20 deletions

View File

@ -52,37 +52,39 @@ $action = $_POST["action"];
if (isset($_POST["userid"]) && (!is_numeric($_POST["userid"]) || $_POST["userid"]<-1)) {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("unknown_user"));
}
$userid = isset($_POST["userid"]) ? $_POST["userid"] : -1;
$userid = 0;
if(isset($_POST["userid"]))
$userid = $_POST["userid"];
if ($userid > 0){
$u=$dms->getUser($userid);
if (($u->getId() != $user->getId()) && !$user->isAdmin())
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("access_denied"));
}
if (isset($_POST["groupid"]) && (!is_numeric($_POST["groupid"]) || $_POST["groupid"]<-1)) {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("unknown_group"));
}
if(isset($_POST["groupid"]))
$groupid = $_POST["groupid"];
$groupid = isset($_POST["groupid"]) ? $_POST["groupid"] : -1;
if (isset($_POST["groupid"])&&$_POST["groupid"]!=-1){
if ($groupid > 0){
$group=$dms->getGroup($groupid);
if (!$group->isMember($user,true) && !$user->isAdmin())
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied"));
}
$folder = $document->getFolder();
$docPathHTML = getFolderPathHTML($folder, true). " / <a href=\"../out/out.ViewDocument.php?documentid=".$documentid."\">".$document->getName()."</a>";
if ($document->getAccessMode($user) < M_READ) {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied"));
}
// delete notification
if ($action == "delnotify"){
if ($userid) {
if ($action == "delnotify") {
if ($userid > 0) {
$obj = $dms->getUser($userid);
$res = $document->removeNotify($userid, true);
} elseif (isset($groupid)) {
} elseif ($groupid > 0) {
$obj = $dms->getGroup($groupid);
$res = $document->removeNotify($groupid, false);
}
@ -137,7 +139,7 @@ else if ($action == "addnotify") {
break;
}
}
if ($groupid != -1) {
if ($groupid > 0) {
$res = $document->addNotify($groupid, false);
switch ($res) {
case -1:

View File

@ -53,19 +53,24 @@ if (isset($_POST["userid"]) && (!is_numeric($_POST["userid"]) || $_POST["userid"
}
$userid = isset($_POST["userid"]) ? $_POST["userid"] : -1;
if ($userid > 0){
$u=$dms->getUser($userid);
if (($u->getId() != $user->getId()) && !$user->isAdmin())
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("access_denied"));
}
if (isset($_POST["groupid"]) && (!is_numeric($_POST["groupid"]) || $_POST["groupid"]<-1)) {
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("unknown_group"));
}
$groupid = isset($_POST["groupid"]) ? $_POST["groupid"] : -1;
if (isset($_POST["groupid"])&&$_POST["groupid"]!=-1){
if ($groupid > 0){
$group=$dms->getGroup($groupid);
if (!$group->isMember($user,true) && !$user->isAdmin())
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("access_denied"));
}
$folderPathHTML = getFolderPathHTML($folder, true);
if ($folder->getAccessMode($user) < M_READ) {
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("access_denied"));
}
@ -74,12 +79,11 @@ if ($folder->getAccessMode($user) < M_READ) {
if ($action == "delnotify") {
if ($userid > 0) {
$res = $folder->removeNotify($userid, true);
$obj = $dms->getUser($userid);
}
elseif ($groupid > 0) {
$res = $folder->removeNotify($groupid, false);
$res = $folder->removeNotify($userid, true);
} elseif ($groupid > 0) {
$obj = $dms->getGroup($groupid);
$res = $folder->removeNotify($groupid, false);
}
switch ($res) {
case -1:
@ -106,7 +110,7 @@ if ($action == "delnotify") {
// Add notification ----------------------------------------------------------
else if ($action == "addnotify") {
if ($userid != -1) {
if ($userid > 0) {
$res = $folder->addNotify($userid, true);
switch ($res) {
case -1:
@ -132,7 +136,7 @@ else if ($action == "addnotify") {
break;
}
}
if ($groupid != -1) {
if ($groupid > 0) {
$res = $folder->addNotify($groupid, false);
switch ($res) {
case -1: