本文整理汇总了PHP中SearchForm::generateSearchWhere方法的典型用法代码示例。如果您正苦于以下问题:PHP SearchForm::generateSearchWhere方法的具体用法?PHP SearchForm::generateSearchWhere怎么用?PHP SearchForm::generateSearchWhere使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SearchForm
的用法示例。
在下文中一共展示了SearchForm::generateSearchWhere方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGeneratedWhereClauseDoesNotHaveValueOfFieldNotSetInSearchForm
/**
* @ticket 44858
*/
public function testGeneratedWhereClauseDoesNotHaveValueOfFieldNotSetInSearchForm()
{
//test to check that if value of a dropdown field is already set in REQUEST object (from any form such as mass update form instead of search form)
//i.e. search is made on empty string, but REQUEST object gets value of that dropdown field from some other form on the same page
//then on clicking serach button, value of that field should not be used as filter in where clause
$this->markTestIncomplete('This test should actually check that the $whereArray is indeed populated');
return;
//array to simulate REQUEST object
$requestArray['module'] = 'Accounts';
$requestArray['action'] = 'index';
$requestArray['searchFormTab'] = 'basic_search';
$requestArray['account_type'] = 'Analyst';
//value of a dropdown field set in REQUEST object
$requestArray['query'] = 'true';
$requestArray['button'] = 'Search';
$requestArray['globalLinksOpen'] = 'true';
$requestArray['current_user_only_basic'] = 0;
$account = SugarTestAccountUtilities::createAccount();
$searchForm = new SearchForm($account, 'Accounts');
require 'modules/Accounts/vardefs.php';
require 'modules/Accounts/metadata/SearchFields.php';
require 'modules/Accounts/metadata/searchdefs.php';
$searchForm->searchFields = $searchFields[$searchForm->module];
$searchForm->searchdefs = $searchdefs[$searchForm->module];
$searchForm->populateFromArray($requestArray, 'basic_search', false);
$whereArray = $searchForm->generateSearchWhere(true, $account->module_dir);
//echo var_export($whereArray, true);
$this->assertEquals(0, count($whereArray));
}
示例2: generateSearchWhere
public function generateSearchWhere($add_custom_fields = false, $module = '')
{
$onlyActive = false;
if (isset($this->searchFields['open_only_active_users']['value'])) {
if ($this->searchFields['open_only_active_users']['value'] == 1) {
$onlyActive = true;
}
unset($this->searchFields['open_only_active_users']['value']);
}
$where_clauses = parent::generateSearchWhere($add_custom_fields, $module);
if ($onlyActive) {
$where_clauses[] = "users.employee_status = 'Active'";
}
// Add in code to remove portal/group/hidden users
$where_clauses[] = "users.portal_only = 0";
$where_clauses[] = "(users.is_group = 0 or users.is_group is null)";
$where_clauses[] = "users.show_on_employees = 1";
return $where_clauses;
}
示例3: SoapError
/**
* Given a list of modules to search and a search string, return the id, module_name, along with the fields
* We will support Accounts, Bug Tracker, Cases, Contacts, Leads, Opportunities, Project, ProjectTask, Quotes
*
* @param string $session - Session ID returned by a previous call to login.
* @param string $search_string - string to search
* @param string[] $modules - array of modules to query
* @param int $offset - a specified offset in the query
* @param int $max_results - max number of records to return
* @return Array 'entry_list' -- Array('Accounts' => array(array('name' => 'first_name', 'value' => 'John', 'name' => 'last_name', 'value' => 'Do')))
* @exception 'SoapFault' -- The SOAP error, if any
*/
function search_by_module($session, $search_string, $modules, $offset, $max_results)
{
$GLOBALS['log']->info('Begin: SugarWebServiceImpl->search_by_module');
global $beanList, $beanFiles;
global $sugar_config, $current_language;
$error = new SoapError();
$output_list = array();
if (!self::$helperObject->checkSessionAndModuleAccess($session, 'invalid_session', '', '', '', $error)) {
$error->set_error('invalid_login');
$GLOBALS['log']->info('End: SugarWebServiceImpl->search_by_module');
return;
}
global $current_user;
if ($max_results > 0) {
$sugar_config['list_max_entries_per_page'] = $max_results;
}
require_once 'modules/Home/UnifiedSearchAdvanced.php';
require_once 'include/utils.php';
$usa = new UnifiedSearchAdvanced();
if (!file_exists($cachedfile = sugar_cached('modules/unified_search_modules.php'))) {
$usa->buildCache();
}
include $cachedfile;
$modules_to_search = array();
$unified_search_modules['Users'] = array('fields' => array());
$unified_search_modules['ProjectTask'] = array('fields' => array());
foreach ($unified_search_modules as $module => $data) {
if (in_array($module, $modules)) {
$modules_to_search[$module] = $beanList[$module];
}
// if
}
// foreach
$GLOBALS['log']->info('SugarWebServiceImpl->search_by_module - search string = ' . $search_string);
if (!empty($search_string) && isset($search_string)) {
$search_string = trim($GLOBALS['db']->quote(securexss(from_html(clean_string($search_string, 'UNIFIED_SEARCH')))));
foreach ($modules_to_search as $name => $beanName) {
$where_clauses_array = array();
$unifiedSearchFields = array();
foreach ($unified_search_modules[$name]['fields'] as $field => $def) {
$unifiedSearchFields[$name][$field] = $def;
$unifiedSearchFields[$name][$field]['value'] = $search_string;
}
$seed = BeanFactory::getBean($name);
require_once 'include/SearchForm/SearchForm2.php';
if ($beanName == "User" || $beanName == "ProjectTask") {
if (!self::$helperObject->check_modules_access($current_user, $seed->module_dir, 'read')) {
continue;
}
// if
if (!$seed->ACLAccess('ListView')) {
continue;
}
// if
}
if ($beanName != "User" && $beanName != "ProjectTask") {
$searchForm = new SearchForm($seed, $name);
$searchForm->setup(array($name => array()), $unifiedSearchFields, '', 'saved_views');
$where_clauses = $searchForm->generateSearchWhere();
require_once 'include/SearchForm/SearchForm2.php';
$searchForm = new SearchForm($seed, $name);
$searchForm->setup(array($name => array()), $unifiedSearchFields, '', 'saved_views');
$where_clauses = $searchForm->generateSearchWhere();
$emailQuery = false;
$where = '';
if (count($where_clauses) > 0) {
$where = '(' . implode(' ) OR ( ', $where_clauses) . ')';
}
$mod_strings = return_module_language($current_language, $seed->module_dir);
require_once SugarAutoLoader::loadWithMetafiles($seed->module_dir, 'listviewdefs');
$filterFields = array();
foreach ($listViewDefs[$seed->module_dir] as $colName => $param) {
if (!empty($param['default']) && $param['default'] == true) {
$filterFields[] = strtolower($colName);
}
// if
}
// foreach
if (!in_array('id', $filterFields)) {
$filterFields[] = 'id';
}
// if
$ret_array = $seed->create_new_list_query('', $where, $filterFields, array(), 0, '', true, $seed, true);
if (empty($params) or !is_array($params)) {
$params = array();
}
if (!isset($params['custom_select'])) {
$params['custom_select'] = '';
//.........这里部分代码省略.........
示例4: array
/**
* Given a list of modules to search and a search string, return the id, module_name, along with the fields
* We will support Accounts, Bug Tracker, Cases, Contacts, Leads, Opportunities, Project, ProjectTask, Quotes
*
* @param string $session - Session ID returned by a previous call to login.
* @param string $search_string - string to search
* @param string[] $modules - array of modules to query
* @param int $offset - a specified offset in the query
* @param int $max_results - max number of records to return
* @param string $assigned_user_id - a user id to filter all records by, leave empty to exclude the filter
* @param string[] $select_fields - An array of fields to return. If empty the default return fields will be from the active list view defs.
* @param bool $unified_search_only - A boolean indicating if we should only search against those modules participating in the unified search.
* @param bool $favorites - A boolean indicating if we should only search against records marked as favorites.
* @return Array return_search_result - Array('Accounts' => array(array('name' => 'first_name', 'value' => 'John', 'name' => 'last_name', 'value' => 'Do')))
* @exception 'SoapFault' -- The SOAP error, if any
*/
function search_by_module($session, $search_string, $modules, $offset, $max_results, $assigned_user_id = '', $select_fields = array(), $unified_search_only = TRUE, $favorites = FALSE)
{
$GLOBALS['log']->info('Begin: SugarWebServiceImpl->search_by_module');
global $beanList, $beanFiles;
global $sugar_config, $current_language;
$error = new SoapError();
$output_list = array();
if (!self::$helperObject->checkSessionAndModuleAccess($session, 'invalid_session', '', '', '', $error)) {
$error->set_error('invalid_login');
$GLOBALS['log']->error('End: SugarWebServiceImpl->search_by_module - FAILED on checkSessionAndModuleAccess');
return;
}
global $current_user;
if ($max_results > 0) {
$sugar_config['list_max_entries_per_page'] = $max_results;
}
require_once 'modules/Home/UnifiedSearchAdvanced.php';
require_once 'include/utils.php';
$usa = new UnifiedSearchAdvanced();
if (!file_exists($cachefile = sugar_cached('modules/unified_search_modules.php'))) {
$usa->buildCache();
}
include $cachefile;
$modules_to_search = array();
$unified_search_modules['Users'] = array('fields' => array());
$unified_search_modules['ProjectTask'] = array('fields' => array());
//If we are ignoring the unified search flag within the vardef we need to re-create the search fields. This allows us to search
//against a specific module even though it is not enabled for the unified search within the application.
if (!$unified_search_only) {
foreach ($modules as $singleModule) {
if (!isset($unified_search_modules[$singleModule])) {
$newSearchFields = array('fields' => self::$helperObject->generateUnifiedSearchFields($singleModule));
$unified_search_modules[$singleModule] = $newSearchFields;
}
}
}
foreach ($unified_search_modules as $module => $data) {
if (in_array($module, $modules)) {
$modules_to_search[$module] = $beanList[$module];
}
// if
}
// foreach
$GLOBALS['log']->info('SugarWebServiceImpl->search_by_module - search string = ' . $search_string);
if (!empty($search_string) && isset($search_string)) {
$search_string = trim($GLOBALS['db']->quote(securexss(from_html(clean_string($search_string, 'UNIFIED_SEARCH')))));
foreach ($modules_to_search as $name => $beanName) {
$where_clauses_array = array();
$unifiedSearchFields = array();
foreach ($unified_search_modules[$name]['fields'] as $field => $def) {
$unifiedSearchFields[$name][$field] = $def;
$unifiedSearchFields[$name][$field]['value'] = $search_string;
}
require_once $beanFiles[$beanName];
$seed = new $beanName();
require_once 'include/SearchForm/SearchForm2.php';
if ($beanName == "User" || $beanName == "ProjectTask") {
if (!self::$helperObject->check_modules_access($current_user, $seed->module_dir, 'read')) {
continue;
}
// if
if (!$seed->ACLAccess('ListView')) {
continue;
}
// if
}
if ($beanName != "User" && $beanName != "ProjectTask") {
$searchForm = new SearchForm($seed, $name);
$searchForm->setup(array($name => array()), $unifiedSearchFields, '', 'saved_views');
$where_clauses = $searchForm->generateSearchWhere();
require_once 'include/SearchForm/SearchForm2.php';
$searchForm = new SearchForm($seed, $name);
$searchForm->setup(array($name => array()), $unifiedSearchFields, '', 'saved_views');
$where_clauses = $searchForm->generateSearchWhere();
$emailQuery = false;
$where = '';
if (count($where_clauses) > 0) {
$where = '(' . implode(' ) OR ( ', $where_clauses) . ')';
}
$mod_strings = return_module_language($current_language, $seed->module_dir);
if (count($select_fields) > 0) {
$filterFields = $select_fields;
} else {
if (file_exists('custom/modules/' . $seed->module_dir . '/metadata/listviewdefs.php')) {
//.........这里部分代码省略.........
示例5: generateSearchWhere
function generateSearchWhere($module, $query)
{
//this function is similar with function prepareSearchForm() in view.list.php
$seed = loadBean($module);
$this->use_old_search = true;
if (file_exists('modules/' . $module . '/SearchForm.html')) {
if (file_exists('modules/' . $module . '/metadata/SearchFields.php')) {
require_once 'include/SearchForm/SearchForm.php';
$searchForm = new SearchForm($module, $seed);
} elseif (!empty($_SESSION['export_where'])) {
//bug 26026, sometimes some module doesn't have a metadata/SearchFields.php, the searchfrom is generated in the ListView.php.
//So currently massupdate will not gernerate the where sql. It will use the sql stored in the SESSION. But this will cause bug 24722, and it cannot be avoided now.
$where = $_SESSION['export_where'];
$whereArr = explode(" ", trim($where));
if ($whereArr[0] == trim('where')) {
$whereClean = array_shift($whereArr);
}
$this->where_clauses = implode(" ", $whereArr);
return;
} else {
$this->where_clauses = '';
return;
}
} else {
$this->use_old_search = false;
require_once 'include/SearchForm/SearchForm2.php';
if (file_exists('custom/modules/' . $module . '/metadata/metafiles.php')) {
require 'custom/modules/' . $module . '/metadata/metafiles.php';
} elseif (file_exists('modules/' . $module . '/metadata/metafiles.php')) {
require 'modules/' . $module . '/metadata/metafiles.php';
}
if (file_exists('custom/modules/' . $module . '/metadata/searchdefs.php')) {
require_once 'custom/modules/' . $module . '/metadata/searchdefs.php';
} elseif (!empty($metafiles[$module]['searchdefs'])) {
require_once $metafiles[$module]['searchdefs'];
} elseif (file_exists('modules/' . $module . '/metadata/searchdefs.php')) {
require_once 'modules/' . $module . '/metadata/searchdefs.php';
}
if (!empty($metafiles[$module]['searchfields'])) {
require_once $metafiles[$module]['searchfields'];
} elseif (file_exists('modules/' . $module . '/metadata/SearchFields.php')) {
require_once 'modules/' . $module . '/metadata/SearchFields.php';
}
if (empty($searchdefs) || empty($searchFields)) {
$this->where_clauses = '';
//for some modules, such as iframe, it has massupdate, but it doesn't have search function, the where sql should be empty.
return;
}
$searchForm = new SearchForm($seed, $module);
$searchForm->setup($searchdefs, $searchFields, 'include/SearchForm/tpls/SearchFormGeneric.tpl');
}
/* bug 31271: using false to not add all bean fields since some beans - like SavedReports
can have fields named 'module' etc. which may break the query */
$searchForm->populateFromArray(unserialize(base64_decode($query)), null, true);
// see bug 31271
$this->searchFields = $searchForm->searchFields;
$where_clauses = $searchForm->generateSearchWhere(true, $module);
if (count($where_clauses) > 0) {
$this->where_clauses = '(' . implode(' ) AND ( ', $where_clauses) . ')';
$GLOBALS['log']->info("MassUpdate Where Clause: {$this->where_clauses}");
} else {
$this->where_clauses = '';
}
}
示例6: generateSearchWhere
function generateSearchWhere($module, $query)
{
//this function is similar with function prepareSearchForm() in view.list.php
$seed = loadBean($module);
if (file_exists('modules/' . $module . '/SearchForm.html')) {
if (file_exists('modules/' . $module . '/metadata/SearchFields.php')) {
require_once 'include/SearchForm/SearchForm.php';
$searchForm = new SearchForm($module, $seed);
} elseif (!empty($_SESSION['export_where'])) {
//bug 26026, sometimes some module doesn't have a metadata/SearchFields.php, the searchfrom is generated in the ListView.php.
//So currently massupdate will not gernerate the where sql. It will use the sql stored in the SESSION. But this will cause bug 24722, and it cannot be avoided now.
$where = $_SESSION['export_where'];
$whereArr = explode(" ", trim($where));
if ($whereArr[0] == trim('where')) {
$whereClean = array_shift($whereArr);
}
$where = implode(" ", $whereArr);
//rrs bug: 31329 - previously this was just returning $where, but the problem is the caller of this function
//expects the results in an array, not just a string. So rather than fixing the caller, I felt it would be best for
//the function to return the results in a standard format.
$ret_array['where'] = $where;
$ret_array['searchFields'] = array();
return $ret_array;
} else {
return;
}
} else {
require_once 'include/SearchForm/SearchForm2.php';
if (file_exists('custom/modules/' . $module . '/metadata/metafiles.php')) {
require 'custom/modules/' . $module . '/metadata/metafiles.php';
} elseif (file_exists('modules/' . $module . '/metadata/metafiles.php')) {
require 'modules/' . $module . '/metadata/metafiles.php';
}
if (file_exists('custom/modules/' . $module . '/metadata/searchdefs.php')) {
require_once 'custom/modules/' . $module . '/metadata/searchdefs.php';
} elseif (!empty($metafiles[$module]['searchdefs'])) {
require_once $metafiles[$module]['searchdefs'];
} elseif (file_exists('modules/' . $module . '/metadata/searchdefs.php')) {
require_once 'modules/' . $module . '/metadata/searchdefs.php';
}
if (!empty($metafiles[$module]['searchfields'])) {
require_once $metafiles[$module]['searchfields'];
} elseif (file_exists('modules/' . $module . '/metadata/SearchFields.php')) {
require_once 'modules/' . $module . '/metadata/SearchFields.php';
}
if (empty($searchdefs) || empty($searchFields)) {
//for some modules, such as iframe, it has massupdate, but it doesn't have search function, the where sql should be empty.
return;
}
$searchForm = new SearchForm($seed, $module);
$searchForm->setup($searchdefs, $searchFields, 'include/SearchForm/tpls/SearchFormGeneric.tpl');
}
$searchForm->populateFromArray(unserialize(base64_decode($query)));
$where_clauses = $searchForm->generateSearchWhere(true, $module);
if (count($where_clauses) > 0) {
$where = '(' . implode(' ) AND ( ', $where_clauses) . ')';
}
$GLOBALS['log']->info("Export Where Clause: {$where}");
$ret_array['where'] = $where;
$ret_array['searchFields'] = $searchForm->searchFields;
return $ret_array;
}
示例7: testRetrieveByDaterange
public function testRetrieveByDaterange()
{
global $current_user;
$_REQUEST = $_POST = array("module" => "Meetings", "action" => "index", "searchFormTab" => "basic_search", "query" => "true", "name_basic" => "", "current_user_only_basic" => "0", "favorites_only_basic" => "0", "open_only_basic" => "0", "date_start_basic_range_choice" => "between", "range_date_start_basic" => "", "start_range_date_start_basic" => "13/07/2011", "end_range_date_start_basic" => "14/07/2011", "button" => "Search");
$srch = new SearchForm(new Meeting(), "Meetings");
$srch->setup($this->searchDefs, $this->searchFields, "");
$srch->populateFromRequest();
$w = $srch->generateSearchWhere();
// Due to daylight savings, I cannot hardcode intervals...
$GMTDatesStart = $this->timedate->getDayStartEndGMT("2011-07-13");
$GMTDatesEnd = $this->timedate->getDayStartEndGMT("2011-07-14");
// Current User is on GMT+2.
// Asking for meeting between 13 and 14 July 2011, I expect to search (GMT) from 12 July at 22:00 until 14 July at 22:00 (excluded)
$expectedWhere = "meetings.date_start >= '" . $GMTDatesStart['start'] . "' AND meetings.date_start <= '" . $GMTDatesEnd['end'] . "'";
$this->assertEquals($w[0], $expectedWhere);
}
示例8: unset
$storeQuery->populateRequest();
} else {
$storeQuery->saveFromGet($currentModule);
}
}
if (isset($_REQUEST['query'])) {
// we have a query
$searchForm->populateFromRequest();
if (!empty($_REQUEST['date_closed']) && !empty($_REQUEST['date_start'])) {
// this is to handle dashboard queries
$whereAdditional = "opportunities.date_closed >= '" . PearDatabase::quote($_REQUEST['date_start']) . "' and opportunities.date_closed <= '" . PearDatabase::quote($_REQUEST['date_closed']) . "'";
if (isset($searchForm->searchFields['date_closed'])) {
unset($searchForm->searchFields['date_closed']);
}
}
$where_clauses = $searchForm->generateSearchWhere($_REQUEST, true, "Opportunities");
// First change the query string value for sales_stage
$position = array_search("opportunities.sales_stage = 'Other'", $where_clauses);
if ($position !== false) {
$where_clauses[$position] = "opportunities.sales_stage not in ('Closed Won', 'Closed Lost')";
// Same as: ("SELECT DISTINCT sales_stage from opportunities where sales_stage not in ('Closed Won', 'Closed Lost')")
}
if (isset($whereAdditional)) {
array_push($where_clauses, $whereAdditional);
}
$where = "";
if (count($where_clauses) > 0) {
$where = implode(' and ', $where_clauses);
}
$GLOBALS['log']->info("Here is the where clause for the list view: {$where}");
}
示例9: StoreQuery
}
if (!isset($where)) {
$where = "";
}
require_once 'modules/MySettings/StoreQuery.php';
$storeQuery = new StoreQuery();
if (!isset($_REQUEST['query'])) {
$storeQuery->loadQuery($currentModule);
$storeQuery->populateRequest();
} else {
$storeQuery->saveFromGet($currentModule);
}
if (isset($_REQUEST['query'])) {
// we have a query
$searchForm->populateFromRequest();
$where_clauses = $searchForm->generateSearchWhere($_REQUEST, true, "Contacts");
$where = "";
if (count($where_clauses) > 0) {
$where = implode(' and ', $where_clauses);
}
$GLOBALS['log']->info("Here is the where clause for the list view: {$where}");
}
if (!isset($_REQUEST['search_form']) || $_REQUEST['search_form'] != 'false') {
$searchForm->setup();
if (isset($_REQUEST['searchFormTab']) && $_REQUEST['searchFormTab'] == 'advanced_search') {
$searchForm->displayAdvanced();
} elseif (isset($_REQUEST['searchFormTab']) && $_REQUEST['searchFormTab'] == 'saved_views') {
$searchForm->displaySavedViews($listViewDefs, $lv);
} else {
$searchForm->displayBasic();
}
示例10: _performSearch
/**
* Performs the search
*
* @param $query string what we are searching for
* @param $modules array modules we are searching in
* @param $offset int search result offset
* @return array
*/
protected function _performSearch($query, $modules, $offset = -1)
{
$primary_module = '';
$results = array();
require_once 'include/SearchForm/SearchForm2.php';
$where = '';
$searchEmail = preg_match("/^([^\\%]|\\%)*@([^\\%]|\\%)*\$/", $query);
foreach ($modules as $moduleName) {
if (empty($primary_module)) {
$primary_module = $moduleName;
}
$searchFields = SugarSpot::getSearchFields($moduleName);
$class = $GLOBALS['beanList'][$moduleName];
$return_fields = array();
$seed = new $class();
if (empty($searchFields[$moduleName])) {
continue;
}
if ($class == 'aCase') {
$class = 'Case';
}
foreach ($searchFields[$moduleName] as $k => $v) {
$keep = false;
$searchFields[$moduleName][$k]['value'] = $query;
if (!empty($GLOBALS['dictionary'][$class]['unified_search'])) {
if (empty($GLOBALS['dictionary'][$class]['fields'][$k]['unified_search'])) {
if (isset($searchFields[$moduleName][$k]['db_field'])) {
foreach ($searchFields[$moduleName][$k]['db_field'] as $field) {
if (!empty($GLOBALS['dictionary'][$class]['fields'][$field]['unified_search'])) {
$return_fields[] = $field;
$keep = true;
}
}
}
if (!$keep) {
if (strpos($k, 'email') === false || !$searchEmail) {
unset($searchFields[$moduleName][$k]);
}
}
} else {
$return_fields[] = $k;
}
} else {
if (empty($GLOBALS['dictionary'][$class]['fields'][$k])) {
unset($searchFields[$moduleName][$k]);
} else {
switch ($GLOBALS['dictionary'][$class]['fields'][$k]['type']) {
case 'id':
case 'date':
case 'datetime':
case 'bool':
unset($searchFields[$moduleName][$k]);
default:
$return_fields[] = $k;
}
}
}
}
$searchForm = new SearchForm($seed, $moduleName);
$searchForm->setup(array($moduleName => array()), $searchFields, '', 'saved_views');
$where_clauses = $searchForm->generateSearchWhere();
$where = "";
if (count($where_clauses) > 0) {
$where = '((' . implode(' ) OR ( ', $where_clauses) . '))';
}
$lvd = new ListViewData();
$lvd->additionalDetails = false;
$max = !empty($sugar_config['max_spotresults_initial']) ? $sugar_config['max_spotresults_initial'] : 5;
if ($offset !== -1) {
$max = !empty($sugar_config['max_spotresults_more']) ? $sugar_config['max_spotresults_more'] : 20;
}
$params = array();
if ($moduleName == 'Reports') {
$params['overrideOrder'] = true;
$params['orderBy'] = 'name';
}
$results[$moduleName] = $lvd->getListViewData($seed, $where, $offset, $max, $return_fields, $params, 'id');
}
return $results;
}
示例11: search
function search()
{
if (!file_exists($GLOBALS['sugar_config']['cache_dir'] . 'modules/unified_search_modules.php')) {
$this->buildCache();
}
include $GLOBALS['sugar_config']['cache_dir'] . 'modules/unified_search_modules.php';
require_once 'include/ListView/ListViewSmarty.php';
global $modListHeader, $beanList, $beanFiles, $current_language, $app_strings, $current_user, $mod_strings;
$home_mod_strings = return_module_language($current_language, 'Home');
$overlib = true;
$_REQUEST['query_string'] = $GLOBALS['db']->quote(securexss(from_html(clean_string($_REQUEST['query_string'], 'UNIFIED_SEARCH'))));
if (!empty($_REQUEST['advanced']) && $_REQUEST['advanced'] != 'false') {
$modules_to_search = array();
foreach ($_REQUEST as $param => $value) {
if (preg_match('/^search_mod_(.*)$/', $param, $match)) {
$modules_to_search[$match[1]] = $beanList[$match[1]];
}
}
$current_user->setPreference('globalSearch', $modules_to_search, 0, 'search');
// save selections to user preference
} else {
$users_modules = $current_user->getPreference('globalSearch', 'search');
if (isset($users_modules)) {
// use user's previous selections
$modules_to_search = $users_modules;
} else {
// select all the modules (ie first time user has used global search)
foreach ($unified_search_modules as $module => $data) {
$modules_to_search[$module] = $beanList[$module];
}
$current_user->setPreference('globalSearch', $modules_to_search, 'search');
}
}
echo $this->getDropDownDiv('modules/Home/UnifiedSearchAdvancedForm.tpl');
$module_results = array();
$module_counts = array();
$has_results = false;
if (!empty($_REQUEST['query_string'])) {
// MFH BUG 15404: Added support to trim off whitespace at the beginning and end of a search string
$_REQUEST['query_string'] = trim($_REQUEST['query_string']);
foreach ($modules_to_search as $moduleName => $beanName) {
if (array_key_exists($moduleName, $modListHeader)) {
$unifiedSearchFields = array();
foreach ($unified_search_modules[$moduleName]['fields'] as $field => $def) {
$unifiedSearchFields[$moduleName][$field] = $def;
$unifiedSearchFields[$moduleName][$field]['value'] = $_REQUEST['query_string'];
}
/*
* Use searchForm2->generateSearchWhere() to create the search query, as it can generate SQL for the full set of comparisons required
* generateSearchWhere() expects to find the search conditions for a field in the 'value' parameter of the searchFields entry for that field
*/
require_once $beanFiles[$beanName];
$seed = new $beanName();
require_once 'include/SearchForm/SearchForm2.php';
$searchForm = new SearchForm($seed, $moduleName);
$searchForm->setup(array($moduleName => array()), $unifiedSearchFields, '', 'saved_views');
$where_clauses = $searchForm->generateSearchWhere();
if (count($where_clauses) > 0) {
$where = '(' . implode(' ) OR ( ', $where_clauses) . ')';
}
$lv = new ListViewSmarty();
$lv->lvd->additionalDetails = false;
$mod_strings = return_module_language($current_language, $seed->module_dir);
if (file_exists('custom/modules/' . $seed->module_dir . '/metadata/listviewdefs.php')) {
require_once 'custom/modules/' . $seed->module_dir . '/metadata/listviewdefs.php';
} else {
require_once 'modules/' . $seed->module_dir . '/metadata/listviewdefs.php';
}
$displayColumns = array();
foreach ($listViewDefs[$seed->module_dir] as $colName => $param) {
if (!empty($param['default']) && $param['default'] == true) {
$param['url_sort'] = true;
//bug 27933
$displayColumns[$colName] = $param;
}
}
if (count($displayColumns) > 0) {
$lv->displayColumns = $displayColumns;
} else {
$lv->displayColumns = $listViewDefs[$seed->module_dir];
}
$lv->export = false;
$lv->mergeduplicates = false;
$lv->multiSelect = false;
$lv->delete = false;
$lv->select = false;
if ($overlib) {
$lv->overlib = true;
$overlib = false;
} else {
$lv->overlib = false;
}
$lv->setup($seed, 'include/ListView/ListViewGeneric.tpl', $where, 0, 10);
$module_results[$moduleName] = '<br /><br />' . get_form_header($GLOBALS['app_list_strings']['moduleList'][$seed->module_dir] . ' (' . $lv->data['pageData']['offsets']['total'] . ')', '', false);
$module_counts[$moduleName] = $lv->data['pageData']['offsets']['total'];
if ($lv->data['pageData']['offsets']['total'] == 0) {
$module_results[$moduleName] .= '<h2>' . $home_mod_strings['LBL_NO_RESULTS_IN_MODULE'] . '</h2>';
} else {
$has_results = true;
$module_results[$moduleName] .= $lv->display(false, false);
//.........这里部分代码省略.........
示例12: _performSearch
//.........这里部分代码省略.........
}
}
if (!isset($return_fields['name'])) {
// if we couldn't find any name fields, try search fields that have name in it
foreach ($searchFields[$moduleName] as $k => $v) {
if (strpos($k, 'name') != -1 && isset($seed->field_defs[$k]) && !isset($seed->field_defs[$k]['source'])) {
$return_fields[$k] = $seed->field_defs[$k];
break;
}
}
}
if (!isset($return_fields['name'])) {
// last resort - any fields that have 'name' in their name
foreach ($seed->field_defs as $k => $v) {
if (strpos($k, 'name') != -1 && isset($seed->field_defs[$k]) && !isset($seed->field_defs[$k]['source'])) {
$return_fields[$k] = $seed->field_defs[$k];
break;
}
}
}
if (!isset($return_fields['name'])) {
// FAIL: couldn't find id & name for the module
$GLOBALS['log']->error("Unable to find name for module {$moduleName}");
continue;
}
if (isset($return_fields['name']['fields'])) {
// some names are composite
foreach ($return_fields['name']['fields'] as $field) {
$return_fields[$field] = $seed->field_defs[$field];
}
}
$searchForm = new SearchForm($seed, $moduleName);
$searchForm->setup(array($moduleName => array()), $searchFields, '', 'saved_views');
$where_clauses = $searchForm->generateSearchWhere();
if (empty($where_clauses)) {
continue;
}
if (count($where_clauses) > 1) {
$query_parts = array();
$ret_array_start = $seed->create_new_list_query('', '', $return_fields, array(), 0, '', true, $seed, true);
$search_keys = array_keys($searchFields[$moduleName]);
foreach ($where_clauses as $n => $clause) {
$allfields = $return_fields;
$skey = $search_keys[$n];
if (isset($seed->field_defs[$skey])) {
// Joins for foreign fields aren't produced unless the field is in result, hence the merge
$allfields[$skey] = $seed->field_defs[$skey];
}
$ret_array = $seed->create_new_list_query('', $clause, $allfields, array(), 0, '', true, $seed, true);
$query_parts[] = $ret_array_start['select'] . $ret_array['from'] . $ret_array['where'] . $ret_array['order_by'];
}
$main_query = "(" . join(") UNION (", $query_parts) . ")";
} else {
foreach ($searchFields[$moduleName] as $k => $v) {
if (isset($seed->field_defs[$k])) {
$return_fields[$k] = $seed->field_defs[$k];
}
}
$ret_array = $seed->create_new_list_query('', $where_clauses[0], $return_fields, array(), 0, '', true, $seed, true);
$main_query = $ret_array['select'] . $ret_array['from'] . $ret_array['where'] . $ret_array['order_by'];
}
$totalCount = null;
if ($limit < -1) {
$result = $seed->db->query($main_query);
} else {
if ($limit == -1) {
示例13: search
function search()
{
if (!file_exists($GLOBALS['sugar_config']['cache_dir'] . 'modules/unified_search_modules.php')) {
$this->buildCache();
}
include $GLOBALS['sugar_config']['cache_dir'] . 'modules/unified_search_modules.php';
require_once 'include/ListView/ListViewSmarty.php';
global $modListHeader, $beanList, $beanFiles, $current_language, $app_strings, $current_user, $mod_strings;
$home_mod_strings = return_module_language($current_language, 'Home');
$overlib = true;
$this->query_string = $GLOBALS['db']->quote(securexss(from_html(clean_string($this->query_string, 'UNIFIED_SEARCH'))));
if (!empty($_REQUEST['advanced']) && $_REQUEST['advanced'] != 'false') {
$modules_to_search = array();
foreach ($_REQUEST as $param => $value) {
if (preg_match('/^search_mod_(.*)$/', $param, $match)) {
$modules_to_search[$match[1]] = $beanList[$match[1]];
}
}
$current_user->setPreference('globalSearch', $modules_to_search, 0, 'search');
// save selections to user preference
} else {
$users_modules = $current_user->getPreference('globalSearch', 'search');
if (isset($users_modules)) {
// use user's previous selections
foreach ($users_modules as $key => $value) {
if (isset($unified_search_modules[$key])) {
$modules_to_search[$key] = $value;
}
}
} else {
// select all the modules (ie first time user has used global search)
foreach ($unified_search_modules as $module => $data) {
if (!empty($data['default'])) {
$modules_to_search[$module] = $beanList[$module];
}
}
}
$current_user->setPreference('globalSearch', $modules_to_search, 'search');
}
echo $this->getDropDownDiv('modules/Home/UnifiedSearchAdvancedForm.tpl');
$module_results = array();
$module_counts = array();
$has_results = false;
if (!empty($this->query_string)) {
foreach ($modules_to_search as $moduleName => $beanName) {
$unifiedSearchFields = array();
$innerJoins = array();
foreach ($unified_search_modules[$moduleName]['fields'] as $field => $def) {
//bug: 34125 we might want to try to use the LEFT JOIN operator instead of the INNER JOIN in the case we are
//joining against a field that has not been populated.
if (!empty($def['innerjoin'])) {
if (empty($def['db_field'])) {
continue;
}
$innerJoins[$field] = $def;
$def['innerjoin'] = str_replace('INNER', 'LEFT', $def['innerjoin']);
}
$unifiedSearchFields[$moduleName][$field] = $def;
$unifiedSearchFields[$moduleName][$field]['value'] = $this->query_string;
}
/*
* Use searchForm2->generateSearchWhere() to create the search query, as it can generate SQL for the full set of comparisons required
* generateSearchWhere() expects to find the search conditions for a field in the 'value' parameter of the searchFields entry for that field
*/
require_once $beanFiles[$beanName];
$seed = new $beanName();
require_once 'include/SearchForm/SearchForm2.php';
$searchForm = new SearchForm($seed, $moduleName);
$searchForm->setup(array($moduleName => array()), $unifiedSearchFields, '', 'saved_views');
$where_clauses = $searchForm->generateSearchWhere();
//add inner joins back into the where clause
$params = array('custom_select' => "");
foreach ($innerJoins as $field => $def) {
if (isset($def['db_field'])) {
foreach ($def['db_field'] as $dbfield) {
$where_clauses[] = $dbfield . " LIKE '" . $this->query_string . "%'";
}
$params['custom_select'] .= ", {$dbfield}";
$params['distinct'] = true;
//$filterFields[$dbfield] = $dbfield;
}
}
if (count($where_clauses) > 0) {
$where = '((' . implode(' ) OR ( ', $where_clauses) . '))';
}
$lv = new ListViewSmarty();
$lv->lvd->additionalDetails = false;
$mod_strings = return_module_language($current_language, $seed->module_dir);
if (file_exists('custom/modules/' . $seed->module_dir . '/metadata/listviewdefs.php')) {
require_once 'custom/modules/' . $seed->module_dir . '/metadata/listviewdefs.php';
} else {
require_once 'modules/' . $seed->module_dir . '/metadata/listviewdefs.php';
}
if (!isset($listViewDefs) || !isset($listViewDefs[$seed->module_dir])) {
continue;
}
$displayColumns = array();
foreach ($listViewDefs[$seed->module_dir] as $colName => $param) {
if (!empty($param['default']) && $param['default'] == true) {
$param['url_sort'] = true;
//.........这里部分代码省略.........
示例14: elseif
require_once 'custom/modules/' . $module . '/metadata/searchdefs.php';
} elseif (!empty($metafiles[$module]['searchdefs'])) {
require_once $metafiles[$module]['searchdefs'];
} elseif (file_exists('modules/' . $module . '/metadata/searchdefs.php')) {
require_once 'modules/' . $module . '/metadata/searchdefs.php';
}
if (!empty($metafiles[$module]['searchfields'])) {
require_once $metafiles[$module]['searchfields'];
} elseif (file_exists('modules/' . $module . '/metadata/SearchFields.php')) {
require_once 'modules/' . $module . '/metadata/SearchFields.php';
}
if (!empty($searchdefs) && !empty($searchFields)) {
$searchForm = new SearchForm($seed, $module);
$searchForm->setup($searchdefs, $searchFields, 'include/SearchForm/tpls/SearchFormGeneric.tpl');
$searchForm->populateFromArray($current_query_by_page_array, 'advanced');
$where_clauses_arr = $searchForm->generateSearchWhere(true, $module);
if (count($where_clauses_arr) > 0) {
$where_clauses = '(' . implode(' ) AND ( ', $where_clauses_arr) . ')';
}
}
$ret_array = create_export_query_relate_link_patch($module, $searchFields, $where_clauses);
$query = $seed->create_export_query($order_by, $ret_array['where'], $ret_array['join']);
$result = $GLOBALS['db']->query($query, true);
$uids = array();
while ($val = $GLOBALS['db']->fetchByAssoc($result, -1, false)) {
array_push($uids, $val['id']);
}
$_REQUEST['subpanel_id'] = $uids;
}
if ($bean_name == 'Team') {
$subpanel_id = $_REQUEST['subpanel_id'];
示例15: AND
}
// use the stored query if there is one
if (!isset($where)) {
$where = "(is_group=0) AND (portal_only=0)";
}
if (isset($_REQUEST['query'])) {
// we have a query
// first save columns
$current_user->setPreference('ListViewDisplayColumns', $displayColumns, 0, 'Employees');
if (!empty($_SERVER['HTTP_REFERER']) && preg_match('/action=EditView/', $_SERVER['HTTP_REFERER'])) {
// from EditView cancel
$searchForm->populateFromArray($storeQuery->query);
} else {
$searchForm->populateFromRequest();
}
$where_clauses = $searchForm->generateSearchWhere(true, "Employees");
// builds the where clause from search field inputs
if (count($where_clauses) > 0) {
$where .= ' AND (' . implode(' ) AND ( ', $where_clauses) . ')';
}
$GLOBALS['log']->info("Here is the where clause for the list view: {$where}");
}
// start display
// which tab of search form to display
if (!isset($_REQUEST['search_form']) || $_REQUEST['search_form'] != 'false') {
$searchForm->setup();
if (isset($_REQUEST['searchFormTab']) && $_REQUEST['searchFormTab'] == 'advanced_search') {
$searchForm->displayAdvanced();
} elseif (isset($_REQUEST['searchFormTab']) && $_REQUEST['searchFormTab'] == 'saved_views') {
$searchForm->displaySavedViews($listViewDefs, $lv);
} else {