Commit 1d80be8a78e6b785cf428962deac690d3e127b0e
1 parent
483ed264
KTC-286
"Welcome to knowledgeTree dashlet should always be on the top left corner of the dashlet container" Fixed. Refactored the way the users state is refreshed. It now uses the plugin_helper table to get any new dashlets. Committed by: Megan Watson Reviewed by: Conrad Vermeulen git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@7816 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
3 changed files
with
151 additions
and
65 deletions
dashboard.php
| @@ -3,38 +3,38 @@ | @@ -3,38 +3,38 @@ | ||
| 3 | * $Id$ | 3 | * $Id$ |
| 4 | * | 4 | * |
| 5 | * Main dashboard page -- This page is presented to the user after login. | 5 | * Main dashboard page -- This page is presented to the user after login. |
| 6 | - * It contains a high level overview of the users subscriptions, checked out | ||
| 7 | - * document, pending approval routing documents, etc. | 6 | + * It contains a high level overview of the users subscriptions, checked out |
| 7 | + * document, pending approval routing documents, etc. | ||
| 8 | * | 8 | * |
| 9 | * KnowledgeTree Open Source Edition | 9 | * KnowledgeTree Open Source Edition |
| 10 | * Document Management Made Simple | 10 | * Document Management Made Simple |
| 11 | * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited | 11 | * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited |
| 12 | - * | 12 | + * |
| 13 | * This program is free software; you can redistribute it and/or modify it under | 13 | * This program is free software; you can redistribute it and/or modify it under |
| 14 | * the terms of the GNU General Public License version 3 as published by the | 14 | * the terms of the GNU General Public License version 3 as published by the |
| 15 | * Free Software Foundation. | 15 | * Free Software Foundation. |
| 16 | - * | 16 | + * |
| 17 | * This program is distributed in the hope that it will be useful, but WITHOUT | 17 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 18 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | 18 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 19 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | 19 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 20 | * details. | 20 | * details. |
| 21 | - * | 21 | + * |
| 22 | * You should have received a copy of the GNU General Public License | 22 | * You should have received a copy of the GNU General Public License |
| 23 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 23 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 24 | - * | 24 | + * |
| 25 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, | 25 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, |
| 26 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. | 26 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. |
| 27 | - * | 27 | + * |
| 28 | * The interactive user interfaces in modified source and object code versions | 28 | * The interactive user interfaces in modified source and object code versions |
| 29 | * of this program must display Appropriate Legal Notices, as required under | 29 | * of this program must display Appropriate Legal Notices, as required under |
| 30 | * Section 5 of the GNU General Public License version 3. | 30 | * Section 5 of the GNU General Public License version 3. |
| 31 | - * | 31 | + * |
| 32 | * In accordance with Section 7(b) of the GNU General Public License version 3, | 32 | * In accordance with Section 7(b) of the GNU General Public License version 3, |
| 33 | * these Appropriate Legal Notices must retain the display of the "Powered by | 33 | * these Appropriate Legal Notices must retain the display of the "Powered by |
| 34 | - * KnowledgeTree" logo and retain the original copyright notice. If the display of the | 34 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the |
| 35 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | 35 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices |
| 36 | - * must display the words "Powered by KnowledgeTree" and retain the original | ||
| 37 | - * copyright notice. | 36 | + * must display the words "Powered by KnowledgeTree" and retain the original |
| 37 | + * copyright notice. | ||
| 38 | * Contributor( s): ______________________________________ | 38 | * Contributor( s): ______________________________________ |
| 39 | */ | 39 | */ |
| 40 | 40 | ||
| @@ -53,9 +53,9 @@ require_once(KT_LIB_DIR . '/dashboard/DashletDisables.inc.php'); | @@ -53,9 +53,9 @@ require_once(KT_LIB_DIR . '/dashboard/DashletDisables.inc.php'); | ||
| 53 | $sectionName = 'dashboard'; | 53 | $sectionName = 'dashboard'; |
| 54 | 54 | ||
| 55 | class DashboardDispatcher extends KTStandardDispatcher { | 55 | class DashboardDispatcher extends KTStandardDispatcher { |
| 56 | - | 56 | + |
| 57 | var $notifications = array(); | 57 | var $notifications = array(); |
| 58 | - var $sHelpPage = 'ktcore/dashboard.html'; | 58 | + var $sHelpPage = 'ktcore/dashboard.html'; |
| 59 | 59 | ||
| 60 | function DashboardDispatcher() { | 60 | function DashboardDispatcher() { |
| 61 | $this->aBreadcrumbs = array( | 61 | $this->aBreadcrumbs = array( |
| @@ -67,25 +67,29 @@ class DashboardDispatcher extends KTStandardDispatcher { | @@ -67,25 +67,29 @@ class DashboardDispatcher extends KTStandardDispatcher { | ||
| 67 | $this->oPage->setShowPortlets(false); | 67 | $this->oPage->setShowPortlets(false); |
| 68 | // retrieve action items for the user. | 68 | // retrieve action items for the user. |
| 69 | // FIXME what is the userid? | 69 | // FIXME what is the userid? |
| 70 | - | ||
| 71 | - | 70 | + |
| 71 | + | ||
| 72 | $oDashletRegistry =& KTDashletRegistry::getSingleton(); | 72 | $oDashletRegistry =& KTDashletRegistry::getSingleton(); |
| 73 | $aDashlets = $oDashletRegistry->getDashlets($this->oUser); | 73 | $aDashlets = $oDashletRegistry->getDashlets($this->oUser); |
| 74 | - | 74 | + |
| 75 | $this->sSection = 'dashboard'; | 75 | $this->sSection = 'dashboard'; |
| 76 | $this->oPage->setBreadcrumbDetails(_kt('Home')); | 76 | $this->oPage->setBreadcrumbDetails(_kt('Home')); |
| 77 | $this->oPage->title = _kt('Dashboard'); | 77 | $this->oPage->title = _kt('Dashboard'); |
| 78 | - | 78 | + |
| 79 | // simplistic improvement over the standard rendering: float half left | 79 | // simplistic improvement over the standard rendering: float half left |
| 80 | // and half right. +Involves no JS -can leave lots of white-space at the bottom. | 80 | // and half right. +Involves no JS -can leave lots of white-space at the bottom. |
| 81 | 81 | ||
| 82 | $aDashletsLeft = array(); | 82 | $aDashletsLeft = array(); |
| 83 | - $aDashletsRight = array(); | 83 | + $aDashletsRight = array(); |
| 84 | 84 | ||
| 85 | $i = 0; | 85 | $i = 0; |
| 86 | foreach ($aDashlets as $oDashlet) { | 86 | foreach ($aDashlets as $oDashlet) { |
| 87 | - if ($i == 0) { $aDashletsLeft[] = $oDashlet; } | ||
| 88 | - else {$aDashletsRight[] = $oDashlet; } | 87 | + if(strpos(strtolower($oDashlet->sTitle), 'welcome to knowledgetree') !== false && !empty($aDashletsLeft)){ |
| 88 | + array_unshift($aDashletsLeft, $oDashlet); | ||
| 89 | + }else{ | ||
| 90 | + if ($i == 0) { $aDashletsLeft[] = $oDashlet; } | ||
| 91 | + else {$aDashletsRight[] = $oDashlet; } | ||
| 92 | + } | ||
| 89 | $i += 1; | 93 | $i += 1; |
| 90 | $i %= 2; | 94 | $i %= 2; |
| 91 | } | 95 | } |
| @@ -97,10 +101,10 @@ class DashboardDispatcher extends KTStandardDispatcher { | @@ -97,10 +101,10 @@ class DashboardDispatcher extends KTStandardDispatcher { | ||
| 97 | $this->oPage->requireJSResource('thirdpartyjs/yui/dom/dom.js'); | 101 | $this->oPage->requireJSResource('thirdpartyjs/yui/dom/dom.js'); |
| 98 | $this->oPage->requireJSResource('thirdpartyjs/yui/dragdrop/dragdrop.js'); | 102 | $this->oPage->requireJSResource('thirdpartyjs/yui/dragdrop/dragdrop.js'); |
| 99 | $this->oPage->requireJSResource('resources/js/DDList.js'); | 103 | $this->oPage->requireJSResource('resources/js/DDList.js'); |
| 100 | - | 104 | + |
| 101 | 105 | ||
| 102 | $this->oUser->refreshDashboadState(); | 106 | $this->oUser->refreshDashboadState(); |
| 103 | - | 107 | + |
| 104 | // dashboard | 108 | // dashboard |
| 105 | $sDashboardState = $this->oUser->getDashboardState(); | 109 | $sDashboardState = $this->oUser->getDashboardState(); |
| 106 | $sDSJS = 'var savedState = '; | 110 | $sDSJS = 'var savedState = '; |
| @@ -114,7 +118,6 @@ class DashboardDispatcher extends KTStandardDispatcher { | @@ -114,7 +118,6 @@ class DashboardDispatcher extends KTStandardDispatcher { | ||
| 114 | $this->oPage->requireJSStandalone($sDSJS); | 118 | $this->oPage->requireJSStandalone($sDSJS); |
| 115 | $this->oPage->requireJSResource('resources/js/dashboard.js'); | 119 | $this->oPage->requireJSResource('resources/js/dashboard.js'); |
| 116 | 120 | ||
| 117 | - | ||
| 118 | // render | 121 | // render |
| 119 | $oTemplating =& KTTemplating::getSingleton(); | 122 | $oTemplating =& KTTemplating::getSingleton(); |
| 120 | $oTemplate = $oTemplating->loadTemplate('kt3/dashboard'); | 123 | $oTemplate = $oTemplating->loadTemplate('kt3/dashboard'); |
| @@ -125,33 +128,33 @@ class DashboardDispatcher extends KTStandardDispatcher { | @@ -125,33 +128,33 @@ class DashboardDispatcher extends KTStandardDispatcher { | ||
| 125 | ); | 128 | ); |
| 126 | return $oTemplate->render($aTemplateData); | 129 | return $oTemplate->render($aTemplateData); |
| 127 | } | 130 | } |
| 128 | - | 131 | + |
| 129 | // return some kind of ID for each dashlet | 132 | // return some kind of ID for each dashlet |
| 130 | // currently uses the class name | 133 | // currently uses the class name |
| 131 | function _getDashletId($oDashlet) { | 134 | function _getDashletId($oDashlet) { |
| 132 | return get_class($oDashlet); | 135 | return get_class($oDashlet); |
| 133 | } | 136 | } |
| 134 | 137 | ||
| 135 | - // disable a dashlet. | 138 | + // disable a dashlet. |
| 136 | // FIXME this very slightly violates the separation of concerns, but its not that flagrant. | 139 | // FIXME this very slightly violates the separation of concerns, but its not that flagrant. |
| 137 | function do_disableDashlet() { | 140 | function do_disableDashlet() { |
| 138 | $sNamespace = KTUtil::arrayGet($_REQUEST, 'fNamespace'); | 141 | $sNamespace = KTUtil::arrayGet($_REQUEST, 'fNamespace'); |
| 139 | $iUserId = $this->oUser->getId(); | 142 | $iUserId = $this->oUser->getId(); |
| 140 | - | 143 | + |
| 141 | if (empty($sNamespace)) { | 144 | if (empty($sNamespace)) { |
| 142 | $this->errorRedirectToMain('No dashlet specified.'); | 145 | $this->errorRedirectToMain('No dashlet specified.'); |
| 143 | exit(0); | 146 | exit(0); |
| 144 | } | 147 | } |
| 145 | - | 148 | + |
| 146 | // do the "delete" | 149 | // do the "delete" |
| 147 | - | 150 | + |
| 148 | $this->startTransaction(); | 151 | $this->startTransaction(); |
| 149 | $aParams = array('sNamespace' => $sNamespace, 'iUserId' => $iUserId); | 152 | $aParams = array('sNamespace' => $sNamespace, 'iUserId' => $iUserId); |
| 150 | $oDD = KTDashletDisable::createFromArray($aParams); | 153 | $oDD = KTDashletDisable::createFromArray($aParams); |
| 151 | if (PEAR::isError($oDD)) { | 154 | if (PEAR::isError($oDD)) { |
| 152 | $this->errorRedirectToMain('Failed to disable the dashlet.'); | 155 | $this->errorRedirectToMain('Failed to disable the dashlet.'); |
| 153 | } | 156 | } |
| 154 | - | 157 | + |
| 155 | $this->commitTransaction(); | 158 | $this->commitTransaction(); |
| 156 | $this->successRedirectToMain('Dashlet disabled.'); | 159 | $this->successRedirectToMain('Dashlet disabled.'); |
| 157 | } | 160 | } |
lib/dashboard/dashletregistry.inc.php
| @@ -5,32 +5,32 @@ | @@ -5,32 +5,32 @@ | ||
| 5 | * KnowledgeTree Open Source Edition | 5 | * KnowledgeTree Open Source Edition |
| 6 | * Document Management Made Simple | 6 | * Document Management Made Simple |
| 7 | * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited | 7 | * Copyright (C) 2004 - 2007 The Jam Warehouse Software (Pty) Limited |
| 8 | - * | 8 | + * |
| 9 | * This program is free software; you can redistribute it and/or modify it under | 9 | * This program is free software; you can redistribute it and/or modify it under |
| 10 | * the terms of the GNU General Public License version 3 as published by the | 10 | * the terms of the GNU General Public License version 3 as published by the |
| 11 | * Free Software Foundation. | 11 | * Free Software Foundation. |
| 12 | - * | 12 | + * |
| 13 | * This program is distributed in the hope that it will be useful, but WITHOUT | 13 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | 15 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 16 | * details. | 16 | * details. |
| 17 | - * | 17 | + * |
| 18 | * You should have received a copy of the GNU General Public License | 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | - * | 20 | + * |
| 21 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, | 21 | * You can contact The Jam Warehouse Software (Pty) Limited, Unit 1, Tramber Place, |
| 22 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. | 22 | * Blake Street, Observatory, 7925 South Africa. or email info@knowledgetree.com. |
| 23 | - * | 23 | + * |
| 24 | * The interactive user interfaces in modified source and object code versions | 24 | * The interactive user interfaces in modified source and object code versions |
| 25 | * of this program must display Appropriate Legal Notices, as required under | 25 | * of this program must display Appropriate Legal Notices, as required under |
| 26 | * Section 5 of the GNU General Public License version 3. | 26 | * Section 5 of the GNU General Public License version 3. |
| 27 | - * | 27 | + * |
| 28 | * In accordance with Section 7(b) of the GNU General Public License version 3, | 28 | * In accordance with Section 7(b) of the GNU General Public License version 3, |
| 29 | * these Appropriate Legal Notices must retain the display of the "Powered by | 29 | * these Appropriate Legal Notices must retain the display of the "Powered by |
| 30 | - * KnowledgeTree" logo and retain the original copyright notice. If the display of the | 30 | + * KnowledgeTree" logo and retain the original copyright notice. If the display of the |
| 31 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices | 31 | * logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices |
| 32 | - * must display the words "Powered by KnowledgeTree" and retain the original | ||
| 33 | - * copyright notice. | 32 | + * must display the words "Powered by KnowledgeTree" and retain the original |
| 33 | + * copyright notice. | ||
| 34 | * Contributor( s): ______________________________________ | 34 | * Contributor( s): ______________________________________ |
| 35 | * | 35 | * |
| 36 | */ | 36 | */ |
| @@ -53,6 +53,55 @@ class KTDashletRegistry { | @@ -53,6 +53,55 @@ class KTDashletRegistry { | ||
| 53 | $this->nsnames[$nsname] = array($name, $filename, $nsname, $sPlugin); | 53 | $this->nsnames[$nsname] = array($name, $filename, $nsname, $sPlugin); |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | + /** | ||
| 57 | + * Get any dashlets added since the user's last login | ||
| 58 | + * | ||
| 59 | + * @param object $oUser | ||
| 60 | + */ | ||
| 61 | + function getNewDashlets($oUser, $sCurrent) { | ||
| 62 | + $new = array(); | ||
| 63 | + $inactive = array(); | ||
| 64 | + | ||
| 65 | + static $sInactive = ''; | ||
| 66 | + $sIgnore = (!empty($sInactive)) ? $sCurrent.','.$sInactive : $sCurrent; | ||
| 67 | + | ||
| 68 | + // Get all dashlets that haven't already been displayed to the user and are active for the user | ||
| 69 | + $query = "SELECT * FROM plugin_helper h | ||
| 70 | + INNER JOIN plugins p ON (h.plugin = p.namespace) | ||
| 71 | + WHERE p.disabled = 0 AND classtype = 'dashlet' | ||
| 72 | + AND h.classname NOT IN ($sIgnore)"; | ||
| 73 | + | ||
| 74 | + $res = DBUtil::getResultArray($query); | ||
| 75 | + | ||
| 76 | + // If the query is not empty, get the dashlets and return the new active ones | ||
| 77 | + // Add the inactive ones the list. | ||
| 78 | + if(!PEAR::isError($res) && !empty($res)){ | ||
| 79 | + $oRegistry =& KTPluginRegistry::getSingleton(); | ||
| 80 | + foreach ($res as $item){ | ||
| 81 | + $name = $item['classname']; | ||
| 82 | + $filename = $item['pathname']; | ||
| 83 | + $sPluginName = $item['plugin']; | ||
| 84 | + | ||
| 85 | + require_once($filename); | ||
| 86 | + $oPlugin =& $oRegistry->getPlugin($sPluginName); | ||
| 87 | + | ||
| 88 | + $oDashlet = new $name; | ||
| 89 | + $oDashlet->setPlugin($oPlugin); | ||
| 90 | + if ($oDashlet->is_active($oUser)) { | ||
| 91 | + $new[] = $name; | ||
| 92 | + }else{ | ||
| 93 | + $inactive[] = "'$name'"; | ||
| 94 | + } | ||
| 95 | + } | ||
| 96 | + // Add new inactive dashlets | ||
| 97 | + $sNewInactive = implode(',', $inactive); | ||
| 98 | + $sInactive = (!empty($sInactive)) ? $sInactive.','.$sNewInactive : $sNewInactive; | ||
| 99 | + | ||
| 100 | + return $new; | ||
| 101 | + } | ||
| 102 | + return ''; | ||
| 103 | + } | ||
| 104 | + | ||
| 56 | // FIXME we might want to do the pruning now, but I'm unsure how to handle the preconditions. | 105 | // FIXME we might want to do the pruning now, but I'm unsure how to handle the preconditions. |
| 57 | function getDashlets($oUser) { | 106 | function getDashlets($oUser) { |
| 58 | $aDashlets = array(); | 107 | $aDashlets = array(); |
lib/users/User.inc
| @@ -81,6 +81,12 @@ class User extends KTEntity { | @@ -81,6 +81,12 @@ class User extends KTEntity { | ||
| 81 | var $dLastLogin = null; | 81 | var $dLastLogin = null; |
| 82 | var $bDisabled = false; | 82 | var $bDisabled = false; |
| 83 | 83 | ||
| 84 | + /** | ||
| 85 | + * The dashboard state for the current user | ||
| 86 | + * @var string | ||
| 87 | + */ | ||
| 88 | + var $sDashboardState = ''; | ||
| 89 | + | ||
| 84 | var $_aFieldToSelect = array( | 90 | var $_aFieldToSelect = array( |
| 85 | 'iId' => 'id', | 91 | 'iId' => 'id', |
| 86 | 'sUserName' => 'username', | 92 | 'sUserName' => 'username', |
| @@ -176,23 +182,26 @@ class User extends KTEntity { | @@ -176,23 +182,26 @@ class User extends KTEntity { | ||
| 176 | } | 182 | } |
| 177 | 183 | ||
| 178 | function getDashboardState() { | 184 | function getDashboardState() { |
| 179 | - return KTUtil::getSystemSetting($this->_getDashboardStateKey()); | 185 | + if(empty($this->sDashboardState)){ |
| 186 | + $this->sDashboardState = KTUtil::getSystemSetting($this->_getDashboardStateKey()); | ||
| 187 | + } | ||
| 188 | + return $this->sDashboardState; | ||
| 180 | } | 189 | } |
| 181 | 190 | ||
| 182 | function setDashboardState($mValue) { | 191 | function setDashboardState($mValue) { |
| 192 | + $this->sDashboardState = $mValue; | ||
| 183 | KTUtil::setSystemSetting($this->_getDashboardStateKey(), $mValue); | 193 | KTUtil::setSystemSetting($this->_getDashboardStateKey(), $mValue); |
| 184 | } | 194 | } |
| 185 | 195 | ||
| 186 | function refreshDashboadState() | 196 | function refreshDashboadState() |
| 187 | { | 197 | { |
| 188 | require_once(KT_DIR . "/thirdparty/pear/JSON.php"); | 198 | require_once(KT_DIR . "/thirdparty/pear/JSON.php"); |
| 189 | - | ||
| 190 | $dashletRegistry = & KTDashletRegistry::getSingleton(); | 199 | $dashletRegistry = & KTDashletRegistry::getSingleton(); |
| 191 | 200 | ||
| 192 | - $aDashlets = $dashletRegistry->getDashlets($this); | 201 | + $update = false; |
| 202 | + $knownlist = array(); | ||
| 193 | 203 | ||
| 194 | $oJSON = new Services_JSON(); | 204 | $oJSON = new Services_JSON(); |
| 195 | - | ||
| 196 | $state = $this->getDashboardState(); | 205 | $state = $this->getDashboardState(); |
| 197 | $dashlets = $oJSON->decode($state); | 206 | $dashlets = $oJSON->decode($state); |
| 198 | 207 | ||
| @@ -200,34 +209,59 @@ class User extends KTEntity { | @@ -200,34 +209,59 @@ class User extends KTEntity { | ||
| 200 | if (!isset($dashlets->right)) $dashlets->right = array(); | 209 | if (!isset($dashlets->right)) $dashlets->right = array(); |
| 201 | $mergedlist = kt_array_merge($dashlets->left,$dashlets->right); | 210 | $mergedlist = kt_array_merge($dashlets->left,$dashlets->right); |
| 202 | 211 | ||
| 203 | - | ||
| 204 | - $knownlist = array(); | ||
| 205 | foreach($mergedlist as $dashlet) | 212 | foreach($mergedlist as $dashlet) |
| 206 | { | 213 | { |
| 207 | - array_push($knownlist,$dashlet->id); | 214 | + array_push($knownlist,"'".$dashlet->id."'"); |
| 208 | } | 215 | } |
| 209 | - $update=false; | ||
| 210 | 216 | ||
| 211 | - //if (!isset($dashlets->left)) $dashlets->left=array(); | ||
| 212 | - //if (!isset($dashlets->right)) $dashlets->right=array(); | 217 | + $sKnownlist = implode(',', $knownlist); |
| 218 | + $aDashlets = $dashletRegistry->getNewDashlets($this, $sKnownlist); | ||
| 219 | + | ||
| 220 | + if(!empty($aDashlets)){ | ||
| 221 | + $column=1; | ||
| 222 | + foreach($aDashlets as $class) | ||
| 223 | + { | ||
| 224 | + $column = ($column + 1) %2; | ||
| 225 | + $obj = new stdClass(); | ||
| 226 | + $obj->id=$class; | ||
| 227 | + $obj->state=0; | ||
| 228 | + | ||
| 229 | + if ($column == 0) | ||
| 230 | + array_push($dashlets->left,$obj); | ||
| 231 | + else | ||
| 232 | + array_push($dashlets->right,$obj); | ||
| 233 | + $update=true; | ||
| 234 | + } | ||
| 235 | + } | ||
| 213 | 236 | ||
| 214 | - $column=1; | ||
| 215 | - foreach($aDashlets as $dashlet) | ||
| 216 | - { | ||
| 217 | - $class = get_class($dashlet); | ||
| 218 | - $column=($column + 1) %2; | ||
| 219 | - if (!in_array($class,$knownlist)) | ||
| 220 | - { | ||
| 221 | - $obj = new stdClass(); | ||
| 222 | - $obj->id=$class; | ||
| 223 | - $obj->state=0; | ||
| 224 | - | ||
| 225 | - if ($column == 0) | ||
| 226 | - array_push($dashlets->left,$obj); | ||
| 227 | - else | ||
| 228 | - array_push($dashlets->right,$obj); | ||
| 229 | - $update=true; | ||
| 230 | - } | 237 | + // Check if the KT Info dashlet is being displayed |
| 238 | + // If it's not in the top left corner, move it there. | ||
| 239 | + if(!(strpos($sKnownlist, 'KTInfoDashlet') === false) && $knownlist[0] != "'KTInfoDashlet'"){ | ||
| 240 | + $left = $dashlets->left; | ||
| 241 | + $right = $dashlets->right; | ||
| 242 | + | ||
| 243 | + $found = false; | ||
| 244 | + $update = true; | ||
| 245 | + foreach($left as $key => $item){ | ||
| 246 | + if($item->id == 'KTInfoDashlet'){ | ||
| 247 | + // found the dashlet | ||
| 248 | + $found = 'true'; | ||
| 249 | + array_splice($dashlets->left, $key, 1); | ||
| 250 | + array_unshift($dashlets->left, $item); | ||
| 251 | + continue; | ||
| 252 | + } | ||
| 253 | + } | ||
| 254 | + if(!$found){ | ||
| 255 | + foreach($right as $key => $item){ | ||
| 256 | + if($item->id == 'KTInfoDashlet'){ | ||
| 257 | + // found the dashlet | ||
| 258 | + $found = 'true'; | ||
| 259 | + array_splice($dashlets->right, $key, 1); | ||
| 260 | + array_unshift($dashlets->left, $item); | ||
| 261 | + continue; | ||
| 262 | + } | ||
| 263 | + } | ||
| 264 | + } | ||
| 231 | } | 265 | } |
| 232 | 266 | ||
| 233 | if ($update) | 267 | if ($update) |