--- /dev/null
+<?php class Operator_Exception extends Horde_Exception {}
\ No newline at end of file
$vars->set('enddate', $enddate);
}
+ try {
+ $accountcodes = Operator::getAccountCodes(true);
+ } catch (Exception $e) {
+ $GLOBALS['notification']->push($e);
+ $accountcodes = array();
+ }
+
// Parameters for Horde_Form_datetime
$start_year = date('Y', $now) - 3;
$params = array($start_year, $end_year, $picker, $format_in,
$format_out, $show_seconds);
- $this->addVariable(_("Account Code"), 'accountcode', 'enum', false, false, null, array(Operator::getAccountCodes(true)));
+ $this->addVariable(_("Account Code"), 'accountcode', 'enum', false, false, null, array($accountcodes));
$this->addVariable(_("Destination Context"), 'dcontext', 'text', false, false, _("An empty destination context will match all destination contexts."));
$this->addVariable(_("Start Date/Time"), 'startdate', 'datetime', true, false, null, $params);
$this->addVariable(_("End Date/Time"), 'enddate', 'datetime', true, false, null, $params);
{
global $operator;
- $accountcodes = $operator->driver->getAccountCodes();
+ // Set up arrays for filtering
+ $keys = $values = $operator->driver->getAccountCodes();
- if (Horde_Auth::isAdmin() ||
+ if (Horde_Auth::isAdmin() ||
$GLOBALS['perms']->hasPermission('operator:accountcodes',
Horde_Auth::getAuth(),
Horde_Perms::READ)) {
if (!$permfilter ||
$GLOBALS['perms']->hasPermission('operator:accountcodes:%',
- Horde_Auth::geAuth(),
+ Horde_Auth::getAuth(),
Horde_Perms::READ)) {
// Add an option to select all accounts
- $keys = $accountcodes;
array_unshift($keys, '%');
- $values = $accountcodes;
array_unshift($values, _("-- All Accounts Combined --"));
}
-
+
// Only add the Empty value if it is exists in the backend
if ($index = array_search('', $values)) {
$values[$index] = _("-- Empty Accountcode --");
}
- // Filter the returned list of account codes through Permissions
- // if requested.
- $accountcodes = array();
- foreach ($keys as $index => $accountcode) {
- if ($permfilter) {
+ if ($permfilter) {
+ // Filter the returned list of account codes through Permissions
+ // if requested.
+ $accountcodes = array();
+ foreach ($keys as $index => $accountcode) {
if (empty($accountcode)) {
$permitem = 'operator:accountcodes';
} else {
Horde_Perms::SHOW)) {
$accountcodes[$accountcode] = $values[$index];
}
- } else {
- $accountcodes[$accountcode] = $values[$index];
}
+
+ if (empty($accountcodes)) {
+ throw new Operator_Exception(_("You do not have permission to view any accounts."));
+ }
+ } else {
+ $accountcodes = array_merge($keys, $values);
}
+
return $accountcodes;
}