- moved all notification code out of LetoDMS_Document into the 'layer'

above. This will allow to get rid of most of the global variables
	in LetoDMS_Document and make it reusable
This commit is contained in:
steinm 2010-11-18 13:53:26 +00:00
parent cc43fca1a3
commit 1f09dc0a34
17 changed files with 2682 additions and 2450 deletions

File diff suppressed because it is too large Load Diff

View File

@ -68,6 +68,26 @@ $res = $document->addDocumentFile($name, $comment, $user, $userfiletmp,
if (is_bool($res) && !$res) {
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("error_occured"));
} else {
$document->getNotifyList();
// Send notification to subscribers.
if($notifier) {
$subject = "###SITENAME###: ".$document->_name." - ".getMLText("new_file_email");
$message = getMLText("new_file_email")."\r\n";
$message .=
getMLText("name").": ".$name."\r\n".
getMLText("comment").": ".$comment."\r\n".
getMLText("user").": ".$user->getFullName()." <". $user->getEmail() .">\r\n".
"URL: ###URL_PREFIX###out/out.ViewDocument.php?documentid=".$document->getID()."\r\n";
$subject=mydmsDecodeString($subject);
$message=mydmsDecodeString($message);
$notifier->toList($user, $document->_notifyList["users"], $subject, $message);
foreach ($document->_notifyList["groups"] as $grp) {
$notifier->toGroup($user, $grp, $subject, $message);
}
}
}
add_log_line("?name=".$name."&documentid=".$documentid);

View File

@ -66,7 +66,7 @@ if (is_object($subFolder)) {
getMLText("name").": ".$name."\r\n".
getMLText("folder").": ".$subFolder->getFolderPathPlain()."\r\n".
getMLText("comment").": ".$comment."\r\n".
getMLText("user").": ".$owner->getFullName()."\r\n".
getMLText("user").": ".$user->getFullName()."\r\n".
"URL: ###URL_PREFIX###out/out.ViewFolder.php?folderid=".$subFolder->getID()."\r\n";
$subject=mydmsDecodeString($subject);

View File

@ -188,9 +188,34 @@ else if ($_POST["approvalType"] == "grp") {
//
if ($_POST["approvalStatus"]==-1){
if($content->setStatus(S_REJECTED,$comment,$user)) {
$nl=$document->getNotifyList();
// Send notification to subscribers.
if($notifier) {
$folder = $document->getFolder();
$subject = "###SITENAME###: ".$document->_name." - ".getMLText("document_status_changed_email");
$message = getMLText("document_status_changed_email")."\r\n";
$message .=
getMLText("document").": ".$document->_name."\r\n".
getMLText("status").": ".getOverallStatusText($status)."\r\n".
getMLText("folder").": ".$folder->getFolderPathPlain()."\r\n".
getMLText("comment").": ".$document->getComment()."\r\n".
"URL: ###URL_PREFIX###out/out.ViewDocument.php?documentid=".$document->getID()."&version=".$content->_version."\r\n";
$content->setStatus(S_REJECTED,$comment,$user);
$uu = (is_null($updateUser) ? $document->_dms->getUser($settings->_adminID) : $updateUser);
$subject=mydmsDecodeString($subject);
$message=mydmsDecodeString($message);
$notifier->toList($uu, $nl["users"], $subject, $message);
foreach ($nl["groups"] as $grp) {
$notifier->toGroup($uu, $grp, $subject, $message);
}
}
// TODO: if user os not owner send notification to owner
}
}else{
$docApprovalStatus = $content->getApprovalStatus(true);
@ -212,7 +237,33 @@ if ($_POST["approvalStatus"]==-1){
if ($approvalCT == $approvalTotal) {
// Change the status to released.
$newStatus=2;
$content->setStatus($newStatus, getMLText("automatic_status_update"), $user);
if($content->setStatus($newStatus, getMLText("automatic_status_update"), $user)) {
$nl=$document->getNotifyList();
// Send notification to subscribers.
if($notifier) {
$folder = $document->getFolder();
$subject = "###SITENAME###: ".$document->_name." - ".getMLText("document_status_changed_email");
$message = getMLText("document_status_changed_email")."\r\n";
$message .=
getMLText("document").": ".$document->_name."\r\n".
getMLText("status").": ".getOverallStatusText($status)."\r\n".
getMLText("folder").": ".$folder->getFolderPathPlain()."\r\n".
getMLText("comment").": ".$document->getComment()."\r\n".
"URL: ###URL_PREFIX###out/out.ViewDocument.php?documentid=".$document->getID()."&version=".$content->_version."\r\n";
$uu = (is_null($updateUser) ? $document->_dms->getUser($settings->_adminID) : $updateUser);
$subject=mydmsDecodeString($subject);
$message=mydmsDecodeString($message);
$notifier->toList($uu, $nl["users"], $subject, $message);
foreach ($nl["groups"] as $grp) {
$notifier->toGroup($uu, $grp, $subject, $message);
}
}
// TODO: if user os not owner send notification to owner
}
}
}

View File

@ -118,15 +118,81 @@ if ($action == "setowner") {
if (!is_object($newOwner)) {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("unknown_user"));
}
$document->setOwner($newOwner);
$oldOwner = $document->getOwner();
if($document->setOwner($newOwner)) {
$document->getNotifyList();
// Send notification to subscribers.
if($notifier) {
$folder = $document->getFolder();
$subject = "###SITENAME###: ".$document->_name." - ".getMLText("ownership_changed_email");
$message = getMLText("ownership_changed_email")."\r\n";
$message .=
getMLText("document").": ".$document->_name."\r\n".
getMLText("old").": ".$oldOwner->getFullName()."\r\n".
getMLText("new").": ".$newOwner->getFullName()."\r\n".
getMLText("folder").": ".$folder->getFolderPathPlain()."\r\n".
getMLText("comment").": ".$document->_comment."\r\n".
"URL: ###URL_PREFIX###out/out.ViewDocument.php?documentid=".$document->_id."\r\n";
$subject=mydmsDecodeString($subject);
$message=mydmsDecodeString($message);
$notifier->toList($user, $document->_notifyList["users"], $subject, $message);
foreach ($document->_notifyList["groups"] as $grp) {
$notifier->toGroup($user, $grp, $subject, $message);
}
// Send notification to previous owner.
$notifier->toIndividual($user, $oldOwner, $subject, $message);
}
}
}
//Änderung auf nicht erben ------------------------------------------------------------------------
else if ($action == "notinherit") {
$defAccess = $document->getDefaultAccess();
$document->setInheritAccess(false);
$document->setDefaultAccess($defAccess);
if($document->setInheritAccess(false)) {
$document->getNotifyList();
if($notifier) {
$folder = $document->getFolder();
// Send notification to subscribers.
$subject = "###SITENAME###: ".$document->_name." - ".getMLText("access_permission_changed_email");
$message = getMLText("access_permission_changed_email")."\r\n";
$message .=
getMLText("document").": ".$document->_name."\r\n".
getMLText("folder").": ".$folder->getFolderPathPlain()."\r\n".
"URL: ###URL_PREFIX###out/out.ViewDocument.php?documentid=".$document->_id."\r\n";
$subject=mydmsDecodeString($subject);
$message=mydmsDecodeString($message);
$notifier->toList($user, $document->_notifyList["users"], $subject, $message);
foreach ($document->_notifyList["groups"] as $grp) {
$notifier->toGroup($user, $grp, $subject, $message);
}
}
}
if($document->setDefaultAccess($defAccess)) {
$document->getNotifyList();
if($notifier) {
$folder = $document->getFolder();
// Send notification to subscribers.
$subject = "###SITENAME###: ".$document->_name." - ".getMLText("access_permission_changed_email");
$message = getMLText("access_permission_changed_email")."\r\n";
$message .=
getMLText("document").": ".$document->_name."\r\n".
getMLText("folder").": ".$folder->getFolderPathPlain()."\r\n".
"URL: ###URL_PREFIX###out/out.ViewDocument.php?documentid=".$document->_id."\r\n";
$subject=mydmsDecodeString($subject);
$message=mydmsDecodeString($message);
$notifier->toList($user, $document->_notifyList["users"], $subject, $message);
foreach ($document->_notifyList["groups"] as $grp) {
$notifier->toGroup($user, $grp, $subject, $message);
}
}
}
//copy ACL of parent folder
if ($mode == "copy") {
@ -146,10 +212,30 @@ else if ($action == "inherit") {
//Standardberechtigung setzen----------------------------------------------------------------------
else if ($action == "setdefault") {
$document->setDefaultAccess($mode);
if($document->setDefaultAccess($mode)) {
$document->getNotifyList();
if($notifier) {
$folder = $document->getFolder();
// Send notification to subscribers.
$subject = "###SITENAME###: ".$document->_name." - ".getMLText("access_permission_changed_email");
$message = getMLText("access_permission_changed_email")."\r\n";
$message .=
getMLText("document").": ".$document->_name."\r\n".
getMLText("folder").": ".$folder->getFolderPathPlain()."\r\n".
"URL: ###URL_PREFIX###out/out.ViewDocument.php?documentid=".$document->_id."\r\n";
$subject=mydmsDecodeString($subject);
$message=mydmsDecodeString($message);
$notifier->toList($user, $document->_notifyList["users"], $subject, $message);
foreach ($document->_notifyList["groups"] as $grp) {
$notifier->toGroup($user, $grp, $subject, $message);
}
}
}
}
//Bestehende Berechtigung änndern -----------------------------------------------------------------
// Bestehende Berechtigung ändern --------------------------------------------
else if ($action == "editaccess") {
if (isset($userid)) {
$document->changeAccess($mode, $userid, true);

View File

@ -74,10 +74,14 @@ if ($document->getAccessMode($user) < M_READ) {
//Benachrichtigung löschen ------------------------------------------------------------------------
if ($action == "delnotify"){
if (isset($userid)) {
$res = $document->removeNotify($userid, true);
if($res = $document->removeNotify($userid, true)) {
$obj = $dms->getUser($userid);
}
}
else if (isset($groupid)) {
$res = $document->removeNotify($groupid, false);
if($res = $document->removeNotify($groupid, false)) {
$obj = $dms->getGroup($groupid);
}
}
switch ($res) {
case -1:
@ -93,6 +97,34 @@ if ($action == "delnotify"){
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("internal_error"));
break;
case 0:
// Email user / group, informing them of subscription change.
if($notifier) {
$path="";
$folder = $document->getFolder();
$folderPath = $folder->getPath();
for ($i = 0; $i < count($folderPath); $i++) {
$path .= $folderPath[$i]->getName();
if ($i +1 < count($folderPath))
$path .= " / ";
}
$subject = "###SITENAME###: ".$document->getName()." - ".getMLText("notify_deleted_email");
$message = getMLText("notify_deleted_email")."\r\n";
$message .=
getMLText("document").": ".$document->getName()."\r\n".
getMLText("folder").": ".$path."\r\n".
getMLText("comment").": ".$document->getComment()."\r\n".
"URL: ###URL_PREFIX###out/out.ViewDocument.php?documentid=".$document->_id."\r\n";
$subject=mydmsDecodeString($subject);
$message=mydmsDecodeString($message);
if ($isUser) {
$notifier->toIndividual($user, $obj, $subject, $message);
}
else {
$notifier->toGroup($user, $obj, $subject, $message);
}
}
break;
}
}
@ -116,6 +148,31 @@ else if ($action == "addnotify") {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("internal_error"));
break;
case 0:
// Email user / group, informing them of subscription.
if ($notifier){
$path="";
$folder = $document->getFolder();
$folderPath = $folder->getPath();
for ($i = 0; $i < count($folderPath); $i++) {
$path .= $folderPath[$i]->getName();
if ($i +1 < count($folderPath))
$path .= " / ";
}
$obj = $dms->getUser($userid);
$subject = "###SITENAME###: ".$document->getName()." - ".getMLText("notify_added_email");
$message = getMLText("notify_added_email")."\r\n";
$message .=
getMLText("document").": ".$document->getName()."\r\n".
getMLText("folder").": ".$path."\r\n".
getMLText("comment").": ".$document->getComment()."\r\n".
"URL: ###URL_PREFIX###out/out.ViewDocument.php?documentid=".$document->_id."\r\n";
$subject=mydmsDecodeString($subject);
$message=mydmsDecodeString($message);
$notifier->toIndividual($user, $obj, $subject, $message);
}
break;
}
}
@ -135,6 +192,29 @@ else if ($action == "addnotify") {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("internal_error"));
break;
case 0:
if ($notifier){
$path="";
$folder = $document->getFolder();
$folderPath = $folder->getPath();
for ($i = 0; $i < count($folderPath); $i++) {
$path .= $folderPath[$i]->getName();
if ($i +1 < count($folderPath))
$path .= " / ";
}
$obj = $dms->getGroup($groupid);
$subject = "###SITENAME###: ".$document->getName()." - ".getMLText("notify_added_email");
$message = getMLText("notify_added_email")."\r\n";
$message .=
getMLText("document").": ".$document->getName()."\r\n".
getMLText("folder").": ".$path."\r\n".
getMLText("comment").": ".$document->getComment()."\r\n".
"URL: ###URL_PREFIX###out/out.ViewDocument.php?documentid=".$document->_id."\r\n";
$subject=mydmsDecodeString($subject);
$message=mydmsDecodeString($message);
$notifier->toGroup($user, $obj, $subject, $message);
}
break;
}
}

View File

@ -110,7 +110,7 @@ if (isset($_GET["version"])){
header("Content-Length: " . filesize($settings->_contentDir . $file->getPath() ));
header("Content-Disposition: attachment; filename=\"" . mydmsDecodeString($file->getOriginalFileName()) . "\"");
//header("Expires: 0");
//header("Content-Type: " . $content->getMimeType());
header("Content-Type: " . $file->getMimeType());
//header("Cache-Control: no-cache, must-revalidate");
header("Cache-Control: must-revalidate");
//header("Pragma: no-cache");
@ -170,7 +170,7 @@ if (isset($_GET["version"])){
// versioning info download
$documentid = $_GET["documentid"];
$document = getDocument($documentid);
$document = $dms->getDocument($documentid);
if (!is_object($document)) {
UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id"));

View File

@ -57,8 +57,28 @@ if (!is_object($version)) {
$comment = sanitizeString($_POST["comment"]);
if (($version->getComment() == $comment) || $version->setComment($comment))
{
if (($oldcomment = $version->getComment()) == $comment) {
if($version->setComment($comment)) {
$document->getNotifyList();
if($notifier) {
$subject = "###SITENAME###: ".$document->getName().", v.".$version->_version." - ".getMLText("comment_changed_email");
$message = getMLText("comment_changed_email")."\r\n";
$message .=
getMLText("document").": ".$document->getName()."\r\n".
getMLText("version").": ".$version->_version."\r\n".
getMLText("comment").": ".$comment."\r\n".
getMLText("user").": ".$user->getFullName()." <". $user->getEmail() .">\r\n".
"URL: ###URL_PREFIX###out/out.ViewDocument.php?documentid=".$document->getID()."&version=".$version->_version."\r\n";
$subject=mydmsDecodeString($subject);
$message=mydmsDecodeString($message);
$notifier->toList($user, $document->_notifyList["users"], $subject, $message);
foreach ($document->_notifyList["groups"] as $grp) {
$notifier->toGroup($user, $grp, $subject, $message);
}
}
}
}
else {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured"));

View File

@ -52,7 +52,6 @@ if ($document->getAccessMode($user) < M_READWRITE) {
*/
$notifier = new LetoDMS_Email();
$notifier->setSender($user);
$document->setNotifier($notifier);
$name = sanitizeString($_POST["name"]);
$comment = sanitizeString($_POST["comment"]);
@ -62,18 +61,88 @@ if (!is_numeric($sequence)) {
$sequence="keep";
}
if (
(($document->getName() == $name) || $document->setName($name))
&& (($document->getComment() == $comment) || $document->setComment($comment))
&& (($document->getKeywords() == $keywords) || $document->setKeywords($keywords))
&& (($sequence == "keep") || $document->setSequence($sequence))
)
{
if (($oldname = $document->getName()) == $name) {
if($document->setName($name)) {
// Send notification to subscribers.
$document->getNotifyList();
if($notifier) {
$folder = $document->getFolder();
$subject = "###SITENAME###: ".$document->_name." - ".getMLText("document_renamed_email");
$message = getMLText("document_renamed_email")."\r\n";
$message .=
getMLText("old").": ".$oldname."\r\n".
getMLText("new").": ".$name."\r\n".
getMLText("folder").": ".$folder->getFolderPathPlain()."\r\n".
getMLText("comment").": ".$document->getComment()."\r\n".
"URL: ###URL_PREFIX###out/out.ViewDocument.php?documentid=".$document->getID()."\r\n";
$subject=mydmsDecodeString($subject);
$message=mydmsDecodeString($message);
$notifier->toList($user, $document->_notifyList["users"], $subject, $message);
foreach ($document->_notifyList["groups"] as $grp) {
$notifier->toGroup($user, $grp, $subject, $message);
}
// if user is not owner send notification to owner
if ($user->getID()!= $document->_ownerID)
$notifier->toIndividual($user, $document->getOwner(), $subject, $message);
}
}
}
else {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured"));
}
if (($oldcomment = $document->getComment()) != $comment) {
if($document->setComment($comment)) {
// Send notification to subscribers.
$document->getNotifyList();
if($notifier) {
$folder = $document->getFolder();
$subject = "###SITENAME###: ".$document->getName()." - ".getMLText("comment_changed_email");
$message = getMLText("comment_changed_email")."\r\n";
$message .=
getMLText("document").": ".$document->getName()."\r\n".
getMLText("folder").": ".$folder->getFolderPathPlain()."\r\n".
getMLText("comment").": ".$comment."\r\n".
"URL: ###URL_PREFIX###out/out.ViewDocument.php?documentid=".$document->getID()."\r\n";
$subject=mydmsDecodeString($subject);
$message=mydmsDecodeString($message);
$notifier->toList($user, $document->_notifyList["users"], $subject, $message);
foreach ($document->_notifyList["groups"] as $grp) {
$notifier->toGroup($user, $grp, $subject, $message);
}
// if user is not owner send notification to owner
if ($user->getID() != $document->getOwner())
$notifier->toIndividual($user, $document->getOwner(), $subject, $message);
}
}
else {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured"));
}
}
if (($oldkeywords = $document->getKeywords()) != $keywords) {
if($document->setKeywords($keywords)) {
}
else {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured"));
}
}
if($sequence != "keep") {
if($document->setSequence($sequence)) {
}
else {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured"));
}
}
add_log_line("?documentid=".$documentid);
header("Location:../out/out.ViewDocument.php?documentid=".$documentid);

View File

@ -58,7 +58,33 @@ if (($document->getAccessMode($user) < M_READWRITE) || ($targetFolder->getAccess
}
if ($targetid != $oldFolder->getID()) {
if (!$document->setFolder($targetFolder)) {
if ($document->setFolder($targetFolder)) {
$document->getNotifyList();
// Send notification to subscribers.
if($notifier) {
$folder = $document->getFolder();
$subject = "###SITENAME###: ".$document->_name." - ".getMLText("document_moved_email");
$message = getMLText("document_moved_email")."\r\n";
$message .=
getMLText("document").": ".$document->_name."\r\n".
getMLText("folder").": ".$folder->getFolderPathPlain()."\r\n".
getMLText("new_folder").": ".$targetFolder->getFolderPathPlain()."\r\n".
"URL: ###URL_PREFIX###out/out.ViewDocument.php?documentid=".$document->getID()."\r\n";
$subject=mydmsDecodeString($subject);
$message=mydmsDecodeString($message);
$notifier->toList($user, $document->_notifyList["users"], $subject, $message);
foreach ($document->_notifyList["groups"] as $grp) {
$notifier->toGroup($user, $grp, $subject, $message);
}
// if user is not owner send notification to owner
if ($user->getID()!= $document->getOwner())
$notifier->toIndividual($user, $document->getOwner(), $subject, $message);
}
} else {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured"));
}
}

View File

@ -75,6 +75,32 @@ if ($overrideStatus != $overallStatus["status"]) {
if (!$content->setStatus($overrideStatus, $comment, $user)) {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured"));
} else {
$nl=$document->getNotifyList();
// Send notification to subscribers.
if($notifier) {
$folder = $document->getFolder();
$subject = "###SITENAME###: ".$document->_name." - ".getMLText("document_status_changed_email");
$message = getMLText("document_status_changed_email")."\r\n";
$message .=
getMLText("document").": ".$document->_name."\r\n".
getMLText("status").": ".getOverallStatusText($status)."\r\n".
getMLText("folder").": ".$folder->getFolderPathPlain()."\r\n".
getMLText("comment").": ".$document->getComment()."\r\n".
"URL: ###URL_PREFIX###out/out.ViewDocument.php?documentid=".$document->getID()."&version=".$content->_version."\r\n";
$uu = (is_null($updateUser) ? $document->_dms->getUser($settings->_adminID) : $updateUser);
$subject=mydmsDecodeString($subject);
$message=mydmsDecodeString($message);
$notifier->toList($uu, $nl["users"], $subject, $message);
foreach ($nl["groups"] as $grp) {
$notifier->toGroup($uu, $grp, $subject, $message);
}
}
// TODO: if user os not owner send notification to owner
}
}
add_log_line("?documentid=".$documentid);

View File

@ -47,6 +47,34 @@ $folder = $document->getFolder();
if (!$document->remove()) {
UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("error_occured"));
} else {
$document->getNotifyList();
if ($notifier){
$path = "";
$folderPath = $folder->getPath();
for ($i = 0; $i < count($folderPath); $i++) {
$path .= $folderPath[$i]->getName();
if ($i +1 < count($folderPath))
$path .= " / ";
}
$subject = "###SITENAME###: ".$document->getName()." - ".getMLText("document_deleted_email");
$message = getMLText("document_deleted_email")."\r\n";
$message .=
getMLText("document").": ".$document->getName()."\r\n".
getMLText("folder").": ".$path."\r\n".
getMLText("comment").": ".$document->getComment()."\r\n".
getMLText("user").": ".$user->getFullName()." <". $user->getEmail() ."> ";
$subject=mydmsDecodeString($subject);
$message=mydmsDecodeString($message);
// Send notification to subscribers.
$notifier->toList($user, $document->_notifyList["users"], $subject, $message);
foreach ($document->_notifyList["groups"] as $grp) {
$notifier->toGroup($user, $grp, $subject, $message);
}
}
}
add_log_line("?documentid=".$documentid);

View File

@ -57,6 +57,26 @@ if (($document->getAccessMode($user) < M_ALL)&&($user->getID()!=$file->getUserID
if (!$document->removeDocumentFile($fileid)) {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured"));
} else {
// Send notification to subscribers.
$document->getNotifyList();
if($notifier) {
$subject = "###SITENAME###: ".$document->_name." - ".getMLText("removed_file_email");
$message = getMLText("removed_file_email")."\r\n";
$message .=
getMLText("name").": ".$name."\r\n".
getMLText("comment").": ".$comment."\r\n".
getMLText("user").": ".$user->getFullName()." <". $user->getEmail() .">\r\n".
"URL: ###URL_PREFIX###out/out.ViewDocument.php?documentid=".$document->getID()."\r\n";
$subject=mydmsDecodeString($subject);
$message=mydmsDecodeString($message);
$notifier->toList($user, $document->_notifyList["users"], $subject, $message);
foreach ($document->_notifyList["groups"] as $grp) {
$notifier->toGroup($user, $grp, $subject, $message);
}
}
}
add_log_line("?documentid=".$documentid."&fileid=".$fileid);

View File

@ -57,11 +57,87 @@ if (!is_object($version)) {
if (count($document->getContent())==1) {
if (!$document->remove()) {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured"));
} else {
$document->getNotifyList();
if ($notifier){
$path = "";
$folder = $document->getFolder();
$folderPath = $folder->getPath();
for ($i = 0; $i < count($folderPath); $i++) {
$path .= $folderPath[$i]->getName();
if ($i +1 < count($folderPath))
$path .= " / ";
}
$subject = "###SITENAME###: ".$document->getName()." - ".getMLText("document_deleted_email");
$message = getMLText("document_deleted_email")."\r\n";
$message .=
getMLText("document").": ".$document->getName()."\r\n".
getMLText("folder").": ".$path."\r\n".
getMLText("comment").": ".$document->getComment()."\r\n".
getMLText("user").": ".$user->getFullName()." <". $user->getEmail() ."> ";
$subject=mydmsDecodeString($subject);
$message=mydmsDecodeString($message);
// Send notification to subscribers.
$notifier->toList($user, $document->_notifyList["users"], $subject, $message);
foreach ($document->_notifyList["groups"] as $grp) {
$notifier->toGroup($user, $grp, $subject, $message);
}
}
}
}
else {
if (!$version->remove()) {
/* Before deleting the content get a list of all users that should
* be informed about the removal.
*/
$emailList = array();
$emailList[] = $version->_userID;
$status = $version->getReviewStatus();
foreach ($status as $st) {
if ($st["status"]==0 && !in_array($st["required"], $emailList)) {
$emailList[] = $st["required"];
}
}
$status = $version->getApprovalStatus();
foreach ($status as $st) {
if ($st["status"]==0 && !in_array($st["required"], $emailList)) {
$emailList[] = $st["required"];
}
}
if (!$document->removeContent($version)) {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured"));
} else {
// Notify affected users.
if ($notifier){
$recipients = array();
foreach ($emailList as $eID) {
$eU = $version->_document->_dms->getUser($eID);
$recipients[] = $eU;
}
$subject = "###SITENAME###: ".$document->getName().", v.".$version->_version." - ".getMLText("version_deleted_email");
$message = getMLText("version_deleted_email")."\r\n";
$message .=
getMLText("document").": ".$document->getName()."\r\n".
getMLText("version").": ".$version->_version."\r\n".
getMLText("comment").": ".$version->getComment()."\r\n".
getMLText("user").": ".$user->getFullName()." <". $user->getEmail() ."> ";
$subject=mydmsDecodeString($subject);
$message=mydmsDecodeString($message);
$notifier->toList($user, $recipients, $subject, $message);
// Send notification to subscribers.
$nl=$document->getNotifyList();
LetoDMS_Email::toList($user, $nl["users"], $subject, $message);
foreach ($nl["groups"] as $grp) {
LetoDMS_Email::toGroup($user, $grp, $subject, $message);
}
}
}
}

View File

@ -183,7 +183,33 @@ else if ($_POST["reviewType"] == "grp") {
if ($_POST["reviewStatus"]==-1){
$content->setStatus(S_REJECTED,$comment,$user);
if($content->setStatus(S_REJECTED,$comment,$user)) {
$nl=$document->getNotifyList();
// Send notification to subscribers.
if($notifier) {
$folder = $document->getFolder();
$subject = "###SITENAME###: ".$document->_name." - ".getMLText("document_status_changed_email");
$message = getMLText("document_status_changed_email")."\r\n";
$message .=
getMLText("document").": ".$document->_name."\r\n".
getMLText("status").": ".getOverallStatusText($status)."\r\n".
getMLText("folder").": ".$folder->getFolderPathPlain()."\r\n".
getMLText("comment").": ".$document->getComment()."\r\n".
"URL: ###URL_PREFIX###out/out.ViewDocument.php?documentid=".$document->getID()."&version=".$content->_version."\r\n";
$uu = (is_null($updateUser) ? $document->_dms->getUser($settings->_adminID) : $updateUser);
$subject=mydmsDecodeString($subject);
$message=mydmsDecodeString($message);
$notifier->toList($uu, $nl["users"], $subject, $message);
foreach ($nl["groups"] as $grp) {
$notifier->toGroup($uu, $grp, $subject, $message);
}
}
// TODO: if user os not owner send notification to owner
}
}else{
@ -228,6 +254,31 @@ if ($_POST["reviewStatus"]==-1){
$newStatus=2;
}
if ($content->setStatus($newStatus, getMLText("automatic_status_update"), $user)) {
// Send notification to subscribers.
$nl=$document->getNotifyList();
if($notifier) {
$folder = $document->getFolder();
$subject = "###SITENAME###: ".$document->_name." - ".getMLText("document_status_changed_email");
$message = getMLText("document_status_changed_email")."\r\n";
$message .=
getMLText("document").": ".$document->_name."\r\n".
getMLText("status").": ".getOverallStatusText($status)."\r\n".
getMLText("folder").": ".$folder->getFolderPathPlain()."\r\n".
getMLText("comment").": ".$document->getComment()."\r\n".
"URL: ###URL_PREFIX###out/out.ViewDocument.php?documentid=".$document->getID()."&version=".$content->_version."\r\n";
$uu = (is_null($updateUser) ? $document->_dms->getUser($settings->_adminID) : $updateUser);
$subject=mydmsDecodeString($subject);
$message=mydmsDecodeString($message);
$notifier->toList($uu, $nl["users"], $subject, $message);
foreach ($nl["groups"] as $grp) {
$notifier->toGroup($uu, $grp, $subject, $message);
}
}
// TODO: if user os not owner send notification to owner
// Notify approvers, if necessary.
if ($newStatus == S_DRAFT_APP) {

View File

@ -119,6 +119,22 @@ foreach ($pIndRev as $p) {
switch ($res) {
case 0:
// Send an email notification to the new reviewer.
if ($notifier) {
$subject = "###SITENAME###: ".$document->getName().", v.".$this->_version." - ".getMLText("review_request_email");
$message = getMLText("review_request_email")."\r\n";
$message .=
getMLText("document").": ".$document->getName()."\r\n".
getMLText("version").": ".$this->_version."\r\n".
getMLText("comment").": ".$this->getComment()."\r\n".
getMLText("user").": ".$user->getFullName()." <". $user->getEmail() .">\r\n".
"URL: ###URL_PREFIX###out/out.ViewDocument.php?documentid=".$document->getID()."&version=".$this->_version."\r\n";
$subject=mydmsDecodeString($subject);
$message=mydmsDecodeString($message);
$notifier->toIndividual($user, $docAccess["users"][$accessIndex["i"][$p]], $subject, $message);
}
break;
case -1:
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("internal_error"));
@ -161,6 +177,22 @@ if (count($reviewIndex["i"]) > 0) {
$uml = $docAccess["users"][$accessIndex["i"][$rx]]->getEmail();
switch ($res) {
case 0:
// Send an email notification to the reviewer.
if ($notifier) {
$subject = "###SITENAME###: ".$document->getName().", v.".$content->_version." - ".getMLText("review_deletion_email");
$message = getMLText("review_deletion_email")."\r\n";
$message .=
getMLText("document").": ".$document->getName()."\r\n".
getMLText("version").": ".$content->_version."\r\n".
getMLText("comment").": ".$content->getComment()."\r\n".
getMLText("user").": ".$user->getFullName()." <". $user->getEmail() .">\r\n".
"URL: ###URL_PREFIX###out/out.ViewDocument.php?documentid=".$document->getID()."\r\n";
$subject=mydmsDecodeString($subject);
$message=mydmsDecodeString($message);
$notifier->toIndividual($user, $docAccess["users"][$accessIndex["i"][$rx]], $subject, $message);
}
break;
case -1:
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("internal_error"));
@ -190,6 +222,22 @@ foreach ($pGrpRev as $p) {
$gnm = $docAccess["groups"][$accessIndex["g"][$p]]->getName();
switch ($res) {
case 0:
// Send an email notification to the new reviewer.
if ($notifier) {
$subject = "###SITENAME###: ".$document->getName().", v.".$content->_version." - ".getMLText("review_request_email");
$message = getMLText("review_request_email")."\r\n";
$message .=
getMLText("document").": ".$document->getName()."\r\n".
getMLText("version").": ".$content->_version."\r\n".
getMLText("comment").": ".$content->getComment()."\r\n".
getMLText("user").": ".$user->getFullName()." <". $user->getEmail() .">\r\n".
"URL: ###URL_PREFIX###out/out.ViewDocument.php?documentid=".$document->getID()."&version=".$content->_version."\r\n";
$subject=mydmsDecodeString($subject);
$message=mydmsDecodeString($message);
$notifier->toGroup($user, $docAccess["groups"][$accessIndex["g"][$p]], $subject, $message);
}
break;
case -1:
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("internal_error"));
@ -229,6 +277,23 @@ if (count($reviewIndex["g"]) > 0) {
$gnm = $docAccess["groups"][$accessIndex["g"][$rx]]->getName();
switch ($res) {
case 0:
// Send an email notification to the review group.
if ($notifier) {
$subject = "###SITENAME###: ".$document->getName().", v.".$content->_version." - ".getMLText("review_deletion_email");
$message = getMLText("review_deletion_email")."\r\n";
$message .=
getMLText("document").": ".$document->getName()."\r\n".
getMLText("version").": ".$content->_version."\r\n".
getMLText("comment").": ".$content->getComment()."\r\n".
getMLText("user").": ".$user->getFullName()." <". $user->getEmail() .">\r\n".
"URL: ###URL_PREFIX###out/out.ViewDocument.php?documentid=".$document->getID()."\r\n";
$subject=mydmsDecodeString($subject);
$message=mydmsDecodeString($message);
$notifier->toGroup($user, $docAccess["groups"][$accessIndex["g"][$rx]], $subject, $message);
}
break;
case -1:
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("internal_error"));
@ -263,6 +328,22 @@ foreach ($pIndApp as $p) {
$uml = $docAccess["users"][$accessIndex["i"][$p]]->getEmail();
switch ($res) {
case 0:
// Send an email notification to the new approver.
if ($overallStatus["status"]!=0 && $notifier) {
$subject = "###SITENAME###: ".$document->getName().", v.".$content->_version." - ".getMLText("approval_request_email");
$message = getMLText("approval_request_email")."\r\n";
$message .=
getMLText("document").": ".$document->getName()."\r\n".
getMLText("version").": ".$content->_version."\r\n".
getMLText("comment").": ".$content->getComment()."\r\n".
getMLText("user").": ".$user->getFullName()." <". $user->getEmail() .">\r\n".
"URL: ###URL_PREFIX###out/out.ViewDocument.php?documentid=".$document->getID()."&version=".$content->_version."\r\n";
$subject=mydmsDecodeString($subject);
$message=mydmsDecodeString($message);
$notifier->toIndividual($user, $docAccess["users"][$accessIndex["i"][$p]], $subject, $message);
}
break;
case -1:
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("internal_error"));
@ -302,6 +383,22 @@ if (count($approvalIndex["i"]) > 0) {
$uml = $docAccess["users"][$accessIndex["i"][$rx]]->getEmail();
switch ($res) {
case 0:
// Send an email notification to the approver.
if ($notifier) {
$subject = "###SITENAME###: ".$document->getName().", v.".$content->_version." - ".getMLText("approval_deletion_email");
$message = getMLText("approval_deletion_email")."\r\n";
$message .=
getMLText("document").": ".$document->getName()."\r\n".
getMLText("version").": ".$content->_version."\r\n".
getMLText("comment").": ".$content->getComment()."\r\n".
getMLText("user").": ".$user->getFullName()." <". $user->getEmail() .">\r\n".
"URL: ###URL_PREFIX###out/out.ViewDocument.php?documentid=".$document->getID()."\r\n";
$subject=mydmsDecodeString($subject);
$message=mydmsDecodeString($message);
$notifier->toIndividual($user, $docAccess["users"][$accessIndex["i"][$rx]], $subject, $message);
}
break;
case -1:
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("internal_error"));
@ -331,6 +428,22 @@ foreach ($pGrpApp as $p) {
$gnm = $docAccess["groups"][$accessIndex["g"][$p]]->getName();
switch ($res) {
case 0:
// Send an email notification to the new approver.
if ($overallStatus["status"]!=0 && $notifier) {
$subject = "###SITENAME###: ".$document->getName().", v.".$content->_version." - ".getMLText("approval_request_email");
$message = getMLText("approval_request_email")."\r\n";
$message .=
getMLText("document").": ".$document->getName()."\r\n".
getMLText("version").": ".$content->_version."\r\n".
getMLText("comment").": ".$content->getComment()."\r\n".
getMLText("user").": ".$user->getFullName()." <". $user->getEmail() .">\r\n".
"URL: ###URL_PREFIX###out/out.ViewDocument.php?documentid=".$document->getID()."&version=".$content->_version."\r\n";
$subject=mydmsDecodeString($subject);
$message=mydmsDecodeString($message);
$notifier->toGroup($user, $docAccess["groups"][$accessIndex["g"][$p]], $subject, $message);
}
break;
case -1:
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("internal_error"));
@ -370,6 +483,23 @@ if (count($approvalIndex["g"]) > 0) {
$gnm = $docAccess["groups"][$accessIndex["g"][$rx]]->getName();
switch ($res) {
case 0:
// Send an email notification to the approval group.
if ($notifier) {
$subject = "###SITENAME###: ".$document->getName().", v.".$content->_version." - ".getMLText("approval_deletion_email");
$message = getMLText("approval_deletion_email")."\r\n";
$message .=
getMLText("document").": ".$document->getName()."\r\n".
getMLText("version").": ".$content->_version."\r\n".
getMLText("comment").": ".$content->getComment()."\r\n".
getMLText("user").": ".$user->getFullName()." <". $user->getEmail() .">\r\n".
"URL: ###URL_PREFIX###out/out.ViewDocument.php?documentid=".$document->getID()."\r\n";
$subject=mydmsDecodeString($subject);
$message=mydmsDecodeString($message);
$notifier->toGroup($user, $docAccess["groups"][$accessIndex["g"][$rx]], $subject, $message);
}
break;
case -1:
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("internal_error"));

View File

@ -142,13 +142,58 @@ if (is_uploaded_file($_FILES["userfile"]["tmp_name"]) && $_FILES["userfile"]["si
$contentResult=$document->addContent($comment, $user, $userfiletmp, basename($userfilename), $fileType, $userfiletype, $reviewers, $approvers);
if (is_bool($contentResult) && !$contentResult) {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured"));
}
else {
// Send notification to subscribers.
$document->getNotifyList();
if ($notifier){
$folder = $document->getFolder();
$subject = "###SITENAME###: ".$document->_name." - ".getMLText("document_updated_email");
$message = getMLText("document_updated_email")."\r\n";
$message .=
getMLText("document").": ".$document->_name."\r\n".
getMLText("folder").": ".$folder->getFolderPathPlain()."\r\n".
getMLText("comment").": ".$document->getComment()."\r\n".
"URL: ###URL_PREFIX###out/out.ViewDocument.php?documentid=".$document->_id."\r\n";
$subject=mydmsDecodeString($subject);
$message=mydmsDecodeString($message);
$notifier->toList($user, $document->_notifyList["users"], $subject, $message);
foreach ($document->_notifyList["groups"] as $grp) {
$notifier->toGroup($user, $grp, $subject, $message);
}
// if user is not owner send notification to owner
if ($user->getID()!= $document->_ownerID)
$notifier->toIndividual($user, $document->getOwner(), $subject, $message);
}
$expires = ($_POST["expires"] == "true") ? mktime(0,0,0, $_POST["expmonth"], $_POST["expday"], $_POST["expyear"]) : false;
if (!$document->setExpires($expires)) {
if ($document->setExpires($expires)) {
$document->getNotifyList();
if($notifier) {
$folder = $document->getFolder();
// Send notification to subscribers.
$subject = "###SITENAME###: ".$document->_name." - ".getMLText("expiry_changed_email");
$message = getMLText("expiry_changed_email")."\r\n";
$message .=
getMLText("document").": ".$document->_name."\r\n".
getMLText("folder").": ".$folder->getFolderPathPlain()."\r\n".
getMLText("comment").": ".$document->getComment()."\r\n".
"URL: ###URL_PREFIX###out/out.ViewDocument.php?documentid=".$document->_id."\r\n";
$subject=mydmsDecodeString($subject);
$message=mydmsDecodeString($message);
$notifier->toList($user, $document->_notifyList["users"], $subject, $message);
foreach ($document->_notifyList["groups"] as $grp) {
$notifier->toGroup($user, $grp, $subject, $message);
}
}
} else {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("error_occured"));
}
}