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; }
function process(Mobile_API_Request $request) { $viewer = new Mobile_UI_Viewer(); $viewer->assign('errorcode', $this->error['code']); $viewer->assign('errormsg', $this->error['message']); return $viewer->process('generic/Error.tpl'); }
function process(Mobile_API_Request $request) { $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); $response = $viewer->process('generic/decideActivityType.tpl'); return $response; }
function process(Mobile_API_Request $request) { $response = new Mobile_API_Response(); $current_language = $this->sessionGet('language'); include_once dirname(__FILE__) . '/../language/' . $current_language . '.lang.php'; $module = $request->get('module'); $record = $request->get('record'); $viewer = new Mobile_UI_Viewer(); $viewer->assign('LANGUAGE', $current_language); $viewer->assign('MOD', $mod_strings); $viewer->assign('_MODULE', $module); $viewer->assign('id', $record); $response = $viewer->process('generic/deleteConfirmation.tpl'); 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; }
/** END */ function process(Mobile_API_Request $request) { $wsResponse = parent::process($request); $response = false; if ($wsResponse->hasError()) { $response = $wsResponse; } else { $wsResponseResult = $wsResponse->getResult(); $viewer = new Mobile_UI_Viewer(); $viewer->assign('_MODULE', $this->cachedModule($wsResponseResult['module'])); $viewer->assign('_RECORDS', Mobile_UI_ModuleRecordModel::buildModelsFromResponse($wsResponseResult['records'])); $viewer->assign('_MODE', $request->get('mode')); $viewer->assign('_PAGER', $this->getPagingModel($request)); $viewer->assign('_SEARCH', $request->get('search')); $response = $viewer->process('generic/List.tpl'); } return $response; }
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) { $wsResponse = parent::process($request); $response = false; if ($wsResponse->hasError()) { $response = $wsResponse; } else { $wsResponseResult = $wsResponse->getResult(); $modules = Mobile_UI_ModuleModel::buildModelsFromResponse($wsResponseResult['modules']); $this->cacheModules($modules); $viewer = new Mobile_UI_Viewer(); $viewer->assign('_MODULES', $modules); $response = $viewer->process('generic/Home.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; }
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(); $viewer = new Mobile_UI_Viewer(); $viewer->assign('_COMMENTS', array($wsResponseResult['comment'])); $response = $viewer->process('generic/Comments.tpl'); $response->setResult(json_encode(array('html' => $response->getResult()))); } return $response; }
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) { 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; }
/** END */ function process(Mobile_API_Request $request) { global $config_settings, $app_strings, $mod_strings; $wsResponse = parent::process($request); if (isset($_REQUEST['delaction'])) { //delete? if ($_REQUEST['delaction'] == 'deleteEntity') { $recordid = vtlib_purify($_REQUEST['record']); if (trim($recordid) != '') { //delete record $delResponse = Mobile_WS_DeleteRecords::process($request); } } } $current_user = $this->getActiveUser(); $current_language = $this->sessionGet('language'); include_once dirname(__FILE__) . '/../language/' . $current_language . '.lang.php'; $response = false; if ($wsResponse->hasError()) { $response = $wsResponse; } else { $wsResponseResult = $wsResponse->getResult(); $tabid = getTabid($wsResponseResult['module']); $CATEGORY = getParentTabFromModule($wsResponseResult['module']); if ($wsResponseResult['module'] != 'Calendar' && $wsResponseResult['module'] != 'Events') { $customView = new CustomView($wsResponseResult['module']); $id1 = $_REQUEST['viewName']; $id2 = $_REQUEST['view']; if ($id2 !== "" && $id2 == '1') { $viewid = $id1; } else { $viewid = $customView->getViewId($wsResponseResult['module']); } $customview_html = $customView->getCustomViewCombo($viewid); $customview_html = str_replace("></option>", ">" . $mod_strings['LBL_FILTER'] . "</option>", $customview_html); $viewinfo = $customView->getCustomViewByCvid($viewid); $focus = new $wsResponseResult['module'](); $focus->initSortbyField($wsResponseResult['module']); $order_by = $focus->getOrderBy(); $url_string = ''; } else { $calendarview_selected = $_REQUEST['viewName']; //week as default value if ($calendarview_selected == "") { if (isset($config_settings['calendarview']) and $config_settings['calendarview'] != '') { //get the default view from config $calendarview_selected = $config_settings['calendarview']; } else { $calendarview_selected = 'week'; } } $CATEGORY = getParentTabFromModule($wsResponseResult['module']); $customView = new CustomView($wsResponseResult['module']); $viewid = $customView->getViewId($wsResponseResult['module']); //special view for Calendar, custom filters are not considered $customview_arr = array('today' => 'LBL_TODAY', 'week' => 'LBL_WEEK', 'month' => 'LBL_MONTH', 'year' => 'LBL_YEAR'); $customview_html = ''; foreach ($customview_arr as $key => $value) { if ($key != $calendarview_selected) { $customview_html .= "<option value=" . $key . ">" . $mod_strings[$value] . "</option>"; } else { $customview_html .= "<option value=" . $key . " selected='selected'>" . $mod_strings[$value] . "</option>"; } } } $viewer = new Mobile_UI_Viewer(); if ($viewinfo['viewname'] == 'All' || $viewinfo['viewname'] == '') { $viewer->assign('_ALL', 'ALL'); } global $current_user, $adb, $list_max_entries_per_page; $current_user = $this->getActiveUser(); $viewer->assign('_MODULE', $this->cachedModule($wsResponseResult['module'])); $viewer->assign('_MODE', $request->get('mode')); $viewer->assign('_CATEGORY', $CATEGORY); $viewer->assign('_CUSTOMVIEW_OPTION', $customview_html); $viewer->assign('_PAGER', $this->getPagingModel($request)); $viewer->assign('_SEARCH', $request->get('search')); $viewer->assign('MOD', $mod_strings); $viewer->assign('LANGUAGE', $current_language); $viewer->assign('_VIEW', $viewid); $viewer->assign('_VIEWNAME', $calendarview_selected); $viewer->assign('CALENDARSELECT', $config_settings['compactcalendar']); $response = $viewer->process('generic/List.tpl'); } return $response; }
/** END */ function process(Mobile_API_Request $request) { global $current_user, $current_language, $displayed_modules; global $adb, $theme; $wsResponse = parent::process($request); $response = false; if ($wsResponse->hasError()) { $response = $wsResponse; } else { $current_user = $this->getActiveUser(); $response = false; $total_record_count = 0; $query_string = trim($_REQUEST['query_string']); $curModule = 'Home'; $search_tag = vtlib_purify($_REQUEST['search_tag']); //get language $current_user = $this->getActiveUser(); $CRM_Version = Mobile::config('crm_version'); if ($CRM_Version != '5.2.1') { //for v5.3.0 use User's Settings include 'user_privileges/user_privileges_' . $current_user->id . '.php'; if (isset($user_info['language'])) { $this->activeUser->column_fields['language'] = $user_info['language']; } else { $this->activeUser->column_fields['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()); $this->activeUser->column_fields['language'] = $adb->query_result($queryResult, 0, 'prefix'); } $current_language = $this->activeUser->column_fields['language']; include dirname(__FILE__) . '/../language/' . $current_language . '.lang.php'; function getSearchModules($filter = array()) { global $adb; // vtlib customization: Ignore disabled modules. //$sql = 'select distinct vtiger_field.tabid,name from vtiger_field inner join vtiger_tab on vtiger_tab.tabid=vtiger_field.tabid where vtiger_tab.tabid not in (16,29)'; $sql = 'select distinct vtiger_field.tabid,name from vtiger_field inner join vtiger_tab on vtiger_tab.tabid=vtiger_field.tabid where vtiger_tab.tabid not in (16,29) and vtiger_tab.presence != 1 and vtiger_field.presence in (0,2)'; // END $result = $adb->pquery($sql, array()); while ($module_result = $adb->fetch_array($result)) { $modulename = $module_result['name']; // Do we need to filter the module selection? if (!empty($filter) && is_array($filter) && !in_array($modulename, $filter)) { continue; } // END if ($modulename != 'Calendar') { $return_arr[$modulename] = $modulename; } else { $return_arr[$modulename] = 'Activity'; } } return $return_arr; } if (isset($query_string) && $query_string != '') { // limit search to modules enabled for mobile $search_onlyin = vtlib_purify($_REQUEST['search_onlyin']); if (!empty($search_onlyin)) { $search_onlyin = explode(',', $search_onlyin); //prevent manipulations if (array_values($search_onlyin) != array_values($displayed_modules)) { //do standard search $search_onlyin = $displayed_modules; } } else { $search_onlyin = $displayed_modules; } // Save the selection for future use (UnifiedSearchModules.php) $_SESSION['__UnifiedSearch_SelectedModules__'] = $search_onlyin; // END $object_array = getSearchModules($search_onlyin); $search_val = $query_string; $search_module = $_REQUEST['search_module']; $i = 0; $moduleRecordCount = array(); foreach ($object_array as $module => $object_name) { if ($curModule == 'Home' || $curModule == $module && !empty($_REQUEST['ajax'])) { $focus = CRMEntity::getInstance($module); if (isPermitted($module, "index") == "yes") { $listquery = getListQuery($module); $oCustomView = ''; $oCustomView = new CustomView($module); //Instead of getting current customview id, use cvid of All so that all entities will be found //$viewid = $oCustomView->getViewId($module); $cv_res = $adb->pquery("select cvid from vtiger_customview where viewname='All' and entitytype=?", array($module)); $viewid = $adb->query_result($cv_res, 0, 'cvid'); $listquery = $oCustomView->getModifiedCvListQuery($viewid, $listquery, $module); if ($module == "Calendar") { if (!isset($oCustomView->list_fields['Close'])) { $oCustomView->list_fields['Close'] = array('activity' => 'status'); } if (!isset($oCustomView->list_fields_name['Close'])) { $oCustomView->list_fields_name['Close'] = 'status'; } } if ($search_module != '' || $search_tag != '') { //This is for Tag search $where = getTagWhere($search_val, $current_user->id); $search_msg = $app_strings['LBL_TAG_SEARCH']; $search_msg .= "<b>" . to_html($search_val) . "</b>"; } else { //This is for Global search $where = getUnifiedWhere($listquery, $module, $search_val); $search_msg = $app_strings['LBL_SEARCH_RESULTS_FOR']; $search_msg .= "<b>" . htmlentities($search_val, ENT_QUOTES, $default_charset) . "</b>"; } if ($where != '') { $listquery .= ' and (' . $where . ')'; } if (!(isset($_REQUEST['ajax']) && $_REQUEST['ajax'] != '')) { $count_result = $adb->query($listquery); $noofrows = $adb->num_rows($count_result); } else { $noofrows = vtlib_purify($_REQUEST['recordCount']); } $moduleRecordCount[$module]['count'] = $noofrows; global $list_max_entries_per_page; if (!empty($_REQUEST['start'])) { $start = $_REQUEST['start']; if ($start == 'last') { $count_result = $adb->query(mkCountQuery($listquery)); $noofrows = $adb->query_result($count_result, 0, "count"); if ($noofrows > 0) { $start = ceil($noofrows / $list_max_entries_per_page); } } if (!is_numeric($start)) { $start = 1; } elseif ($start < 0) { $start = 1; } $start = ceil($start); } else { $start = 1; } $navigation_array = VT_getSimpleNavigationValues($start, $list_max_entries_per_page, $noofrows); $limitStartRecord = ($navigation_array['start'] - 1) * $list_max_entries_per_page; if ($adb->dbType == "pgsql") { $listquery = $listquery . " OFFSET {$limitStartRecord} LIMIT {$list_max_entries_per_page}"; } else { $listquery = $listquery . " LIMIT {$limitStartRecord}, {$list_max_entries_per_page}"; } $list_result = $adb->query($listquery); $listview_entries = $adb->pquery($listquery, array()); $entity = "select id from vtiger_ws_entity where ismodule=1 and name =?"; $ws_entity = $adb->pquery($entity, array($module)); $ws_entity2 = $adb->query_result($ws_entity, 0, 'id'); $filde = "select fieldname,entityidfield from vtiger_entityname where modulename =?"; $ws_entity1 = $adb->pquery($filde, array($module)); $fieldname = $adb->query_result($ws_entity1, 0, 'fieldname'); $entityidfield = $adb->query_result($ws_entity1, 0, 'entityidfield'); $firstname = explode(',', $fieldname); $noofrows = $adb->num_rows($listview_entries); //for new GUI for ($i = 0; $i < $noofrows; $i++) { $lstcontent[$module][$i]['firstname'] = $adb->query_result($listview_entries, $i, $firstname[0]); $lstcontent[$module][$i]['lastname'] = $adb->query_result($listview_entries, $i, $firstname[1]); if ($module == 'Calendar') { $eventtask = $adb->query_result($listview_entries, $i, 'activitytype'); if ($acttype != 'Task') { $ws_entity2 = 18; } else { $ws_entity2 = 1; } } $lstcontent[$module][$i]['id'] = $ws_entity2 . "x" . $adb->query_result($listview_entries, $i, 'crmid'); } //get translated module name $modullabel[$module] = $this->cachedModule($module)->label(); $i++; } } } //Added to display the Total record count } //end search $viewer = new Mobile_UI_Viewer(); $viewer->assign("MOD", $mod_strings); $viewer->assign("MODULE", $module); $viewer->assign("TAG_SEARCH", $search_tag); $viewer->assign("SEARCH_MODULE", vtlib_purify($_REQUEST['search_module'])); $viewer->assign("SINGLE_MOD", $module); $viewer->assign("SEARCH_STRING", htmlentities($search_val, ENT_QUOTES, $default_charset)); $viewer->assign('_MODULES', $modules); $viewer->assign('LISTHEADER', $listview_header); $viewer->assign('LISTENTITY', $lstcontent); $viewer->assign('MODLABEL', $modullabel); $viewer->assign('HEADERCOUNT', count($listview_header)); $viewer->assign("SEARCH_CRITERIA", "( {$noofrows} )" . $search_msg); $response = $viewer->process('generic/GlobalSearch.tpl'); } return $response; }
/** END */ function process(Mobile_API_Request $request) { $wsResponse = parent::process($request); $response = false; if ($wsResponse->hasError()) { $response = $wsResponse; } else { $wsResponseResult = $wsResponse->getResult(); $tabid = getTabid($wsResponseResult['module']); $CATEGORY = getParentTabFromModule($wsResponseResult['module']); //serch $total_record_count = 0; $query_string = trim($_REQUEST['query_string']); $curModule = 'Home'; $search_tag = vtlib_purify($_REQUEST['search_tag']); function getSearchModules($filter = array()) { global $adb; // vtlib customization: Ignore disabled modules. //$sql = 'select distinct vtiger_field.tabid,name from vtiger_field inner join vtiger_tab on vtiger_tab.tabid=vtiger_field.tabid where vtiger_tab.tabid not in (16,29)'; $sql = 'select distinct vtiger_field.tabid,name from vtiger_field inner join vtiger_tab on vtiger_tab.tabid=vtiger_field.tabid where vtiger_tab.tabid not in (16,29) and vtiger_tab.presence != 1 and vtiger_field.presence in (0,2)'; // END $result = $adb->pquery($sql, array()); while ($module_result = $adb->fetch_array($result)) { $modulename = $module_result['name']; // Do we need to filter the module selection? if (!empty($filter) && is_array($filter) && !in_array($modulename, $filter)) { continue; } // END if ($modulename != 'Calendar') { $return_arr[$modulename] = $modulename; } else { $return_arr[$modulename] = 'Activity'; } } return $return_arr; } if (isset($query_string) && $query_string != '') { // Was the search limited by user for specific modules? $search_onlyin = $_REQUEST['search_onlyin']; if (!empty($search_onlyin) && $search_onlyin != '--USESELECTED--') { $search_onlyin = explode(',', $search_onlyin); } else { if ($search_onlyin == '--USESELECTED--') { $search_onlyin = $_SESSION['__UnifiedSearch_SelectedModules__']; } else { $search_onlyin = array(); } } // Save the selection for futur use (UnifiedSearchModules.php) $_SESSION['__UnifiedSearch_SelectedModules__'] = $search_onlyin; // END $object_array = getSearchModules($search_onlyin); global $adb; global $current_user; global $theme; $theme_path = "themes/" . $theme . "/"; $image_path = $theme_path . "images/"; $search_val = $query_string; $search_module = $_REQUEST['search_module']; $i = 0; $moduleRecordCount = array(); foreach ($object_array as $module => $object_name) { if ($curModule == 'Home' || $curModule == $module && !empty($_REQUEST['ajax'])) { $focus = CRMEntity::getInstance($module); if (isPermitted($module, "index") == "yes") { $smarty = new vtigerCRM_Smarty(); global $mod_strings; global $app_strings; $smarty->assign("MOD", $mod_strings); $smarty->assign("APP", $app_strings); $smarty->assign("THEME", $theme); $smarty->assign("IMAGE_PATH", $image_path); $smarty->assign("MODULE", $module); $smarty->assign("TAG_SEARCH", $search_tag); $smarty->assign("SEARCH_MODULE", vtlib_purify($_REQUEST['search_module'])); $smarty->assign("SINGLE_MOD", $module); $smarty->assign("SEARCH_STRING", htmlentities($search_val, ENT_QUOTES, $default_charset)); $listquery = getListQuery($module); $oCustomView = ''; $oCustomView = new CustomView($module); //Instead of getting current customview id, use cvid of All so that all entities will be found //$viewid = $oCustomView->getViewId($module); $cv_res = $adb->pquery("select cvid from vtiger_customview where viewname='All' and entitytype=?", array($module)); $viewid = $adb->query_result($cv_res, 0, 'cvid'); $listquery = $oCustomView->getModifiedCvListQuery($viewid, $listquery, $module); if ($module == "Calendar") { if (!isset($oCustomView->list_fields['Close'])) { $oCustomView->list_fields['Close'] = array('activity' => 'status'); } if (!isset($oCustomView->list_fields_name['Close'])) { $oCustomView->list_fields_name['Close'] = 'status'; } } if ($search_module != '' || $search_tag != '') { //This is for Tag search $where = getTagWhere($search_val, $current_user->id); $search_msg = $app_strings['LBL_TAG_SEARCH']; $search_msg .= "<b>" . to_html($search_val) . "</b>"; } else { //This is for Global search $where = getUnifiedWhere($listquery, $module, $search_val); $search_msg = $app_strings['LBL_SEARCH_RESULTS_FOR']; $search_msg .= "<b>" . htmlentities($search_val, ENT_QUOTES, $default_charset) . "</b>"; } if ($where != '') { $listquery .= ' and (' . $where . ')'; } if (!(isset($_REQUEST['ajax']) && $_REQUEST['ajax'] != '')) { $count_result = $adb->query($listquery); $noofrows = $adb->num_rows($count_result); } else { $noofrows = vtlib_purify($_REQUEST['recordCount']); } $moduleRecordCount[$module]['count'] = $noofrows; global $list_max_entries_per_page; if (!empty($_REQUEST['start'])) { $start = $_REQUEST['start']; if ($start == 'last') { $count_result = $adb->query(mkCountQuery($listquery)); $noofrows = $adb->query_result($count_result, 0, "count"); if ($noofrows > 0) { $start = ceil($noofrows / $list_max_entries_per_page); } } if (!is_numeric($start)) { $start = 1; } elseif ($start < 0) { $start = 1; } $start = ceil($start); } else { $start = 1; } $navigation_array = VT_getSimpleNavigationValues($start, $list_max_entries_per_page, $noofrows); $limitStartRecord = ($navigation_array['start'] - 1) * $list_max_entries_per_page; if ($adb->dbType == "pgsql") { $listquery = $listquery . " OFFSET {$limitStartRecord} LIMIT {$list_max_entries_per_page}"; } else { $listquery = $listquery . " LIMIT {$limitStartRecord}, {$list_max_entries_per_page}"; } $list_result = $adb->query($listquery); $listview_entries = $adb->pquery($listquery, array()); $entity = "select id from vtiger_ws_entity where ismodule=1 and name =?"; $ws_entity = $adb->pquery($entity, array($module)); $ws_entity2 = $adb->query_result($ws_entity, 0, 'id'); $filde = "select fieldname,entityidfield from vtiger_entityname where modulename =?"; $ws_entity1 = $adb->pquery($filde, array($module)); $fieldname = $adb->query_result($ws_entity1, 0, 'fieldname'); $entityidfield = $adb->query_result($ws_entity1, 0, 'entityidfield'); $firstname = explode(',', $fieldname); $noofrows = $adb->num_rows($listview_entries); $lstresult = array(); for ($i = 0; $i < $noofrows; $i++) { $lstresult[$i]['firstname'] = $adb->query_result($listview_entries, $i, $firstname[0]); $lstresult[$i]['lastname'] = $adb->query_result($listview_entries, $i, $firstname[1]); $lstresult[$i]['id'] = $ws_entity2 . "x" . $adb->query_result($listview_entries, $i, 'crmid'); } //Do not display the Header if there are no entires in listview_entries if (count($listview_entries) > 0) { $display_header = 1; } else { $display_header = 0; } $smarty->assign("LISTHEADER", $listview_header); $smarty->assign("LISTENTITY", $lstresult); $smarty->assign("DISPLAYHEADER", $display_header); $smarty->assign("HEADERCOUNT", count($listview_header)); $smarty->assign("searchstring", $query_string); $smarty->assign("SEARCH_CRITERIA", "( {$noofrows} )" . $search_msg); $smarty->display("UnifiedSearchAjax1.tpl"); unset($_SESSION['lvs'][$module]); $i++; } } } //Added to display the Total record count } //end search $viewer = new Mobile_UI_Viewer(); $viewer->assign('_MODULE', $this->cachedModule($wsResponseResult['module'])); $viewer->assign('_RECORDS', Mobile_UI_ModuleRecordModel::buildModelsFromResponse($wsResponseResult['records'])); } return $response; }