Commit 821155c99635a8d14677fbfe00aa6d096a9b13be
1 parent
f0c1de40
very simple dashlet disabling.
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4396 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
7 changed files
with
154 additions
and
28 deletions
config/tableMappings.inc
| ... | ... | @@ -141,4 +141,5 @@ $default->permission_dynamic_conditions_table = 'permission_dynamic_conditions'; |
| 141 | 141 | $default->permission_dynamic_assignments_table = 'permission_dynamic_assignments'; |
| 142 | 142 | $default->notifications_table = "notifications"; |
| 143 | 143 | $default->authentication_sources_table = "authentication_sources"; |
| 144 | +$default->dashlet_disable_table = "dashlet_disables"; | |
| 144 | 145 | ?> | ... | ... |
lib/dashboard/DashletDisables.inc.php
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +require_once(KT_LIB_DIR . "/ktentity.inc"); | |
| 4 | + | |
| 5 | +/** a _disable_ flag for a particular dashlet, and a particular user. | |
| 6 | + | |
| 7 | + shouldn't use an enable flag, since the target user is transient and | |
| 8 | + may need to know about the item on creation, not on dashlet registration. | |
| 9 | + | |
| 10 | +*/ | |
| 11 | + | |
| 12 | + | |
| 13 | +class KTDashletDisable extends KTEntity { | |
| 14 | + | |
| 15 | + /** primary key value */ | |
| 16 | + var $iId = -1; | |
| 17 | + var $iUserId; | |
| 18 | + var $sNamespace; | |
| 19 | + | |
| 20 | + var $_bUsePearError = true; | |
| 21 | + | |
| 22 | + function getId() { return $this->iId; } | |
| 23 | + function getUserId() { return $this->iUserId; } | |
| 24 | + function setUserId($iNewValue) { $this->iUserId = $iNewValue; } | |
| 25 | + function getNamespace() { return $this->sNamespace; } | |
| 26 | + function setNamespace($sNewValue) { $this->sNamespace = $sNewValue; } | |
| 27 | + | |
| 28 | + var $_aFieldToSelect = array( | |
| 29 | + "iId" => "id", | |
| 30 | + "iUserId" => "user_id", | |
| 31 | + "sNamespace" => "dashlet_namespace", | |
| 32 | + ); | |
| 33 | + | |
| 34 | + function _table () { | |
| 35 | + return KTUtil::getTableName('dashlet_disable'); | |
| 36 | + } | |
| 37 | + | |
| 38 | + // Static function | |
| 39 | + function &get($iId) { return KTEntityUtil::get('KTDashletDisable', $iId); } | |
| 40 | + function &getList($sWhereClause = null) { return KTEntityUtil::getList2('KTDashletDisable', $sWhereClause); } | |
| 41 | + function &createFromArray($aOptions) { return KTEntityUtil::createFromArray('KTDashletDisable', $aOptions); } | |
| 42 | + | |
| 43 | + function &getForUserAndDashlet($iUserId, $sNamespace) { | |
| 44 | + $sWhereClause = 'WHERE user_id = ? AND dashlet_namespace = ?'; | |
| 45 | + $aParams = array($iUserId, $sNamespace); | |
| 46 | + | |
| 47 | + return KTDashletDisable::getList(array($sWhereClause, $aParams)); | |
| 48 | + } | |
| 49 | +} | |
| 50 | + | |
| 51 | +?> | |
| 0 | 52 | \ No newline at end of file | ... | ... |
plugins/ktcore/assistance/KTUserAssistance.php
| ... | ... | @@ -5,6 +5,7 @@ |
| 5 | 5 | require_once(KT_LIB_DIR . '/plugins/pluginregistry.inc.php'); |
| 6 | 6 | require_once(KT_LIB_DIR . '/plugins/plugin.inc.php'); |
| 7 | 7 | require_once(KT_LIB_DIR . '/dashboard/dashlet.inc.php'); |
| 8 | +require_once(KT_LIB_DIR . '/dashboard/DashletDisables.inc.php'); | |
| 8 | 9 | require_once(KT_LIB_DIR . "/templating/templating.inc.php"); |
| 9 | 10 | require_once(KT_LIB_DIR . "/dashboard/Notification.inc.php"); |
| 10 | 11 | require_once(KT_LIB_DIR . "/security/Permission.inc"); |
| ... | ... | @@ -25,10 +26,17 @@ $oRegistry->registerPlugin('KTUserAssistance', 'ktcore.userassistance', __FILE__ |
| 25 | 26 | $oPlugin =& $oRegistry->getPlugin('ktcore.userassistance'); |
| 26 | 27 | |
| 27 | 28 | // ultra simple skeleton for the user tutorial |
| 29 | +// FIXME do we want to store the namespace inside the dashlet? | |
| 28 | 30 | class KTUserTutorialDashlet extends KTBaseDashlet { |
| 29 | 31 | function is_active($oUser) { |
| 30 | - // FIXME check if the user has "turned this off" for themselves. | |
| 31 | - return true; | |
| 32 | + $namespace = 'ktcore.dashlet.usertutorial'; | |
| 33 | + $disables = KTDashletDisable::getForUserAndDashlet($oUser->getId(), $namespace); | |
| 34 | + | |
| 35 | + if (!empty($disables)) { | |
| 36 | + return false; | |
| 37 | + } else { | |
| 38 | + return true; | |
| 39 | + } | |
| 32 | 40 | } |
| 33 | 41 | |
| 34 | 42 | function render() { |
| ... | ... | @@ -45,9 +53,19 @@ $oPlugin->registerDashlet('KTUserTutorialDashlet', 'ktcore.dashlet.usertutorial' |
| 45 | 53 | // ultra simple skeleton for the admin tutorial |
| 46 | 54 | class KTAdminTutorialDashlet extends KTBaseDashlet { |
| 47 | 55 | function is_active($oUser) { |
| 48 | - // FIXME check if the user has "turned this off" for themselves. | |
| 49 | - return Permission::userIsSystemAdministrator($oUser->getId()); | |
| 50 | - return true; | |
| 56 | + | |
| 57 | + $namespace = 'ktcore.dashlet.admintutorial'; | |
| 58 | + | |
| 59 | + if (!Permission::userIsSystemAdministrator($oUser->getId())) { | |
| 60 | + return false; // quickest disable. | |
| 61 | + } | |
| 62 | + | |
| 63 | + $disables = KTDashletDisable::getForUserAndDashlet($oUser->getId(), $namespace); | |
| 64 | + if (!empty($disables)) { | |
| 65 | + return false; | |
| 66 | + } else { | |
| 67 | + return true; | |
| 68 | + } | |
| 51 | 69 | } |
| 52 | 70 | |
| 53 | 71 | function render() { |
| ... | ... | @@ -78,6 +96,8 @@ class KTUserAssistBasePage extends KTStandardDispatcher { |
| 78 | 96 | $this->oPage->setShowPortlets(false); |
| 79 | 97 | return $contents; |
| 80 | 98 | } |
| 99 | + | |
| 100 | + // hide the dashlet from the user (e.g. don't show it again) and redirect back to the dashboard. | |
| 81 | 101 | } |
| 82 | 102 | |
| 83 | 103 | class KTUserAssistB1WhatIs extends KTUserAssistBasePage { var $pagefile = 'kt3b1-what-is-a-beta'; var $title = 'What is a Beta?'; } | ... | ... |
presentation/lookAndFeel/knowledgeTree/dashboard.php
| ... | ... | @@ -37,11 +37,13 @@ require_once(KT_LIB_DIR . "/templating/templating.inc.php"); |
| 37 | 37 | require_once(KT_LIB_DIR . "/templating/kt3template.inc.php"); |
| 38 | 38 | require_once(KT_LIB_DIR . "/dispatcher.inc.php"); |
| 39 | 39 | |
| 40 | +require_once(KT_LIB_DIR . "/dashboard/DashletDisables.inc.php"); | |
| 41 | + | |
| 40 | 42 | $sectionName = "dashboard"; |
| 41 | 43 | |
| 42 | 44 | class DashboardDispatcher extends KTStandardDispatcher { |
| 43 | - | |
| 44 | - var $notifications = array(); | |
| 45 | + | |
| 46 | + var $notifications = array(); | |
| 45 | 47 | |
| 46 | 48 | function DashboardDispatcher() { |
| 47 | 49 | $this->aBreadcrumbs = array( |
| ... | ... | @@ -50,26 +52,50 @@ class DashboardDispatcher extends KTStandardDispatcher { |
| 50 | 52 | return parent::KTStandardDispatcher(); |
| 51 | 53 | } |
| 52 | 54 | function do_main() { |
| 53 | - $this->oPage->setShowPortlets(false); | |
| 54 | - // retrieve action items for the user. | |
| 55 | - // FIXME what is the userid? | |
| 56 | - | |
| 57 | - | |
| 58 | - $oDashletRegistry =& KTDashletRegistry::getSingleton(); | |
| 59 | - $aDashlets = $oDashletRegistry->getDashlets($this->oUser); | |
| 60 | - | |
| 61 | - $this->sSection = "dashboard"; | |
| 62 | - $this->oPage->setBreadcrumbDetails(_("Home")); | |
| 63 | - $this->oPage->title = _("Dashboard"); | |
| 64 | - | |
| 65 | - $oTemplating = new KTTemplating; | |
| 66 | - $oTemplate = $oTemplating->loadTemplate("kt3/dashboard"); | |
| 67 | - $aTemplateData = array( | |
| 55 | + $this->oPage->setShowPortlets(false); | |
| 56 | + // retrieve action items for the user. | |
| 57 | + // FIXME what is the userid? | |
| 58 | + | |
| 59 | + | |
| 60 | + $oDashletRegistry =& KTDashletRegistry::getSingleton(); | |
| 61 | + $aDashlets = $oDashletRegistry->getDashlets($this->oUser); | |
| 62 | + | |
| 63 | + $this->sSection = "dashboard"; | |
| 64 | + $this->oPage->setBreadcrumbDetails(_("Home")); | |
| 65 | + $this->oPage->title = _("Dashboard"); | |
| 66 | + | |
| 67 | + $oTemplating = new KTTemplating; | |
| 68 | + $oTemplate = $oTemplating->loadTemplate("kt3/dashboard"); | |
| 69 | + $aTemplateData = array( | |
| 68 | 70 | "context" => $this, |
| 69 | - "dashlets" => $aDashlets, | |
| 70 | - ); | |
| 71 | - return $oTemplate->render($aTemplateData); | |
| 72 | - } | |
| 71 | + "dashlets" => $aDashlets, | |
| 72 | + ); | |
| 73 | + return $oTemplate->render($aTemplateData); | |
| 74 | + } | |
| 75 | + | |
| 76 | + // disable a dashlet. | |
| 77 | + // FIXME this very slightly violates the separation of concerns, but its not that flagrant. | |
| 78 | + function do_disableDashlet() { | |
| 79 | + $sNamespace = KTUtil::arrayGet($_REQUEST, 'fNamespace'); | |
| 80 | + $iUserId = $this->oUser->getId(); | |
| 81 | + | |
| 82 | + if (empty($sNamespace)) { | |
| 83 | + $this->errorRedirectToMain('No dashlet specified.'); | |
| 84 | + exit(0); | |
| 85 | + } | |
| 86 | + | |
| 87 | + // do the "delete" | |
| 88 | + | |
| 89 | + $this->startTransaction(); | |
| 90 | + $aParams = array('sNamespace' => $sNamespace, 'iUserId' => $iUserId); | |
| 91 | + $oDD = KTDashletDisable::createFromArray($aParams); | |
| 92 | + if (PEAR::isError($oDD)) { | |
| 93 | + $this->errorRedirectToMain('Failed to disable the dashlet.'); | |
| 94 | + } | |
| 95 | + | |
| 96 | + $this->commitTransaction(); | |
| 97 | + $this->successRedirectToMain('Dashlet disabled.'); | |
| 98 | + } | |
| 73 | 99 | } |
| 74 | 100 | |
| 75 | 101 | $oDispatcher = new DashboardDispatcher(); | ... | ... |
sql/mysql/install/structure.sql
| ... | ... | @@ -118,6 +118,22 @@ CREATE TABLE `data_types` ( |
| 118 | 118 | -- -------------------------------------------------------- |
| 119 | 119 | |
| 120 | 120 | -- |
| 121 | +-- Table structure for table `dashlet_disables` | |
| 122 | +-- | |
| 123 | + | |
| 124 | +CREATE TABLE `dashlet_disables` ( | |
| 125 | + `id` int(11) NOT NULL default '0', | |
| 126 | + `user_id` int(11) NOT NULL default '', | |
| 127 | + `dashlet_namespace` varchar(255) NOT NULL default '', | |
| 128 | + UNIQUE KEY `id` (`id`), | |
| 129 | + INDEX (`user_id`), | |
| 130 | + INDEX (`dashlet_namespace`) | |
| 131 | +) ENGINE=InnoDB ; | |
| 132 | + | |
| 133 | +-- -------------------------------------------------------- | |
| 134 | + | |
| 135 | + | |
| 136 | +-- | |
| 121 | 137 | -- Table structure for table `dependant_document_instance` |
| 122 | 138 | -- |
| 123 | 139 | |
| ... | ... | @@ -2084,6 +2100,18 @@ CREATE TABLE `zseq_workflows` ( |
| 2084 | 2100 | PRIMARY KEY (`id`) |
| 2085 | 2101 | ) ENGINE=MyISAM ; |
| 2086 | 2102 | |
| 2103 | + | |
| 2104 | +-- -------------------------------------------------------- | |
| 2105 | + | |
| 2106 | +-- | |
| 2107 | +-- Table structure for table `zseq_dashlet_disables` | |
| 2108 | +-- | |
| 2109 | + | |
| 2110 | +CREATE TABLE `zseq_dashlet_disables` ( | |
| 2111 | + `id` int(10) unsigned NOT NULL auto_increment, | |
| 2112 | + PRIMARY KEY (`id`) | |
| 2113 | +) ENGINE=MyISAM ; | |
| 2114 | + | |
| 2087 | 2115 | -- |
| 2088 | 2116 | -- Constraints for dumped tables |
| 2089 | 2117 | -- | ... | ... |
templates/ktcore/dashlets/admintutorial.smarty
| ... | ... | @@ -9,4 +9,4 @@ which might help you get to grips with the new system.{/i18n}</p> |
| 9 | 9 | href="{$rootUrl}/plugin.php/ktcore.userassistance/admin-quickguide">{i18n}Read the admin introduction.{/i18n}</a> | |
| 10 | 10 | <a |
| 11 | 11 | href="{$rootUrl}/plugin.php/ktcore.userassistance/admin-guide-whats-new-in-kt3">{i18n}Find out what's different in <strong>KT 3</strong>.{/i18n}</a> | |
| 12 | -<a href="#">{i18n}Don't show me this again.{/i18n}</a> | |
| 12 | +<a href="?action=disableDashlet&fNamespace=ktcore.dashlet.admintutorial">{i18n}Don't show me this again.{/i18n}</a> | ... | ... |
templates/ktcore/dashlets/usertutorial.smarty
| ... | ... | @@ -6,4 +6,4 @@ KnowledgeTree&trade; 3? We've written some quick documentation{/i18n}</p> |
| 6 | 6 | |
| 7 | 7 | <a href="#">Take the crash course.</a> | |
| 8 | 8 | <a href="#">Learn about KnowledgeTree 3.</a> | |
| 9 | -<a href="#">Don't show me this again.</a> | |
| 9 | +<a href="?action=disableDashlet&fNamespace=ktcore.dashlet.usertutorial">{i18n}Don't show me this again.{/i18n}</a> | ... | ... |