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