[turba] api.php and search source order
Stephen Grier
s.e.grier@qmul.ac.uk
Thu, 26 Sep 2002 12:50:52 +0100
I've recently noticed a small problem when using turba-1.1 and imp-3.1. I have set
the entries in my turba/config/sources.php file in such as way so as to get the
desired order of address search sources for the list on the search page of turba.
However, I noticed that having selected the 'Address Book' link from the compose
window of IMP, the order of the search sources in the list (on contacts.php) was
different from that of my sources.php file, and not the order I want them to
appear in.
I have tracked the cause of this behaviour to the turbaGetSources() function of
lib/api.php. The search_sources list is split into 2 arrays; those which are
read-only, and those not. However, when the 'writable' flag is *not* set,
turbaGetSources() calls array_merge() which alters the order of the search
sources, rather than returning the original list.
The changes I have made to lib/api.php follow. Maybe someone might take a look and
let me know if this is wrong.
Thanks,
Stephen Grier.
--------------------------------------------------------------
# gdiff -Naur api.php.orig api.php
--- api.php.orig Fri Apr 12 17:10:08 2002
+++ api.php Thu Sep 26 12:17:04 2002
@@ -110,6 +110,7 @@
$readonly = array();
$writeonly = array();
+ $all = array();
foreach ($cfgSources as $key => $entry) {
if ($entry['readonly'] && (!isset($entry['admin']) ||
!in_array(Auth::getAuth(), $entry['admin']))) {
@@ -117,12 +118,13 @@
} else {
$writeonly[$key] = $entry['title'];
}
+ $all[$key] = $entry['title'];
}
if ($writeable) {
return $writeonly;
} else {
- return array_merge($readonly, $writeonly);
+ return $all;
}
}
-------------------------------------------------------------
--
Stephen Grier s.e.grier@qmul.ac.uk
Systems Developer
Computing Services
Queen Mary, University of London