function constructAjax() { require_once 'modules/ModuleBuilder/MB/AjaxCompose.php'; $ajax = new AjaxCompose(); switch ($this->editLayout) { case MB_WIRELESSBASICSEARCH: case MB_WIRELESSADVANCEDSEARCH: $searchLabel = 'LBL_WIRELESSSEARCH'; break; default: if (isModuleBWC($this->editModule)) { $searchLabel = 'LBL_' . strtoupper($this->editLayout); } else { $searchLabel = 'LBL_FILTER_SEARCH'; } break; } $layoutLabel = 'LBL_LAYOUTS'; $layoutView = 'layouts'; if (in_array($this->editLayout, array(MB_WIRELESSBASICSEARCH, MB_WIRELESSADVANCEDSEARCH))) { $layoutLabel = 'LBL_WIRELESSLAYOUTS'; $layoutView = 'wirelesslayouts'; } if ($this->fromModuleBuilder) { $ajax->addCrumb(translate('LBL_MODULEBUILDER', 'ModuleBuilder'), 'ModuleBuilder.main("mb")'); $ajax->addCrumb($_REQUEST['view_package'], 'ModuleBuilder.getContent("module=ModuleBuilder&action=package&package=' . $_REQUEST['view_package'] . '")'); $ajax->addCrumb($this->editModule, 'ModuleBuilder.getContent("module=ModuleBuilder&action=module&view_package=' . $_REQUEST['view_package'] . "&view_module={$this->editModule}" . '")'); $ajax->addCrumb(translate($layoutLabel, 'ModuleBuilder'), 'ModuleBuilder.getContent("module=ModuleBuilder&MB=true&action=wizard&view_module=' . $this->editModule . '&view_package=' . $_REQUEST['view_package'] . '")'); if ($layoutLabel == 'LBL_LAYOUTS') { $ajax->addCrumb(translate('LBL_SEARCH_FORMS', 'ModuleBuilder'), 'ModuleBuilder.getContent("module=ModuleBuilder&MB=true&action=wizard&view=search&view_module=' . $this->editModule . '&view_package=' . $_REQUEST['view_package'] . '")'); } $ajax->addCrumb(translate($searchLabel, 'ModuleBuilder'), ''); } else { $ajax->addCrumb(translate('LBL_STUDIO', 'ModuleBuilder'), 'ModuleBuilder.main("studio")'); $ajax->addCrumb($this->translatedEditModule, 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view_module=' . $this->editModule . '")'); $ajax->addCrumb(translate($layoutLabel, 'ModuleBuilder'), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view=' . $layoutView . '&view_module=' . $this->editModule . '")'); if ($layoutLabel == 'LBL_LAYOUTS') { $ajax->addCrumb(translate('LBL_SEARCH_FORMS', 'ModuleBuilder'), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view=search&view_module=' . $this->editModule . '")'); } $ajax->addCrumb(translate($searchLabel, 'ModuleBuilder'), ''); } $this->title = $searchLabel; return $ajax; }
function isQuickCreateValid($module, $panel_id) { //try to retrieve the subpanel defs global $beanList; $isValid = false; $layout_defs = $this->getSubpanelDefs($_REQUEST['module']); //For Sidecar modules return false as we want caller to add an //onClick routed to the SubPanelTiles.js subp_nav_sidecar function if (!isModuleBWC($module)) { return false; } //lets check to see if the subpanel buttons are defined, and if they extend quick create //If no buttons are defined, then the default ones are used which do NOT use quick create if (!empty($panel_id) && !empty($layout_defs) && is_array($layout_defs) && !empty($layout_defs[$_REQUEST['module']]) && !empty($layout_defs[$_REQUEST['module']]['subpanel_setup'][$panel_id]) && !empty($layout_defs[$_REQUEST['module']]['subpanel_setup'][$panel_id]['top_buttons']) && is_array($layout_defs[$_REQUEST['module']]['subpanel_setup'][$panel_id]['top_buttons'])) { //we have the buttons from the definitions, lets see if they enabled for quickcreate foreach ($layout_defs[$_REQUEST['module']]['subpanel_setup'][$panel_id]['top_buttons'] as $buttonClasses) { $buttonClass = ''; //get the button class if (isset($buttonClasses['widget_class'])) { $buttonClass = $buttonClasses['widget_class']; } //include the button class and see if it extends quick create $className = 'SugarWidget' . $buttonClass; if (SugarAutoLoader::requireWithCustom('include/generic/SugarWidgets/' . $className . '.php')) { if (class_exists($className)) { $button = new $className(); //set valid flag to true if this class extends quickcreate button if ($button instanceof SugarWidgetSubPanelTopButtonQuickCreate) { $isValid = true; } } } } } //if only default buttons are used, or none of the buttons extended quick create, then there is no need to proceed if (!$isValid) { return false; } //So our create buttons are defined, now lets check for the proper quick create meta files if (SugarAutoLoader::existingCustomOne('modules/' . $module . '/metadata/quickcreatedefs.php')) { return true; } return false; }
/** * Upgrade Task to Run */ public function run() { if (version_compare($this->from_version, '7.0.0', '<') && $this->toFlavor('ent')) { $settings = Opportunity::getSettings(); if ($settings['opps_view_by'] !== 'RevenueLineItems') { $this->log('Not using Revenue Line Items; Skipping Upgrade Script'); return; } $fields = array('sales_stage', 'probability', 'commit_stage'); require_once 'modules/ModuleBuilder/parsers/ParserFactory.php'; $this->log('Processing Opportunity RecordView'); $recordViewDefsParser = ParserFactory::getParser(MB_RECORDVIEW, 'Opportunities', null, null, 'base'); if ($this->removeFields($recordViewDefsParser, $fields)) { $recordViewDefsParser->handleSave(false); } $this->log('Processing Opportunity ListView'); $recordViewDefsParser = ParserFactory::getParser(MB_LISTVIEW, 'Opportunities', null, null, 'base'); if ($this->removeFields($recordViewDefsParser, $fields)) { $recordViewDefsParser->handleSave(false); } $modules = array('Accounts', 'Contacts', 'Campaigns', 'Documents'); global $modInvisList; if (array_search('Project', $modInvisList)) { $modules[] = 'Project'; } foreach ($modules as $module) { $this->log('Processing Opportunity SubPanel for ' . $module . ' module'); if (isModuleBWC($module)) { require_once 'modules/ModuleBuilder/parsers/views/SubpanelMetaDataParser.php'; $pf = new SubpanelMetaDataParser('opportunities', $module); } else { $pf = ParserFactory::getParser(MB_LISTVIEW, $module, null, 'opportunities'); } if ($this->removeFields($pf, $fields)) { $pf->handleSave(false); } } } }
protected function fixModule($module) { if (!isModuleBWC($module)) { $this->log("{$module} is not BWC, not checking"); return; } $filename = "custom/modules/{$module}/metadata/detailviewdefs.php"; if (file_exists($filename)) { $this->log("Checking {$filename}"); $viewdefs = array(); include $filename; if (empty($viewdefs[$module]) || empty($viewdefs[$module]['DetailView']['panels'])) { $this->log("Could not find viewdefs, skipping"); return; } $modified = false; foreach ($viewdefs[$module]['DetailView']['panels'] as $pname => $panel) { foreach ($panel as $rid => $row) { foreach ($row as $fid => $field) { // Check that the field is one of the broken fields and has broken label // and no custom code if (is_array($field) && !empty($field['name']) && !empty($field['label']) && !isset($field['customCode']) && !empty($this->fields_names[$field['name']]) && $this->fields_names[$field['name']]['label'] == $field['label']) { // Reset field to using proper custom code $newfield = array('name' => $field['name'], 'customCode' => $this->fields_names[$field['name']]['customCode']); $viewdefs[$module]['DetailView']['panels'][$pname][$rid][$fid] = $newfield; $modified = true; } } } } if ($modified) { $this->log("Updating {$filename}"); write_array_to_file("viewdefs['{$module}']['DetailView']", $viewdefs[$module]['DetailView'], $filename); } } }
public function display() { global $mod_strings, $locale; $ajax = new AjaxCompose(); $smarty = new Sugar_Smarty(); if (isset($_REQUEST['MB']) && $_REQUEST['MB'] == "1") { $smarty->assign("MB", $_REQUEST['MB']); $smarty->assign("view_package", $_REQUEST['view_package']); } if (!empty($_REQUEST['selected_lang'])) { $selected_lang = $_REQUEST['selected_lang']; } else { $selected_lang = $locale->getAuthenticatedUserLanguage(); } if (empty($selected_lang)) { $selected_lang = $GLOBALS['sugar_config']['default_language']; } $smarty->assign('available_languages', get_languages()); $smarty->assign('selected_lang', $selected_lang); ksort($this->properties); if (isset($this->properties['width'])) { $smarty->assign('defaultWidths', SidecarListLayoutMetaDataParser::getDefaultWidths()); } // BWC modules width are in %, sidecar modules widths are in pixels. $smarty->assign('widthUnit', isModuleBWC($this->editModule) ? '%' : 'px'); $smarty->assign("properties", $this->properties); $smarty->assign("mod_strings", $mod_strings); $smarty->assign('APP', $GLOBALS['app_strings']); $smarty->assign("view_module", $this->editModule); $smarty->assign("subpanel", $this->subpanel); if (isset($this->editPackage)) { $smarty->assign("view_package", $this->editPackage); } $ajax->addSection('east', translate('LBL_SECTION_PROPERTIES', 'ModuleBuilder'), $smarty->fetch('modules/ModuleBuilder/tpls/editProperty.tpl')); echo $ajax->getJavascript(); }
/** * Checks if the user updated the bean from PMSE_Inbox * * @param type $bean * @return boolean */ public function isPMSEEdit($bean) { if (isset($_REQUEST['moduleName']) && isModuleBWC($_REQUEST['moduleName'])) { $url = $_REQUEST['module']; } else { $url = $_REQUEST['__sugar_url']; } if (strpos($url, 'pmse') === false) { return false; } else { $this->logger->debug("Start Event {$bean->id} can not be triggered by PMSE modules."); return true; } }
protected function getButtons($history, $disableLayout, $params) { $buttons = array(); if (!$this->fromModuleBuilder) { $buttons[] = array('id' => 'saveBtn', 'text' => translate('LBL_BTN_SAVE'), 'actionScript' => "onclick='if(Studio2.checkGridLayout(\"{$this->editLayout}\")) Studio2.handleSave();'", 'disabled' => $disableLayout); $buttons[] = array('id' => 'publishBtn', 'text' => translate('LBL_BTN_SAVEPUBLISH'), 'actionScript' => "onclick='if(Studio2.checkGridLayout(\"{$this->editLayout}\")) Studio2.handlePublish();'", 'disabled' => $disableLayout); } else { $buttons[] = array('id' => 'saveBtn', 'text' => $GLOBALS['mod_strings']['LBL_BTN_SAVE'], 'actionScript' => "onclick='if(Studio2.checkGridLayout(\"{$this->editLayout}\")) Studio2.handlePublish();'", 'disabled' => $disableLayout); } $buttons[] = array('id' => 'spacer', 'width' => '33px'); $buttons[] = array('id' => 'historyBtn', 'text' => translate('LBL_HISTORY'), 'actionScript' => "onclick='ModuleBuilder.history.browse(\"{$this->editModule}\", \"{$this->editLayout}\")'", 'disabled' => $disableLayout); if (!$params) { $action = 'ModuleBuilder.history.revert(' . '"' . $this->editModule . '",' . '"' . $this->editLayout . '",' . '"' . $history->getLast() . '",' . '""' . ')'; } else { $action = 'ModuleBuilder.history.resetToDefault(' . '"' . $this->editModule . '",' . '"' . $this->editLayout . '"' . ')'; } $buttons[] = array('id' => 'historyDefault', 'text' => translate('LBL_RESTORE_DEFAULT'), 'actionScript' => "onclick='{$action}'", 'disabled' => $disableLayout); $implementation = $this->parser->getImplementation(); if ($this->editLayout == MB_DETAILVIEW || $this->editLayout == MB_QUICKCREATE) { $buttons[] = array('id' => 'copyFromEditView', 'text' => translate('LBL_COPY_FROM_EDITVIEW'), 'actionScript' => "onclick='ModuleBuilder.copyFromView(\"{$this->editModule}\", \"{$this->editLayout}\")'", 'disabled' => $disableLayout); } elseif (!empty($GLOBALS['sugar_config']['roleBasedViews']) && !isModuleBWC($this->editModule) && ($this->editLayout == MB_RECORDVIEW || $this->editLayout == MB_WIRELESSEDITVIEW || $this->editLayout == MB_WIRELESSDETAILVIEW) && $implementation->isDeployed()) { $availableRoles = $this->getRoleList($implementation); $buttons[] = array('type' => 'spacer', 'width' => '33px'); $buttons[] = array('type' => 'label', "text" => translate('LBL_ROLE') . ":"); $buttons[] = array('id' => 'roleList', 'type' => 'enum', 'actionScript' => 'style="max-width:150px" onchange="ModuleBuilder.switchLayoutRole(this)"', "options" => $this->getAvailableRoleList($implementation), "selected" => empty($params['role']) ? "" : $params['role']); if (!empty($params['role'])) { $rolesWithMetadata = $this->getRoleListWithMetadata($availableRoles, $params['role']); $buttons[] = array('id' => 'copyBtn', 'text' => translate('LBL_BTN_COPY_FROM'), 'actionScript' => "onclick='ModuleBuilder.copyLayoutFromRole();'", 'disabled' => !count($rolesWithMetadata)); } } return $buttons; }
/** * Load the layout def file and associate the definition with a variable in the file. */ function open_layout_defs($reload = false, $layout_def_key = '', $original_only = false) { require_once 'include/MetaDataManager/MetaDataManager.php'; $mm = MetaDataManager::getManager(); $layout_defs[$this->_focus->module_dir] = array(); $layout_defs[$layout_def_key] = array(); $def_path = array(); if (empty($this->layout_defs) || $reload || !empty($layout_def_key) && !isset($layout_defs[$layout_def_key])) { if (!$original_only) { if (isModuleBWC($this->_focus->module_dir)) { $def_path = array('modules/' . $this->_focus->module_dir . '/metadata/' . ($this->platform == 'mobile' ? 'wireless.' : '') . 'subpaneldefs.php'); $def_path[] = SugarAutoLoader::loadExtension($this->platform == 'mobile' ? 'wireless_subpanels' : 'layoutdefs', $this->_focus->module_dir); foreach (SugarAutoLoader::existing($def_path) as $file) { require $file; } } else { $viewdefs = $mm->getModuleLayouts($this->_focus->module_dir); $viewdefs = !empty($viewdefs['subpanels']['meta']['components']) ? $viewdefs['subpanels']['meta']['components'] : array(); } } $layoutDefsKey = !empty($layout_def_key) ? $layout_def_key : $this->_focus->module_dir; // convert sidecar subpanels to the array the SubpanelDefinitions are looking for if ($this->_focus instanceof SugarBean && !isModuleBWC($this->_focus->module_dir) && isset($viewdefs)) { require_once 'include/MetaDataManager/MetaDataConverter.php'; $metaDataConverter = new MetaDataConverter(); $layout_defs[$layoutDefsKey] = $metaDataConverter->toLegacySubpanelLayoutDefs($viewdefs, $this->_focus); } $this->layout_defs = $layout_defs[$layoutDefsKey]; } }
/** * Retrieve the subpanel definitions for a given SugarBean object. Unforunately we can't reuse * any of the SubPanelDefinion.php functions. * * @param SugarBean $bean * @return array The subpanel definitions. */ private function getSubpanelDefs($bean) { if (empty($bean->module_dir)) { return array(); } $layout_defs = array(); // Handle things differently for BWC modules if (isModuleBWC($bean->module_dir)) { foreach (SugarAutoLoader::existingCustom('modules/' . $bean->module_dir . '/metadata/subpaneldefs.php') as $file) { require $file; } $defs = SugarAutoLoader::loadExtension('layoutdefs', $bean->module_dir); if ($defs) { require $defs; } } else { // Handle things the new way foreach (SugarAutoLoader::existingCustom('modules/' . $bean->module_dir . '/clients/base/layouts/subpanels/subpanels.php') as $file) { require $file; } // Add in any studio customizations $ext = 'custom/modules/' . $bean->module_dir . '/Ext/clients/base/layouts/subpanels/subpanels.ext.php'; if (SugarAutoLoader::fileExists($ext)) { require $ext; } // Massage defs to look like old style for use in the rename process if (isset($viewdefs[$bean->module_dir]['base']['layout']['subpanels']['components'])) { $layout_defs = $this->getSidecarSubpanelDefsAsLegacy($viewdefs[$bean->module_dir]['base']['layout']['subpanels']['components'], $bean); } } return isset($layout_defs[$bean->module_dir]['subpanel_setup']) ? $layout_defs[$bean->module_dir]['subpanel_setup'] : $layout_defs; }
/** * Gets the file data array needed for the upgraders to process the upgrade * * @param string $file * @param string $module * @param string $client * @param string $type * @param string $package * @param bool $deployed * @param bool $sidecar Is this a sidecar view? * @param bool $subpanels Is this a subpanel view * @return array Array of file params if found, false otherwise */ public function getUpgradeFileParams($file, $module, $client, $type = 'base', $package = null, $deployed = true, $sidecar = false, $subpanels = false) { $this->logUpgradeStatus("Candidate for upgrade: {$file}"); // Timestamp for history files $timestamp = null; // Handle history file handling different $history = is_numeric(substr($file, -4)); // In the case of undeployed modules, type may be set to base // If it is, and there is a history file, set type to history // This is primarily for saving new defs using the MetaDataFiles // class to get the correct name of the metadata file if ($history && !$deployed && $type == 'base') { $type = 'history'; } // if the module is not among active, not upgrading it for now, but letting // undeployed get through to the next step of validation if (empty($GLOBALS['beanList'][$module]) && $client != 'wireless' && $deployed) { $this->logUpgradeStatus("Not upgrading {$file}: Module {$module} is deployed but not in the module list"); return false; } // If this is an undeployed module and a history file, stop. We only // upgrade history files for deployed modules. if (!$deployed && $history) { $this->logUpgradeStatus("Not upgrading {$file}: This {$module} module is not deployed and this file is a history file"); return false; } if ($client == 'base' && isModuleBWC($module) && !$subpanels) { // if the module is in BWC, do not upgrade its views in base client $this->logUpgradeStatus("Not upgrading {$file}: BWC module"); return false; } // Only hit history files for history types with a timestamp // Unless we are looking at undeployed modules if ($history && $type != 'history' || !$history && $type == 'history' && $deployed) { $this->logUpgradeStatus("Not upgrading {$file}: wrong history format"); return false; } if ($history) { $parts = explode(':', str_replace('.php_', ':', $file)); $filename = basename($parts[0]); $timestamp = $parts[1]; } else { $filename = basename($file, '.php'); } if ($subpanels || !empty($this->legacyMetaDataFileNames[$client]) && in_array($filename, $this->legacyMetaDataFileNames[$client])) { // Success! We have a full file path. Add this module to the stack $this->addUpgradeModule($module); return array('client' => $client, 'module' => $module, 'type' => $type, 'basename' => $filename, 'timestamp' => $timestamp, 'fullpath' => $file, 'package' => $package, 'deployed' => $deployed, 'sidecar' => $sidecar, 'viewtype' => $this->getViewTypeFromFilename($filename, $client, $type, $file)); } $this->logUpgradeStatus("Not upgrading {$file}: no file name for {$filename}"); return false; }
/** * Format a link to a record. * * @param SugarBean $focus The record. * @return string The formatted HTML link. */ function get_href_link($focus) { global $sugar_config; $link = $sugar_config['site_url']; if (isModuleBWC($focus->module_name)) { $link .= "/#bwc/index.php?module={$focus->module_dir}&action=DetailView&record={$focus->id}"; } else { $link .= '/#' . buildSidecarRoute($focus->module_dir, $focus->id); } if (!empty($focus->name)) { $label = $focus->name; } else { $label = translate('LBL_EMAIL_LINK_RECORD', $focus->module_dir); } return '<a href="' . $link . '">' . $label . '</a>'; }
public function action_searchViewSave() { $packageName = isset($_REQUEST['view_package']) ? $_REQUEST['view_package'] : null; // Bug 56789 - Set the client from the view to ensure the proper viewdef file $client = MetaDataFiles::getClientByView($_REQUEST['view']); if (isModuleBWC($_REQUEST['view_module'])) { $parser = new SearchViewMetaDataParser($_REQUEST['view'], $_REQUEST['view_module'], $packageName, $client); } else { $client = empty($client) ? 'base' : $client; $parser = new SidecarFilterLayoutMetaDataParser($_REQUEST['view_module'], $packageName, $client); } $parser->handleSave(); //Repair or create a custom SearchFields.php file as needed $module_name = $_REQUEST['view_module']; global $beanList; if (isset($beanList[$module_name]) && $beanList[$module_name] != "") { $objectName = BeanFactory::getObjectName($module_name); //Load the vardefs for the module to pass to TemplateRange VardefManager::loadVardef($module_name, $objectName, true); global $dictionary; $vardefs = $dictionary[$objectName]['fields']; TemplateRange::repairCustomSearchFields($vardefs, $module_name, $packageName); } $this->view = 'searchView'; }
public function getVariableMap($module) { if (isModuleBWC($module)) { $variableMap = array(MB_EDITVIEW => 'EditView', MB_DETAILVIEW => 'DetailView', MB_QUICKCREATE => 'QuickCreate'); $hideQuickCreateForModules = array('KBDocuments', 'Campaigns', 'Quotes', 'ProductTemplates', 'ProjectTask'); if (in_array($module, $hideQuickCreateForModules)) { if (isset($variableMap['quickcreate'])) { unset($variableMap['quickcreate']); } } if ($module == 'KBDocuments') { $variableMap = array(); } } else { $variableMap = array(MB_RECORDVIEW => 'record'); } return $variableMap; }
/** * Sets and gets a list of subpanels provided to other modules * * @return array */ public function getProvidedSubpanels() { if (isModuleBWC($this->module)) { return $this->getBWCProvidedSubpanels(); } return $this->getSidecarProvidedSubpanels(); }
/** * Added for bug #40941 * Deletes the field from DetailView and editView of the appropriate module * after the relatioship is deleted in delete() function above. * @param $relationship The relationship that is getting deleted * return null */ private function removeFieldsFromDeployedLayout($relationship) { // many-to-many relationships don't have fields so if we have a many-to-many we can just skip this... if ($relationship->getType() == MB_MANYTOMANY) { return false; } $successful = true; $layoutAdditions = $relationship->buildFieldsToLayouts(); foreach ($layoutAdditions as $deployedModuleName => $fieldName) { // Handle decision making on views for BWC/non-BWC modules if (isModuleBWC($deployedModuleName)) { $views = array(MB_EDITVIEW, MB_DETAILVIEW); } else { $views = array(MB_RECORDVIEW); } foreach ($views as $view) { $parser = ParserFactory::getParser($view, $deployedModuleName); $parser->removeField($fieldName); $parser->handleSave(false); } } return $successful; }
/** * Create a new parser * * @param string $view The view, for example EditView or ListView. For search views, use advanced_search or basic_search * @param string $moduleName Module name * @param string $packageName Package name. If present implies that we are being called from ModuleBuilder * @param string $client The view client (e.g. portal, wireless, etc.) * @param array $params Additional parser parameters * @return AbstractMetaDataParser */ public static function getParser($view, $moduleName, $packageName = null, $subpanelName = null, $client = '', array $params = array()) { $GLOBALS['log']->info("ParserFactory->getParser({$view},{$moduleName},{$packageName},{$subpanelName},{$client} )"); $sm = null; $lView = strtolower($view); if (empty($packageName) || $packageName == 'studio') { $packageName = null; //For studio modules, check for view parser overrides $parser = self::checkForStudioParserOverride($view, $moduleName, $packageName); if ($parser) { return $parser; } $sm = StudioModuleFactory::getStudioModule($moduleName); //If we didn't find a specofic parser, see if there is a view to type mapping foreach ($sm->sources as $file => $def) { if (!empty($def['view']) && $def['view'] == $view && !empty($def['type'])) { $lView = strtolower($def['type']); break; } } } switch ($lView) { case MB_RECORDVIEW: require_once 'modules/ModuleBuilder/parsers/views/SidecarGridLayoutMetaDataParser.php'; return new SidecarGridLayoutMetaDataParser($view, $moduleName, $packageName, 'base', $params); case MB_EDITVIEW: case MB_DETAILVIEW: case MB_QUICKCREATE: require_once 'modules/ModuleBuilder/parsers/views/GridLayoutMetaDataParser.php'; return new GridLayoutMetaDataParser($view, $moduleName, $packageName); case MB_WIRELESSEDITVIEW: case MB_WIRELESSDETAILVIEW: case MB_PORTALRECORDVIEW: case MB_PORTALDETAILVIEW: case MB_PORTALEDITVIEW: if (empty($client)) { $client = MB_WIRELESS; if ($lView == MB_PORTALRECORDVIEW || $lView == MB_PORTALDETAILVIEW || $lView == MB_PORTALEDITVIEW) { $client = MB_PORTAL; } } require_once 'modules/ModuleBuilder/parsers/views/SidecarGridLayoutMetaDataParser.php'; return new SidecarGridLayoutMetaDataParser($view, $moduleName, $packageName, $client, $params); case MB_WIRELESSLISTVIEW: case MB_PORTALLISTVIEW: // Handle client settings if we can if (empty($client)) { $client = MB_WIRELESS; if ($lView == MB_PORTALLISTVIEW) { $client = MB_PORTAL; } } require_once 'modules/ModuleBuilder/parsers/views/SidecarListLayoutMetaDataParser.php'; return new SidecarListLayoutMetaDataParser($view, $moduleName, $packageName, $client); case MB_BASICSEARCH: case MB_ADVANCEDSEARCH: case MB_WIRELESSBASICSEARCH: case MB_WIRELESSADVANCEDSEARCH: // Make sure we have the right client if ($lView == MB_WIRELESSBASICSEARCH || $lView == MB_WIRELESSADVANCEDSEARCH) { $client = MB_WIRELESS; } // When it comes to search, mobile is like BWC if (isModuleBWC($moduleName) || $client == MB_WIRELESS) { require_once 'modules/ModuleBuilder/parsers/views/SearchViewMetaDataParser.php'; return new SearchViewMetaDataParser($view, $moduleName, $packageName, $client); } require_once 'modules/ModuleBuilder/parsers/views/SidecarFilterLayoutMetaDataParser.php'; $client = empty($client) ? 'base' : $client; return new SidecarFilterLayoutMetaDataParser($moduleName, $packageName, $client); case MB_LISTVIEW: if ($subpanelName == null) { if (isModuleBWC($moduleName)) { require_once 'modules/ModuleBuilder/parsers/views/ListLayoutMetaDataParser.php'; return new ListLayoutMetaDataParser(MB_LISTVIEW, $moduleName, $packageName); } else { require_once 'modules/ModuleBuilder/parsers/views/SidecarListLayoutMetaDataParser.php'; return new SidecarListLayoutMetaDataParser(MB_SIDECARLISTVIEW, $moduleName, $packageName, 'base'); } } else { if (isModuleBWC($moduleName)) { require_once 'modules/ModuleBuilder/parsers/views/SubpanelMetaDataParser.php'; return new SubpanelMetaDataParser($subpanelName, $moduleName, $packageName); } else { // $client can be empty for all other Parsers, however SidecarSubpanelLayout needs it set, therefore if its blank its base $client = empty($client) ? 'base' : $client; require_once 'modules/ModuleBuilder/parsers/views/SidecarSubpanelLayoutMetaDataParser.php'; return new SidecarSubpanelLayoutMetaDataParser($subpanelName, $moduleName, $packageName, $client); } } case MB_DASHLET: case MB_DASHLETSEARCH: require_once 'modules/ModuleBuilder/parsers/views/DashletMetaDataParser.php'; return new DashletMetaDataParser($view, $moduleName, $packageName); case MB_SIDECARPOPUPVIEW: case MB_SIDECARDUPECHECKVIEW: require_once 'modules/ModuleBuilder/parsers/views/SidecarListLayoutMetaDataParser.php'; return new SidecarListLayoutMetaDataParser($view, $moduleName, $packageName, 'base'); case MB_POPUPLIST: case MB_POPUPSEARCH: require_once 'modules/ModuleBuilder/parsers/views/PopupMetaDataParser.php'; return new PopupMetaDataParser($view, $moduleName, $packageName); case MB_LABEL: require_once 'modules/ModuleBuilder/parsers/parser.label.php'; return new ParserLabel($moduleName, $packageName); case MB_VISIBILITY: require_once 'modules/ModuleBuilder/parsers/parser.visibility.php'; return new ParserVisibility($moduleName, $packageName); default: $parser = self::checkForParserClass($view, $moduleName, $packageName); if ($parser) { return $parser; } } $GLOBALS['log']->fatal("ParserFactory: cannot create ModuleBuilder Parser {$view}"); }
/** * Get the link name for a subpanel using witchcraft and wizardry * @param string $subpanelName - this is the name of the subpanel * @param string $loadedModule - this is the name of the module that is loaded * @return string the linkname for the subpanel */ protected function getLinkName($subpanelName, $loadedModule) { if (isModuleBWC($loadedModule) && !file_exists("modules/{$loadedModule}/clients/" . $this->getViewClient() . "/layouts/subpanels/subpanels.php")) { @(include "modules/{$loadedModule}/metadata/subpaneldefs.php"); if (empty($layout_defs[$loadedModule]['subpanel_setup'])) { $GLOBALS['log']->error("Cannot find subpanel layout defs for {$loadedModule}"); return $subpanelName; } foreach ($layout_defs[$loadedModule]['subpanel_setup'] as $linkName => $def) { if ($def['module'] == $subpanelName) { return $linkName; } } } $viewdefs = MetaDataFiles::getClientFileContents(MetaDataFiles::getClientFiles(array($this->getViewClient()), 'layout', $loadedModule), 'layout', $loadedModule); if (empty($viewdefs['subpanels'])) { return $subpanelName; } $legacyDefs = $this->mdc->toLegacySubpanelLayoutDefs($viewdefs['subpanels']['meta']['components'], BeanFactory::newBean($loadedModule)); if (empty($legacyDefs['subpanel_setup'])) { $GLOBALS['log']->error("Could not convert subpanels for subpanel: {$subpanelName} - {$loadedModule}"); return $subpanelName; } foreach ($legacyDefs['subpanel_setup'] as $linkName => $def) { if ($def['module'] == $subpanelName) { return $linkName; } } return $subpanelName; }
/** * Saving the bean data if sent through the engine * @param type $beanData * @codeCoverageIgnore */ public function saveBeanData($beanData) { $fields = $beanData; $bpmInboxId = $fields['flow_id']; $moduleName = $fields['moduleName']; $moduleId = $fields['beanId']; foreach ($beanData as $key => $value) { if (in_array($key, $this->engineFields)) { unset($fields[$key]); } } //modified_by_name => Current if (!isset($moduleName) || $moduleName == '') { $GLOBALS['log']->fatal('moduleName Empty cannot complete the route case'); header('Location: #Home'); } //If Process is Completed break... $bpmI = PMSEEngineUtils::getBPMInboxStatus($bpmInboxId); if ($bpmI === false) { header('Location: #pmse_Inbox/$bpmInboxId/layout/no-show-case/$bpmFlowId'); die; } $beanObject = BeanFactory::getBean($moduleName, $moduleId); $historyData = new PMSEHistoryData($moduleName); foreach ($fields as $key => $value) { $historyData->lock(!array_key_exists($key, $beanObject->fetched_row)); if (isset($beanObject->{$key})) { $historyData->verifyRepeated($beanObject->{$key}, $value); $historyData->savePredata($key, $beanObject->{$key}); $beanObject->{$key} = $value; $historyData->savePostdata($key, $value); } } //If a module includes custom save/editview logic in Save.php, use that instead of a direct save. if (isModuleBWC($beanObject->module_dir) && SugarAutoLoader::fileExists("modules/{$beanObject->module_dir}/Save.php")) { global $disable_redirects; $disable_redirects = true; $_REQUEST['record'] = $beanObject->id; include "modules/{$beanObject->module_dir}/Save.php"; $disable_redirects = false; } else { $beanObject->save(); } $fields['log_data'] = $historyData->getLog(); $this->caseFlowHandler->saveFormAction($fields); }
/** * Builds an appropriate Sidecar or BWC href attribute for the additional * details buttons, using the link supplied from the additional details * module metadata. * * @private * @param string $link (optional) The link from additional details module * metadata. The function returns an empty string if none is supplied. * @return string The href attribute used for the button. */ private function buildButtonLink($link = '') { if (preg_match('/module=([^&]+)/', $link, $matches) && !isModuleBWC($matches[1])) { parse_str(parse_url($link, PHP_URL_QUERY), $params); $script = navigateToSidecar(buildSidecarRoute($params['module'], $params['record'], translateToSidecarAction($params['action']))); $link = "javascript:{$script};"; } return $link; }
/** * Returns types of existing customizations for the given module * * @param string $module Module name * @return array */ protected function getModuleCustomizations($module) { global $mod_strings; $result = array(); if (!SugarAutoLoader::existingCustomOne("modules/{$module}/metadata/studio.php")) { return $result; } $path = 'custom/modules/' . $module; $subdirectories = $this->getSubdirectories('custom/modules/' . $module); foreach ($subdirectories as $type) { switch ($type) { case 'language': $result[$type] = $mod_strings['LBL_EC_CUSTOMFIELD']; break; case 'metadata': case 'clients': // BWC modules keep metadata in the 'metadata' directory if (isModuleBWC($module)) { $result[$type] = $mod_strings['LBL_EC_CUSTOMLAYOUT']; } else { // New style pathing $fullpath = $path . '/' . $type; // Right now only views are customizable in studio $viewDirs = glob("{$fullpath}/*/views"); foreach ($viewDirs as $viewDir) { if ($this->isDirectoryExportable($viewDir)) { $result[$type] = $mod_strings['LBL_EC_CUSTOMLAYOUT']; break; } } } break; case 'Ext': // Simply checking the Ext directory isn't enough... // we need to check certain directories inside of it // to make sure there are things that are eligible // to export $fullpath = $path . '/' . $type; // Start first with custom fields if ($this->isDirectoryExportable("{$fullpath}/Vardefs")) { $result["{$type}/Vardefs"] = $mod_strings['LBL_EC_CUSTOMFIELD']; } // Now check custom labels if ($this->isDirectoryExportable("{$fullpath}/Language")) { $result["{$type}/Language"] = $mod_strings['LBL_EC_CUSTOMLABEL']; } break; default: $result[$type] = $mod_strings['LBL_UNDEFINED']; } } return $result; }
/** * This function handles create the email notifications email. * @param string $templateName the name of the template used for the email content * @param null|User $notify_user User object, current user if not specified * @return XTemplate */ protected function createNotificationEmailTemplate($templateName, $notify_user = null) { global $sugar_config, $current_user, $sugar_version, $locale; if ($notify_user && !empty($notify_user->preferred_language)) { $currentLanguage = $notify_user->preferred_language; } else { $currentLanguage = $locale->getAuthenticatedUserLanguage(); } $xtpl = new XTemplate(get_notify_template_file($currentLanguage)); if (in_array('set_notification_body', get_class_methods($this))) { $xtpl = $this->set_notification_body($xtpl, $this); } else { //Default uses OBJECT key for both subject and body (see en_us.notify_template.html) $singularModuleLabel = $GLOBALS['app_list_strings']['moduleListSingular'][$this->module_name]; $xtpl->assign("OBJECT", $singularModuleLabel); } $xtpl->assign("ASSIGNED_USER", $this->new_assigned_user_name); $xtpl->assign("ASSIGNER", $current_user->name); $parsedSiteUrl = parse_url($sugar_config['site_url']); $host = $parsedSiteUrl['host']; if (!isset($parsedSiteUrl['port'])) { $parsedSiteUrl['port'] = 80; } $port = $parsedSiteUrl['port'] != 80 ? ":" . $parsedSiteUrl['port'] : ''; $path = isset($parsedSiteUrl['path']) ? rtrim($parsedSiteUrl['path'], '/') : ''; $cleanUrl = "{$parsedSiteUrl['scheme']}://{$host}{$port}{$path}"; if (isModuleBWC($this->module_name)) { $xtpl->assign("URL", $cleanUrl . "/#bwc/index.php?module={$this->module_dir}&action=DetailView&record={$this->id}"); } else { $xtpl->assign('URL', $cleanUrl . '/index.php#' . $this->module_name . '/' . $this->id); } $xtpl->assign("SUGAR", "Sugar v{$sugar_version}"); $xtpl->parse($templateName); $xtpl->parse($templateName . "_Subject"); return $xtpl; }
$this->ss->assign('title', $title); $this->ss->assign('enabled_subs', $orig_vals_array[0]); $this->ss->assign('disabled_subs', $orig_vals_array[1]); $this->ss->assign('enabled_subs_string', $orig_vals_str[0]); $this->ss->assign('disabled_subs_string', $orig_vals_str[1]); // FIXME we are doing this way since this view is going to be removed later // this should be with proper buttons from smarty tpls. require_once 'include/formbase.php'; $url = buildRedirectURL(); $cancelButtonClick = "SUGAR.ajaxUI.loadContent('{$url}'); return false;"; /* * Parse the module from the URL first using regular expression. * This is faster than parse_url + parse_str in first place and most of * our redirects won't go to sidecar (at least for now). */ if (preg_match('/module=([^&]+)/', $url, $matches) && !isModuleBWC($matches[1])) { parse_str(parse_url($url, PHP_URL_QUERY), $params); $script = navigateToSidecar(buildSidecarRoute($params['module'], $params['record'], translateToSidecarAction($params['action']))); $cancelButtonClick = "{$script} return false;"; } $buttons = array('<input id="save_button" title="' . $app_strings['LBL_SAVE_BUTTON_TITLE'] . '" accessKey="' . $app_strings['LBL_SAVE_BUTTON_KEY'] . '" class="button" onclick="save();this.form.action.value=\'Subscriptions\'; " type="submit" name="button" value="' . $app_strings['LBL_SAVE_BUTTON_LABEL'] . '">', '<input id="cancel_button" title="' . $app_strings['LBL_CANCEL_BUTTON_TITLE'] . '" accessKey="' . $app_strings['LBL_CANCEL_BUTTON_KEY'] . '" class="button" onclick="' . $cancelButtonClick . '" type="submit" name="button" value="' . $app_strings['LBL_CANCEL_BUTTON_LABEL'] . '">'); $this->ss->assign('BUTTONS', $buttons); $this->ss->display('modules/Campaigns/Subscriptions.tpl'); /* *This function constructs Drag and Drop multiselect box of subscriptions for display in manage subscription form */ function constructDDSubscriptionList($focus, $classname = '') { require_once "include/templates/TemplateDragDropChooser.php"; global $mod_strings; $unsubs_arr = '';
function removeFieldsFromLayout($layoutAdditions) { // these modules either lack editviews/detailviews or use custom mechanisms for the editview/detailview. // In either case, we don't want to attempt to add a relate field to them // would be better if GridLayoutMetaDataParser could handle this gracefully, so we don't have to maintain this list here $invalidModules = array('emails', 'kbdocuments'); foreach ($layoutAdditions as $deployedModuleName => $fieldName) { if (!in_array(strtolower($deployedModuleName), $invalidModules)) { // Handle decision making on views for BWC/non-BWC modules if (isModuleBWC($deployedModuleName)) { $views = array(MB_EDITVIEW, MB_DETAILVIEW); } else { $views = array(MB_RECORDVIEW); } foreach ($views as $view) { $GLOBALS['log']->debug(get_class($this) . ": adding {$fieldName} to {$view} layout for module {$deployedModuleName}"); $parser = ParserFactory::getParser($view, $deployedModuleName); $parser->removeField($fieldName); $parser->handleSave(false); } } } }
/** * Redirect to another URL. * * If the module is not in BWC it will try to map to sidecar url. * If it loads only temporarily, please check if the module is pointing to * a layout/view in BWC. * * This function writes session data, ends the session and exists the app. * * @param string $url The URL to redirect to. */ public function redirect($url) { global $disable_redirects; //Dirty hack to enable the inclusion of BWC style scripts that wish to redirect without breaking REST requests. if ($disable_redirects) { return; } /* * Parse the module from the URL first using regular expression. * This is faster than parse_url + parse_str in first place and most of * our redirects won't go to sidecar (at least for now). */ if (preg_match('/module=([^&]+)/', $url, $matches) && !isModuleBWC($matches[1])) { parse_str(parse_url($url, PHP_URL_QUERY), $params); $script = navigateToSidecar(buildSidecarRoute($params['module'], $params['record'], translateToSidecarAction($params['action']))); echo "<script>{$script}</script>"; exit; } session_write_close(); header('HTTP/1.1 301 Moved Permanently'); header("Location: {$url}"); exit; }
function constructSmarty($parser) { global $mod_strings; $isModuleBWC = isModuleBWC($this->editModule); $smarty = new Sugar_Smarty(); $smarty->assign('translate', true); $smarty->assign('language', $parser->getLanguage()); $smarty->assign('view', $this->editLayout); $smarty->assign('module', "ModuleBuilder"); $smarty->assign('field_defs', $parser->getFieldDefs()); $smarty->assign('action', 'listViewSave'); $smarty->assign('view_module', $this->editModule); if (!empty($this->subpanel)) { $smarty->assign('subpanel', $this->subpanel); $smarty->assign('subpanelLabel', $this->subpanelLabel); if (!$this->fromModuleBuilder) { $subList = SubPanel::getModuleSubpanels($this->editModule); $subRef = $subList[strtolower($this->subpanel)]; $subTitleKey = !empty($subRef) ? $subRef : "LBL_" . strtoupper($this->subpanel) . "_SUBPANEL_TITLE"; $subTitle = !empty($subRef) ? translate($subTitleKey, $this->editModule) : UCfirst($this->subpanel); $smarty->assign('subpanel_label', $subTitleKey); $smarty->assign('subpanel_title', $subTitle); } } $helpName = $this->subpanel ? 'subPanelEditor' : 'listViewEditor'; $smarty->assign('helpName', $helpName); $smarty->assign('helpDefault', 'modify'); $smarty->assign('title', $this->_constructTitle()); $groups = array(); foreach ($parser->columns as $column => $function) { // update this so that each field has a properties set // properties are name, value, title (optional) $groups[$GLOBALS['mod_strings'][$column]] = $parser->{$function}(); // call the parser functions to populate the list view columns, by default 'default', 'available' and 'hidden' } foreach ($groups as $groupKey => $group) { foreach ($group as $fieldKey => $field) { if (isset($field['width'])) { if ($isModuleBWC) { $width = intval($field['width']); $unit = '%'; } else { $isPercentage = strrpos($field['width'], '%') !== false; if ($isPercentage) { // We won't be bringing over the % definitions from metadata $width = ''; $unit = ''; } else { $width = intval($field['width']); if ($width > 0) { $unit = 'px'; } else { // check if it is a valid string $width = in_array($field['width'], SidecarListLayoutMetaDataParser::getDefaultWidths()) ? $field['width'] : ''; $unit = ''; } } } $groups[$groupKey][$fieldKey]['width'] = $width; $groups[$groupKey][$fieldKey]['units'] = $unit; } } } $smarty->assign('groups', $groups); $smarty->assign('from_mb', $this->fromModuleBuilder); global $image_path; $imageSave = SugarThemeRegistry::current()->getImage('studio_save', '', null, null, '.gif', $mod_strings['LBL_BTN_SAVE']); // $imageHelp = SugarThemeRegistry::current()->getImage('help') ; $history = $parser->getHistory(); $histaction = "ModuleBuilder.history.browse(\"{$this->editModule}\", \"{$this->editLayout}\")"; if ($this->subpanel) { $histaction = "ModuleBuilder.history.browse(\"{$this->editModule}\", \"{$this->editLayout}\", \"{$this->subpanel}\")"; } $restoreAction = "onclick='ModuleBuilder.history.revert(\"{$this->editModule}\", \"{$this->editLayout}\", \"{$history->getLast()}\", \"\")'"; if ($this->subpanel) { $restoreAction = "onclick='ModuleBuilder.history.revert(\"{$this->editModule}\", \"{$this->editLayout}\", \"{$history->getLast()}\", \"{$this->subpanel}\")'"; } $buttons = array(); $buttons[] = array('id' => 'savebtn', 'name' => 'savebtn', 'image' => $imageSave, 'text' => !$this->fromModuleBuilder ? $GLOBALS['mod_strings']['LBL_BTN_SAVEPUBLISH'] : $GLOBALS['mod_strings']['LBL_BTN_SAVE'], 'actionScript' => "onclick='studiotabs.generateGroupForm(\"edittabs\");if (countListFields()==0) ModuleBuilder.layoutValidation.popup() ; else ModuleBuilder.handleSave(\"edittabs\" )'"); $buttons[] = array('id' => 'spacer', 'width' => '50px'); $buttons[] = array('id' => 'historyBtn', 'name' => 'historyBtn', 'text' => translate('LBL_HISTORY'), 'actionScript' => "onclick='{$histaction}'"); $buttons[] = array('id' => 'historyDefault', 'name' => 'historyDefault', 'text' => translate('LBL_RESTORE_DEFAULT'), 'actionScript' => $restoreAction); $smarty->assign('buttons', $this->_buildImageButtons($buttons)); $editImage = SugarThemeRegistry::current()->getImage('edit_inline', '', null, null, '.gif', $mod_strings['LBL_EDIT']); $smarty->assign('editImage', $editImage); $deleteImage = SugarThemeRegistry::current()->getImage('delete_inline', '', null, null, '.gif', $mod_strings['LBL_MB_DELETE']); $smarty->assign('deleteImage', $deleteImage); $smarty->assign('MOD', $GLOBALS['mod_strings']); if ($this->fromModuleBuilder) { $smarty->assign('MB', true); $smarty->assign('view_package', $_REQUEST['view_package']); $mb = new ModuleBuilder(); $module =& $mb->getPackageModule($_REQUEST['view_package'], $this->editModule); $smarty->assign('current_mod_strings', $module->getModStrings()); if ($this->subpanel) { if (isset($_REQUEST['local'])) { $smarty->assign('local', '1'); } $smarty->assign("subpanel", $this->subpanel); } else { $smarty->assign('description', $GLOBALS['mod_strings']['LBL_LISTVIEW_DESCRIPTION']); } } else { if ($this->subpanel) { $smarty->assign("subpanel", "{$this->subpanel}"); } else { $smarty->assign('description', $GLOBALS['mod_strings']['LBL_LISTVIEW_DESCRIPTION']); } } return $smarty; }
public function run() { if (version_compare($this->from_version, '7.0', '>=')) { // no need to run this on 7 return; } $md5_string = array(); if (!file_exists('files.md5')) { return $this->fail("files.md5 not found"); } require 'files.md5'; $this->md5_files = $md5_string; require 'include/modules.php'; $this->beanList = $beanList; $this->beanFiles = $beanFiles; $modules = glob("modules/*", GLOB_ONLYDIR); foreach ($modules as $module) { $module_name = substr($module, 8); // cut off modules/ if (isModuleBWC($module_name)) { // it's already bwc, don't bother it continue; } if ($this->isNewModule($module_name)) { if (!$this->isMBModule($module)) { // new and not MB - list as BWC $this->log("Setting {$module_name} as BWC module"); // keep list of modules we BWC'ed in state so we could tell the user $this->upgrader->state['bwcModules'][] = $module_name; $this->bwcModules[] = $module_name; } else { $mbModules[] = $module_name; } } } if (!empty($mbModules)) { $this->upgrader->state['MBModules'] = $mbModules; } if (!empty($this->bwcModules)) { $data = "<?php \n/* This file was generated by Sugar Upgrade */\n"; foreach ($this->bwcModules as $module) { $data .= '$bwcModules[] = \'' . addslashes($module) . "';\n"; // update current list, we may need it for later scripts $GLOBALS['bwcModules'][] = $module; } $this->putFile("custom/Extension/application/Ext/Include/upgrade_bwc.php", $data); $this->rebuild(); } }
/** * Applies the Action to the target. * * @param SugarBean $target * * Should only be fired when saving from an edit view and the expression is false. */ public function fire(&$target) { $result = Parser::evaluate($this->expression, $target)->evaluate(); if ($result === AbstractExpression::$FALSE) { require_once 'modules/ModuleBuilder/parsers/ParserFactory.php'; require_once 'modules/ModuleBuilder/parsers/constants.php'; $view = isModuleBWC($target->module_name) ? MB_EDITVIEW : MB_RECORDVIEW; $parser = ParserFactory::getParser($view, $target->module_dir); $fields = $parser->getFieldsInPanel($this->targetPanel); foreach ($fields as $field) { unset($target->{$field}); } } }
/** * updateMetaDataFiles * This method updates the metadata files (detailviewdefs.php) according to the settings in display_config.php * @return $result boolean value indicating whether or not the method successfully completed. */ public static function updateMetaDataFiles() { if (file_exists(CONNECTOR_DISPLAY_CONFIG_FILE)) { $modules_sources = array(); require CONNECTOR_DISPLAY_CONFIG_FILE; $GLOBALS['log']->debug(var_export($modules_sources, true)); if (!empty($modules_sources)) { foreach ($modules_sources as $module => $mapping) { if (!isModuleBWC($module)) { // this is done only for BWC modules continue; } $metadata_file = file_exists("custom/modules/{$module}/metadata/detailviewdefs.php") ? "custom/modules/{$module}/metadata/detailviewdefs.php" : "modules/{$module}/metadata/detailviewdefs.php"; $viewdefs = array(); if (!file_exists($metadata_file)) { $GLOBALS['log']->info("Unable to update metadata file for module: {$module}"); continue; } else { require $metadata_file; } $insertConnectorButton = true; if (!empty($viewdefs)) { $buttons = !empty($viewdefs[$module]['DetailView']['templateMeta']['form']['buttons']) ? $viewdefs[$module]['DetailView']['templateMeta']['form']['buttons'] : array(); } $hasConnectorDefined = false; $button_keys = array(); foreach ($buttons as $id => $button) { if (!is_array($button) && $button == 'CONNECTOR') { $button_keys['CONNECTOR'] = $id; $hasConnectorDefined = true; } } $hasWizardSourceEnabled = self::hasWizardSourceEnabledForModule($module); if (!empty($mapping) && !$hasConnectorDefined && $hasWizardSourceEnabled) { $buttons[] = 'CONNECTOR'; } else { if (empty($mapping) && $hasConnectorDefined || !$hasWizardSourceEnabled) { if (!empty($button_keys['CONNECTOR']) && !empty($buttons[$button_keys['CONNECTOR']])) { unset($buttons[$button_keys['CONNECTOR']]); } } } //Update the button changes $viewdefs[$module]['DetailView']['templateMeta']['form']['buttons'] = $buttons; self::removeHoverField($viewdefs, $module); //Insert the hover field if available if (!empty($mapping)) { require_once 'include/connectors/sources/SourceFactory.php'; require_once 'include/connectors/formatters/FormatterFactory.php'; $shown_formatters = array(); foreach ($mapping as $id) { $source = SourceFactory::getSource($id, false); if ($source->isEnabledInHover() && $source->isRequiredConfigFieldsForButtonSet()) { $shown_formatters[$id] = FormatterFactory::getInstance($id); } } //Now we have to decide which field to put it on... use the first one for now if (!empty($shown_formatters)) { foreach ($shown_formatters as $id => $formatter) { $added_field = false; $formatter_mapping = $formatter->getSourceMapping(); $source = $formatter->getComponent()->getSource(); //go through the mapping and add the hover to every field define in the mapping //1) check for hover fields $hover_fields = $source->getFieldsWithParams('hover', true); foreach ($hover_fields as $key => $def) { if (!empty($formatter_mapping['beans'][$module][$key])) { $added_field = self::setHoverField($viewdefs, $module, $formatter_mapping['beans'][$module][$key], $id); } } //2) check for first mapping field if (!$added_field && !empty($formatter_mapping['beans'][$module])) { foreach ($formatter_mapping['beans'][$module] as $key => $val) { $added_field = self::setHoverField($viewdefs, $module, $val, $id); if ($added_field) { break; } } } } //foreach //Log an error message if (!$added_field) { $GLOBALS['log']->fatal("Unable to place hover field link on metadata for module {$module}"); } } } //Make the directory for the metadata file if (!file_exists("custom/modules/{$module}/metadata")) { mkdir_recursive("custom/modules/{$module}/metadata"); } if (!write_array_to_file('viewdefs', $viewdefs, "custom/modules/{$module}/metadata/detailviewdefs.php")) { $GLOBALS['log']->fatal("Cannot update file custom/modules/{$module}/metadata/detailviewdefs.php"); return false; } if (file_exists($cachedfile = sugar_cached("modules/{$module}/DetailView.tpl")) && !unlink($cachedfile)) { $GLOBALS['log']->fatal("Cannot delete file {$cachedfile}"); return false; } } } } return true; }
/** * Check if module is allowed to be in convert flow * * @param $module * @return bool */ public function isModuleAllowedInConvert($module) { //exclude modules that are in BWC or in the exclude list return !isModuleBWC($module) && !in_array($module, $this->excludedModules); }
/** * This is a shim for while we're still in bwc when the current module is a * sidecar (not bwc) module. See SP-1630: Clicking Create from BWC subpanels * for sidecar should open sidecar create view. * @param $defines * @return a sidecar compatable button or falsy */ function _get_form_sidecar($defines) { global $app_strings; global $subpanel_item_count; global $current_language; $sidecarReadySubPanelCreates = array("SubPanelTopCreateButton", "SubPanelTopButtonQuickCreate", "SubPanelTopCreateAccountNameButton", "SubPanelTopCreateLeadNameButton", "SubPanelTopCreateNoteButton", "SubPanelTopScheduleMeetingButton", "SubPanelTopScheduleCallButton", "SubPanelTopCreateTaskButton"); $module = $defines['module']; $label = $app_strings['LBL_CREATE_BUTTON_LABEL']; //Sometimes module is 'History' but the child module is Notes. For the //purposes of determining whether to redirect to sidecar create or not, //treat History (a bwc) as a Note (a sidecar). if ($defines['widget_class'] == 'SubPanelTopCreateNoteButton' && $defines['child_module_name'] == 'Notes') { $module = 'Notes'; $modStringsNotes = return_module_language($current_language, 'Notes'); $label = $modStringsNotes['LNK_NEW_NOTE']; } //Not bwc and in our white-listed subpanel create button widgets if (!isModuleBWC($module) && in_array($defines['widget_class'], $sidecarReadySubPanelCreates)) { $wid = $this->getWidgetId(); $id = $wid . "_create_" . $subpanel_item_count; //bug 51512 $parentId = $defines['focus']->id; $relationship_name = $this->get_subpanel_relationship_name($defines); $form = 'form' . $relationship_name; $panelDefs = $defines['subpanel_definition']; $link = ''; //Normalize Activities which should result in child module creates if ($module == "Activities" && $defines['child_module_name'] == 'Tasks') { $module = "Tasks"; $label = $app_strings['LBL_CREATE_TASK']; } elseif ($module == "Activities" && $defines['child_module_name'] == 'Meetings') { $module = "Meetings"; $label = $app_strings['LBL_SCHEDULE_MEETING_BUTTON_LABEL']; } elseif ($module == "Activities" && $defines['child_module_name'] == 'Calls') { $module = "Calls"; $label = $app_strings['LBL_SCHEDULE_CALL']; } if ($panelDefs->isCollection()) { foreach ($panelDefs->sub_subpanels as $panel) { if ($panel->get_module_name() == $module) { $link = $panel->get_data_source_name(); break; } } } else { $link = $panelDefs->get_data_source_name(); } if ($this->enableActionMenu) { $button = '<form data-legacy-subpanel-create="1" action="index.php" method="post" name="form" id="' . $form . "\">\n" . "<a href='#' onClick=\"javascript:subp_nav_sidecar(\n '" . $module . "','" . $parentId . "','c', '" . $link . "'\n );\"" . " class='create_from_bwc_to_sidecar' id=\"{$id}\">" . $label . '</a>'; } else { $button = '<form data-legacy-subpanel-create="1" action="index.php" method="post" name="form" id="' . $form . "\">\n" . "<input type='button' onClick=\"javascript:subp_nav_sidecar(\n '" . $module . "','" . $parentId . "','c', '" . $link . "'\n );\"" . " class='create_from_bwc_to_sidecar' id=\"{$id}\" value=\"{$label}\">"; } // Set the sidecar flag so that calling codes knows what to do $this->sidecar = true; return $button; } return false; }