Giter Site home page Giter Site logo

Comments (8)

coudot avatar coudot commented on August 27, 2024

Interesting feature, but will not be in 0.2 which should be released soon.

from white-pages.

vlepetit avatar vlepetit commented on August 27, 2024

Can you give me advice to implement this feature in your code.

In which file can i works ?
the best way or approach ?

And maybe i can propose code...

Regards,
vlepetit

from white-pages.

coudot avatar coudot commented on August 27, 2024

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.

from white-pages.

vlepetit avatar vlepetit commented on August 27, 2024

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,
vlepetit

from white-pages.

coudot avatar coudot commented on August 27, 2024

You must not assign to template inside the smarty function. You need to call the function in the template.

from white-pages.

coudot avatar coudot commented on August 27, 2024

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.

from white-pages.

coudot avatar coudot commented on August 27, 2024

Code done in #74

from white-pages.

coudot avatar coudot commented on August 27, 2024

Doc updated: https://ltb-project.org/documentation/white-pages/0.3/config_attributes

from white-pages.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.