/** * @static * @param string $name * @param array $config * @return mixed (bool|SugarSearchEngineInterface) */ protected static function setupEngine($name = '', $config = array()) { // if name is empty set name and config if (empty($name) && !empty($GLOBALS['sugar_config']['full_text_engine'])) { $name = self::getFTSEngineNameFromConfig(); $config = $GLOBALS['sugar_config']['full_text_engine'][$name]; } // if config is empty set config if (empty($config) && !empty($GLOBALS['sugar_config']['full_text_engine'][$name])) { $config = $GLOBALS['sugar_config']['full_text_engine'][$name]; } $paths = array("include/SugarSearchEngine/{$name}/SugarSearchEngine{$name}.php" => $name, "include/SugarSearchEngine/SugarSearchEngine.php" => ''); // object loader using custom override foreach ($paths as $path => $baseClass) { if (SugarAutoLoader::requireWithCustom($path, true)) { $engineClass = SugarAutoLoader::customClass("SugarSearchEngine{$baseClass}"); $engineInstance = new $engineClass($config); if ($engineInstance instanceof SugarSearchEngineInterface) { $GLOBALS['log']->info("Found Sugar Search Engine: " . get_class($engineInstance)); return $engineInstance; } } } return false; }
public function process() { // fetch the data from the filter end point $file = 'modules/ForecastWorksheets/clients/base/api/ForecastWorksheetsFilterApi.php'; $klass = 'ForecastWorksheetsFilterApi'; SugarAutoLoader::requireWithCustom('include/api/RestService.php'); SugarAutoLoader::requireWithCustom($file); $klass = SugarAutoLoader::customClass($klass); /* @var $obj ForecastWorksheetsFilterApi */ $obj = new $klass(); $api = new RestService(); $api->user = $GLOBALS['current_user']; $data = $obj->forecastWorksheetsGet($api, array('module' => 'ForecastWorksheets', 'timeperiod_id' => $this->getArg('timeperiod_id'), 'user_id' => $this->getArg('user_id'))); $fields_array = array('date_closed' => 'date_closed', 'sales_stage' => 'sales_stage', 'name' => 'name', 'commit_stage' => 'commit_stage', 'probability' => 'probability'); $admin = BeanFactory::getBean('Administration'); $settings = $admin->getConfigForModule('Forecasts'); if ($settings['show_worksheet_best']) { $fields_array['best_case'] = 'best_case'; } if ($settings['show_worksheet_likely']) { $fields_array['likely_case'] = 'likely_case'; } if ($settings['show_worksheet_worst']) { $fields_array['worst_case'] = 'worst_case'; } $seed = BeanFactory::getBean('ForecastWorksheets'); return $this->getContent($data['records'], $seed, $fields_array, 'commit_stage', $this->getArg('filters')); }
public function export(ServiceBase $api, $args = array()) { ob_start(); // Load up a seed bean $seed = BeanFactory::getBean('ForecastWorksheets'); if (!$seed->ACLAccess('list')) { throw new SugarApiExceptionNotAuthorized('No access to view records for module: ' . $seed->object_name); } $args['timeperiod_id'] = isset($args['timeperiod_id']) ? $args['timeperiod_id'] : TimePeriod::getCurrentId(); $args['user_id'] = isset($args['user_id']) ? $args['user_id'] : $api->user->id; if (!isset($args['filters'])) { $args['filters'] = array(); } elseif (!is_array($args['filters'])) { $args['filters'] = array($args['filters']); } // don't allow encoding to html for data used in export $args['encode_to_html'] = false; // base file and class name $file = 'include/SugarForecasting/Export/Individual.php'; $klass = 'SugarForecasting_Export_Individual'; // check for a custom file exists SugarAutoLoader::requireWithCustom($file); $klass = SugarAutoLoader::customClass($klass); // create the class /* @var $obj SugarForecasting_Export_AbstractExport */ $obj = new $klass($args); $content = $obj->process($api); ob_end_clean(); return $this->doExport($api, $obj->getFilename(), $content); }
/** * include a source class file. * @param string $class a class file to include. */ public static function loadClass($class, $type) { $dir = str_replace('_', '/', $class); $parts = explode("/", $dir); $file = "{$type}/{$dir}/" . $parts[count($parts) - 1] . '.php'; if (!SugarAutoLoader::requireWithCustom("modules/Connectors/connectors/{$file}")) { return SugarAutoLoader::requireWithCustom("connectors/{$file}"); } return true; }
/** * Helper method to load SugarMetric_Manager * * SugarAutoLoader is not available only in case of entryPoint = "getYUIComboFile" * @see include/preDispatch.php */ public static function loadManagerClass() { if (class_exists('SugarAutoLoader')) { SugarAutoLoader::requireWithCustom('include/SugarMetric/Manager.php'); } else { if (file_exists('custom/include/SugarMetric/Manager.php')) { require_once 'custom/include/SugarMetric/Manager.php'; } elseif (file_exists('include/SugarMetric/Manager.php')) { require_once 'include/SugarMetric/Manager.php'; } } }
protected function loadApiClass($route) { if (!SugarAutoLoader::requireWithCustom($route['file'])) { throw new SugarApiException('Missing API file.'); } if (!class_exists($route['className'])) { throw new SugarApiException('Missing API class.'); } $apiClassName = $route['className']; $apiClass = new $apiClassName(); return $apiClass; }
/** * * Facet object loader * @param string $type * @return FacetAbstract */ public static function get($type) { if (isset(self::$loaded[$type])) { return self::$loaded[$type]; } self::$loaded[$type] = false; $className = "Facet" . ucfirst($type); $classFile = "include/SugarSearchEngine/Elastic/Facets/{$className}.php"; if (SugarAutoLoader::requireWithCustom($classFile)) { self::$loaded[$type] = new $className(); } return self::$loaded[$type]; }
/** * Returns an instance of the authentication controller * * @param string $type this is the type of authentication you want to use default is SugarAuthenticate * @return AuthenticationController An instance of the authentication controller */ public static function getInstance($type = null) { global $sugar_config; if (empty($type)) { $type = !empty($sugar_config['authenticationClass']) ? $sugar_config['authenticationClass'] : 'SugarAuthenticate'; } if (empty(static::$authcontrollerinstance)) { SugarAutoLoader::requireWithCustom('modules/Users/authentication/AuthenticationController.php'); $controllerClass = SugarAutoLoader::customClass('AuthenticationController'); static::$authcontrollerinstance = new $controllerClass($type); } return static::$authcontrollerinstance; }
/** * @param $args * @return SugarForecasting_Individual */ protected function getClass($args) { // base file and class name $file = 'include/SugarForecasting/Individual.php'; $klass = 'SugarForecasting_Individual'; // check for a custom file exists SugarAutoLoader::requireWithCustom($file); $klass = SugarAutoLoader::customClass($klass); // create the class /* @var $obj SugarForecasting_AbstractForecast */ $obj = new $klass($args); return $obj; }
/** * This function will make the decision for which container to load. * * If container is not specified * 1. check if user has a default container they prefer load * * @param string $dashletMetaDataFile - file path to the meta-data specificying the Dashlets used in this container * @param string $container - name of the Dashlet Container to use if not specified it will use the system default * @static * @return DashletContainer */ public static function getContainer($dashletMetaDataFile, $container = null) { if ($container == null) { $container = self::$defaultContainer; } if (!SugarAutoLoader::requireWithCustom('include/DashletContainer/Containers/' . $container . '.php')) { return false; } $class = SugarAutoLoader::customClass($container); if (!class_exists($class)) { return false; } return new $class($dashletMetaDataFile); }
/** * @static * @param string $name * @param array $config * @return mixed (bool|SugarSearchEngineInterface) */ protected static function setupStrategy($name, $config = array()) { $className = "SugarSearchEngineElasticIndexStrategy" . ucfirst($name); $filePath = "include/SugarSearchEngine/Elastic/{$className}.php"; if (SugarAutoLoader::requireWithCustom($filePath, true)) { $className = SugarAutoLoader::customClass($className, true); $strategy = new $className(); if ($strategy instanceof SugarSearchEngineElasticIndexStrategyInterface) { $strategy->setConfig($config); $GLOBALS['log']->info("Found Sugar Search Elastic Index Strategy: {$className}"); return $strategy; } } $GLOBALS['log']->fatal("Failure loading SSE index strategy class: {$className}"); return false; }
/** * Returns a reference to the DB object of specific type * * @param string $type DB type * @param array $config DB configuration * @return object DBManager instance */ public static function getTypeInstance($type, $config = array()) { global $sugar_config; if (empty($config['db_manager'])) { // standard types switch ($type) { case "mysql": if (empty($sugar_config['mysqli_disabled']) && function_exists('mysqli_connect')) { $my_db_manager = 'MysqliManager'; } else { $my_db_manager = "MysqlManager"; } break; case "mssql": if (function_exists('sqlsrv_connect') && (empty($config['db_mssql_force_driver']) || $config['db_mssql_force_driver'] == 'sqlsrv')) { $my_db_manager = 'SqlsrvManager'; } elseif (self::isFreeTDS() && (empty($config['db_mssql_force_driver']) || $config['db_mssql_force_driver'] == 'freetds')) { $my_db_manager = 'FreeTDSManager'; } else { $my_db_manager = 'MssqlManager'; } break; default: $my_db_manager = self::getManagerByType($type, false); if (empty($my_db_manager)) { echo $type . "\n"; display_stack_trace(); $GLOBALS['log']->fatal("unable to load DB manager for: {$type}"); sugar_die("Cannot load DB manager"); } } } else { $my_db_manager = $config['db_manager']; } // sanitize the name $my_db_manager = preg_replace("/[^A-Za-z0-9_-]/", "", $my_db_manager); if (!empty($config['db_manager_class'])) { $my_db_manager = $config['db_manager_class']; } else { SugarAutoLoader::requireWithCustom("include/database/{$my_db_manager}.php"); } if (class_exists($my_db_manager)) { return new $my_db_manager(); } else { return null; } }
/** * This function will return the OAuth2Server class, it will check * the custom/ directory so users can customize the authorization * types and storage */ public static function getOAuth2Server() { static $currentOAuth2Server = null; if (!isset($currentOAuth2Server)) { SugarAutoLoader::requireWithCustom('include/SugarOAuth2/SugarOAuth2Storage.php'); $oauthStorageName = SugarAutoLoader::customClass('SugarOAuth2Storage'); $oauthStorage = new $oauthStorageName(); SugarAutoLoader::requireWithCustom('include/SugarOAuth2/SugarOAuth2Server.php'); $oauthServerName = SugarAutoLoader::customClass('SugarOAuth2Server'); $config = array(); if (!empty($GLOBALS['sugar_config']['oauth2'])) { $config = $GLOBALS['sugar_config']['oauth2']; } $currentOAuth2Server = new $oauthServerName($oauthStorage, $config); } return $currentOAuth2Server; }
/** * Obtain an instance of the correct controller. * * @return an instance of SugarController */ function getController($module) { if (SugarAutoLoader::requireWithCustom("modules/{$module}/controller.php")) { $class = SugarAutoLoader::customClass(ucfirst($module) . 'Controller'); } else { SugarAutoLoader::requireWithCustom('include/MVC/Controller/SugarController.php'); $class = SugarAutoLoader::customClass('SugarController'); } if (class_exists($class, false)) { $controller = new $class(); } if (empty($controller)) { $controller = new SugarController(); } //setup the controller $controller->setup($module); return $controller; }
/** * This method looks up the helper class for the bean and will provide the default helper * if there is not one defined for that particular bean * * @param $api ServiceBase The API that will be associated to this helper class * This is used so the formatting functions can handle different * API's with varying formatting requirements. * @param $bean SugarBean Grab the helper module for this bean * @returns SugarBeanApiHelper A API helper class for beans */ public static function getHelper(ServiceBase $api, SugarBean $bean) { $module = $bean->module_dir; if (!isset(self::$moduleHelpers[$module])) { require_once 'data/SugarBeanApiHelper.php'; if (SugarAutoLoader::requireWithCustom('modules/' . $module . '/' . $module . 'ApiHelper.php')) { $moduleHelperClass = SugarAutoLoader::customClass($module . 'ApiHelper'); } elseif (SugarAutoLoader::fileExists('custom/data/SugarBeanApiHelper.php')) { require_once 'custom/data/SugarBeanApiHelper.php'; $moduleHelperClass = 'CustomSugarBeanApiHelper'; } else { $moduleHelperClass = 'SugarBeanApiHelper'; } self::$moduleHelpers[$module] = new $moduleHelperClass($api); } $moduleHelperClass = self::$moduleHelpers[$module]; return $moduleHelperClass; }
public function preDisplay() { if (session_id()) { // kill old session session_destroy(); } SugarAutoLoader::load('custom/include/RestService.php'); $restServiceClass = SugarAutoLoader::customClass('RestService'); $service = new $restServiceClass(); SugarOAuth2Server::getOAuth2Server(); // to load necessary classes SugarAutoLoader::requireWithCustom('clients/base/api/OAuth2Api.php'); $oapiClassName = SugarAutoLoader::customClass('OAuth2Api'); $oapi = new $oapiClassName(); $args = $_REQUEST; $args['client_id'] = 'sugar'; $args['client_secret'] = ''; if (!empty($_REQUEST['SAMLResponse'])) { $args['grant_type'] = SugarOAuth2Storage::SAML_GRANT_TYPE; $args['assertion'] = $_REQUEST['SAMLResponse']; } else { if (empty($args['grant_type'])) { $args['grant_type'] = OAuth2::GRANT_TYPE_USER_CREDENTIALS; if (!empty($args['user_name']) && isset($args['user_password'])) { // old-style login, let's translate it $args['username'] = $args['user_name']; $args['password'] = $args['user_password']; } } } try { $this->authorization = $oapi->token($service, $args); } catch (Exception $e) { $GLOBALS['log']->error("Login exception: " . $e->getMessage()); sugar_die($e->getMessage()); } if (!empty($_REQUEST['dataOnly'])) { $this->dataOnly = true; } if (!empty($_REQUEST['platform'])) { $this->platform = $_REQUEST['platform']; } parent::preDisplay(); }
/** * Returns a reference to the ChartEngine object for instance $chartEngine, or the default * instance if one is not specified * * @param string $chartEngine optional, name of the chart engine from $sugar_config['chartEngine'] * @param string $module optional, name of module extension for chart engine (see JitReports or SugarFlashReports) * @return object ChartEngine instance */ public static function getInstance($chartEngine = '', $module = '') { global $sugar_config; $defaultEngine = "nvd3"; //fall back to the default Js Engine if config is not defined if (empty($sugar_config['chartEngine'])) { $sugar_config['chartEngine'] = $defaultEngine; } if (empty($chartEngine)) { $chartEngine = $sugar_config['chartEngine']; } if (!SugarAutoLoader::requireWithCustom("include/SugarCharts/{$chartEngine}/{$chartEngine}{$module}.php")) { $GLOBALS['log']->debug("using default engine include/SugarCharts/{$defaultEngine}/{$defaultEngine}{$module}.php"); require_once "include/SugarCharts/{$defaultEngine}/{$defaultEngine}{$module}.php"; $chartEngine = $defaultEngine; } $className = $chartEngine . $module; return new $className(); }
/** * Forecast Worksheet API Handler to return data formatted for the chart * * @param ServiceBase $api * @param array $args * @return array|string */ public function forecastWorksheetsChartGet(ServiceBase $api, array $args) { if (isset($args['no_data']) && $args['no_data'] == 1) { $worksheetData = array('records' => array()); } else { //get data via forecastWorksheetsGet, no need to bother with filter setup, get will do that $worksheetData = $this->forecastWorksheetsGet($api, $args); } // default to the Individual Code $file = 'include/SugarForecasting/Chart/Individual.php'; $klass = 'SugarForecasting_Chart_Individual'; // check for a custom file exists SugarAutoLoader::requireWithCustom($file); $klass = SugarAutoLoader::customClass($klass); // create the class /* @var $obj SugarForecasting_Chart_AbstractChart */ $args['data_array'] = $worksheetData['records']; $obj = new $klass($args); $chartData = $obj->process(); return $chartData; }
/** * Build out the chart for the sales rep view in the forecast module * * @param ServiceBase $api The Api Class * @param array $args Service Call Arguments * @return mixed */ public function chart($api, $args) { $args['timeperiod_id'] = clean_string($args['timeperiod_id']); $args['user_id'] = clean_string($args['user_id']); $args['group_by'] = !isset($args['group_by']) ? "forecast" : $args['group_by']; // default to the Individual Code $file = 'include/SugarForecasting/Chart/Individual.php'; $klass = 'SugarForecasting_Chart_Individual'; // test to see if we need to display the manager if ((bool) $args['display_manager'] && User::isManager($api->user->id)) { // we have a manager view, pull in the manager classes $file = 'include/SugarForecasting/Chart/Manager.php'; $klass = 'SugarForecasting_Chart_Manager'; } // check for a custom file exists SugarAutoLoader::requireWithCustom($file); $klass = SugarAutoLoader::customClass($klass); // create the class /* @var $obj SugarForecasting_Chart_AbstractChart */ $obj = new $klass($args); return $obj->process(); }
/** * Get search form - module specific, custom or default * @param SugarBean $bean * @param string $module * @return SearchForm */ function getSearchForm($bean, $module) { if (SugarAutoLoader::requireWithCustom("modules/{$module}/{$module}SearchForm.php")) { $searchFormClass = SugarAutoLoader::customClass("{$module}SearchForm"); } else { SugarAutoLoader::requireWithCustom('include/SearchForm/SearchForm2.php'); $searchFormClass = SugarAutoLoader::customClass('SearchForm'); } return new $searchFormClass($bean, $module); }
private function getImportMap($importSource) { $import_map_seed = null; if (strncasecmp("custom:", $importSource, 7) == 0) { $id = substr($importSource, 7); $import_map_seed = BeanFactory::getBean('Import_1', $id, array("encode" => false)); $this->ss->assign("SOURCE_ID", $import_map_seed->id); $this->ss->assign("SOURCE_NAME", $import_map_seed->name); $this->ss->assign("SOURCE", $import_map_seed->source); } else { $classname = 'ImportMap' . ucfirst($importSource); if (!SugarAutoLoader::requireWithCustom("modules/Import/maps/{$classname}.php")) { SugarAutoLoader::requireWithCustom("modules/Import/maps/ImportMapOther.php"); $classname = 'ImportMapOther'; $importSource = 'other'; } if (class_exists($classname)) { $import_map_seed = new $classname(); $this->ss->assign("SOURCE", $importSource); } } return $import_map_seed; }
if (substr($sapi_type, 0, 3) != 'cli') { sugar_die("cron.php is CLI only."); } SugarMetric_Manager::getInstance()->setMetricClass('background')->setTransactionName('cron'); if (empty($current_language)) { $current_language = $sugar_config['default_language']; } $app_list_strings = return_app_list_strings_language($current_language); $app_strings = return_application_language($current_language); global $current_user; $current_user = BeanFactory::getBean('Users'); $current_user->getSystemUser(); $GLOBALS['log']->debug('--------------------------------------------> at cron.php <--------------------------------------------'); $cron_driver = !empty($sugar_config['cron_class']) ? $sugar_config['cron_class'] : 'SugarCronJobs'; $GLOBALS['log']->debug("Using {$cron_driver} as CRON driver"); SugarAutoLoader::requireWithCustom("include/SugarQueue/{$cron_driver}.php"); $jobq = new $cron_driver(); $jobq->runCycle(); $exit_on_cleanup = true; sugar_cleanup(false); // some jobs have annoying habit of calling sugar_cleanup(), and it can be called only once // but job results can be written to DB after job is finished, so we have to disconnect here again // just in case we couldn't call cleanup if (class_exists('DBManagerFactory')) { $db = DBManagerFactory::getInstance(); $db->disconnect(); } // If we have a session left over, destroy it if (session_id()) { session_destroy(); }
/** * Retrieves an User bean * pre-format name & full_name attribute with first/last * loads User's preferences * If the picture doesn't exist on the file system, it empties out the picture field * * @param string $id ID of the User * @param bool $encode Encode the result * @param bool $deleted Include deleted users * @return User|null Returns the user object unless once is not found, then it returns null */ public function retrieve($id, $encode = true, $deleted = true) { $ret = parent::retrieve($id, $encode, $deleted); //CurrentUserApi needs a consistent timestamp/format of the data modified for hash purposes. $this->hashTS = $this->fetched_row['date_modified']; if ($ret) { if (isset($_SESSION)) { $this->loadPreferences(); } // make sure that the picture actually exists SugarAutoLoader::requireWithCustom('include/download_file.php'); $download_file = new DownloadFile(); if (!empty($ret->picture) && !file_exists($download_file->getFilePathFromId($ret->picture))) { $ret->picture = ''; } } return $ret; }
/** * Simple factory for getting a metadata manager * * @param string $platform The platform for the metadata * @param bool $public Public or private * @param bool $fresh Whether to skip the cache and get a new manager * @return MetaDataManager */ public static function getManager($platform = null, $public = false, $fresh = false) { if ($platform == null) { $platform = array('base'); } $platform = (array) $platform; // Get the platform metadata class name $class = self::getManagerClassName(''); // MetaDataManager $path = 'include/MetaDataManager/'; $found = false; foreach ($platform as $type) { $mmClass = self::getManagerClassName($type); $file = $path . $mmClass . '.php'; if (SugarAutoLoader::requireWithCustom($file)) { $class = SugarAutoLoader::customClass($mmClass); $found = true; break; } } if (!$found) { SugarAutoLoader::requireWithCustom($path . $class . '.php'); $class = SugarAutoLoader::customClass($class); } // Build a simple key $key = implode(':', $platform) . ':' . intval($public); if ($fresh || empty(self::$managers[$key])) { $manager = new $class($platform, $public); // Cache it and move on self::$managers[$key] = $manager; } return self::$managers[$key]; }
/** * Save the FTS settings for the system and any modules that may be enabled/disabled * by the administrator. */ public function action_ScheduleFTSIndex() { $type = !empty($_REQUEST['type']) ? $_REQUEST['type'] : ''; $host = !empty($_REQUEST['host']) ? $_REQUEST['host'] : ''; $port = !empty($_REQUEST['port']) ? $_REQUEST['port'] : ''; $clearData = !empty($_REQUEST['clearData']) ? true : false; $modules = !empty($_REQUEST['modules']) ? explode(",", $_REQUEST['modules']) : array(); $scheduleIndex = !empty($_REQUEST['sched']) ? true : false; // merge current config with new parameters $ftsConfig = $this->mergeFtsConfig($type, array('host' => $host, 'port' => $port)); $this->cfg = new Configurator(); $this->cfg->config['full_text_engine'] = ''; $this->cfg->saveConfig(); $this->cfg->config['full_text_engine'] = array($type => $ftsConfig); $this->cfg->handleOverride(); $scheduled = false; if ($scheduleIndex) { SugarAutoLoader::requireWithCustom('include/SugarSearchEngine/SugarSearchEngineFullIndexer.php'); $indexerClass = SugarAutoLoader::customClass('SugarSearchEngineFullIndexer'); $indexer = new $indexerClass(); $indexer->initiateFTSIndexer($modules, $clearData); $scheduled = true; } echo json_encode(array('success' => $scheduled)); }
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; }
/** * Factory method with custom override capability * * @param Sugar_Smarty $smarty Smarty template object * @param SugarBean $bean Bean context * @param string $viewType View type as in 'EditView', 'DetailView', ... * @return UserViewHelper */ public static function create(Sugar_Smarty $smarty, SugarBean $bean, $viewType) { SugarAutoLoader::requireWithCustom('modules/Users/UserViewHelper.php', true); $className = SugarAutoLoader::customClass('UserViewHelper'); return new $className($smarty, $bean, $viewType); }
/** * Sets the platform storage object into this object * * @param string $platform * @throws Exception */ protected function setPlatformStore($platform = null) { if (empty($this->platformStore) || $platform && ($store = $this->platformStore->getPlatformName()) != $platform) { // Handle setting the platform storage object if (empty($platform)) { $platform = empty($_SESSION['platform']) ? 'base' : $_SESSION['platform']; } // Reset the platform if it doesn't match if ($this->platform != $platform) { $this->platform = $platform; } // Normalize the platform $platform_class = 'SugarOAuth2Storage' . ucfirst(strtolower($platform)); if ($platform != 'base' && SugarAutoLoader::requireWithCustom("include/SugarOAuth2/{$platform_class}.php")) { $oauthStorageName = SugarAutoLoader::customClass($platform_class); } else { SugarAutoLoader::requireWithCustom('include/SugarOAuth2/SugarOAuth2StorageBase.php'); $oauthStorageName = SugarAutoLoader::customClass('SugarOAuth2StorageBase'); } if (empty($oauthStorageName)) { throw new Exception('No OAuth storage handler found'); } $this->platformStore = new $oauthStorageName(); } }
*/ $mod_strings = return_module_language($current_language, $_REQUEST['target_module']); $target_module = $_REQUEST['target_module']; // target class if (SugarAutoLoader::existing('modules/' . $_REQUEST['target_module'] . '/EditView.php')) { $tpl = $_REQUEST['tpl']; if (SugarAutoLoader::requireWithCustom('modules/' . $target_module . '/' . $target_module . 'QuickCreate.php')) { // if there is a quickcreate override $editviewClass = SugarAutoLoader::customClass($target_module . 'QuickCreate'); // eg. OpportunitiesQuickCreate $editview = new $editviewClass($target_module, 'modules/' . $target_module . '/tpls/' . $tpl); $editview->viaAJAX = true; } else { // else use base class require_once 'include/EditView/EditViewQuickCreate.php'; $editview = new EditViewQuickCreate($target_module, 'modules/' . $target_module . '/tpls/' . $tpl); } $editview->process(); echo $editview->display(); } else { $subpanelView = 'modules/' . $target_module . '/views/view.subpanelquickcreate.php'; $view = !empty($_REQUEST['target_view']) ? $_REQUEST['target_view'] : 'QuickCreate'; //Check if there is a custom override, then check for module override, finally use default (SubpanelQuickCreate) if (SugarAutoLoader::requireWithCustom($subpanelView)) { $subpanelClass = SugarAutoLoader::customClass($target_module . 'SubpanelQuickCreate'); $sqc = new $subpanelClass($target_module, $view); } else { require_once 'include/EditView/SubpanelQuickCreate.php'; $sqc = new SubpanelQuickCreate($target_module, $view); } }
function getClassFromWidgetDef($widget_def, $use_default = false) { static $class_map = array('SugarWidgetSubPanelTopCreateButton' => array('widget_class' => 'SugarWidgetSubPanelTopButton', 'title' => 'LBL_NEW_BUTTON_TITLE', 'access_key' => 'LBL_NEW_BUTTON_KEY', 'form_value' => 'LBL_NEW_BUTTON_LABEL', 'ACL' => 'edit'), 'SugarWidgetSubPanelTopButtonQuickCreate' => array('widget_class' => 'SugarWidgetSubPanelTopButtonQuickCreate', 'title' => 'LBL_NEW_BUTTON_TITLE', 'access_key' => 'LBL_NEW_BUTTON_KEY', 'form_value' => 'LBL_NEW_BUTTON_LABEL', 'ACL' => 'edit'), 'SugarWidgetSubPanelTopCreateLeadNameButton' => array('widget_class' => 'SugarWidgetSubPanelTopCreateLeadNameButton', 'title' => 'LBL_NEW_BUTTON_TITLE', 'access_key' => 'LBL_NEW_BUTTON_KEY', 'form_value' => 'LBL_NEW_BUTTON_LABEL', 'ACL' => 'edit'), 'SugarWidgetSubPanelTopScheduleMeetingButton' => array('widget_class' => 'SugarWidgetSubPanelTopScheduleMeetingButton', 'module' => 'Meetings', 'title' => 'LBL_NEW_BUTTON_TITLE', 'access_key' => 'LBL_NEW_BUTTON_KEY', 'form_value' => 'LNK_NEW_MEETING', 'ACL' => 'edit'), 'SugarWidgetSubPanelTopScheduleCallButton' => array('widget_class' => 'SugarWidgetSubPanelTopScheduleCallButton', 'module' => 'Calls', 'title' => 'LBL_NEW_BUTTON_TITLE', 'access_key' => 'LBL_NEW_BUTTON_KEY', 'form_value' => 'LNK_NEW_CALL', 'ACL' => 'edit'), 'SugarWidgetSubPanelTopCreateTaskButton' => array('widget_class' => 'SugarWidgetSubPanelTopCreateTaskButton', 'module' => 'Tasks', 'title' => 'LBL_NEW_BUTTON_TITLE', 'access_key' => 'LBL_NEW_BUTTON_KEY', 'form_value' => 'LNK_NEW_TASK', 'ACL' => 'edit'), 'SugarWidgetSubPanelTopCreateNoteButton' => array('widget_class' => 'SugarWidgetSubPanelTopCreateNoteButton', 'module' => 'Notes', 'title' => 'LBL_NEW_BUTTON_TITLE', 'access_key' => 'LBL_NEW_BUTTON_KEY', 'form_value' => 'LNK_NEW_NOTE', 'ACL' => 'edit'), 'SugarWidgetSubPanelTopCreateContactAccountButton' => array('widget_class' => 'SugarWidgetSubPanelTopButton', 'module' => 'Contacts', 'title' => 'LBL_NEW_BUTTON_TITLE', 'access_key' => 'LBL_NEW_BUTTON_KEY', 'form_value' => 'LBL_NEW_BUTTON_LABEL', 'additional_form_fields' => array('primary_address_street' => 'shipping_address_street', 'primary_address_city' => 'shipping_address_city', 'primary_address_state' => 'shipping_address_state', 'primary_address_country' => 'shipping_address_country', 'primary_address_postalcode' => 'shipping_address_postalcode', 'to_email_addrs' => 'email1'), 'ACL' => 'edit'), 'SugarWidgetSubPanelTopCreateContact' => array('widget_class' => 'SugarWidgetSubPanelTopButton', 'module' => 'Contacts', 'title' => 'LBL_NEW_BUTTON_TITLE', 'access_key' => 'LBL_NEW_BUTTON_KEY', 'form_value' => 'LBL_NEW_BUTTON_LABEL', 'additional_form_fields' => array('account_id' => 'account_id', 'account_name' => 'account_name'), 'ACL' => 'edit'), 'SugarWidgetSubPanelTopCreateRevisionButton' => array('widget_class' => 'SugarWidgetSubPanelTopButton', 'module' => 'DocumentRevisions', 'title' => 'LBL_NEW_BUTTON_TITLE', 'access_key' => 'LBL_NEW_BUTTON_KEY', 'form_value' => 'LBL_NEW_BUTTON_LABEL', 'additional_form_fields' => array('parent_name' => 'document_name', 'document_name' => 'document_name', 'document_revision' => 'latest_revision', 'document_filename' => 'filename', 'document_revision_id' => 'document_revision_id'), 'ACL' => 'edit'), 'SugarWidgetSubPanelTopCreateDirectReport' => array('widget_class' => 'SugarWidgetSubPanelTopButton', 'module' => 'Contacts', 'title' => 'LBL_NEW_BUTTON_TITLE', 'access_key' => 'LBL_NEW_BUTTON_KEY', 'form_value' => 'LBL_NEW_BUTTON_LABEL', 'additional_form_fields' => array('reports_to_name' => 'name', 'reports_to_id' => 'id'), 'ACL' => 'edit'), 'SugarWidgetSubPanelTopSelectFromReportButton' => array('widget_class' => 'SugarWidgetSubPanelTopSelectReportsButton', 'module' => 'Reports', 'title' => 'LBL_SELECT_REPORTS_BUTTON_LABEL', 'access_key' => 'LBL_SELECT_BUTTON_KEY', 'form_value' => 'LBL_SELECT_REPORTS_BUTTON_LABEL', 'ACL' => 'edit', 'add_to_passthru_data' => array('return_type' => 'report')), 'SugarWidgetSubPanelTopCreateAccountNameButton' => array('widget_class' => 'SugarWidgetSubPanelTopCreateAccountNameButton', 'module' => 'Contacts', 'title' => 'LBL_NEW_BUTTON_TITLE', 'access_key' => 'LBL_NEW_BUTTON_KEY', 'form_value' => 'LBL_NEW_BUTTON_LABEL', 'ACL' => 'edit'), 'SugarWidgetSubPanelAddToProspectListButton' => array('widget_class' => 'SugarWidgetSubPanelTopSelectButton', 'module' => 'ProspectLists', 'title' => 'LBL_ADD_TO_PROSPECT_LIST_BUTTON_LABEL', 'access_key' => 'LBL_ADD_TO_PROSPECT_LIST_BUTTON_KEY', 'form_value' => 'LBL_ADD_TO_PROSPECT_LIST_BUTTON_LABEL', 'ACL' => 'edit', 'add_to_passthru_data' => array('return_type' => 'addtoprospectlist', 'parent_module' => 'ProspectLists', 'parent_type' => 'ProspectList', 'child_id' => 'target_id', 'link_attribute' => 'target_type', 'link_type' => 'polymorphic'))); $fieldDef = $this->getFieldDef($widget_def); if (!empty($fieldDef) && !empty($fieldDef['type']) && strtolower(trim($fieldDef['type'])) == 'multienum') { $widget_def['widget_class'] = 'Fieldmultienum'; } if (!empty($fieldDef) && !empty($fieldDef['type']) && strtolower(trim($fieldDef['type'])) == 'bool') { $widget_def['widget_class'] = 'Fieldbool'; } if ($use_default) { switch ($widget_def['name']) { case 'assigned_user_id': //bug 39170 - begin //bug 39170 - begin case 'created_by': case 'modified_user_id': //bug 39170 - end $widget_def['widget_class'] = 'Fielduser_name'; break; case 'team_id': $widget_def['widget_class'] = 'Fieldteam_name'; break; default: if (isset($widget_def['type'])) { $widget_def['widget_class'] = 'Field' . $widget_def['type']; } else { $widget_def['widget_class'] = 'Field' . $this->DBHelper->getFieldType($widget_def); } } } if (!empty($widget_def['name']) && $widget_def['name'] == 'team_set_id') { $widget_def['widget_class'] = 'Fieldteam_set_id'; } if (empty($widget_def['widget_class'])) { // Default the class to SugarWidgetField $class_name = $this->widget_prefix . $this->default_widget_name; } else { $class_name = $this->widget_prefix . $widget_def['widget_class']; } // Check to see if this is one of the known class mappings. if (!empty($class_map[$class_name])) { if (empty($class_map[$class_name]['widget_class'])) { $widget = new SugarWidgetSubPanelTopButton($class_map[$class_name]); } else { if (!class_exists($class_map[$class_name]['widget_class'])) { require_once 'include/generic/SugarWidgets/' . $class_map[$class_name]['widget_class'] . '.php'; } $widget = new $class_map[$class_name]['widget_class']($class_map[$class_name]); } return $widget; } // At this point, we have a class name and we do not have a valid class defined. if (!class_exists($class_name)) { SugarAutoLoader::requireWithCustom("include/generic/SugarWidgets/{$class_name}.php"); if (!class_exists($class_name)) { // If we still do not have a class, oops.... die("LayoutManager: Class not found:" . $class_name); } } $parent_bean = null; if (isset($widget_def['parent_bean'])) { $parent_bean = $widget_def['parent_bean']; } elseif (isset($widget_def['focus'])) { $parent_bean = $widget_def['focus']; } $widget = new $class_name($this); // cache disabled $this->getClassFromCache($class_name); $widget->setParentBean($parent_bean); return $widget; }