Esempio n. 1
2
 function process(Mobile_API_Request $request)
 {
     $current_user = $this->getActiveUser();
     $query = $request->get('query');
     $nextPage = 0;
     $queryResult = false;
     if (preg_match("/(.*) LIMIT[^;]+;/i", $query)) {
         $queryResult = vtws_query($query, $current_user);
     } else {
         // Implicit limit and paging
         $query = rtrim($query, ";");
         $currentPage = intval($request->get('page', 0));
         $FETCH_LIMIT = Mobile::config('API_RECORD_FETCH_LIMIT');
         $startLimit = $currentPage * $FETCH_LIMIT;
         $queryWithLimit = sprintf("%s LIMIT %u,%u;", $query, $startLimit, $FETCH_LIMIT + 1);
         $queryResult = vtws_query($queryWithLimit, $current_user);
         // Determine paging
         $hasNextPage = count($queryResult) > $FETCH_LIMIT;
         if ($hasNextPage) {
             array_pop($queryResult);
             // Avoid sending next page record now
             $nextPage = $currentPage + 1;
         }
     }
     $records = array();
     if (!empty($queryResult)) {
         foreach ($queryResult as $recordValues) {
             $records[] = $this->processQueryResultRecord($recordValues, $current_user);
         }
     }
     $result = array('records' => $records, 'nextPage' => $nextPage);
     $response = new Mobile_API_Response();
     $response->setResult($result);
     return $response;
 }
Esempio n. 2
0
 function viewController()
 {
     $smarty = new vtigerCRM_Smarty();
     foreach ($this->parameters as $k => $v) {
         $smarty->assign($k, $v);
     }
     $smarty->assign("IS_SAFARI", Mobile::isSafari());
     $smarty->assign("SKIN", Mobile::config('Default.Skin'));
     return $smarty;
 }
Esempio n. 3
0
 function getHistoryList()
 {
     $uid = intval($this->Get['uid']);
     if (empty($uid)) {
         Mobile::error("No Error Tips", 321);
     }
     $info = $this->MyPmLogic->getHistoryList(MEMBER_ID, $uid, array("per_page_num" => Mobile::config("perpage_pm")));
     if (!empty($info)) {
         $info['current_page'] = empty($info['current_page']) ? 1 : $info['current_page'];
         Mobile::output($info);
     } else {
         Mobile::error("No Error Tips", 400);
     }
 }
Esempio n. 4
0
 function Main()
 {
     $uid = intval($this->Get['uid']);
     $param = array('limit' => Mobile::config("perpage_def"), 'uid' => $uid);
     $ret = Mobile::convert($this->MTagLogic->getTagList($param));
     if (is_array($ret)) {
         $tag_list = $ret['tag_list'];
         $list_count = $ret['list_count'];
         $total_record = $ret['total_record'];
         $max_id = $ret['max_id'];
     } else {
         Mobile::show_message($ret);
     }
     include template('tag_list');
 }
Esempio n. 5
0
 function searchUser()
 {
     Mobile::logic('member');
     $MemberLogic = new MemberLogic();
     $q = trim($this->Get['q']);
     if (empty($q)) {
         Mobile::error("No Data", 400);
     }
     $param = array('limit' => Mobile::config("perpage_member"), 'nickname' => $q, 'max_id' => $this->Get['max_id']);
     $ret = $MemberLogic->getMemberList($param);
     if (is_array($ret)) {
         Mobile::output($ret);
     } else {
         Mobile::error("No Data", $ret);
     }
 }
Esempio n. 6
0
 function getHistoryList()
 {
     $uid = intval($this->Get['uid']);
     if (empty($uid)) {
         Mobile::show_message(300);
     }
     $info = Mobile::convert($this->MyPmLogic->getHistoryList(MEMBER_ID, $uid, array("per_page_num" => Mobile::config("perpage_pm"))));
     if (!empty($info)) {
         $pm_list = $info['pm_list'];
         $current_page = empty($info['current_page']) ? 1 : $info['current_page'];
         $next_page = $current_page + 1;
         $total_page = intval($info['total_page']);
         $list_count = count($info['pm_list']);
     } else {
         Mobile::show_message(400);
     }
     include template('pm_list');
 }
Esempio n. 7
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;
 }
Esempio n. 8
0
 function searchUser()
 {
     $this->Title = "Search User";
     Mobile::logic('member');
     $MemberLogic = new MemberLogic();
     $q = trim($this->Get['q']);
     if (empty($q)) {
         Mobile::show_message($ret);
     } else {
         $param = array('limit' => Mobile::config("perpage_member"), 'nickname' => $q);
         $keyword = urlencode($param['nickname']);
         $ret = Mobile::convert($MemberLogic->getMemberList($param));
         if (is_array($ret)) {
             $member_list = $ret['member_list'];
             $total_record = $ret['total_record'];
             $list_count = count($member_list);
             $max_tid = $ret['max_tid'];
         } else {
             Mobile::show_message($ret);
         }
     }
     include template('search_user');
 }
Esempio n. 9
0
 function getCommentList()
 {
     $tid = intval($this->Get['tid']);
     $topic_info = $this->MblogLogic->TopicLogic->Get($tid);
     if (empty($topic_info)) {
         Mobile::error('No Data', 400);
     }
     if ($topic_info['replys'] > 0) {
         $param = array('tid' => $tid, 'limit' => Mobile::config("perpage_mblog"), 'max_tid' => intval($this->Get['max_tid']));
         $ret = $this->MblogLogic->getCommentList($param);
         $error_code = 0;
         if (is_array($ret)) {
             $topic_list = $ret['topic_list'];
             $ret['list_count'] = count($topic_list);
             Mobile::output($ret);
         } else {
             $error_code = $ret;
             Mobile::error('No Data', 400);
         }
     } else {
         Mobile::error('No Data', 400);
     }
 }
Esempio n. 10
0
 function __construct()
 {
     $this->_limit = Mobile::config('API_RECORD_FETCH_LIMIT', 20);
 }
Esempio n. 11
0
 function MasterObject(&$config)
 {
     require_once ROOT_PATH . 'mobile/include/func/mobile.func.php';
     $config['client_type'] = '';
     $user_agent = $_SERVER['HTTP_USER_AGENT'];
     if (empty($user_agent)) {
         exit('Access Denied');
     }
     $pc_browser = false;
     if (preg_match("/android/i", $user_agent)) {
         $config['client_type'] = "android";
     } else {
         if (preg_match("/iphone/i", $user_agent)) {
             $config['client_type'] = "iphone";
         } else {
             $pc_browser = true;
         }
     }
     $config['is_mobile_client'] = false;
     if (isset($_GET['JSG_SESSION']) && isset($_GET['iv']) && isset($_GET['app_key']) && isset($_GET['app_secret']) && isset($_GET['bt'])) {
         $config['is_mobile_client'] = true;
         define("IS_MOBILE_CLIENT", true);
     }
     define("CLIENT_TYPE", $config['client_type']);
     $config['sys_version'] = sys_version();
     $config['sys_published'] = SYS_PUBLISHED;
     if (!$config['mobile_url']) {
         $config['mobile_url'] = $config['site_url'] . "/mobile";
     }
     if (!$config['topic_length']) {
         $config['topic_length'] = 140;
     }
     $this->Config = $config;
     $this->Config = array_merge($this->Config, Mobile::config());
     define("CHARSET", $this->Config['charset']);
     Obj::register('config', $this->Config);
     $this->Get =& $_GET;
     $this->Post =& $_POST;
     $this->Module = trim($this->Post['mod'] ? $this->Post['mod'] : $this->Get['mod']);
     $this->Code = trim($this->Post['code'] ? $this->Post['code'] : $this->Get['code']);
     $this->DatabaseHandler =& Obj::registry('DatabaseHandler');
     $uid = 0;
     $password = '';
     $authcode = '';
     $implicit_pass = true;
     if (!empty($this->Get['JSG_SESSION']) && $config['is_mobile_client']) {
         $authcode = $this->Get['JSG_SESSION'];
         $authcode = rawurldecode($authcode);
         $implicit_pass = false;
     } else {
         $authcode = jsg_getcookie('auth');
     }
     if (!empty($authcode)) {
         list($password, $uid) = explode("\t", authcode($authcode, 'DECODE'));
     }
     $this->MemberHandler = jclass('member');
     $MemberFields = $this->MemberHandler->FetchMember($uid, $password);
     if ($this->MemberHandler->HasPermission($this->Module, $this->Code) == false) {
         Mobile::show_message(411);
         exit;
     }
     if (!in_array($this->Module, array('member', 'login', 'wechat'))) {
         $visit_rets = $this->MemberHandler->visit();
         if ($visit_rets['error']) {
             Mobile::show_message(411);
             exit;
         }
     }
     $this->Title = $this->MemberHandler->CurrentAction['name'];
     Obj::register("MemberHandler", $this->MemberHandler);
     $rets = jsg_member_login_extract();
     if ($rets) {
         if (MEMBER_ID < 1) {
             $func = $rets['login_direct'];
         } else {
             $func = $rets['logout_direct'];
         }
         if ($func && function_exists($func)) {
             $ret = $func();
         }
     }
     if (MEMBER_ID > 0) {
         jsg_member_login_set_status($MemberFields);
     }
     if ($this->Config['extcredits_enable']) {
         if (MEMBER_ID > 0 && jsg_getcookie('login_credits') + 3600 < time()) {
             update_credits_by_action('login', MEMBER_ID);
             jsg_setcookie('login_credits', time(), 3600);
         }
     }
 }
Esempio n. 12
0
 /** 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;
 }
Esempio n. 13
0
 function blacklist()
 {
     $param = array('limit' => Mobile::config("perpage_member"), 'uid' => intval($this->Get['uid']), 'max_id' => intval($this->Get['max_id']));
     $ret = $this->FriendLogic->getBlackList($param);
     if (is_array($ret)) {
         Mobile::output($ret);
     } else {
         Mobile::error("No Error Tips", $ret);
     }
 }
Esempio n. 14
0
 function getCommentList()
 {
     $tid = intval($this->Get['tid']);
     $topic_info = $this->MblogLogic->TopicLogic->Get($tid);
     if (empty($topic_info)) {
         Mobile::show_message(400);
     }
     if ($topic_info['replys'] > 0) {
         $param = array('tid' => $tid, 'limit' => Mobile::config("perpage_mblog"));
         $ret = Mobile::convert($this->MblogLogic->getCommentList($param));
         $error_code = 0;
         if (is_array($ret)) {
             $topic_list = $ret['topic_list'];
             $parent_list = $ret['parent_list'];
             $total_record = $ret['total_record'];
             $list_count = count($topic_list);
             $max_tid = $ret['max_tid'];
             $next_page = $ret['next_page'];
         }
     } else {
     }
     $huifu_flg = "is_huifu";
     include template('topic_comment');
 }
Esempio n. 15
0
 function getPagingModel(Mobile_API_Request $request)
 {
     $pagingModel = Mobile_WS_PagingModel::modelWithPageStart($request->get('page'));
     $pagingModel->setLimit(Mobile::config('Navigation.Limit', 100));
     return $pagingModel;
 }
Esempio n. 16
0
 function blacklist()
 {
     $param = array('limit' => Mobile::config("perpage_member"));
     $ret = Mobile::convert($this->FriendLogic->getBlackList($param));
     if (is_array($ret)) {
         $member_list = $ret['member_list'];
         $list_count = count($member_list);
         $total_record = $ret['total_record'];
         $max_id = $ret['max_id'];
     } else {
         Mobile::show_message($ret);
     }
     include template('friend_list');
 }
Esempio n. 17
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;
 }
Esempio n. 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;
 }
Esempio n. 19
0
                echo $topic['replys'];
                ?>
)
<?php 
            } else {
                ?>
评论
<?php 
            }
            ?>
 </span></p></a> </footer> </article> <?php 
        }
    }
    ?>
 </div> <?php 
    if ($list_count == Mobile::config('perpage_mblog')) {
        ?>
 <?php 
        if ($this->Module == 'topic') {
            ?>
 <?php 
            if ($this->Code == 'tag') {
                ?>
 <div class="wb_more" onclick='getMoreMBlogList({"max_tid":<?php 
                echo $max_tid;
                ?>
, "next_page":<?php 
                echo $next_page;
                ?>
, "code":"tag", "tag_key":"<?php 
                echo $tag_key;
Esempio n. 20
0
                    ?>
 <a href="javascript:;" onclick="delFollow(this, <?php 
                    echo $member['uid'];
                    ?>
); return true;" class="btn_y"></a> <?php 
                }
                ?>
 <?php 
            }
            ?>
 </div> </li> <?php 
        }
    }
    ?>
 </ul> <?php 
    if ($list_count == Mobile::config('perpage_member')) {
        ?>
 <div class="wb_more" onclick="getSerachMoreMemberList({'max_id':<?php 
        echo $max_id;
        ?>
, 'q':'<?php 
        echo $keyword;
        ?>
'})" id="btn_more">更多...</div> <?php 
    }
    ?>
 <?php 
}
?>
 </div> </div> <div id="g_toolbar" class="g_toolbar"> <ul class="g_toolbar_ul g_towbtn"> <li><a href="javascript:openPublishBox(PUBLISH_NEW, {'atuid':<?php 
echo $member['uid'];