Commit 82dd10735cf6c8558951e638269a6448da8a96b3
1 parent
e4e656f1
total revision of the subscription "engine"
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4392 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
10 changed files
with
824 additions
and
410 deletions
lib/dashboard/Notification.inc.php
| ... | ... | @@ -164,7 +164,7 @@ class KTSubscriptionNotification extends KTNotificationHandler { |
| 164 | 164 | "ArchivedDocument" => _('Document archived'), // can go through and request un-archival (?) |
| 165 | 165 | "RestoredArchivedDocument" => _('Document restored') |
| 166 | 166 | ); |
| 167 | - parent::KTNotificationHandler(); | |
| 167 | + //parent::KTNotificationHandler(); | |
| 168 | 168 | } |
| 169 | 169 | // helper method to extract / set the various pieces of information |
| 170 | 170 | function _getSubscriptionData($oKTNotification) { |
| ... | ... | @@ -219,13 +219,8 @@ class KTSubscriptionNotification extends KTNotificationHandler { |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | function handleNotification($oKTNotification) { |
| 222 | - $oTemplating = new KTTemplating; | |
| 223 | - $oTemplate = $oTemplating->loadTemplate("kt3/notifications/subscriptions"); | |
| 224 | - $aTemplateData = array( | |
| 225 | - "context" => $oKTNotification, | |
| 226 | - "info" => $this->_getSubscriptionData($oKTNotification), | |
| 227 | - ); | |
| 228 | - return $oTemplate->render($aTemplateData); | |
| 222 | + $oSubscriptionContent = new SubscriptionContent(); | |
| 223 | + return $oSubscriptionContent->getNotificationAlertContent($oKTNotification); | |
| 229 | 224 | } |
| 230 | 225 | |
| 231 | 226 | // helper to _create_ a notification, in a way that is slightly less opaque. | ... | ... |
lib/documentmanagement/documentutil.inc.php
| ... | ... | @@ -30,16 +30,15 @@ |
| 30 | 30 | // LEGACY PATHS |
| 31 | 31 | require_once(KT_LIB_DIR . '/documentmanagement/DocumentFieldLink.inc'); |
| 32 | 32 | require_once(KT_LIB_DIR . '/documentmanagement/DocumentTransaction.inc'); |
| 33 | -require_once(KT_LIB_DIR . '/subscriptions/SubscriptionEngine.inc'); | |
| 34 | -require_once(KT_LIB_DIR . '/subscriptions/SubscriptionConstants.inc'); | |
| 35 | 33 | |
| 36 | 34 | // NEW PATHS |
| 37 | 35 | require_once(KT_LIB_DIR . '/storage/storagemanager.inc.php'); |
| 38 | 36 | require_once(KT_LIB_DIR . '/filelike/filelikeutil.inc.php'); |
| 39 | 37 | require_once(KT_LIB_DIR . '/metadata/metadatautil.inc.php'); |
| 40 | 38 | require_once(KT_LIB_DIR . '/metadata/fieldset.inc.php'); |
| 41 | - | |
| 39 | +require_once(KT_LIB_DIR . "/subscriptions/subscriptions.inc.php"); | |
| 42 | 40 | require_once(KT_LIB_DIR . '/triggers/triggerregistry.inc.php'); |
| 41 | +require_once(KT_LIB_DIR . "/foldermanagement/Folder.inc"); | |
| 43 | 42 | |
| 44 | 43 | class KTDocumentUtil { |
| 45 | 44 | function createMetadataVersion($oDocument) { |
| ... | ... | @@ -164,12 +163,10 @@ class KTDocumentUtil { |
| 164 | 163 | } |
| 165 | 164 | |
| 166 | 165 | // fire subscription alerts for the checked in document |
| 167 | - $count = SubscriptionEngine::fireSubscription($oDocument->getID(), SubscriptionConstants::subscriptionAlertType("CheckInDocument"), | |
| 168 | - SubscriptionConstants::subscriptionType("DocumentSubscription"), | |
| 169 | - array( "folderID" => $oDocument->getFolderID(), | |
| 170 | - "modifiedDocumentName" => $oDocument->getName() )); | |
| 171 | - global $default; | |
| 172 | - $default->log->info("checkInDocumentBL.php fired $count subscription alerts for checked out document " . $oDocument->getName()); | |
| 166 | + $oSubscriptionEvent = new SubscriptionEvent(); | |
| 167 | + $oFolder = Folder::get($oDocument->getFolderID()); | |
| 168 | + $oSubscriptionEvent->CheckinDocument($oDocument, $oFolder); | |
| 169 | + | |
| 173 | 170 | return true; |
| 174 | 171 | } |
| 175 | 172 | |
| ... | ... | @@ -420,12 +417,9 @@ class KTDocumentUtil { |
| 420 | 417 | } |
| 421 | 418 | |
| 422 | 419 | // fire subscription alerts for the checked in document |
| 423 | - $count = SubscriptionEngine::fireSubscription($oDocument->getID(), SubscriptionConstants::subscriptionAlertType("AddDocument"), | |
| 424 | - SubscriptionConstants::subscriptionType("DocumentSubscription"), | |
| 425 | - array( "folderID" => $oDocument->getFolderID(), | |
| 426 | - "newDocumentName" => $oDocument->getName() )); | |
| 427 | - global $default; | |
| 428 | - $default->log->info("checkInDocumentBL.php fired $count subscription alerts for checked out document " . $oDocument->getName()); | |
| 420 | + $oSubscriptionEvent = new SubscriptionEvent(); | |
| 421 | + $oFolder = Folder::get($oDocument->getFolderID()); | |
| 422 | + $oSubscriptionEvent->AddDocument($oDocument, $oFolder); | |
| 429 | 423 | |
| 430 | 424 | return $oDocument; |
| 431 | 425 | } | ... | ... |
lib/foldermanagement/folderutil.inc.php
| ... | ... | @@ -25,6 +25,7 @@ |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | require_once(KT_LIB_DIR . '/storage/storagemanager.inc.php'); |
| 28 | +require_once(KT_LIB_DIR . "/subscriptions/subscriptions.inc.php"); | |
| 28 | 29 | |
| 29 | 30 | class KTFolderUtil { |
| 30 | 31 | function _add ($oParentFolder, $sFolderName, $oUser) { |
| ... | ... | @@ -54,14 +55,8 @@ class KTFolderUtil { |
| 54 | 55 | } |
| 55 | 56 | |
| 56 | 57 | // fire subscription alerts for the new folder |
| 57 | - /* $count = SubscriptionEngine::fireSubscription( | |
| 58 | - $oParentFolder->getID(), SubscriptionConstants::subscriptionAlertType("AddFolder"), | |
| 59 | - SubscriptionConstants::subscriptionType("FolderSubscription"), | |
| 60 | - array( | |
| 61 | - "newFolderName" => $sFolderName, | |
| 62 | - "parentFolderName" => $oParentFolder->getName(), | |
| 63 | - ) | |
| 64 | - );*/ | |
| 58 | + $oSubscriptionEvent = new SubscriptionEvent(); | |
| 59 | + $oSubscriptionEvent->AddFolder($oFolder, $oParentFolder); | |
| 65 | 60 | return $oFolder; |
| 66 | 61 | } |
| 67 | 62 | ... | ... |
lib/subscriptions/Subscription.inc
| ... | ... | @@ -2,6 +2,7 @@ |
| 2 | 2 | require_once(KT_LIB_DIR . "/subscriptions/SubscriptionConstants.inc"); |
| 3 | 3 | require_once(KT_LIB_DIR . "/foldermanagement/Folder.inc"); |
| 4 | 4 | require_once(KT_LIB_DIR . "/documentmanagement/Document.inc"); |
| 5 | +require_once(KT_LIB_DIR . "/subscriptions/subscriptions.inc.php"); | |
| 5 | 6 | /** |
| 6 | 7 | * $Id$ |
| 7 | 8 | * |
| ... | ... | @@ -318,9 +319,9 @@ class Subscription extends KTEntity { |
| 318 | 319 | * @return string the subscription id field name to use |
| 319 | 320 | */ |
| 320 | 321 | function getIdFieldName($iSubscriptionType) { |
| 321 | - if ($iSubscriptionType == SubscriptionConstants::subscriptionType("DocumentSubscription")) { | |
| 322 | + if ($iSubscriptionType == SubscriptionEvent::subTypes("Document")) { | |
| 322 | 323 | return "document_id"; |
| 323 | - } else if($iSubscriptionType == SubscriptionConstants::subscriptionType("FolderSubscription")) { | |
| 324 | + } else if($iSubscriptionType == SubscriptionEvent::subTypes("Folder")) { | |
| 324 | 325 | return "folder_id"; |
| 325 | 326 | } |
| 326 | 327 | ... | ... |
lib/subscriptions/SubscriptionEngine.inc deleted
| 1 | -<?php | |
| 2 | -global $default; | |
| 3 | -require_once(KT_LIB_DIR . "/users/User.inc"); | |
| 4 | -require_once(KT_LIB_DIR . "/documentmanagement/Document.inc"); | |
| 5 | -require_once(KT_LIB_DIR . "/foldermanagement/Folder.inc"); | |
| 6 | -require_once(KT_LIB_DIR . "/subscriptions/Subscription.inc"); | |
| 7 | -require_once(KT_LIB_DIR . "/alert/AlertContent.inc"); | |
| 8 | -require_once(KT_LIB_DIR . "/alert/delivery/EmailAlert.inc"); | |
| 9 | -require_once(KT_LIB_DIR . "/alert/delivery/SMSAlert.inc"); | |
| 10 | - | |
| 11 | -require_once(KT_LIB_DIR . "/dashboard/Notification.inc.php"); | |
| 12 | - | |
| 13 | -/** | |
| 14 | - * $Id$ | |
| 15 | - * | |
| 16 | - * Facilitates firing subscription alerts. | |
| 17 | - * | |
| 18 | - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com | |
| 19 | - * | |
| 20 | - * This program is free software; you can redistribute it and/or modify | |
| 21 | - * it under the terms of the GNU General Public License as published by | |
| 22 | - * the Free Software Foundation; either version 2 of the License, or | |
| 23 | - * (at your option) any later version. | |
| 24 | - * | |
| 25 | - * This program is distributed in the hope that it will be useful, | |
| 26 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 27 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 28 | - * GNU General Public License for more details. | |
| 29 | - * | |
| 30 | - * You should have received a copy of the GNU General Public License | |
| 31 | - * along with this program; if not, write to the Free Software | |
| 32 | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 33 | - * | |
| 34 | - * @version $Revision$ | |
| 35 | - * @author Michael Joseph <michael@jamwarehouse.com>, Jam Warehouse (Pty) Ltd, South Africa | |
| 36 | - * @package lib.subscriptions | |
| 37 | - */ | |
| 38 | -class SubscriptionEngine { | |
| 39 | - | |
| 40 | - /** | |
| 41 | - * Fires a subscription alert for this subscription content | |
| 42 | - * | |
| 43 | - * @param int the id of the subscription content | |
| 44 | - * @param int the alert type (document change, new folder, etc.) | |
| 45 | - * @param int the subscription content type (folder, document) | |
| 46 | - * @param array any dynamic values that should be sent with the alert (eg. document name, path to modified document) | |
| 47 | - * @param int the original object id (e.g. if fired on a document, and chained to a folder. | |
| 48 | - */ | |
| 49 | - function fireSubscription($iExternalID, $iSubscriptionAlertType, $iSubscriptionType, $aValues, $iOriginalId = null) { | |
| 50 | - global $default; | |
| 51 | - $default->log->info("fireSubscription ($iExternalID, $iSubscriptionAlertType, $iSubscriptionType, values)"); | |
| 52 | - // get the list of subscriber addresses that we need to alert | |
| 53 | - $aSubscribers = SubscriptionEngine::retrieveSubscribers($iExternalID, $iSubscriptionType); | |
| 54 | - | |
| 55 | - // count the number of subscriptions we've sent | |
| 56 | - $iSubscriptionsSent = 0; | |
| 57 | - | |
| 58 | - // if the subscription type is document, fire the folder subscriptions also | |
| 59 | - if ($iSubscriptionType == SubscriptionConstants::subscriptionType("DocumentSubscription")) { | |
| 60 | - $iSubscriptionsSent = SubscriptionEngine::fireSubscription($aValues["folderID"], | |
| 61 | - ($iSubscriptionAlertType == SubscriptionConstants::subscriptionAlertType("RemoveSubscribedDocument") ? | |
| 62 | - SubscriptionConstants::subscriptionAlertType("RemoveChildDocument") : | |
| 63 | - $iSubscriptionAlertType), | |
| 64 | - SubscriptionConstants::subscriptionType("FolderSubscription"), | |
| 65 | - $aValues, | |
| 66 | - $iExternalId); | |
| 67 | - $default->log->info("SubscriptionEngine::fireSubscription fired folder subscribers, count=$iSubscriptionsSent"); | |
| 68 | - } | |
| 69 | - | |
| 70 | - // for each subscriber, construct an address based on their notification preferences | |
| 71 | - for ($i=0; $i<count($aSubscribers); $i++) { | |
| 72 | - // lookup the subscription | |
| 73 | - if ($iSubscriptionType == SubscriptionConstants::subscriptionType("FolderSubscription")) { | |
| 74 | - $oSubscription = & Subscription::getByIDs($aSubscribers[$i]->getID(), $aValues['folderID'], $iSubscriptionType); | |
| 75 | - if (empty($oSubscription) || PEAR::isError($oSubscription)) { | |
| 76 | - $oSubscription =& new Subscription($aSubscribers[$i]->getID(), $aValues["folderID"], $iSubscriptionType); | |
| 77 | - $res = $oSubscription->create(); | |
| 78 | - if (empty($res) || PEAR::isError($res)) { | |
| 79 | - continue; | |
| 80 | - } | |
| 81 | - } | |
| 82 | - } else { | |
| 83 | - $oSubscription = & Subscription::getByIDs($aSubscribers[$i]->getID(), $iExternalID, $iSubscriptionType); | |
| 84 | - } | |
| 85 | - | |
| 86 | - // update the alerted status | |
| 87 | - $oSubscription->setIsAlerted(true); | |
| 88 | - | |
| 89 | - // write it back to the db | |
| 90 | - if ($oSubscription->update()) { | |
| 91 | - | |
| 92 | - // get the subscription id | |
| 93 | - $aValues["subscriptionID"] = $oSubscription->getID(); | |
| 94 | - // and type | |
| 95 | - $aValues["subscriptionType"] = $iSubscriptionType; | |
| 96 | - // and subscriber name | |
| 97 | - $aValues["subscriberName"] = $aSubscribers[$i]->getName(); | |
| 98 | - | |
| 99 | - // retrieve the appropriate content | |
| 100 | - // using the values array to customise the notification message | |
| 101 | - $sAlertContent = AlertContent::getSubscriptionAlert($iSubscriptionAlertType, $aValues); | |
| 102 | - | |
| 103 | - // construct alerts | |
| 104 | - | |
| 105 | - // dashboard notification. | |
| 106 | - $aNotificationOptions = array(); | |
| 107 | - | |
| 108 | - $aNotificationOptions['target_user'] = $aSubscribers[$i]->getID(); | |
| 109 | - $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null. | |
| 110 | - | |
| 111 | - // location name: ditto. | |
| 112 | - // target_name: ditto. | |
| 113 | - | |
| 114 | - //$default->log->debug('subscriptionengine: received ' . print_r($aValues, true)); | |
| 115 | - | |
| 116 | - // sweet lord this is _hideous_. Please, oh please kill the subscriptionsconstants | |
| 117 | - if (SubscriptionConstants::subscriptionAlertTypeString($iSubscriptionAlertType) == "AddFolder") { | |
| 118 | - $aNotificationOptions['target_name'] = $aValues["newFolderName"]; | |
| 119 | - $aNotificationOptions['location_name'] = $aValues["parentFolderName"]; | |
| 120 | - $aNotificationOptions['object_id'] = $iExternalId; // parent folder_id, in this case. | |
| 121 | - $aNotificationOptions['event_type'] = "AddFolder"; | |
| 122 | - } else if (SubscriptionConstants::subscriptionAlertTypeString($iSubscriptionAlertType) == "RemoveSubscribedFolder") { | |
| 123 | - $aNotificationOptions['target_name'] = $aValues["removedFolderName"]; | |
| 124 | - $aNotificationOptions['location_name'] = $aValues["parentFolderName"]; | |
| 125 | - $aNotificationOptions['object_id'] = $iExternalId; // parent folder_id, in this case. | |
| 126 | - $aNotificationOptions['event_type'] = "RemoveSubscribedFolder"; | |
| 127 | - } else if (SubscriptionConstants::subscriptionAlertTypeString($iSubscriptionAlertType) == "RemoveChildFolder") { | |
| 128 | - $aNotificationOptions['target_name'] = $aValues["removedFolderName"]; | |
| 129 | - $aNotificationOptions['location_name'] = $aValues["parentFolderName"]; | |
| 130 | - $aNotificationOptions['object_id'] = $iExternalId; // parent folder_id, in this case, where user is subscribed. | |
| 131 | - $aNotificationOptions['event_type'] = "RemoveChildFolder"; | |
| 132 | - } else if (SubscriptionConstants::subscriptionAlertTypeString($iSubscriptionAlertType) == "AddDocument") { | |
| 133 | - $aNotificationOptions['target_name'] = $aValues["newDocumentName"]; | |
| 134 | - $aNotificationOptions['location_name'] = $aValues["parentFolderName"]; | |
| 135 | - if ($iOriginalId !== null) { | |
| 136 | - $aNotificationOptions['object_id'] = $iOriginalId; // folder subscription, this _was_ the document. | |
| 137 | - } else { | |
| 138 | - $aNotificationOptions['object_id'] = $iExternalId; // this path _shouldn't_ be hit since its a new document - user _can't_ be subscribed to it already. | |
| 139 | - } | |
| 140 | - $aNotificationOptions['event_type'] = "AddDocument"; | |
| 141 | - } else if (SubscriptionConstants::subscriptionAlertTypeString($iSubscriptionAlertType) == "RemoveChildDocument") { | |
| 142 | - $aNotificationOptions['target_name'] = $aValues["removedDocumentName"]; | |
| 143 | - $aNotificationOptions['location_name'] = $aValues["folderName"]; | |
| 144 | - $aNotificationOptions['object_id'] = $iExternalId; // parent folder_id, in this case, where user is subscribed... is it? | |
| 145 | - $aNotificationOptions['event_type'] = "RemoveChildDocument"; | |
| 146 | - } else if (SubscriptionConstants::subscriptionAlertTypeString($iSubscriptionAlertType) == "RemoveSubscribedDocument") { | |
| 147 | - $aNotificationOptions['target_name'] = $aValues["removedDocumentName"]; | |
| 148 | - $aNotificationOptions['location_name'] = $aValues["folderName"]; | |
| 149 | - $aNotificationOptions['object_id'] = $iExternalId; // not used. | |
| 150 | - $aNotificationOptions['event_type'] = "RemoveSubscribedDocument"; | |
| 151 | - } else if (SubscriptionConstants::subscriptionAlertTypeString($iSubscriptionAlertType) == "ModifyDocument") { | |
| 152 | - $aNotificationOptions['target_name'] = $aValues["modifiedDocumentName"]; | |
| 153 | - $aNotificationOptions['location_name'] = null; // not used... why? don't we have the folder name? why not? | |
| 154 | - if ($iOriginalId !== null) { | |
| 155 | - $aNotificationOptions['object_id'] = $iOriginalId; // folder subscription, this _was_ the document. | |
| 156 | - } else { | |
| 157 | - $aNotificationOptions['object_id'] = $iExternalId; // this path _shouldn't_ be hit since its a new document - user _can't_ be subscribed to it already. | |
| 158 | - } | |
| 159 | - $aNotificationOptions['event_type'] = "ModifyDocument"; | |
| 160 | - } else if (SubscriptionConstants::subscriptionAlertTypeString($iSubscriptionAlertType) == "CheckInDocument") { | |
| 161 | - $aNotificationOptions['target_name'] = $aValues["modifiedDocumentName"]; | |
| 162 | - $aNotificationOptions['location_name'] = null; // not used... why? don't we have the folder name? why not? | |
| 163 | - if ($iOriginalId !== null) { | |
| 164 | - $aNotificationOptions['object_id'] = $iOriginalId; // folder subscription, this _was_ the document. | |
| 165 | - } else { | |
| 166 | - $aNotificationOptions['object_id'] = $iExternalId; // this path _shouldn't_ be hit since its a new document - user _can't_ be subscribed to it already. | |
| 167 | - }$aNotificationOptions['event_type'] = "CheckInDocument"; | |
| 168 | - } else if (SubscriptionConstants::subscriptionAlertTypeString($iSubscriptionAlertType) == "CheckOutDocument") { | |
| 169 | - $aNotificationOptions['target_name'] = $aValues["modifiedDocumentName"]; | |
| 170 | - $aNotificationOptions['location_name'] = null; // not used... why? don't we have the folder name? why not? | |
| 171 | - if ($iOriginalId !== null) { | |
| 172 | - $aNotificationOptions['object_id'] = $iOriginalId; // folder subscription, this _was_ the document. | |
| 173 | - } else { | |
| 174 | - $aNotificationOptions['object_id'] = $iExternalId; // this path _shouldn't_ be hit since its a new document - user _can't_ be subscribed to it already. | |
| 175 | - }$aNotificationOptions['event_type'] = "CheckOutDocument"; | |
| 176 | - } else if (SubscriptionConstants::subscriptionAlertTypeString($iSubscriptionAlertType) == "MovedDocument") { | |
| 177 | - $aNotificationOptions['target_name'] = $aValues["modifiedDocumentName"]; | |
| 178 | - $aNotificationOptions['location_name'] = $aValues["oldFolderName"]; | |
| 179 | - if ($iOriginalId !== null) { | |
| 180 | - $aNotificationOptions['object_id'] = $iOriginalId; // folder subscription, this _was_ the document. | |
| 181 | - } else { | |
| 182 | - $aNotificationOptions['object_id'] = $iExternalId; | |
| 183 | - }$aNotificationOptions['event_type'] = "MovedDocument"; | |
| 184 | - } else if (SubscriptionConstants::subscriptionAlertTypeString($iSubscriptionAlertType) == "ArchivedDocument") { | |
| 185 | - $aNotificationOptions['target_name'] = $aValues["modifiedDocumentName"]; | |
| 186 | - $aNotificationOptions['location_name'] = $aValues["folderName"]; | |
| 187 | - if ($iOriginalId !== null) { | |
| 188 | - $aNotificationOptions['object_id'] = $iOriginalId; // folder subscription, this _was_ the document. | |
| 189 | - } else { | |
| 190 | - $aNotificationOptions['object_id'] = $iExternalId; | |
| 191 | - } | |
| 192 | - $aNotificationOptions['event_type'] = "ArchivedDocument"; | |
| 193 | - } else if (SubscriptionConstants::subscriptionAlertTypeString($iSubscriptionAlertType) == "RestoredArchivedDocument") { | |
| 194 | - $aNotificationOptions['target_name'] = $aValues["modifiedDocumentName"]; | |
| 195 | - $aNotificationOptions['location_name'] = null; // $aValues["folderName"]; // not reachable. | |
| 196 | - if ($iOriginalId !== null) { | |
| 197 | - $aNotificationOptions['object_id'] = $iOriginalId; // folder subscription, this _was_ the document. | |
| 198 | - } else { | |
| 199 | - $aNotificationOptions['object_id'] = $iExternalId; | |
| 200 | - } | |
| 201 | - $aNotificationOptions['event_type'] = "RestoredArchivedDocument"; | |
| 202 | - } | |
| 203 | - | |
| 204 | - $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); | |
| 205 | - | |
| 206 | - // email alert. | |
| 207 | - if ($aSubscribers[$i]->getEmailNotification() && (strlen($aSubscribers[$i]->getEmail()) > 0)) { | |
| 208 | - | |
| 209 | - $oEmail = new EmailAlert($aSubscribers[$i]->getEmail(), $sAlertContent["subject"], $sAlertContent["text"]); | |
| 210 | - if ($oEmail->send()) { | |
| 211 | - $iSubscriptionsSent++; | |
| 212 | - $default->log->debug("SubscriptionEngine::fireSubscription successfully sent email alert to " . $aSubscribers[$i]->getEmail() . " for subscriptionID=" . $aSubscribers[$i]->getID()); | |
| 213 | - } else { | |
| 214 | - $default->log->error("SubscriptionEngine::fireSubscription failed sending email alert to " . $aSubscribers[$i]->getEmail() . " for subscriptionID=" . $aSubscribers[$i]->getID() . "; text=$sAlertContent"); | |
| 215 | - } | |
| 216 | - } | |
| 217 | - | |
| 218 | - // if sms notification is enabled, sms them | |
| 219 | - if ($aSubscribers[$i]->getSmsNotification() && strlen($aSubscribers[$i]->getMobile()) > 0) { | |
| 220 | - $oSms = new SMSAlert($aSubscribers[$i]->getMobile(), $sAlertContent["text"]); | |
| 221 | - if ($oSms->send()) { | |
| 222 | - $iSubscriptionsSent++; | |
| 223 | - $default->log->debug("SubscriptionEngine::fireSubscription successfully sent sms for folderID=$iFolderID, subscriber=" . $aSubscribers[$i]->getID() . "; text=$sNotificationText"); | |
| 224 | - } else { | |
| 225 | - $default->log->error("SubscriptionEngine::fireSubscription failed sending sms for folderID=$iFolderID, subscriber=" . $aSubscribers[$i]->getID() . "; text=$sNotificationText"); | |
| 226 | - } | |
| 227 | - } | |
| 228 | - } else { | |
| 229 | - $default->log->error("SubscriptionEngine::fireSubscription could not update subscription- db error?"); | |
| 230 | - } | |
| 231 | - } | |
| 232 | - | |
| 233 | - if ($iSubscriptionType == SubscriptionConstants::subscriptionType("FolderSubscription")) { | |
| 234 | - $oFolder =& Folder::get($iExternalID); | |
| 235 | - if ($oFolder && !PEAR::isError($oFolder)) { | |
| 236 | - $iThisSubscriptionsSent = SubscriptionEngine::fireSubscription($oFolder->getParentId(), | |
| 237 | - ($iSubscriptionAlertType == SubscriptionConstants::subscriptionAlertType("RemoveSubscribedDocument") ? | |
| 238 | - SubscriptionConstants::subscriptionAlertType("RemoveChildDocument") : | |
| 239 | - $iSubscriptionAlertType), | |
| 240 | - SubscriptionConstants::subscriptionType("FolderSubscription"), | |
| 241 | - $aValues); | |
| 242 | - $default->log->info("SubscriptionEngine::fireSubscription fired folder subscribers, count=$iThisSubscriptionsSent"); | |
| 243 | - $iSubscriptionsSent += $iThisSubscriptionsSent; | |
| 244 | - } | |
| 245 | - } | |
| 246 | - | |
| 247 | - // return the number of processed subscriptions | |
| 248 | - return $iSubscriptionsSent; | |
| 249 | - } | |
| 250 | - | |
| 251 | - /** | |
| 252 | - * Retrieves the users that are subscribed to this subscription content | |
| 253 | - * | |
| 254 | - * @param integer the ID of the subscription content to retrieve subscribers for | |
| 255 | - * @param int the subscription content type (folder, document) | |
| 256 | - * @return array of users objects representing the subscribers, false on error | |
| 257 | - */ | |
| 258 | - function retrieveSubscribers($iExternalID, $iSubscriptionType) { | |
| 259 | - global $default; | |
| 260 | - global $aAlreadySent; | |
| 261 | - if (!isset($aAlreadySent)) { | |
| 262 | - $aAlreadySent = array(); | |
| 263 | - } | |
| 264 | - | |
| 265 | - $sql = $default->db; | |
| 266 | - $aUsers = array(); | |
| 267 | - $default->log->debug("retrieveSubscribers(id=$iExternalID, type=$iSubscriptionType); table=" .Subscription::getTableName($iSubscriptionType). "; id=" .Subscription::getIdFieldName($iSubscriptionType)); | |
| 268 | - $sQuery = "SELECT user_id FROM " . Subscription::getTableName($iSubscriptionType) . " WHERE " . Subscription::getIdFieldName($iSubscriptionType) . " = ?";/*ok*/ | |
| 269 | - $aParams = array($iExternalID); | |
| 270 | - if ($sql->query(array($sQuery, $aParams))) { | |
| 271 | - while ($sql->next_record()) { | |
| 272 | - $iUserID = $sql->f("user_id"); | |
| 273 | - if (in_array($iUserID, $aAlreadySent)) { | |
| 274 | - continue; | |
| 275 | - } | |
| 276 | - $aAlreadySent[] = $iUserID; | |
| 277 | - $oUser = & User::get($iUserID ); | |
| 278 | - if ($oUser) { | |
| 279 | - $aUsers[] = $oUser; | |
| 280 | - } else { | |
| 281 | - $default->log->error("SubscriptionEngine::fireSubscription subscriber id=$iUserID doesn't exist"); | |
| 282 | - // remove this users subscription | |
| 283 | - if ($sql->query("DELETE FROM " . Subscription::getTableName($iSubscriptionType) . " " . | |
| 284 | - "WHERE user_id = $iUserID")) { | |
| 285 | - $default->log->info("SubscriptionEngine::fireSubscription successfully removed subscription for removed user id=$iUserID"); | |
| 286 | - } else { | |
| 287 | - $default->log->error("SubscriptionEngine::fireSubscription error removing subscription for user id=$iUserID"); | |
| 288 | - } | |
| 289 | - } | |
| 290 | - } | |
| 291 | - } else { | |
| 292 | - $_SESSION["errorMessage"] = $lang_err_database; | |
| 293 | - return false; | |
| 294 | - } | |
| 295 | - $default->log->debug('retrieveSubscribers found count=' . count($aUsers)); | |
| 296 | - return $aUsers; | |
| 297 | - } | |
| 298 | -} |
lib/subscriptions/SubscriptionManager.inc
| 1 | 1 | <?php |
| 2 | -require_once("$default->fileSystemRoot/lib/subscriptions/Subscription.inc"); | |
| 2 | + | |
| 3 | +require_once(KT_LIB_DIR . "/subscriptions/Subscription.inc"); | |
| 4 | +require_once(KT_LIB_DIR . "/subscriptions/subscriptions.inc.php"); | |
| 5 | + | |
| 3 | 6 | /** |
| 4 | 7 | * $Id$ |
| 5 | 8 | * |
| ... | ... | @@ -136,8 +139,8 @@ class SubscriptionManager { |
| 136 | 139 | * @return array of subscription objects |
| 137 | 140 | */ |
| 138 | 141 | function listSubscriptions($iUserID) { |
| 139 | - return $aSubscriptions = array_merge(SubscriptionManager::retrieveUserSubscriptions($iUserID, SubscriptionConstants::subscriptionType("FolderSubscription")), | |
| 140 | - SubscriptionManager::retrieveUserSubscriptions($iUserID, SubscriptionConstants::subscriptionType("DocumentSubscription"))); | |
| 142 | + return $aSubscriptions = array_merge(SubscriptionManager::retrieveUserSubscriptions($iUserID, SubscriptionEvent::subTypes('Folder')), | |
| 143 | + SubscriptionManager::retrieveUserSubscriptions($iUserID, SubscriptionEvent::subTypes('Document'))); | |
| 141 | 144 | } |
| 142 | 145 | |
| 143 | 146 | /** |
| ... | ... | @@ -170,8 +173,8 @@ class SubscriptionManager { |
| 170 | 173 | * @return array of subscription objects |
| 171 | 174 | */ |
| 172 | 175 | function listSubscriptionAlerts($iUserID) { |
| 173 | - return $aSubscriptions = array_merge(SubscriptionManager::retrieveSubscriptionAlerts($iUserID, SubscriptionConstants::subscriptionType("FolderSubscription")), | |
| 174 | - SubscriptionManager::retrieveSubscriptionAlerts($iUserID, SubscriptionConstants::subscriptionType("DocumentSubscription"))); | |
| 176 | + return $aSubscriptions = array_merge(SubscriptionManager::retrieveSubscriptionAlerts($iUserID, SubscriptionEvent::subTypes("Folder")), | |
| 177 | + SubscriptionManager::retrieveSubscriptionAlerts($iUserID, SubscriptionEvent::subTypes("Document"))); | |
| 175 | 178 | } |
| 176 | 179 | |
| 177 | 180 | /** | ... | ... |
lib/subscriptions/subscriptions.inc.php
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +/* Subscription notification type. | |
| 4 | + * | |
| 5 | + * To use this, instantiate a SubscriptionEvent, and call the appropriate "event" method. | |
| 6 | + * | |
| 7 | + * @author Brad Shuttleworth <brad@jamwarehouse.com> Jam Warehouse Software (Pty) Ltd. | |
| 8 | + */ | |
| 9 | + | |
| 10 | +require_once(KT_LIB_DIR . "/database/dbutil.inc"); | |
| 11 | +require_once(KT_LIB_DIR . "/subscriptions/Subscription.inc"); | |
| 12 | +require_once(KT_LIB_DIR . "/users/User.inc"); | |
| 13 | +require_once(KT_LIB_DIR . "/dashboard/Notification.inc.php"); | |
| 14 | +require_once(KT_LIB_DIR . "/alert/delivery/EmailAlert.inc"); | |
| 15 | + | |
| 16 | +require_once(KT_LIB_DIR . "/templating/templating.inc.php"); | |
| 17 | + | |
| 18 | +class SubscriptionEvent { | |
| 19 | + var $eventTypes = array( | |
| 20 | + "AddFolder", | |
| 21 | + "RemoveSubscribedFolder", | |
| 22 | + "RemoveChildFolder", | |
| 23 | + "AddDocument", | |
| 24 | + "RemoveSubscribedDocument", | |
| 25 | + "RemoveChildDocument", | |
| 26 | + "ModifyDocument", | |
| 27 | + "CheckInDocument", | |
| 28 | + "CheckOutDocument", | |
| 29 | + "MovedDocument", | |
| 30 | + "ArchivedDocument", | |
| 31 | + "RestoredArchivedDocument", | |
| 32 | + ); | |
| 33 | + | |
| 34 | + var $subscriptionTypes = array( | |
| 35 | + "Document" => 1, | |
| 36 | + "Folder" => 2, | |
| 37 | + ); | |
| 38 | + | |
| 39 | + function &subTypes($sType) { | |
| 40 | + $subscriptionTypes = array( | |
| 41 | + "Document" => 1, | |
| 42 | + "Folder" => 2, | |
| 43 | + ); | |
| 44 | + | |
| 45 | + return KTUtil::arrayGet($subscriptionTypes, $sType, null); | |
| 46 | + } | |
| 47 | + | |
| 48 | + var $alertedUsers = array(); // per-instance (e.g. per-event) list of users who were contacted. | |
| 49 | + var $_parameters = array(); // internal storage for | |
| 50 | + var $child = -1; // the child object-id (e.g. which initiated the event: document OR folder) | |
| 51 | + var $parent = -1; // the folder-id of the parent | |
| 52 | + | |
| 53 | + // FIXME stubs. | |
| 54 | + /* Each of these functions handles appropriate propogation (e.g. both | |
| 55 | + * folder and document subscription) without calling secondary functions. | |
| 56 | + * Every attempt is made to be as explicit as possible. | |
| 57 | + */ | |
| 58 | + | |
| 59 | + // alerts users who are subscribed to $iParentFolderId. | |
| 60 | + function AddFolder($oAddedFolder, $oParentFolder) { | |
| 61 | + $content = new SubscriptionContent(); // needed for i18n | |
| 62 | + | |
| 63 | + // only useful for folder subscriptions. | |
| 64 | + $aUsers = $this->_getSubscribers($oParentFolder->getId(), $this->subscriptionTypes["Folder"]); | |
| 65 | + $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. | |
| 66 | + foreach ($aUsers as $oSubscriber) { | |
| 67 | + | |
| 68 | + // notification object first. | |
| 69 | + $aNotificationOptions = array(); | |
| 70 | + $aNotificationOptions['target_user'] = $oSubscriber->getID(); | |
| 71 | + $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null. | |
| 72 | + $aNotificationOptions['target_name'] = $oAddedFolder->getName(); | |
| 73 | + $aNotificationOptions['location_name'] = $oParentFolder->getName(); | |
| 74 | + $aNotificationOptions['object_id'] = $oAddedFolder->getId(); // parent folder_id, in this case. | |
| 75 | + $aNotificationOptions['event_type'] = "AddFolder"; | |
| 76 | + $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); | |
| 77 | + | |
| 78 | + // now the email content. | |
| 79 | + // FIXME this needs to be handled entirely within notifications from now on. | |
| 80 | + if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { | |
| 81 | + $emailContent = $content->getEmailAlertContent($oNotification); | |
| 82 | + $emailSubject = $content->getEmailAlertSubject($oNotification); | |
| 83 | + $oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent); | |
| 84 | + $oEmail->send(); | |
| 85 | + } | |
| 86 | + } | |
| 87 | + } | |
| 88 | + function AddDocument ($oAddedDocument, $oParentFolder) { | |
| 89 | + $content = new SubscriptionContent(); // needed for i18n | |
| 90 | + // two parts to this: | |
| 91 | + $aUsers = $this->_getSubscribers($oParentFolder->getId(), $this->subscriptionTypes["Folder"]); | |
| 92 | + $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. | |
| 93 | + foreach ($aUsers as $oSubscriber) { | |
| 94 | + | |
| 95 | + // notification object first. | |
| 96 | + $aNotificationOptions = array(); | |
| 97 | + $aNotificationOptions['target_user'] = $oSubscriber->getID(); | |
| 98 | + $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null - is this valid? | |
| 99 | + $aNotificationOptions['target_name'] = $oAddedDocument->getName(); | |
| 100 | + $aNotificationOptions['location_name'] = $oParentFolder->getName(); | |
| 101 | + $aNotificationOptions['object_id'] = $oAddedDocument->getId(); // parent folder_id, in this case. | |
| 102 | + $aNotificationOptions['event_type'] = "AddDocument"; | |
| 103 | + | |
| 104 | + $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); | |
| 105 | + | |
| 106 | + // now the email content. | |
| 107 | + // FIXME this needs to be handled entirely within notifications from now on. | |
| 108 | + if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { | |
| 109 | + $emailContent = $content->getEmailAlertContent($oNotification); | |
| 110 | + $emailSubject = $content->getEmailAlertSubject($oNotification); | |
| 111 | + $oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent); | |
| 112 | + $oEmail->send(); | |
| 113 | + } | |
| 114 | + } | |
| 115 | + } | |
| 116 | + function RemoveFolder($oRemovedFolder, $oParentFolder) { | |
| 117 | + $content = new SubscriptionContent(); // needed for i18n | |
| 118 | + // two cases to consider here: | |
| 119 | + // - notify people who are subscribed to the parent folder. | |
| 120 | + // - notify and unsubscribe people who are subscribed to the actual folder. | |
| 121 | + | |
| 122 | + // we need to start with the latter, so we don't "lose" any. | |
| 123 | + $aUsers = $this->_getSubscribers($oRemovedFolder->getId(), $this->subscriptionTypes["Folder"]); | |
| 124 | + $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. | |
| 125 | + foreach ($aUsers as $oSubscriber) { | |
| 126 | + | |
| 127 | + // notification object first. | |
| 128 | + $aNotificationOptions = array(); | |
| 129 | + $aNotificationOptions['target_user'] = $oSubscriber->getID(); | |
| 130 | + $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null. | |
| 131 | + $aNotificationOptions['target_name'] = $oRemovedFolder->getName(); | |
| 132 | + $aNotificationOptions['location_name'] = $oParentFolder->getName(); | |
| 133 | + $aNotificationOptions['object_id'] = $oParentFolder->getId(); // parent folder_id, since the removed one is removed. | |
| 134 | + $aNotificationOptions['event_type'] = "RemoveSubscribedFolder"; | |
| 135 | + $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); | |
| 136 | + | |
| 137 | + // now the email content. | |
| 138 | + // FIXME this needs to be handled entirely within notifications from now on. | |
| 139 | + if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { | |
| 140 | + $emailContent = $content->getEmailAlertContent($oNotification); | |
| 141 | + $emailSubject = $content->getEmailAlertSubject($oNotification); | |
| 142 | + $oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent); | |
| 143 | + $oEmail->send(); | |
| 144 | + } | |
| 145 | + | |
| 146 | + // now grab each oSubscribers oSubscription, and delete. | |
| 147 | + $oSubscription = Subscription::getByIds($oSubscriber->getId(), $oRemovedFolder->getId(), $this->subscriptionTypes["Folder"]); | |
| 148 | + if (!(PEAR::isError($oSubscription) || ($oSubscription == false))) { | |
| 149 | + $oSubscription->delete(); | |
| 150 | + } | |
| 151 | + } | |
| 152 | + | |
| 153 | + // now handle (for those who haven't been alerted) users watching the folder. | |
| 154 | + $aUsers = $this->_getSubscribers($oParentFolder->getId(), $this->subscriptionTypes["Folder"]); | |
| 155 | + $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. | |
| 156 | + foreach ($aUsers as $oSubscriber) { | |
| 157 | + | |
| 158 | + // notification object first. | |
| 159 | + $aNotificationOptions = array(); | |
| 160 | + $aNotificationOptions['target_user'] = $oSubscriber->getID(); | |
| 161 | + $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null. | |
| 162 | + $aNotificationOptions['target_name'] = $oRemovedFolder->getName(); | |
| 163 | + $aNotificationOptions['location_name'] = $oParentFolder->getName(); | |
| 164 | + $aNotificationOptions['object_id'] = $oParentFolder->getId(); // parent folder_id, since the removed one is removed. | |
| 165 | + $aNotificationOptions['event_type'] = "RemoveChildFolder"; | |
| 166 | + $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); | |
| 167 | + | |
| 168 | + // now the email content. | |
| 169 | + // FIXME this needs to be handled entirely within notifications from now on. | |
| 170 | + if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { | |
| 171 | + $emailContent = $content->getEmailAlertContent($oNotification); | |
| 172 | + $emailSubject = $content->getEmailAlertSubject($oNotification); | |
| 173 | + $oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent); | |
| 174 | + $oEmail->send(); | |
| 175 | + } | |
| 176 | + } | |
| 177 | + | |
| 178 | + } | |
| 179 | + function RemoveDocument($oRemovedDocument, $oParentFolder) { | |
| 180 | + $content = new SubscriptionContent(); // needed for i18n | |
| 181 | + // two cases to consider here: | |
| 182 | + // - notify people who are subscribed to the parent folder. | |
| 183 | + // - notify and unsubscribe people who are subscribed to the actual folder. | |
| 184 | + | |
| 185 | + // we need to start with the latter, so we don't "lose" any. | |
| 186 | + $aUsers = $this->_getSubscribers($oRemovedDocument->getId(), $this->subscriptionTypes["Document"]); | |
| 187 | + $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. | |
| 188 | + foreach ($aUsers as $oSubscriber) { | |
| 189 | + | |
| 190 | + // notification object first. | |
| 191 | + $aNotificationOptions = array(); | |
| 192 | + $aNotificationOptions['target_user'] = $oSubscriber->getID(); | |
| 193 | + $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null. | |
| 194 | + $aNotificationOptions['target_name'] = $oRemovedDocument->getName(); | |
| 195 | + $aNotificationOptions['location_name'] = $oParentFolder->getName(); | |
| 196 | + $aNotificationOptions['object_id'] = $oParentFolder->getId(); // parent folder_id, since the removed one is removed. | |
| 197 | + $aNotificationOptions['event_type'] = "RemoveSubscribedDocument"; | |
| 198 | + $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); | |
| 199 | + | |
| 200 | + // now the email content. | |
| 201 | + // FIXME this needs to be handled entirely within notifications from now on. | |
| 202 | + if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { | |
| 203 | + $emailContent = $content->getEmailAlertContent($oNotification); | |
| 204 | + $emailSubject = $content->getEmailAlertSubject($oNotification); | |
| 205 | + $oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent); | |
| 206 | + $oEmail->send(); | |
| 207 | + } | |
| 208 | + | |
| 209 | + // now grab each oSubscribers oSubscription, and delete. | |
| 210 | + $oSubscription = Subscription::getByIds($oSubscriber->getId(), $oRemovedDocument->getId(), $this->subscriptionTypes["Document"]); | |
| 211 | + if (!(PEAR::isError($oSubscription) || ($oSubscription == false))) { | |
| 212 | + $oSubscription->delete(); | |
| 213 | + } | |
| 214 | + } | |
| 215 | + | |
| 216 | + // now handle (for those who haven't been alerted) users watching the folder. | |
| 217 | + $aUsers = $this->_getSubscribers($oParentFolder->getId(), $this->subscriptionTypes["Folder"]); | |
| 218 | + $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. | |
| 219 | + foreach ($aUsers as $oSubscriber) { | |
| 220 | + | |
| 221 | + // notification object first. | |
| 222 | + $aNotificationOptions = array(); | |
| 223 | + $aNotificationOptions['target_user'] = $oSubscriber->getID(); | |
| 224 | + $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null. | |
| 225 | + $aNotificationOptions['target_name'] = $oRemovedDocument->getName(); | |
| 226 | + $aNotificationOptions['location_name'] = $oParentFolder->getName(); | |
| 227 | + $aNotificationOptions['object_id'] = $oParentFolder->getId(); // parent folder_id, since the removed one is removed. | |
| 228 | + $aNotificationOptions['event_type'] = "RemoveChildDocument"; | |
| 229 | + $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); | |
| 230 | + | |
| 231 | + // now the email content. | |
| 232 | + // FIXME this needs to be handled entirely within notifications from now on. | |
| 233 | + if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { | |
| 234 | + $emailContent = $content->getEmailAlertContent($oNotification); | |
| 235 | + $emailSubject = $content->getEmailAlertSubject($oNotification); | |
| 236 | + $oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent); | |
| 237 | + $oEmail->send(); | |
| 238 | + } | |
| 239 | + } | |
| 240 | + | |
| 241 | + } | |
| 242 | + function ModifyDocument($oModifiedDocument, $oParentFolder) { | |
| 243 | + $content = new SubscriptionContent(); // needed for i18n | |
| 244 | + // OK: two actions: document registrants, folder registrants. | |
| 245 | + $aUsers = $this->_getSubscribers($oModifiedDocument->getId(), $this->subscriptionTypes["Document"]); | |
| 246 | + $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. | |
| 247 | + foreach ($aUsers as $oSubscriber) { | |
| 248 | + | |
| 249 | + // notification object first. | |
| 250 | + $aNotificationOptions = array(); | |
| 251 | + $aNotificationOptions['target_user'] = $oSubscriber->getID(); | |
| 252 | + $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null. | |
| 253 | + $aNotificationOptions['target_name'] = $oModifiedDocument->getName(); | |
| 254 | + $aNotificationOptions['location_name'] = $oParentFolder->getName(); | |
| 255 | + $aNotificationOptions['object_id'] = $oModifiedDocument->getId(); // parent folder_id, in this case. | |
| 256 | + $aNotificationOptions['event_type'] = "ModifyDocument"; | |
| 257 | + $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); | |
| 258 | + | |
| 259 | + // now the email content. | |
| 260 | + // FIXME this needs to be handled entirely within notifications from now on. | |
| 261 | + if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { | |
| 262 | + $emailContent = $content->getEmailAlertContent($oNotification); | |
| 263 | + $emailSubject = $content->getEmailAlertSubject($oNotification); | |
| 264 | + $oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent); | |
| 265 | + $oEmail->send(); | |
| 266 | + } | |
| 267 | + } | |
| 268 | + | |
| 269 | + | |
| 270 | + $aUsers = $this->_getSubscribers($oParentFolder->getId(), $this->subscriptionTypes["Folder"]); | |
| 271 | + $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. | |
| 272 | + foreach ($aUsers as $oSubscriber) { | |
| 273 | + | |
| 274 | + // notification object first. | |
| 275 | + $aNotificationOptions = array(); | |
| 276 | + $aNotificationOptions['target_user'] = $oSubscriber->getID(); | |
| 277 | + $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null. | |
| 278 | + $aNotificationOptions['target_name'] = $oModifiedDocument->getName(); | |
| 279 | + $aNotificationOptions['location_name'] = $oParentFolder->getName(); | |
| 280 | + $aNotificationOptions['object_id'] = $oModifiedDocument->getId(); // parent folder_id, in this case. | |
| 281 | + $aNotificationOptions['event_type'] = "ModifyDocument"; | |
| 282 | + $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); | |
| 283 | + | |
| 284 | + // now the email content. | |
| 285 | + // FIXME this needs to be handled entirely within notifications from now on. | |
| 286 | + if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { | |
| 287 | + $emailContent = $content->getEmailAlertContent($oNotification); | |
| 288 | + $emailSubject = $content->getEmailAlertSubject($oNotification); | |
| 289 | + $oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent); | |
| 290 | + $oEmail->send(); | |
| 291 | + } | |
| 292 | + } | |
| 293 | + } | |
| 294 | + function CheckinDocument($oModifiedDocument, $oParentFolder) { | |
| 295 | + $content = new SubscriptionContent(); // needed for i18n | |
| 296 | + // OK: two actions: document registrants, folder registrants. | |
| 297 | + $aUsers = $this->_getSubscribers($oModifiedDocument->getId(), $this->subscriptionTypes["Document"]); | |
| 298 | + $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. | |
| 299 | + foreach ($aUsers as $oSubscriber) { | |
| 300 | + | |
| 301 | + // notification object first. | |
| 302 | + $aNotificationOptions = array(); | |
| 303 | + $aNotificationOptions['target_user'] = $oSubscriber->getID(); | |
| 304 | + $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null. | |
| 305 | + $aNotificationOptions['target_name'] = $oModifiedDocument->getName(); | |
| 306 | + $aNotificationOptions['location_name'] = $oParentFolder->getName(); | |
| 307 | + $aNotificationOptions['object_id'] = $oModifiedDocument->getId(); // parent folder_id, in this case. | |
| 308 | + $aNotificationOptions['event_type'] = "CheckinDocument"; | |
| 309 | + $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); | |
| 310 | + | |
| 311 | + // now the email content. | |
| 312 | + // FIXME this needs to be handled entirely within notifications from now on. | |
| 313 | + if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { | |
| 314 | + $emailContent = $content->getEmailAlertContent($oNotification); | |
| 315 | + $emailSubject = $content->getEmailAlertSubject($oNotification); | |
| 316 | + $oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent); | |
| 317 | + $oEmail->send(); | |
| 318 | + } | |
| 319 | + } | |
| 320 | + | |
| 321 | + | |
| 322 | + $aUsers = $this->_getSubscribers($oParentFolder->getId(), $this->subscriptionTypes["Folder"]); | |
| 323 | + $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. | |
| 324 | + foreach ($aUsers as $oSubscriber) { | |
| 325 | + | |
| 326 | + // notification object first. | |
| 327 | + $aNotificationOptions = array(); | |
| 328 | + $aNotificationOptions['target_user'] = $oSubscriber->getID(); | |
| 329 | + $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null. | |
| 330 | + $aNotificationOptions['target_name'] = $oModifiedDocument->getName(); | |
| 331 | + $aNotificationOptions['location_name'] = $oParentFolder->getName(); | |
| 332 | + $aNotificationOptions['object_id'] = $oModifiedDocument->getId(); // parent folder_id, in this case. | |
| 333 | + $aNotificationOptions['event_type'] = "CheckinDocument"; | |
| 334 | + $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); | |
| 335 | + | |
| 336 | + // now the email content. | |
| 337 | + // FIXME this needs to be handled entirely within notifications from now on. | |
| 338 | + if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { | |
| 339 | + $emailContent = $content->getEmailAlertContent($oNotification); | |
| 340 | + $emailSubject = $content->getEmailAlertSubject($oNotification); | |
| 341 | + $oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent); | |
| 342 | + $oEmail->send(); | |
| 343 | + | |
| 344 | + } | |
| 345 | + } | |
| 346 | + } | |
| 347 | + function CheckoutDocument($oModifiedDocument, $oParentFolder) { | |
| 348 | + $content = new SubscriptionContent(); // needed for i18n | |
| 349 | + // OK: two actions: document registrants, folder registrants. | |
| 350 | + $aUsers = $this->_getSubscribers($oModifiedDocument->getId(), $this->subscriptionTypes["Document"]); | |
| 351 | + $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. | |
| 352 | + foreach ($aUsers as $oSubscriber) { | |
| 353 | + | |
| 354 | + // notification object first. | |
| 355 | + $aNotificationOptions = array(); | |
| 356 | + $aNotificationOptions['target_user'] = $oSubscriber->getID(); | |
| 357 | + $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null. | |
| 358 | + $aNotificationOptions['target_name'] = $oModifiedDocument->getName(); | |
| 359 | + $aNotificationOptions['location_name'] = $oParentFolder->getName(); | |
| 360 | + $aNotificationOptions['object_id'] = $oModifiedDocument->getId(); // parent folder_id, in this case. | |
| 361 | + $aNotificationOptions['event_type'] = "CheckoutDocument"; | |
| 362 | + $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); | |
| 363 | + | |
| 364 | + // now the email content. | |
| 365 | + // FIXME this needs to be handled entirely within notifications from now on. | |
| 366 | + if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { | |
| 367 | + $emailContent = $content->getEmailAlertContent($oNotification); | |
| 368 | + $emailSubject = $content->getEmailAlertSubject($oNotification); | |
| 369 | + $oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent); | |
| 370 | + $oEmail->send(); | |
| 371 | + } | |
| 372 | + } | |
| 373 | + | |
| 374 | + | |
| 375 | + $aUsers = $this->_getSubscribers($oParentFolder->getId(), $this->subscriptionTypes["Folder"]); | |
| 376 | + $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. | |
| 377 | + foreach ($aUsers as $oSubscriber) { | |
| 378 | + | |
| 379 | + // notification object first. | |
| 380 | + $aNotificationOptions = array(); | |
| 381 | + $aNotificationOptions['target_user'] = $oSubscriber->getID(); | |
| 382 | + $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null. | |
| 383 | + $aNotificationOptions['target_name'] = $oModifiedDocument->getName(); | |
| 384 | + $aNotificationOptions['location_name'] = $oParentFolder->getName(); | |
| 385 | + $aNotificationOptions['object_id'] = $oModifiedDocument->getId(); // parent folder_id, in this case. | |
| 386 | + $aNotificationOptions['event_type'] = "CheckoutDocument"; | |
| 387 | + $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); | |
| 388 | + | |
| 389 | + // now the email content. | |
| 390 | + // FIXME this needs to be handled entirely within notifications from now on. | |
| 391 | + if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { | |
| 392 | + $emailContent = $content->getEmailAlertContent($oNotification); | |
| 393 | + $emailSubject = $content->getEmailAlertSubject($oNotification); | |
| 394 | + $oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent); | |
| 395 | + $oEmail->send(); | |
| 396 | + } | |
| 397 | + } | |
| 398 | + } | |
| 399 | + function MoveDocument($oMovedDocument, $oToFolder, $oFromFolder) { | |
| 400 | + $content = new SubscriptionContent(); // needed for i18n | |
| 401 | + // OK: two actions: document registrants, folder registrants. | |
| 402 | + $aUsers = $this->_getSubscribers($oModifiedDocument->getId(), $this->subscriptionTypes["Document"]); | |
| 403 | + $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. | |
| 404 | + foreach ($aUsers as $oSubscriber) { | |
| 405 | + | |
| 406 | + // notification object first. | |
| 407 | + $aNotificationOptions = array(); | |
| 408 | + $aNotificationOptions['target_user'] = $oSubscriber->getID(); | |
| 409 | + $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null. | |
| 410 | + $aNotificationOptions['target_name'] = $oModifiedDocument->getName(); | |
| 411 | + $aNotificationOptions['location_name'] = $oToFolder->getName(); | |
| 412 | + $aNotificationOptions['object_id'] = $oToFolder->getId(); // parent folder_id, in this case. | |
| 413 | + $aNotificationOptions['event_type'] = "MovedDocument"; | |
| 414 | + $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); | |
| 415 | + | |
| 416 | + // now the email content. | |
| 417 | + // FIXME this needs to be handled entirely within notifications from now on. | |
| 418 | + if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { | |
| 419 | + $emailContent = $content->getEmailAlertContent($oNotification); | |
| 420 | + $emailSubject = $content->getEmailAlertSubject($oNotification); | |
| 421 | + $oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent); | |
| 422 | + $oEmail->send(); | |
| 423 | + } | |
| 424 | + } | |
| 425 | + | |
| 426 | + | |
| 427 | + $aUsers = $this->_getSubscribers($oFromFolder->getId(), $this->subscriptionTypes["Folder"]); | |
| 428 | + $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. | |
| 429 | + foreach ($aUsers as $oSubscriber) { | |
| 430 | + | |
| 431 | + // notification object first. | |
| 432 | + $aNotificationOptions = array(); | |
| 433 | + $aNotificationOptions['target_user'] = $oSubscriber->getID(); | |
| 434 | + $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null. | |
| 435 | + $aNotificationOptions['target_name'] = $oModifiedDocument->getName(); | |
| 436 | + $aNotificationOptions['location_name'] = $oToFolder->getName(); | |
| 437 | + $aNotificationOptions['object_id'] = $oToFolder->getId(); // parent folder_id, in this case. | |
| 438 | + $aNotificationOptions['event_type'] = "MovedDocument"; | |
| 439 | + $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); | |
| 440 | + | |
| 441 | + // now the email content. | |
| 442 | + // FIXME this needs to be handled entirely within notifications from now on. | |
| 443 | + if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { | |
| 444 | + $emailContent = $content->getEmailAlertContent($oNotification); | |
| 445 | + $emailSubject = $content->getEmailAlertSubject($oNotification); | |
| 446 | + $oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent); | |
| 447 | + $oEmail->send(); | |
| 448 | + } | |
| 449 | + } | |
| 450 | + | |
| 451 | + $aUsers = $this->_getSubscribers($oToFolder->getId(), $this->subscriptionTypes["Folder"]); | |
| 452 | + $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. | |
| 453 | + foreach ($aUsers as $oSubscriber) { | |
| 454 | + | |
| 455 | + // notification object first. | |
| 456 | + $aNotificationOptions = array(); | |
| 457 | + $aNotificationOptions['target_user'] = $oSubscriber->getID(); | |
| 458 | + $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null. | |
| 459 | + $aNotificationOptions['target_name'] = $oModifiedDocument->getName(); | |
| 460 | + $aNotificationOptions['location_name'] = $oToFolder->getName(); | |
| 461 | + $aNotificationOptions['object_id'] = $oToFolder->getId(); // parent folder_id, in this case. | |
| 462 | + $aNotificationOptions['event_type'] = "MovedDocument"; | |
| 463 | + $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); | |
| 464 | + | |
| 465 | + // now the email content. | |
| 466 | + // FIXME this needs to be handled entirely within notifications from now on. | |
| 467 | + if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { | |
| 468 | + $emailContent = $content->getEmailAlertContent($oNotification); | |
| 469 | + $emailSubject = $content->getEmailAlertSubject($oNotification); | |
| 470 | + $oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent); | |
| 471 | + $oEmail->send(); | |
| 472 | + } | |
| 473 | + } | |
| 474 | + } | |
| 475 | + function ArchivedDocument($oModifiedDocument, $oParentFolder) { | |
| 476 | + $content = new SubscriptionContent(); // needed for i18n | |
| 477 | + // OK: two actions: document registrants, folder registrants. | |
| 478 | + $aUsers = $this->_getSubscribers($oModifiedDocument->getId(), $this->subscriptionTypes["Document"]); | |
| 479 | + $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. | |
| 480 | + foreach ($aUsers as $oSubscriber) { | |
| 481 | + | |
| 482 | + // notification object first. | |
| 483 | + $aNotificationOptions = array(); | |
| 484 | + $aNotificationOptions['target_user'] = $oSubscriber->getID(); | |
| 485 | + $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null. | |
| 486 | + $aNotificationOptions['target_name'] = $oModifiedDocument->getName(); | |
| 487 | + $aNotificationOptions['location_name'] = $oParentFolder->getName(); | |
| 488 | + $aNotificationOptions['object_id'] = $oModifiedDocument->getId(); // parent folder_id, in this case. | |
| 489 | + $aNotificationOptions['event_type'] = "ArchivedDocument"; | |
| 490 | + $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); | |
| 491 | + | |
| 492 | + // now the email content. | |
| 493 | + // FIXME this needs to be handled entirely within notifications from now on. | |
| 494 | + if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { | |
| 495 | + $emailContent = $content->getEmailAlertContent($oNotification); | |
| 496 | + $emailSubject = $content->getEmailAlertSubject($oNotification); | |
| 497 | + $oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent); | |
| 498 | + $oEmail->send(); | |
| 499 | + } | |
| 500 | + } | |
| 501 | + | |
| 502 | + | |
| 503 | + $aUsers = $this->_getSubscribers($oParentFolder->getId(), $this->subscriptionTypes["Folder"]); | |
| 504 | + $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. | |
| 505 | + foreach ($aUsers as $oSubscriber) { | |
| 506 | + | |
| 507 | + // notification object first. | |
| 508 | + $aNotificationOptions = array(); | |
| 509 | + $aNotificationOptions['target_user'] = $oSubscriber->getID(); | |
| 510 | + $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null. | |
| 511 | + $aNotificationOptions['target_name'] = $oModifiedDocument->getName(); | |
| 512 | + $aNotificationOptions['location_name'] = $oParentFolder->getName(); | |
| 513 | + $aNotificationOptions['object_id'] = $oModifiedDocument->getId(); // parent folder_id, in this case. | |
| 514 | + $aNotificationOptions['event_type'] = "ArchivedDocument"; | |
| 515 | + $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); | |
| 516 | + | |
| 517 | + // now the email content. | |
| 518 | + // FIXME this needs to be handled entirely within notifications from now on. | |
| 519 | + if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { | |
| 520 | + $emailContent = $content->getEmailAlertContent($oNotification); | |
| 521 | + $emailSubject = $content->getEmailAlertSubject($oNotification); | |
| 522 | + $oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent); | |
| 523 | + $oEmail->send(); | |
| 524 | + } | |
| 525 | + } | |
| 526 | + } | |
| 527 | + | |
| 528 | + function RestoreDocument($oModifiedDocument, $oParentFolder) { | |
| 529 | + $content = new SubscriptionContent(); // needed for i18n | |
| 530 | + // OK: two actions: document registrants, folder registrants. | |
| 531 | + $aUsers = $this->_getSubscribers($oModifiedDocument->getId(), $this->subscriptionTypes["Document"]); | |
| 532 | + $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. | |
| 533 | + foreach ($aUsers as $oSubscriber) { | |
| 534 | + | |
| 535 | + // notification object first. | |
| 536 | + $aNotificationOptions = array(); | |
| 537 | + $aNotificationOptions['target_user'] = $oSubscriber->getID(); | |
| 538 | + $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null. | |
| 539 | + $aNotificationOptions['target_name'] = $oModifiedDocument->getName(); | |
| 540 | + $aNotificationOptions['location_name'] = $oParentFolder->getName(); | |
| 541 | + $aNotificationOptions['object_id'] = $oModifiedDocument->getId(); // parent folder_id, in this case. | |
| 542 | + $aNotificationOptions['event_type'] = "RestoreArchivedDocument"; | |
| 543 | + $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); | |
| 544 | + | |
| 545 | + // now the email content. | |
| 546 | + // FIXME this needs to be handled entirely within notifications from now on. | |
| 547 | + if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { | |
| 548 | + $emailContent = $content->getEmailAlertContent($oNotification); | |
| 549 | + $emailSubject = $content->getEmailAlertSubject($oNotification); | |
| 550 | + $oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent); | |
| 551 | + $oEmail->send(); | |
| 552 | + } | |
| 553 | + } | |
| 554 | + | |
| 555 | + | |
| 556 | + $aUsers = $this->_getSubscribers($oParentFolder->getId(), $this->subscriptionTypes["Folder"]); | |
| 557 | + $aUsers = $this->_pruneAlertedUsers($aUsers); // setup the alerted users. _might_ be a singleton. | |
| 558 | + foreach ($aUsers as $oSubscriber) { | |
| 559 | + | |
| 560 | + // notification object first. | |
| 561 | + $aNotificationOptions = array(); | |
| 562 | + $aNotificationOptions['target_user'] = $oSubscriber->getID(); | |
| 563 | + $aNotificationOptions['actor_id'] = KTUtil::arrayGet($_SESSION,"userID", null); // _won't_ be null. | |
| 564 | + $aNotificationOptions['target_name'] = $oModifiedDocument->getName(); | |
| 565 | + $aNotificationOptions['location_name'] = $oParentFolder->getName(); | |
| 566 | + $aNotificationOptions['object_id'] = $oModifiedDocument->getId(); // parent folder_id, in this case. | |
| 567 | + $aNotificationOptions['event_type'] = "RestoreArchivedDocument"; | |
| 568 | + $oNotification =& KTSubscriptionNotification::generateSubscriptionNotification($aNotificationOptions); | |
| 569 | + | |
| 570 | + // now the email content. | |
| 571 | + // FIXME this needs to be handled entirely within notifications from now on. | |
| 572 | + if ($oSubscriber->getEmailNotification() && (strlen($oSubscriber->getEmail()) > 0)) { | |
| 573 | + $emailContent = $content->getEmailAlertContent($oNotification); | |
| 574 | + $emailSubject = $content->getEmailAlertSubject($oNotification); | |
| 575 | + $oEmail = new EmailAlert($oSubscriber->getEmail(), $emailSubject, $emailContent); | |
| 576 | + $oEmail->send(); | |
| 577 | + } | |
| 578 | + } | |
| 579 | + } | |
| 580 | + | |
| 581 | + // small helper function to assist in identifying the numeric id. | |
| 582 | + function _getKeyForType($sEventType) { | |
| 583 | + foreach ($this->eventTypes as $key => $val) { | |
| 584 | + if ($val == $sSubType) { return $key; } | |
| 585 | + } | |
| 586 | + return -1; | |
| 587 | + } | |
| 588 | + | |
| 589 | + // helper function to get & adjust the $alertedUsers | |
| 590 | + // note that this has side-effects: $this->alertedUsers is a merged version | |
| 591 | + // after this has been called. | |
| 592 | + function _pruneAlertedUsers($aUserIds) { | |
| 593 | + $returnArray = array_diff($aUserIds, $this->alertedUsers); | |
| 594 | + $this->alertedUsers = array_merge($returnArray, $this->alertedUsers); // now contains all users who will have been alerted. | |
| 595 | + return $returnArray; | |
| 596 | + } | |
| 597 | + | |
| 598 | + // gets subscribers to object, with appropriate type (e.g. folder or document). | |
| 599 | + // need the second part because docs and folders have separate ids. | |
| 600 | + // based on the old SubscriptionEngine::retrieveSubscribers. | |
| 601 | + function _getSubscribers($iObjectId, $iSubType) { | |
| 602 | + global $default; // for the logging. | |
| 603 | + $default->log->debug("_getSubscribers(id=$iObjectId, type=$iSubType); table=" .Subscription::getTableName($iSubType). "; id=" .Subscription::getIdFieldName($iSubType)); | |
| 604 | + | |
| 605 | + $aUsers = array(); | |
| 606 | + $sQuery = "SELECT user_id FROM " . Subscription::getTableName($iSubType) . " WHERE " . Subscription::getIdFieldName($iSubType) . " = ?"; | |
| 607 | + $aParams = array($iObjectId); | |
| 608 | + | |
| 609 | + $aNewUsers = DBUtil::getResultArrayKey(array($sQuery, $aParams), "user_id"); | |
| 610 | + | |
| 611 | + // notionally less efficient than the old code. if its a big issue, can easily | |
| 612 | + // be refactored. | |
| 613 | + $default->log->error("SubscriptionEvent:: " . print_r($iSubType, true)); | |
| 614 | + foreach ($aNewUsers as $iUserId) { | |
| 615 | + $oUser = & User::get($iUserId); | |
| 616 | + | |
| 617 | + // do a quick prune here, for performance/maintenance reasons. | |
| 618 | + if (PEAR::isError($oUser) || ($oUser == false)) { | |
| 619 | + $sQuery = "DELETE FROM " . Subscription::getTableName($iSubType) . " WHERE user_id = ?"; | |
| 620 | + $aParams = array($iUserId); | |
| 621 | + DBUtil::runQuery(array($sQuery, $sParams)); | |
| 622 | + $default->log->error("SubscriptionEvent::fireSubscription error removing subscription for user id=$iUserID"); | |
| 623 | + } else { | |
| 624 | + $aUsers[] = $oUser; | |
| 625 | + } | |
| 626 | + } | |
| 627 | + | |
| 628 | + $default->log->debug('retrieveSubscribers found count=' . count($aUsers)); | |
| 629 | + return $aUsers; | |
| 630 | + } | |
| 631 | +} | |
| 632 | + | |
| 633 | +// interesting: how do we want to generate email & notification content? | |
| 634 | +// first suggestion: | |
| 635 | +// - generate this content here. | |
| 636 | +// - alternatively, generate the content inside the notification environment (for part 2). | |
| 637 | + | |
| 638 | +/* very simple class to handle and hold the various and sundry event types content for emails. */ | |
| 639 | +class SubscriptionContent { | |
| 640 | + // have to be instantiated, or the i18n can't work. | |
| 641 | + function SubscriptionContent() { | |
| 642 | + $this->_eventTypeNames = array( | |
| 643 | + "AddFolder" => _('Folder added'), | |
| 644 | + "RemoveSubscribedFolder" => _('Folder removed'), // nothing. your subscription is now gone. | |
| 645 | + "RemoveChildFolder" => _('Folder removed'), | |
| 646 | + "AddDocument" => _('Document added'), | |
| 647 | + "RemoveSubscribedDocument" => _('Document removed'), // nothing. your subscription is now gone. | |
| 648 | + "RemoveChildDocument" => _('Document removed'), | |
| 649 | + "ModifyDocument" => _('Document modified'), | |
| 650 | + "CheckInDocument" => _('Document checked in'), | |
| 651 | + "CheckOutDocument" => _('Document checked out'), | |
| 652 | + "MovedDocument" => _('Document moved'), | |
| 653 | + "ArchivedDocument" => _('Document archived'), // can go through and request un-archival (?) | |
| 654 | + "RestoredArchivedDocument" => _('Document restored') | |
| 655 | + ); | |
| 656 | + } | |
| 657 | + | |
| 658 | + function getEmailAlertContent($oKTNotification) { | |
| 659 | + // we can re-use the normal template. | |
| 660 | + // however, we need to wrap it - no need for a second template here. | |
| 661 | + $str = '<html><body>' . $this->getNotificationAlertContent($oKTNotification) . '</body></html>'; | |
| 662 | + return $str; | |
| 663 | + } | |
| 664 | + | |
| 665 | + function getEmailAlertSubject($oKTNotification) { | |
| 666 | + $info = $this->_getSubscriptionData($oKTNotification); | |
| 667 | + return $info["title"]; | |
| 668 | + } | |
| 669 | + | |
| 670 | + function getNotificationAlertContent($oKTNotification) { | |
| 671 | + $info = $this->_getSubscriptionData($oKTNotification); | |
| 672 | + $oTemplating = new KTTemplating; | |
| 673 | + | |
| 674 | + $oTemplate = $oTemplating->loadTemplate("kt3/notifications/subscriptions." . $info['event_type']); | |
| 675 | + // if, for some reason, this doesn't actually work, use the "generic" title. | |
| 676 | + if (PEAR::isError($oTemplate)) { | |
| 677 | + $oTemplate = $oTemplating->loadTemplate("kt3/notifications/subscriptions.generic"); | |
| 678 | + } | |
| 679 | + // FIXME we need to specify the i18n by user. | |
| 680 | + $aTemplateData = array( | |
| 681 | + "context" => $oKTNotification, | |
| 682 | + "info" => $info, | |
| 683 | + ); | |
| 684 | + return $oTemplate->render($aTemplateData); | |
| 685 | + } | |
| 686 | + // no separate subject function, its rolled into get...Content() | |
| 687 | + | |
| 688 | + var $_eventObjectMap = array( | |
| 689 | + "AddFolder" => 'folder', | |
| 690 | + "RemoveSubscribedFolder" => '', // nothing. your subscription is now gone. | |
| 691 | + "RemoveChildFolder" => 'folder', | |
| 692 | + "AddDocument" => 'document', | |
| 693 | + "RemoveSubscribedDocument" => '', // nothing. your subscription is now gone. | |
| 694 | + "RemoveChildDocument" => 'folder', | |
| 695 | + "ModifyDocument" => 'document', | |
| 696 | + "CheckInDocument" => 'document', | |
| 697 | + "CheckOutDocument" => 'document', | |
| 698 | + "MovedDocument" => 'document', | |
| 699 | + "ArchivedDocument" => 'document', // can go through and request un-archival (?) | |
| 700 | + "RestoredArchivedDocument" => 'document'); | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + function _getSubscriptionData($oKTNotification) { | |
| 705 | + $info = array( | |
| 706 | + 'object_name' => $oKTNotification->getLabel(), | |
| 707 | + 'event_type' => $oKTNotification->getStrData1(), | |
| 708 | + 'location_name' => $oKTNotification->getStrData2(), | |
| 709 | + 'object_id' => $oKTNotification->getIntData1(), | |
| 710 | + 'actor_id' => $oKTNotification->getIntData2(), | |
| 711 | + 'has_actor' => false, | |
| 712 | + 'notify_id' => $oKTNotification->getId(), | |
| 713 | + ); | |
| 714 | + | |
| 715 | + $info['title'] = KTUtil::arrayGet($this->_eventTypeNames, $info['event_type'], 'Subscription alert:') .': ' . $info['object_name']; | |
| 716 | + | |
| 717 | + if ($info['actor_id'] !== null) { | |
| 718 | + $oTempUser = User::get($info['actor_id']); | |
| 719 | + if (PEAR::isError($oTempUser) || ($oTempUser == false)) { | |
| 720 | + // no-act | |
| 721 | + $info['actor'] = null; | |
| 722 | + } else { | |
| 723 | + $info['actor'] = $oTempUser; | |
| 724 | + $info['has_actor'] = true; | |
| 725 | + } | |
| 726 | + } | |
| 727 | + | |
| 728 | + if ($info['object_id'] !== null) { | |
| 729 | + $info['object'] = $this->_getEventObject($info['event_type'], $info['object_id']); | |
| 730 | + } | |
| 731 | + | |
| 732 | + return $info; | |
| 733 | + } | |
| 734 | + | |
| 735 | + // resolve the object type based on the alert type. | |
| 736 | + function _getEventObject($sAlertType, $id) { | |
| 737 | + $t = KTUtil::arrayGet($this->_eventObjectMap, $sAlertType ,''); | |
| 738 | + if ($t == 'document') { | |
| 739 | + $o = Document::get($id); | |
| 740 | + if (PEAR::isError($o) || ($o == false)) { return null; | |
| 741 | + } else { return $o; } | |
| 742 | + } else if ($t == 'folder') { | |
| 743 | + $o = Folder::get($id); | |
| 744 | + if (PEAR::isError($o) || ($o == false)) { return null; | |
| 745 | + } else { return $o; } | |
| 746 | + } else { | |
| 747 | + return null; | |
| 748 | + } | |
| 749 | + } | |
| 750 | + | |
| 751 | + function _getEventObjectType($sAlertType) { | |
| 752 | + return KTUtil::arrayGet($this->_eventObjectMap, $sAlertType ,''); | |
| 753 | + } | |
| 754 | +} | |
| 755 | + | |
| 756 | +?> | |
| 0 | 757 | \ No newline at end of file | ... | ... |
plugins/ktstandard/KTSubscriptions.php
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | require_once(KT_LIB_DIR . '/subscriptions/Subscription.inc'); |
| 4 | -require_once(KT_LIB_DIR . '/subscriptions/SubscriptionEngine.inc'); | |
| 5 | -require_once(KT_LIB_DIR . '/subscriptions/SubscriptionConstants.inc'); | |
| 4 | + | |
| 5 | + | |
| 6 | 6 | require_once(KT_LIB_DIR . '/subscriptions/SubscriptionManager.inc'); |
| 7 | +require_once(KT_LIB_DIR . "/subscriptions/subscriptions.inc.php"); | |
| 7 | 8 | |
| 8 | 9 | require_once(KT_LIB_DIR . '/plugins/pluginregistry.inc.php'); |
| 9 | 10 | require_once(KT_LIB_DIR . '/plugins/plugin.inc.php'); |
| ... | ... | @@ -75,14 +76,14 @@ class KTDocumentSubscriptionAction extends KTDocumentAction { |
| 75 | 76 | var $sName = 'ktstandard.subscription.documentsubscription'; |
| 76 | 77 | var $sDisplayName = 'Subscribe to document'; |
| 77 | 78 | function getInfo() { |
| 78 | - if (Subscription::exists($this->oUser->getID(), $this->oDocument->getID(), SubscriptionConstants::subscriptionType("DocumentSubscription"))) { | |
| 79 | + if (Subscription::exists($this->oUser->getID(), $this->oDocument->getID(), SubscriptionEvent::subTypes('Document'))) { | |
| 79 | 80 | return null; |
| 80 | 81 | } |
| 81 | 82 | return parent::getInfo(); |
| 82 | 83 | } |
| 83 | 84 | |
| 84 | 85 | function do_main() { |
| 85 | - $iSubscriptionType = SubscriptionConstants::subscriptionType("DocumentSubscription"); | |
| 86 | + $iSubscriptionType = SubscriptionEvent::subTypes('Document'); | |
| 86 | 87 | if (Subscription::exists($this->oUser->getId(), $this->oDocument->getId(), $iSubscriptionType)) { |
| 87 | 88 | $_SESSION['KTErrorMessage'][] = _("You are already subscribed to that document"); |
| 88 | 89 | } else { |
| ... | ... | @@ -106,14 +107,14 @@ class KTDocumentUnsubscriptionAction extends KTDocumentAction { |
| 106 | 107 | var $sName = 'ktstandard.subscription.documentunsubscription'; |
| 107 | 108 | var $sDisplayName = 'Unsubscribe from document'; |
| 108 | 109 | function getInfo() { |
| 109 | - if (Subscription::exists($this->oUser->getID(), $this->oDocument->getID(), SubscriptionConstants::subscriptionType("DocumentSubscription"))) { | |
| 110 | + if (Subscription::exists($this->oUser->getID(), $this->oDocument->getID(), SubscriptionEvent::subTypes('Document'))) { | |
| 110 | 111 | return parent::getInfo(); |
| 111 | 112 | } |
| 112 | 113 | return null; |
| 113 | 114 | } |
| 114 | 115 | |
| 115 | 116 | function do_main() { |
| 116 | - $iSubscriptionType = SubscriptionConstants::subscriptionType("DocumentSubscription"); | |
| 117 | + $iSubscriptionType = SubscriptionEvent::subTypes('Document'); | |
| 117 | 118 | if (!Subscription::exists($this->oUser->getId(), $this->oDocument->getId(), $iSubscriptionType)) { |
| 118 | 119 | $_SESSION['KTErrorMessage'][] = _("You were not subscribed to that document"); |
| 119 | 120 | } else { |
| ... | ... | @@ -143,11 +144,12 @@ class KTCheckoutSubscriptionTrigger { |
| 143 | 144 | global $default; |
| 144 | 145 | $oDocument =& $this->aInfo["document"]; |
| 145 | 146 | // fire subscription alerts for the checked out document |
| 146 | - $count = SubscriptionEngine::fireSubscription($oDocument->getId(), SubscriptionConstants::subscriptionAlertType("CheckOutDocument"), | |
| 147 | - SubscriptionConstants::subscriptionType("DocumentSubscription"), | |
| 148 | - array( "folderID" => $oDocument->getFolderID(), | |
| 149 | - "modifiedDocumentName" => $oDocument->getName() )); | |
| 150 | - $default->log->info("checkOutDocumentBL.php fired $count subscription alerts for checked out document " . $oDocument->getName()); | |
| 147 | + | |
| 148 | + // fire subscription alerts for the checked in document | |
| 149 | + $oSubscriptionEvent = new SubscriptionEvent(); | |
| 150 | + $oFolder = Folder::get($oDocument->getFolderID()); | |
| 151 | + $oSubscriptionEvent->CheckoutDocument($oDocument, $oFolder); | |
| 152 | + | |
| 151 | 153 | } |
| 152 | 154 | } |
| 153 | 155 | $oPlugin->registerTrigger('checkout', 'postValidate', 'KTCheckoutSubscriptionTrigger', 'ktstandard.triggers.subscription.checkout'); |
| ... | ... | @@ -165,22 +167,11 @@ class KTDeleteSubscriptionTrigger { |
| 165 | 167 | $oDocument =& $this->aInfo["document"]; |
| 166 | 168 | |
| 167 | 169 | // fire subscription alerts for the deleted document |
| 168 | - $count = SubscriptionEngine::fireSubscription($oDocument->getId(), | |
| 169 | - SubscriptionConstants::subscriptionAlertType("RemoveSubscribedDocument"), | |
| 170 | - SubscriptionConstants::subscriptionType("DocumentSubscription"), | |
| 171 | - array( | |
| 172 | - "folderID" => $oDocument->getFolderID(), | |
| 173 | - "removedDocumentName" => $oDocument->getName(), | |
| 174 | - "folderName" => Folder::getFolderDisplayPath($oDocument->getFolderID()), | |
| 175 | - )); | |
| 176 | - $default->log->info("deleteDocumentBL.php fired $count subscription alerts for removed document " . $oDocument->getName()); | |
| 177 | - | |
| 178 | - // remove all document subscriptions for this document | |
| 179 | - if (SubscriptionManager::removeSubscriptions($oDocument->getId(), SubscriptionConstants::subscriptionType("DocumentSubscription"))) { | |
| 180 | - $default->log->info("deleteDocumentBL.php removed all subscriptions for this document"); | |
| 181 | - } else { | |
| 182 | - $default->log->error("deleteDocumentBL.php couldn't remove document subscriptions"); | |
| 183 | - } | |
| 170 | + | |
| 171 | + // fire subscription alerts for the checked in document | |
| 172 | + $oSubscriptionEvent = new SubscriptionEvent(); | |
| 173 | + $oFolder = Folder::get($oDocument->getFolderID()); | |
| 174 | + $oSubscriptionEvent->RemoveDocument($oDocument, $oFolder); | |
| 184 | 175 | } |
| 185 | 176 | } |
| 186 | 177 | $oPlugin->registerTrigger('delete', 'postValidate', 'KTDeleteSubscriptionTrigger', 'ktstandard.triggers.subscription.delete'); |
| ... | ... | @@ -199,29 +190,10 @@ class KTDocumentMoveSubscriptionTrigger { |
| 199 | 190 | $oOldFolder =& $this->aInfo["old_folder"]; |
| 200 | 191 | $oNewFolder =& $this->aInfo["new_folder"]; |
| 201 | 192 | |
| 202 | - // fire subscription alerts for the moved document (and the folder its in) | |
| 203 | - $count = SubscriptionEngine::fireSubscription($oDocument->getId(), SubscriptionConstants::subscriptionAlertType("MovedDocument"), | |
| 204 | - SubscriptionConstants::subscriptionType("DocumentSubscription"), | |
| 205 | - array( | |
| 206 | - "folderID" => $oOldFolder->getId(), | |
| 207 | - "modifiedDocumentName" => $oDocument->getName(), | |
| 208 | - "oldFolderName" => Folder::getFolderName($oOldFolder->getId()), | |
| 209 | - "newFolderName" => Folder::getFolderName($oNewFolder->getID()), | |
| 210 | - ) | |
| 211 | - ); | |
| 212 | - $default->log->info("moveDocumentBL.php fired $count (folderID=$fFolderID) folder subscription alerts for moved document " . $oDocument->getName()); | |
| 213 | - | |
| 214 | - // fire folder subscriptions for the destination folder | |
| 215 | - $count = SubscriptionEngine::fireSubscription($oNewFolder->getId(), SubscriptionConstants::subscriptionAlertType("MovedDocument"), | |
| 216 | - SubscriptionConstants::subscriptionType("FolderSubscription"), | |
| 217 | - array( | |
| 218 | - "folderID" => $oOldFolder->getId(), | |
| 219 | - "modifiedDocumentName" => $oDocument->getName(), | |
| 220 | - "oldFolderName" => Folder::getFolderName($oOldFolder->getId()), | |
| 221 | - "newFolderName" => Folder::getFolderName($oNewFolder->getId()), | |
| 222 | - ) | |
| 223 | - ); | |
| 224 | - $default->log->info("moveDocumentBL.php fired $count (folderID=$fFolderID) folder subscription alerts for moved document " . $oDocument->getName()); | |
| 193 | + | |
| 194 | + // fire subscription alerts for the checked in document | |
| 195 | + $oSubscriptionEvent = new SubscriptionEvent(); | |
| 196 | + $oSubscriptionEvent->MoveDocument($oDocument, $oNewFolder, $oNewFolder); | |
| 225 | 197 | } |
| 226 | 198 | } |
| 227 | 199 | $oPlugin->registerTrigger('moveDocument', 'postValidate', 'KTDocumentMoveSubscriptionTrigger', 'ktstandard.triggers.subscription.moveDocument'); |
| ... | ... | @@ -238,14 +210,10 @@ class KTArchiveSubscriptionTrigger { |
| 238 | 210 | global $default; |
| 239 | 211 | $oDocument =& $this->aInfo["document"]; |
| 240 | 212 | |
| 241 | - $count = SubscriptionEngine::fireSubscription($fDocumentID, SubscriptionConstants::subscriptionAlertType("ArchivedDocument"), | |
| 242 | - SubscriptionConstants::subscriptionType("DocumentSubscription"), | |
| 243 | - array( | |
| 244 | - "folderID" => $oDocument->getFolderID(), | |
| 245 | - "modifiedDocumentName" => $oDocument->getName(), | |
| 246 | - "folderName" => $oDocument->getFolderName(), | |
| 247 | - )); | |
| 248 | - $default->log->info("archiveDocumentBL.php fired $count subscription alerts for archived document " . $oDocument->getName()); | |
| 213 | + // fire subscription alerts for the checked in document | |
| 214 | + $oSubscriptionEvent = new SubscriptionEvent(); | |
| 215 | + $oFolder = Folder::get($oDocument->getFolderID()); | |
| 216 | + $oSubscriptionEvent->ArchiveDocument($oDocument, $oFolder); | |
| 249 | 217 | } |
| 250 | 218 | } |
| 251 | 219 | $oPlugin->registerTrigger('archive', 'postValidate', 'KTArchiveSubscriptionTrigger', 'ktstandard.triggers.subscription.archive'); |
| ... | ... | @@ -256,7 +224,7 @@ class KTFolderSubscriptionAction extends KTFolderAction { |
| 256 | 224 | var $sName = 'ktstandard.subscription.foldersubscription'; |
| 257 | 225 | var $sDisplayName = 'Subscribe to folder'; |
| 258 | 226 | function getInfo() { |
| 259 | - if (Subscription::exists($this->oUser->getID(), $this->oFolder->getID(), SubscriptionConstants::subscriptionType("FolderSubscription"))) { | |
| 227 | + if (Subscription::exists($this->oUser->getID(), $this->oFolder->getID(), SubscriptionEvent::subTypes('Folder'))) { | |
| 260 | 228 | // KTFolderUnsubscriptionAction will display instead. |
| 261 | 229 | return null; |
| 262 | 230 | } |
| ... | ... | @@ -264,7 +232,7 @@ class KTFolderSubscriptionAction extends KTFolderAction { |
| 264 | 232 | } |
| 265 | 233 | |
| 266 | 234 | function do_main() { |
| 267 | - $iSubscriptionType = SubscriptionConstants::subscriptionType("FolderSubscription"); | |
| 235 | + $iSubscriptionType = SubscriptionEvent::subTypes('Folder'); | |
| 268 | 236 | if (Subscription::exists($this->oUser->getId(), $this->oFolder->getId(), $iSubscriptionType)) { |
| 269 | 237 | $_SESSION['KTErrorMessage'][] = _("You are already subscribed to that document"); |
| 270 | 238 | } else { |
| ... | ... | @@ -289,14 +257,14 @@ class KTFolderUnsubscriptionAction extends KTFolderAction { |
| 289 | 257 | var $sDisplayName = 'Unsubscribe from folder'; |
| 290 | 258 | |
| 291 | 259 | function getInfo() { |
| 292 | - if (Subscription::exists($this->oUser->getID(), $this->oFolder->getID(), SubscriptionConstants::subscriptionType("FolderSubscription"))) { | |
| 260 | + if (Subscription::exists($this->oUser->getID(), $this->oFolder->getID(), SubscriptionEvent::subTypes('Folder'))) { | |
| 293 | 261 | return parent::getInfo(); |
| 294 | 262 | } |
| 295 | 263 | return null; |
| 296 | 264 | } |
| 297 | 265 | |
| 298 | 266 | function do_main() { |
| 299 | - $iSubscriptionType = SubscriptionConstants::subscriptionType("FolderSubscription"); | |
| 267 | + $iSubscriptionType = SubscriptionEvent::subTypes('Folder'); | |
| 300 | 268 | if (!Subscription::exists($this->oUser->getId(), $this->oFolder->getId(), $iSubscriptionType)) { |
| 301 | 269 | $_SESSION['KTErrorMessage'][] = _("You were not subscribed to that folder"); |
| 302 | 270 | } else { |
| ... | ... | @@ -320,9 +288,9 @@ class KTSubscriptionManagePage extends KTStandardDispatcher { |
| 320 | 288 | function do_main() { |
| 321 | 289 | $this->aBreadcrumbs[] = array("name" => _("Subscription Management")); |
| 322 | 290 | $aFolderSubscriptions = SubscriptionManager::retrieveUserSubscriptions( |
| 323 | - $this->oUser->getId(), SubscriptionConstants::subscriptionType("FolderSubscription")); | |
| 291 | + $this->oUser->getId(), SubscriptionEvent::subTypes('Folder')); | |
| 324 | 292 | $aDocumentSubscriptions = SubscriptionManager::retrieveUserSubscriptions( |
| 325 | - $this->oUser->getId(), SubscriptionConstants::subscriptionType("DocumentSubscription")); | |
| 293 | + $this->oUser->getId(), SubscriptionEvent::subTypes('Document')); | |
| 326 | 294 | $bNoSubscriptions = ((count($aFolderSubscriptions) == 0) && (count($aDocumentSubscriptions) == 0)) ? true : false; |
| 327 | 295 | |
| 328 | 296 | $oTemplate = $this->oValidator->validateTemplate('ktstandard/subscriptions/manage'); |
| ... | ... | @@ -347,7 +315,7 @@ class KTSubscriptionManagePage extends KTStandardDispatcher { |
| 347 | 315 | |
| 348 | 316 | if (!empty($foldersubscriptions)) { |
| 349 | 317 | foreach ($foldersubscriptions as $iSubscriptionId) { |
| 350 | - $oSubscription = Subscription::get($iSubscriptionId, SubscriptionConstants::subscriptionType('FolderSubscription')); | |
| 318 | + $oSubscription = Subscription::get($iSubscriptionId, SubscriptionEvent::subTypes('Folder')); | |
| 351 | 319 | if ($oSubscription) { |
| 352 | 320 | $oSubscription->delete(); |
| 353 | 321 | $iSuccesses++; |
| ... | ... | @@ -359,7 +327,7 @@ class KTSubscriptionManagePage extends KTStandardDispatcher { |
| 359 | 327 | |
| 360 | 328 | if (!empty($documentsubscriptions)) { |
| 361 | 329 | foreach ($documentsubscriptions as $iSubscriptionId) { |
| 362 | - $oSubscription = Subscription::get($iSubscriptionId, SubscriptionConstants::subscriptionType('DocumentSubscription')); | |
| 330 | + $oSubscription = Subscription::get($iSubscriptionId, SubscriptionEvent::subTypes('Document')); | |
| 363 | 331 | if ($oSubscription) { |
| 364 | 332 | $oSubscription->delete(); |
| 365 | 333 | $iSuccesses++; | ... | ... |
templates/kt3/notifications/subscriptions.smarty renamed to templates/kt3/notifications/subscriptions.AddDocument.smarty
| 1 | 1 | <dt class="actionitem subscription">{$info.title}</dt> |
| 2 | 2 | <dd class="actionmessage"> |
| 3 | 3 | <!-- could break this up. --> |
| 4 | -{if ($info.event_type == 'AddDocument')} | |
| 5 | 4 | The document "{$info.object_name}" was added{if ($info.location_name !== null)} to "{$info.location_name}"{/if}. |
| 6 | 5 | <div class="actionoptions"> |
| 7 | - <a href="{$rootUrl}/notify.php?id={$info.notify_id}">{i18n}Read Document{/i18n}</a> | | |
| 8 | - <a href="{$rootUrl}/notify.php?id={$info.notify_id}¬ify_action=clear">{i18n}Clear Alert{/i18n}</a> | |
| 9 | - </div> | |
| 10 | -{else} <!-- fallback. --> | |
| 11 | -{/if} | |
| 12 | - <div class="actionoptions"> | |
| 13 | - <a href="{$rootUrl}/notify.php?id={$info.notify_id}¬ify_action=clear">{i18n}Clear Alert{/i18n}</a> | |
| 6 | + <a href="{$absoluteRootUrl}/notify.php?id={$info.notify_id}">{i18n}Read Document{/i18n}</a> | | |
| 7 | + <a href="{$absoluteRootUrl}/notify.php?id={$info.notify_id}¬ify_action=clear">{i18n}Clear Alert{/i18n}</a> | |
| 14 | 8 | </div> |
| 15 | 9 | </dd> | ... | ... |
templates/kt3/notifications/subscriptions.generic.smarty
0 → 100644