Commit 419b5e002853f1854e6cea961b4351efcdd67fe4
1 parent
20f4bc35
- 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]) git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@5004 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
7 changed files
with
134 additions
and
2 deletions
lib/browse/browseutil.inc.php
| ... | ... | @@ -294,11 +294,14 @@ class KTBrowseUtil { |
| 294 | 294 | */ |
| 295 | 295 | function getBrowseableFolders($oUser) { |
| 296 | 296 | $aPermissionDescriptors = KTPermissionUtil::getPermissionDescriptorsForUser($oUser); |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 297 | 300 | if (empty($aPermissionDescriptors)) { |
| 298 | 301 | return array(); |
| 299 | 302 | } |
| 300 | 303 | $sPermissionDescriptors = DBUtil::paramArray($aPermissionDescriptors); |
| 301 | - | |
| 304 | + | |
| 302 | 305 | $sFoldersTable = KTUtil::getTableName('folders'); |
| 303 | 306 | $sPLTable = KTUtil::getTableName('permission_lookups'); |
| 304 | 307 | $sPLATable = KTUtil::getTableName('permission_lookup_assignments'); |
| ... | ... | @@ -310,9 +313,10 @@ class KTBrowseUtil { |
| 310 | 313 | 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 = ? |
| 311 | 314 | WHERE |
| 312 | 315 | PLA.permission_descriptor_id IN ($sPermissionDescriptors) |
| 313 | - AND NOT PLA2.permission_descriptor_id IN ($sPermissionDescriptors)"; | |
| 316 | + AND NOT (PLA2.permission_descriptor_id IN ($sPermissionDescriptors))"; | |
| 314 | 317 | $aParams = array_merge(array($oPermission->getId(), $oPermission->getId()), $aPermissionDescriptors, $aPermissionDescriptors); |
| 315 | 318 | $res = DBUtil::getResultArrayKey(array($sQuery, $aParams), 'id'); |
| 319 | + | |
| 316 | 320 | if (PEAR::isError($res)) { |
| 317 | 321 | return $res; |
| 318 | 322 | } | ... | ... |
plugins/browseabledashlet/BrowseableDashlet.php
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +require_once(KT_LIB_DIR . '/browse/browseutil.inc.php'); | |
| 4 | + | |
| 5 | +class BrowseableFolderDashlet extends KTBaseDashlet { | |
| 6 | + var $oUser; | |
| 7 | + | |
| 8 | + function is_active($oUser) { | |
| 9 | + $this->oUser = $oUser; | |
| 10 | + | |
| 11 | + return true; | |
| 12 | + } | |
| 13 | + | |
| 14 | + function render() { | |
| 15 | + $oTemplating =& KTTemplating::getSingleton(); | |
| 16 | + $oTemplate = $oTemplating->loadTemplate('browseabledashlet/dashlet'); | |
| 17 | + | |
| 18 | + $aFolders = KTBrowseUtil::getBrowseableFolders($this->oUser); | |
| 19 | + if (PEAR::isError($aFolders)) { | |
| 20 | + // just hide it. | |
| 21 | + $aFolders = array(); | |
| 22 | + } | |
| 23 | + | |
| 24 | + $aTemplateData = array( | |
| 25 | + 'folders' => $aFolders, | |
| 26 | + ); | |
| 27 | + return $oTemplate->render($aTemplateData); | |
| 28 | + } | |
| 29 | +} | |
| 30 | + | |
| 31 | +?> | |
| 0 | 32 | \ No newline at end of file | ... | ... |
plugins/browseabledashlet/BrowseableDashletPlugin.php
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +require_once(KT_LIB_DIR . '/plugins/plugin.inc.php'); | |
| 4 | +require_once(KT_LIB_DIR . '/plugins/pluginregistry.inc.php'); | |
| 5 | + | |
| 6 | +class BrowseableDashletPlugin extends KTPlugin { | |
| 7 | + var $sNamespace = "nbm.browseable.plugin"; | |
| 8 | + | |
| 9 | + function setup() { | |
| 10 | + $this->registerDashlet('BrowseableFolderDashlet', 'nbm.browseable.dashlet', 'BrowseableDashlet.php'); | |
| 11 | + | |
| 12 | + require_once(KT_LIB_DIR . "/templating/templating.inc.php"); | |
| 13 | + $oTemplating =& KTTemplating::getSingleton(); | |
| 14 | + $oTemplating->addLocation('browseabledashlet', '/plugins/browseabledashlet/templates'); | |
| 15 | + } | |
| 16 | +} | |
| 17 | + | |
| 18 | +$oPluginRegistry =& KTPluginRegistry::getSingleton(); | |
| 19 | +$oPluginRegistry->registerPlugin('BrowseableDashletPlugin', 'nbm.browseable.plugin', __FILE__); | |
| 20 | +?> | ... | ... |
plugins/ktstandard/SearchDashlet.php
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | + | |
| 4 | +class SearchDashlet extends KTBaseDashlet { | |
| 5 | + function render() { | |
| 6 | + $oTemplating =& KTTemplating::getSingleton(); | |
| 7 | + $oTemplate = $oTemplating->loadTemplate('ktstandard/searchdashlet/dashlet'); | |
| 8 | + | |
| 9 | + $aSearches = KTSavedSearch::getSearches(); | |
| 10 | + // empty on error. | |
| 11 | + if (PEAR::isError($aSearches)) { | |
| 12 | + $aSearches = array(); | |
| 13 | + } | |
| 14 | + | |
| 15 | + | |
| 16 | + $aTemplateData = array( | |
| 17 | + 'savedsearches' => $aSearches, | |
| 18 | + ); | |
| 19 | + return $oTemplate->render($aTemplateData); | |
| 20 | + } | |
| 21 | +} | |
| 22 | + | |
| 23 | +?> | |
| 0 | 24 | \ No newline at end of file | ... | ... |
plugins/ktstandard/SearchDashletPlugin.php
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +require_once(KT_LIB_DIR . '/plugins/plugin.inc.php'); | |
| 4 | +require_once(KT_LIB_DIR . '/plugins/pluginregistry.inc.php'); | |
| 5 | + | |
| 6 | +class SearchDashletPlugin extends KTPlugin { | |
| 7 | + var $sNamespace = "nbm.searchdashlet.plugin"; | |
| 8 | + | |
| 9 | + function setup() { | |
| 10 | + $this->registerDashlet('SearchDashlet', 'nbm.searchdashlet.dashlet', 'SearchDashlet.php'); | |
| 11 | + | |
| 12 | + require_once(KT_LIB_DIR . "/templating/templating.inc.php"); | |
| 13 | + $oTemplating =& KTTemplating::getSingleton(); | |
| 14 | + $oTemplating->addLocation('searchdashlet', '/plugins/searchdashlet/templates'); | |
| 15 | + } | |
| 16 | +} | |
| 17 | + | |
| 18 | +$oPluginRegistry =& KTPluginRegistry::getSingleton(); | |
| 19 | +$oPluginRegistry->registerPlugin('SearchDashletPlugin', 'nbm.searchdashlet.plugin', __FILE__); | |
| 20 | +?> | ... | ... |
resources/css/kt-framing.css
| ... | ... | @@ -680,6 +680,15 @@ a.main_nav_item { |
| 680 | 680 | padding-left: 17px; |
| 681 | 681 | } |
| 682 | 682 | |
| 683 | +#dashlet-search-text { | |
| 684 | + border: 1px solid black; | |
| 685 | + background: white url(../../resources/graphics/search-button.png) center left no-repeat; | |
| 686 | + margin: 0.5em 0.5em 0.5em 0; | |
| 687 | + padding: 3px; | |
| 688 | + padding-left: 17px; | |
| 689 | + width: 80%; | |
| 690 | +} | |
| 691 | + | |
| 683 | 692 | .searchbutton { |
| 684 | 693 | border: 1px solid black; |
| 685 | 694 | margin: 0.5em; | ... | ... |
templates/ktstandard/searchdashlet/dashlet.smarty
0 → 100644
| 1 | +<fieldset> | |
| 2 | +<legend>{i18n}Search{/i18n}</legend> | |
| 3 | + | |
| 4 | +<form action="{ktLink base="search/simpleSearch.php"}" method="GET"> | |
| 5 | +<input type="text" name="fSearchableText" id="dashlet-search-text" | |
| 6 | +size="15" /><input type="submit" value="{i18n}search{/i18n}" | |
| 7 | +class="searchbutton frontpage" /> | |
| 8 | +</form> | |
| 9 | + | |
| 10 | +<a href="{$rootUrl}/search/booleanSearch.php">{i18n}Advanced | |
| 11 | +Search{/i18n}</a> | |
| 12 | + | |
| 13 | +{if (!empty($saved_searches))} | |
| 14 | +<h3>Saved Searches</h3> | |
| 15 | + | |
| 16 | +{foreach item=oSearch from=$saved_searches} | |
| 17 | +<span class="descriptiveText">Saved Search: </span><a | |
| 18 | +href="{"booleanSearch"|generateControllerUrl}&qs[action]=performSearch&qs[fSavedSearchId]={$oSearch->getId()}">{$oSearch->getName()}</a><br /> | |
| 19 | +{/foreach} | |
| 20 | + | |
| 21 | +<hr /> | |
| 22 | +{/if} | |
| 23 | + | |
| 24 | + | |
| 25 | +</fieldset> | |
| 0 | 26 | \ No newline at end of file | ... | ... |