/** * returns record prepared for json transport * * @param Tinebase_Record_Interface $_record * @return array record data */ protected function _recordToJson($_record) { switch (get_class($_record)) { case 'Timetracker_Model_Timesheet': $_record['timeaccount_id'] = $_record['timeaccount_id'] ? $this->_timeaccountController->get($_record['timeaccount_id']) : $_record['timeaccount_id']; $_record['timeaccount_id']['account_grants'] = Timetracker_Model_TimeaccountGrants::getGrantsOfAccount(Tinebase_Core::get('currentAccount'), $_record['timeaccount_id']); $_record['timeaccount_id']['account_grants'] = $this->_resolveTimesheetGrantsByTimeaccountGrants($_record['timeaccount_id']['account_grants'], $_record['account_id']); Tinebase_User::getInstance()->resolveUsers($_record, 'account_id'); $recordArray = parent::_recordToJson($_record); break; case 'Timetracker_Model_Timeaccount': $recordArray = parent::_recordToJson($_record); // When editing a single TA we send _ALL_ grants to the client $recordArray['grants'] = Timetracker_Model_TimeaccountGrants::getTimeaccountGrants($_record)->toArray(); foreach ($recordArray['grants'] as &$value) { switch ($value['account_type']) { case Tinebase_Acl_Rights::ACCOUNT_TYPE_USER: $value['account_name'] = Tinebase_User::getInstance()->getUserById($value['account_id'])->toArray(); break; case Tinebase_Acl_Rights::ACCOUNT_TYPE_GROUP: $value['account_name'] = Tinebase_Group::getInstance()->getGroupById($value['account_id'])->toArray(); break; case Tinebase_Acl_Rights::ACCOUNT_TYPE_ANYONE: $value['account_name'] = array('accountDisplayName' => 'Anyone'); break; default: throw new Tinebase_Exception_InvalidArgument('Unsupported accountType.'); break; } } break; } return $recordArray; }
/** * returns task prepared for json transport * * @param Tinebase_Record_Interface $_record * @return array record data */ protected function _recordToJson($_record) { $recordArray = parent::_recordToJson($_record); // group data $groupData = Admin_Controller_Group::getInstance()->get($_record->group_id)->toArray(); unset($groupData['id']); $groupData['members'] = $this->_getCourseMembers($_record->group_id); // course type $recordArray['type'] = array('value' => $recordArray['type'], 'records' => $this->searchCourseTypes(NULL, NULL)); return array_merge($groupData, $recordArray); }
/** * returns record prepared for json transport * * @param Tinebase_Record_Interface $_record * @return array record data */ protected function _recordToJson($_record) { $recordArray = parent::_recordToJson($_record); switch (get_class($_record)) { case 'Voipmanager_Model_Snom_Phone': // add settings $recordArray = array_merge($recordArray, $this->getSnomPhoneSettings($_record->getId())); // add snom templates (no filter + no pagination) $recordArray['template_id'] = array('value' => $_record->template_id, 'records' => $this->searchSnomTemplates('', '')); // add snom locations (no filter + no pagination) $recordArray['location_id'] = array('value' => $_record->location_id, 'records' => $this->searchSnomLocations('', '')); // resolve lines foreach ($recordArray['lines'] as &$line) { $line['asteriskline_id'] = Voipmanager_Controller_Asterisk_SipPeer::getInstance()->get($line['asteriskline_id'])->toArray(); } break; case 'Voipmanager_Model_Snom_Template': // add snom softwares (no filter + no pagination) $recordArray['software_id'] = array('value' => $recordArray['software_id'], 'records' => $this->searchSnomSoftwares('', '')); // add snom settings (no filter + no pagination) $recordArray['setting_id'] = array('value' => $recordArray['setting_id'], 'records' => $this->searchSnomSettings('', '')); break; case 'Voipmanager_Model_Snom_Phone': // add settings $recordArray = array_merge($recordArray, $this->getSnomPhoneSettings($recordArray['id'])); // resolve snom template_id $recordArray['template_id'] = array('value' => $recordArray['template_id'], 'records' => $this->searchSnomTemplates('', '')); // resolve snom location_id $recordArray['location_id'] = array('value' => $recordArray['location_id'], 'records' => $this->searchSnomLocations('', '')); // add names to lines foreach ($recordArray['lines'] as &$line) { $line['name'] = Voipmanager_Controller_Asterisk_SipPeer::getInstance()->get($line['asteriskline_id'])->name; } break; case 'Voipmanager_Model_Asterisk_SipPeer': case 'Voipmanager_Model_Asterisk_Voicemail': // resolve context_id $recordArray['context_id'] = array('value' => $recordArray['context_id'], 'records' => $this->searchAsteriskContexts('', '')); break; } return $recordArray; }
/** * returns record prepared for json transport * * @param Tinebase_Record_Interface $_record * @return array record data */ protected function _recordToJson($_record) { switch (get_class($_record)) { case 'Timetracker_Model_Timesheet': $_record['timeaccount_id'] = $_record['timeaccount_id'] ? $this->_timeaccountController->get($_record['timeaccount_id']) : $_record['timeaccount_id']; $_record['timeaccount_id']['account_grants'] = Timetracker_Model_TimeaccountGrants::getGrantsOfAccount(Tinebase_Core::get('currentAccount'), $_record['timeaccount_id']); $_record['timeaccount_id']['account_grants'] = $this->_resolveTimesheetGrantsByTimeaccountGrants($_record['timeaccount_id']['account_grants'], $_record['account_id']); Tinebase_User::getInstance()->resolveUsers($_record, 'account_id'); if (Tinebase_Core::getUser()->hasRight('Sales', 'manage_invoices') && !empty($_record['invoice_id'])) { try { $_record['invoice_id'] = Sales_Controller_Invoice::getInstance()->get($_record['invoice_id']); } catch (Tinebase_Exception_NotFound $nfe) { Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' Could not resolve invoice with id ' . $_record['invoice_id']); } } $recordArray = parent::_recordToJson($_record); break; case 'Timetracker_Model_Timeaccount': $recordArray = parent::_recordToJson($_record); // When editing a single TA we send _ALL_ grants to the client $recordArray['grants'] = Timetracker_Model_TimeaccountGrants::getTimeaccountGrants($_record)->toArray(); foreach ($recordArray['grants'] as &$value) { switch ($value['account_type']) { case Tinebase_Acl_Rights::ACCOUNT_TYPE_USER: $value['account_name'] = Tinebase_User::getInstance()->getUserById($value['account_id'])->toArray(); break; case Tinebase_Acl_Rights::ACCOUNT_TYPE_GROUP: $value['account_name'] = Tinebase_Group::getInstance()->getGroupById($value['account_id'])->toArray(); break; case Tinebase_Acl_Rights::ACCOUNT_TYPE_ANYONE: $value['account_name'] = array('accountDisplayName' => 'Anyone'); break; default: throw new Tinebase_Exception_InvalidArgument('Unsupported accountType.'); break; } } break; } return $recordArray; }
/** * returns contact prepared for json transport * * @param Addressbook_Model_Contact $_contact * @return array contact data */ protected function _recordToJson($_contact) { $result = parent::_recordToJson($_contact); $result['jpegphoto'] = $this->_getImageLink($result); return $result; }
/** * returns message prepared for json transport * - overwriten to convert recipients to array * * @param Tinebase_Record_Interface $_record * @return array record data */ protected function _recordToJson($_record) { if ($_record instanceof Felamimail_Model_Message) { foreach (array('to', 'cc', 'bcc') as $type) { if (!is_array($_record->{$type})) { if (!empty($_record->{$type})) { $exploded = explode(',', $_record->{$type}); $_record->{$type} = $exploded; } else { $_record->{$type} = array(); } } } if ($_record->preparedParts instanceof Tinebase_Record_RecordSet) { foreach ($_record->preparedParts as $preparedPart) { if ($preparedPart->preparedData instanceof Calendar_Model_iMIP) { try { $iMIPFrontend = new Calendar_Frontend_iMIP(); $iMIPFrontend->prepareComponent($preparedPart->preparedData, true); } catch (Exception $e) { Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' Could not prepare calendar iMIP component: ' . $e->getMessage()); if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . $e->getTraceAsString()); } $_record->preparedParts->removeRecord($preparedPart); } } } } } else { if ($_record instanceof Felamimail_Model_Account) { // add usernames $_record->resolveCredentials(); // imap $_record->resolveCredentials(TRUE, FALSE, TRUE); // smtp } else { if ($_record instanceof Felamimail_Model_Sieve_Vacation) { if (!$_record->mime) { $_record->reason = Tinebase_Mail::convertFromTextToHTML($_record->reason, 'felamimail-body-blockquote'); } } } } return parent::_recordToJson($_record); }
/** * returns record prepared for json transport * * @param Tinebase_Record_Interface $_record * @return array record data */ protected function _recordToJson($_record) { switch (get_class($_record)) { case 'Sipgate_Model_Account': $filter = new Sipgate_Model_LineFilter(array(), 'AND'); $filter->addFilter(new Tinebase_Model_Filter_Id(array('field' => 'account_id', 'operator' => 'equals', 'value' => $_record->id))); $_record->lines = $this->_multipleRecordsToJson(Sipgate_Controller_Line::getInstance()->search($filter)); break; case 'Sipgate_Model_Line': Tinebase_User::getInstance()->resolveUsers($_record, $this->_resolveUserFields['Sipgate_Model_Line']); $_record->account_id = Sipgate_Controller_Account::getInstance()->get($_record->account_id); break; } return parent::_recordToJson($_record); }
/** * returns record prepared for json transport * * @param Tinebase_Record_Interface $_record * @return array record data */ protected function _recordToJson($_record) { $recordArray = parent::_recordToJson($_record); switch (get_class($_record)) { case 'Phone_Model_MyPhone': // add settings $settings = Voipmanager_Controller_Snom_PhoneSettings::getInstance()->get($_record->getId()); $recordArray = array_merge($recordArray, $settings->toArray()); // resolve lines foreach ($recordArray['lines'] as &$line) { $line['asteriskline_id'] = Voipmanager_Controller_Asterisk_SipPeer::getInstance()->get($line['asteriskline_id'])->toArray(); } break; } return $recordArray; }
/** * returns record prepared for json transport * * @param Tinebase_Record_Interface $_record * @return array record data */ protected function _recordToJson($_record) { $result = parent::_recordToJson($_record); if ($_record instanceof Tinebase_Model_Container) { $result['account_grants'] = Tinebase_Frontend_Json_Container::resolveAccounts($result['account_grants']); } return $result; }
/** * returns record prepared for json transport * * @param Tinebase_Record_Interface $_record * @return array record data */ protected function _recordToJson($_record) { if ($_record instanceof Tasks_Model_Task) { Tinebase_User::getInstance()->resolveUsers($_record, 'organizer', true); } return parent::_recordToJson($_record); }