Commit aaf5ddbf821d1355beb58e61301172f96d50406d

Authored by Megan Watson
1 parent df0ee020

KTS-2182

"A user, which subscribe to a folder doesn't need to be notify for his own action on the folder"
Fixed. Added a check for the current user when getting the list of subscribers.

Committed by: Megan Watson
Reviewed by: Jonathan Byrne



git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@8014 c91229c3-7414-0410-bfa2-8a42b809f60b
lib/subscriptions/subscriptions.inc.php
@@ -5,32 +5,32 @@ @@ -5,32 +5,32 @@
5 * KnowledgeTree Open Source Edition 5 * KnowledgeTree Open Source Edition
6 * Document Management Made Simple 6 * Document Management Made Simple
7 * Copyright (C) 2004 - 2008 The Jam Warehouse Software (Pty) Limited 7 * Copyright (C) 2004 - 2008 The Jam Warehouse Software (Pty) Limited
8 - * 8 + *
9 * This program is free software; you can redistribute it and/or modify it under 9 * This program is free software; you can redistribute it and/or modify it under
10 * the terms of the GNU General Public License version 3 as published by the 10 * the terms of the GNU General Public License version 3 as published by the
11 * Free Software Foundation. 11 * Free Software Foundation.
12 - * 12 + *
13 * This program is distributed in the hope that it will be useful, but WITHOUT 13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 15 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
16 * details. 16 * details.
17 - * 17 + *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 - * 20 + *
21 * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, 21 * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place,
22 * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. 22 * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com.
23 - * 23 + *
24 * The interactive user interfaces in modified source and object code versions 24 * The interactive user interfaces in modified source and object code versions
25 * of this program must display Appropriate Legal Notices, as required under 25 * of this program must display Appropriate Legal Notices, as required under
26 * Section 5 of the GNU General Public License version 3. 26 * Section 5 of the GNU General Public License version 3.
27 - * 27 + *
28 * In accordance with Section 7(b) of the GNU General Public License version 3, 28 * In accordance with Section 7(b) of the GNU General Public License version 3,
29 * these Appropriate Legal Notices must retain the display of the "Powered by 29 * these Appropriate Legal Notices must retain the display of the "Powered by
30 - * KnowledgeTree" logo and retain the original copyright notice. If the display of the 30 + * KnowledgeTree" logo and retain the original copyright notice. If the display of the
31 * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices 31 * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
32 - * must display the words "Powered by KnowledgeTree" and retain the original  
33 - * copyright notice. 32 + * must display the words "Powered by KnowledgeTree" and retain the original
  33 + * copyright notice.
34 * Contributor( s): ______________________________________ 34 * Contributor( s): ______________________________________
35 * 35 *
36 * 36 *
@@ -101,7 +101,7 @@ class SubscriptionEvent { @@ -101,7 +101,7 @@ class SubscriptionEvent {
101 // only useful for folder subscriptions. 101 // only useful for folder subscriptions.
102 $aUsers = $this->_getSubscribers($oParentFolder->getId(), $this->subscriptionTypes["Folder"]); 102 $aUsers = $this->_getSubscribers($oParentFolder->getId(), $this->subscriptionTypes["Folder"]);
103 foreach ($aUsers as $oSubscriber) { 103 foreach ($aUsers as $oSubscriber) {
104 - 104 +
105 // notification object first. 105 // notification object first.
106 $aNotificationOptions = array(); 106 $aNotificationOptions = array();
107 $aNotificationOptions['target_user'] = $oSubscriber->getID(); 107 $aNotificationOptions['target_user'] = $oSubscriber->getID();
@@ -111,7 +111,7 @@ class SubscriptionEvent { @@ -111,7 +111,7 @@ class SubscriptionEvent {
111 $aNotificationOptions['object_id'] = $oAddedFolder->getId(); // parent folder_id, in this case. 111 $aNotificationOptions['object_id'] = $oAddedFolder->getId(); // parent folder_id, in this case.
112 $aNotificationOptions['event_type'] = "AddFolder"; 112 $aNotificationOptions['event_type'] = "AddFolder";
113 $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); 113 $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions);
114 - 114 +
115 // now the email content. 115 // now the email content.
116 // FIXME this needs to be handled entirely within notifications from now on. 116 // FIXME this needs to be handled entirely within notifications from now on.
117 if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { 117 if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) {
@@ -127,7 +127,7 @@ class SubscriptionEvent { @@ -127,7 +127,7 @@ class SubscriptionEvent {
127 // two parts to this: 127 // two parts to this:
128 $aUsers = $this->_getSubscribers($oParentFolder->getId(), $this->subscriptionTypes["Folder"]); 128 $aUsers = $this->_getSubscribers($oParentFolder->getId(), $this->subscriptionTypes["Folder"]);
129 foreach ($aUsers as $oSubscriber) { 129 foreach ($aUsers as $oSubscriber) {
130 - 130 +
131 // notification object first. 131 // notification object first.
132 $aNotificationOptions = array(); 132 $aNotificationOptions = array();
133 $aNotificationOptions['target_user'] = $oSubscriber->getID(); 133 $aNotificationOptions['target_user'] = $oSubscriber->getID();
@@ -136,9 +136,9 @@ class SubscriptionEvent { @@ -136,9 +136,9 @@ class SubscriptionEvent {
136 $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId()); 136 $aNotificationOptions['location_name'] = Folder::generateFullFolderPath($oParentFolder->getId());
137 $aNotificationOptions['object_id'] = $oAddedDocument->getId(); // parent folder_id, in this case. 137 $aNotificationOptions['object_id'] = $oAddedDocument->getId(); // parent folder_id, in this case.
138 $aNotificationOptions['event_type'] = "AddDocument"; 138 $aNotificationOptions['event_type'] = "AddDocument";
139 - 139 +
140 $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); 140 $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions);
141 - 141 +
142 // now the email content. 142 // now the email content.
143 // FIXME this needs to be handled entirely within notifications from now on. 143 // FIXME this needs to be handled entirely within notifications from now on.
144 if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { 144 if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) {
@@ -400,7 +400,7 @@ class SubscriptionEvent { @@ -400,7 +400,7 @@ class SubscriptionEvent {
400 400
401 401
402 $aUsers = $this->_getSubscribers($oParentFolder->getId(), $this->subscriptionTypes["Folder"]); 402 $aUsers = $this->_getSubscribers($oParentFolder->getId(), $this->subscriptionTypes["Folder"]);
403 - 403 +
404 foreach ($aUsers as $oSubscriber) { 404 foreach ($aUsers as $oSubscriber) {
405 405
406 // notification object first. 406 // notification object first.
@@ -428,9 +428,9 @@ class SubscriptionEvent { @@ -428,9 +428,9 @@ class SubscriptionEvent {
428 $content = new SubscriptionContent(); // needed for i18n 428 $content = new SubscriptionContent(); // needed for i18n
429 // OK: two actions: document registrants, folder registrants. 429 // OK: two actions: document registrants, folder registrants.
430 $aUsers = $this->_getSubscribers($oModifiedDocument->getId(), $this->subscriptionTypes["Document"]); 430 $aUsers = $this->_getSubscribers($oModifiedDocument->getId(), $this->subscriptionTypes["Document"]);
431 - 431 +
432 foreach ($aUsers as $oSubscriber) { 432 foreach ($aUsers as $oSubscriber) {
433 - 433 +
434 // notification object first. 434 // notification object first.
435 $aNotificationOptions = array(); 435 $aNotificationOptions = array();
436 $aNotificationOptions['target_user'] = $oSubscriber->getID(); 436 $aNotificationOptions['target_user'] = $oSubscriber->getID();
@@ -440,7 +440,7 @@ class SubscriptionEvent { @@ -440,7 +440,7 @@ class SubscriptionEvent {
440 $aNotificationOptions['object_id'] = $oModifiedDocument->getId(); // parent folder_id, in this case. 440 $aNotificationOptions['object_id'] = $oModifiedDocument->getId(); // parent folder_id, in this case.
441 $aNotificationOptions['event_type'] = "CheckOutDocument"; 441 $aNotificationOptions['event_type'] = "CheckOutDocument";
442 $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); 442 $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions);
443 - 443 +
444 // now the email content. 444 // now the email content.
445 // FIXME this needs to be handled entirely within notifications from now on. 445 // FIXME this needs to be handled entirely within notifications from now on.
446 if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { 446 if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) {
@@ -454,7 +454,7 @@ class SubscriptionEvent { @@ -454,7 +454,7 @@ class SubscriptionEvent {
454 454
455 $aUsers = $this->_getSubscribers($oParentFolder->getId(), $this->subscriptionTypes["Folder"]); 455 $aUsers = $this->_getSubscribers($oParentFolder->getId(), $this->subscriptionTypes["Folder"]);
456 foreach ($aUsers as $oSubscriber) { 456 foreach ($aUsers as $oSubscriber) {
457 - 457 +
458 // notification object first. 458 // notification object first.
459 $aNotificationOptions = array(); 459 $aNotificationOptions = array();
460 $aNotificationOptions['target_user'] = $oSubscriber->getID(); 460 $aNotificationOptions['target_user'] = $oSubscriber->getID();
@@ -464,7 +464,7 @@ class SubscriptionEvent { @@ -464,7 +464,7 @@ class SubscriptionEvent {
464 $aNotificationOptions['object_id'] = $oModifiedDocument->getId(); // parent folder_id, in this case. 464 $aNotificationOptions['object_id'] = $oModifiedDocument->getId(); // parent folder_id, in this case.
465 $aNotificationOptions['event_type'] = "CheckOutDocument"; 465 $aNotificationOptions['event_type'] = "CheckOutDocument";
466 $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); 466 $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions);
467 - 467 +
468 // now the email content. 468 // now the email content.
469 // FIXME this needs to be handled entirely within notifications from now on. 469 // FIXME this needs to be handled entirely within notifications from now on.
470 if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { 470 if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) {
@@ -491,7 +491,7 @@ class SubscriptionEvent { @@ -491,7 +491,7 @@ class SubscriptionEvent {
491 $aNotificationOptions['object_id'] = $oToFolder->getId(); // parent folder_id, in this case. 491 $aNotificationOptions['object_id'] = $oToFolder->getId(); // parent folder_id, in this case.
492 $aNotificationOptions['event_type'] = $moveOrCopy; 492 $aNotificationOptions['event_type'] = $moveOrCopy;
493 $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); 493 $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions);
494 - 494 +
495 // now the email content. 495 // now the email content.
496 // FIXME this needs to be handled entirely within notifications from now on. 496 // FIXME this needs to be handled entirely within notifications from now on.
497 if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { 497 if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) {
@@ -504,9 +504,9 @@ class SubscriptionEvent { @@ -504,9 +504,9 @@ class SubscriptionEvent {
504 504
505 505
506 $aUsers = $this->_getSubscribers($oFromFolder->getId(), $this->subscriptionTypes["Folder"]); 506 $aUsers = $this->_getSubscribers($oFromFolder->getId(), $this->subscriptionTypes["Folder"]);
507 - 507 +
508 foreach ($aUsers as $oSubscriber) { 508 foreach ($aUsers as $oSubscriber) {
509 - 509 +
510 // notification object first. 510 // notification object first.
511 $aNotificationOptions = array(); 511 $aNotificationOptions = array();
512 $aNotificationOptions['target_user'] = $oSubscriber->getID(); 512 $aNotificationOptions['target_user'] = $oSubscriber->getID();
@@ -516,7 +516,7 @@ class SubscriptionEvent { @@ -516,7 +516,7 @@ class SubscriptionEvent {
516 $aNotificationOptions['object_id'] = $oToFolder->getId(); // parent folder_id, in this case. 516 $aNotificationOptions['object_id'] = $oToFolder->getId(); // parent folder_id, in this case.
517 $aNotificationOptions['event_type'] = $moveOrCopy; 517 $aNotificationOptions['event_type'] = $moveOrCopy;
518 $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); 518 $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions);
519 - 519 +
520 // now the email content. 520 // now the email content.
521 // FIXME this needs to be handled entirely within notifications from now on. 521 // FIXME this needs to be handled entirely within notifications from now on.
522 if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { 522 if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) {
@@ -529,7 +529,7 @@ class SubscriptionEvent { @@ -529,7 +529,7 @@ class SubscriptionEvent {
529 529
530 $aUsers = $this->_getSubscribers($oToFolder->getId(), $this->subscriptionTypes["Folder"]); 530 $aUsers = $this->_getSubscribers($oToFolder->getId(), $this->subscriptionTypes["Folder"]);
531 foreach ($aUsers as $oSubscriber) { 531 foreach ($aUsers as $oSubscriber) {
532 - 532 +
533 // notification object first. 533 // notification object first.
534 $aNotificationOptions = array(); 534 $aNotificationOptions = array();
535 $aNotificationOptions['target_user'] = $oSubscriber->getID(); 535 $aNotificationOptions['target_user'] = $oSubscriber->getID();
@@ -539,7 +539,7 @@ class SubscriptionEvent { @@ -539,7 +539,7 @@ class SubscriptionEvent {
539 $aNotificationOptions['object_id'] = $oToFolder->getId(); // parent folder_id, in this case. 539 $aNotificationOptions['object_id'] = $oToFolder->getId(); // parent folder_id, in this case.
540 $aNotificationOptions['event_type'] = $moveOrCopy; 540 $aNotificationOptions['event_type'] = $moveOrCopy;
541 $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); 541 $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions);
542 - 542 +
543 // now the email content. 543 // now the email content.
544 // FIXME this needs to be handled entirely within notifications from now on. 544 // FIXME this needs to be handled entirely within notifications from now on.
545 if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { 545 if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) {
@@ -703,7 +703,7 @@ class SubscriptionEvent { @@ -703,7 +703,7 @@ class SubscriptionEvent {
703 } 703 }
704 } 704 }
705 } 705 }
706 - 706 +
707 // small helper function to assist in identifying the numeric id. 707 // small helper function to assist in identifying the numeric id.
708 function _getKeyForType($sEventType) { 708 function _getKeyForType($sEventType) {
709 foreach ($this->eventTypes as $key => $val) { 709 foreach ($this->eventTypes as $key => $val) {
@@ -737,9 +737,16 @@ class SubscriptionEvent { @@ -737,9 +737,16 @@ class SubscriptionEvent {
737 // Remove alerted users 737 // Remove alerted users
738 $aNewUsers = $this->_pruneAlertedUsers($aNewUsers); 738 $aNewUsers = $this->_pruneAlertedUsers($aNewUsers);
739 739
  740 +
  741 + $iCurrentUserId = $_SESSION['userID'];
740 // notionally less efficient than the old code. if its a big issue, can easily 742 // notionally less efficient than the old code. if its a big issue, can easily
741 // be refactored. 743 // be refactored.
742 foreach ($aNewUsers as $iUserId) { 744 foreach ($aNewUsers as $iUserId) {
  745 + // the user doesn't need to be notified for his/her own modifications
  746 + if($iUserId == $iCurrentUserId){
  747 + continue;
  748 + }
  749 +
743 $oUser = & User::get($iUserId); 750 $oUser = & User::get($iUserId);
744 751
745 // do a quick prune here, for performance/maintenance reasons. 752 // do a quick prune here, for performance/maintenance reasons.