diff --git a/doc/conf/LSobject.docbook b/doc/conf/LSobject.docbook index 9241d258..4081f4de 100644 --- a/doc/conf/LSobject.docbook +++ b/doc/conf/LSobject.docbook @@ -68,6 +68,8 @@ // Configuration des recherches de l'objet ), // fin LSsearch + 'globalSearch' => [booleen], + // ioFormat 'ioFormat' => array ( // Configuration des formats d'import/export de l'objet @@ -264,6 +266,14 @@ + + globalSearch + + Inclure ou non ce type d'objet dans le résultat des recherches globales + (Par défaut : True). + + + ioFormat diff --git a/doc/conf/globale.docbook b/doc/conf/globale.docbook index 434ca623..71aba2fc 100644 --- a/doc/conf/globale.docbook +++ b/doc/conf/globale.docbook @@ -115,6 +115,18 @@ define('CONST2','val2') + + globalSearch + + Activation/Désactivation de la recherche globale dans l'annuaire. + + Valeurs possibles : True ou + False + Valeur par défaut : True + + + + keepLSsessionActive diff --git a/doc/conf/srv-ldap.docbook b/doc/conf/srv-ldap.docbook index e2fd4abf..8828b41b 100644 --- a/doc/conf/srv-ldap.docbook +++ b/doc/conf/srv-ldap.docbook @@ -25,6 +25,7 @@ serveur LDAP. ), 'cacheLSprofiles' => [boolean], 'cacheSearch' => [boolean], + 'globalSearch' => [boolean], 'authObjectType' => [LSobject], 'authObjectFilter' => [LSformat], 'authObjectTypeAttrPwd' => [attribut], @@ -129,6 +130,16 @@ serveur LDAP. + + globalSearch + + Activation/Désactivation de la recherche globale sur ce serveur + en particulier. Par defaut, la valeur du paramètre global + globalSearch est utilisée. + + + + authObjectType diff --git a/public_html/css/default/base.css b/public_html/css/default/base.css index f55635c2..5659b949 100644 --- a/public_html/css/default/base.css +++ b/public_html/css/default/base.css @@ -104,6 +104,16 @@ a img { * Menu ****************** */ +form.LSglobal_search { + margin-top: 0.8em; +} + +input.LSglobal_search { + background: url(../../images/default/find.png) no-repeat right #fff; + padding-right: 18px; + width: 138px!important; +} + ul.menu { list-style-image: url(../../images/default/puce.png); } diff --git a/public_html/global_search.php b/public_html/global_search.php new file mode 100644 index 00000000..4caba1e7 --- /dev/null +++ b/public_html/global_search.php @@ -0,0 +1,110 @@ + 'Refresh', + 'url' => 'global_search.php?pattern='.urlencode($pattern).'&refresh=1', + 'action' => 'refresh' + ); + LStemplate :: assign('LSview_actions', $LSview_actions); + + if (LSsession :: loadLSclass('LSform')) { + LSform :: loadDependenciesDisplayView(); + } + + $onlyOne = true; + $onlyOneObject = false; + + if (LSsession :: loadLSclass('LSsearch')) { + $pages=array(); + foreach ($LSobjects as $LSobject) { + if ( LSsession :: loadLSobject($LSobject) ) { + if (!LSconfig::get("LSobjects.$LSobject.globalSearch", true, 'bool')) + continue; + $object = new $LSobject(); + LStemplate :: assign('pagetitle',$object -> getLabel()); + + $LSsearch = new LSsearch($LSobject,'LSview'); + $LSsearch -> setParamsFormPostData(); + + $LSsearch -> run(); + + if ($LSsearch -> total > 0) { + $page = $LSsearch -> getPage(0); + LStemplate :: assign('page',$page); + LStemplate :: assign('LSsearch',$LSsearch); + $pages[] = LSsession :: fetchTemplate('global_search_one_page.tpl'); + + if ($onlyOne) { + if ($LSsearch -> total > 1) { + $onlyOne = false; + } + else { + if ($onlyOneObject === false) { + $onlyOneObject = array ( + 'LSobject' => $LSobject, + 'dn' => $page['list'][0] -> dn, + ); + } + else { + // More than one LSobject type result with one object found + $onlyOne = false; + } + } + } + } + } + } + } + else { + LSsession :: addErrorCode('LSsession_05','LSsearch'); + } + + if ($onlyOne && $onlyOneObject && isset($_REQUEST['LSsearch_submit'])) { + LSsession :: redirect('view.php?LSobject='.$onlyOneObject['LSobject'].'&dn='.urlencode($onlyOneObject['dn'])); + } + + LStemplate :: assign('pattern',$pattern); + LStemplate :: assign('pages',$pages); + LSsession :: setTemplate('global_search.tpl'); + + LStemplate :: addEvent('displayed', array($LSsearch, 'afterUsingResult')); + } + else { + LSerror :: addErrorCode('LSsession_11'); + } +} +else { + LSsession :: setTemplate('login.tpl'); +} + +// Print template +LSsession :: displayTemplate(); + diff --git a/public_html/includes/class/class.LSsession.php b/public_html/includes/class/class.LSsession.php index 3a61a505..f746cc36 100644 --- a/public_html/includes/class/class.LSsession.php +++ b/public_html/includes/class/class.LSsession.php @@ -531,6 +531,8 @@ class LSsession { if (!self :: loadLSobject(self :: $ldapServer['authObjectType'])) { return; } + + LStemplate :: assign('globalSearch', self :: globalSearch()); if (isset($_GET['LSsession_logout'])) { // Trigger LSauth logout @@ -632,6 +634,7 @@ class LSsession { self :: loadLSaccess(); self :: loadLSaddonsViewsAccess(); LStemplate :: assign('LSsession_username',self :: getLSuserObject() -> getDisplayName()); + LStemplate :: assign('globalSearch', self :: globalSearch()); $_SESSION['LSsession']=self :: getContextInfos(); return true; } @@ -2258,7 +2261,18 @@ class LSsession { public static function cacheSearch() { return ( (LSconfig :: get('cacheSearch')) || (self :: $ldapServer['cacheSearch'])); } - + + /** + * Return true if global search is enabled + * + * @author Benjamin Renard + * + * @retval boolean True if global search is enabled, false instead + */ + public static function globalSearch() { + return LSconfig :: get('globalSearch', LSconfig :: get('globalSearch', true, 'bool'), 'bool', self :: $ldapServer); + } + /** * Retourne le label des niveaux pour le serveur ldap courant * diff --git a/public_html/lang/fr_FR.UTF8/lang.php b/public_html/lang/fr_FR.UTF8/lang.php index 94c0d3dc..af5cecb4 100644 --- a/public_html/lang/fr_FR.UTF8/lang.php +++ b/public_html/lang/fr_FR.UTF8/lang.php @@ -71,6 +71,9 @@ $GLOBALS['LSlang'] = array ( "Given email address is invalid." => "L'adresse mail saisie est invalide.", +"Global search" => + "Recherche globale", + "Godfather of ..." => "Parrain de ...", diff --git a/public_html/templates/default/global_search.tpl b/public_html/templates/default/global_search.tpl new file mode 100644 index 00000000..5797340f --- /dev/null +++ b/public_html/templates/default/global_search.tpl @@ -0,0 +1,29 @@ +{include file='ls:top.tpl'} + + + + +{include file='ls:bottom.tpl'} diff --git a/public_html/templates/default/global_search_one_page.tpl b/public_html/templates/default/global_search_one_page.tpl new file mode 100644 index 00000000..2588c5b8 --- /dev/null +++ b/public_html/templates/default/global_search_one_page.tpl @@ -0,0 +1,88 @@ +

+ {$pagetitle} +

+ + + + + {if $LSsearch->displaySubDn} + + {/if} + + + {foreach from=$page.list item=object} + + + {if $LSsearch->displaySubDn}{/if} + + + {foreachelse} + + + + {/foreach} +
+ {if $LSsearch->sort} + + {if $LSsearch->sortBy == 'displayName'} + {$LSsearch->label_objectName|escape:'htmlall'} + {$LSsearch->sortDirection} + {else} + {$LSsearch->label_objectName|escape:'htmlall'} + {/if} + + {else} + {$LSsearch->label_objectName|escape:'htmlall'} + {/if} + + {if $LSsearch->sort} + + {if $LSsearch->sortBy == 'subDn'} + {$LSsearch->label_level|escape:'htmlall'} + {$LSsearch->sortDirection} + {else} + {$LSsearch->label_level|escape:'htmlall'} + {/if} + + {else} + {$LSsearch->label_level|escape:'htmlall'} + {/if} + {$LSsearch->label_actions}
dn|escape:'url'}' class='LSobject-list'>{$object->displayName|escape:'htmlall'} {$object->subDn|escape:'htmlall'} + {foreach from=$object->actions item=item} + {$item.label|escape: + {/foreach} +
{$LSsearch->label_no_result|escape:'htmlall'}
+{$LSsearch->label_total|escape:'htmlall'} +{if $page.nbPages > 1} +

+ + {if $page.nbPages > 10} + {if $page.nb > 5} + {if $page.nb > $page.nbPages-6} + {assign var=start value=$page.nbPages-12} + {else} + {assign var=start value=$page.nb-6} + {/if} + {else} + {assign var=start value=0} + {/if} + < + {foreach from=0|range:10 item=i} + {if $page.nb==$start+$i} + {$page.nb+1} + {else} + {$i+$start+1} + {/if} + {/foreach} + > + {else} + {section name=listpage loop=$page.nbPages step=1} + {if $page.nb == $smarty.section.listpage.index} + {$page.nb+1} + {else} + {$smarty.section.listpage.index+1} + {/if} + {/section} + {/if} +

+{/if} diff --git a/public_html/templates/default/top.tpl b/public_html/templates/default/top.tpl index 2ca5bc01..cb464ed5 100644 --- a/public_html/templates/default/top.tpl +++ b/public_html/templates/default/top.tpl @@ -28,6 +28,14 @@ {/if} + + {if $globalSearch} + + {/if} +