コード例 #1
0
ファイル: AddRecordComment.php プロジェクト: kduqi/corebos
 function process(Mobile_API_Request $request)
 {
     $values = Zend_Json::decode($request->get('values'));
     $relatedTo = $values['related_to'];
     $commentContent = $values['commentcontent'];
     $user = $this->getActiveUser();
     $targetModule = '';
     if (!empty($relatedTo) && Mobile_WS_Utils::detectModulenameFromRecordId($relatedTo) == 'HelpDesk') {
         $targetModule = 'HelpDesk';
     } else {
         $targetModule = 'ModComments';
     }
     $response = false;
     if ($targetModule == 'HelpDesk') {
         $response = $this->saveCommentToHelpDesk($commentContent, $relatedTo, $user);
     } else {
         if (vtlib_isModuleActive($targetModule)) {
             $request->set('module', $targetModule);
             $values['assigned_user_id'] = sprintf('%sx%s', Mobile_WS_Utils::getEntityModuleWSId('Users'), $user->id);
             $request->set('values', Zend_Json::encode($values));
             $response = parent::process($request);
         }
     }
     return $response;
 }
コード例 #2
0
ファイル: Login.php プロジェクト: kduqi/corebos
 function process(Mobile_API_Request $request)
 {
     $response = new Mobile_API_Response();
     $username = $request->get('username');
     $password = $request->get('password');
     $current_user = CRMEntity::getInstance('Users');
     $current_user->column_fields['user_name'] = $username;
     if (vtlib_isModuleActive('Mobile') === false) {
         $response->setError(1501, 'Service not available');
         return $response;
     }
     if (!$current_user->load_user($password) || !$current_user->authenticated) {
         global $mod_strings;
         $response->setError(1210, $mod_strings['ERR_INVALID_PASSWORD']);
     } else {
         // Start session now
         $sessionid = Mobile_API_Session::init();
         if ($sessionid === false) {
             echo "Session init failed {$sessionid}\n";
         }
         include_once 'config.php';
         global $application_unique_key;
         $current_user->id = $current_user->retrieve_user_id($username);
         $this->setActiveUser($current_user);
         $_SESSION["authenticated_user_id"] = $current_user->id;
         $_SESSION["app_unique_key"] = $application_unique_key;
         $result = array();
         $result['login'] = array('userid' => $current_user->id, 'crm_tz' => DateTimeField::getDBTimeZone(), 'user_tz' => $current_user->time_zone, 'session' => $sessionid, 'language' => $current_user->language, 'vtiger_version' => Mobile_WS_Utils::getVtigerVersion(), 'mobile_module_version' => Mobile_WS_Utils::getVersion());
         $response->setResult($result);
         $this->postProcess($response);
     }
     return $response;
 }
コード例 #3
0
ファイル: Login.php プロジェクト: cannking/vtigercrm-debug
 function process(Mobile_API_Request $request)
 {
     $response = new Mobile_API_Response();
     $username = $request->get('username');
     $password = $request->get('password');
     $current_user = CRMEntity::getInstance('Users');
     $current_user->column_fields['user_name'] = $username;
     if (vtlib_isModuleActive('Mobile') === false) {
         $response->setError(1501, 'Service not available');
         return $response;
     }
     if (!$current_user->doLogin($password)) {
         $response->setError(1210, 'Authentication Failed');
     } else {
         // Start session now
         $sessionid = Mobile_API_Session::init();
         if ($sessionid === false) {
             echo "Session init failed {$sessionid}\n";
         }
         $current_user->id = $current_user->retrieve_user_id($username);
         $current_user->retrieveCurrentUserInfoFromFile($current_user->id);
         $this->setActiveUser($current_user);
         $result = array();
         $result['login'] = array('userid' => $current_user->id, 'crm_tz' => DateTimeField::getDBTimeZone(), 'user_tz' => $current_user->time_zone, 'user_currency' => $current_user->currency_code, 'session' => $sessionid, 'vtiger_version' => Mobile_WS_Utils::getVtigerVersion(), 'date_format' => $current_user->date_format, 'mobile_module_version' => Mobile_WS_Utils::getVersion());
         $response->setResult($result);
         $this->postProcess($response);
     }
     return $response;
 }
コード例 #4
0
ファイル: Describe.php プロジェクト: Bergdahls/YetiForceCRM
 function process(Mobile_API_Request $request)
 {
     $current_user = $this->getActiveUser();
     $module = $request->get('module');
     $describeInfo = vtws_describe($module, $current_user);
     Mobile_WS_Utils::fixDescribeFieldInfo($module, $describeInfo);
     $response = new Mobile_API_Response();
     $response->setResult(array('describe' => $describeInfo));
     return $response;
 }
コード例 #5
0
 function getGroups($currentUserModel, $moduleName)
 {
     $groups = $currentUserModel->getAccessibleGroupForModule($moduleName);
     $groupIds = array_keys($groups);
     $groupsList = array();
     $groupsWSId = Mobile_WS_Utils::getEntityModuleWSId('Groups');
     foreach ($groupIds as $groupId) {
         $groupName = getGroupName($groupId);
         $groupsList[] = array('value' => $groupsWSId . 'x' . $groupId, 'label' => $groupName[0]);
     }
     return $groupsList;
 }
コード例 #6
0
 function process(Mobile_API_Request $request)
 {
     global $current_user, $adb, $currentModule;
     $current_user = $this->getActiveUser();
     $response = new Mobile_API_Response();
     $record = $request->get('record');
     $relatedmodule = $request->get('relatedmodule');
     $currentPage = $request->get('page', 0);
     // Input validation
     if (empty($record)) {
         $response->setError(1001, 'Record id is empty');
         return $response;
     }
     $recordid = vtws_getIdComponents($record);
     $recordid = $recordid[1];
     $module = Mobile_WS_Utils::detectModulenameFromRecordId($record);
     // Initialize global variable
     $currentModule = $module;
     $functionHandler = Mobile_WS_Utils::getRelatedFunctionHandler($module, $relatedmodule);
     if ($functionHandler) {
         $sourceFocus = CRMEntity::getInstance($module);
         $relationResult = call_user_func_array(array($sourceFocus, $functionHandler), array($recordid, getTabid($module), getTabid($relatedmodule)));
         $query = $relationResult['query'];
         $querySEtype = "vtiger_crmentity.setype as setype";
         if ($relatedmodule == 'Calendar') {
             $querySEtype = "vtiger_activity.activitytype as setype";
         }
         $query = sprintf("SELECT vtiger_crmentity.crmid, {$querySEtype} %s", substr($query, stripos($query, 'FROM')));
         $queryResult = $adb->query($query);
         // Gather resolved record id's
         $relatedRecords = array();
         while ($row = $adb->fetch_array($queryResult)) {
             $targetSEtype = $row['setype'];
             if ($relatedmodule == 'Calendar') {
                 if ($row['setype'] != 'Task' && $row['setype'] != 'Emails') {
                     $targetSEtype = 'Events';
                 } else {
                     $targetSEtype = $relatedmodule;
                 }
             }
             $relatedRecords[] = sprintf("%sx%s", Mobile_WS_Utils::getEntityModuleWSId($targetSEtype), $row['crmid']);
         }
         // Perform query to get record information with grouping
         $wsquery = sprintf("SELECT * FROM %s WHERE id IN ('%s');", $relatedmodule, implode("','", $relatedRecords));
         $newRequest = new Mobile_API_Request();
         $newRequest->set('module', $relatedmodule);
         $newRequest->set('query', $wsquery);
         $newRequest->set('page', $currentPage);
         $response = parent::process($newRequest);
     }
     return $response;
 }
コード例 #7
0
ファイル: FetchRecord.php プロジェクト: yozhi/YetiForceCRM
 function resolveRecordValues(&$record, $user, $ignoreUnsetFields = false)
 {
     if (empty($record)) {
         return $record;
     }
     $fieldnamesToResolve = Mobile_WS_Utils::detectFieldnamesToResolve($this->detectModuleName($record['id']));
     if (!empty($fieldnamesToResolve)) {
         foreach ($fieldnamesToResolve as $resolveFieldname) {
             if ($ignoreUnsetFields === false || isset($record[$resolveFieldname])) {
                 $fieldvalueid = $record[$resolveFieldname];
                 $fieldvalue = $this->fetchRecordLabelForId($fieldvalueid, $user);
                 $record[$resolveFieldname] = array('value' => $fieldvalueid, 'label' => $fieldvalue);
             }
         }
     }
 }
コード例 #8
0
ファイル: Describe.php プロジェクト: kduqi/corebos
 protected function transformToBlocks($module)
 {
     $current_user = $this->getActiveUser();
     $moduleFieldGroups = Mobile_WS_Utils::gatherModuleFieldGroupInfo($module);
     $describeInfo = vtws_describe($module, $current_user);
     Mobile_WS_Utils::fixDescribeFieldInfo($module, $describeInfo, $current_user);
     $modifiedResult = array();
     $blocks = array();
     $labelFields = false;
     foreach ($moduleFieldGroups as $blocklabel => $fieldgroups) {
         $fields = array();
         foreach ($fieldgroups as $fieldname => $fieldinfo) {
             $field['name'] = $fieldname;
             $field['value'] = '';
             $field['label'] = $fieldinfo['label'];
             $field['uitype'] = $fieldinfo['uitype'];
             $field['typeofdata'] = $fieldinfo['typeofdata'];
             foreach ($describeInfo['fields'] as $describeField) {
                 if ($describeField['name'] == $fieldname) {
                     $field['type'] = '';
                     if (isset($describeField['type']) && $describeField['type'] != '') {
                         $picklistValues = $describeField['type']['picklistValues'];
                         $field['type']['value'] = array('value' => $picklistValues, 'name' => $fieldname);
                     }
                 }
             }
             if ($field['uitype'] == '51' || $field['uitype'] == '59' || $field['uitype'] == '10') {
                 $field['relatedmodule'] = Mobile_WS_Utils::getEntityName($field['name'], $module);
             }
             $fields[] = $field;
         }
         $blocks[] = array('label' => $blocklabel, 'fields' => $fields);
     }
     $sections = array();
     $moduleFieldGroupKeys = array_keys($moduleFieldGroups);
     foreach ($moduleFieldGroupKeys as $blocklabel) {
         // eliminate empty blocks
         if (isset($groups[$blocklabel]) && !empty($groups[$blocklabel])) {
             $sections[] = array('label' => $blocklabel, 'count' => count($groups[$blocklabel]));
         }
     }
     $modifiedResult = array('blocks' => $blocks, 'id' => $resultRecord['id']);
     if ($labelFields) {
         $modifiedResult['labelFields'] = $labelFields;
     }
     return $modifiedResult;
 }
コード例 #9
0
 function getListing($user)
 {
     $modulewsids = Mobile_WS_Utils::getEntityModuleWSIds();
     // Disallow modules
     unset($modulewsids['Users']);
     // Calendar & Events module will be merged
     unset($modulewsids['Events']);
     $listresult = vtws_listtypes(null, $user);
     $listing = array();
     foreach ($listresult['types'] as $index => $modulename) {
         if (!isset($modulewsids[$modulename])) {
             continue;
         }
         $listing[] = array('id' => $modulewsids[$modulename], 'name' => $modulename, 'isEntity' => $listresult['information'][$modulename]['isEntity'], 'label' => $listresult['information'][$modulename]['label'], 'singular' => $listresult['information'][$modulename]['singular']);
     }
     return $listing;
 }
コード例 #10
0
ファイル: getAutocomplete.php プロジェクト: kduqi/corebos
 function process(Mobile_API_Request $request)
 {
     $response = new Mobile_API_Response();
     global $adb;
     global $current_language;
     $current_language = Mobile_API_Session::get('language');
     //never trust an entry
     $sSearch = vtlib_purify($request->get('term'));
     $sResult = "";
     $arrayName = array();
     $ModuleArray = explode(',', vtlib_purify($request->get('relmodule')));
     $ModuleLabels = array();
     foreach ($ModuleArray as $Module) {
         $translatedModule = getTranslatedString($Module, 'Mobile');
         $arrayName[$translatedModule] = array();
         $moduleWSID = Mobile_WS_Utils::getEntityModuleWSId($Module);
         // get related module fields
         $query = "SELECT tablename,fieldname,entityidfield FROM vtiger_entityname WHERE modulename = ?";
         $result = $adb->pquery($query, array($Module));
         if (!$result or $adb->num_rows($result) == 0) {
             $response->setError(1407, 'Error: Could not fetch entity info');
             return $response;
         }
         $tablename = $adb->query_result($result, 0, 'tablename');
         $fieldname = $adb->query_result($result, 0, 'fieldname');
         $entityidfield = $adb->query_result($result, 0, 'entityidfield');
         $fieldname = explode(',', $fieldname);
         $fieldname = $fieldname[0];
         //START DATABASE ACCOUNT SEARCH
         $minhaquery = "SELECT " . $fieldname . "," . $entityidfield . " FROM " . $tablename . " \n\t\t\t\t\t\t\tINNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = " . $tablename . "." . $entityidfield . "\n\t\t\t\t\t\t\tWHERE deleted = 0 AND " . $fieldname . " LIKE ? ORDER BY " . $fieldname . "";
         $params = $sSearch . "%";
         $result = $adb->pquery($minhaquery, array($params));
         if (!$result) {
             $response->setError(1408, 'Error: Could not fetch entity data');
             return $response;
         }
         for ($i = 0; $i < $adb->num_rows($result); $i++) {
             $arrayName[$translatedModule][] = array($moduleWSID . 'x' . $adb->query_result($result, $i, $entityidfield), decode_html($adb->query_result($result, $i, $fieldname)));
         }
     }
     $sResult = $arrayName;
     $sResult = json_encode($sResult);
     $response->setResult($sResult);
     return $response;
 }
コード例 #11
0
ファイル: getRelationList.php プロジェクト: kduqi/corebos
 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;
 }
コード例 #12
0
 function getListing($user)
 {
     function useSortBySettings($a, $b)
     {
         global $displayed_modules;
         $posA = $displayed_modules[$a['name']];
         $posB = $displayed_modules[$b['name']];
         if ($posA == $posB) {
             return 0;
         }
         return $posA < $posB ? -1 : 1;
     }
     //settings information
     global $displayed_modules, $current_language, $app_strings;
     $modulewsids = Mobile_WS_Utils::getEntityModuleWSIds();
     // Disallow modules
     unset($modulewsids['Users']);
     include_once dirname(__FILE__) . '/../../Mobile.Config.php';
     $CRM_Version = Mobile::config('crm_version');
     if ($CRM_Version != '5.2.1') {
         //we use this class only for privilege purposes on types
         $listresult = vtws_listtypes(null, $user, 'en_us');
     } else {
         $listresult = vtws_listtypes($user);
     }
     $listing = array();
     foreach ($listresult['types'] as $index => $modulename) {
         if (!isset($modulewsids[$modulename])) {
             continue;
         }
         if (in_array($modulename, $displayed_modules)) {
             $listing[] = array('id' => $modulewsids[$modulename], 'name' => $modulename, 'isEntity' => $listresult['information'][$modulename]['isEntity'], 'label' => getTranslatedString($modulename, $modulename), 'singular' => getTranslatedString('SINGLE_' . $modulename, $modulename));
         }
     }
     //make sure the active modules are displayed in the order of the $displayed_modules settings entry in MobileSettings.config.php
     $displayed_modules = array_flip($displayed_modules);
     usort($listing, 'useSortBySettings');
     return $listing;
 }
コード例 #13
0
 function process(Mobile_API_Request $request)
 {
     global $current_user, $adb, $currentModule;
     $current_user = $this->getActiveUser();
     $response = new Mobile_API_Response();
     $record = $request->get('record');
     $currentPage = $request->get('page', 0);
     // Input validation
     if (empty($record)) {
         $response->setError(1001, 'Record id is empty');
         return $response;
     }
     $recordid = vtws_getIdComponents($record);
     $recordid = $recordid[1];
     $module = Mobile_WS_Utils::detectModulenameFromRecordId($record);
     // Initialize global variable
     $currentModule = $module;
     //related module currently supported
     $relatedmodule = array('Contacts', 'Potentials', 'HelpDesk');
     $activemodule = $this->sessionGet('_MODULES');
     foreach ($activemodule as $amodule) {
         if (in_array($amodule->name(), $relatedmodule)) {
             $active_related_module[] = $amodule->name();
         }
     }
     foreach ($active_related_module as $relmod) {
         $functionHandler = Mobile_WS_Utils::getRelatedFunctionHandler($module, $relmod);
         $fieldmodel = new Mobile_UI_FieldModel();
         if ($functionHandler) {
             $sourceFocus = CRMEntity::getInstance($module);
             $relationResult = call_user_func_array(array($sourceFocus, $functionHandler), array($recordid, getTabid($module), getTabid($relmod)));
             $relatedRecords[$relmod] = array_keys($relationResult['entries']);
             $response->setResult($relatedRecords);
         } else {
             $response->setError(1018, 'Function Handler for module ' . $module . ' for related Module ' . $relmod . '  not found.');
         }
     }
     return $response;
 }
コード例 #14
0
ファイル: addComment.php プロジェクト: kduqi/corebos
 function getContent(Mobile_API_Request $request)
 {
     $comment = $request->get('comment');
     $parentid = $request->get('parentid');
     if (isset($comment) && !empty($comment)) {
         $parentmodule = Mobile_WS_Utils::detectModulenameFromRecordId($parentid);
         if ($parentmodule != 'HelpDesk') {
             include_once 'include/Webservices/Create.php';
             $current_user = $this->getActiveUser();
             $userid = Mobile_WS_Utils::getEntityModuleWSId('Users') . "x" . $current_user->id;
             $arr_comment = array('commentcontent' => $comment, 'related_to' => $parentid, 'creator' => $userid, 'assigned_user_id' => $userid);
             $ele = vtws_create('ModComments', $arr_comment, $current_user);
         } else {
             $parentrecordid = vtws_getIdComponents($parentid);
             $parentrecordid = $parentrecordid[1];
             //there is currently no vtws service available for ticket comments
             $current_user = $this->getActiveUser();
             $current_user_id = $current_user->id;
             $userrecordid = vtws_getIdComponents($current_user_id);
             $userrecordid = $userrecordid[1];
             $arr_comment = array('commentcontent' => $comment, 'related_to' => $parentrecordid, 'creator' => $current_user_id);
             //$ele = vtws_create('ModComments', $arr_comment, $current_user);
             $saverecord = Mobile_WS_Utils::createTicketComment($arr_comment);
             if ($saverecord == true) {
                 $userid = Mobile_WS_Utils::getEntityModuleWSId('Users') . "x" . $current_user_id;
                 $ele['commentcontent'] = $arr_comment['commentcontent'];
                 $ele['creator'] = $userid;
                 $ele['assigned_user_id'] = $userid;
                 $ele['related_to'] = $parentid;
                 $ele['id'] = '';
                 $ele['createdtime'] = DateTimeField::convertToUserFormat(date('Y-m-d H:i:s'));
             }
         }
     }
     $response = new Mobile_API_Response();
     $ele['assigned_user_id'] = vtws_getName($ele['creator'], $current_user);
     $response->setResult(array('comment' => $ele));
     return $response;
 }
コード例 #15
0
 function fetchAlertRecords($module, $alert)
 {
     global $adb;
     // Initialize global variable: ($alert->query() could indirectly depend if its using Module API as its base)
     global $current_user;
     if (!isset($current_user)) {
         $current_user = $alert->getUser();
     }
     $moduleWSID = Mobile_WS_Utils::getEntityModuleWSId($module);
     $alertResult = $adb->pquery($alert->query(), $alert->queryParameters());
     $alertRecords = array();
     // For Calendar module there is a need for merging Todo's
     if ($module == 'Calendar') {
         $eventsWSID = Mobile_WS_Utils::getEntityModuleWSId('Events');
         $eventIds = array();
         $taskIds = array();
         while ($resultrow = $adb->fetch_array($alertResult)) {
             if (isset($resultrow['activitytype']) && $resultrow['activitytype'] == 'Task') {
                 $taskIds[] = "{$moduleWSID}x" . $resultrow['crmid'];
             } else {
                 $eventIds[] = "{$eventsWSID}x" . $resultrow['crmid'];
             }
         }
         $alertRecords = $this->fetchRecordsWithId($module, $taskIds, $alert->getUser());
         if (!empty($eventIds)) {
             $alertRecords = array_merge($alertRecords, $this->fetchRecordsWithId('Events', $eventIds, $alert->getUser()));
         }
     } else {
         $fetchIds = array();
         while ($resultrow = $adb->fetch_array($alertResult)) {
             $fetchIds[] = "{$moduleWSID}x" . $resultrow['crmid'];
         }
         $alertRecords = $this->fetchRecordsWithId($module, $fetchIds, $alert->getUser());
     }
     return $alertRecords;
 }
コード例 #16
0
 protected function transformRecordWithGrouping($resultRecord, $module, $isTemplateRecord = false)
 {
     $current_user = $this->getActiveUser();
     $moduleFieldGroups = Mobile_WS_Utils::gatherModuleFieldGroupInfo($module);
     $modifiedResult = array();
     $blocks = array();
     $labelFields = false;
     foreach ($moduleFieldGroups as $blocklabel => $fieldgroups) {
         $fields = array();
         foreach ($fieldgroups as $fieldname => $fieldinfo) {
             $value = $resultRecord[$fieldname];
             $fieldlabel = $fieldinfo['label'];
             // get field information
             if (isset($resultRecord[$fieldname])) {
                 //get standard content & perform special settings
                 if ($fieldinfo['uitype'] == 17 && strlen($resultRecord[$fieldname])) {
                     //www fields
                     if ($_REQUEST['_operation'] == 'edit') {
                         $resultRecord[$fieldname] = $resultRecord[$fieldname];
                     } else {
                         $htmlstring = str_replace("http://", "", $resultRecord[$fieldname]);
                         $resultRecord[$fieldname] = "<A HREF=\"#\" onclick=\"window.location.href ='http://" . $htmlstring . "';\" rel=external>" . $htmlstring . "</A>";
                     }
                 }
                 if ($fieldinfo['uitype'] == 13 && strlen($resultRecord[$fieldname])) {
                     // email fields
                     if ($_REQUEST['_operation'] == 'edit') {
                         $resultRecord[$fieldname] = $resultRecord[$fieldname];
                     } else {
                         $resultRecord[$fieldname] = "<A HREF=\"#\" onclick=\"window.location.href ='mailto:" . $resultRecord[$fieldname] . "';\">" . $resultRecord[$fieldname] . "</A>";
                     }
                 }
                 if ($fieldinfo['uitype'] == 72 && strlen($resultRecord[$fieldname])) {
                     //currency fields
                     $resultRecord[$fieldname] = round($resultRecord[$fieldname], 2);
                 }
                 $field = array('name' => $fieldname, 'value' => $resultRecord[$fieldname], 'label' => $fieldinfo['label'], 'uitype' => $fieldinfo['uitype'], 'typeofdata' => $fieldinfo['typeofdata']);
                 // Template record requested, send more details if available
                 if ($isTemplateRecord) {
                     $describeFieldInfo = $this->cachedDescribeFieldInfo($fieldname);
                     foreach ($describeFieldInfo as $k => $v) {
                         if (isset($field[$k])) {
                             continue;
                         }
                         $field[$k] = $v;
                     }
                     // Entity fieldnames
                     $labelFields = $this->cachedEntityFieldnames($module);
                 }
                 //handling for special UI types: modify $field
                 if ($field['uitype'] == '53') {
                     //assigned user
                     global $adb;
                     $output = array_chunk($value, 1);
                     $recordarray = explode('x', $output[0][0]);
                     $recordprefix = $recordarray[0];
                     $value = $output[0][0];
                     if ($value != '' && $value != 0) {
                         $assigned_user_id = $value;
                     } else {
                         $assigned_user_id = $current_user->id;
                     }
                     $fieldvalue = Mobile_WS_Utils::getassignedtoValues($current_user, $assigned_user_id);
                     $field['type']['value'] = array('value' => $fieldvalue, 'name' => $fieldname);
                     //end UI 53
                 } else {
                     if ($field['uitype'] == '117') {
                         $field['type']['defaultValue'] = $field['value'];
                     } else {
                         if ($field['uitype'] == '15' || $field['uitype'] == '16' || $field['uitype'] == '33') {
                             //picklists
                             global $adb;
                             require_once 'modules/PickList/PickListUtils.php';
                             $fieldvalue = array();
                             $options = array();
                             $chk_val = "";
                             $roleid = $current_user->roleid;
                             $picklistValues = getAssignedPicklistValues($fieldname, $roleid, $adb);
                             $valueArr = explode("|##|", $value);
                             $pickcount = 0;
                             //get values
                             if (!empty($picklistValues)) {
                                 foreach ($picklistValues as $order => $pickListValue) {
                                     if (in_array(trim($pickListValue), array_map("trim", $valueArr))) {
                                         $chk_val = "selected";
                                         $pickcount++;
                                     } else {
                                         $chk_val = '';
                                     }
                                     if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') {
                                         $options[] = array('label' => htmlentities(getTranslatedString($pickListValue), ENT_QUOTES, $default_charset), 'value' => $pickListValue, 'selected' => $chk_val);
                                     } else {
                                         $options[] = array('label' => getTranslatedString($pickListValue), 'value' => $pickListValue, 'selected' => $chk_val);
                                     }
                                 }
                                 if ($pickcount == 0 && !empty($value)) {
                                     $options[] = array('label' => $app_strings['LBL_NOT_ACCESSIBLE'], 'value' => $value, 'selected');
                                 }
                             }
                             $editview_label[] = getTranslatedString($fieldlabel, $module);
                             if ($field['uitype'] == '33') {
                                 $field['value'] = implode(',', $valueArr);
                             }
                             $fieldvalue[] = $options;
                             $field['type']['value'] = array('value' => $options, 'name' => $fieldname);
                             //end picklists
                         } else {
                             if ($field['uitype'] == '51' || $field['uitype'] == '59' || $field['uitype'] == '10') {
                                 $field['relatedmodule'] = Mobile_WS_Utils::getEntityName($field['name'], $module);
                             }
                         }
                     }
                 }
                 $fields[] = $field;
             }
         }
         // build address for "open address in maps" button
         // array with all different address fieldnames for each module
         $fieldnamesByModule = array("Accounts" => array("bill_street", "ship_street", "bill_city", "ship_city", "bill_state", "ship_state", "bill_code", "ship_code", "bill_country", "ship_country", "ship_address", "bill_address"), "SalesOrder" => array("bill_street", "ship_street", "bill_city", "ship_city", "bill_state", "ship_state", "bill_code", "ship_code", "bill_country", "ship_country", "ship_address", "bill_address"), "Contacts" => array("mailingstreet", "otherstreet", "mailingcity", "othercity", "mailingstate", "otherstate", "mailingzip", "otherzip", "mailingcountry", "othercountry", "mailingaddress", "otheraddress"), "Leads" => array("lane", "", "city", "", "state", "", "code", "", "country", "", "mailingaddress", ""));
         // get the right array depending on current module
         $fieldnames = $fieldnamesByModule[$module];
         /*
         0 = appears if fieldgroup is not address information
         1 = address values are set, show button
         -1 = city or street is missing, don't show the button and avoid set back to 1 
         */
         $mailingAddressOK = 0;
         $otherAddressOK = 0;
         $mailingAddress = "";
         $otherAddress = "";
         // go through all fields
         foreach ($fieldgroups as $fieldname => $fieldinfo) {
             if (!is_array($resultRecord[$fieldname]) and !is_object($resultRecord[$fieldname])) {
                 $value = trim($resultRecord[$fieldname]);
                 // check street and city for first address
                 if ($mailingAddressOK != -1 and ($fieldname == $fieldnames[0] or $fieldname == $fieldnames[2])) {
                     $mailingAddressOK = 1;
                     if (strlen($value) > 0) {
                         $mailingAddress .= $value . " ";
                     } else {
                         $mailingAddressOK = -1;
                     }
                 } else {
                     if ($otherAddressOK != -1 and ($fieldname == $fieldnames[1] or $fieldname == $fieldnames[3])) {
                         $otherAddressOK = 1;
                         if (strlen($value) > 0) {
                             $otherAddress .= $value . " ";
                         } else {
                             $otherAddressOK = -1;
                         }
                     } else {
                         if (in_array($fieldname, array($fieldnames[4], $fieldnames[6])) and strlen($value) > 0) {
                             $mailingAddress .= $value . " ";
                         } else {
                             if (in_array($fieldname, array($fieldnames[5], $fieldnames[7])) and strlen($value) > 0) {
                                 $otherAddress .= $value . " ";
                             }
                         }
                     }
                 }
             }
         }
         if ($mailingAddressOK == 1) {
             if ($module == 'Contacts') {
                 $label = getTranslatedString("address", "Mobile");
             } else {
                 $label = getTranslatedString("bill_address", "Mobile");
             }
             $fields[] = array("name" => $fieldnames[10], "value" => $mailingAddress, "label" => $label, "uitype" => "crm_app_map", "typeofdata" => "O");
         }
         if ($otherAddressOK == 1) {
             if ($module == 'Contacts') {
                 $label = getTranslatedString("otheraddress", "Mobile");
             } else {
                 $label = getTranslatedString("ship_address", "Mobile");
             }
             $fields[] = array("name" => $fieldnames[11], "value" => $otherAddress, "label" => $label, "uitype" => "crm_app_map", "typeofdata" => "O");
         }
         $blocks[] = array('label' => $blocklabel, 'fields' => $fields);
     }
     $sections = array();
     $moduleFieldGroupKeys = array_keys($moduleFieldGroups);
     foreach ($moduleFieldGroupKeys as $blocklabel) {
         // eliminate empty blocks
         if (isset($groups[$blocklabel]) && !empty($groups[$blocklabel])) {
             $sections[] = array('label' => $blocklabel, 'count' => count($groups[$blocklabel]));
         }
     }
     $modifiedResult = array('blocks' => $blocks, 'id' => $resultRecord['id']);
     if ($labelFields) {
         $modifiedResult['labelFields'] = $labelFields;
     }
     return $modifiedResult;
 }
コード例 #17
0
ファイル: History.php プロジェクト: Bergdahls/YetiForceCRM
function vtws_history($element, $user)
{
    $MAXLIMIT = 100;
    $adb = PearDatabase::getInstance();
    // Mandatory input validation
    if (empty($element['module']) && empty($element['record'])) {
        throw new WebServiceException(WebServiceErrorCode::$MANDFIELDSMISSING, "Missing mandatory input values.");
    }
    if (!CRMEntity::getInstance('ModTracker') || !vtlib_isModuleActive('ModTracker')) {
        throw new WebServiceException("TRACKING_MODULE_NOT_ACTIVE", "Tracking module not active.");
    }
    $idComponents = NULL;
    $moduleName = $element['module'];
    $record = $element['record'];
    $mode = empty($element['mode']) ? 'Private' : $element['mode'];
    // Private or All
    $page = empty($element['page']) ? 0 : intval($element['page']);
    // Page to start
    $acrossAllModule = false;
    if ($moduleName == 'Home') {
        $acrossAllModule = true;
    }
    // Pre-condition check
    if (empty($moduleName)) {
        $moduleName = Mobile_WS_Utils::detectModulenameFromRecordId($record);
        $idComponents = vtws_getIdComponents($record);
        // We have it - as the input is validated.
    }
    if (!$acrossAllModule && !ModTracker::isTrackingEnabledForModule($moduleName)) {
        throw new WebServiceException("Module_NOT_TRACKED", "Module not tracked for changes.");
    }
    // Per-condition has been met, perform the operation
    $sql = '';
    $params = array();
    // REFER: modules/ModTracker/ModTracker.php
    // Two split phases for data extraction - so we can apply limit of retrieveal at record level.
    $sql = 'SELECT vtiger_modtracker_basic.* FROM vtiger_modtracker_basic
		INNER JOIN vtiger_crmentity ON vtiger_modtracker_basic.crmid = vtiger_crmentity.crmid
		AND vtiger_crmentity.deleted = 0';
    if ($mode == 'Private') {
        $sql .= ' WHERE vtiger_modtracker_basic.whodid = ?';
        $params[] = $user->getId();
    } else {
        if ($mode == 'All') {
            if ($acrossAllModule) {
                // TODO collate only active (or enabled) modules for tracking.
            } else {
                if ($moduleName) {
                    $sql .= ' WHERE vtiger_modtracker_basic.module = ?';
                    $params[] = $moduleName;
                } else {
                    $sql .= ' WHERE vtiger_modtracker_basic.crmid = ?';
                    $params[] = $idComponents[1];
                }
            }
        }
    }
    // Get most recently tracked changes with limit
    $start = $page * $MAXLIMIT;
    if ($start > 0) {
        $start = $start + 1;
    }
    // Adjust the start range
    $sql .= sprintf(' ORDER BY vtiger_modtracker_basic.id DESC LIMIT %s,%s', $start, $MAXLIMIT);
    $result = $adb->pquery($sql, $params);
    $recordValuesMap = array();
    $orderedIds = array();
    while ($row = $adb->fetch_array($result)) {
        $orderedIds[] = $row['id'];
        $whodid = vtws_history_entityIdHelper('Users', $row['whodid']);
        $crmid = vtws_history_entityIdHelper($acrossAllModule ? '' : $moduleName, $row['crmid']);
        $status = $row['status'];
        $statuslabel = '';
        switch ($status) {
            case ModTracker::$UPDATED:
                $statuslabel = 'updated';
                break;
            case ModTracker::$DELETED:
                $statuslabel = 'deleted';
                break;
            case ModTracker::$CREATED:
                $statuslabel = 'created';
                break;
            case ModTracker::$RESTORED:
                $statuslabel = 'restored';
                break;
            case ModTracker::$LINK:
                $statuslabel = 'link';
                break;
            case ModTracker::$UNLINK:
                $statuslabel = 'unlink';
                break;
        }
        $item['modifieduser'] = $whodid;
        $item['id'] = $crmid;
        $item['modifiedtime'] = $row['changedon'];
        $item['status'] = $status;
        $item['statuslabel'] = $statuslabel;
        $item['values'] = array();
        $recordValuesMap[$row['id']] = $item;
    }
    $historyItems = array();
    // Minor optimizatin to avoid 2nd query run when there is nothing to expect.
    if (!empty($orderedIds)) {
        $sql = 'SELECT vtiger_modtracker_detail.* FROM vtiger_modtracker_detail';
        $sql .= ' WHERE vtiger_modtracker_detail.id IN (' . generateQuestionMarks($orderedIds) . ')';
        // LIMIT here is not required as $ids extracted is with limit at record level earlier.
        $params = $orderedIds;
        $result = $adb->pquery($sql, $params);
        while ($row = $adb->fetch_array($result)) {
            $item = $recordValuesMap[$row['id']];
            // NOTE: For reference field values transform them to webservice id.
            $item['values'][$row['fieldname']] = array('previous' => $row['prevalue'], 'current' => $row['postvalue']);
            $recordValuesMap[$row['id']] = $item;
        }
        // Group the values per basic-transaction
        foreach ($orderedIds as $id) {
            $historyItems[] = $recordValuesMap[$id];
        }
    }
    return $historyItems;
}
コード例 #18
0
 function process(Mobile_API_Request $request)
 {
     if ($request->get('username') == '') {
         $response = new Mobile_API_Response();
         $response->setError(1501, 'Login required');
     } else {
         global $displayed_modules, $current_language, $current_user, $mod_strings, $app_strings;
         $username = $request->get('username');
         $current_user = CRMEntity::getInstance('Users');
         $userid = $current_user->retrieve_user_id($username);
         $current_user = $current_user->retrieveCurrentUserInfoFromFile($userid);
         $language = $current_user->language;
         $CRM_Version = Mobile::config('crm_version');
         if ($CRM_Version != '5.2.1') {
             //for v5.3.0 use User's Settings
             if ($language != '') {
                 $current_language = $language;
             } else {
                 $current_language = 'en_us';
             }
         } else {
             //for v5.2.1 use default language
             global $adb;
             $queryResult = $adb->pquery("SELECT prefix FROM vtiger_language WHERE isdefault =1", array());
             $current_language = $adb->query_result($queryResult, 0, 'prefix');
         }
         //set $app_strings
         Mobile_WS_Utils::initAppGlobals();
         $wsResponse = parent::process($request);
         $response = false;
         if ($wsResponse->hasError()) {
             $response = $wsResponse;
         } else {
             $wsResponseResult = $wsResponse->getResult();
             //fill cache
             $modules = Mobile_UI_ModuleModel::buildModelsFromResponse($wsResponseResult['modules']);
             $this->cacheModules($modules);
             Mobile_API_Session::set('language', $current_language);
             include dirname(__FILE__) . '/../language/' . $current_language . '.lang.php';
             //remove Events from module list display
             function filter_by_value($array, $index, $value)
             {
                 if (is_array($array) && count($array) > 0) {
                     foreach (array_keys($array) as $key) {
                         $temp[$key] = $array[$key][$index];
                         if ($temp[$key] == $value) {
                             $newarray[$key] = $array[$key];
                         }
                     }
                 }
                 return $newarray;
             }
             $eventarray = filter_by_value($wsResponseResult['modules'], 'name', 'Events');
             $eventkey = array_keys($eventarray);
             unset($modules[$eventkey[0]]);
             $viewer = new Mobile_UI_Viewer();
             $viewer->assign('_MODULES', $modules);
             $viewer->assign('MOD', $mod_strings);
             //reserved for future use: list modules for global search
             $viewer->assign('SEARCHIN', implode(",", $displayed_modules));
             $response = $viewer->process('generic/Home.tpl');
         }
     }
     return $response;
 }
コード例 #19
0
 protected function transformRecordWithGrouping($resultRecord, $module, $isTemplateRecord = false)
 {
     $current_user = $this->getActiveUser();
     $moduleFieldGroups = Mobile_WS_Utils::gatherModuleFieldGroupInfo($module);
     $modifiedResult = array();
     $blocks = array();
     $labelFields = false;
     foreach ($moduleFieldGroups as $blocklabel => $fieldgroups) {
         $fields = array();
         foreach ($fieldgroups as $fieldname => $fieldinfo) {
             // Pickup field if its part of the result
             if (isset($resultRecord[$fieldname])) {
                 $field = array('name' => $fieldname, 'value' => $resultRecord[$fieldname], 'label' => $fieldinfo['label'], 'uitype' => $fieldinfo['uitype']);
                 // Template record requested send more details if available
                 if ($isTemplateRecord) {
                     $describeFieldInfo = $this->cachedDescribeFieldInfo($fieldname);
                     if ($describeFieldInfo) {
                         foreach ($describeFieldInfo as $k => $v) {
                             if (isset($field[$k])) {
                                 continue;
                             }
                             $field[$k] = $v;
                         }
                     }
                     // Entity fieldnames
                     $labelFields = $this->cachedEntityFieldnames($module);
                 }
                 // Fix the assigned to uitype
                 if ($field['uitype'] == '53') {
                     $field['type']['defaultValue'] = array('value' => "19x{$current_user->id}", 'label' => $current_user->column_fields['last_name']);
                 } else {
                     if ($field['uitype'] == '117') {
                         $field['type']['defaultValue'] = $field['value'];
                     }
                 }
                 // END
                 $fields[] = $field;
             }
         }
         $blocks[] = array('label' => $blocklabel, 'fields' => $fields);
     }
     $sections = array();
     $moduleFieldGroupKeys = array_keys($moduleFieldGroups);
     foreach ($moduleFieldGroupKeys as $blocklabel) {
         // Eliminate empty blocks
         if (isset($groups[$blocklabel]) && !empty($groups[$blocklabel])) {
             $sections[] = array('label' => $blocklabel, 'count' => count($groups[$blocklabel]));
         }
     }
     $modifiedResult = array('blocks' => $blocks, 'id' => $resultRecord['id']);
     if ($labelFields) {
         $modifiedResult['labelFields'] = $labelFields;
     }
     if (isset($resultRecord['LineItems'])) {
         $modifiedResult['LineItems'] = $resultRecord['LineItems'];
     }
     return $modifiedResult;
 }
コード例 #20
0
 function process(Mobile_API_Request $request)
 {
     $current_user = $this->getActiveUser();
     $current_user_wsid = sprintf("%sx%s", Mobile_WS_Utils::getEntityModuleWSId("Users"), $current_user->id);
     $module = $request->get('module');
     $lastSyncTime = $request->get('syncToken', 0);
     $currentPage = intval($request->get('page', 0));
     $isPrivateMode = $this->isModePrivate($request);
     $FETCH_LIMIT = Mobile::config('API_RECORD_FETCH_LIMIT');
     $startLimit = $currentPage * $FETCH_LIMIT;
     // Keep track of sync-token for futher reference
     $maxSyncTime = $lastSyncTime;
     $describeInfo = vtws_describe($module, $current_user);
     $this->cacheDescribeInfo($describeInfo);
     $hasAssignedToField = false;
     foreach ($describeInfo['fields'] as $fieldinfo) {
         if ($fieldinfo['name'] == 'assigned_user_id') {
             $hasAssignedToField = true;
             break;
         }
     }
     /////////////////////////////
     // MODIFIED RECORDS TRACKING
     /////////////////////////////
     if (empty($lastSyncTime)) {
         // No previous state information available? Lookup records recently modified
         if ($hasAssignedToField && $isPrivateMode) {
             $queryActive = sprintf("SELECT * FROM %s WHERE assigned_user_id = '%s' ORDER BY modifiedtime DESC", $module, $current_user_wsid);
         } else {
             $queryActive = sprintf("SELECT * FROM %s ORDER BY modifiedtime DESC", $module);
         }
     } else {
         // Attempt to lookup records from previous state
         if ($hasAssignedToField && $isPrivateMode) {
             $queryActive = sprintf("SELECT * FROM %s WHERE assigned_user_id = '%s' AND modifiedtime > '%s'", $module, $current_user_wsid, date("Y-m-d H:i:s", $lastSyncTime));
         } else {
             $queryActive = sprintf("SELECT * FROM %s WHERE modifiedtime > '%s'", $module, date("Y-m-d H:i:s", $lastSyncTime));
         }
     }
     // Try to fetch record with paging (one extra record fetch is attempted to determine presence of next page)
     $activeQuery = sprintf("%s LIMIT %u,%u;", $queryActive, $startLimit, $FETCH_LIMIT + 1);
     $activeResult = vtws_query($activeQuery, $current_user);
     // Determine paging
     $hasNextPage = count($activeResult) > $FETCH_LIMIT;
     // Special case handling merge Events records
     if ($module == 'Calendar') {
         $activeResult2 = vtws_query(str_replace('Calendar', 'Events', $activeQuery), $current_user);
         if (!empty($activeResult2)) {
             $activeResult = array_merge($activeResult, $activeResult2);
             if (!$hasNextPage) {
                 // If there was not Calendar next-page of records - check with Events
                 $hasNextPage = count($activeResult) > $FETCH_LIMIT;
             }
         }
         // Indicator that we fetched both Calendar+Events
         $FETCH_LIMIT *= 2;
     }
     $nextPage = 0;
     if ($hasNextPage) {
         array_pop($activeResult);
         // Avoid sending next page record now
         $nextPage = $currentPage + 1;
     }
     // Resolved record details
     $resolvedModifiedRecords = array();
     $resolvedDeletedRecords = array();
     if (!empty($activeResult)) {
         foreach ($activeResult as $recordValues) {
             $this->resolveRecordValues($recordValues, $current_user);
             $transformedRecord = $this->transformRecordWithGrouping($recordValues, $module);
             // Update entity fieldnames
             $transformedRecord['labelFields'] = $this->cachedEntityFieldnames($module);
             $resolvedModifiedRecords[] = $transformedRecord;
             $modifiedTimeInSeconds = strtotime($recordValues['modifiedtime']);
             if ($maxSyncTime < $modifiedTimeInSeconds) {
                 $maxSyncTime = $modifiedTimeInSeconds;
             }
         }
     }
     ////////////////////////////
     // DELETED RECORDS TRACKING
     ////////////////////////////
     // Only when there is previous state information and is first page
     if (!empty($lastSyncTime) && $currentPage === 0) {
         $adb = PearDatabase::getInstance();
         $queryDeletedParameters = array($module, date('Y-m-d H:i:s', $lastSyncTime));
         $andsmowneridequal = "";
         if ($hasAssignedToField) {
             if ($isPrivateMode) {
                 $queryDeletedParameters[] = $current_user->id;
                 $andsmowneridequal = " AND vtiger_crmentity.smownerid=?";
             } else {
                 $andsmowneridequal = Mobile_WS_Utils::querySecurityFromSuffix($module, $current_user);
             }
         }
         // Since Calendar and Events are merged
         if ($module == 'Calendar') {
             $queryDeleted = $adb->pquery("SELECT activityid as crmid, activitytype as setype FROM vtiger_activity\n\t\t\t\t\tINNER JOIN vtiger_crmentity ON vtiger_activity.activityid=vtiger_crmentity.crmid\n\t\t\t\t\tAND vtiger_crmentity.deleted=1 AND vtiger_crmentity.setype=? AND vtiger_crmentity.modifiedtime > ?\n\t\t\t\t\tLEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid\n\t\t\t\t\tLEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid WHERE 1=1\t{$andsmowneridequal} ", $queryDeletedParameters);
         } else {
             if ($module == 'Leads') {
                 $queryDeleted = $adb->pquery("SELECT crmid, modifiedtime, setype FROM vtiger_crmentity\n\t\t\t\tINNER JOIN vtiger_leaddetails ON vtiger_leaddetails.leadid=vtiger_crmentity.crmid\n\t\t\t\tLEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid\n\t\t\t\tLEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\t\tWHERE (vtiger_crmentity.deleted=1 OR (vtiger_crmentity.deleted=0 AND vtiger_leaddetails.converted=1)) AND vtiger_crmentity.setype=? AND vtiger_crmentity.modifiedtime > ? {$andsmowneridequal}", $queryDeletedParameters);
             } else {
                 $queryDeleted = $adb->pquery("SELECT crmid, modifiedtime, setype FROM vtiger_crmentity\n\t\t\t\tLEFT JOIN vtiger_users ON vtiger_users.id = vtiger_crmentity.smownerid\n\t\t\t\tLEFT JOIN vtiger_groups ON vtiger_groups.groupid = vtiger_crmentity.smownerid\n\t\t\t\tWHERE vtiger_crmentity.deleted=1 AND vtiger_crmentity.setype=? AND vtiger_crmentity.modifiedtime > ? {$andsmowneridequal}", $queryDeletedParameters);
             }
         }
         while ($row = $adb->fetch_array($queryDeleted)) {
             $recordModule = $row['setype'];
             if ($module == 'Calendar') {
                 if ($row['setype'] != 'Task' && $row['setype'] != 'Emails') {
                     $recordModule = 'Events';
                 } else {
                     $recordModule = $module;
                 }
             }
             $resolvedDeletedRecords[] = sprintf("%sx%s", Mobile_WS_Utils::getEntityModuleWSId($recordModule), $row['crmid']);
             $modifiedTimeInSeconds = strtotime($row['modifiedtime']);
             if ($maxSyncTime < $modifiedTimeInSeconds) {
                 $maxSyncTime = $modifiedTimeInSeconds;
             }
         }
     }
     $result = array('nextSyncToken' => $maxSyncTime, 'deleted' => $resolvedDeletedRecords, 'updated' => $resolvedModifiedRecords, 'nextPage' => $nextPage);
     $response = new Mobile_API_Response();
     $response->setResult(array('sync' => $result));
     return $response;
 }
コード例 #21
0
 function query()
 {
     $sql = Mobile_WS_Utils::getModuleListQuery('Potentials', "vtiger_potential.sales_stage not like 'Closed%' AND\n\t\t\t\t\tDATEDIFF(vtiger_potential.closingdate, CURDATE()) <= 5");
     return preg_replace("/^SELECT count\\(\\*\\) as count(.*)/i", "SELECT crmid \$1", Vtiger_Functions::mkCountQuery($sql));
 }
コード例 #22
0
ファイル: ListModuleRecords.php プロジェクト: kduqi/corebos
 function queryToSelectFilteredRecords($module, $fieldnames, $filterOrAlertInstance, $pagingModel)
 {
     if ($filterOrAlertInstance instanceof Mobile_WS_SearchFilterModel) {
         return $filterOrAlertInstance->execute($fieldnames, $pagingModel);
     }
     global $adb;
     $moduleWSId = Mobile_WS_Utils::getEntityModuleWSId($module);
     $columnByFieldNames = Mobile_WS_Utils::getModuleColumnTableByFieldNames($module, $fieldnames);
     // Build select clause similar to Webservice query
     $selectColumnClause = "CONCAT('{$moduleWSId}','x',vtiger_crmentity.crmid) as id,";
     foreach ($columnByFieldNames as $fieldname => $fieldinfo) {
         $selectColumnClause .= sprintf("%s.%s as %s,", $fieldinfo['table'], $fieldinfo['column'], $fieldname);
     }
     $selectColumnClause = rtrim($selectColumnClause, ',');
     $query = $filterOrAlertInstance->query();
     $query = preg_replace("/SELECT.*FROM(.*)/i", "SELECT {$selectColumnClause} FROM \$1", $query);
     if ($pagingModel !== false) {
         $query .= sprintf(" LIMIT %s, %s", $pagingModel->currentCount(), $pagingModel->limit());
     }
     $prequeryResult = $adb->pquery($query, $filterOrAlertInstance->queryParameters());
     return new SqlResultIterator($adb, $prequeryResult);
 }
コード例 #23
0
ファイル: events.json.php プロジェクト: kduqi/corebos
    $startdate = $adb->query_result($result, $k, "date_start");
    //only European time format is currently supported
    $newStartDate = gmdate("d-m-Y h:m:s", strtotime($startdate));
    $starttime = $adb->query_result($result, $k, "time_start");
    $startDateTime = $startdate . ' ' . $starttime;
    //requires timestamp in miliseconds = unix time stamp * 1000
    $startDateTime = strtotime($startDateTime) * 1000;
    $starttmp = $adb->query_result($result, $k, "time_start");
    $endtime = $adb->query_result($result, $k, "time_end");
    $subject = $adb->query_result($result, $k, "subject");
    $activitytype = $adb->query_result($result, $k, "activitytype");
    $activitytypetrans = getTranslatedString($adb->query_result($result, $k, "activitytype"), 'Calendar');
    $descr = $adb->query_result($result, $k, "description");
    $cal_id = $adb->query_result($result, $k, "crmid");
    $moduleWSID = Mobile_WS_Utils::getEntityModuleWSId('Calendar');
    $eventsWSID = Mobile_WS_Utils::getEntityModuleWSId('Events');
    if ($activitytype != 'Task') {
        $calid = "{$eventsWSID}x" . $cal_id;
    } else {
        $calid = "{$moduleWSID}x" . $cal_id;
    }
    $tmp_str .= $separator;
    $tmp_str .= '	{ "date": "';
    $tmp_str .= $startDateTime;
    $tmp_str .= '", "type": "meeting", "title":  "' . $subject . ' ';
    $tmp_str .= '-';
    $tmp_str .= $activitytype . '", "description": "' . $descr . '", "url": "?_operation=fetchRecordWithGrouping&amp;record=' . $calid . '" }';
    $separator = ",";
    $tmp_arr[] = array('date' => "{$startDateTime}", 'type' => 'meeting', 'title' => $subject . ' - ' . $activitytypetrans, 'description' => $descr, 'url' => "?_operation=fetchRecordWithGrouping&amp;record={$calid}");
}
echo json_encode($tmp_arr);