[dev] conf.php not getting loaded
Nathan Mills
nathan at nwacg.net
Fri Jun 27 03:57:13 UTC 2008
I found myself needing to call a function from an application in
prefs.php to populate an enum field. I ran across the issue with
including base.php in prefs.php, did some research, and found that I
should be including the one file with the function I need.
That part works, but for some reason conf.php is getting lost when (and
only when) I call the function. If it's never called from prefs.php,
there's no problem. What am I doing wrong?
I'm doing this in prefs.php:
require_once dirname(__FILE__) . '/../lib/Astdial.php';
$_prefs['channel'] = array(
'value' => '',
'locked' => false,
'shared' => false,
'type' => 'enum',
'enum' => Astdial::listDestinations(),
'desc' => _("Phone number where you can be reached")
);
This is the function in question:
function listDestinations()
{
static $dests;
if(is_null($dests)) {
$apiargs = array(
'addresses' => array(''),
'addressbooks' => array('asterisk'),
'fields' => array()
);
$result = $GLOBALS['registry']->call('contacts/search', $apiargs);
if(is_a($result, 'PEAR_Error')) {
return $result;
}
$dests = array();
if(!empty($result)) {
$result = $result[''];
foreach ($result as $dest) {
$dests[$dest['id']] = $dest['name'];
}
}
uasort($dests, 'strcoll');
}
return $dests;
}
Thanks,
-Nathan
More information about the dev
mailing list