本文整理汇总了PHP中SearchForm::setup方法的典型用法代码示例。如果您正苦于以下问题:PHP SearchForm::setup方法的具体用法?PHP SearchForm::setup怎么用?PHP SearchForm::setup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SearchForm
的用法示例。
在下文中一共展示了SearchForm::setup方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setup
/**
* @see SearchForm::setup()
*/
function setup()
{
parent::setup();
$this->xtpl->assign('LOADING_IMAGE', getStudioIcon('loading', 'loading', 16, 16));
$this->xtpl->assign('HELP_IMAGE', SugarThemeRegistry::current()->getImageURL('help-dashlet.gif'));
$this->xtpl->assign('CLOSE_IMAGE', SugarThemeRegistry::current()->getImageURL('close.gif'));
}
示例2: display
//.........这里部分代码省略.........
}
}
$lv->displayColumns = $displayColumns;
$this->seed = $seed;
$this->module = $module;
$searchForm = null;
$storeQuery = new StoreQuery();
if (!isset($_REQUEST['query'])) {
$storeQuery->loadQuery($this->module);
$storeQuery->populateRequest();
} else {
$storeQuery->saveFromRequest($this->module);
}
//search
$view = 'basic_search';
if (!empty($_REQUEST['search_form_view'])) {
$view = $_REQUEST['search_form_view'];
}
$headers = true;
if (!empty($_REQUEST['search_form_only']) && $_REQUEST['search_form_only']) {
$headers = false;
} elseif (!isset($_REQUEST['search_form']) || $_REQUEST['search_form'] != 'false') {
if (isset($_REQUEST['searchFormTab']) && $_REQUEST['searchFormTab'] == 'advanced_search') {
$view = 'advanced_search';
} else {
$view = 'basic_search';
}
}
$use_old_search = true;
if (file_exists('modules/' . $this->module . '/SearchForm.html')) {
require_once 'include/SearchForm/SearchForm.php';
$searchForm = new SearchForm($this->module, $this->seed);
} else {
$use_old_search = false;
require_once 'include/SearchForm/SearchForm2.php';
if (file_exists('custom/modules/' . $this->module . '/metadata/searchdefs.php')) {
require_once 'custom/modules/' . $this->module . '/metadata/searchdefs.php';
} elseif (!empty($metafiles[$this->module]['searchdefs'])) {
require_once $metafiles[$this->module]['searchdefs'];
} elseif (file_exists('modules/' . $this->module . '/metadata/searchdefs.php')) {
require_once 'modules/' . $this->module . '/metadata/searchdefs.php';
}
if (!empty($metafiles[$this->module]['searchfields'])) {
require_once $metafiles[$this->module]['searchfields'];
} elseif (file_exists('modules/' . $this->module . '/metadata/SearchFields.php')) {
require_once 'modules/' . $this->module . '/metadata/SearchFields.php';
}
$searchForm = new SearchForm($this->seed, $this->module, $this->action);
$searchForm->setup($searchdefs, $searchFields, 'include/SearchForm/tpls/SearchFormGeneric.tpl', $view, $listViewDefs);
$searchForm->lv = $lv;
}
if (isset($this->options['show_title']) && $this->options['show_title']) {
$moduleName = isset($this->seed->module_dir) ? $this->seed->module_dir : $GLOBALS['mod_strings']['LBL_MODULE_NAME'];
echo getClassicModuleTitle($moduleName, array($GLOBALS['mod_strings']['LBL_MODULE_TITLE']), FALSE);
}
$where = '';
if (isset($_REQUEST['query'])) {
// we have a query
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, $this->seed->module_dir);
if (count($where_clauses) > 0) {
$where = '(' . implode(' ) AND ( ', $where_clauses) . ')';
}
$GLOBALS['log']->info("List View Where Clause: {$where}");
}
if ($use_old_search) {
switch ($view) {
case 'basic_search':
$searchForm->setup();
$searchForm->displayBasic($headers);
break;
case 'advanced_search':
$searchForm->setup();
$searchForm->displayAdvanced($headers);
break;
case 'saved_views':
echo $searchForm->displaySavedViews($listViewDefs, $lv, $headers);
break;
}
} else {
echo $searchForm->display($headers);
}
if (!$headers) {
return;
}
if (empty($_REQUEST['search_form_only']) || $_REQUEST['search_form_only'] == false) {
if (!is_admin($current_user)) {
$lv->setup($seed, 'include/ListView/ListViewNoMassUpdate.tpl', $where, $params);
} else {
$lv->setup($seed, 'include/ListView/ListViewGeneric.tpl', $where, $params);
}
$savedSearchName = empty($_REQUEST['saved_search_select_name']) ? '' : ' - ' . $_REQUEST['saved_search_select_name'];
echo $lv->display();
}
}
示例3: 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 = '';
}
}
示例4: 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;
}
示例5: elseif
}
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)) {
$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;
}
示例6: 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);
}
示例7: _performSearch
//.........这里部分代码省略.........
$return_fields[$k] = $seed->field_defs[$k];
}
}
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 {
示例8: _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;
}
示例9: 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);
//.........这里部分代码省略.........
示例10: 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;
//.........这里部分代码省略.........
示例11: 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'] = '';
//.........这里部分代码省略.........
示例12: display
/**
* @see SugarView::display()
*/
public function display()
{
global $mod_strings;
global $app_list_strings;
global $app_strings;
global $current_user;
global $sugar_config;
global $currentModule;
$seed = new System();
$searchForm = new SearchForm('Administration', $seed);
$admin = Administration::getSettings();
$system_id = 1;
if (!empty($admin->settings['system_system_id'])) {
$system_id = $admin->settings['system_system_id'];
} else {
$admin->saveSetting('system', 'system_id', $system_id);
}
$num_lic_oc = $admin->settings['license_num_lic_oc'];
if (!isset($system_id) || empty($system_id)) {
$system_id = 1;
}
$error = '';
$where = 'system_id != ' . $system_id;
$row_count = $seed->getEnabledOfflineClients($seed->create_new_list_query("", $where));
if (isset($_REQUEST['view']) && ($_REQUEST['view'] == 'disable' || $_REQUEST['view'] == 'enable')) {
if (isset($_REQUEST['system_id'])) {
$system = new System();
$system->retrieve($_REQUEST['system_id']);
if ($system != null && $system->deleted != 1) {
if ($_REQUEST['view'] == 'disable') {
$system->status = 'Inactive';
$system->save();
} else {
if ($_REQUEST['view'] == 'enable') {
if ($row_count == $num_lic_oc) {
$error = $mod_strings['ERR_NUM_OFFLINE_CLIENTS_MET'];
} else {
$system->status = 'Active';
$system->save();
$row_count++;
}
}
}
if (!empty($_SESSION['EXCEEDING_OC_LICENSES']) && $_SESSION['EXCEEDING_OC_LICENSES'] == true) {
if ($row_count - 1 <= $num_lic_oc) {
unset($_SESSION['EXCEEDING_OC_LICENSES']);
header('Location: index.php?module=Administration&action=ListViewOfflineClient');
}
}
}
}
}
$user_name = '';
if (isset($_REQUEST['query'])) {
$user_name = isset($_REQUEST['user_name']) ? $_REQUEST['user_name'] : '';
require_once 'modules/Administration/metadata/SearchFields.php';
$searchForm->setup();
$user = BeanFactory::getBean('Users');
$searchForm->populateFromRequest('advanced_search');
$where_clauses = $searchForm->generateSearchWhere(true, "Administration");
$search_where = "";
if (count($where_clauses) > 0) {
$search_where = implode(' and ', $where_clauses);
}
}
if (isset($search_where) && !empty($search_where)) {
$where .= ' AND ' . $search_where;
}
echo getClassicModuleTitle("Administration", array("<a href='index.php?module=Administration&action=index'>" . translate('LBL_MODULE_NAME', 'Administration') . "</a>", $mod_strings['LBL_MANAGE_OFFLINE_CLIENT']), false);
echo '<div class="listViewBody">';
//now we want to display how many offline clients are currently in use
echo "<h4>";
if (!empty($error)) {
echo "<span class='error'>{$error}</span><br />";
}
if ($row_count == 0) {
echo "{$mod_strings['NO_ENABLED_OFFLINE_CLIENTS']}";
} else {
echo "{$row_count} of {$num_lic_oc} {$mod_strings['ENABLED_OFFLINE_CLIENTS']}";
}
echo "</h4>";
//SEARCH
if (!isset($_REQUEST['search_form']) || $_REQUEST['search_form'] != 'false') {
$search_form = new Sugar_Smarty();
$search_form->assign("MOD", $mod_strings);
$search_form->assign("APP", $app_strings);
$search_form->assign("BASIC_SEARCH_PNG", SugarThemeRegistry::current()->getImage('basic_search', 'border="0"', null, null, '.gif', $app_strings['LNK_BASIC_SEARCH']));
if (isset($user_name)) {
$search_form->assign("USER_NAME", $user_name);
}
$search_form->assign("JAVASCRIPT", get_clear_form_js());
$search_form->display('modules/Administration/templates/OfflineClientSearchForm.tpl');
}
//SEARCH
$ListView = new ListView();
$ListView->initNewXTemplate('modules/Administration/templates/ViewOfflineClients.html', $mod_strings);
$ListView->xTemplateAssign("RETURN_URL", "&return_module=" . $currentModule . "&return_action=ListView");
//.........这里部分代码省略.........
示例13: display
//.........这里部分代码省略.........
$storeQuery->loadQuery($this->module);
$storeQuery->populateRequest();
} else {
$storeQuery->saveFromRequest($this->module);
}
//search
$view = 'basic_search';
if (!empty($_REQUEST['search_form_view'])) {
$view = $_REQUEST['search_form_view'];
}
$headers = true;
if (!empty($_REQUEST['search_form_only']) && $_REQUEST['search_form_only']) {
$headers = false;
} elseif (!isset($_REQUEST['search_form']) || $_REQUEST['search_form'] != 'false') {
if (isset($_REQUEST['searchFormTab']) && $_REQUEST['searchFormTab'] == 'advanced_search') {
$view = 'advanced_search';
} else {
$view = 'basic_search';
}
}
$use_old_search = true;
if (SugarAutoLoader::existing('modules/' . $this->module . '/SearchForm.html')) {
require_once 'include/SearchForm/SearchForm.php';
$searchForm = new SearchForm($this->module, $this->seed);
} else {
$use_old_search = false;
require_once 'include/SearchForm/SearchForm2.php';
$defs = SugarAutoLoader::loadWithMetafiles($this->module, 'searchdefs');
if (!empty($defs)) {
require $defs;
}
$searchFields = SugarAutoLoader::loadSearchFields($this->module);
$searchForm = new SearchForm($this->seed, $this->module, $this->action);
$searchForm->setup($searchdefs, $searchFields, 'SearchFormGeneric.tpl', $view, $listViewDefs);
$searchForm->lv = $lv;
}
if (isset($this->options['show_title']) && $this->options['show_title']) {
$moduleName = isset($this->seed->module_dir) ? $this->seed->module_dir : $GLOBALS['mod_strings']['LBL_MODULE_NAME'];
echo getClassicModuleTitle($moduleName, array($GLOBALS['mod_strings']['LBL_MODULE_TITLE']), FALSE);
}
$where = '';
if (isset($_REQUEST['query'])) {
// we have a query
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, $this->seed->module_dir);
if (count($where_clauses) > 0) {
$where = '(' . implode(' ) AND ( ', $where_clauses) . ')';
}
$GLOBALS['log']->info("List View Where Clause: {$where}");
}
if ($use_old_search) {
switch ($view) {
case 'basic_search':
$searchForm->setup();
$searchForm->displayBasic($headers);
break;
case 'advanced_search':
$searchForm->setup();
$searchForm->displayAdvanced($headers);
break;
case 'saved_views':
示例14: 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')) {
//.........这里部分代码省略.........
示例15: elseif
}
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)) {
$searchForm = new SearchForm($seed, $module);
$searchForm->setup($searchdefs, $searchFields, '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, false)) {
array_push($uids, $val['id']);
}
$_REQUEST['subpanel_id'] = $uids;
}