コード例 #1
0
 /**
  * @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;
 }
コード例 #2
0
 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);
 }
コード例 #3
0
ファイル: Individual.php プロジェクト: jglaine/sugar761-ent
 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'));
 }
コード例 #4
0
 /**
  * return the singleton of the SugarField
  *
  * @param string $field Field type
  * @param boolean $returnNullIfBase
  * @return SugarFieldBase
  */
 static function getSugarField($field, $returnNullIfBase = false)
 {
     static $sugarFieldObjects = array();
     $field = self::fixupFieldType($field);
     $field = ucfirst($field);
     if (!isset($sugarFieldObjects[$field])) {
         //check custom directory
         $file = SugarAutoLoader::existingCustomOne("include/SugarFields/Fields/{$field}/SugarField{$field}.php");
         if ($file) {
             $type = $field;
         } else {
             // No direct class, check the directories to see if they are defined
             if ($returnNullIfBase && !SugarAutoLoader::existing('include/SugarFields/Fields/' . $field)) {
                 return null;
             }
             $file = 'include/SugarFields/Fields/Base/SugarFieldBase.php';
             $type = 'Base';
         }
         require_once $file;
         $class = SugarAutoLoader::customClass('SugarField' . $type);
         //could be a custom class check it
         $sugarFieldObjects[$field] = new $class($field);
     }
     return $sugarFieldObjects[$field];
 }
コード例 #5
0
ファイル: Localization.php プロジェクト: jglaine/sugar761-ent
 /**
  * Method to get Localization object
  *
  * @return Localization
  */
 public static function getObject()
 {
     $class = __CLASS__;
     if (SugarAutoLoader::load('custom/include/Localization/Localization.php')) {
         $class = SugarAutoLoader::customClass($class);
     }
     return new $class();
 }
コード例 #6
0
 /**
  * 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;
 }
コード例 #7
0
 /**
  * @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;
 }
コード例 #8
0
ファイル: DCFactory.php プロジェクト: jglaine/sugar761-ent
 /**
  * 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;
 }
コード例 #10
0
 /**
  * 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;
 }
コード例 #11
0
 /**
  * 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;
 }
コード例 #12
0
ファイル: ApiHelper.php プロジェクト: jglaine/sugar761-ent
 /**
  * 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;
 }
コード例 #13
0
 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();
 }
コード例 #14
0
 public function __construct($params = array())
 {
     // Setup Elastica Client object
     $this->_config = $params;
     // this timeout can be overriden at $sugar_config['full_text_engine']['Elastic']['timeout']
     if (empty($this->_config['timeout'])) {
         $this->_config['timeout'] = 15;
     }
     $this->setClient(new \Elastica\Client($this->_config));
     // Setup index strategy
     $this->indexStrategy = SugarSearchEngineElasticIndexStrategyFactory::getinstance();
     // Asynchronous indexing through fts_queue table
     $this->forceAsyncIndex = SugarConfig::getInstance()->get('search_engine.force_async_index', false);
     // Elastic mapping
     $mappingClass = SugarAutoLoader::customClass('SugarSearchEngineElasticMapping');
     $this->mapper = new $mappingClass($this);
     // Facet handler
     $this->facetHandler = new FacetHandler();
     parent::__construct();
 }
コード例 #15
0
 /**
  * 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;
 }
コード例 #16
0
 /**
  * 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();
 }
コード例 #17
0
ファイル: controller.php プロジェクト: jglaine/sugar761-ent
 /**
  * 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));
 }
コード例 #18
0
 /**
  * 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);
 }
コード例 #19
0
 /**
  * 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();
     }
 }
コード例 #20
0
 */
$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);
    }
}
コード例 #21
0
ファイル: export_utils.php プロジェクト: jglaine/sugar761-ent
/**
 * 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);
}
コード例 #22
0
ファイル: rest.php プロジェクト: jglaine/sugar761-ent
<?php

if (!defined('sugarEntry')) {
    define('sugarEntry', true);
}
/*
 * 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.
 */
ob_start();
chdir(dirname(__FILE__) . '/../');
define('ENTRY_POINT_TYPE', 'api');
require 'include/entryPoint.php';
require_once "include/api/RestService.php";
SugarAutoLoader::load('custom/include/RestService.php');
$restServiceClass = SugarAutoLoader::customClass('RestService');
global $service;
$service = new $restServiceClass();
$service->execute();
コード例 #23
0
ファイル: ViewFactory.php プロジェクト: jglaine/sugar761-ent
 /**
  * This is a private function which just helps the getView function generate the
  * proper view object
  *
  * @return a valid SugarView
  */
 function _buildFromFile($file, &$bean, $view_object_map, $type, $module)
 {
     require_once $file;
     //try ModuleViewType first then try ViewType if that fails then use SugarView
     $class = SugarAutoLoader::customClass(ucfirst($module) . 'View' . ucfirst($type));
     if (class_exists($class)) {
         return ViewFactory::_buildClass($class, $bean, $view_object_map);
     }
     //Now try the next set of possibilites if it was none of the above
     //It can be expensive to load classes this way so it's not recommended
     $class = SugarAutoLoader::customClass('View' . ucfirst($type));
     if (class_exists($class)) {
         return ViewFactory::_buildClass($class, $bean, $view_object_map);
     }
     //Now check if there is a custom SugarView for generic handling
     // autoloader will check filesystem
     $class = SugarAutoLoader::customClass('SugarView', true);
     //if all else fails return SugarView
     return new $class($bean, $view_object_map);
 }
コード例 #24
0
 /**
  * Get instance
  * @return CsrfAuthenticator
  */
 public static function getInstance()
 {
     if (empty(static::$instance)) {
         $config = \SugarConfig::getInstance();
         // setup token generator
         $tokenGenerator = new CsrfTokenGenerator();
         $tokenGenerator->setSize($config->get('csrf.token_size', 32));
         // setup token storage using sessions
         $tokenStorage = new CsrfTokenStorage();
         $manager = new CsrfTokenManager($tokenGenerator, $tokenStorage);
         $logger = new LoggerTransition(\LoggerManager::getLogger());
         $class = \SugarAutoLoader::customClass('Sugarcrm\\Sugarcrm\\Security\\Csrf\\CsrfAuthenticator');
         static::$instance = new $class($manager, $logger, $config);
     }
     return static::$instance;
 }
コード例 #25
0
function check_now($send_usage_info = true, $get_request_data = false, $response_data = false, $from_install = false)
{
    global $sugar_config, $timedate;
    global $db, $license;
    // This section of code is a portion of the code referred
    // to as Critical Control Software under the End User
    // License Agreement.  Neither the Company nor the Users
    // may modify any portion of the Critical Control Software.
    if (ocLicense()) {
        return array();
    }
    // END REQUIRED CODE
    $return_array = array();
    if (!$from_install && empty($license)) {
        loadLicense(true);
    }
    if (!$response_data) {
        $systemInfo = SugarSystemInfo::getInstance();
        SugarAutoLoader::requireWithCustom('include/SugarHeartbeat/SugarHeartbeatClient.php', true);
        $sclientClass = SugarAutoLoader::customClass('SugarHeartbeatClient');
        $sclient = new $sclientClass();
        if ($from_install) {
            $info = $systemInfo->getBaseInfo();
        } else {
            $info = $systemInfo->getInfo();
        }
        // This section of code is a portion of the code referred
        // to as Critical Control Software under the End User
        // License Agreement.  Neither the Company nor the Users
        // may modify any portion of the Critical Control Software.
        if (!empty($license->settings['license_key'])) {
            $key = $license->settings['license_key'];
        } else {
            //END REQUIRED CODE
            $key = '4829482749329';
        }
        $encoded = sugarEncode($key, serialize($info));
        if ($get_request_data) {
            $request_data = array('key' => $key, 'data' => $encoded);
            return serialize($request_data);
        }
        $encodedResult = $sclient->sugarHome($key, $info);
    } else {
        $encodedResult = $response_data['data'];
        $key = $response_data['key'];
    }
    if ($response_data || !$sclient->getError()) {
        $serializedResultData = sugarDecode($key, $encodedResult);
        $resultData = unserialize($serializedResultData);
        if ($response_data && empty($resultData)) {
            $resultData = array();
            $resultData['validation'] = 'invalid validation key';
        }
    } else {
        $resultData = array();
        $resultData['versions'] = array();
    }
    if (!isset($resultData['validation'])) {
        $resultData['validation'] = 'invalid';
    }
    if ($response_data || !$sclient->getError()) {
        // This section of code is a portion of the code referred
        // to as Critical Control Software under the End User
        // License Agreement.  Neither the Company nor the Users
        // may modify any portion of the Critical Control Software.
        checkDownloadKey($resultData['validation']);
        //END REQUIRED CODE
        if (!empty($resultData['msg'])) {
            if (!empty($resultData['msg']['admin'])) {
                $license->saveSetting('license', 'msg_admin', base64_encode($resultData['msg']['admin']));
            } else {
                $license->saveSetting('license', 'msg_admin', '');
            }
            if (!empty($resultData['msg']['all'])) {
                $license->saveSetting('license', 'msg_all', base64_encode($resultData['msg']['all']));
            } else {
                $license->saveSetting('license', 'msg_all', '');
            }
        } else {
            $license->saveSetting('license', 'msg_admin', '');
            $license->saveSetting('license', 'msg_all', '');
        }
        $license->saveSetting('license', 'last_validation', 'success');
        unset($_SESSION['COULD_NOT_CONNECT']);
    } else {
        $resultData = array();
        $resultData['versions'] = array();
        $license->saveSetting('license', 'last_connection_fail', TimeDate::getInstance()->nowDb());
        $license->saveSetting('license', 'last_validation', 'no_connection');
        if (empty($license->settings['license_last_validation_success']) && empty($license->settings['license_last_validation_fail']) && empty($license->settings['license_vk_end_date'])) {
            $license->saveSetting('license', 'vk_end_date', TimeDate::getInstance()->nowDb());
            $license->saveSetting('license', 'validation_key', base64_encode(serialize(array('verified' => false))));
        }
        $_SESSION['COULD_NOT_CONNECT'] = TimeDate::getInstance()->nowDb();
    }
    if (!empty($resultData['versions'])) {
        $license->saveSetting('license', 'latest_versions', base64_encode(serialize($resultData['versions'])));
    } else {
        $resultData['versions'] = array();
        $license->saveSetting('license', 'latest_versions', '');
    }
    include 'sugar_version.php';
    if (sizeof($resultData) == 1 && !empty($resultData['versions'][0]['version']) && compareVersions($sugar_version, $resultData['versions'][0]['version'])) {
        $resultData['versions'][0]['version'] = $sugar_version;
        $resultData['versions'][0]['description'] = "You have the latest version.";
    }
    return $resultData['versions'];
}
コード例 #26
0
 public function SubpanelQuickCreate($module, $view = 'QuickCreate', $proccessOverride = false)
 {
     $this->viewType = $view;
     //treat quickedit and quickcreate views as the same
     if ($this->viewType == 'QuickEdit') {
         $this->viewType = 'QuickCreate';
     }
     // locate the best viewdefs to use: 1. custom/module/quickcreatedefs.php 2. module/quickcreatedefs.php 3. editviewdefs as in metafile
     $source = SugarAutoLoader::existingCustomOne("modules/{$module}/metadata/quickcreatedefs.php");
     if (!$source) {
         $source = SugarAutoLoader::loadWithMetafiles($module, "editviewdefs");
         $this->viewType = 'EditView';
     }
     $this->ev = $this->getEditView();
     $this->ev->view = $this->viewType;
     $this->ev->ss = new Sugar_Smarty();
     $bean = BeanFactory::getBean($module);
     if ($bean && !empty($_REQUEST['record'])) {
         $bean->retrieve($_REQUEST['record']);
     }
     $this->ev->setup($module, $bean, $source);
     unset($bean);
     // Bug 49219 - Check empty before set defaults, or the settings from viewdefs above will be overridden.
     if (!isset($this->ev->defs['templateMeta']['form']['headerTpl'])) {
         $this->ev->defs['templateMeta']['form']['headerTpl'] = 'include/EditView/header.tpl';
     }
     if (!isset($this->ev->defs['templateMeta']['form']['footerTpl'])) {
         $this->ev->defs['templateMeta']['form']['footerTpl'] = 'include/EditView/footer.tpl';
     }
     // Comment below, breaks many out of the box viewdefs
     /*if (empty($this->ev->defs['templateMeta']['form']['buttons'])) $this->ev->defs['templateMeta']['form']['buttons'] = array('SUBPANELSAVE', 'SUBPANELCANCEL', 'SUBPANELFULLFORM');*/
     $this->ev->defs['templateMeta']['form']['buttons'] = array('SUBPANELSAVE', 'SUBPANELCANCEL', 'SUBPANELFULLFORM');
     //Load the parent view class if it exists.  Check for custom file first
     loadParentView('edit');
     $viewEditSource = SugarAutoLoader::existingCustomOne('modules/' . $module . '/views/view.edit.php');
     if (!empty($viewEditSource) && !$proccessOverride) {
         require_once $viewEditSource;
         $c = SugarAutoLoader::customClass($module . 'ViewEdit');
         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);
     }
 }
コード例 #27
0
 /**
  * Perform the actual massupdate.
  */
 protected function action_massupdate()
 {
     global $app_strings;
     if (!empty($_REQUEST['massupdate']) && $_REQUEST['massupdate'] == 'true' && (!empty($_REQUEST['uid']) || !empty($_REQUEST['entire']))) {
         if (!empty($_REQUEST['Delete']) && $_REQUEST['Delete'] == 'true' && !$this->bean->ACLAccess('delete') || (empty($_REQUEST['Delete']) || $_REQUEST['Delete'] != 'true') && !$this->bean->ACLAccess('save')) {
             ACLController::displayNoAccess(true);
             sugar_cleanup(true);
         }
         set_time_limit(0);
         //I'm wondering if we will set it never goes timeout here.
         // until we have more efficient way of handling MU, we have to disable the limit
         $GLOBALS['db']->setQueryLimit(0);
         require_once 'modules/MySettings/StoreQuery.php';
         $seed = BeanFactory::getBean($_REQUEST['module']);
         SugarAutoLoader::requireWithCustom('include/MassUpdate.php');
         $massUpdateClass = SugarAutoLoader::customClass('MassUpdate');
         $mass = new $massUpdateClass();
         $mass->setSugarBean($seed);
         if (isset($_REQUEST['entire']) && empty($_POST['mass'])) {
             $mass->generateSearchWhere($_REQUEST['module'], $_REQUEST['current_query_by_page']);
         }
         $arr = $mass->handleMassUpdate();
         $storeQuery = new StoreQuery();
         //restore the current search. to solve bug 24722 for multi tabs massupdate.
         $temp_req = array('current_query_by_page' => $_REQUEST['current_query_by_page'], 'return_module' => $_REQUEST['return_module'], 'return_action' => $_REQUEST['return_action']);
         if (!empty($_POST['mass'])) {
             $total_records = count($_POST['mass']);
             $failed_update = count($arr);
             $successful_update = $total_records - $failed_update;
             if ($successful_update == $total_records) {
                 //show succesful deletion message if this is a delete update
                 if (!empty($_REQUEST['Delete'])) {
                     $massupdate_status = $app_strings['TPL_MASSDELETE_SUCCESS'];
                     $massupdate_status = str_replace("{{num}}", $successful_update, $massupdate_status);
                 } else {
                     //show succesful update message if this is not a delete request
                     $massupdate_status = $app_strings['LBL_MASS_UPDATE_SUCCESS'];
                 }
             } else {
                 if (!empty($_REQUEST['Delete'])) {
                     $massupdate_status = $app_strings['TPL_MASSDELETE_SUCCESS'];
                 } else {
                     $massupdate_status = $app_strings['TPL_MASSUPDATE_SUCCESS'];
                 }
                 $massupdate_status .= " " . $app_strings['TPL_MASSUPDATE_WARNING_PERMISSION'];
                 $massupdate_status = str_replace("{{num}}", $successful_update, $massupdate_status);
                 $massupdate_status = str_replace("{{remain}}", $failed_update, $massupdate_status);
             }
             $temp_req['updated_records'] = $massupdate_status;
         }
         if ($_REQUEST['return_module'] == 'Emails') {
             if (!empty($_REQUEST['type']) && !empty($_REQUEST['ie_assigned_user_id'])) {
                 $this->req_for_email = array('type' => $_REQUEST['type'], 'ie_assigned_user_id' => $_REQUEST['ie_assigned_user_id']);
                 // Specifically for My Achieves
             }
         }
         $_REQUEST = array();
         $_REQUEST = unserialize(base64_decode($temp_req['current_query_by_page']));
         unset($_REQUEST[$seed->module_dir . '2_' . strtoupper($seed->object_name) . '_offset']);
         //after massupdate, the page should redirect to no offset page
         $storeQuery->saveFromRequest($_REQUEST['module']);
         $_REQUEST = array('return_module' => $temp_req['return_module'], 'return_action' => $temp_req['return_action'], 'updated_records' => $temp_req['updated_records']);
         //for post_massupdate, to go back to original page.
     } else {
         sugar_die("You must massupdate at least one record");
     }
 }
コード例 #28
0
ファイル: 5_FTSHook.php プロジェクト: jglaine/sugar761-ent
 /**
  * Get custom class name if that exists or original one if not for logic hook
  *
  * @return string
  */
 protected function getHookClass()
 {
     return SugarAutoLoader::customClass(self::HOOK_CLASS);
 }
コード例 #29
0
 /**
  * Lazily loads metadata hacks instance
  *
  * @return MetaDataHacks
  */
 protected function getMetaDataHacks()
 {
     if (!$this->metaDataHacks) {
         $className = SugarAutoLoader::customClass('MetaDataHacks');
         $this->metaDataHacks = new $className();
     }
     return $this->metaDataHacks;
 }
コード例 #30
0
 /**
  * Get SugarHeartbeatClient object
  *
  * @return SugarHeartbeatClient
  */
 protected function getClient()
 {
     SugarAutoLoader::requireWithCustom('include/SugarHeartbeat/SugarHeartbeatClient.php', true);
     $clientClass = SugarAutoLoader::customClass('SugarHeartbeatClient');
     return new $clientClass();
 }