This commit is contained in:
2024-04-27 09:23:34 +02:00
commit 11e713ca6f
11884 changed files with 3263371 additions and 0 deletions

View File

@@ -0,0 +1,65 @@
<?php
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/**
* ResourceObserver.php
* This class serves as the base class for the notifier/observable pattern used
* by the resource management framework.
*/
class ResourceObserver {
var $module;
var $limit;
function ResourceObserver($module) {
$this->module = $module;
}
function setLimit($limit) {
$this->limit = $limit;
}
function notify($msg = '') {
if($this->dieOnError) {
die($GLOBALS['app_strings']['ERROR_NOTIFY_OVERRIDE']);
} else {
echo($GLOBALS['app_strings']['ERROR_NOTIFY_OVERRIDE']);
}
}
}
?>

View File

@@ -0,0 +1,80 @@
<?php
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
require_once('include/resource/Observers/ResourceObserver.php');
class SoapResourceObserver extends ResourceObserver {
private $soapServer;
function SoapResourceObserver($module) {
parent::ResourceObserver($module);
}
/**
* set_soap_server
* This method accepts an instance of the nusoap soap server so that a proper
* response can be returned when the notify method is triggered.
* @param $server The instance of the nusoap soap server
*/
function set_soap_server(& $server) {
$this->soapServer = $server;
}
/**
* notify
* Soap implementation to notify the soap clients of a resource management error
* @param msg String message to possibly display
*/
public function notify($msg = '') {
header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error');
header('Content-Type: text/xml; charset="ISO-8859-1"');
$error = new SoapError();
$error->set_error('resource_management_error');
//Override the description
$error->description = $msg;
$this->soapServer->methodreturn = array('result'=>$msg, 'error'=>$error->get_soap_array());
$this->soapServer->serialize_return();
$this->soapServer->send_response();
sugar_cleanup(true);
}
}
?>

View File

@@ -0,0 +1,63 @@
<?php
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
require_once('include/resource/Observers/ResourceObserver.php');
/**
* WebResourceObserver.php
* This is a subclass of ResourceObserver to provide notification handling
* for web clients.
*/
class WebResourceObserver extends ResourceObserver {
function WebResourceObserver($module) {
parent::ResourceObserver($module);
}
/**
* notify
* Web implementation to notify the browser
* @param msg String message to possibly display
*
*/
public function notify($msg = '') {
echo $msg;
sugar_cleanup(true);
}
}
?>

View File

@@ -0,0 +1,153 @@
<?php
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/**
* ResourceManager.php
* This class is responsible for resource management of SQL queries, file usage, etc.
*/
class ResourceManager {
private static $instance;
private $_observers = array();
/**
* The constructor; declared as private
*/
private function ResourceManager() {
}
/**
* getInstance
* Singleton method to return static instance of ResourceManager
* @return The static singleton ResourceManager instance
*/
static public function getInstance(){
if (!isset(self::$instance)) {
self::$instance = new ResourceManager();
} // if
return self::$instance;
}
/**
* setup
* Handles determining the appropriate setup based on client type.
* It will create a SoapResourceObserver instance if the $module parameter is set to
* 'Soap'; otherwise, it will try to create a WebResourceObserver instance.
* @param $module The module value used to create the corresponding observer
* @return boolean value indicating whether or not an observer was successfully setup
*/
public function setup($module) {
//Check if config.php exists
if(!file_exists('config.php') || empty($module)) {
return false;
}
if($module == 'Soap') {
require_once('include/resource/Observers/SoapResourceObserver.php');
$observer = new SoapResourceObserver('Soap');
} else {
require_once('include/resource/Observers/WebResourceObserver.php');
$observer = new WebResourceObserver($module);
}
//Load config
if(!empty($observer->module)) {
$limit = 0;
if(isset($GLOBALS['sugar_config']['resource_management'])) {
$res = $GLOBALS['sugar_config']['resource_management'];
if(!empty($res['special_query_modules']) &&
in_array($observer->module, $res['special_query_modules']) &&
!empty($res['special_query_limit']) &&
is_int($res['special_query_limit']) &&
$res['special_query_limit'] > 0) {
$limit = $res['special_query_limit'];
} else if(!empty($res['default_limit']) && is_int($res['default_limit']) && $res['default_limit'] > 0) {
$limit = $res['default_limit'];
}
} //if
if($limit) {
$db = DBManagerFactory::getInstance();
$db->setQueryLimit($limit);
$observer->setLimit($limit);
$this->_observers[] = $observer;
}
return true;
}
return false;
}
/**
* notifyObservers
* This method notifies the registered observers with the provided message.
* @param $msg Message from language file to notify observers with
*/
public function notifyObservers($msg) {
if(empty($this->_observers)) {
return;
}
//Notify observers limit has been reached
if(empty($GLOBALS['app_strings'])) {
$GLOBALS['app_strings'] = return_application_language($GLOBALS['current_language']);
}
$limitMsg = $GLOBALS['app_strings'][$msg];
foreach( $this->_observers as $observer) {
$limit = $observer->limit;
$module = $observer->module;
eval("\$limitMsg = \"$limitMsg\";");
$GLOBALS['log']->fatal($limitMsg);
$observer->notify($limitMsg);
}
}
/*
* getObservers
* Returns the observer instances that have been setup for the ResourceManager instance
* @return Array of ResourceObserver(s)
*/
function getObservers() {
return $this->_observers;
}
}
?>