2011-01-28 07:35:26 +00:00
|
|
|
<?php
|
|
|
|
// MyDMS. Document Management System
|
|
|
|
// Copyright (C) 2002-2005 Markus Westphal
|
|
|
|
// Copyright (C) 2006-2008 Malcolm Cowe
|
2016-08-09 05:34:30 +00:00
|
|
|
// Copyright (C) 2010-2016 Uwe Steinmann
|
2011-01-28 07:35:26 +00:00
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation; either version 2 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
include("../inc/inc.Settings.php");
|
|
|
|
include("../inc/inc.Utils.php");
|
2022-11-09 05:40:50 +00:00
|
|
|
include("../inc/inc.LogInit.php");
|
2011-01-28 07:35:26 +00:00
|
|
|
include("../inc/inc.Language.php");
|
2014-12-08 13:47:32 +00:00
|
|
|
include("../inc/inc.Init.php");
|
|
|
|
include("../inc/inc.Extension.php");
|
|
|
|
include("../inc/inc.DBInit.php");
|
2011-01-28 07:35:26 +00:00
|
|
|
include("../inc/inc.ClassUI.php");
|
2010-10-29 13:19:51 +00:00
|
|
|
include("../inc/inc.Authentication.php");
|
|
|
|
|
2012-09-11 12:51:46 +00:00
|
|
|
if(!checkFormKey('foldernotify')) {
|
|
|
|
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("invalid_request_token"));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isset($_POST["folderid"]) || !is_numeric($_POST["folderid"]) || intval($_POST["folderid"])<1) {
|
2011-01-28 07:35:26 +00:00
|
|
|
UI::exitError(getMLText("folder_title", array("foldername" => getMLText("invalid_folder_id"))),getMLText("invalid_folder_id"));
|
2010-10-29 13:19:51 +00:00
|
|
|
}
|
2011-01-28 07:35:26 +00:00
|
|
|
|
2012-09-11 12:51:46 +00:00
|
|
|
$folderid = $_POST["folderid"];
|
2010-11-12 22:47:41 +00:00
|
|
|
$folder = $dms->getFolder($folderid);
|
2011-01-28 07:35:26 +00:00
|
|
|
|
|
|
|
if (!is_object($folder)) {
|
|
|
|
UI::exitError(getMLText("folder_title", array("foldername" => getMLText("invalid_folder_id"))),getMLText("invalid_folder_id"));
|
|
|
|
}
|
|
|
|
|
2012-09-11 12:51:46 +00:00
|
|
|
if (!isset($_POST["action"]) || (strcasecmp($_POST["action"], "delnotify") && strcasecmp($_POST["action"], "addnotify"))) {
|
2011-01-28 07:35:26 +00:00
|
|
|
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("invalid_action"));
|
|
|
|
}
|
2012-09-11 12:51:46 +00:00
|
|
|
$action = $_POST["action"];
|
2011-01-28 07:35:26 +00:00
|
|
|
|
2012-09-11 12:51:46 +00:00
|
|
|
if (isset($_POST["userid"]) && (!is_numeric($_POST["userid"]) || $_POST["userid"]<-1)) {
|
2011-01-28 07:35:26 +00:00
|
|
|
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("unknown_user"));
|
|
|
|
}
|
2013-03-06 11:53:25 +00:00
|
|
|
$userid = isset($_POST["userid"]) ? $_POST["userid"] : -1;
|
2011-01-28 07:35:26 +00:00
|
|
|
|
2012-09-11 12:51:46 +00:00
|
|
|
if (isset($_POST["groupid"]) && (!is_numeric($_POST["groupid"]) || $_POST["groupid"]<-1)) {
|
2011-01-28 07:35:26 +00:00
|
|
|
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("unknown_group"));
|
|
|
|
}
|
2013-03-06 11:53:25 +00:00
|
|
|
$groupid = isset($_POST["groupid"]) ? $_POST["groupid"] : -1;
|
2010-10-29 13:19:51 +00:00
|
|
|
|
2012-09-11 12:51:46 +00:00
|
|
|
if (isset($_POST["groupid"])&&$_POST["groupid"]!=-1){
|
2010-11-15 12:01:21 +00:00
|
|
|
$group=$dms->getGroup($groupid);
|
2010-10-29 13:19:51 +00:00
|
|
|
if (!$group->isMember($user,true) && !$user->isAdmin())
|
|
|
|
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("access_denied"));
|
2011-01-28 07:35:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$folderPathHTML = getFolderPathHTML($folder, true);
|
|
|
|
|
|
|
|
if ($folder->getAccessMode($user) < M_READ) {
|
2010-10-29 13:19:51 +00:00
|
|
|
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("access_denied"));
|
2011-01-28 07:35:26 +00:00
|
|
|
}
|
|
|
|
|
2013-01-24 10:12:15 +00:00
|
|
|
// Delete notification -------------------------------------------------------
|
2011-01-28 07:35:26 +00:00
|
|
|
if ($action == "delnotify") {
|
|
|
|
|
|
|
|
if ($userid > 0) {
|
|
|
|
$res = $folder->removeNotify($userid, true);
|
2010-11-17 07:34:12 +00:00
|
|
|
$obj = $dms->getUser($userid);
|
2011-01-28 07:35:26 +00:00
|
|
|
}
|
|
|
|
elseif ($groupid > 0) {
|
|
|
|
$res = $folder->removeNotify($groupid, false);
|
2010-11-17 07:34:12 +00:00
|
|
|
$obj = $dms->getGroup($groupid);
|
2011-01-28 07:35:26 +00:00
|
|
|
}
|
|
|
|
switch ($res) {
|
2010-10-29 13:19:51 +00:00
|
|
|
case -1:
|
2011-01-28 07:35:26 +00:00
|
|
|
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),isset($userid) ? getMLText("unknown_user") : getMLText("unknown_group"));
|
|
|
|
break;
|
|
|
|
case -2:
|
|
|
|
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("access_denied"));
|
|
|
|
break;
|
|
|
|
case -3:
|
2021-05-18 15:39:14 +00:00
|
|
|
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("not_subscribed"));
|
2011-01-28 07:35:26 +00:00
|
|
|
break;
|
|
|
|
case -4:
|
|
|
|
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("internal_error"));
|
|
|
|
break;
|
|
|
|
case 0:
|
2021-05-21 06:53:43 +00:00
|
|
|
$session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_rm_notify')));
|
2010-11-17 07:34:12 +00:00
|
|
|
if($notifier) {
|
2021-05-18 15:39:14 +00:00
|
|
|
$notifier->sendDeleteFolderNotifyMail($folder, $user, $obj);
|
2010-11-17 07:34:12 +00:00
|
|
|
}
|
2011-01-28 07:35:26 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-05 07:50:45 +00:00
|
|
|
// Add notification ----------------------------------------------------------
|
2011-01-28 07:35:26 +00:00
|
|
|
else if ($action == "addnotify") {
|
|
|
|
|
|
|
|
if ($userid != -1) {
|
|
|
|
$res = $folder->addNotify($userid, true);
|
|
|
|
switch ($res) {
|
|
|
|
case -1:
|
|
|
|
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("unknown_user"));
|
|
|
|
break;
|
|
|
|
case -2:
|
|
|
|
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("access_denied"));
|
|
|
|
break;
|
|
|
|
case -3:
|
|
|
|
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("already_subscribed"));
|
|
|
|
break;
|
|
|
|
case -4:
|
|
|
|
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("internal_error"));
|
|
|
|
break;
|
|
|
|
case 0:
|
2021-05-21 06:53:43 +00:00
|
|
|
$session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_add_notify')));
|
2010-11-17 07:34:12 +00:00
|
|
|
if($notifier) {
|
2013-03-06 11:53:25 +00:00
|
|
|
$obj = $dms->getUser($userid);
|
2021-05-18 15:39:14 +00:00
|
|
|
$notifier->sendNewFolderNotifyMail($folder, $user, $obj);
|
2010-11-17 07:34:12 +00:00
|
|
|
}
|
|
|
|
|
2011-01-28 07:35:26 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($groupid != -1) {
|
|
|
|
$res = $folder->addNotify($groupid, false);
|
|
|
|
switch ($res) {
|
|
|
|
case -1:
|
|
|
|
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("unknown_group"));
|
|
|
|
break;
|
|
|
|
case -2:
|
|
|
|
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("access_denied"));
|
|
|
|
break;
|
|
|
|
case -3:
|
|
|
|
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("already_subscribed"));
|
|
|
|
break;
|
|
|
|
case -4:
|
|
|
|
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("internal_error"));
|
|
|
|
break;
|
|
|
|
case 0:
|
2021-05-21 06:53:43 +00:00
|
|
|
$session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_add_notify')));
|
2010-11-17 07:34:12 +00:00
|
|
|
if($notifier) {
|
2013-03-06 11:53:25 +00:00
|
|
|
$obj = $dms->getGroup($groupid);
|
2021-05-18 15:39:14 +00:00
|
|
|
$notifier->sendNewFolderNotifyMail($folder, $user, $obj);
|
2010-11-17 07:34:12 +00:00
|
|
|
}
|
2011-01-28 07:35:26 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-29 13:19:51 +00:00
|
|
|
header("Location:../out/out.FolderNotify.php?folderid=".$folderid);
|
2011-01-28 07:35:26 +00:00
|
|
|
|
|
|
|
?>
|