Hi,
This is a bit of a wiki help question, but hopefully people here might have had some experience with this!
I'm setting up a wiki for use on our company intranet, and I've created a page that will pull information out of active directory, and publish it, so employees have an easy way of finding each others contact details. I've created the page by using PHP inside of the wiki page, which runs an LDAP query, this all works fine, and displays the information correctly in an unsorted format. I would like to sort the information by employee name. I have the code, and it works in a plain PHP file perfectly, however, when I copy & paste the working code from the PHP file, into our wiki (Dokuwiki), the sort function fails to work. I've looked through a few options, such as register_globals being off in the PHP.ini, and set it to ON, but this hasn't helped. Below is a snip of my code, can anyone suggest a way to get this working in a wiki page?
Cheers
Ben
<snip>
$info = ldap_get_entries($connect, $read);
function my_sort(&$a, &$b)
{
global $sort_by;
if ($a[$sort_by][0]==$b[$sort_by][0]) return 0;
return ($a[$sort_by][0]<$b[$sort_by][0]) ? -1 : 1;
}
$sort_by = 'displayname';
usort($info, 'my_sort');
print "<table><tr>"
. "<td><b>Name</b></td>"
. "<td><b>Mobile Number</b></td>"
. "</tr>";
for($i=1;$i<@$info[$i];$i++)
{
print "<tr><td>" . $info[$i]["displayname"][0] . "</td>";
if (isset($info[$i]["mobile"][0]))
{
print "<td>" . $info[$i]["mobile"][0] . "</td></tr>";
} else {
print "<td>No Number Available</td></tr>";
}
}
print "</table>";
<snip>