当前位置: 首页>>代码示例>>PHP>>正文


PHP QueryGenerator::initForDefaultCustomView方法代码示例

本文整理汇总了PHP中QueryGenerator::initForDefaultCustomView方法的典型用法代码示例。如果您正苦于以下问题:PHP QueryGenerator::initForDefaultCustomView方法的具体用法?PHP QueryGenerator::initForDefaultCustomView怎么用?PHP QueryGenerator::initForDefaultCustomView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QueryGenerator的用法示例。


在下文中一共展示了QueryGenerator::initForDefaultCustomView方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getInstance

 /**
  * Static Function to get the Instance of Vtiger ListView model for a given module and custom view
  * @param <String> $moduleName - Module Name
  * @param <Number> $viewId - Custom View Id
  * @return Vtiger_ListView_Model instance
  */
 public static function getInstance($moduleName, $sourceModule)
 {
     $db = PearDatabase::getInstance();
     $currentUser = vglobal('current_user');
     $modelClassName = Vtiger_Loader::getComponentClassName('Model', 'ListView', $moduleName);
     $instance = new $modelClassName();
     $sourceModuleModel = Vtiger_Module_Model::getInstance($sourceModule);
     $queryGenerator = new QueryGenerator($sourceModuleModel->get('name'), $currentUser);
     $queryGenerator->initForDefaultCustomView();
     $controller = new ListViewController($db, $currentUser, $queryGenerator);
     return $instance->set('module', $sourceModuleModel)->set('query_generator', $queryGenerator)->set('listview_controller', $controller);
 }
开发者ID:nouphet,项目名称:vtigercrm-6.0.0-ja,代码行数:18,代码来源:ListView.php

示例2: getContent

 function getContent(Mobile_API_Request $request)
 {
     global $current_user, $adb;
     $current_user = $this->getActiveUser();
     $module = $request->get('module');
     $limit = $request->get('number');
     $offset = $request->get('offset');
     $search = isset($_REQUEST['src_str']) ? $request->get('src_str') : '';
     $customView = new CustomView($module);
     if (!empty($_REQUEST['view'])) {
         $viewid = $_REQUEST['view'];
     } else {
         $viewid = $customView->getViewId($module);
     }
     $queryGenerator = new QueryGenerator($module, $current_user);
     if ($viewid != "0") {
         $queryGenerator->initForCustomViewById($viewid);
     } else {
         $queryGenerator->initForDefaultCustomView();
     }
     $list_query = $queryGenerator->getQuery();
     //get entity fields for each module
     $entity_sql = "select fieldname,tablename,entityidfield from vtiger_entityname where modulename =?";
     $ws_entity = $adb->pquery($entity_sql, array($module));
     $fieldname = $adb->query_result($ws_entity, 0, 'fieldname');
     $tablename = $adb->query_result($ws_entity, 0, 'tablename');
     //set the list and content order
     if ($module == 'Contacts' || $module == 'Leads') {
         $list_query .= " AND (lastname LIKE '%{$search}%' OR firstname LIKE '%{$search}%') ORDER BY lastname";
     } elseif ($module != 'Calendar' and $module != 'Events') {
         $list_query .= " AND " . $tablename . "." . $fieldname . " LIKE '%{$search}%' ORDER BY " . $tablename . "." . $fieldname;
     } elseif ($module == 'Calendar' || $module == 'Events') {
         $calendarview_selected = $request->get('viewName');
         $list_query .= " AND vtiger_activity.activitytype!='Emails'";
         if ($calendarview_selected == 'week') {
             $list_query .= " AND week(date_start) = week(NOW()) AND year(date_start) = year(NOW())";
         } elseif ($calendarview_selected == 'month') {
             $list_query .= " AND month(date_start) = month(NOW()) AND year(date_start) = year(NOW())";
         } elseif ($calendarview_selected == 'year') {
             $list_query .= " AND year(date_start) = year(NOW())";
         } elseif ($calendarview_selected == 'today') {
             $list_query .= " AND DATE(date_start) = DATE(NOW())";
         }
         $list_query .= " AND subject LIKE '%{$search}%' ORDER BY date_start DESC";
     } else {
         $list_query .= " AND " . $tablename . "." . $fieldname . " LIKE '%{$search}%' ORDER BY " . $tablename . "." . $fieldname;
     }
     $list_query .= " LIMIT {$offset}, {$limit};";
     $listview_entries = $adb->pquery($list_query, array());
     $response = new Mobile_API_Response();
     $response->setResult(array('records' => $listview_entries, 'module' => $module));
     return $response;
 }
开发者ID:kduqi,项目名称:corebos,代码行数:53,代码来源:getScrollContent.php

示例3: getRecordsList

 public function getRecordsList()
 {
     $moduleName = $this->api->getModuleName();
     $user = new Users();
     $currentUser = $user->retrieveCurrentUserInfoFromFile(Users::getActiveAdminId());
     vglobal('current_user', $currentUser);
     $listQuery = '';
     $queryGenerator = new QueryGenerator($moduleName, $currentUser);
     $queryGenerator->initForDefaultCustomView();
     $listQuery = $queryGenerator->getQuery();
     $db = PearDatabase::getInstance();
     $listResult = $db->query($listQuery);
     $records = [];
     while ($row = $db->fetch_array($listResult)) {
         $records[] = $row;
     }
     //$listQuery = getListQuery('OSSTimeControl', '');
     return ['headers' => $queryGenerator->getFields(), 'records' => $records, 'count' => 456];
 }
开发者ID:snowflakelady,项目名称:YetiForceCRM,代码行数:19,代码来源:GetRecordsList.php

示例4: createRecords

 public function createRecords()
 {
     $adb = PearDatabase::getInstance();
     $moduleName = $this->module;
     $focus = CRMEntity::getInstance($moduleName);
     $moduleHandler = vtws_getModuleHandlerFromName($moduleName, $this->user);
     $moduleMeta = $moduleHandler->getMeta();
     $moduleObjectId = $moduleMeta->getEntityId();
     $moduleFields = $moduleMeta->getModuleFields();
     $tableName = Import_Utils::getDbTableName($this->user);
     $sql = 'SELECT * FROM ' . $tableName . ' WHERE status = ' . Import_Data_Controller::$IMPORT_RECORD_NONE;
     if ($this->batchImport) {
         $configReader = new ConfigReader('modules/Import/config.inc', 'ImportConfig');
         $importBatchLimit = $configReader->getConfig('importBatchLimit');
         $sql .= ' LIMIT ' . $importBatchLimit;
     }
     $result = $adb->query($sql);
     $numberOfRecords = $adb->num_rows($result);
     if ($numberOfRecords <= 0) {
         return;
     }
     $fieldMapping = $this->fieldMapping;
     $fieldColumnMapping = $moduleMeta->getFieldColumnMapping();
     for ($i = 0; $i < $numberOfRecords; ++$i) {
         $row = $adb->raw_query_result_rowdata($result, $i);
         $rowId = $row['id'];
         $entityInfo = null;
         $fieldData = array();
         foreach ($fieldMapping as $fieldName => $index) {
             $fieldData[$fieldName] = $row[$fieldName];
         }
         $mergeType = $this->mergeType;
         $createRecord = false;
         if (method_exists($focus, 'importRecord')) {
             $entityInfo = $focus->importRecord($this, $fieldData);
         } else {
             if (!empty($mergeType) && $mergeType != Import_Utils::$AUTO_MERGE_NONE) {
                 $queryGenerator = new QueryGenerator($moduleName, $this->user);
                 $queryGenerator->initForDefaultCustomView();
                 $fieldsList = array('id');
                 $queryGenerator->setFields($fieldsList);
                 $mergeFields = $this->mergeFields;
                 foreach ($mergeFields as $index => $mergeField) {
                     if ($index != 0) {
                         $queryGenerator->addConditionGlue(QueryGenerator::$AND);
                     }
                     $comparisonValue = $fieldData[$mergeField];
                     $fieldInstance = $moduleFields[$mergeField];
                     if ($fieldInstance->getFieldDataType() == 'owner') {
                         $userId = getUserId_Ol($comparisonValue);
                         $comparisonValue = getUserFullName($userId);
                     }
                     if ($fieldInstance->getFieldDataType() == 'reference') {
                         if (strpos($comparisonValue, '::::') > 0) {
                             $referenceFileValueComponents = explode('::::', $comparisonValue);
                         } else {
                             $referenceFileValueComponents = explode(':::', $comparisonValue);
                         }
                         if (count($referenceFileValueComponents) > 1) {
                             $comparisonValue = trim($referenceFileValueComponents[1]);
                         }
                     }
                     $queryGenerator->addCondition($mergeField, $comparisonValue, 'e');
                 }
                 $query = $queryGenerator->getQuery();
                 $duplicatesResult = $adb->query($query);
                 $noOfDuplicates = $adb->num_rows($duplicatesResult);
                 if ($noOfDuplicates > 0) {
                     if ($mergeType == Import_Utils::$AUTO_MERGE_IGNORE) {
                         $entityInfo['status'] = self::$IMPORT_RECORD_SKIPPED;
                     } elseif ($mergeType == Import_Utils::$AUTO_MERGE_OVERWRITE || $mergeType == Import_Utils::$AUTO_MERGE_MERGEFIELDS) {
                         for ($index = 0; $index < $noOfDuplicates - 1; ++$index) {
                             $duplicateRecordId = $adb->query_result($duplicatesResult, $index, $fieldColumnMapping['id']);
                             $entityId = vtws_getId($moduleObjectId, $duplicateRecordId);
                             vtws_delete($entityId, $this->user);
                         }
                         $baseRecordId = $adb->query_result($duplicatesResult, $noOfDuplicates - 1, $fieldColumnMapping['id']);
                         $baseEntityId = vtws_getId($moduleObjectId, $baseRecordId);
                         if ($mergeType == Import_Utils::$AUTO_MERGE_OVERWRITE) {
                             $fieldData = $this->transformForImport($fieldData, $moduleMeta);
                             $fieldData['id'] = $baseEntityId;
                             $entityInfo = vtws_update($fieldData, $this->user);
                             $entityInfo['status'] = self::$IMPORT_RECORD_UPDATED;
                             //Prepare data for event handler
                             $entityData = array();
                             $entityData['rowId'] = $rowId;
                             $entityData['tableName'] = $tableName;
                             $entityData['entityInfo'] = $entityInfo;
                             $entityData['fieldData'] = $fieldData;
                             $entityData['moduleName'] = $moduleName;
                             $entityData['user'] = $this->user;
                             cbEventHandler::do_action('corebos.entity.import.overwrite', $entityData);
                         }
                         if ($mergeType == Import_Utils::$AUTO_MERGE_MERGEFIELDS) {
                             $filteredFieldData = array();
                             $defaultFieldValues = $this->getDefaultFieldValues($moduleMeta);
                             foreach ($fieldData as $fieldName => $fieldValue) {
                                 if (!empty($fieldValue)) {
                                     $filteredFieldData[$fieldName] = $fieldValue;
                                 }
//.........这里部分代码省略.........
开发者ID:casati-dolibarr,项目名称:corebos,代码行数:101,代码来源:Import_Data_Controller.php

示例5: QueryGenerator

    $other_text['s_mail'] = $app_strings[LBL_SEND_MAIL_BUTTON];
}
if (isset($CActionDtls)) {
    $other_text['s_cmail'] = $app_strings[LBL_SEND_CUSTOM_MAIL_BUTTON];
}
if ($viewnamedesc['viewname'] == 'All') {
    $smarty->assign("ALL", 'All');
}
//Retreive the list from Database
//<<<<<<<<<customview>>>>>>>>>
global $current_user;
$queryGenerator = new QueryGenerator($currentModule, $current_user);
if ($viewid != "0") {
    $queryGenerator->initForCustomViewById($viewid);
} else {
    $queryGenerator->initForDefaultCustomView();
}
//<<<<<<<<customview>>>>>>>>>
if (!isset($where)) {
    $where = "";
}
$url_string = '';
// assigning http url string
if (isset($_REQUEST['query']) && $_REQUEST['query'] == 'true') {
    $queryGenerator->addUserSearchConditions($_REQUEST);
    $ustring = getSearchURL($_REQUEST);
    // we have a query
    $url_string .= "&query=true" . $ustring;
    $smarty->assign("SEARCH_URL", $url_string);
}
$list_query = $queryGenerator->getQuery();
开发者ID:hardikk,项目名称:HNH,代码行数:31,代码来源:ListView.php

示例6: createRecords

 public function createRecords()
 {
     $adb = PearDatabase::getInstance();
     $moduleName = $this->module;
     $focus = CRMEntity::getInstance($moduleName);
     $moduleHandler = vtws_getModuleHandlerFromName($moduleName, $this->user);
     $moduleMeta = $moduleHandler->getMeta();
     $moduleObjectId = $moduleMeta->getEntityId();
     $moduleFields = $moduleMeta->getModuleFields();
     $entityData = array();
     $tableName = Import_Utils_Helper::getDbTableName($this->user);
     $sql = 'SELECT * FROM ' . $tableName . ' WHERE status = ' . Import_Data_Action::$IMPORT_RECORD_NONE;
     if ($this->batchImport) {
         $configReader = new Import_Config_Model();
         $importBatchLimit = $configReader->get('importBatchLimit');
         $sql .= ' LIMIT ' . $importBatchLimit;
     }
     $result = $adb->query($sql);
     $numberOfRecords = $adb->num_rows($result);
     if ($numberOfRecords <= 0) {
         return;
     }
     $fieldMapping = $this->fieldMapping;
     $fieldColumnMapping = $moduleMeta->getFieldColumnMapping();
     for ($i = 0; $i < $numberOfRecords; ++$i) {
         $row = $adb->raw_query_result_rowdata($result, $i);
         $rowId = $row['id'];
         $entityInfo = null;
         $fieldData = array();
         foreach ($fieldMapping as $fieldName => $index) {
             $fieldData[$fieldName] = $row[$fieldName];
         }
         $mergeType = $this->mergeType;
         $createRecord = false;
         if (method_exists($focus, 'importRecord')) {
             $entityInfo = $focus->importRecord($this, $fieldData);
         } else {
             if (!empty($mergeType) && $mergeType != Import_Utils_Helper::$AUTO_MERGE_NONE) {
                 $queryGenerator = new QueryGenerator($moduleName, $this->user);
                 $customView = new CustomView($moduleName);
                 $viewId = $customView->getViewIdByName('All', $moduleName);
                 if (!empty($viewId)) {
                     $queryGenerator->initForCustomViewById($viewId);
                 } else {
                     $queryGenerator->initForDefaultCustomView();
                 }
                 $fieldsList = array('id');
                 $queryGenerator->setFields($fieldsList);
                 $mergeFields = $this->mergeFields;
                 if ($queryGenerator->getWhereFields() && $mergeFields) {
                     $queryGenerator->addConditionGlue(QueryGenerator::$AND);
                 }
                 foreach ($mergeFields as $index => $mergeField) {
                     if ($index != 0) {
                         $queryGenerator->addConditionGlue(QueryGenerator::$AND);
                     }
                     $comparisonValue = $fieldData[$mergeField];
                     $fieldInstance = $moduleFields[$mergeField];
                     if ($fieldInstance->getFieldDataType() == 'owner') {
                         $userId = getUserId_Ol($comparisonValue);
                         $comparisonValue = getUserFullName($userId);
                     }
                     if ($fieldInstance->getFieldDataType() == 'reference') {
                         if (strpos($comparisonValue, '::::') > 0) {
                             $referenceFileValueComponents = explode('::::', $comparisonValue);
                         } else {
                             $referenceFileValueComponents = explode(':::', $comparisonValue);
                         }
                         if (count($referenceFileValueComponents) > 1) {
                             $comparisonValue = trim($referenceFileValueComponents[1]);
                         }
                     }
                     $queryGenerator->addCondition($mergeField, $comparisonValue, 'e', '', '', '', true);
                 }
                 $query = $queryGenerator->getQuery();
                 $duplicatesResult = $adb->query($query);
                 $noOfDuplicates = $adb->num_rows($duplicatesResult);
                 if ($noOfDuplicates > 0) {
                     if ($mergeType == Import_Utils_Helper::$AUTO_MERGE_IGNORE) {
                         $entityInfo['status'] = self::$IMPORT_RECORD_SKIPPED;
                     } elseif ($mergeType == Import_Utils_Helper::$AUTO_MERGE_OVERWRITE || $mergeType == Import_Utils_Helper::$AUTO_MERGE_MERGEFIELDS) {
                         for ($index = 0; $index < $noOfDuplicates - 1; ++$index) {
                             $duplicateRecordId = $adb->query_result($duplicatesResult, $index, $fieldColumnMapping['id']);
                             $entityId = vtws_getId($moduleObjectId, $duplicateRecordId);
                             vtws_delete($entityId, $this->user);
                         }
                         $baseRecordId = $adb->query_result($duplicatesResult, $noOfDuplicates - 1, $fieldColumnMapping['id']);
                         $baseEntityId = vtws_getId($moduleObjectId, $baseRecordId);
                         if ($mergeType == Import_Utils_Helper::$AUTO_MERGE_OVERWRITE) {
                             $fieldData = $this->transformForImport($fieldData, $moduleMeta);
                             $fieldData['id'] = $baseEntityId;
                             $entityInfo = vtws_update($fieldData, $this->user);
                             $entityInfo['status'] = self::$IMPORT_RECORD_UPDATED;
                         }
                         if ($mergeType == Import_Utils_Helper::$AUTO_MERGE_MERGEFIELDS) {
                             $filteredFieldData = array();
                             foreach ($fieldData as $fieldName => $fieldValue) {
                                 // empty will give false for value = 0
                                 if (!empty($fieldValue) || $fieldValue != "") {
                                     $filteredFieldData[$fieldName] = $fieldValue;
//.........这里部分代码省略.........
开发者ID:cannking,项目名称:vtigercrm-debug,代码行数:101,代码来源:Data.php

示例7: getInstance

 /**
  * Static Function to get the Instance of Vtiger ListView model for a given module and custom view
  * @param <String> $moduleName - Module Name
  * @param <Number> $viewId - Custom View Id
  * @return Vtiger_ListView_Model instance
  */
 public static function getInstance($moduleName, $viewId = '0')
 {
     $db = PearDatabase::getInstance();
     $currentUser = vglobal('current_user');
     $modelClassName = Vtiger_Loader::getComponentClassName('Model', 'ListView', $moduleName);
     $instance = new $modelClassName();
     $moduleModel = Vtiger_Module_Model::getInstance($moduleName);
     $queryGenerator = new QueryGenerator($moduleModel->get('name'), $currentUser);
     $customView = new CustomView();
     if (!empty($viewId) && $viewId != "0") {
         $queryGenerator->initForCustomViewById($viewId);
         //Used to set the viewid into the session which will be used to load the same filter when you refresh the page
         $viewId = $customView->getViewId($moduleName);
     } else {
         $viewId = $customView->getViewId($moduleName);
         if (!empty($viewId) && $viewId != 0) {
             $queryGenerator->initForDefaultCustomView();
         } else {
             $entityInstance = CRMEntity::getInstance($moduleName);
             $listFields = $entityInstance->list_fields_name;
             $listFields[] = 'id';
             $queryGenerator->setFields($listFields);
         }
     }
     $controller = new ListViewController($db, $currentUser, $queryGenerator);
     return $instance->set('module', $moduleModel)->set('query_generator', $queryGenerator)->set('listview_controller', $controller);
 }
开发者ID:rcrrich,项目名称:UpdatePackages,代码行数:33,代码来源:ListView.php

示例8: execute

 function execute($fieldnames, $pagingModel = false)
 {
     if ($this->moduleName == 'Project') {
         // Custom View
         include_once 'modules/CustomView/CustomView.php';
         include_once 'include/QueryGenerator/QueryGenerator.php';
         include_once 'modules/Mobile/api/ws/Controller.php';
         include_once 'include/DatabaseUtil.php';
         $customView = new CustomView($this->moduleName);
         $viewid = $customView->getViewId($this->moduleName);
         $customview_html = $customView->getCustomViewCombo($viewid);
         $viewinfo = $customView->getCustomViewByCvid($viewid);
         global $current_user;
         // Required for vtws_update API
         $userid = $_SESSION['_authenticated_user_id'];
         $current_user = CRMEntity::getInstance('Users');
         $current_user = $current_user->retrieveCurrentUserInfoFromFile($userid);
         $queryGenerator = new QueryGenerator($this->moduleName, $current_user);
         if ($viewid != "0") {
             $queryGenerator->initForCustomViewById($viewid);
         } else {
             $queryGenerator->initForDefaultCustomView();
         }
         $selectClause = sprintf("SELECT %s", implode(',', $fieldnames) . ",vtiger_project.projectid");
         $fromClause = $queryGenerator->getFromClause();
         $whereClause = $queryGenerator->getWhereClause();
         $orderClause = "";
         $groupClause = "";
         $limitClause = $pagingModel ? " LIMIT {$pagingModel->currentCount()},{$pagingModel->limit()}" : "";
         if (!empty($this->criterias)) {
             $_sortCriteria = $this->criterias['_sort'];
             if (!empty($_sortCriteria)) {
                 $orderClause = $_sortCriteria;
             }
         }
         $query = sprintf("%s %s %s %s %s %s;", $selectClause, $fromClause, $whereClause, $orderClause, $groupClause, $limitClause);
         global $adb;
         $result = $adb->pquery($query, array());
         $noofrows = $adb->num_rows($result);
         $lstresult = array();
         for ($i = 0; $i < $noofrows; $i++) {
             $lstresult[$i]['firstname'] = $adb->query_result($result, $i, 'projectname');
             $lstresult[$i]['id'] = "31x" . $adb->query_result($result, $i, 'projectid');
         }
         return $lstresult;
     } else {
         $selectClause = sprintf("SELECT %s", implode(',', $fieldnames));
         $fromClause = sprintf("FROM %s", $this->moduleName);
         $whereClause = "";
         $orderClause = "";
         $groupClause = "";
         $limitClause = $pagingModel ? " LIMIT {$pagingModel->currentCount()},{$pagingModel->limit()}" : "";
         if (!empty($this->criterias)) {
             $_sortCriteria = $this->criterias['_sort'];
             if (!empty($_sortCriteria)) {
                 $orderClause = $_sortCriteria;
             }
         }
         $query = sprintf("%s %s %s %s %s %s;", $selectClause, $fromClause, $whereClause, $orderClause, $groupClause, $limitClause);
         return vtws_query($query, $this->getUser());
     }
 }
开发者ID:kduqi,项目名称:corebos,代码行数:62,代码来源:SearchFilter.php


注:本文中的QueryGenerator::initForDefaultCustomView方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。