/**
* Search the database for call detail records, taking permissions into
* consideration.
*
* @return array [0] contains summary statistics; [1] is an array of the
* actual call records.
* @throws Operator_Exception
*/
public function getRecords($start, $end, $accountcode = null, $dcontext = null, $rowstart = 0, $rowlimit = 100)
{
// Start Date
if (!is_a($start, 'Horde_Date')) {
$start = new Horde_Date($start);
}
// End Date
if (!is_a($end, 'Horde_Date')) {
$end = new Horde_Date($end);
}
if ($start->compareDate($end) > 0) {
throw new Operator_Exception(_("\"Start\" date must be on or before \"End\" date."));
}
if (empty($accountcode) || $accountcode == '%') {
$permentry = 'operator:accountcodes';
} else {
$permentry = 'operator:accountcodes:' . $accountcode;
}
$perms = $GLOBALS['injector']->getInstance('Horde_Perms');
if ($GLOBALS['registry']->isAdmin() || $perms->hasPermission('operator:accountcodes', $GLOBALS['registry']->getAuth(), Horde_Perms::READ) || $perms->hasPermission($permentry, $GLOBALS['registry']->getAuth(), Horde_Perms::READ)) {
return $this->_getRecords($start, $end, $accountcode, $dcontext, $rowstart, $rowlimit);
}
throw new Operator_Exception(_("You do not have permission to view call detail records for that account code."));
}