-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add dropdown list to advanced search criteria #42
Comments
Interesting feature, but will not be in 0.2 which should be released soon. |
Can you give me advice to implement this feature in your code. In which file can i works ? And maybe i can propose code... Regards, |
You new to create a new type and define how it will appear in search form in templates/search_displayer.tpl There is already a select box for boolean values, you can use the same idea. |
hi, so i tried that but i had some problems 1 - I had copy already existing function 'get_attribute' and created an adapt to a new smarty function in smarty.inc.php to return an array -> function get_attributes_entity($params, $smarty) {
$return = "";
$dn = $params["dn"];
$attributes = $params["attributes"];
$ldap_url = $params["ldap_url"];
$ldap_starttls = $params["ldap_starttls"];
$ldap_binddn = $params["ldap_binddn"];
$ldap_bindpw = $params["ldap_bindpw"];
$ldap_user_filter = $params["ldap_user_filter"];
# Connect to LDAP
$ldap_connection = wp_ldap_connect($ldap_url, $ldap_starttls, $ldap_binddn, $ldap_bindpw);
$ldap = $ldap_connection[0];
$result = $ldap_connection[1];
if ($ldap) {
# Search entry
$search = ldap_search($ldap, $dn, $ldap_user_filter, array($attributes));
$errno = ldap_errno($ldap);
if ( $errno ) {
error_log("LDAP - Search error $errno (".ldap_error($ldap).")");
} else {
$entry = ldap_get_entries($ldap, $search);
//$return = $entry[0][$attribute][0];
$return = $entry;
}
}
$template->assign($params['entitys'], $return);
/*return $return;*/
} 2 - i had register this new plugin in index.php -> # Register plugins
require_once("../lib/smarty.inc.php");
$smarty->registerPlugin("function", "get_attribute", "get_attribute");
$smarty->registerPlugin("function", "convert_ldap_date", "convert_ldap_date");
$smarty->registerPlugin("function", "get_attributes_entity", "get_attributes_entity"); 3 - and i tried to called this function and manipulate the retrurned array values in search_displayer.tpl -> {elseif {$item} eq 'organizationalunit' and $type eq 'entity'}
{get_attributes_entity entitys="entitysValues" dn="ou=structures,dc=univ-psl,dc=fr" attributes="supanncodeentite,ou" ldap_url="{$ldap_params.ldap_url}" ldap_starttls="{$ldap_params.ldap_starttls}" ldap_binddn="{$ldap_params.ldap_binddn}" ldap_bindpw="{$ldap_params.ldap_bindpw}" ldap_user_filter="ou=*"}
<select class="form-control" id="{$item}" name="{$item}" placeholder="{$label}">
{foreach from=$entitysValues key=supanncodeentite item=ou}
{*<option value="{$entity.supanncodeentite[0]}">{$entity.ou}</option>*}
{$supanncodeentite} : {$ou}<br/>
{$entitys|@print_r}
{/foreach}
</select>
{else}.... But at this moment i can not take values inside returned array. Ans i don't now if my function/plugin return something... Maybe you can help me ? Regards, |
You must not assign to template inside the smarty function. You need to call the function in the template. |
Seems a plugin cannot return an array: smarty-php/smarty#228 The only solution I see is to search for values in php code and assign the result to a template var. It is not as clean as calling directly the plugin in smarty template, but this should work. I will give a try. |
Code done in #74 |
Hi,
it's possible to add dropdown list to advanced for some search criteria like team. The list may be contain in ldap or just right in hard list in config files ?
This functionality to help users who don't know the name of all team in organisation and want to know members of differents teams or services..
Regards,
vlepetit
The text was updated successfully, but these errors were encountered: