Beispiel #1
0
 function process(Mobile_API_Request $request)
 {
     $mode = $request->get('mode');
     $module = $this->cachedModule($request->get('module'));
     $searchIn = $this->cachedSearchFields($module->name());
     if ($mode == 'update') {
         $searchIn = array();
         foreach ($_REQUEST as $k => $v) {
             if (preg_match("/field_(.*)/i", $k, $m)) {
                 $searchIn[] = vtlib_purify($m[1]);
             }
         }
         $this->cacheSearchFields($module->name(), $searchIn);
         header("Location: index.php?_operation=listModuleRecords&module={$module->name()}&mode=search");
         exit;
     }
     $request->setDefault('record', "{$module->id()}x0");
     $wsResponse = parent::process($request);
     $wsResponseResult = $wsResponse->getResult();
     $templateRecord = Mobile_UI_ModuleRecordModel::buildModelFromResponse($wsResponseResult['record']);
     $viewer = new Mobile_UI_Viewer();
     $viewer->assign('_MODULE', $module);
     $viewer->assign('_RECORD', $templateRecord);
     $viewer->assign('_SEARCHIN', $searchIn);
     $viewer->assign('_SEARCHIN_ALL', empty($searchIn));
     $response = $viewer->process('generic/SearchConfig.tpl');
     return $response;
 }
Beispiel #2
0
 function process(Mobile_API_Request $request)
 {
     $current_user = vglobal('current_user');
     // Required for vtws_update API
     $current_user = $this->getActiveUser();
     $module = $request->get('module');
     $recordid = $request->get('record');
     $valuesJSONString = $request->get('values');
     $values = "";
     if (!empty($valuesJSONString) && is_string($valuesJSONString)) {
         $values = Zend_Json::decode($valuesJSONString);
     } else {
         $values = $valuesJSONString;
         // Either empty or already decoded.
     }
     $response = new Mobile_API_Response();
     if (empty($values)) {
         $response->setError(1501, "Values cannot be empty!");
         return $response;
     }
     try {
         // Retrieve or Initalize
         if (!empty($recordid) && !$this->isTemplateRecordRequest($request)) {
             $this->recordValues = vtws_retrieve($recordid, $current_user);
         } else {
             $this->recordValues = array();
         }
         // Set the modified values
         foreach ($values as $name => $value) {
             $this->recordValues[$name] = $value;
         }
         // Update or Create
         if (isset($this->recordValues['id'])) {
             $this->recordValues = vtws_update($this->recordValues, $current_user);
         } else {
             // Set right target module name for Calendar/Event record
             if ($module == 'Calendar') {
                 if (!empty($this->recordValues['eventstatus']) && $this->recordValues['activitytype'] != 'Task') {
                     $module = 'Events';
                 }
             }
             $this->recordValues = vtws_create($module, $this->recordValues, $current_user);
         }
         // Update the record id
         $request->set('record', $this->recordValues['id']);
         // Gather response with full details
         $response = parent::process($request);
     } catch (Exception $e) {
         $response->setError($e->getCode(), $e->getMessage());
     }
     return $response;
 }
 function process(Mobile_API_Request $request)
 {
     $wsResponse = parent::process($request);
     $response = false;
     if ($wsResponse->hasError()) {
         $response = $wsResponse;
     } else {
         $wsResponseResult = $wsResponse->getResult();
         $module = $this->cachedModuleLookupWithRecordId($wsResponseResult['record']['id']);
         $record = Mobile_UI_ModuleRecordModel::buildModelFromResponse($wsResponseResult['record']);
         $record->setId($wsResponseResult['record']['id']);
         $viewer = new Mobile_UI_Viewer();
         $viewer->assign('_MODULE', $module);
         $viewer->assign('_RECORD', $record);
         $response = $viewer->process('generic/Detail.tpl');
     }
     return $response;
 }
Beispiel #4
0
 function process(Mobile_API_Request $request)
 {
     global $app_strings, $mod_strings;
     $wsResponse = parent::process($request);
     $response = false;
     if ($wsResponse->hasError()) {
         $response = $wsResponse;
     } else {
         $wsResponseResult = $wsResponse->getResult();
         $current_user = $this->getActiveUser();
         $current_language = $this->sessionGet('language');
         $app_strings = return_application_language($current_language);
         $relatedlistsmodule = array_keys($wsResponseResult);
         $relatedresponse = new Mobile_API_Response();
         foreach ($relatedlistsmodule as $module) {
             $moduleWSId = Mobile_WS_Utils::getEntityModuleWSId($module);
             if ($module == 'Events' || $module == 'Calendar') {
                 $fieldnames = Mobile_WS_Utils::getEntityFieldnames('Calendar');
             } else {
                 $fieldnames = Mobile_WS_Utils::getEntityFieldnames($module);
             }
             foreach ($wsResponseResult[$module] as $key => $shortrecordid) {
                 $recordid = $moduleWSId . 'x' . $shortrecordid;
                 $detailrequest = new Mobile_API_Request();
                 $detailrequest->set('record', $recordid);
                 $detailrequest->set('_operation', 'fetchRecordWithGrouping');
                 $detailrequest->set('module', $module);
                 $detailresponse = Mobile_WS_FetchRecordWithGrouping::process($detailrequest);
                 $detailresponse_record[$module][$key] = $detailresponse->getResult();
             }
         }
         $relatedresponse->setResult($detailresponse_record);
         $response = new Mobile_API_Response();
         $current_language = $this->sessionGet('language');
         include_once dirname(__FILE__) . '/../language/' . $current_language . '.lang.php';
         $viewer = new Mobile_UI_Viewer();
         $viewer->assign('LANGUAGE', $current_language);
         $viewer->assign('MOD', $mod_strings);
         $viewer->assign('_MODULE', $module);
         $viewer->assign('_RECORDS', $relatedresponse);
         $response = $viewer->process('generic/getRelatedLists.tpl');
     }
     return $response;
 }
 function process(Mobile_API_Request $request)
 {
     global $modules_with_comments;
     $wsResponse = parent::process($request);
     $current_user = $this->getActiveUser();
     $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);
     $response = false;
     if ($wsResponse->hasError()) {
         $response = $wsResponse;
     } else {
         $wsResponseResult = $wsResponse->getResult();
         $moduleObj = $this->cachedModuleLookupWithRecordId($wsResponseResult['record']['id']);
         $record = Mobile_UI_ModuleRecordModel::buildModelFromResponse($wsResponseResult['record']);
         $record->setId($wsResponseResult['record']['id']);
         $viewer = new Mobile_UI_Viewer();
         //display comments? $modules_with_comments comes from MobileSettings.config.php
         if (in_array($moduleObj->name(), $modules_with_comments)) {
             $viewer->assign('COMMENTDISPLAY', true);
         } else {
             $viewer->assign('COMMENTDISPLAY', false);
         }
         $viewer->assign('_MODULE', $moduleObj);
         $viewer->assign('_RECORD', $record);
         $viewer->assign('MOD', $mod_strings);
         $viewer->assign('DATEFORMAT', $target_date_format);
         $viewer->assign('HOURFORMAT', $current_user->hour_format);
         $viewer->assign('LANGUAGE', $current_language);
         if (isset($wsResponseResult['comments'])) {
             $viewer->assign('_COMMENTS', $wsResponseResult['comments']);
         }
         $response = $viewer->process('generic/Detail.tpl');
     }
     return $response;
 }
Beispiel #6
0
 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;
 }