[pmwiki-users] Function in .tmpl file (Repost)

Thomas Lederer celok at gmx.net
Mon Mar 27 06:09:09 CST 2006


Hi there,
without urging anyone, maybe here could someone help me code this :)

The plan would be to call a function with $AuthID as argument, and being
able to use a new variable $RealLDAPName (or something) as well in a
Template file or a WikiPage.

Is that possible?

Currently i have a .php file in the cookbook folder, and call
<!--function:LDAPRetrieval $LastModified 2-->, but i can not do this in
a WikiPage Like a Footer or Sidebar...

Tom

Thomas Lederer schrieb am 20.03.2006 7:38 Uhr:
> Patrick R. Michaud schrieb am 17.03.2006 14:29 Uhr:
>>> I would also be happy if i could define the function in config.php so
>>> that the "real name" is accessible through a $LastModRealName and/or
>>> $AuthIDRealName variable... (i actually need both)
>> If you can forward your function, or at least let me know how
>> it's called, I can give an example of turning it into a page
>> variable.
> 
> Actually i think that this would be the better way, because the author
> does appear at so many places. While <!--function does work in the
> template, it does not everywhere. And so i would like to come back to
> this offer.
> 
> Meanwhile i have identified several places where i would need to insert
> the Real Name.
> 
> Here i give the script (which is crude, but i hope clear in what it
> should do), so maybe can help me how to put that into my config, so that
> i have variables which are accessible all over the wiki.
> 
> Like: RecentChangesFmt, In a wikipage (Sidebar), Template...
> 
> Best Regards,
> Tom
> 
> ----
> // Here is what i had as cookbookfile...
> 
> <?php if (!defined('PmWiki')) exit();
> 
> /*
>     This  script should be able to spit out the realname from LDAP
>     servers related to to a login
> 
>     Mode 1: Output of simple text name
>     Mode 2: Output of Link
> */
> 
> function LDAPRetrieval($pagename, $args) {
> 
> // $args being split, because <!--function passes all paramters as $args
> 
> list($requested_user, $mode) = split(" ",$args);
> 
> if ($requested_user) {
> 
> // search and retrieval of the data from the ldap server
> 
>          $ldap_userid = 'uid='.$requested_user;
>          $ldap_dn = 'dc=xxxxx,dc=com';
>          $ldap_server = 'ldap://xxxxx.com';
> 
>          $ldapconn = ldap_connect($ldap_server);
>          $ldapbind = ldap_bind($ldapconn);
> 
>          $result=ldap_search($ldapconn, $ldap_dn, $ldap_userid);
> 
>          $info = ldap_get_entries($ldapconn, $result);
> 
>          $result_givenname = $info[0]["givenname"][0];
>          $result_nickname = $info[0]["nickname"][0];
>          $result_sn = $info[0]["sn"][0];
>          $result_mail = $info[0]["mail"][0];
> 
>          $result_fullname = $result_nickname ?
>                          $result_nickname." ".$result_sn :
>                          $result_givenname." ".$result_sn;
> 
>          ldap_close($ldapconn);
> }
> 
> // Output
> // output should be system if page has no editor (nonexistent pages)
> // can show PmWiki-Users letter (documentation pages)
> // tested by nonexistence in ldap server (ie !result surname)
> 
> $unknown_output = $mode ? $requested_user." (PmWiki-user)" : "system";
> if (!$result_sn) {echo $unknown_output;}
> 
> // Mode 1: textmode, just drop the name
> if ($mode == 1) {echo $result_fullname;}
> 
> if ($mode == 2) {
> echo "<a href='mailto:'.$result_mail.'$result_fullname' ></a>";
> }
> }
> ?>
> 
> _______________________________________________
> pmwiki-users mailing list
> pmwiki-users at pmichaud.com
> http://host.pmichaud.com/mailman/listinfo/pmwiki-users
> 
> 




More information about the pmwiki-users mailing list