本文整理汇总了PHP中CustomView::getViewIdByName方法的典型用法代码示例。如果您正苦于以下问题:PHP CustomView::getViewIdByName方法的具体用法?PHP CustomView::getViewIdByName怎么用?PHP CustomView::getViewIdByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CustomView
的用法示例。
在下文中一共展示了CustomView::getViewIdByName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
public static function render($userInputObject, $user)
{
global $list_max_entries_per_page;
$adb = PearDatabase::getInstance();
$viewer = new Import_UI_Viewer();
$ownerId = $userInputObject->get('foruser');
$owner = new Users();
$owner->id = $ownerId;
$owner->retrieve_entity_info($ownerId, 'Users');
if (!is_admin($user) && $user->id != $owner->id) {
$viewer->display('OperationNotPermitted.tpl', 'Vtiger');
exit;
}
$userDBTableName = Import_Utils::getDbTableName($owner);
$moduleName = $userInputObject->get('module');
$moduleMeta = self::getModuleMeta($moduleName, $user);
$result = $adb->query('SELECT recordid FROM ' . $userDBTableName . ' WHERE status is NOT NULL AND recordid IS NOT NULL');
$noOfRecords = $adb->num_rows($result);
$importedRecordIds = array();
for ($i = 0; $i < $noOfRecords; ++$i) {
$importedRecordIds[] = $adb->query_result($result, $i, 'recordid');
}
if (count($importedRecordIds) == 0) {
$importedRecordIds[] = 0;
}
$focus = CRMEntity::getInstance($moduleName);
$queryGenerator = new QueryGenerator($moduleName, $user);
$customView = new CustomView($moduleName);
$viewId = $customView->getViewIdByName('All', $moduleName);
$queryGenerator->initForCustomViewById($viewId);
$list_query = $queryGenerator->getQuery();
// Fetch only last imported records
$list_query .= ' AND ' . $focus->table_name . '.' . $focus->table_index . ' IN (' . implode(',', $importedRecordIds) . ')';
if (PerformancePrefs::getBoolean('LISTVIEW_COMPUTE_PAGE_COUNT', false) === true) {
$count_result = $adb->query(mkCountQuery($list_query));
$noofrows = $adb->query_result($count_result, 0, "count");
} else {
$noofrows = null;
}
$start = ListViewSession::getRequestCurrentPage($moduleName, $list_query, $viewId, false);
$navigation_array = VT_getSimpleNavigationValues($start, $list_max_entries_per_page, $noofrows);
$limit_start_rec = ($start - 1) * $list_max_entries_per_page;
$list_result = $adb->pquery($list_query . " LIMIT {$limit_start_rec}, {$list_max_entries_per_page}", array());
$recordListRangeMsg = getRecordRangeMessage($list_result, $limit_start_rec, $noofrows);
$viewer->assign('recordListRange', $recordListRangeMsg);
$controller = new ListViewController($adb, $user, $queryGenerator);
$listview_header = $controller->getListViewHeader($focus, $moduleName, $url_string, $sorder, $order_by, true);
$listview_entries = $controller->getListViewEntries($focus, $moduleName, $list_result, $navigation_array, true);
$viewer->assign('CURRENT_PAGE', $start);
$viewer->assign('LISTHEADER', $listview_header);
$viewer->assign('LISTENTITY', $listview_entries);
$viewer->assign('FOR_MODULE', $moduleName);
$viewer->assign('FOR_USER', $ownerId);
$isAjax = $userInputObject->get('ajax');
if (!empty($isAjax)) {
echo $viewer->fetch('ListViewEntries.tpl');
} else {
$viewer->display('ImportListView.tpl');
}
}
示例2: CustomView
if (isset($_REQUEST['selected_module']) && $_REQUEST['selected_module'] != '') {
$select_module = vtlib_purify($_REQUEST['selected_module']);
if (!in_array($select_module, $module_name)) {
show_error_msg();
}
} else {
if (count($module_name) > 0) {
$select_module = $module_name[0];
} else {
show_error_msg('no_permitted_modules');
}
}
$focus = CRMEntity::getInstance($select_module);
if (count($module_name) > 0) {
$cur_mod_view = new CustomView($select_module);
$viewid = $cur_mod_view->getViewIdByName('All', $select_module);
global $current_user;
$queryGenerator = new QueryGenerator($select_module, $current_user);
$queryGenerator->initForCustomViewById($viewid);
// Enabling Module Search
$url_string = '';
if ($_REQUEST['query'] == 'true') {
$queryGenerator->addUserSearchConditions($_REQUEST);
$ustring = getSearchURL($_REQUEST);
$url_string .= "&query=true{$ustring}";
$smarty->assign('SEARCH_URL', $url_string);
}
$list_query = $queryGenerator->getQuery();
$list_query = preg_replace("/vtiger_crmentity.deleted\\s*=\\s*0/i", 'vtiger_crmentity.deleted = 1', $list_query);
//Search criteria added to the list Query
if (isset($where) && $where != '') {
示例3: 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;
//.........这里部分代码省略.........
示例4: 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 = Users_Record_Model::getCurrentUserModel();
$modelClassName = Vtiger_Loader::getComponentClassName('Model', 'ListView', 'Import');
$instance = new $modelClassName();
$moduleModel = Vtiger_Module_Model::getInstance($moduleName);
$queryGenerator = new QueryGenerator($moduleModel->get('name'), $currentUser);
$customView = new CustomView();
$viewId = $customView->getViewIdByName('All', $moduleName);
$queryGenerator->initForCustomViewById($viewId);
$controller = new ListViewController($db, $currentUser, $queryGenerator);
return $instance->set('module', $moduleModel)->set('query_generator', $queryGenerator)->set('listview_controller', $controller);
}