/** * returns multiple records prepared for json transport * * NOTE: we can't use parent::_multipleRecordsToJson here because of the different container handling * * @param Tinebase_Record_RecordSet $_leads Crm_Model_Lead * @return array data */ protected function _multipleRecordsToJson(Tinebase_Record_RecordSet $_records, $_filter = NULL) { if (count($_records) == 0) { return array(); } switch ($_records->getRecordClassName()) { case 'Timetracker_Model_Timesheet': // resolve timeaccounts $timeaccountIds = $_records->timeaccount_id; $timeaccounts = $this->_timeaccountController->getMultiple(array_unique(array_values($timeaccountIds))); Timetracker_Model_TimeaccountGrants::getGrantsOfRecords($timeaccounts, Tinebase_Core::get('currentAccount')); foreach ($_records as $record) { $idx = $timeaccounts->getIndexById($record->timeaccount_id); if ($idx !== FALSE) { $record->timeaccount_id = $timeaccounts[$idx]; $record->timeaccount_id->account_grants = $this->_resolveTimesheetGrantsByTimeaccountGrants($record->timeaccount_id->account_grants, $record->account_id); } else { Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' Could not resolve timeaccount (id: ' . $record->timeaccount_id . '). No permission?'); } } // resolve user afterwards because we compare ids in _resolveTimesheetGrantsByTimeaccountGrants() Tinebase_User::getInstance()->resolveMultipleUsers($_records, array('account_id', 'created_by', 'last_modified_by'), true); break; case 'Timetracker_Model_Timeaccount': // resolve timeaccounts grants Timetracker_Model_TimeaccountGrants::getGrantsOfRecords($_records, Tinebase_Core::get('currentAccount')); $this->_resolveTimeaccountGrants($_records); break; } Tinebase_Tags::getInstance()->getMultipleTagsOfRecords($_records); $_records->setTimezone(Tinebase_Core::get('userTimeZone')); $_records->convertDates = true; $result = $_records->toArray(); return $result; }