function process(Mobile_API_Request $request) { $response = new Mobile_API_Response(); $current_user = $this->getActiveUser(); $module = $request->get('module'); $moduleWSID = Mobile_WS_Utils::getEntityModuleWSId($module); if (empty($module)) { $response->setError(1501, "Module not specified."); return $response; } $records = array(); // Fetch the request parameters $idlist = $request->get('ids'); $alertid = $request->get('alertid'); // List of ids specified? if (!empty($idlist)) { $idlist = Zend_Json::decode($idlist); $records = $this->fetchRecordsWithId($module, $idlist, $current_user); } else { if (!empty($alertid)) { $alert = Mobile_WS_AlertModel::modelWithId($alertid); if ($alert === false) { $response->setError(1404, "Alert not found."); $records = false; } $alert->setUser($current_user); $records = $this->fetchAlertRecords($module, $alert); } } if ($records !== false) { $response->setResult(array('records' => $records)); } return $response; }
function __construct() { parent::__construct(); $this->name = 'Pending Ticket Alert'; $this->moduleName = 'HelpDesk'; $this->refreshRate = 1 * (24 * 60 * 60); // 1 day $this->description = 'Alert sent when ticket assigned is not yet closed'; }
function __construct() { parent::__construct(); $this->name = 'Your events for the day'; $this->moduleName = 'Calendar'; $this->refreshRate = 1 * (24 * 60 * 60); // 1 day $this->description = 'Alert sent when events are scheduled for the day'; }
function __construct() { parent::__construct(); $this->name = 'My Project Task'; $this->moduleName = 'ProjectTask'; $this->refreshRate = 1 * (24 * 60 * 60); // 1 day $this->description = 'Project Task Assigned To Me'; }
function __construct() { parent::__construct(); $this->name = 'Upcoming Opportunity'; $this->moduleName = 'Potentials'; $this->refreshRate = 1 * (24 * 60 * 60); // 1 day $this->description = 'Alert sent when Potential Close Date is due before 5 days or less'; }
function getAlertDetails() { $alertModels = Mobile_WS_AlertModel::models(); $alerts = array(); foreach ($alertModels as $alertModel) { $alerts[] = $alertModel->serializeToSend(); } return $alerts; }
function getAlertDetails($alertid) { $alertModel = Mobile_WS_AlertModel::modelWithId($alertid); $alert = false; if ($alertModel) { $alert = $alertModel->serializeToSend(); $alertModel->setUser($this->getActiveUser()); $alert['message'] = $alertModel->message(); } return $alert; }
function __construct() { // Mandatory call to parent constructor parent::__construct(); $this->name = 'Server Time Alert'; $this->description = 'Alert to get server time information'; $this->refreshRate = 1; // 1 second $this->recordsLinked = FALSE; // There is no module records linked with message. // If set to true $this->moduleName needs to be set. }
function processSearchRecordLabel(Mobile_API_Request $request) { global $current_user; // Few core API assumes this variable availability $current_user = $this->getActiveUser(); $module = $request->get('module'); $alertid = $request->get('alertid'); $filterid = $request->get('filterid'); $search = $request->get('search'); $filterOrAlertInstance = false; if (!empty($alertid)) { $filterOrAlertInstance = Mobile_WS_AlertModel::modelWithId($alertid); } else { if (!empty($filterid)) { $filterOrAlertInstance = Mobile_WS_FilterModel::modelWithId($module, $filterid); } else { if (!empty($search)) { $filterOrAlertInstance = $this->getSearchFilterModel($module, $search); } } } if ($filterOrAlertInstance && strcmp($module, $filterOrAlertInstance->moduleName)) { $response = new Mobile_API_Response(); $response->setError(1001, 'Mistached module information.'); return $response; } // Initialize with more information if ($filterOrAlertInstance) { $filterOrAlertInstance->setUser($current_user); } // Paging model $pagingModel = $this->getPagingModel($request); if ($this->isCalendarModule($module)) { return $this->processSearchRecordLabelForCalendar($request, $pagingModel); } $records = $this->fetchRecordLabelsForModule($module, $current_user, array(), $filterOrAlertInstance, $pagingModel); $modifiedRecords = array(); foreach ($records as $record) { if ($record instanceof SqlResultIteratorRow) { $record = $record->data; // Remove all integer indexed mappings for ($index = count($record); $index > -1; --$index) { if (isset($record[$index])) { unset($record[$index]); } } } $recordid = $record['id']; unset($record['id']); $eventstart = ''; if ($this->isCalendarModule($module)) { $eventstart = $record['date_start']; unset($record['date_start']); } $values = array_values($record); $label = implode(' ', $values); $modifiedRecord = array('id' => $recordid, 'label' => $label); if (!empty($eventstart)) { $modifiedRecord['eventstart'] = $eventstart; } $modifiedRecords[] = $modifiedRecord; } $response = new Mobile_API_Response(); $response->setResult(array('records' => $modifiedRecords, 'module' => $module)); return $response; }