From c8c7ae0d05e107014d3627deace64bebb4a1f89c Mon Sep 17 00:00:00 2001 From: kevin_fourie Date: Sat, 2 Aug 2008 15:22:03 +0000 Subject: [PATCH] Merged in from STABLE trunk... --- i18n/knowledgeTree.pot | 163 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------ plugins/MyDropDocumentsPlugin/MyDropDocumentsDashlet.php | 158 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------- plugins/MyDropDocumentsPlugin/MyDropDocumentsPage.php | 1318 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- plugins/ktstandard/KTWebDAVDashletPlugin.php | 2 +- 4 files changed, 860 insertions(+), 781 deletions(-) diff --git a/i18n/knowledgeTree.pot b/i18n/knowledgeTree.pot index 72c6d87..5f685f9 100644 --- a/i18n/knowledgeTree.pot +++ b/i18n/knowledgeTree.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2008-07-30 17:05+0200\n" +"POT-Creation-Date: 2008-08-02 17:09+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -16,22 +16,22 @@ msgstr "" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: lib/util/ktutil.inc:154 +#: lib/util/ktutil.inc:162 #, php-format msgid " %d day(s)" msgstr "" -#: lib/util/ktutil.inc:155 +#: lib/util/ktutil.inc:163 #, php-format msgid " %d hour(s)" msgstr "" -#: lib/util/ktutil.inc:156 +#: lib/util/ktutil.inc:164 #, php-format msgid " %d minute(s)" msgstr "" -#: lib/util/ktutil.inc:157 +#: lib/util/ktutil.inc:165 #, php-format msgid " %d second(s)" msgstr "" @@ -45,6 +45,10 @@ msgstr "" msgid " Note: group is set as unit administrator, but is not assigned to a unit." msgstr "" +#: plugins/MyDropDocumentsPlugin/MyDropDocumentsPage.php:319 +msgid " View All" +msgstr "" + #: lib/browse/Criteria.inc:964 msgid " ago" msgstr "" @@ -264,7 +268,7 @@ msgstr "" msgid "(Closed at metadata version: #ver#)" msgstr "" -#: config/dmsDefaults.php:601 +#: config/dmsDefaults.php:602 msgid "(Community Edition)" msgstr "" @@ -321,6 +325,11 @@ msgid "" "

" msgstr "" +#: plugins/MyDropDocumentsPlugin/MyDropDocumentsPage.php:204 +#: plugins/MyDropDocumentsPlugin/MyDropDocumentsPage.php:248 +msgid " You do not have any dropped documents


" +msgstr "" + #: i18n/templates.c:2540 msgid "Deleted, which completely removes the selected items from the lookup. Note that this may not be possible if some other aspect of the system depends on a particular lookup." msgstr "" @@ -1553,7 +1562,7 @@ msgstr "" msgid "Available Workflows" msgstr "" -#: lib/util/ktutil.inc:205 +#: lib/util/ktutil.inc:213 msgid "B" msgstr "" @@ -2189,7 +2198,8 @@ msgstr "" msgid "Clicking on a given behaviour below will show you which fields and values can be selected when the clicked behaviour is active." msgstr "" -#: plugins/ktcore/admin/configSettings.php:153 +#: plugins/ktcore/admin/configSettings.php:277 +#: plugins/ktcore/admin/configSettings.php:281 #: plugins/ktcore/KTCorePlugin.php:334 msgid "Client Tools Settings" msgstr "" @@ -2569,16 +2579,16 @@ msgstr "" msgid "Could change permission on exec script: " msgstr "" -#: setup/upgrade.php:297 +#: setup/upgrade.php:301 msgid "Could not authenticate administrative user" msgstr "" -#: lib/util/ktutil.inc:596 lib/util/ktutil.inc:627 lib/util/ktutil.inc:632 +#: lib/util/ktutil.inc:604 lib/util/ktutil.inc:635 lib/util/ktutil.inc:640 #, php-format msgid "Could not copy to destination: %s" msgstr "" -#: lib/util/ktutil.inc:503 +#: lib/util/ktutil.inc:511 #, php-format msgid "Could not create destination directory: %s" msgstr "" @@ -2677,12 +2687,12 @@ msgstr "" msgid "Could not find user in LDAP server" msgstr "" -#: lib/util/ktutil.inc:605 +#: lib/util/ktutil.inc:613 #, php-format msgid "Could not move to destination: %s" msgstr "" -#: lib/util/ktutil.inc:499 +#: lib/util/ktutil.inc:507 #, php-format msgid "Could not open source directory: %s" msgstr "" @@ -2706,7 +2716,7 @@ msgstr "" msgid "Could not remove link" msgstr "" -#: lib/util/ktutil.inc:600 +#: lib/util/ktutil.inc:608 #, php-format msgid "Could not remove source: %s" msgstr "" @@ -2737,17 +2747,17 @@ msgstr "" msgid "Couldn't create folder" msgstr "" -#: lib/util/ktutil.inc:589 +#: lib/util/ktutil.inc:597 #, php-format msgid "Couldn't move file to destination: %s" msgstr "" -#: lib/util/ktutil.inc:584 lib/util/ktutil.inc:622 +#: lib/util/ktutil.inc:592 lib/util/ktutil.inc:630 #, php-format msgid "Couldn't stat destination location: %s" msgstr "" -#: lib/util/ktutil.inc:580 lib/util/ktutil.inc:618 +#: lib/util/ktutil.inc:588 lib/util/ktutil.inc:626 #, php-format msgid "Couldn't stat source file: %s" msgstr "" @@ -3074,6 +3084,10 @@ msgstr "" msgid "Date Created Delta" msgstr "" +#: plugins/MyDropDocumentsPlugin/MyDropDocumentsPage.php:260 +msgid "Date Dropped" +msgstr "" + #: lib/browse/Criteria.inc:713 msgid "Date Modified" msgstr "" @@ -3267,11 +3281,11 @@ msgstr "" msgid "Description" msgstr "" -#: lib/util/ktutil.inc:480 +#: lib/util/ktutil.inc:488 msgid "Destination directory already exists." msgstr "" -#: lib/util/ktutil.inc:494 +#: lib/util/ktutil.inc:502 msgid "Destination of move is within source" msgstr "" @@ -3379,6 +3393,7 @@ msgstr "" msgid "Do you still wish to continue with deleting this item?" msgstr "" +#: plugins/MyDropDocumentsPlugin/MyDropDocumentsPage.php:259 #: i18n/templates.c:476 i18n/templates.c:578 i18n/templates.c:677 #: i18n/templates.c:755 i18n/templates.c:845 i18n/templates.c:911 #: i18n/templates.c:7103 @@ -3824,6 +3839,7 @@ msgstr "" msgid "Document must be a symbolic link entity" msgstr "" +#: plugins/MyDropDocumentsPlugin/MyDropDocumentsPage.php:516 #: plugins/network/extendedtransactioninfo/adminReports.php:243 #: plugins/network/extendedtransactioninfo/latestchanges.php:78 #: plugins/network/extendedtransactioninfo/latestchanges.php:91 @@ -4409,7 +4425,8 @@ msgstr "" msgid "Email Plugin" msgstr "" -#: plugins/ktcore/admin/configSettings.php:173 +#: plugins/ktcore/admin/configSettings.php:291 +#: plugins/ktcore/admin/configSettings.php:295 #: plugins/ktcore/KTCorePlugin.php:322 msgid "Email Settings" msgstr "" @@ -4590,6 +4607,39 @@ msgstr "" msgid "Error updating user" msgstr "" +#: plugins/MyDropDocumentsPlugin/MyDropDocumentsPage.php:480 +msgid "Error: Cannot create WorkSpaceOwner role allocation on personal folder" +msgstr "" + +#: plugins/MyDropDocumentsPlugin/MyDropDocumentsPage.php:92 +#: plugins/MyDropDocumentsPlugin/MyDropDocumentsPage.php:136 +msgid "Error: Failed to create WorkSpaceOwner Role" +msgstr "" + +#: plugins/MyDropDocumentsPlugin/MyDropDocumentsPage.php:218 +msgid "Error: WorkSpaceOwner Role does not exist" +msgstr "" + +#: plugins/MyDropDocumentsPlugin/MyDropDocumentsPage.php:177 +msgid "Error: WorkSpaceOwner Role not setup, cannot assign to Personal Folder" +msgstr "" + +#: plugins/MyDropDocumentsPlugin/MyDropDocumentsPage.php:383 +msgid "Error: cannot create WorkSpaceOwner role allocation" +msgstr "" + +#: plugins/MyDropDocumentsPlugin/MyDropDocumentsPage.php:424 +msgid "Error: cannot find WorkSpaceOwner role allocation" +msgstr "" + +#: plugins/MyDropDocumentsPlugin/MyDropDocumentsPage.php:191 +msgid "Error: cannot set personal folder role permissions: more than one role named 'WorkSpaceOwner' exists" +msgstr "" + +#: plugins/MyDropDocumentsPlugin/MyDropDocumentsPage.php:109 +msgid "Error: cannot set user role permissions: more than one role named 'WorkSpaceOwner' exists" +msgstr "" + #: i18n/templates.c:3596 msgid "Estimated completion time:" msgstr "" @@ -4989,6 +5039,7 @@ msgid "Failure resolving child folder with id = %d." msgstr "" #: plugins/ktcore/KTPermissions.php:787 +#: plugins/MyDropDocumentsPlugin/MyDropDocumentsPage.php:631 msgid "Failure to generate folderlisting." msgstr "" @@ -5365,7 +5416,7 @@ msgstr "" msgid "Full-text Content Indexing" msgstr "" -#: lib/util/ktutil.inc:193 +#: lib/util/ktutil.inc:201 msgid "GB" msgstr "" @@ -5377,7 +5428,8 @@ msgstr "" msgid "General Metadata" msgstr "" -#: plugins/ktcore/admin/configSettings.php:191 +#: plugins/ktcore/admin/configSettings.php:305 +#: plugins/ktcore/admin/configSettings.php:309 #: plugins/ktcore/KTCorePlugin.php:338 msgid "General Settings" msgstr "" @@ -5841,7 +5893,7 @@ msgstr "" msgid "Index Date" msgstr "" -#: plugins/ktcore/KTDashlets.php:221 +#: plugins/ktcore/KTDashlets.php:226 msgid "Indexer Status" msgstr "" @@ -5926,7 +5978,8 @@ msgstr "" msgid "Inter-document linking" msgstr "" -#: plugins/ktcore/admin/configSettings.php:210 +#: plugins/ktcore/admin/configSettings.php:319 +#: plugins/ktcore/admin/configSettings.php:323 #: plugins/ktcore/KTCorePlugin.php:342 msgid "Internationalisation Settings" msgstr "" @@ -6118,7 +6171,7 @@ msgstr "" msgid "Item updated" msgstr "" -#: plugins/ktcore/KTDashlets.php:135 plugins/ktcore/KTMiscPages.php:82 +#: plugins/ktcore/KTDashlets.php:140 plugins/ktcore/KTMiscPages.php:82 #: i18n/templates.c:2375 msgid "Items that require your attention" msgstr "" @@ -6147,7 +6200,7 @@ msgstr "" msgid "Jump To Document" msgstr "" -#: lib/util/ktutil.inc:201 +#: lib/util/ktutil.inc:209 msgid "KB" msgstr "" @@ -6474,7 +6527,7 @@ msgstr "" msgid "Lucene Migration Status" msgstr "" -#: lib/util/ktutil.inc:197 +#: lib/util/ktutil.inc:205 msgid "MB" msgstr "" @@ -6482,7 +6535,7 @@ msgstr "" msgid "MD5 Checksum of files (used to ensure files have not been tampered with)" msgstr "" -#: plugins/ktcore/KTDashlets.php:288 +#: plugins/ktcore/KTDashlets.php:293 msgid "Mail Server Status" msgstr "" @@ -6961,6 +7014,14 @@ msgstr "" msgid "Must select a field to edit." msgstr "" +#: plugins/MyDropDocumentsPlugin/MyDropDocumentsPlugin.php:41 +msgid "My Drop Documents" +msgstr "" + +#: plugins/MyDropDocumentsPlugin/MyDropDocumentsDashlet.php:44 +msgid "My Dropped Documents" +msgstr "" + #: plugins/search2/MigrationDashlet.php:81 #: search2/indexing/indexerCore.inc.php:927 #: search2/indexing/indexerCore.inc.php:941 i18n/templates.c:1139 @@ -7260,7 +7321,7 @@ msgstr "" msgid "No body provided" msgstr "" -#: lib/templating/smartytemplate.inc.php:328 +#: lib/templating/smartytemplate.inc.php:330 msgid "No breadcrumbs available" msgstr "" @@ -7781,7 +7842,7 @@ msgstr "" msgid "No workflow selected." msgstr "" -#: lib/util/ktutil.inc:658 lib/util/ktutil.inc:665 lib/util/ktutil.inc:678 +#: lib/util/ktutil.inc:666 lib/util/ktutil.inc:673 lib/util/ktutil.inc:686 msgid "Non-entity object" msgstr "" @@ -7797,7 +7858,7 @@ msgstr "" msgid "Non-true and non-error return value" msgstr "" -#: lib/templating/smartytemplate.inc.php:199 +#: lib/templating/smartytemplate.inc.php:201 #: plugins/ktcore/admin/documentFieldsv2.php:235 #: plugins/rssplugin/KTrss.inc.php:362 msgid "None" @@ -8110,7 +8171,7 @@ msgstr "" msgid "Ownership changed." msgstr "" -#: lib/util/ktutil.inc:185 +#: lib/util/ktutil.inc:193 msgid "PB" msgstr "" @@ -8884,6 +8945,10 @@ msgstr "" msgid "Recently Added/Changed Documents" msgstr "" +#: plugins/MyDropDocumentsPlugin/MyDropDocumentsPage.php:254 +msgid "Recently Dropped Documents" +msgstr "" + #: plugins/network/userhistory/UserHistoryDashlet.inc.php:34 msgid "Recently Viewed Items" msgstr "" @@ -9430,7 +9495,8 @@ msgstr "" msgid "Search and Indexing" msgstr "" -#: plugins/ktcore/admin/configSettings.php:229 +#: plugins/ktcore/admin/configSettings.php:333 +#: plugins/ktcore/admin/configSettings.php:337 #: plugins/ktcore/KTCorePlugin.php:240 plugins/ktcore/KTCorePlugin.php:330 msgid "Search and Indexing Settings" msgstr "" @@ -10171,7 +10237,7 @@ msgstr "" msgid "System Temporary Folder" msgstr "" -#: lib/util/ktutil.inc:189 +#: lib/util/ktutil.inc:197 msgid "TB" msgstr "" @@ -10385,6 +10451,10 @@ msgstr "" msgid "The condition required for this trigger has been deleted, so it is always available." msgstr "" +#: plugins/ktcore/admin/configSettings.php:233 +msgid "The configuration settings have been updated." +msgstr "" + #: plugins/ktcore/folder/addDocument.php:120 msgid "The contents of the document to be added to the document management system." msgstr "" @@ -11932,6 +12002,10 @@ msgstr "" msgid "Unable to find workflow trigger: %s" msgstr "" +#: plugins/MyDropDocumentsPlugin/MyDropDocumentsPage.php:647 +msgid "Unable to get documents in folder " +msgstr "" + #: plugins/ktcore/KTPermissions.php:801 #, php-format msgid "Unable to get documents in folder %s: %s" @@ -11951,6 +12025,7 @@ msgid "Unable to load trigger." msgstr "" #: plugins/ktcore/KTPermissions.php:795 +#: plugins/MyDropDocumentsPlugin/MyDropDocumentsPage.php:640 msgid "Unable to locate folder: " msgstr "" @@ -12006,7 +12081,7 @@ msgstr "" msgid "Unable to retrieve parent folder." msgstr "" -#: lib/util/ktutil.inc:1076 +#: lib/util/ktutil.inc:1084 #, php-format msgid "Unable to retrieve system setting %s: %s" msgstr "" @@ -12186,15 +12261,15 @@ msgstr "" msgid "Unknown op: %s" msgstr "" -#: lib/database/dbutil.inc:175 +#: lib/database/dbutil.inc:177 msgid "Unknown return value for autoInsert" msgstr "" -#: lib/database/dbutil.inc:191 +#: lib/database/dbutil.inc:193 msgid "Unknown return value for autoUpdate" msgstr "" -#: lib/database/dbutil.inc:216 +#: lib/database/dbutil.inc:218 msgid "Unknown return value for whereUpdate" msgstr "" @@ -12446,7 +12521,7 @@ msgstr "" msgid "User Information: #username# in \"#folder#\"" msgstr "" -#: plugins/ktcore/admin/configSettings.php:135 +#: plugins/ktcore/admin/configSettings.php:263 #: plugins/ktcore/KTCorePlugin.php:326 msgid "User Interface Settings" msgstr "" @@ -12775,11 +12850,15 @@ msgstr "" msgid "Warning: Database is inconsistent with the contents of the repository." msgstr "" +#: plugins/ktstandard/KTWebDAVDashletPlugin.php:66 +msgid "WebDAV Connection Information" +msgstr "" + #: plugins/ktstandard/KTWebDAVDashletPlugin.php:50 msgid "WebDAV Dashlet Plugin" msgstr "" -#: lib/util/ktutil.inc:364 +#: lib/util/ktutil.inc:372 msgid "Weird WhereClause passed" msgstr "" @@ -13422,7 +13501,7 @@ msgstr "" msgid "You're not authorized to delete this shortcut" msgstr "" -#: plugins/ktcore/KTDashlets.php:181 +#: plugins/ktcore/KTDashlets.php:186 msgid "Your Checked-out Documents" msgstr "" @@ -13554,7 +13633,7 @@ msgstr "" msgid "after " msgstr "" -#: lib/util/ktutil.inc:145 +#: lib/util/ktutil.inc:153 msgid "ago" msgstr "" diff --git a/plugins/MyDropDocumentsPlugin/MyDropDocumentsDashlet.php b/plugins/MyDropDocumentsPlugin/MyDropDocumentsDashlet.php index 9d50d43..57b8318 100644 --- a/plugins/MyDropDocumentsPlugin/MyDropDocumentsDashlet.php +++ b/plugins/MyDropDocumentsPlugin/MyDropDocumentsDashlet.php @@ -1,79 +1,79 @@ -. - * - * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, - * California 94120-7775, or email info@knowledgetree.com. - * - * The interactive user interfaces in modified source and object code versions - * of this program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU General Public License version 3. - * - * In accordance with Section 7(b) of the GNU General Public License version 3, - * these Appropriate Legal Notices must retain the display of the "Powered by - * KnowledgeTree" logo and retain the original copyright notice. If the display of the - * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices - * must display the words "Powered by KnowledgeTree" and retain the original - * copyright notice. - * Contributor( s): ______________________________________ - * - */ - -class MyDropDocumentsDashlet extends KTBaseDashlet { - var $oUser; - //var $sClass = 'ktError'; - - function MyDropDocumentsDashlet(){ - $this->sTitle = _kt('My Dropped Documents'); - } - - function is_active($oUser) { - $this->oUser = $oUser; - return true; - } - - -/* - function is_active($oUser) { - $this->oUser = $oUser; - return Permission::userIsSystemAdministrator($oUser); - } -*/ - - function render() { - global $main; - $main->requireJSResource("plugins/MyDropDocumentsPlugin/js/update.js"); - - $oPlugin =& $this->oPlugin; - - $oTemplating =& KTTemplating::getSingleton(); - $oTemplate = $oTemplating->loadTemplate('MyDropDocumentsPlugin/dashlet'); - - $aTemplateData = array( - 'context' => $this, - 'url' => $oPlugin->getPagePath('MyDropDocuments'), - - ); - - - return $oTemplate->render($aTemplateData); - } -} -?> +. + * + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, + * California 94120-7775, or email info@knowledgetree.com. + * + * The interactive user interfaces in modified source and object code versions + * of this program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU General Public License version 3. + * + * In accordance with Section 7(b) of the GNU General Public License version 3, + * these Appropriate Legal Notices must retain the display of the "Powered by + * KnowledgeTree" logo and retain the original copyright notice. If the display of the + * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices + * must display the words "Powered by KnowledgeTree" and retain the original + * copyright notice. + * Contributor( s): ______________________________________ + * + */ + +class MyDropDocumentsDashlet extends KTBaseDashlet { + var $oUser; + //var $sClass = 'ktError'; + + function MyDropDocumentsDashlet(){ + $this->sTitle = _kt('My Dropped Documents'); + } + + function is_active($oUser) { + $this->oUser = $oUser; + return true; + } + + +/* + function is_active($oUser) { + $this->oUser = $oUser; + return Permission::userIsSystemAdministrator($oUser); + } +*/ + + function render() { + global $main; + $main->requireJSResource("plugins/MyDropDocumentsPlugin/js/update.js"); + + $oPlugin =& $this->oPlugin; + + $oTemplating =& KTTemplating::getSingleton(); + $oTemplate = $oTemplating->loadTemplate('MyDropDocumentsPlugin/dashlet'); + + $aTemplateData = array( + 'context' => $this, + 'url' => $oPlugin->getPagePath('MyDropDocuments'), + + ); + + + return $oTemplate->render($aTemplateData); + } +} +?> diff --git a/plugins/MyDropDocumentsPlugin/MyDropDocumentsPage.php b/plugins/MyDropDocumentsPlugin/MyDropDocumentsPage.php index af0d87e..9dc38a5 100644 --- a/plugins/MyDropDocumentsPlugin/MyDropDocumentsPage.php +++ b/plugins/MyDropDocumentsPlugin/MyDropDocumentsPage.php @@ -1,659 +1,659 @@ -. - * - * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, - * California 94120-7775, or email info@knowledgetree.com. - * - * The interactive user interfaces in modified source and object code versions - * of this program must display Appropriate Legal Notices, as required under - * Section 5 of the GNU General Public License version 3. - * - * In accordance with Section 7(b) of the GNU General Public License version 3, - * these Appropriate Legal Notices must retain the display of the "Powered by - * KnowledgeTree" logo and retain the original copyright notice. If the display of the - * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices - * must display the words "Powered by KnowledgeTree" and retain the original - * copyright notice. - * Contributor( s): ______________________________________ - * - */ - -require_once(KT_DIR . "/ktapi/ktapi.inc.php"); -require_once(KT_LIB_DIR . "/plugins/plugin.inc.php"); -require_once(KT_LIB_DIR . "/plugins/pluginregistry.inc.php"); -require_once(KT_LIB_DIR . "/dashboard/dashlet.inc.php"); -require_once(KT_DIR . "/plugins/ktcore/KTFolderActions.php"); -require_once(KT_DIR . "/plugins/network/extendedtransactioninfo/simpletransactionutil.inc.php"); -require_once(KT_DIR . "/ktapi/KTAPIFolder.inc.php"); -require_once(KT_LIB_DIR . "/roles/Role.inc"); -require_once(KT_LIB_DIR . "/roles/roleallocation.inc.php"); -require_once(KT_LIB_DIR . "/permissions/permissionutil.inc.php"); -require_once(KT_LIB_DIR . '/mime.inc.php'); -/* This page is run via an AJAX call from the update.js for this plugin. - * It checks to see if both the dropdocuments folder and the users personal folder exist. - * If they don't, it creates them and assigns permission and roles accordingly. - * If the dropdocuments folder does exist it checks if the WorkSpaceOwner role exists. - * If the role exists it assigns the current user to the role on the dropdocuments folder. - * Therefore any users running the plugin after the dropdocuments folder has been created will have access to it too. - * The underlying logic is that everyone is assigned to the WorkSpaceOwner Role, they have all permission except - * Delete, Rename Folder, Manage security and Manage workflow on the dropdocuments folder. - * This role is then assigned to their personal folder too (which is named according to their username) and is overidden - * to give only the current user full rights to their folder. - * Essentially everyone can look at the dropdocuments folder but will only see their own folder within it. - */ - -class MyDropDocumentsPage extends KTStandardDispatcher { - - function do_main() { - - $iRootID = (int)1; - $oUser = $this->oUser; - $sUserName = (string)$this->oUser->getUserName(); - $this->ktapi = new KTAPI(); - $this->session = $this->ktapi->start_system_session(); - - if(!Folder::FolderExistsName('DroppedDocuments', $iRootID)) - { - - $root=$this->ktapi->get_root_folder(); - - //Create dropdocuments folder - $userFolder = $root->add_folder('DroppedDocuments'); - - //In order to stop permission inheritance a copy of the parent permission object is created. - //This copy is then used to set separate permissions for this folder. - KTPermissionUtil::copyPermissionObject($userFolder->get_folder()); - - //If WorkSpaceOwner role doesn't exist, create it - if(!$this->roleExistsName('WorkSpaceOwner')) - { - $oWorkSpaceOwnerRole = $this->createRole('WorkSpaceOwner'); - if ($oWorkSpaceOwnerRole == null) - { - $this->session->logout(); - return _kt('Error: Failed to create WorkSpaceOwner Role'); - } - } - - //$root=$this->ktapi->get_root_folder(); - //$personalFolder = $root->get_folder_by_name('/dropdocuments/'.$sUserName); - - //Get the folder object - $userFolderObject = $userFolder->get_folder(); - - //Get the permission object from the dropdocuments folder object - $oUserPO = KTPermissionObject::get($userFolderObject->getPermissionObjectId()); - - //Check to see if there are duplicate WorkSpaceOwner roles. - if (count($this->getRoleIdByName('WorkSpaceOwner')) > 1) - { - $this->session->logout(); - return _kt('Error: cannot set user role permissions: more than one role named \'WorkSpaceOwner\' exists'); - - } - - //call the function to set the permission on the dropdocuments folder - $this->setUserDocsPermissions($oUserPO); - - //Assign the current user to the WorkSpaceOwner role - $this->setUserDocsRoleAllocation($userFolderObject); - - } - else - { - - $root = $this->ktapi->get_root_folder(); - $userFolder = $root->get_folder_by_name('/DroppedDocuments'); - - //Get the dropdocuments folder object - $userFolderObject = $userFolder->get_folder(); - - if(!$this->roleExistsName('WorkSpaceOwner')) - { - - $oWorkSpaceOwnerRole = $this->createRole('WorkSpaceOwner'); - if ($oWorkSpaceOwnerRole == null) - { - $this->session->logout(); - return _kt('Error: Failed to create WorkSpaceOwner Role'); - } - - //set permissions - $oUserPO = KTPermissionObject::get($userFolderObject->getPermissionObjectId()); - $this->setUserDocsPermissions($oUserPO); - //assign current user to role - $this->setUserDocsRoleAllocation($userFolderObject); - } - else - { - - //update WrokSpaceOwner role to include current user - $this->updateUserDocsRoleAllocation($userFolderObject); - } - - } - - $iUserDocsFolderID = $this->getFolderID('DroppedDocuments'); - $oUserDocsFolder = Folder::get($iUserDocsFolderID); - - if(!Folder::FolderExistsName($sUserName, $iUserDocsFolderID)) - { - - - $root=$this->ktapi->get_root_folder(); - $userDocsFolder = $root->get_folder_by_name('/DroppedDocuments'); - - //create the personal folder. (Use the username to create it) - $personalFolder = $userDocsFolder->add_folder($sUserName); - - //Copy the permission object to stop permission inheritance - KTPermissionUtil::copyPermissionObject($personalFolder->get_folder()); - - //The role should exist by now. - //In both the if and else statements for the dropdocuments above the role is created - //If its doesn't exist by now there is an error - if(!$this->roleExistsName('WorkSpaceOwner')) - { - - $this->session->logout(); - return _kt('Error: WorkSpaceOwner Role not setup, cannot assign to Personal Folder'); - - } - - $personalFolderRole = $root->get_folder_by_name('/DroppedDocuments/'.$sUserName); - $PersonalFolderObject = ($personalFolderRole->get_folder()); - - //Get permission object - $oPO = KTPermissionObject::get($PersonalFolderObject->getPermissionObjectId()); - - //Check for duplicate WorkSpaceOwner roles - if (count($this->getRoleIdByName('WorkSpaceOwner')) > 1) - { - $this->session->logout(); - return _kt('Error: cannot set personal folder role permissions: more than one role named \'WorkSpaceOwner\' exists'); - - } - - $this->setPersonalFolderPermissions($oPO); - - $this->updatePersonalFolderRoleAllocation($PersonalFolderObject); - - - //folder just created so no top list of last modified documents - - $iMyDocsFolderID = $this->getFolderID($sUserName); - $this->session->logout(); - return _kt(' You do not have any dropped documents


'); - - - } - - else //if personal folder does exist - { - //Getting personal folder id - $iMyDocsFolderID = $this->getFolderID($sUserName); - - - if(!$this->roleExistsName('WorkSpaceOwner')) - { - $this->session->logout(); - return _kt('Error: WorkSpaceOwner Role does not exist'); - } - else - { - - $oTempPersonalFolder = $root->get_folder_by_name('/DroppedDocuments/'.$sUserName); - $oPersonalFolder = $oTempPersonalFolder->get_folder(); - //update WorkSpaceOwner role to include current user - - //Get permission object - $oPO = KTPermissionObject::get($oPersonalFolder->getPermissionObjectId()); - - $this->setPersonalFolderPermissions($oPO); - - $this->updatePersonalFolderRoleAllocation($oPersonalFolder); - - } - - - - $aExternalWhereClauses[] = '(DT.transaction_namespace IN (?,?,?) AND (D.parent_folder_ids LIKE "%,'.$iMyDocsFolderID.',%" OR D.parent_folder_ids LIKE "%,'.$iMyDocsFolderID.'"))'; - $aExternalWhereParams[] = 'ktcore.transactions.create'; - $aExternalWhereParams[] = 'ktcore.transactions.check_in'; - $aExternalWhereParams[] = 'ktcore.transactions.event'; - - - $aDocumentTransactions = KTSimpleTransactionUtil::getTransactionsMatchingQuery($oUser, '', $aExternalWhereClauses, $aExternalWhereParams); - if (empty($aDocumentTransactions)) - { - $this->session->logout(); - return _kt(' You do not have any dropped documents


'); - } - - $maxcount = 5; - $aDocumentTransactions = array_slice($aDocumentTransactions, 0, $maxcount); - - $sReturnTable = ''._kt('Recently Dropped Documents').' - - - - - - - - - '; - - $sOddorEven = ''; - $count = 1; - foreach ($aDocumentTransactions as $aRow) - { - $oDocument = Document::get($aRow[document_id]); - $aParentFolders = explode('/',$oDocument->getFullPath()); - $sPath = ''; - - for($i = 0; $i < count($aParentFolders); $i++) - { - if ($i > 2) - { - $sPath .= '/'.$aParentFolders[$i]; - } - } - - $sContentType = KTMime::getIconPath($oDocument->getMimeTypeID()); - $aAnchorData = $this->getDocInfo($aRow[document_id]); - $sLink = $aAnchorData[0]; - $sDocName = $aAnchorData[1]; - $sShortDocName = $sDocName; - if(strlen($sPath) > 0) - { - $sDocName = $sPath.'/'.$sDocName; - } - - $sFullDocName = $sDocName; - $iDocLength = strlen($sDocName); - if ( $iDocLength > 30 ) - { - $sDocName = substr($sDocName, ($iDocLength - 30), $iDocLength); - $sDocName = '...'.$sDocName; - } - - if($count%2 == 0) - { - $sOddorEven = 'even'; - } - else - { - $sOddorEven = 'odd'; - } - - $sReturnTable .= ''. - ''. - ''. - ''; - $count ++; - } - - $location = 'browse.php?fFolderId='.$iMyDocsFolderID; - $sReturnTable .= ''. - '
'._kt('Document').''._kt('Date Dropped').'
'.$sDocName.''.$aRow[datetime].'
'. - '
'. - ''._kt(' View All').'

'; - $this->session->logout(); - - return $sReturnTable; - - } - } - - function handleOutput($sOutput) { - print $sOutput; - } - - //This function is used to set the permission on the dropdocuments folder - function setUserDocsPermissions($oUserPO) - { - //arrays returned from get Role ID's - $aWorkSpaceOwnerRoleID = $this->getRoleIdByName('WorkSpaceOwner'); - $aAdminGroupID = $this->getGroupIdByName('System Administrators'); - - //arrays used to make integers for $aAllowed array variable - $iWorkSpaceOwnerRoleID = $aWorkSpaceOwnerRoleID[0]['id']; - $iAdminGroupID = $aAdminGroupID[0]['id']; - //$aBothAllowed is used to give permissions to the admin group and the WorkSpaceOwner role - $aBothAllowed = array('group' => array($iAdminGroupID), 'role' => array($iWorkSpaceOwnerRoleID)); - - //$aAdminAllowed is used to give permissions to the admin group only - $aAdminAllowed = array('group' => array($iAdminGroupID)); - - //Get the list of permissions - $aPermissions = KTPermission::getList(); - - foreach ($aPermissions as $oPermission) - { - //If the permission is not one of the below then both are allowed the permission - //Otherwise only the admin group is allowed the permission - if($oPermission->getHumanName() != 'Delete' && $oPermission->getHumanName() != 'Rename Folder' - && $oPermission->getHumanName() != 'Manage security' && $oPermission->getHumanName() != 'Manage workflow') - { - KTPermissionUtil::setPermissionForId($oPermission, $oUserPO, $aBothAllowed); - } - else - { - KTPermissionUtil::setPermissionForId($oPermission, $oUserPO, $aAdminAllowed); - } - } - - //UPdate the permission lookup - KTPermissionUtil::updatePermissionLookupForPO($oUserPO); - } - - //This function is used for allocating the user to the WorkSpaceOwner role only when the dropdocuments folder - //has just been created. - function setUserDocsRoleAllocation($oUserFolderObject) - { - $userFolderID = $oUserFolderObject->getId(); - - $tempWorkSpaceOwnerRoleID = $this->getRoleIdByName('WorkSpaceOwner'); - $WorkSpaceOwnerRoleID = $tempWorkSpaceOwnerRoleID[0]['id']; - - //create a new role allocation - $oDropdocumentsRoleAllocation = new RoleAllocation(); - if ($oDropdocumentsRoleAllocation == null) - { - $this->session->logout(); - return _kt('Error: cannot create WorkSpaceOwner role allocation'); - } - - //set the folder and role for the allocation - $oDropdocumentsRoleAllocation->setFolderId($userFolderID); - $oDropdocumentsRoleAllocation->setRoleId($WorkSpaceOwnerRoleID); - - $aWorkSpaceOwnerRoleAllowed = array(); - $oDropdocumentsRoleAllocation->setAllowed($aWorkSpaceOwnerRoleAllowed); - //It might be a problem that i'm not doing a "start transaction" here. - //Unable to roll back in event of db failure - $res = $oDropdocumentsRoleAllocation->create(); - - //The role is created and then updated by adding the current user to the allowed list - - $oPD = $oDropdocumentsRoleAllocation->getPermissionDescriptor(); - $aWorkSpaceOwnerRoleAssignAllowed = $oPD->getAllowed(); - $aUserId[] = $this->oUser->getId(); - $aWorkSpaceOwnerRoleAssignAllowed['user'] = $aUserId; - $oDropdocumentsRoleAllocation->setAllowed($aWorkSpaceOwnerRoleAssignAllowed); - $res = $oDropdocumentsRoleAllocation->update(); - - //Update all info linked to the role - $this->renegeratePermissionsForRole($oDropdocumentsRoleAllocation->getRoleId(), $userFolderID); - } - - //This function is used to allocate the current user to the WorkSpaceOwner role after the Dropdocuments folder - //has already been created. - function updateUserDocsRoleAllocation($oUserFolder) - { - $userFolderID = $oUserFolder->getId(); - $tempWorkSpaceOwnerRoleID = $this->getRoleIdByName('WorkSpaceOwner');//$oUserRole->getId(); - $WorkSpaceOwnerRoleID = $tempWorkSpaceOwnerRoleID[0]['id']; - - //Get the role allocation object for the Dropdocuments folder and the WorkSpaceOwner role - $oDropdocumentsRoleAllocation = $oRoleAllocation = RoleAllocation::getAllocationsForFolderAndRole($userFolderID, $WorkSpaceOwnerRoleID); - - //check that the object is not null - if ($oDropdocumentsRoleAllocation == null) - { - $this->session->logout(); - return _kt('Error: cannot find WorkSpaceOwner role allocation'); - } - - $oPD = $oDropdocumentsRoleAllocation->getPermissionDescriptor(); - $aWorkSpaceOwnerRoleAssignAllowed = $oPD->getAllowed(); - - //If the user ID is not in the allowed list already then add it to the list. - if(!in_array($this->oUser->getId(), $aWorkSpaceOwnerRoleAssignAllowed['user'])) - { - $aNewAllowed = array(); - $aNewAllowed = $aWorkSpaceOwnerRoleAssignAllowed['user']; - $aNewAllowed[] = $this->oUser->getId(); - $aWorkSpaceOwnerRoleAssignAllowed['user'] = $aNewAllowed; - $oDropdocumentsRoleAllocation->setAllowed($aWorkSpaceOwnerRoleAssignAllowed); - $res = $oDropdocumentsRoleAllocation->update(); - $this->renegeratePermissionsForRole($oDropdocumentsRoleAllocation->getRoleId(), $userFolderID); - } - } - - function setPersonalFolderPermissions($oPO) - { - $aWorkSpaceOwnerRoleID = $this->getRoleIdByName('WorkSpaceOwner'); - $aAdminGroupID = $this->getGroupIdByName('System Administrators'); - - //arrays used to make integers for $aAllowed array variable - $iWorkSpaceOwnerRoleID = $aWorkSpaceOwnerRoleID[0]['id']; - $iAdminGroupID = $aAdminGroupID[0]['id']; - - //set permissions for the role and the admin group - $aAllowed = array('role' => array($iWorkSpaceOwnerRoleID), 'group' => array($iAdminGroupID)); - - //Get the List of all the permissions - $aPersonalFolderPermissions = KTPermission::getList(); - - //Iterate through and apply all permissions to the current user and the admin group - foreach ($aPersonalFolderPermissions as $oPersonalFolderPermission) - { - KTPermissionUtil::setPermissionForId($oPersonalFolderPermission, $oPO, $aAllowed); - - } - - //Update permission lookup - KTPermissionUtil::updatePermissionLookupForPO($oPO); - } - - function updatePersonalFolderRoleAllocation($oPersonalFolder) - { - //Assign user to the WorkSpaceOwner role - $personalFolderID = $oPersonalFolder->getId(); - $tempWorkSpaceOwnerRoleID = $this->getRoleIdByName('WorkSpaceOwner'); - $WorkSpaceOwnerRoleID = $tempWorkSpaceOwnerRoleID[0]['id']; - - $oRoleAllocation = new RoleAllocation(); - if ($oRoleAllocation == null) - { - $this->session->logout(); - return _kt('Error: Cannot create WorkSpaceOwner role allocation on personal folder'); - } - $oRoleAllocation->setFolderId($personalFolderID); - $oRoleAllocation->setRoleId($WorkSpaceOwnerRoleID); - - $aRoleAllowed = array(); - $oRoleAllocation->setAllowed($aRoleAllowed); - - //It might be a problem that i'm not doing a "start transaction" here. - //Unable to roll back in event of db failure - $res = $oRoleAllocation->create(); - - //The role is first created and then the current user is allocated to the role below - - $oPD = $oRoleAllocation->getPermissionDescriptor(); - $aRoleAssignAllowed = $oPD->getAllowed(); - $aUserId[] = $this->oUser->getId(); - $aRoleAssignAllowed['user'] = $aUserId; - $oRoleAllocation->setAllowed($aRoleAssignAllowed); - $res = $oRoleAllocation->update(); - $this->renegeratePermissionsForRole($oRoleAllocation->getRoleId(), $personalFolderID); - } - - //FIXME: Direct Database access - function getFolderID($sFolderName) { - $sQuery = 'SELECT id FROM folders WHERE name = \''.$sFolderName.'\''; - - $id = DBUtil::getResultArray($sQuery); - return $id[0]['id']; - } - - //this function returns the document link and document name to be displayed on the dashlet - function getDocInfo($iDocId) { - $oDocument = Document::get($iDocId); - - if (PEAR::isError($oDocument)) { - return _kt('Document no longer exists.'); - } - - $sName = htmlentities($oDocument->getName(), ENT_NOQUOTES, 'UTF-8'); - $sLink = KTBrowseUtil::getUrlForDocument($oDocument); - - $aAnchorData = array(); - $aAnchorData[] = $sLink; - $aAnchorData[] = $sName; - return $aAnchorData; - } - - //This function is used to create the role, role allocation is done separately - function createRole ($sName) - { - $this->startTransaction(); - $oRole = Role::createFromArray(array('name' => $sName)); - - if (PEAR::isError($oRole) || ($oRole == false)) - { - if ($this->bTransactionStarted) - { - $this->rollbackTransaction(); - } - //return null on failure - return null; - } - else - { - return $oRole; - - } - } - - //FIXME: Direct Database access - function roleExistsName ($sName) - { - $sQuery = "SELECT id FROM roles WHERE name = ?"; - $aParams = array($sName); - $res = DBUtil::getResultArray(array($sQuery, $aParams)); - - if (count($res) != 0) - { - return true; - } - return false; - } - - //FIXME: Direct Database access - function groupExistsName ($sName) - { - $sQuery = "SELECT id FROM groups_lookup WHERE name = ?"; - $aParams = array($sName); - $res = DBUtil::getResultArray(array($sQuery, $aParams)); - - if (count($res) != 0) - { - return true; - } - return false; - } - - //FIXME: Direct Database access - function getRoleIdByName($sName) - { - $sQuery = "SELECT id FROM roles WHERE name = ?"; - $aParams = array($sName); - $res = DBUtil::getResultArray(array($sQuery, $aParams)); - return $res; - } - - //FIXME: Direct Database access - function getGroupIdByName ($sName) - { - $sQuery = "SELECT id FROM groups_lookup WHERE name = ?"; - $aParams = array($sName); - $res = DBUtil::getResultArray(array($sQuery, $aParams)); - return $res; - } - - //function taken from KTPermission.php and edited to work here - function renegeratePermissionsForRole($iRoleId, $iFolderId) { - $iStartFolderId = $iFolderId; - /* - * 1. find all folders & documents "below" this one which use the role - * definition _active_ (not necessarily present) at this point. - * 2. tell permissionutil to regen their permissions. - * - * The find algorithm is: - * - * folder_queue <- (iStartFolderId) - * while folder_queue is not empty: - * active_folder = - * for each folder in the active_folder: - * find folders in _this_ folder without a role-allocation on the iRoleId - * add them to the folder_queue - * update the folder's permissions. - * find documents in this folder: - * update their permissions. - */ - - $sRoleAllocTable = KTUtil::getTableName('role_allocations'); - $sFolderTable = KTUtil::getTableName('folders'); - $sQuery = sprintf('SELECT f.id as id FROM %s AS f LEFT JOIN %s AS ra ON (f.id = ra.folder_id) WHERE ra.id IS NULL AND f.parent_id = ?', $sFolderTable, $sRoleAllocTable); - - - $folder_queue = array($iStartFolderId); - while (!empty($folder_queue)) { - $active_folder = array_pop($folder_queue); - - $aParams = array($active_folder); - - $aNewFolders = DBUtil::getResultArrayKey(array($sQuery, $aParams), 'id'); - if (PEAR::isError($aNewFolders)) { - //$this->errorRedirectToMain(_kt('Failure to generate folderlisting.')); - echo _kt('Failure to generate folderlisting.'); - } - $folder_queue = kt_array_merge ($folder_queue, (array) $aNewFolders); // push. - - - // update the folder. - $oFolder =& Folder::get($active_folder); - if (PEAR::isError($oFolder) || ($oFolder == false)) { - //$this->errorRedirectToMain(_kt('Unable to locate folder: ') . $active_folder); - echo _kt('Unable to locate folder: ').$active_folder; - } - - KTPermissionUtil::updatePermissionLookup($oFolder); - $aDocList =& Document::getList(array('folder_id = ?', $active_folder)); - if (PEAR::isError($aDocList) || ($aDocList === false)) { - //$this->errorRedirectToMain(sprintf(_kt('Unable to get documents in folder %s: %s'), $active_folder, $aDocList->getMessage())); - echo _kt('Unable to get documents in folder ').$active_folder; - } - - foreach ($aDocList as $oDoc) { - if (!PEAR::isError($oDoc)) { - KTPermissionUtil::updatePermissionLookup($oDoc); - } - } - } - } - -} -?> +. + * + * You can contact KnowledgeTree Inc., PO Box 7775 #87847, San Francisco, + * California 94120-7775, or email info@knowledgetree.com. + * + * The interactive user interfaces in modified source and object code versions + * of this program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU General Public License version 3. + * + * In accordance with Section 7(b) of the GNU General Public License version 3, + * these Appropriate Legal Notices must retain the display of the "Powered by + * KnowledgeTree" logo and retain the original copyright notice. If the display of the + * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices + * must display the words "Powered by KnowledgeTree" and retain the original + * copyright notice. + * Contributor( s): ______________________________________ + * + */ + +require_once(KT_DIR . "/ktapi/ktapi.inc.php"); +require_once(KT_LIB_DIR . "/plugins/plugin.inc.php"); +require_once(KT_LIB_DIR . "/plugins/pluginregistry.inc.php"); +require_once(KT_LIB_DIR . "/dashboard/dashlet.inc.php"); +require_once(KT_DIR . "/plugins/ktcore/KTFolderActions.php"); +require_once(KT_DIR . "/plugins/network/extendedtransactioninfo/simpletransactionutil.inc.php"); +require_once(KT_DIR . "/ktapi/KTAPIFolder.inc.php"); +require_once(KT_LIB_DIR . "/roles/Role.inc"); +require_once(KT_LIB_DIR . "/roles/roleallocation.inc.php"); +require_once(KT_LIB_DIR . "/permissions/permissionutil.inc.php"); +require_once(KT_LIB_DIR . '/mime.inc.php'); +/* This page is run via an AJAX call from the update.js for this plugin. + * It checks to see if both the dropdocuments folder and the users personal folder exist. + * If they don't, it creates them and assigns permission and roles accordingly. + * If the dropdocuments folder does exist it checks if the WorkSpaceOwner role exists. + * If the role exists it assigns the current user to the role on the dropdocuments folder. + * Therefore any users running the plugin after the dropdocuments folder has been created will have access to it too. + * The underlying logic is that everyone is assigned to the WorkSpaceOwner Role, they have all permission except + * Delete, Rename Folder, Manage security and Manage workflow on the dropdocuments folder. + * This role is then assigned to their personal folder too (which is named according to their username) and is overidden + * to give only the current user full rights to their folder. + * Essentially everyone can look at the dropdocuments folder but will only see their own folder within it. + */ + +class MyDropDocumentsPage extends KTStandardDispatcher { + + function do_main() { + + $iRootID = (int)1; + $oUser = $this->oUser; + $sUserName = (string)$this->oUser->getUserName(); + $this->ktapi = new KTAPI(); + $this->session = $this->ktapi->start_system_session(); + + if(!Folder::FolderExistsName('DroppedDocuments', $iRootID)) + { + + $root=$this->ktapi->get_root_folder(); + + //Create dropdocuments folder + $userFolder = $root->add_folder('DroppedDocuments'); + + //In order to stop permission inheritance a copy of the parent permission object is created. + //This copy is then used to set separate permissions for this folder. + KTPermissionUtil::copyPermissionObject($userFolder->get_folder()); + + //If WorkSpaceOwner role doesn't exist, create it + if(!$this->roleExistsName('WorkSpaceOwner')) + { + $oWorkSpaceOwnerRole = $this->createRole('WorkSpaceOwner'); + if ($oWorkSpaceOwnerRole == null) + { + $this->session->logout(); + return _kt('Error: Failed to create WorkSpaceOwner Role'); + } + } + + //$root=$this->ktapi->get_root_folder(); + //$personalFolder = $root->get_folder_by_name('/dropdocuments/'.$sUserName); + + //Get the folder object + $userFolderObject = $userFolder->get_folder(); + + //Get the permission object from the dropdocuments folder object + $oUserPO = KTPermissionObject::get($userFolderObject->getPermissionObjectId()); + + //Check to see if there are duplicate WorkSpaceOwner roles. + if (count($this->getRoleIdByName('WorkSpaceOwner')) > 1) + { + $this->session->logout(); + return _kt('Error: cannot set user role permissions: more than one role named \'WorkSpaceOwner\' exists'); + + } + + //call the function to set the permission on the dropdocuments folder + $this->setUserDocsPermissions($oUserPO); + + //Assign the current user to the WorkSpaceOwner role + $this->setUserDocsRoleAllocation($userFolderObject); + + } + else + { + + $root = $this->ktapi->get_root_folder(); + $userFolder = $root->get_folder_by_name('/DroppedDocuments'); + + //Get the dropdocuments folder object + $userFolderObject = $userFolder->get_folder(); + + if(!$this->roleExistsName('WorkSpaceOwner')) + { + + $oWorkSpaceOwnerRole = $this->createRole('WorkSpaceOwner'); + if ($oWorkSpaceOwnerRole == null) + { + $this->session->logout(); + return _kt('Error: Failed to create WorkSpaceOwner Role'); + } + + //set permissions + $oUserPO = KTPermissionObject::get($userFolderObject->getPermissionObjectId()); + $this->setUserDocsPermissions($oUserPO); + //assign current user to role + $this->setUserDocsRoleAllocation($userFolderObject); + } + else + { + + //update WrokSpaceOwner role to include current user + $this->updateUserDocsRoleAllocation($userFolderObject); + } + + } + + $iUserDocsFolderID = $this->getFolderID('DroppedDocuments'); + $oUserDocsFolder = Folder::get($iUserDocsFolderID); + + if(!Folder::FolderExistsName($sUserName, $iUserDocsFolderID)) + { + + + $root=$this->ktapi->get_root_folder(); + $userDocsFolder = $root->get_folder_by_name('/DroppedDocuments'); + + //create the personal folder. (Use the username to create it) + $personalFolder = $userDocsFolder->add_folder($sUserName); + + //Copy the permission object to stop permission inheritance + KTPermissionUtil::copyPermissionObject($personalFolder->get_folder()); + + //The role should exist by now. + //In both the if and else statements for the dropdocuments above the role is created + //If its doesn't exist by now there is an error + if(!$this->roleExistsName('WorkSpaceOwner')) + { + + $this->session->logout(); + return _kt('Error: WorkSpaceOwner Role not setup, cannot assign to Personal Folder'); + + } + + $personalFolderRole = $root->get_folder_by_name('/DroppedDocuments/'.$sUserName); + $PersonalFolderObject = ($personalFolderRole->get_folder()); + + //Get permission object + $oPO = KTPermissionObject::get($PersonalFolderObject->getPermissionObjectId()); + + //Check for duplicate WorkSpaceOwner roles + if (count($this->getRoleIdByName('WorkSpaceOwner')) > 1) + { + $this->session->logout(); + return _kt('Error: cannot set personal folder role permissions: more than one role named \'WorkSpaceOwner\' exists'); + + } + + $this->setPersonalFolderPermissions($oPO); + + $this->updatePersonalFolderRoleAllocation($PersonalFolderObject); + + + //folder just created so no top list of last modified documents + + $iMyDocsFolderID = $this->getFolderID($sUserName); + $this->session->logout(); + return _kt(' You do not have any dropped documents


'); + + + } + + else //if personal folder does exist + { + //Getting personal folder id + $iMyDocsFolderID = $this->getFolderID($sUserName); + + + if(!$this->roleExistsName('WorkSpaceOwner')) + { + $this->session->logout(); + return _kt('Error: WorkSpaceOwner Role does not exist'); + } + else + { + + $oTempPersonalFolder = $root->get_folder_by_name('/DroppedDocuments/'.$sUserName); + $oPersonalFolder = $oTempPersonalFolder->get_folder(); + //update WorkSpaceOwner role to include current user + + //Get permission object + $oPO = KTPermissionObject::get($oPersonalFolder->getPermissionObjectId()); + + $this->setPersonalFolderPermissions($oPO); + + $this->updatePersonalFolderRoleAllocation($oPersonalFolder); + + } + + + + $aExternalWhereClauses[] = '(DT.transaction_namespace IN (?,?,?) AND (D.parent_folder_ids LIKE "%,'.$iMyDocsFolderID.',%" OR D.parent_folder_ids LIKE "%,'.$iMyDocsFolderID.'"))'; + $aExternalWhereParams[] = 'ktcore.transactions.create'; + $aExternalWhereParams[] = 'ktcore.transactions.check_in'; + $aExternalWhereParams[] = 'ktcore.transactions.event'; + + + $aDocumentTransactions = KTSimpleTransactionUtil::getTransactionsMatchingQuery($oUser, '', $aExternalWhereClauses, $aExternalWhereParams); + if (empty($aDocumentTransactions)) + { + $this->session->logout(); + return _kt(' You do not have any dropped documents


'); + } + + $maxcount = 5; + $aDocumentTransactions = array_slice($aDocumentTransactions, 0, $maxcount); + + $sReturnTable = ''._kt('Recently Dropped Documents').' + + + + + + + + + '; + + $sOddorEven = ''; + $count = 1; + foreach ($aDocumentTransactions as $aRow) + { + $oDocument = Document::get($aRow[document_id]); + $aParentFolders = explode('/',$oDocument->getFullPath()); + $sPath = ''; + + for($i = 0; $i < count($aParentFolders); $i++) + { + if ($i > 2) + { + $sPath .= '/'.$aParentFolders[$i]; + } + } + + $sContentType = KTMime::getIconPath($oDocument->getMimeTypeID()); + $aAnchorData = $this->getDocInfo($aRow[document_id]); + $sLink = $aAnchorData[0]; + $sDocName = $aAnchorData[1]; + $sShortDocName = $sDocName; + if(strlen($sPath) > 0) + { + $sDocName = $sPath.'/'.$sDocName; + } + + $sFullDocName = $sDocName; + $iDocLength = strlen($sDocName); + if ( $iDocLength > 30 ) + { + $sDocName = substr($sDocName, ($iDocLength - 30), $iDocLength); + $sDocName = '...'.$sDocName; + } + + if($count%2 == 0) + { + $sOddorEven = 'even'; + } + else + { + $sOddorEven = 'odd'; + } + + $sReturnTable .= ''. + ''. + ''. + ''; + $count ++; + } + + $location = 'browse.php?fFolderId='.$iMyDocsFolderID; + $sReturnTable .= ''. + '
'._kt('Document').''._kt('Date Dropped').'
'.$sDocName.''.$aRow[datetime].'
'. + '
'. + ''._kt(' View All').'

'; + $this->session->logout(); + + return $sReturnTable; + + } + } + + function handleOutput($sOutput) { + print $sOutput; + } + + //This function is used to set the permission on the dropdocuments folder + function setUserDocsPermissions($oUserPO) + { + //arrays returned from get Role ID's + $aWorkSpaceOwnerRoleID = $this->getRoleIdByName('WorkSpaceOwner'); + $aAdminGroupID = $this->getGroupIdByName('System Administrators'); + + //arrays used to make integers for $aAllowed array variable + $iWorkSpaceOwnerRoleID = $aWorkSpaceOwnerRoleID[0]['id']; + $iAdminGroupID = $aAdminGroupID[0]['id']; + //$aBothAllowed is used to give permissions to the admin group and the WorkSpaceOwner role + $aBothAllowed = array('group' => array($iAdminGroupID), 'role' => array($iWorkSpaceOwnerRoleID)); + + //$aAdminAllowed is used to give permissions to the admin group only + $aAdminAllowed = array('group' => array($iAdminGroupID)); + + //Get the list of permissions + $aPermissions = KTPermission::getList(); + + foreach ($aPermissions as $oPermission) + { + //If the permission is not one of the below then both are allowed the permission + //Otherwise only the admin group is allowed the permission + if($oPermission->getHumanName() != 'Delete' && $oPermission->getHumanName() != 'Rename Folder' + && $oPermission->getHumanName() != 'Manage security' && $oPermission->getHumanName() != 'Manage workflow') + { + KTPermissionUtil::setPermissionForId($oPermission, $oUserPO, $aBothAllowed); + } + else + { + KTPermissionUtil::setPermissionForId($oPermission, $oUserPO, $aAdminAllowed); + } + } + + //UPdate the permission lookup + KTPermissionUtil::updatePermissionLookupForPO($oUserPO); + } + + //This function is used for allocating the user to the WorkSpaceOwner role only when the dropdocuments folder + //has just been created. + function setUserDocsRoleAllocation($oUserFolderObject) + { + $userFolderID = $oUserFolderObject->getId(); + + $tempWorkSpaceOwnerRoleID = $this->getRoleIdByName('WorkSpaceOwner'); + $WorkSpaceOwnerRoleID = $tempWorkSpaceOwnerRoleID[0]['id']; + + //create a new role allocation + $oDropdocumentsRoleAllocation = new RoleAllocation(); + if ($oDropdocumentsRoleAllocation == null) + { + $this->session->logout(); + return _kt('Error: cannot create WorkSpaceOwner role allocation'); + } + + //set the folder and role for the allocation + $oDropdocumentsRoleAllocation->setFolderId($userFolderID); + $oDropdocumentsRoleAllocation->setRoleId($WorkSpaceOwnerRoleID); + + $aWorkSpaceOwnerRoleAllowed = array(); + $oDropdocumentsRoleAllocation->setAllowed($aWorkSpaceOwnerRoleAllowed); + //It might be a problem that i'm not doing a "start transaction" here. + //Unable to roll back in event of db failure + $res = $oDropdocumentsRoleAllocation->create(); + + //The role is created and then updated by adding the current user to the allowed list + + $oPD = $oDropdocumentsRoleAllocation->getPermissionDescriptor(); + $aWorkSpaceOwnerRoleAssignAllowed = $oPD->getAllowed(); + $aUserId[] = $this->oUser->getId(); + $aWorkSpaceOwnerRoleAssignAllowed['user'] = $aUserId; + $oDropdocumentsRoleAllocation->setAllowed($aWorkSpaceOwnerRoleAssignAllowed); + $res = $oDropdocumentsRoleAllocation->update(); + + //Update all info linked to the role + $this->renegeratePermissionsForRole($oDropdocumentsRoleAllocation->getRoleId(), $userFolderID); + } + + //This function is used to allocate the current user to the WorkSpaceOwner role after the Dropdocuments folder + //has already been created. + function updateUserDocsRoleAllocation($oUserFolder) + { + $userFolderID = $oUserFolder->getId(); + $tempWorkSpaceOwnerRoleID = $this->getRoleIdByName('WorkSpaceOwner');//$oUserRole->getId(); + $WorkSpaceOwnerRoleID = $tempWorkSpaceOwnerRoleID[0]['id']; + + //Get the role allocation object for the Dropdocuments folder and the WorkSpaceOwner role + $oDropdocumentsRoleAllocation = $oRoleAllocation = RoleAllocation::getAllocationsForFolderAndRole($userFolderID, $WorkSpaceOwnerRoleID); + + //check that the object is not null + if ($oDropdocumentsRoleAllocation == null) + { + $this->session->logout(); + return _kt('Error: cannot find WorkSpaceOwner role allocation'); + } + + $oPD = $oDropdocumentsRoleAllocation->getPermissionDescriptor(); + $aWorkSpaceOwnerRoleAssignAllowed = $oPD->getAllowed(); + + //If the user ID is not in the allowed list already then add it to the list. + if(!in_array($this->oUser->getId(), $aWorkSpaceOwnerRoleAssignAllowed['user'])) + { + $aNewAllowed = array(); + $aNewAllowed = $aWorkSpaceOwnerRoleAssignAllowed['user']; + $aNewAllowed[] = $this->oUser->getId(); + $aWorkSpaceOwnerRoleAssignAllowed['user'] = $aNewAllowed; + $oDropdocumentsRoleAllocation->setAllowed($aWorkSpaceOwnerRoleAssignAllowed); + $res = $oDropdocumentsRoleAllocation->update(); + $this->renegeratePermissionsForRole($oDropdocumentsRoleAllocation->getRoleId(), $userFolderID); + } + } + + function setPersonalFolderPermissions($oPO) + { + $aWorkSpaceOwnerRoleID = $this->getRoleIdByName('WorkSpaceOwner'); + $aAdminGroupID = $this->getGroupIdByName('System Administrators'); + + //arrays used to make integers for $aAllowed array variable + $iWorkSpaceOwnerRoleID = $aWorkSpaceOwnerRoleID[0]['id']; + $iAdminGroupID = $aAdminGroupID[0]['id']; + + //set permissions for the role and the admin group + $aAllowed = array('role' => array($iWorkSpaceOwnerRoleID), 'group' => array($iAdminGroupID)); + + //Get the List of all the permissions + $aPersonalFolderPermissions = KTPermission::getList(); + + //Iterate through and apply all permissions to the current user and the admin group + foreach ($aPersonalFolderPermissions as $oPersonalFolderPermission) + { + KTPermissionUtil::setPermissionForId($oPersonalFolderPermission, $oPO, $aAllowed); + + } + + //Update permission lookup + KTPermissionUtil::updatePermissionLookupForPO($oPO); + } + + function updatePersonalFolderRoleAllocation($oPersonalFolder) + { + //Assign user to the WorkSpaceOwner role + $personalFolderID = $oPersonalFolder->getId(); + $tempWorkSpaceOwnerRoleID = $this->getRoleIdByName('WorkSpaceOwner'); + $WorkSpaceOwnerRoleID = $tempWorkSpaceOwnerRoleID[0]['id']; + + $oRoleAllocation = new RoleAllocation(); + if ($oRoleAllocation == null) + { + $this->session->logout(); + return _kt('Error: Cannot create WorkSpaceOwner role allocation on personal folder'); + } + $oRoleAllocation->setFolderId($personalFolderID); + $oRoleAllocation->setRoleId($WorkSpaceOwnerRoleID); + + $aRoleAllowed = array(); + $oRoleAllocation->setAllowed($aRoleAllowed); + + //It might be a problem that i'm not doing a "start transaction" here. + //Unable to roll back in event of db failure + $res = $oRoleAllocation->create(); + + //The role is first created and then the current user is allocated to the role below + + $oPD = $oRoleAllocation->getPermissionDescriptor(); + $aRoleAssignAllowed = $oPD->getAllowed(); + $aUserId[] = $this->oUser->getId(); + $aRoleAssignAllowed['user'] = $aUserId; + $oRoleAllocation->setAllowed($aRoleAssignAllowed); + $res = $oRoleAllocation->update(); + $this->renegeratePermissionsForRole($oRoleAllocation->getRoleId(), $personalFolderID); + } + + //FIXME: Direct Database access + function getFolderID($sFolderName) { + $sQuery = 'SELECT id FROM folders WHERE name = \''.$sFolderName.'\''; + + $id = DBUtil::getResultArray($sQuery); + return $id[0]['id']; + } + + //this function returns the document link and document name to be displayed on the dashlet + function getDocInfo($iDocId) { + $oDocument = Document::get($iDocId); + + if (PEAR::isError($oDocument)) { + return _kt('Document no longer exists.'); + } + + $sName = htmlentities($oDocument->getName(), ENT_NOQUOTES, 'UTF-8'); + $sLink = KTBrowseUtil::getUrlForDocument($oDocument); + + $aAnchorData = array(); + $aAnchorData[] = $sLink; + $aAnchorData[] = $sName; + return $aAnchorData; + } + + //This function is used to create the role, role allocation is done separately + function createRole ($sName) + { + $this->startTransaction(); + $oRole = Role::createFromArray(array('name' => $sName)); + + if (PEAR::isError($oRole) || ($oRole == false)) + { + if ($this->bTransactionStarted) + { + $this->rollbackTransaction(); + } + //return null on failure + return null; + } + else + { + return $oRole; + + } + } + + //FIXME: Direct Database access + function roleExistsName ($sName) + { + $sQuery = "SELECT id FROM roles WHERE name = ?"; + $aParams = array($sName); + $res = DBUtil::getResultArray(array($sQuery, $aParams)); + + if (count($res) != 0) + { + return true; + } + return false; + } + + //FIXME: Direct Database access + function groupExistsName ($sName) + { + $sQuery = "SELECT id FROM groups_lookup WHERE name = ?"; + $aParams = array($sName); + $res = DBUtil::getResultArray(array($sQuery, $aParams)); + + if (count($res) != 0) + { + return true; + } + return false; + } + + //FIXME: Direct Database access + function getRoleIdByName($sName) + { + $sQuery = "SELECT id FROM roles WHERE name = ?"; + $aParams = array($sName); + $res = DBUtil::getResultArray(array($sQuery, $aParams)); + return $res; + } + + //FIXME: Direct Database access + function getGroupIdByName ($sName) + { + $sQuery = "SELECT id FROM groups_lookup WHERE name = ?"; + $aParams = array($sName); + $res = DBUtil::getResultArray(array($sQuery, $aParams)); + return $res; + } + + //function taken from KTPermission.php and edited to work here + function renegeratePermissionsForRole($iRoleId, $iFolderId) { + $iStartFolderId = $iFolderId; + /* + * 1. find all folders & documents "below" this one which use the role + * definition _active_ (not necessarily present) at this point. + * 2. tell permissionutil to regen their permissions. + * + * The find algorithm is: + * + * folder_queue <- (iStartFolderId) + * while folder_queue is not empty: + * active_folder = + * for each folder in the active_folder: + * find folders in _this_ folder without a role-allocation on the iRoleId + * add them to the folder_queue + * update the folder's permissions. + * find documents in this folder: + * update their permissions. + */ + + $sRoleAllocTable = KTUtil::getTableName('role_allocations'); + $sFolderTable = KTUtil::getTableName('folders'); + $sQuery = sprintf('SELECT f.id as id FROM %s AS f LEFT JOIN %s AS ra ON (f.id = ra.folder_id) WHERE ra.id IS NULL AND f.parent_id = ?', $sFolderTable, $sRoleAllocTable); + + + $folder_queue = array($iStartFolderId); + while (!empty($folder_queue)) { + $active_folder = array_pop($folder_queue); + + $aParams = array($active_folder); + + $aNewFolders = DBUtil::getResultArrayKey(array($sQuery, $aParams), 'id'); + if (PEAR::isError($aNewFolders)) { + //$this->errorRedirectToMain(_kt('Failure to generate folderlisting.')); + echo _kt('Failure to generate folderlisting.'); + } + $folder_queue = kt_array_merge ($folder_queue, (array) $aNewFolders); // push. + + + // update the folder. + $oFolder =& Folder::get($active_folder); + if (PEAR::isError($oFolder) || ($oFolder == false)) { + //$this->errorRedirectToMain(_kt('Unable to locate folder: ') . $active_folder); + echo _kt('Unable to locate folder: ').$active_folder; + } + + KTPermissionUtil::updatePermissionLookup($oFolder); + $aDocList =& Document::getList(array('folder_id = ?', $active_folder)); + if (PEAR::isError($aDocList) || ($aDocList === false)) { + //$this->errorRedirectToMain(sprintf(_kt('Unable to get documents in folder %s: %s'), $active_folder, $aDocList->getMessage())); + echo _kt('Unable to get documents in folder ').$active_folder; + } + + foreach ($aDocList as $oDoc) { + if (!PEAR::isError($oDoc)) { + KTPermissionUtil::updatePermissionLookup($oDoc); + } + } + } + } + +} +?> diff --git a/plugins/ktstandard/KTWebDAVDashletPlugin.php b/plugins/ktstandard/KTWebDAVDashletPlugin.php index ec1e021..c395006 100644 --- a/plugins/ktstandard/KTWebDAVDashletPlugin.php +++ b/plugins/ktstandard/KTWebDAVDashletPlugin.php @@ -63,7 +63,7 @@ class KTWebDAVDashlet extends KTBaseDashlet { var $sClass = "ktInfo"; function KTWebDAVDashlet( ) { - $this->sTitle = "WebDAV Connection Information"; + $this->sTitle = _kt('WebDAV Connection Information'); } function render() { -- libgit2 0.21.4