static function process(Mobile_API_Request $request) { $operation = $request->getOperation(); $sessionid = HTTP_Session::detectId(); //$request->getSession(); if (empty($operation)) { $operation = 'login'; } $response = false; if (isset(self::$opControllers[$operation])) { $operationFile = self::$opControllers[$operation]['file']; $operationClass = self::$opControllers[$operation]['class']; include_once dirname(__FILE__) . $operationFile; $operationController = new $operationClass(); $operationSession = false; if ($operationController->requireLogin()) { $operationSession = Mobile_API_Session::init($sessionid); if ($operationController->hasActiveUser() === false) { $operationSession = false; } //Mobile_WS_Utils::initAppGlobals(); } else { // By-pass login $operationSession = true; } if ($operationSession === false) { $response = new Mobile_API_Response(); $response->setError(1501, 'Login required'); } else { try { $response = $operationController->process($request); } catch (Exception $e) { $response = new Mobile_API_Response(); $response->setError($e->getCode(), $e->getMessage()); } } } else { $response = new Mobile_API_Response(); $response->setError(1404, 'Operation not found: ' . $operation); } if ($response !== false) { if ($response->hasError()) { include_once dirname(__FILE__) . '/ui/Error.php'; $errorController = new Mobile_UI_Error(); $errorController->setError($response->getError()); echo $errorController->process($request)->emitHTML(); } else { echo $response->emitHTML(); } } }
function process(Mobile_API_Request $request) { global $currentModule; if ($request->getOperation() != 'create') { $wsResponse = parent::process($request); } else { $wsResponse = Mobile_WS_Describe::process($request); } $response = false; if ($wsResponse->hasError()) { $response = $wsResponse; } else { $wsResponseResult = $wsResponse->getResult(); $currentModule = vtlib_purify($_REQUEST['module']); $origmodule = $currentModule; if ($currentModule == 'Events') { $targetModule = 'Calendar'; } else { $targetModule = $currentModule; } if ($request->getOperation() != 'create') { $moduleObj = $this->cachedModuleLookupWithRecordId($wsResponseResult['record']['id']); $record = Mobile_UI_ModuleRecordModel::buildModelFromResponse($wsResponseResult['record']); $record->setId($wsResponseResult['record']['id']); } else { $moduleObj = $this->cachedModuleLookup($targetModule); $record = Mobile_UI_ModuleRecordModel::buildModel($wsResponseResult['record']); $record->setId(''); } $current_user = $this->getActiveUser(); //for compatibility to CRM versions 5.2.1 and 5.3.0 ff. $current_language = $this->sessionGet('language'); include_once dirname(__FILE__) . '/../language/' . $current_language . '.lang.php'; //generate dateformat for Smarty $target_date_format = $current_user->date_format; $target_date_format = str_replace("yyyy", "%Y", $target_date_format); $target_date_format = str_replace("mm", "%m", $target_date_format); $target_date_format = str_replace("dd", "%d", $target_date_format); //generate language for Smarty date (like 'de') $target_lang_format = substr($current_language, 3, 2); // change variance for split record id $recordIdComponents = explode('x', $wsResponseResult['record']['id']); //this is a temporary fix for invitees for events, must get modified later $invited_users = array(); if ($currentModule == 'Events') { global $adb; $sql = 'select vtiger_users.user_name,vtiger_invitees.* from vtiger_invitees left join vtiger_users on vtiger_invitees.inviteeid=vtiger_users.id where activityid=?'; $result = $adb->pquery($sql, array($recordIdComponents[1])); $num_rows = $adb->num_rows($result); for ($i = 0; $i < $num_rows; $i++) { $userid = $adb->query_result($result, $i, 'inviteeid'); $username = $adb->query_result($result, $i, 'user_name'); $invited_users[$userid] = $username; } } //hour format for wheel if ($current_user->hour_format == '24') { $timewheelformat = 'HHii'; } else { $timewheelformat = ''; } $viewer = new Mobile_UI_Viewer(); $viewer->assign('_MODULE', $moduleObj); $viewer->assign('CURRENTMODUL', $currentModule); $viewer->assign('_RECORD', $record); $viewer->assign('id', $wsResponseResult['record']['id']); $viewer->assign('mode', $request->getOperation()); $viewer->assign('mobilerecordid', $wsResponseResult['record']['id']); $viewer->assign('MOD', $mod_strings); $viewer->assign('DATEFORMAT', $current_user->date_format); $viewer->assign('SMARTYDATEFORMAT', $target_date_format); $viewer->assign('HOURFORMATFORMAT', $current_user->hour_format); $viewer->assign('LANGFORMATFORMAT', $target_lang_format); $viewer->assign('INVITEES', implode(",", array_keys($invited_users))); $viewer->assign('LANGUAGE', $current_language); $viewer->assign('ORIGMODULE', $origmodule); $viewer->assign('TIMEWHEEL', $timewheelformat); $response = $viewer->process('generic/edit.tpl'); } return $response; }
function process(Mobile_API_Request $request) { $operation = new Mobile_API_Request(); $operation = $request->getOperation(); if ($operation == 'create') { $newrecord = Mobile_WS_Describe::process($request); $response = new Mobile_API_Response(); $response->setResult(array('record' => $newrecord)); return $response; } else { $response = parent::process($request); return $this->processWithGrouping($request, $response); } }