コード例 #1
0
ファイル: Bug44858Test.php プロジェクト: jgera/sugarcrm_dev
 /**
  * @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
0
 function SearchPlusForm($name = "SearchForm", $fieldName = "Search", $fieldLabel = '')
 {
     $action = $this->getRequest()->param("Action");
     $page = SearchPlusPage::get()->first();
     if ($page) {
         //!in_array($action, array("login", "logout")) &&
         if (!$fieldLabel) {
             if (isset($_REQUEST[$fieldName])) {
                 $searchText = $_REQUEST[$fieldName];
                 //we set $_REQUEST["Search"] below because it is also used by things like Text::ContextSummary
                 $_REQUEST["Search"] = $_REQUEST[$fieldName];
             } elseif (isset($_REQUEST["Search"])) {
                 $searchText = $_REQUEST["Search"];
             } else {
                 $searchText = 'Search';
             }
         } else {
             $searchText = '';
         }
         $field = new TextField($fieldName, $fieldLabel, $searchText);
         $fields = new FieldList($field);
         $actions = new FieldList(new FormAction('results', 'Search'));
         $form = new SearchForm($this, $name, $fields, $actions);
         $form->setFormAction($page->Link() . "results/");
         $form->setPageLength(Config::inst()->get("SearchPlusPage", "result_length"));
         $form->unsetValidator();
         return $form;
     } elseif (!$page) {
         user_error("You need to create a SearchPlusPage to have a search box", E_USER_NOTICE);
     }
 }
コード例 #3
0
 function testPublishedPagesMatchedByTitleInDefaultLanguage()
 {
     $sf = new SearchForm($this->mockController, 'SearchForm');
     $publishedPage = $this->objFromFixture('SiteTree', 'publishedPage');
     $publishedPage->publish('Stage', 'Live');
     $translatedPublishedPage = $publishedPage->createTranslation('de_DE');
     $translatedPublishedPage->Title = 'translatedPublishedPage';
     $translatedPublishedPage->Content = 'German content';
     $translatedPublishedPage->write();
     $translatedPublishedPage->publish('Stage', 'Live');
     $this->waitUntilIndexingFinished();
     // Translatable::set_current_locale() can't be used because the context
     // from the holder is not present here - we set the language explicitly
     // through a pseudo GET variable in getResults()
     $lang = 'en_US';
     $results = $sf->getResults(null, array('Search' => 'content', 'locale' => $lang));
     $this->assertContains($publishedPage->ID, $results->column('ID'), 'Published pages are found by searchform in default language');
     $this->assertNotContains($translatedPublishedPage->ID, $results->column('ID'), 'Published pages in another language are not found when searching in default language');
     $lang = 'de_DE';
     $results = $sf->getResults(null, array('Search' => 'content', 'locale' => $lang));
     $this->assertNotContains($publishedPage->ID, $results->column('ID'), 'Published pages in default language are not found when searching in another language');
     $actual = $results->column('ID');
     array_walk($actual, 'intval');
     $this->assertContains((int) $translatedPublishedPage->ID, $actual, 'Published pages in another language are found when searching in this language');
 }
コード例 #4
0
 public function actionIndex()
 {
     $this->pageTitle = Yii::t('title', 'Server droplist');
     $form = new SearchForm();
     $form->scenario = 'droplist';
     $model = null;
     if (isset($_POST['SearchForm'])) {
         $form->attributes = $_POST['SearchForm'];
         if ($form->validate()) {
             if (!empty($form->mobId) and !empty($form->item_id)) {
                 $where = 'mobId = ' . $form->mobId . ' AND itemid = ' . $form->item_id;
             } elseif (!empty($form->mobId)) {
                 $where = 'mobId = ' . $form->mobId;
             } elseif (!empty($form->item_id)) {
                 $where = 'item_id = ' . $form->item_id;
             } else {
                 $where = null;
             }
             $criteria = new CDbCriteria();
             $criteria->select = 'mobId, item_id, min, max, chance';
             $criteria->condition = $where;
             $criteria->order = 'chance DESC, max DESC';
             $criteria->limit = 100;
             $model = Droplist::model()->findAll($criteria);
         }
     }
     $this->render('/droplist', array('form' => $form, 'model' => $model));
 }
コード例 #5
0
 /**
  * Creates a new company
  */
 public function createAction()
 {
     if ($this->request->isPost()) {
         $form = new SearchForm();
         $company = new MeiuiSearch();
         $data = $this->request->getPost();
         if (!$form->isValid($data, $company)) {
             foreach ($form->getMessages() as $message) {
                 $this->flash->error($message);
             }
             return $this->forward('search/create');
         }
         if ($company->save() == false) {
             foreach ($company->getMessages() as $message) {
                 $this->flash->error($message);
             }
             return $this->forward('search/create');
         }
         $form->clear();
         $this->flash->success("search was created successfully");
         return $this->forward("search/list");
     } else {
         $this->view->form = new SearchForm(null, array('edit' => true));
     }
 }
コード例 #6
0
 function testDisabledShowInSearchFlagNotIncluded()
 {
     $sf = new SearchForm($this->mockController, 'SearchForm');
     $page = $this->objFromFixture('SiteTree', 'dontShowInSearchPage');
     $results = $sf->getResults(null, array('Search' => 'dontShowInSearchPage'));
     $this->assertNotContains($page->ID, $results->column('ID'), 'Page with "Show in Search" disabled doesnt show');
 }
コード例 #7
0
 public function SpeakerSearchForm()
 {
     $searchField = new TextField('mq', 'Search Speaker', $this->getSearchQuery());
     $searchField->setAttribute("placeholder", "first name, last name or irc nickname");
     $fields = new FieldList($searchField);
     $form = new SearchForm($this, 'SpeakerSearchForm', $fields);
     $form->setFormAction($this->Link('results'));
     return $form;
 }
コード例 #8
0
ファイル: CatalogController.php プロジェクト: RexGalicie/yupe
 public function actionSearch()
 {
     if (Yii::app()->getRequest()->getQuery('SearchForm')) {
         $form = new SearchForm();
         $form->setAttributes(Yii::app()->getRequest()->getQuery('SearchForm'));
         if ($form->validate()) {
             $category = $form->category ? StoreCategory::model()->findByPk($form->category) : null;
             $this->render('search', ['category' => $category, 'searchForm' => $form, 'dataProvider' => $this->productRepository->search($form->q, $form->category)]);
         }
     }
 }
コード例 #9
0
 public function actionResult()
 {
     $model = new SearchForm();
     $form = new CForm('application.views.search.form', $model);
     if ($form->submitted('search') && $form->validate()) {
         $result = $model->searchResult();
         //$this->redirect(array('search/index'));
         $this->render('index', array('form' => $form, 'result' => $result));
     } else {
         $this->render('index', array('form' => $form));
     }
 }
コード例 #10
0
 public function actionSearch()
 {
     if (!Yii::app()->getRequest()->getQuery('SearchForm')) {
         throw new CHttpException(404);
     }
     $form = new SearchForm();
     $form->setAttributes(Yii::app()->getRequest()->getQuery('SearchForm'));
     if ($form->validate()) {
         $category = $form->category ? StoreCategory::model()->findByPk($form->category) : null;
         $this->render('search', ['category' => $category, 'searchForm' => $form, 'dataProvider' => $this->productRepository->getByFilter($this->attributeFilter->getMainAttributesForSearchFromQuery(Yii::app()->getRequest(), [AttributeFilter::MAIN_SEARCH_PARAM_NAME => $form->q]), $this->attributeFilter->getEavAttributesForSearchFromQuery(Yii::app()->getRequest()))]);
     }
 }
コード例 #11
0
ファイル: SiteController.php プロジェクト: bgstation/erp
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     $oLogItemNaoCadastrado = LogItemNaoCadastrado::model()->naoCadastrado()->exibir()->findAll();
     $oOrdemServico = new OrdemServico('search');
     $oOrdemServico->unsetAttributes();
     $oSearchForm = new SearchForm();
     $oOrdemServico->status = LogOrdemServico::ABERTA;
     if (isset($_GET['OrdemServico'])) {
         $oOrdemServico->attributes = $_GET['OrdemServico'];
         $oSearchForm->request = $_GET['OrdemServico'];
     }
     $this->render('index', array('oLogItemNaoCadastrado' => $oLogItemNaoCadastrado, 'oOrdemServico' => $oOrdemServico, 'exibeFormularioBusca' => $oSearchForm->checaRequisicaoVazia()));
 }
コード例 #12
0
 public function run()
 {
     $search = new SearchForm();
     $controller = $this->getController();
     $controller->layout = 'form';
     if (isset($_GET['SearchForm'])) {
         $search->attributes = $_GET['SearchForm'];
         if ($search->validate()) {
             if ($search->searchq == '') {
                 $query = '%';
             } else {
                 $query = $search->searchq;
             }
             $kategorie = $search->kategorie;
             $wortart = $search->wortart;
             $klasse = '';
             // Suchoptionen filtern:
             $filteredResults = wortschatz::model()->filterSearchOptions($kategorie, $wortart, $klasse);
             // alle genauen Treffer:
             $exactSearchResults = wortschatz::model()->exactSearch($filteredResults, $query);
             $pages_exact = $exactSearchResults['pages'];
             $countAll_exact = $exactSearchResults['countAll'];
             $count_exact = $exactSearchResults['count'];
             $sort_exact = $exactSearchResults['sort'];
             $models_exact = $exactSearchResults['models'];
             $linkedExactResults = wortschatz::model()->addLinks($models_exact);
             $models_exact_linked = $linkedExactResults['models'];
             // alle LIKE-Treffer:
             $standardSearchResults = wortschatz::model()->standardSearch($filteredResults, $query);
             $pages_standard = $standardSearchResults['pages'];
             $countAll_standard = $standardSearchResults['countAll'];
             $count_standard = $standardSearchResults['count'];
             $sort_standard = $standardSearchResults['sort'];
             $models_standard = $standardSearchResults['models'];
             // LIKE-Treffer ohne genaue Treffer:
             $cleanedResults = wortschatz::model()->removeExactResults($models_standard, $models_exact);
             $linkedResults = wortschatz::model()->addLinks($cleanedResults['models']);
             $models_linked = $linkedResults['models'];
             if ($count_exact != 0 or $count_standard != 0) {
                 $controller->render('search', array('search' => $search, 'query' => $query, 'models' => $models_linked, 'pages' => $pages_standard, 'countAll' => $countAll_standard, 'count' => $count_standard, 'sort' => $sort_standard, 'models_exact' => $models_exact_linked, 'pages_exact' => $pages_exact, 'countAll_exact' => $countAll_exact, 'count_exact' => $count_exact, 'sort_exact' => $sort_exact));
             } else {
                 $controller->render('search', array('search' => $search, 'errortext' => 'Keine Daten gefunden'));
             }
         } else {
             $controller->render('search', array('search' => $search));
         }
     } else {
         $controller->render('search', array('search' => $search));
     }
 }
コード例 #13
0
ファイル: SearchForm.php プロジェクト: ISCCTU/fitak
 public function submitted(self $form)
 {
     $values = $form->getValues(true);
     $params = array('s' => $values['s']);
     if ($values['sortBy'] === SearchRequest::SORT_RELEVANCE) {
         $params['sortBy'] = $values['sortBy'];
     }
     if ($values['groups'] !== array_filter($values['groups'])) {
         $params['groups'] = array_keys(array_filter($values['groups']));
     }
     if (!empty($values['from'])) {
         $params['from'] = $values['from'];
     }
     $this->presenter->redirect('Search:', $params);
 }
コード例 #14
0
 protected function createComponentSearchForm()
 {
     if ($this->searchRequest->groups) {
         $groups = array_fill_keys($this->searchRequest->groups, true);
     } else {
         $groups = array();
         foreach ($this->context->groups->getList() as $group) {
             $groups[$group->id] = true;
         }
     }
     $form = new SearchForm($this->context->groups);
     $form->setDefaults(array('s' => $this->getParameter('s'), 'from' => $this->searchRequest ? $this->searchRequest->from : null, 'groups' => $groups));
     $form->onSuccess[] = callback($form, 'submitted');
     return $form;
 }
コード例 #15
0
 public function isAttributeSafe($attributeName)
 {
     if ($attributeName == 'anyMixedAttributes') {
         return false;
     }
     return parent::isAttributeSafe($attributeName);
 }
コード例 #16
0
ファイル: SearchController.php プロジェクト: barricade86/raui
 public function actionSaveSort()
 {
     $objTypeId = Yii::app()->request->getParam('id', NULL);
     $sort = Yii::app()->request->getParam('sort');
     if (count($sort) >= param('searchMaxField', 15)) {
         HAjax::jsonError(tt('Search max field ') . param('searchMaxField', 3));
     }
     if ($objTypeId !== NULL && $sort && is_array($sort)) {
         $elements = SearchForm::getSearchFields();
         $sql = "DELETE FROM {{search_form}} WHERE obj_type_id=:id AND status!=:status";
         Yii::app()->db->createCommand($sql)->execute(array(':id' => $objTypeId, ':status' => SearchFormModel::STATUS_NOT_REMOVE));
         $i = 3;
         foreach ($sort as $field) {
             if (!isset($elements[$field])) {
                 continue;
             }
             $search = new SearchFormModel();
             $search->attributes = array('obj_type_id' => $objTypeId, 'field' => $field, 'status' => $elements[$field]['status'], 'sorter' => $i, 'formdesigner_id' => isset($elements[$field]['formdesigner_id']) ? $elements[$field]['formdesigner_id'] : 0);
             $search->save();
             $i++;
         }
         // delete assets js cache
         ConfigurationModel::clearGenerateJSAssets();
         HAjax::jsonOk();
     }
     HAjax::jsonError();
 }
コード例 #17
0
 public function init()
 {
     parent::init();
     if (!issetModule('messages')) {
         throw404();
     }
     $this->cityActive = SearchForm::cityInit();
 }
コード例 #18
0
 function display($header = false)
 {
     /*//global $app_list_strings;
       if($this->subPanel->subpanel_defs->isCollection() && isset($this->subPanel->subpanel_defs->base_collection_list)){
           $GLOBALS['app_list_strings']['collection_temp_list'] = $this->getCollectionList($this->subPanel->subpanel_defs->base_collection_list);
       }*/
     $this->th->ss->assign('subpanel', $this->subPanel->subpanel_id);
     return parent::display($header);
 }
コード例 #19
0
    public function actionSearch()
    {
        $model = new SearchForm();
        $dataProvider = null;
        if (isset($_REQUEST['SearchForm'])) {
            $model->attributes = $_REQUEST['SearchForm'];
            if ($model->validate()) {
                $friendList = AuxiliaryFriendsOperator::getFriendIdList();
                $sqlCount = 'SELECT count(*)
					 FROM ' . Upload::model()->tableName() . ' u
					 LEFT JOIN  ' . Users::model()->tableName() . ' s ON s.Id = u.userId 
					 WHERE (u.userId in (' . $friendList . ') 
					 			OR 
						 		u.userId = ' . Yii::app()->user->id . '
						 		OR
						 		u.publicData = 1 )
					 	   AND	
					 	   (s.realname like "%' . $model->keyword . '%"
						   		OR
						   		u.description like "%' . $model->keyword . '%")';
                $count = Yii::app()->db->createCommand($sqlCount)->queryScalar();
                $sql = 'SELECT u.Id as id, u.description, s.realname, s.Id as userId
					 FROM ' . Upload::model()->tableName() . ' u
					 LEFT JOIN  ' . Users::model()->tableName() . ' s ON s.Id = u.userId 
					 WHERE (u.userId in (' . $friendList . ') 
					 			OR 
						 		u.userId = ' . Yii::app()->user->id . ' 
						 		OR
						 		u.publicData = 1)
					 	   AND
					 	   (s.realname like "%' . $model->keyword . '%"
					 			OR
					 	   		u.description like "%' . $model->keyword . '%")';
                $dataProvider = new CSqlDataProvider($sql, array('totalItemCount' => $count, 'sort' => array('attributes' => array('id', 'realname')), 'pagination' => array('pageSize' => Yii::app()->params->imageCountInOnePage, 'params' => array(CHtml::encode('SearchForm[keyword]') => $model->attributes['keyword']))));
            }
        }
        Yii::app()->clientScript->scriptMap['jquery.js'] = false;
        //TODO: added below line because gridview.js is loaded before.
        Yii::app()->clientScript->scriptMap['jquery.yiigridview.js'] = false;
        $this->renderPartial('searchImageResults', array('model' => $model, 'dataProvider' => $dataProvider), false, true);
    }
コード例 #20
0
 /**
  * Show all books.
  */
 public function actionList()
 {
     $criteria = new CDbCriteria();
     $criteria->with = 'author';
     $searchForm = new SearchForm();
     if (isset($_POST['SearchForm'])) {
         $searchForm->setAttributes($_POST['SearchForm']);
         $criteria = $searchForm->apllyFilter($criteria);
     }
     $pages = new CPagination(Books::model()->count());
     $pages->applyLimit($criteria);
     $sort = new CSort('Books');
     $sort->attributes = array('name', 'date', 'date_update', 'author' => array('asc' => 'author.lastname, author.firstname', 'desc' => 'author.lastname DESC, author.firstname DESC', 'label' => 'Автор'));
     $sort->defaultOrder = 'name';
     $sort->applyOrder($criteria);
     $books = Books::model()->findAll($criteria);
     $formWidget = $this->createWidget('FormWindow');
     $formWidget->afterClose = '$("#ui-datepicker-div").remove();$("#content").load("#");';
     $formWidget->run();
     $this->renderAjax('list', array('pages' => $pages, 'models' => $books, 'sort' => $sort, 'searchForm' => $searchForm));
 }
コード例 #21
0
 /**
  * the constructor of a Simple/basic SearchForm
  */
 function __construct($controller, $name, $fields = null, $actions = null)
 {
     if (!$fields) {
         $fields = new FieldSet($searchBy = new CompositeField(new HeaderField(_t('ProductSearchForm.SEARCHBY', 'Search Products'), 2), new HeaderField(_t('ProductSearchForm.WHERE', 'Where?'), 3), new LocationTreeDropdown('Location', ''), $categoryFields = new CompositeField(new HeaderField(_t('ProductSearchForm.SEARCHCRITERIA', 'Search Criteria'), 3), new MyTypeDropdown("ProductCategory1", 'Category #1', 'ProductCategory', null, null, false, array('Any' => 'Any Category')), new LiteralField('or1', ' or '), new MyTypeDropdown("ProductCategory2", 'Category #2', 'ProductCategory', null, null, true, array('' => '')), new LiteralField('or2', ' or '), new MyTypeDropdown("ProductCategory3", 'Category #3', 'ProductCategory', null, null, true, array('' => ''))), new TextField("keywords", _t('ProductSearchForm.KEYWORDS', 'Keywords'))), $sortBy = new CompositeField(new HeaderField(_t('ProductSearchForm.SORTBY', 'Sort Results By'), 3), new OptionsetField("sortby", "", array('PageTitle' => _t('ProductSearchForm.NAME', 'Name'), 'Category' => _t('ProductSearchForm.CATEGORY', 'Category'), 'Location' => _t('ProductSearchForm.LOCATION', 'Location')), 'PageTitle')));
         $searchBy->ID = "ProductSearchForm_SearchBy";
         $sortBy->ID = "ProductSearchForm_SortBy";
         $categoryFields->ID = "ProductSearchForm_SearchBy_Category";
     }
     if (!$actions) {
         $actions = new FieldSet(new FormAction("results", _t('ProductSearchForm.SEARCH', 'Search')));
     }
     parent::__construct($controller, $name, $fields, $actions);
 }
コード例 #22
0
 function display($header = false)
 {
     /*//global $app_list_strings;
       if($this->subPanel->subpanel_defs->isCollection() && isset($this->subPanel->subpanel_defs->base_collection_list)){
           $GLOBALS['app_list_strings']['collection_temp_list'] = $this->getCollectionList($this->subPanel->subpanel_defs->base_collection_list);
       }*/
     $this->th->ss->assign('subpanel', $this->subPanel->subpanel_id);
     // Adding the offset to subpanel search field - this has no affect on pagination
     if ($this->subPanel->parent_bean->module_dir != '') {
         $this->th->ss->assign('subpanelPageOffset', '<input type="hidden" name="' . $this->subPanel->parent_bean->module_dir . '_' . $this->subPanel->subpanel_id . '_CELL_offset" value="0" />');
     }
     $this->parsedView = 'sps';
     return parent::display($header);
 }
コード例 #23
0
 /**
  * the constructor of a Simple/basic SearchForm
  */
 function __construct($controller, $name, $fields = null, $actions = null)
 {
     if (!$fields) {
         $fields = new FieldSet($searchBy = new CompositeField(new HeaderField('SearchByHeader', _t('AdvancedSearchForm.SEARCHBY', 'SEARCH BY')), new TextField("+", _t('AdvancedSearchForm.ALLWORDS', 'All Words')), new TextField("quote", _t('AdvancedSearchForm.EXACT', 'Exact Phrase')), new TextField("any", _t('AdvancedSearchForm.ATLEAST', 'At Least One Of the Words')), new TextField("-", _t('AdvancedSearchForm.WITHOUT', 'Without the Words'))), $sortBy = new CompositeField(new HeaderField('SortByHeader', _t('AdvancedSearchForm.SORTBY', 'SORT RESULTS BY')), new OptionsetField("sortby", "", array('Relevance' => _t('AdvancedSearchForm.RELEVANCE', 'Relevance'), 'LastUpdated' => _t('AdvancedSearchForm.LASTUPDATED', 'Last Updated'), 'PageTitle' => _t('AdvancedSearchForm.PAGETITLE', 'Page Title')), 'Relevance')), $chooseDate = new CompositeField(new HeaderField('LastUpdatedHeader', _t('AdvancedSearchForm.LASTUPDATEDHEADER', 'LAST UPDATED')), new DateField("From", _t('AdvancedSearchForm.FROM', 'From')), new DateField("To", _t('AdvancedSearchForm.TO', 'To'))));
         $searchBy->ID = "AdvancedSearchForm_SearchBy";
         $searchOnly->ID = "AdvancedSearchForm_SearchOnly";
         $sortBy->ID = "AdvancedSearchForm_SortBy";
         $chooseDate->ID = "AdvancedSearchForm_ChooseDate";
     }
     if (!$actions) {
         $actions = new FieldSet(new FormAction("results", _t('AdvancedSearchForm.GO', 'Go')));
     }
     parent::__construct($controller, $name, $fields, $actions);
 }
コード例 #24
0
 function displayAdvanced($header = true, $return = false, $listViewDefs = '', $lv = '')
 {
     global $app_strings;
     $SAVED_SEARCHES_OPTIONS = '';
     $savedSearch = BeanFactory::getBean('SavedSearch');
     $SAVED_SEARCHES_OPTIONS = $savedSearch->getSelect($this->module);
     $str = "";
     if (!empty($SAVED_SEARCHES_OPTIONS) && $this->showSavedSearchOptions) {
         $str .= "   <span class='white-space'>\n                        &nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<b>{$app_strings['LBL_SAVED_SEARCH_SHORTCUT']}</b>&nbsp;\n                        {$SAVED_SEARCHES_OPTIONS}\n                        <span id='go_btn_span' style='display:none'><input tabindex='2' title='go_select' id='go_select'  onclick='SUGAR.searchForm.clear_form(this.form); return false;' class='button' type='button' name='go_select' value=' {$app_strings['LBL_GO_BUTTON_LABEL']} '/></span>\n                    </span>";
     }
     $str .= "\n                <script>\n                    function toggleInlineSearch(){\n                        if (document.getElementById('inlineSavedSearch').style.display == 'none'){\n                            document.getElementById('showSSDIV').value = 'yes'\n                            document.getElementById('inlineSavedSearch').style.display = '';\n\n                            document.getElementById('up_down_img').src='" . SugarThemeRegistry::current()->getImageURL('basic_search.gif') . "';\n                            document.getElementById('up_down_img').setAttribute('alt','" . translate('LBL_ALT_HIDE_OPTIONS') . "');\n\n                        }else{\n\n                            document.getElementById('up_down_img').src='" . SugarThemeRegistry::current()->getImageURL('advanced_search.gif') . "';\n                            document.getElementById('up_down_img').setAttribute('alt','" . translate('LBL_ALT_SHOW_OPTIONS') . "');\n                            document.getElementById('showSSDIV').value = 'no';\n                            document.getElementById('inlineSavedSearch').style.display = 'none';\n                        }\n                    }\n\n\n                </script>\n            ";
     $this->xtpl->assign('ADVANCED_BUTTONS', $str);
     $this->xtpl->assign('LBL_DELETE_CONFIRM', translate('LBL_DELETE_CONFIRM', 'SavedSearch'));
     return parent::displayAdvanced($header, $return, $listViewDefs, $lv);
 }
コード例 #25
0
 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;
 }
 /**
  * the constructor of a Simple/basic SearchForm
  */
 function __construct($controller, $name, $fields = null, $actions = null)
 {
     // Need this before we call parent::_construct
     $this->controller = $controller;
     if (!$fields) {
         if ($this->controller->GeoLevelName() != 'No level' && $this->controller->getBusinessCount() != 0) {
             $searchBusinessHeading = 'Search Businesses in ' . $this->controller->Title;
         } else {
             $searchBusinessHeading = _t('BusinessSearchForm.SEARCHBUSINESSES', 'Search Our Network');
         }
         $fields = new FieldSet($searchBy = new CompositeField(new HeaderField($searchBusinessHeading, 2), new HeaderField(_t('BusinessSearchForm.BUSINESSDETAILS', 'Business Details'), 4), new NumericField("floid", _t('BusinessSearchForm.FLOID', 'FLO ID')), new TextField("keywords", _t('BusinessSearchForm.KEYWORDS', 'Name or keyword')), $this->getLocationFields(), $certFields = new CompositeField(new HeaderField(_t('BusinessSearchForm.SEARCHCRITERIA', 'Product Type / Function'), 4), new MyTypeDropdown("ProductCategory1", 'Product Type', 'ProductCategory', null, null, false, array('All' => 'All')), new MyTypeDropdown("CertificationType1", 'Function', 'CertificationType', null, null, false, array('All' => 'All')), new LiteralField('andOr1', '<span class="andOr" id="andOr1">or</span>'), new MyTypeDropdown("ProductCategory2", 'Product Type', 'ProductCategory', null, null, false, array('All' => 'All')), new MyTypeDropdown("CertificationType2", 'Function', 'CertificationType', null, null, false, array('All' => 'All')), new LiteralField('andOr2', '<span class="andOr" id="andOr2">or</span>'), new MyTypeDropdown("ProductCategory3", 'Product Type', 'ProductCategory', null, null, false, array('All' => 'All')), new MyTypeDropdown("CertificationType3", 'Function', 'CertificationType', null, null, false, array('All' => 'All')), new LiteralField('addCriteria', '<div id="addRemoveCriteria"><a href="#" id="addCriteria">Add criteria</a><span id="addRemovePipe"> | </span><a href="#" id="removeCriteria">Remove criteria</a></div>'), new OptionsetField('CertificationAndOr', '', array('AND' => 'Must match ALL of the selection below', 'OR' => 'Must match ANY of the selection below'), 'AND'))), $sortBy = new HiddenField('sortby', '', 'Location'));
         $searchBy->ID = "BusinessSearchForm_SearchBy";
         $sortBy->ID = "BusinessSearchForm_SortBy";
         $certFields->ID = "BusinessSearchForm_SearchBy_CertificationCriteria";
     }
     if (!$actions) {
         $actions = new FieldSet(new FormAction("results", _t('BusinessSearchForm.SEARCH', 'Search')));
     }
     parent::__construct($controller, $name, $fields, $actions);
 }
コード例 #27
0
    <?php 
if ($this->searchShowLabel) {
    ?>
	<div class="bt1 <?php 
    echo $textClass;
    ?>
"><?php 
    echo tt('Search in section', 'common');
    ?>
:</div>
    <?php 
}
?>
	<li>
		<?php 
$data = SearchForm::apTypes();
echo CHtml::dropDownList('apType', isset($this->apType) ? CHtml::encode($this->apType) : '', $data['propertyType'], array('class' => $fieldClass . ' searchField'));
?>
	</li>

コード例 #28
0
global $current_user;
// focus_list is the means of passing data to a ListView.
global $focus_list;
// setup quicksearch
require_once 'include/QuickSearchDefaults.php';
$qsd = new QuickSearchDefaults();
// clear the display columns back to default when clear query is called
if (!empty($_REQUEST['clear_query']) && $_REQUEST['clear_query'] == 'true') {
    $current_user->setPreference('ListViewDisplayColumns', array(), 0, $currentModule);
}
$savedDisplayColumns = $current_user->getPreference('ListViewDisplayColumns', $currentModule);
// get user defined display columns
$json = getJSONobj();
$seedProducts = new Products();
// seed bean
$searchForm = new SearchForm('Products', $seedProducts);
// new searchform instance
// setup listview smarty
$lv = new ListViewSmarty();
$displayColumns = array();
// check $_REQUEST if new display columns from post
if (!empty($_REQUEST['displayColumns'])) {
    foreach (explode('|', $_REQUEST['displayColumns']) as $num => $col) {
        if (!empty($listViewDefs['Products'][$col])) {
            $displayColumns[$col] = $listViewDefs['Products'][$col];
        }
    }
} elseif (!empty($savedDisplayColumns)) {
    // use user defined display columns from preferences
    $displayColumns = $savedDisplayColumns;
} else {
コード例 #29
0
 /**
  * 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')) {
                         require_once 'custom/modules/' . $seed->module_dir . '/metadata/listviewdefs.php';
                     } else {
                         require_once 'modules/' . $seed->module_dir . '/metadata/listviewdefs.php';
                     }
                     $filterFields = array();
                     foreach ($listViewDefs[$seed->module_dir] as $colName => $param) {
                         if (!empty($param['default']) && $param['default'] == true) {
                             $filterFields[] = strtolower($colName);
                         }
                     }
                     if (!in_array('id', $filterFields)) {
                         $filterFields[] = 'id';
                     }
                 }
                 //Pull in any db fields used for the unified search query so the correct joins will be added
                 $selectOnlyQueryFields = array();
                 foreach ($unifiedSearchFields[$name] as $field => $def) {
                     if (isset($def['db_field']) && !in_array($field, $filterFields)) {
                         $filterFields[] = $field;
                         $selectOnlyQueryFields[] = $field;
                     }
                 }
                 //Add the assigned user filter if applicable
                 if (!empty($assigned_user_id) && isset($seed->field_defs['assigned_user_id'])) {
                     $ownerWhere = $seed->getOwnerWhere($assigned_user_id);
                     $where = "({$where}) AND {$ownerWhere}";
                 }
                 if ($beanName == "Employee") {
                     $where = "({$where}) AND users.deleted = 0 AND users.is_group = 0 AND users.employee_status = 'Active'";
                 }
                 $list_params = array();
                 $ret_array = $seed->create_new_list_query('', $where, $filterFields, $list_params, 0, '', true, $seed, true);
                 if (empty($params) or !is_array($params)) {
                     $params = array();
                 }
                 if (!isset($params['custom_select'])) {
                     $params['custom_select'] = '';
                 }
                 if (!isset($params['custom_from'])) {
                     $params['custom_from'] = '';
                 }
                 if (!isset($params['custom_where'])) {
                     $params['custom_where'] = '';
                 }
                 if (!isset($params['custom_order_by'])) {
                     $params['custom_order_by'] = '';
                 }
                 $main_query = $ret_array['select'] . $params['custom_select'] . $ret_array['from'] . $params['custom_from'] . $ret_array['where'] . $params['custom_where'] . $ret_array['order_by'] . $params['custom_order_by'];
             } else {
                 if ($beanName == "User") {
                     $filterFields = array('id', 'user_name', 'first_name', 'last_name', 'email_address');
                     $main_query = "select users.id, ea.email_address, users.user_name, first_name, last_name from users ";
                     $main_query = $main_query . " LEFT JOIN email_addr_bean_rel eabl ON eabl.bean_module = '{$seed->module_dir}'\n    LEFT JOIN email_addresses ea ON (ea.id = eabl.email_address_id) ";
                     $main_query = $main_query . "where ((users.first_name like '{$search_string}') or (users.last_name like '{$search_string}') or (users.user_name like '{$search_string}') or (ea.email_address like '{$search_string}')) and users.deleted = 0 and users.is_group = 0 and users.employee_status = 'Active'";
                 }
                 // if
                 if ($beanName == "ProjectTask") {
                     $filterFields = array('id', 'name', 'project_id', 'project_name');
                     $main_query = "select {$seed->table_name}.project_task_id id,{$seed->table_name}.project_id, {$seed->table_name}.name, project.name project_name from {$seed->table_name} ";
                     $seed->add_team_security_where_clause($main_query);
                     $main_query .= "LEFT JOIN teams ON {$seed->table_name}.team_id=teams.id AND (teams.deleted=0) ";
                     $main_query .= "LEFT JOIN project ON {$seed->table_name}.project_id = project.id ";
                     $main_query .= "where {$seed->table_name}.name like '{$search_string}%'";
                 }
                 // if
             }
             // else
             $GLOBALS['log']->info('SugarWebServiceImpl->search_by_module - query = ' . $main_query);
             if ($max_results < -1) {
                 $result = $seed->db->query($main_query);
             } else {
                 if ($max_results == -1) {
                     $limit = $sugar_config['list_max_entries_per_page'];
                 } else {
                     $limit = $max_results;
                 }
                 $result = $seed->db->limitQuery($main_query, $offset, $limit + 1);
             }
             $rowArray = array();
             while ($row = $seed->db->fetchByAssoc($result)) {
                 $nameValueArray = array();
                 foreach ($filterFields as $field) {
                     if (in_array($field, $selectOnlyQueryFields)) {
                         continue;
                     }
                     $nameValue = array();
                     if (isset($row[$field])) {
                         $nameValueArray[$field] = self::$helperObject->get_name_value($field, $row[$field]);
                     }
                     // if
                 }
                 // foreach
                 $rowArray[] = $nameValueArray;
             }
             // while
             $output_list[] = array('name' => $name, 'records' => $rowArray);
         }
         // foreach
         $GLOBALS['log']->info('End: SugarWebServiceImpl->search_by_module');
         return array('entry_list' => $output_list);
     }
     // if
     return array('entry_list' => $output_list);
 }
コード例 #30
0
 public function init()
 {
     parent::init();
     //$this->metroStations = SearchForm::stationsInit();
     $this->cityActive = SearchForm::cityInit();
 }