From 419b5e002853f1854e6cea961b4351efcdd67fe4 Mon Sep 17 00:00:00 2001 From: Brad Shuttleworth Date: Fri, 24 Feb 2006 15:11:22 +0000 Subject: [PATCH] - add browseable folder dashlet - add search dashlet - correct NBM's understanding of boolean association: NOT x IN [y] == (NOT X) in [y] != NOT (x in [y]) --- lib/browse/browseutil.inc.php | 8 ++++++-- plugins/browseabledashlet/BrowseableDashlet.php | 31 +++++++++++++++++++++++++++++++ plugins/browseabledashlet/BrowseableDashletPlugin.php | 20 ++++++++++++++++++++ plugins/ktstandard/SearchDashlet.php | 23 +++++++++++++++++++++++ plugins/ktstandard/SearchDashletPlugin.php | 20 ++++++++++++++++++++ resources/css/kt-framing.css | 9 +++++++++ templates/ktstandard/searchdashlet/dashlet.smarty | 25 +++++++++++++++++++++++++ 7 files changed, 134 insertions(+), 2 deletions(-) create mode 100644 plugins/browseabledashlet/BrowseableDashlet.php create mode 100644 plugins/browseabledashlet/BrowseableDashletPlugin.php create mode 100644 plugins/ktstandard/SearchDashlet.php create mode 100644 plugins/ktstandard/SearchDashletPlugin.php create mode 100644 templates/ktstandard/searchdashlet/dashlet.smarty diff --git a/lib/browse/browseutil.inc.php b/lib/browse/browseutil.inc.php index a6e749d..00a9724 100644 --- a/lib/browse/browseutil.inc.php +++ b/lib/browse/browseutil.inc.php @@ -294,11 +294,14 @@ class KTBrowseUtil { */ function getBrowseableFolders($oUser) { $aPermissionDescriptors = KTPermissionUtil::getPermissionDescriptorsForUser($oUser); + + + if (empty($aPermissionDescriptors)) { return array(); } $sPermissionDescriptors = DBUtil::paramArray($aPermissionDescriptors); - + $sFoldersTable = KTUtil::getTableName('folders'); $sPLTable = KTUtil::getTableName('permission_lookups'); $sPLATable = KTUtil::getTableName('permission_lookup_assignments'); @@ -310,9 +313,10 @@ class KTBrowseUtil { LEFT JOIN $sPLTable AS PL2 ON F2.permission_lookup_id = PL2.id LEFT JOIN $sPLATable AS PLA2 ON PLA2.permission_lookup_id = PL2.id AND PLA2.permission_id = ? WHERE PLA.permission_descriptor_id IN ($sPermissionDescriptors) - AND NOT PLA2.permission_descriptor_id IN ($sPermissionDescriptors)"; + AND NOT (PLA2.permission_descriptor_id IN ($sPermissionDescriptors))"; $aParams = array_merge(array($oPermission->getId(), $oPermission->getId()), $aPermissionDescriptors, $aPermissionDescriptors); $res = DBUtil::getResultArrayKey(array($sQuery, $aParams), 'id'); + if (PEAR::isError($res)) { return $res; } diff --git a/plugins/browseabledashlet/BrowseableDashlet.php b/plugins/browseabledashlet/BrowseableDashlet.php new file mode 100644 index 0000000..03518c9 --- /dev/null +++ b/plugins/browseabledashlet/BrowseableDashlet.php @@ -0,0 +1,31 @@ +oUser = $oUser; + + return true; + } + + function render() { + $oTemplating =& KTTemplating::getSingleton(); + $oTemplate = $oTemplating->loadTemplate('browseabledashlet/dashlet'); + + $aFolders = KTBrowseUtil::getBrowseableFolders($this->oUser); + if (PEAR::isError($aFolders)) { + // just hide it. + $aFolders = array(); + } + + $aTemplateData = array( + 'folders' => $aFolders, + ); + return $oTemplate->render($aTemplateData); + } +} + +?> \ No newline at end of file diff --git a/plugins/browseabledashlet/BrowseableDashletPlugin.php b/plugins/browseabledashlet/BrowseableDashletPlugin.php new file mode 100644 index 0000000..f743db8 --- /dev/null +++ b/plugins/browseabledashlet/BrowseableDashletPlugin.php @@ -0,0 +1,20 @@ +registerDashlet('BrowseableFolderDashlet', 'nbm.browseable.dashlet', 'BrowseableDashlet.php'); + + require_once(KT_LIB_DIR . "/templating/templating.inc.php"); + $oTemplating =& KTTemplating::getSingleton(); + $oTemplating->addLocation('browseabledashlet', '/plugins/browseabledashlet/templates'); + } +} + +$oPluginRegistry =& KTPluginRegistry::getSingleton(); +$oPluginRegistry->registerPlugin('BrowseableDashletPlugin', 'nbm.browseable.plugin', __FILE__); +?> diff --git a/plugins/ktstandard/SearchDashlet.php b/plugins/ktstandard/SearchDashlet.php new file mode 100644 index 0000000..bdb71ac --- /dev/null +++ b/plugins/ktstandard/SearchDashlet.php @@ -0,0 +1,23 @@ +loadTemplate('ktstandard/searchdashlet/dashlet'); + + $aSearches = KTSavedSearch::getSearches(); + // empty on error. + if (PEAR::isError($aSearches)) { + $aSearches = array(); + } + + + $aTemplateData = array( + 'savedsearches' => $aSearches, + ); + return $oTemplate->render($aTemplateData); + } +} + +?> \ No newline at end of file diff --git a/plugins/ktstandard/SearchDashletPlugin.php b/plugins/ktstandard/SearchDashletPlugin.php new file mode 100644 index 0000000..f694f34 --- /dev/null +++ b/plugins/ktstandard/SearchDashletPlugin.php @@ -0,0 +1,20 @@ +registerDashlet('SearchDashlet', 'nbm.searchdashlet.dashlet', 'SearchDashlet.php'); + + require_once(KT_LIB_DIR . "/templating/templating.inc.php"); + $oTemplating =& KTTemplating::getSingleton(); + $oTemplating->addLocation('searchdashlet', '/plugins/searchdashlet/templates'); + } +} + +$oPluginRegistry =& KTPluginRegistry::getSingleton(); +$oPluginRegistry->registerPlugin('SearchDashletPlugin', 'nbm.searchdashlet.plugin', __FILE__); +?> diff --git a/resources/css/kt-framing.css b/resources/css/kt-framing.css index 9acf241..2bafe18 100644 --- a/resources/css/kt-framing.css +++ b/resources/css/kt-framing.css @@ -680,6 +680,15 @@ a.main_nav_item { padding-left: 17px; } +#dashlet-search-text { + border: 1px solid black; + background: white url(../../resources/graphics/search-button.png) center left no-repeat; + margin: 0.5em 0.5em 0.5em 0; + padding: 3px; + padding-left: 17px; + width: 80%; +} + .searchbutton { border: 1px solid black; margin: 0.5em; diff --git a/templates/ktstandard/searchdashlet/dashlet.smarty b/templates/ktstandard/searchdashlet/dashlet.smarty new file mode 100644 index 0000000..d03a5ca --- /dev/null +++ b/templates/ktstandard/searchdashlet/dashlet.smarty @@ -0,0 +1,25 @@ +
+{i18n}Search{/i18n} + +
+ +
+ +{i18n}Advanced +Search{/i18n} + +{if (!empty($saved_searches))} +

Saved Searches

+ +{foreach item=oSearch from=$saved_searches} +Saved Search: getId()}">{$oSearch->getName()}
+{/foreach} + +
+{/if} + + +
\ No newline at end of file -- libgit2 0.21.4