Commit 053123756368f8fac853cde41fc6f30b38a6a641
1 parent
66b692f7
This stuff has moved into the Subscriptions plugin in ktstandard.
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4133 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
0 additions
and
243 deletions
presentation/lookAndFeel/knowledgeTree/subscriptions/addSubscriptionBL.php deleted
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -require_once("../../../../config/dmsDefaults.php"); | ||
| 4 | - | ||
| 5 | -KTUtil::extractGPC('fConfirmed', 'fDocumentID', 'fFolderID'); | ||
| 6 | - | ||
| 7 | -require_once("$default->fileSystemRoot/lib/subscriptions/Subscription.inc"); | ||
| 8 | -require_once("$default->fileSystemRoot/lib/subscriptions/SubscriptionManager.inc"); | ||
| 9 | -require_once("$default->fileSystemRoot/presentation/Html.inc"); | ||
| 10 | -/** | ||
| 11 | - * $Id$ | ||
| 12 | - * | ||
| 13 | - * Adds a document or folder subscription for a user. | ||
| 14 | - * | ||
| 15 | - * Querystring variables | ||
| 16 | - * --------------------- | ||
| 17 | - * fFolderID - the folder to subscribe the current user to (optional) | ||
| 18 | - * fDocumentID - the document to subscribe the current user to (optional) | ||
| 19 | - * | ||
| 20 | - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com | ||
| 21 | - * | ||
| 22 | - * This program is free software; you can redistribute it and/or modify | ||
| 23 | - * it under the terms of the GNU General Public License as published by | ||
| 24 | - * the Free Software Foundation; either version 2 of the License, or | ||
| 25 | - * (at your option) any later version. | ||
| 26 | - * | ||
| 27 | - * This program is distributed in the hope that it will be useful, | ||
| 28 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 29 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 30 | - * GNU General Public License for more details. | ||
| 31 | - * | ||
| 32 | - * You should have received a copy of the GNU General Public License | ||
| 33 | - * along with this program; if not, write to the Free Software | ||
| 34 | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 35 | - * | ||
| 36 | - * @version $Revision$ | ||
| 37 | - * @author Michael Joseph <michael@jamwarehouse.com>, Jam Warehouse (Pty) Ltd, South Africa | ||
| 38 | - * @package subscriptions | ||
| 39 | - */ | ||
| 40 | - | ||
| 41 | -/** | ||
| 42 | - * Checks if the user has read permission on the subscription content | ||
| 43 | - * | ||
| 44 | - * @param integer the id of the subscription content | ||
| 45 | - * @param integer the subscription type | ||
| 46 | - */ | ||
| 47 | -function checkPermission($iExternalID, $iSubscriptionType) { | ||
| 48 | - if ($iSubscriptionType == SubscriptionConstants::subscriptionType("FolderSubscription")) { | ||
| 49 | - $oFolder = Folder::get($iExternalID); | ||
| 50 | - return Permission::userHasFolderReadPermission($oFolder); | ||
| 51 | - } else { | ||
| 52 | - $oDocument = Document::get($iExternalID); | ||
| 53 | - return Permission::userHasDocumentReadPermission($oDocument); | ||
| 54 | - } | ||
| 55 | -} | ||
| 56 | -// only if we have a valid session | ||
| 57 | -if (checkSession()) { | ||
| 58 | - | ||
| 59 | - require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); | ||
| 60 | - require_once("subscriptionUI.inc"); | ||
| 61 | - require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc"); | ||
| 62 | - require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc"); | ||
| 63 | - | ||
| 64 | - $oPatternCustom = & new PatternCustom(); | ||
| 65 | - | ||
| 66 | - // retrieve variables | ||
| 67 | - if ($fFolderID || $fDocumentID) { | ||
| 68 | - $iUserID = $_SESSION["userID"]; | ||
| 69 | - // if fFolderID was passed in then its a folder subscription | ||
| 70 | - if ($fFolderID) { | ||
| 71 | - $iExternalID = $fFolderID; | ||
| 72 | - $iSubscriptionType = SubscriptionConstants::subscriptionType("FolderSubscription"); | ||
| 73 | - // or a document subscription | ||
| 74 | - } else if ($fDocumentID) { | ||
| 75 | - $iExternalID = $fDocumentID; | ||
| 76 | - $iSubscriptionType = SubscriptionConstants::subscriptionType("DocumentSubscription"); | ||
| 77 | - } | ||
| 78 | - | ||
| 79 | - if (checkPermission($iExternalID, $iSubscriptionType)) { | ||
| 80 | - | ||
| 81 | - if (!Subscription::exists($iUserID, $iExternalID, $iSubscriptionType)) { | ||
| 82 | - $oSubscription = new Subscription($iUserID, $iExternalID, $iSubscriptionType); | ||
| 83 | - // if we've confirmed the subscription | ||
| 84 | - if ($fConfirmed) { | ||
| 85 | - // add it | ||
| 86 | - if ($oSubscription->create()) { | ||
| 87 | - $default->log->info("addSubscriptionBL.php added subscription for userID=$iUserID, subType=$iSubscriptionType, id=$iExternalID"); | ||
| 88 | - // redirect to viewFolder or viewDocument | ||
| 89 | - $default->log->info("redirecting to " . $oSubscription->getContentUrl()); | ||
| 90 | - | ||
| 91 | - redirect($oSubscription->getContentUrl()); | ||
| 92 | - } else { | ||
| 93 | - // error creating subscription | ||
| 94 | - $default->log->error("addSubscriptionBL.php error creating subscription for userID=$iUserID, subType=$iSubscriptionType, id=$iExternalID"); | ||
| 95 | - $oPatternCustom->setHtml(renderErrorPage(_("An error occurred while creating this subscription"))); | ||
| 96 | - } | ||
| 97 | - } else { | ||
| 98 | - // ask for confirmation | ||
| 99 | - $oPatternCustom->setHtml(renderAddConfirmationPage($oSubscription)); | ||
| 100 | - } | ||
| 101 | - } else { | ||
| 102 | - // you're already subscribed | ||
| 103 | - $oPatternCustom->setHtml(renderErrorPage(_("You are already subscribed to this folder or document"))); | ||
| 104 | - } | ||
| 105 | - | ||
| 106 | - require_once("../../../webpageTemplate.inc"); | ||
| 107 | - $main->setCentralPayload($oPatternCustom); | ||
| 108 | - $main->setFormAction($_SERVER["PHP_SELF"]); | ||
| 109 | - $main->render(); | ||
| 110 | - | ||
| 111 | - } else { | ||
| 112 | - // no permission | ||
| 113 | - $oPatternCustom->setHtml(renderErrorPage(_("You don't have permission to subscribe to this folder or document"))); | ||
| 114 | - require_once("../../../webpageTemplate.inc"); | ||
| 115 | - $main->setCentralPayload($oPatternCustom); | ||
| 116 | - $main->render(); | ||
| 117 | - } | ||
| 118 | - } else { | ||
| 119 | - // neither document or folder chosen | ||
| 120 | - $oPatternCustom->setHtml(renderErrorPage(_("You haven't chosen a folder or a document to subscribe to"))); | ||
| 121 | - require_once("../../../webpageTemplate.inc"); | ||
| 122 | - $main->setCentralPayload($oPatternCustom); | ||
| 123 | - $main->render(); | ||
| 124 | - } | ||
| 125 | -} | ||
| 126 | -?> |
presentation/lookAndFeel/knowledgeTree/subscriptions/removeSubscriptionBL.php deleted
| 1 | -<?php | ||
| 2 | - | ||
| 3 | -require_once("../../../../config/dmsDefaults.php"); | ||
| 4 | - | ||
| 5 | -KTUtil::extractGPC('fConfirmed', 'fDocumentID', 'fDocumentIDs', 'fFolderID', 'fFolderIDs'); | ||
| 6 | - | ||
| 7 | -require_once("$default->fileSystemRoot/lib/subscriptions/Subscription.inc"); | ||
| 8 | -require_once("$default->fileSystemRoot/lib/subscriptions/SubscriptionManager.inc"); | ||
| 9 | -require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); | ||
| 10 | -require_once("subscriptionUI.inc"); | ||
| 11 | -require_once("$default->fileSystemRoot/presentation/Html.inc"); | ||
| 12 | -/** | ||
| 13 | - * $Id$ | ||
| 14 | - * | ||
| 15 | - * Removes a document or folder subscription for a user. | ||
| 16 | - * | ||
| 17 | - * Querystring variables | ||
| 18 | - * --------------------- | ||
| 19 | - * fFolderID - the folder to subscribe the current user to (optional) | ||
| 20 | - * fDocumentID - the document to subscribe the current user to (optional) | ||
| 21 | - * | ||
| 22 | - * Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com | ||
| 23 | - * | ||
| 24 | - * This program is free software; you can redistribute it and/or modify | ||
| 25 | - * it under the terms of the GNU General Public License as published by | ||
| 26 | - * the Free Software Foundation; either version 2 of the License, or | ||
| 27 | - * (at your option) any later version. | ||
| 28 | - * | ||
| 29 | - * This program is distributed in the hope that it will be useful, | ||
| 30 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 31 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 32 | - * GNU General Public License for more details. | ||
| 33 | - * | ||
| 34 | - * You should have received a copy of the GNU General Public License | ||
| 35 | - * along with this program; if not, write to the Free Software | ||
| 36 | - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 37 | - * | ||
| 38 | - * @version $Revision$ | ||
| 39 | - * @author Michael Joseph <michael@jamwarehouse.com>, Jam Warehouse (Pty) Ltd, South Africa | ||
| 40 | - * @package subscriptions | ||
| 41 | - */ | ||
| 42 | - | ||
| 43 | -// only if we have a valid session | ||
| 44 | -if (checkSession()) { | ||
| 45 | - | ||
| 46 | - $oPatternCustom = & new PatternCustom(); | ||
| 47 | - | ||
| 48 | - // retrieve variables | ||
| 49 | - if ($fFolderID || $fDocumentID) { | ||
| 50 | - $iUserID = $_SESSION["userID"]; | ||
| 51 | - // if fFolderID was passed in then its a folder subscription | ||
| 52 | - if ($fFolderID) { | ||
| 53 | - $iExternalID = $fFolderID; | ||
| 54 | - $iSubscriptionType = SubscriptionConstants::subscriptionType("FolderSubscription"); | ||
| 55 | - // or a document subscription | ||
| 56 | - } else if ($fDocumentID) { | ||
| 57 | - $iExternalID = $fDocumentID; | ||
| 58 | - $iSubscriptionType = SubscriptionConstants::subscriptionType("DocumentSubscription"); | ||
| 59 | - } | ||
| 60 | - if (Subscription::exists($iUserID, $iExternalID, $iSubscriptionType)) { | ||
| 61 | - $oSubscription = & Subscription::getByIDs($iUserID, $iExternalID, $iSubscriptionType); | ||
| 62 | - // if we've confirmed the deletion | ||
| 63 | - if ($fConfirmed) { | ||
| 64 | - // remove it | ||
| 65 | - if ($oSubscription->delete()) { | ||
| 66 | - $default->log->info("removeSubscriptionBL.php removed subscription for userID=$iUserID, subType=$iSubscriptionType, id=$iExternalID"); | ||
| 67 | - // redirect to viewFolder or viewDocument | ||
| 68 | - redirect($oSubscription->getContentUrl()); | ||
| 69 | - } else { | ||
| 70 | - // error removing subscription | ||
| 71 | - $default->log->error("removeSubscriptionBL.php error removing subscription for userID=$iUserID, subType=$iSubscriptionType, id=$iExternalID"); | ||
| 72 | - $oPatternCustom->setHtml(renderErrorPage(_("An error occurred while removing this subscription."))); | ||
| 73 | - } | ||
| 74 | - } else { | ||
| 75 | - // ask for confirmation | ||
| 76 | - $default->log->info("sub=" . arrayToString($oSubscription)); | ||
| 77 | - $oPatternCustom->setHtml(renderRemoveConfirmationPage($oSubscription)); | ||
| 78 | - } | ||
| 79 | - } else { | ||
| 80 | - // you're not subscribed | ||
| 81 | - $default->log->error("removeSubscriptionBL.php not subscribed ($iUserID, $iExternalID, $iSubscriptionType)"); | ||
| 82 | - $oPatternCustom->setHtml(renderErrorPage(_("You aren't subscribed to this folder or document"))); | ||
| 83 | - } | ||
| 84 | - | ||
| 85 | - require_once("../../../webpageTemplate.inc"); | ||
| 86 | - $main->setCentralPayload($oPatternCustom); | ||
| 87 | - $main->setFormAction($_SERVER["PHP_SELF"]); | ||
| 88 | - $main->render(); | ||
| 89 | - | ||
| 90 | - } else if ($fDocumentIDs || $fFolderIDs) { | ||
| 91 | - // multiple unsubscribes | ||
| 92 | - | ||
| 93 | - // unsubscribe folders | ||
| 94 | - | ||
| 95 | - // unsubscribe documents | ||
| 96 | - | ||
| 97 | - $oSubscription = & Subscription::getByIDs($iUserID, $iExternalID, $iSubscriptionType); | ||
| 98 | - // remove it | ||
| 99 | - if ($oSubscription->delete()) { | ||
| 100 | - $default->log->info("removeSubscriptionBL.php removed subscription for userID=$iUserID, subType=$iSubscriptionType, id=$iExternalID"); | ||
| 101 | - // redirect to viewFolder or viewDocument | ||
| 102 | - redirect($oSubscription->getContentUrl()); | ||
| 103 | - } else { | ||
| 104 | - // error removing subscription | ||
| 105 | - $default->log->error("removeSubscriptionBL.php error removing subscription for userID=$iUserID, subType=$iSubscriptionType, id=$iExternalID"); | ||
| 106 | - $oPatternCustom->setHtml(renderErrorPage(_("An error occurred while removing this subscription."))); | ||
| 107 | - } | ||
| 108 | - | ||
| 109 | - } else { | ||
| 110 | - // neither document or folder chosen | ||
| 111 | - $oPatternCustom->setHtml(renderErrorPage(_("You haven't chosen a folder or a document to unsubscribe from"))); | ||
| 112 | - require_once("../../../webpageTemplate.inc"); | ||
| 113 | - $main->setCentralPayload($oPatternCustom); | ||
| 114 | - $main->render(); | ||
| 115 | - } | ||
| 116 | -} | ||
| 117 | -?> |