function build() { //we will assume that if the ListView.html file exists we will want to use that one if (SugarAutoLoader::fileExists('modules/' . $this->module . '/ListView.html')) { $this->type = 1; $this->lv = new ListView(); $this->template = 'modules/' . $this->module . '/ListView.html'; } else { $metadataFile = SugarAutoLoader::loadWithMetafiles($this->module, 'listviewdefs'); if ($metadataFile) { require $metadataFile; } SugarACL::listFilter($this->module, $listViewDefs[$this->module], array("owner_override" => true)); $this->lv = new ListViewSmarty(); $displayColumns = array(); if (!empty($_REQUEST['displayColumns'])) { foreach (explode('|', $_REQUEST['displayColumns']) as $num => $col) { if (!empty($listViewDefs[$this->module][$col])) { $displayColumns[$col] = $listViewDefs[$this->module][$col]; } } } else { if (isset($listViewDefs[$this->module])) { foreach ($listViewDefs[$this->module] as $col => $params) { if (!empty($params['default']) && $params['default']) { $displayColumns[$col] = $params; } } } } $this->lv->displayColumns = $displayColumns; $this->type = 2; $this->template = 'include/ListView/ListViewGeneric.tpl'; } }
public static function retrieveReportsSearchDefs() { $searchdefs = array(); $searchFields = array(); $defs = SugarAutoLoader::loadWithMetafiles('Reports', 'searchdefs'); if ($defs) { require $defs; } $searchFields = SugarAutoLoader::loadSearchFields('Reports'); return array('searchdefs' => $searchdefs, 'searchFields' => $searchFields); }
/** * Get variable definitions from metadata or from popup overrides * @param string $varname * @return string|array|null Return filename to include, or data set or null if nothing found */ protected function loadWithPopup($varname) { global $popupMeta; if (!empty($popupMeta) && !empty($popupMeta[$varname])) { //if we have an array, then we are not going to include a file, but rather the //listviewdefs will be defined directly in the popupdefs file //otherwise include the file return $popupMeta[$varname]; } else { return SugarAutoLoader::loadWithMetafiles($this->module, $varname); } }
protected function getSubpanelDefs($module_dir) { if (!isset(self::$defs[$module_dir])) { $defs = SugarAutoLoader::loadWithMetafiles($module_dir, 'subpaneldefs'); if ($defs) { require $defs; } $defs = SugarAutoLoader::loadExtension("layoutdefs", $module_dir); if ($defs) { require $defs; } if (!isset($layout_defs)) { return null; } self::$defs[$module_dir] = $layout_defs; } return self::$defs[$module_dir]; }
/** * Renders the QuickCreate form from Smarty and returns HTML * @param array $vars request variable global * @param object $email Fetched email object * @param bool $addToAddressBook * @return array */ function getQuickCreateForm($vars, $email, $addToAddressBookButton = false) { require_once "include/EditView/EditView2.php"; global $app_strings; global $mod_strings; global $current_user; global $current_language; $module = $_REQUEST['qc_module']; $beanName = BeanFactory::getBeanName($module); //Setup the current module languge $mod_strings = return_module_language($current_language, $module); $focus = BeanFactory::getBean($module); $people = array('Contact', 'Lead'); $emailAddress = array(); // people if (in_array($beanName, $people)) { // lead specific $focus->lead_source = 'Email'; $focus->lead_source_description = trim($email->name); $from = isset($email->from_name) && !empty($email->from_name) ? $email->from_name : $email->from_addr; if (isset($_REQUEST['sugarEmail']) && !empty($_REQUEST['sugarEmail'])) { if ($email->status == "sent") { $from = isset($email->to_addrs_names) && !empty($email->to_addrs_names) ? $email->to_addrs_names : $email->to_addrs; } else { $from = isset($email->from_name) && !empty($email->from_name) ? $email->from_name : $email->from_addr_name; } } $name = explode(" ", trim($from)); $address = trim(array_pop($name)); $address = str_replace(array("<", ">", "<", ">"), "", $address); $emailAddress[] = array('email_address' => $address, 'primary_address' => 1, 'invalid_email' => 0, 'opt_out' => 0, 'reply_to_address' => 1); $focus->email1 = $address; if (!empty($name)) { $focus->last_name = trim(array_pop($name)); foreach ($name as $first) { if (!empty($focus->first_name)) { $focus->first_name .= " "; } $focus->first_name .= trim($first); } } } else { // case & bug specific $focus->source = 'InboundEmail'; // bugs, cases, tasks $focus->name = trim($email->name); } $focus->description = trim(strip_tags($email->description)); $focus->assigned_user_id = $current_user->id; $focus->team_id = $current_user->default_team; $EditView = new EditView(); $EditView->ss = new Sugar_Smarty(); //MFH BUG#20283 - checks for custom quickcreate fields $EditView->setup($module, $focus, SugarAutoLoader::loadWithMetafiles($module, 'editviewdefs')); $EditView->process(); $EditView->render(); $EditView->defs['templateMeta']['form']['buttons'] = array('email2save' => array('id' => 'e2AjaxSave', 'customCode' => '<input type="button" class="button" value=" ' . $app_strings['LBL_SAVE_BUTTON_LABEL'] . ' " onclick="SUGAR.email2.detailView.saveQuickCreate(false);" />'), 'email2saveandreply' => array('id' => 'e2SaveAndReply', 'customCode' => '<input type="button" class="button" value=" ' . $app_strings['LBL_EMAIL_SAVE_AND_REPLY'] . ' " onclick="SUGAR.email2.detailView.saveQuickCreate(\'reply\');" />'), 'email2cancel' => array('id' => 'e2cancel', 'customCode' => '<input type="button" class="button" value=" ' . $app_strings['LBL_EMAIL_CANCEL'] . ' " onclick="SUGAR.email2.detailView.quickCreateDialog.hide();" />')); if ($addToAddressBookButton) { $EditView->defs['templateMeta']['form']['buttons']['email2saveAddToAddressBook'] = array('id' => 'e2addToAddressBook', 'customCode' => '<input type="button" class="button" value=" ' . $app_strings['LBL_EMAIL_ADDRESS_BOOK_SAVE_AND_ADD'] . ' " onclick="SUGAR.email2.detailView.saveQuickCreate(true);" />'); } //Get the module language for javascript if (!is_file(sugar_cached('jsLanguage/') . "{$module}/{$GLOBALS['current_language']}.js")) { require_once 'include/language/jsLanguage.php'; jsLanguage::createModuleStringsCache($module, $GLOBALS['current_language']); } $jsLanguage = getVersionedScript("cache/jsLanguage/{$module}/{$GLOBALS['current_language']}.js", $GLOBALS['sugar_config']['js_lang_version']); if ($focus->object_name == 'Contact') { $admin = Administration::getSettings(); if (empty($admin->settings['portal_on']) || !$admin->settings['portal_on']) { unset($EditView->sectionPanels[strtoupper('lbl_portal_information')]); } else { $jsLanguage .= getVersionedScript("modules/Contacts/Contact.js"); $jsLanguage .= getVersionedScript("modules/Contacts/QuickCreateEmailContact.js"); $jsLanguage .= <<<EOQ \t\t\t <script language="javascript"> \t\t\t\t addToValidateComparison('form_EmailQCView_Contacts', 'portal_password', 'varchar', false, SUGAR.language.get('app_strings', 'ERR_SQS_NO_MATCH_FIELD') + SUGAR.language.get('Contacts', 'LBL_PORTAL_PASSWORD'), 'portal_password1'); \t\t addToValidateVerified('form_EmailQCView_Contacts', 'portal_name_verified', 'bool', false, SUGAR.language.get('app_strings', 'ERR_EXISTING_PORTAL_USERNAME')); \t\t YAHOO.util.Event.on('portal_name', 'blur', validatePortalName); \t\t\t\t YAHOO.util.Event.on('portal_name', 'keydown', handleKeyDown); \t\t\t </script> EOQ; } } $EditView->view = 'EmailQCView'; $EditView->defs['templateMeta']['form']['headerTpl'] = 'include/EditView/header.tpl'; $EditView->defs['templateMeta']['form']['footerTpl'] = 'include/EditView/footer.tpl'; $meta = array(); $meta['html'] = $jsLanguage . $EditView->display(false, true); $meta['html'] = str_replace("src='" . getVersionedPath('include/SugarEmailAddress/SugarEmailAddress.js') . "'", '', $meta['html']); $meta['emailAddress'] = $emailAddress; $mod_strings = return_module_language($current_language, 'Emails'); return $meta; }
/** * Return the metadata file that will be used by this view. * * @return string File location of the metadata file. */ public function getMetaDataFile($type = null) { if ($type === null) { $type = $this->type; } $viewDef = strtolower($type) . 'viewdefs'; return SugarAutoLoader::loadWithMetafiles($this->module, $viewDef); }
/** * Load popupdefs metadata file * Allows to override 'popupdefs' with $metadata variable * NOTE: unlike generic loadWithMetafiles, this one returns defs, not filenames * @param string $module * @param string $metadata metadata name override * @return array popup defs data or NULL */ public static function loadPopupMeta($module, $metadata = null) { $defs = null; if ($metadata == 'undefined' || strpos($metadata, "..") !== false) { $metadata = null; } if (!empty($metadata)) { $defs = SugarAutoLoader::loadWithMetafiles($module, $metadata); } if (!$defs) { $defs = SugarAutoLoader::loadWithMetafiles($module, 'popupdefs'); } if ($defs) { require $defs; return $popupMeta; } return 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. * @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) { $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()); //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; } $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); if (count($select_fields) > 0) { $filterFields = $select_fields; } else { 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 (!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'"; } $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'] = ''; } 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); }
/** * get_subpanel_defs * * @param String $module The name of the module to get the subpanel definition for * @param String $type The type of subpanel definition ('wireless' or 'default') * @return array Array of the subpanel definition; empty array if no matching definition found */ function get_subpanel_defs($module, $type) { global $beanList, $beanFiles; $results = array(); switch ($type) { case 'wireless': $defs = SugarAutoLoader::existingCustomOne('modules/' . $module . '/metadata/wireless.subpaneldefs.php'); if ($defs) { require $defs; } //If an Ext/WirelessLayoutdefs/wireless.subpaneldefs.ext.php file exists, then also load it as well $defs = SugarAutoLoader::loadExtension("wireless_subpanels", $module); if ($defs) { require $defs; } break; case 'default': default: $defs = SugarAutoLoader::loadWithMetafiles($module, 'subpaneldefs'); if ($defs) { require $defs; } $defs = SugarAutoLoader::loadExtension("layoutdefs", $module); if ($defs) { require $defs; } } //Filter results for permissions foreach ($layout_defs[$module]['subpanel_setup'] as $subpanel => $subpaneldefs) { $moduleToCheck = $subpaneldefs['module']; $bean = BeanFactory::getBean($moduleToCheck); if (empty($bean)) { continue; } if ($bean->ACLAccess('list')) { $results[$subpanel] = $subpaneldefs; } } return $results; }
/** * Finds and returns the best viewdefs to use: * 1. custom/module/quickcreatedefs.php * 2. module/quickcreatedefs.php * 3. custom/module/editviewdefs.php * 4. module/editviewdefs.php * * @param $module * @param $view * @return string The path to the viewdefs file to use */ public function getModuleViewDefsSourceFile($module, $view) { $source = SugarAutoLoader::existingCustomOne("modules/{$module}/metadata/" . strtolower($view) . "defs.php"); if (!$source) { $source = SugarAutoLoader::loadWithMetafiles($module, "editviewdefs"); $this->viewType = 'EditView'; } return $source; }
/** * @see SugarView::display() */ public function display() { if (!empty($_REQUEST['handle']) && $_REQUEST['handle'] == 'save') { return $this->handleSave(); } global $beanList; // get the EditView defs to check if opportunity_name exists, for a check below for populating data $opportunityNameInLayout = false; $this->medataDataFile = SugarAutoLoader::loadWithMetafiles('Leads', "editviewdefs"); include $this->medataDataFile; foreach ($viewdefs['Leads']['EditView']['panels'] as $panel_index => $section) { foreach ($section as $row_array) { foreach ($row_array as $cell) { if (isset($cell['name']) && $cell['name'] == 'opportunity_name') { $opportunityNameInLayout = true; } } } } $this->medataDataFile = SugarAutoLoader::existingCustomOne($this->fileName); $this->loadDefs(); $this->getRecord(); $this->checkForDuplicates($this->focus); $smarty = new Sugar_Smarty(); $ev = new EditView(); $ev->ss = $smarty; $ev->view = "ConvertLead"; echo $this->getModuleTitle(); require_once "include/QuickSearchDefaults.php"; $qsd = QuickSearchDefaults::getQuickSearchDefaults(); $qsd->setFormName("ConvertLead"); $this->contact = BeanFactory::getBean('Contacts'); // Bug #50126 We have to fill account_name & add ability to select account from popup with pre populated name /* * Setup filter for Account/Contact popup picker */ $filter = ''; // Check if Lead has an account set if (!empty($this->focus->account_name)) { $filter .= '&name_advanced=' . urlencode($this->focus->account_name); } // Check if Lead First name is available if (!empty($this->focus->first_name)) { $filter .= '&first_name_advanced=' . urlencode($this->focus->first_name); } // Lead Last Name is always available $filter .= '&last_name_advanced=' . urlencode($this->focus->last_name); $smarty->assign('initialFilter', $filter); $smarty->assign('displayParams', array('initial_filter' => '{$initialFilter}')); $relatedFields = $this->contact->get_related_fields(); $selectFields = array(); foreach ($this->defs as $moduleName => $mDefs) { if (!empty($mDefs[$ev->view]['select']) && !empty($relatedFields[$mDefs[$ev->view]['select']])) { $selectFields[$moduleName] = $mDefs[$ev->view]['select']; continue; } foreach ($relatedFields as $fDef) { if (!empty($fDef['link']) && !empty($fDef['module']) && $fDef['module'] == $moduleName) { $selectFields[$moduleName] = $fDef['name']; break; } } } $smarty->assign('selectFields', $selectFields); $smarty->assign("contact_def", $this->contact->field_defs); $smarty->assign("form_name", "ConvertLead"); $smarty->assign("form_id", "ConvertLead"); $smarty->assign("module", "Leads"); $smarty->assign("view", "convertlead"); $smarty->assign("bean", $this->focus); $smarty->assign("record_id", $this->focus->id); global $mod_strings; $smarty->assign('MOD', $mod_strings); $smarty->display("modules/Leads/tpls/ConvertLeadHeader.tpl"); echo "<div class='edit view' style='width:auto;'>"; global $sugar_config, $app_list_strings, $app_strings; $smarty->assign('lead_conv_activity_opt', $sugar_config['lead_conv_activity_opt']); //Switch up list depending on copy or move if ($sugar_config['lead_conv_activity_opt'] == 'move') { $smarty->assign('convertModuleListOptions', get_select_options_with_id(array('None' => $app_strings['LBL_NONE'], 'Contacts' => $app_list_strings["moduleListSingular"]['Contacts']), '')); } else { if ($sugar_config['lead_conv_activity_opt'] == 'copy') { $smarty->assign('convertModuleListOptions', get_select_options_with_id(array('Contacts' => $app_list_strings["moduleListSingular"]['Contacts']), '')); } } foreach ($this->defs as $module => $vdef) { $focus = BeanFactory::getBean($module); // skip if we aren't allowed to save this bean if (empty($focus) || !$focus->ACLAccess('save')) { continue; } $focus->fill_in_additional_detail_fields(); foreach ($focus->field_defs as $field => $def) { if (isset($vdef[$ev->view]['copyData']) && $vdef[$ev->view]['copyData']) { if ($module == "Accounts" && $field == 'name') { $focus->name = $this->focus->account_name; } else { if ($module == "Opportunities" && $field == 'amount') { $focus->amount = unformat_number($this->focus->opportunity_amount); } else { if ($module == "Opportunities" && $field == 'name') { if ($opportunityNameInLayout && !empty($this->focus->opportunity_name)) { $focus->name = $this->focus->opportunity_name; } } else { if ($field == "id") { //If it is not a contact, don't copy the ID from the lead if ($module == "Contacts") { $focus->{$field} = $this->focus->{$field}; } } else { if (is_a($focus, "Company") && $field == 'phone_office') { //Special case where company and person have the same field with a different name $focus->phone_office = $this->focus->phone_work; } else { if (strpos($field, "billing_address") !== false && $focus->field_defs[$field]["type"] == "varchar") { $tmp_field = str_replace("billing_", "primary_", $field); $focus->field_defs[$field]["type"] = "text"; if (isset($this->focus->{$tmp_field})) { $focus->{$field} = $this->focus->{$tmp_field}; } } else { if (strpos($field, "shipping_address") !== false && $focus->field_defs[$field]["type"] == "varchar") { $tmp_field = str_replace("shipping_", "primary_", $field); if (isset($this->focus->{$tmp_field})) { $focus->{$field} = $this->focus->{$tmp_field}; } $focus->field_defs[$field]["type"] = "text"; } else { if (isset($this->focus->{$field})) { $focus->{$field} = $this->focus->{$field}; } } } } } } } } } } //Copy over email data $ev->setup($module, $focus, $this->medataDataFile, "modules/Leads/tpls/ConvertLead.tpl", false); $ev->process(); echo $ev->display(false); echo $this->getValidationJS($module, $focus, $vdef[$ev->view]); } echo "</div>"; echo $qsd->getQSScriptsJSONAlreadyDefined(); // need to re-assign bean as it gets overridden by $ev->display $smarty->assign("bean", $this->focus); $smarty->display("modules/Leads/tpls/ConvertLeadFooter.tpl"); }
function SubpanelQuickEdit($module, $view = 'QuickEdit', $proccessOverride = false) { //treat quickedit and quickcreate views as the same if ($view == 'QuickEdit') { $view = 'QuickCreate'; } // locate the best viewdefs to use: 1. custom/module/quickcreatedefs.php 2. module/quickcreatedefs.php 3. custom/module/editviewdefs.php 4. module/editviewdefs.php $source = SugarAutoLoader::existingCustomOne("modules/{$module}/metadata/" . strtolower($view) . 'defs.php'); if (!$source) { $source = SugarAutoLoader::loadWithMetafiles($module, "editviewdefs"); $view = 'EditView'; } $this->ev = new EditView(); $this->ev->view = $view; $this->ev->ss = new Sugar_Smarty(); $_REQUEST['return_action'] = 'SubPanelViewer'; //retrieve bean if id or record is passed in if (!empty($_REQUEST['record']) || !empty($_REQUEST['id'])) { if (!empty($_REQUEST['record']) && empty($_REQUEST['id'])) { $_REQUEST['id'] = $_REQUEST['record']; } $this->ev->focus = BeanFactory::retrieveBean($module, $_REQUEST['id']); //call setup with focus passed in $this->ev->setup($module, $this->ev->focus, $source); } else { //no id, call setup on new bean $this->ev->setup($module, null, $source); } $this->ev->defs['templateMeta']['form']['headerTpl'] = 'include/EditView/header.tpl'; $this->ev->defs['templateMeta']['form']['footerTpl'] = 'include/EditView/footer.tpl'; $this->ev->defs['templateMeta']['form']['buttons'] = array('SUBPANELSAVE', 'SUBPANELCANCEL', 'SUBPANELFULLFORM'); $this->ev->defs['templateMeta']['form']['hideAudit'] = true; $viewEditSource = SugarAutoLoader::existingCustomOne('modules/' . $module . '/views/view.edit.php'); if (!empty($viewEditSource) && !$proccessOverride) { include $viewEditSource; $c = $module . 'ViewEdit'; $customClass = 'Custom' . $c; if (class_exists($customClass)) { $c = $customClass; } if (class_exists($c)) { $view = new $c(); if ($view->useForSubpanel) { $this->defaultProcess = false; //Check if we should use the module's QuickCreate.tpl file. if ($view->useModuleQuickCreateTemplate && SugarAutoLoader::fileExists('modules/' . $module . '/tpls/QuickCreate.tpl')) { $this->ev->defs['templateMeta']['form']['headerTpl'] = 'modules/' . $module . '/tpls/QuickCreate.tpl'; } $view->ev = $this->ev; $view->ss = $this->ev->ss; $view->bean = BeanFactory::getBean($module); $this->ev->formName = 'form_Subpanel' . $this->ev->view . '_' . $module; $view->showTitle = false; // Do not show title since this is for subpanel $view->display(); } } } //if if ($this->defaultProcess && !$proccessOverride) { $this->process($module); } }
function display() { if (!$this->bean->ACLAccess('list')) { ACLController::displayNoAccess(); return; } $module = $GLOBALS['module']; $metadataFile = SugarAutoLoader::loadWithMetafiles($module, 'listviewdefs'); require_once $metadataFile; $this->bean->ACLFilterFieldList($listViewDefs[$module], array("owner_override" => true)); $seed = $this->bean; if (!empty($this->bean->object_name) && isset($_REQUEST[$module . '2_' . strtoupper($this->bean->object_name) . '_offset'])) { //if you click the pagination button, it will populate the search criteria here if (!empty($_REQUEST['current_query_by_page'])) { //The code support multi browser tabs pagination $blockVariables = array('mass', 'uid', 'massupdate', 'delete', 'merge', 'selectCount', 'request_data', 'current_query_by_page', $module . '2_' . strtoupper($this->bean->object_name) . '_ORDER_BY'); if (isset($_REQUEST['lvso'])) { $blockVariables[] = 'lvso'; } $current_query_by_page = unserialize(base64_decode($_REQUEST['current_query_by_page'])); foreach ($current_query_by_page as $search_key => $search_value) { if ($search_key != $module . '2_' . strtoupper($this->bean->object_name) . '_offset' && !in_array($search_key, $blockVariables)) { if (!is_array($search_value)) { $_REQUEST[$search_key] = $GLOBALS['db']->quote($search_value); } else { foreach ($search_value as $key => &$val) { $val = $GLOBALS['db']->quote($val); } $_REQUEST[$search_key] = $search_value; } } } } } if (!empty($_REQUEST['saved_search_select']) && $_REQUEST['saved_search_select'] != '_none') { if (empty($_REQUEST['button']) && (empty($_REQUEST['clear_query']) || $_REQUEST['clear_query'] != 'true')) { $this->saved_search = BeanFactory::getBean('SavedSearch'); $this->saved_search->retrieveSavedSearch($_REQUEST['saved_search_select']); $this->saved_search->populateRequest(); } elseif (!empty($_REQUEST['button'])) { // click the search button, after retrieving from saved_search $_SESSION['LastSavedView'][$_REQUEST['module']] = ''; unset($_REQUEST['saved_search_select']); unset($_REQUEST['saved_search_select_name']); } } $lv = new ListViewSmarty(); $displayColumns = array(); if (!empty($_REQUEST['displayColumns'])) { foreach (explode('|', $_REQUEST['displayColumns']) as $num => $col) { if (!empty($listViewDefs[$module][$col])) { $displayColumns[$col] = $listViewDefs[$module][$col]; } } } else { foreach ($listViewDefs[$module] as $col => $params) { if (!empty($params['default']) && $params['default']) { $displayColumns[$col] = $params; } } } $params = array('massupdate' => true, 'export' => true); if (!empty($_REQUEST['orderBy'])) { $params['orderBy'] = $_REQUEST['orderBy']; $params['overrideOrder'] = true; if (!empty($_REQUEST['sortOrder'])) { $params['sortOrder'] = $_REQUEST['sortOrder']; } } $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 (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': echo $searchForm->displaySavedViews($listViewDefs, $lv, $headers); break; } } else { echo $searchForm->display($headers); } if (!$headers) { return; } /* * Bug 50575 - related search columns not inluded in query in a proper way */ $lv->searchColumns = $searchForm->searchColumns; if (isset($GLOBALS['mod_strings']['LBL_MODULE_NAME_SINGULAR'])) { $seed->module_title = $GLOBALS['mod_strings']['LBL_MODULE_NAME_SINGULAR']; } if (isset($GLOBALS['mod_strings']['LBL_LIST_PARENT_NAME'])) { $seed->parent_title = $GLOBALS['mod_strings']['LBL_LIST_PARENT_NAME']; $seed->parent_module_dir = 'Project'; } $project = BeanFactory::getBean('Project'); $project_query = new SugarQuery(); $project_query->from($project); $project_list = $project->fetchFromQuery($project_query); if (count($project_list)) { $seed->show_link = true; } if (empty($_REQUEST['search_form_only']) || $_REQUEST['search_form_only'] == false) { //Bug 58841 - mass update form was not displayed for non-admin users that should have access if (ACLController::checkAccess($module, 'massupdate') || ACLController::checkAccess($module, 'export')) { $lv->setup($seed, 'include/ListView/ListViewGeneric.tpl', $where, $params); } else { $lv->setup($seed, 'include/ListView/ListViewNoMassUpdate.tpl', $where, $params); } echo $lv->display(); } }
$order_by_name = $focus->merge_module . '2_' . strtoupper($focus->merge_bean->object_name) . '_ORDER_BY'; $lvso = isset($_REQUEST['lvso']) ? $_REQUEST['lvso'] : ""; $request_order_by_name = isset($_REQUEST[$order_by_name]) ? $_REQUEST[$order_by_name] : ""; echo '<form onsubmit="return check_form(\'MassUpdate\');" id="MassUpdate" name="MassUpdate" method="post" action="index.php">' . '<input type="hidden" value="Step2" name="action"/>' . '<input type="hidden" value="true" name="massupdate"/>' . '<input type="hidden" value="false" name="delete"/>' . '<input type="hidden" value="false" name="merge"/>' . '<input type="hidden" value="MergeRecords" name="module"/>' . "<input type='hidden' name='lvso' value='{$lvso}' />" . "<input type='hidden' name='{$order_by_name}' value='{$request_order_by_name}' />"; $focus->populate_search_params($_REQUEST); echo $focus->get_inputs_for_search_params($_REQUEST); $where_clauses = array(); $where_clauses = $focus->create_where_statement(); $where = $focus->generate_where_statement($where_clauses); $ListView = new ListViewSmarty(); $ListView->should_process = true; $ListView->mergeduplicates = false; $ListView->export = false; $ListView->delete = false; $module = $_REQUEST['merge_module']; $metadataFile = SugarAutoLoader::loadWithMetafiles($module, 'listviewdefs'); if ($metadataFile) { require $metadataFile; } $displayColumns = array(); if (!empty($_REQUEST['displayColumns'])) { foreach (explode('|', $_REQUEST['displayColumns']) as $num => $col) { if (!empty($listViewDefs[$module][$col])) { $displayColumns[$col] = $listViewDefs[$module][$col]; } } } else { foreach ($listViewDefs[$module] as $col => $params) { if (!empty($params['default']) && $params['default']) { $displayColumns[$col] = $params; }
/** * search * * Search function run when user goes to Show All and runs a search again. This outputs the search results * calling upon the various listview display functions for each module searched on. * * Todo: Sync this up with SugarSpot.php search method. * * */ function search() { $unified_search_modules = $this->getUnifiedSearchModules(); $unified_search_modules_display = $this->getUnifiedSearchModulesDisplay(); 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'); $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(); if (!empty($_REQUEST['search_modules'])) { foreach (explode(',', $_REQUEST['search_modules']) as $key) { if (isset($unified_search_modules_display[$key]) && !empty($unified_search_modules_display[$key]['visible'])) { $modules_to_search[$key] = $beanList[$key]; } } } $current_user->setPreference('showGSDiv', isset($_REQUEST['showGSDiv']) ? $_REQUEST['showGSDiv'] : 'no', 0, 'search'); $current_user->setPreference('globalSearch', $modules_to_search, 0, 'search'); // save selections to user preference } else { $users_modules = $current_user->getPreference('globalSearch', 'search'); $modules_to_search = array(); if (!empty($users_modules)) { // use user's previous selections foreach ($users_modules as $key => $value) { if (isset($unified_search_modules_display[$key]) && !empty($unified_search_modules_display[$key]['visible'])) { $modules_to_search[$key] = $beanList[$key]; } } } else { foreach ($unified_search_modules_display as $module => $data) { if (!empty($data['visible'])) { $modules_to_search[$module] = $beanList[$module]; } } } $current_user->setPreference('globalSearch', $modules_to_search, 'search'); } $templateFile = SugarAutoLoader::existingCustomOne('modules/Home/UnifiedSearchAdvancedForm.tpl'); echo $this->getDropDownDiv($templateFile); $module_results = array(); $module_counts = array(); $has_results = false; if (!empty($this->query_string)) { foreach ($modules_to_search as $moduleName => $beanName) { $seed = BeanFactory::getBean($moduleName); $lv = new ListViewSmarty(); $lv->lvd->additionalDetails = false; $mod_strings = return_module_language($current_language, $seed->module_dir); //retrieve the original list view defs and store for processing in case of custom layout changes require 'modules/' . $seed->module_dir . '/metadata/listviewdefs.php'; $orig_listViewDefs = $listViewDefs; $defs = SugarAutoLoader::loadWithMetafiles($seed->module_dir, 'listviewdefs'); if ($defs) { require $defs; } if (!isset($listViewDefs) || !isset($listViewDefs[$seed->module_dir])) { continue; } $unifiedSearchFields = array(); $innerJoins = array(); foreach ($unified_search_modules[$moduleName]['fields'] as $field => $def) { $listViewCheckField = strtoupper($field); //check to see if the field is in listview defs if (empty($listViewDefs[$seed->module_dir][$listViewCheckField]['default'])) { //check to see if field is in original list view defs (in case we are using custom layout defs) if (!empty($orig_listViewDefs[$seed->module_dir][$listViewCheckField]['default'])) { //if we are here then the layout has been customized, but the field is still needed for query creation $listViewDefs[$seed->module_dir][$listViewCheckField] = $orig_listViewDefs[$seed->module_dir][$listViewCheckField]; } } //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']); } if (isset($seed->field_defs[$field]['type'])) { $type = $seed->field_defs[$field]['type']; if ($type == 'int' && !is_numeric($this->query_string)) { continue; } } $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 $this->searchFormPath; $searchForm = new $this->searchFormClass($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) . '))'; } else { /* Clear $where from prev. module if in current module $where_clauses */ $where = ''; } $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; $lv->showMassupdateFields = false; $lv->email = false; $lv->setup($seed, 'include/ListView/ListViewNoMassUpdate.tpl', $where, $params, 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] .= "<li class='noBullet' id='whole_subpanel_{$moduleName}'><div id='div_{$moduleName}'><h2>" . $home_mod_strings['LBL_NO_RESULTS_IN_MODULE'] . '</h2></div></li>'; $module_results[$moduleName] .= '<h2>' . $home_mod_strings['LBL_NO_RESULTS_IN_MODULE'] . '</h2>'; } else { $has_results = true; //$module_results[$moduleName] .= "<li class='noBullet' id='whole_subpanel_{$moduleName}'><div id='div_{$moduleName}'>" . $lv->display(false, false) . '</div></li>'; $module_results[$moduleName] .= $lv->display(false, false); } } } if ($has_results) { foreach ($module_counts as $name => $value) { echo $module_results[$name]; } } else { if (empty($_REQUEST['form_only'])) { echo $home_mod_strings['LBL_NO_RESULTS']; echo $home_mod_strings['LBL_NO_RESULTS_TIPS']; } } }
} else { $focus = BeanFactory::getBean($_REQUEST['module'], $_REQUEST['record']); // If the user selected "All records" from the selection menu, we pull up the list // based on the query they used on that popup to relate them to the parent record if (!empty($_REQUEST['select_entire_list']) && $_REQUEST['select_entire_list'] != 'undefined' && isset($_REQUEST['current_query_by_page'])) { $order_by = ''; $current_query_by_page = $_REQUEST['current_query_by_page']; $current_query_by_page_array = unserialize(base64_decode($current_query_by_page)); $module = $current_query_by_page_array['module']; $seed = BeanFactory::getBean($module); if (empty($seed)) { sugar_die($GLOBALS['app_strings']['ERROR_NO_BEAN']); } $where_clauses = ''; require_once 'include/SearchForm/SearchForm2.php'; $searchdefs_file = SugarAutoLoader::loadWithMetafiles($module, 'searchdefs'); if ($searchdefs_file) { require $searchdefs_file; } $searchFields = SugarAutoLoader::loadSearchFields($module); 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) . ')'; } } $query = $seed->create_new_list_query($order_by, $where_clauses); $result = $GLOBALS['db']->query($query, true);
if (!defined('sugarEntry') || !sugarEntry) { die('Not A Valid Entry Point'); } /* * Your installation or use of this SugarCRM file is subject to the applicable * terms available at * http://support.sugarcrm.com/06_Customer_Center/10_Master_Subscription_Agreements/. * If you do not agree to all of the applicable terms or do not have the * authority to bind the entity as an authorized representative, then do not * install or use this SugarCRM file. * * Copyright (C) SugarCRM Inc. All rights reserved. */ require_once 'include/ListView/ListViewSmarty.php'; require SugarAutoLoader::loadWithMetafiles('Project', 'projecttemplate_listviewdefs'); require_once 'include/SearchForm/SearchForm.php'; echo getClassicModuleTitle($mod_strings['LBL_MODULE_NAME'], array($mod_strings['LBL_PROJECT_TEMPLATES_TITLE']), true); $header_text = ''; global $app_strings, $mod_strings; global $app_list_strings; global $current_language; $current_module_strings = return_module_language($current_language, 'Project'); $current_module_strings['LBL_LIST_FORM_TITLE'] = $mod_strings['LBL_PROJECT_TEMPLATES_LIST']; global $urlPrefix; global $currentModule; global $theme; global $current_user; // focus_list is the means of passing data to a ListView. global $focus_list; // clear the display columns back to default when clear query is called
function generateSearchWhere($module, $query) { //this function is similar with function prepareSearchForm() in view.list.php $seed = BeanFactory::newBean($module); if (SugarAutoLoader::fileExists('modules/' . $module . '/SearchForm.html')) { if (SugarAutoLoader::fileExists('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. // Currently, massupdate will not generate 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'; $searchdefs_file = SugarAutoLoader::loadWithMetafiles($module, 'searchdefs'); if ($searchdefs_file) { require $searchdefs_file; } $searchFields = SugarAutoLoader::loadSearchFields($module); 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 = getSearchForm($seed, $module); $searchForm->setup($searchdefs, $searchFields, '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; }
/* * Your installation or use of this SugarCRM file is subject to the applicable * terms available at * http://support.sugarcrm.com/06_Customer_Center/10_Master_Subscription_Agreements/. * If you do not agree to all of the applicable terms or do not have the * authority to bind the entity as an authorized representative, then do not * install or use this SugarCRM file. * * Copyright (C) SugarCRM Inc. All rights reserved. */ require_once 'include/contextMenus/contextMenu.php'; require_once 'modules/Reports/schedule/ReportSchedule.php'; require_once 'modules/Reports/ListViewReports.php'; require_once 'modules/Reports/SearchFormReports.php'; require_once 'include/ListView/ListViewSmarty.php'; require SugarAutoLoader::loadWithMetafiles('Reports', 'listviewdefs'); global $published_report_titles; global $my_report_titles; global $current_user; global $modules_report; global $mod_strings; global $module_map; global $report_modules; $savedReportsSeed = BeanFactory::getBean('Reports'); $lv = new ListViewReports(); if (empty($_REQUEST['search_form_only'])) { echo "<div class='listViewBody'>"; } if (isset($_REQUEST['Reports2_SAVEDREPORT_offset'])) { //if you click the pagination button, it will populate the search criteria here if (!empty($_REQUEST['current_query_by_page'])) {
/** * Return the search defs for a particular module. * * @static * @param $module */ public static function retrieveSearchDefs($module) { $searchFields = SugarAutoLoader::loadSearchFields($module); $searchdefs = array(); $file = SugarAutoLoader::loadWithMetafiles($module, 'searchdefs'); if ($file) { require $file; } return array('searchdefs' => $searchdefs, 'searchFields' => $searchFields); }
protected function getSearchDefs($module) { $searchdefs_file = SugarAutoLoader::loadWithMetafiles($module, 'searchdefs'); if ($searchdefs_file) { require $searchdefs_file; } return isset($searchdefs) ? $searchdefs : array(); }
function get_admin_fts_list($where, $isMultiSelect = false) { global $app_strings, $app_list_strings, $current_language, $sugar_version, $sugar_config, $current_user; global $urlPrefix, $currentModule, $theme; $current_module_strings = return_module_language($current_language, 'KBDocuments'); // focus_list is the means of passing data to a ListView. global $focus_list; require_once 'include/ListView/ListViewSmarty.php'; require_once SugarAutoLoader::loadWithMetafiles('KBDocuments', 'listviewdefs'); require_once 'modules/KBDocuments/KBListViewData.php'; global $app_strings; global $app_list_strings; global $current_language; $current_module_strings = return_module_language($current_language, 'KBDocuments'); global $urlPrefix; global $currentModule; global $theme; 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(); $seedCase = BeanFactory::getBean('KBDocuments'); // seed bean // setup listview smarty $lv = new ListViewSmarty(); $lv->lvd = new KBListViewData(); $lv->export = false; $lv->select = false; $lv->delete = false; $_REQUEST['action'] = 'index'; $displayColumns = array(); // check $_REQUEST if new display columns from post if (!empty($_REQUEST['displayColumns'])) { foreach (explode('|', $_REQUEST['displayColumns']) as $num => $col) { if (!empty($listViewDefs['KBDocuments'][$col])) { $displayColumns[$col] = $listViewDefs['KBDocuments'][$col]; } } } elseif (!empty($savedDisplayColumns)) { // use user defined display columns from preferences $displayColumns = $savedDisplayColumns; } else { // use columns defined in listviewdefs for default display columns foreach ($listViewDefs['KBDocuments'] as $col => $params) { if (!empty($params['default']) && $params['default']) { $displayColumns[$col] = $params; } } } $params = array('massupdate' => true); // setup ListViewSmarty params if (!empty($_REQUEST['orderBy'])) { // order by coming from $_REQUEST $params['orderBy'] = $_REQUEST['orderBy']; $params['overrideOrder'] = true; if (!empty($_REQUEST['sortOrder'])) { $params['sortOrder'] = $_REQUEST['sortOrder']; } } //make sure the column names (array keys) are in upper case $displayColumns = array_change_key_case($displayColumns, CASE_UPPER); $lv->displayColumns = $displayColumns; // use the stored query if there is one 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 // first save columns $current_user->setPreference('ListViewDisplayColumns', $displayColumns, 0, $currentModule); 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, "kbdocuments"); // builds the where clause from search field inputs if (count($where_clauses) > 0) { $where = implode(' and ', $where_clauses); } $GLOBALS['log']->info("Here is the where clause for the list view: {$where}"); } $lv->export = false; $lv->show_mass_update_form = false; $lv->show_action_dropdown = false; $lv->delete = false; $lv->select = false; $lv->setup($seedCase, 'modules/KBDocuments/AdminSearchListView.tpl', $where, $params); $lv->show_mass_update_form = false; $savedSearchName = empty($_REQUEST['saved_search_select_name']) ? '' : ' - ' . $_REQUEST['saved_search_select_name']; $ret_str = $lv->display(false); $json = getJSONobj(); return $ret_str; }
* authority to bind the entity as an authorized representative, then do not * install or use this SugarCRM file. * * Copyright (C) SugarCRM Inc. All rights reserved. */ require_once 'include/ListView/ListViewSmarty.php'; global $app_strings, $app_list_strings, $current_language, $currentModule, $mod_strings; echo getClassicModuleTitle('SavedSearch', array($mod_strings['LBL_MODULE_TITLE']), false); echo get_form_header($mod_strings['LBL_SEARCH_FORM_TITLE'], '', false); $search_form = new XTemplate('modules/SavedSearch/SearchForm.html'); $search_form->assign('MOD', $mod_strings); $search_form->assign('APP', $app_strings); $search_form->assign('JAVASCRIPT', get_clear_form_js()); if (isset($_REQUEST['name'])) { $search_form->assign('name', to_html($_REQUEST['name'])); } if (isset($_REQUEST['search_module'])) { $search_form->assign('search_module', to_html($_REQUEST['search_module'])); } $search_form->parse('main'); $search_form->out('main'); if (!isset($where)) { $where = "assigned_user_id = {$current_user->id}"; } echo '<br />' . get_form_header($mod_strings['LBL_LIST_FORM_TITLE'], '', false); $savedSearch = BeanFactory::getBean('SavedSearch'); $lv = new ListViewSmarty(); require SugarAutoLoader::loadWithMetafiles('SavedSearch', 'listviewdefs'); $lv->displayColumns = $listViewDefs['SavedSearch']; $lv->setup($savedSearch, 'include/ListView/ListViewGeneric.tpl', $where); $lv->display(true);