2013-09-23 19:30:44 +00:00
< ? php
2018-07-12 10:40:10 +00:00
if ( ! defined ( 'sugarEntry' ) || ! sugarEntry ) {
die ( 'Not A Valid Entry Point' );
}
2018-08-01 19:14:25 +00:00
/**
*
2013-09-23 19:30:44 +00:00
* SugarCRM Community Edition is a customer relationship management program developed by
* SugarCRM , Inc . Copyright ( C ) 2004 - 2013 SugarCRM Inc .
2018-08-01 19:14:25 +00:00
*
* SuiteCRM is an extension to SugarCRM Community Edition developed by SalesAgility Ltd .
* Copyright ( C ) 2011 - 2018 SalesAgility Ltd .
2014-07-07 15:33:23 +00:00
*
2013-09-23 19:30:44 +00:00
* 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 .
2014-07-07 15:33:23 +00:00
*
2013-09-23 19:30:44 +00:00
* 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
2018-08-01 19:14:25 +00:00
* FOR A PARTICULAR PURPOSE . See the GNU Affero General Public License for more
2013-09-23 19:30:44 +00:00
* details .
2014-07-07 15:33:23 +00:00
*
2013-09-23 19:30:44 +00:00
* 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 .
2014-07-07 15:33:23 +00:00
*
2013-09-23 19:30:44 +00:00
* You can contact SugarCRM , Inc . headquarters at 10050 North Wolfe Road ,
* SW2 - 130 , Cupertino , CA 95014 , USA . or at email address contact @ sugarcrm . com .
2014-07-07 15:33:23 +00:00
*
2013-09-23 19:30:44 +00:00
* 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.
2014-07-07 15:33:23 +00:00
*
2013-09-23 19:30:44 +00:00
* 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
2014-07-07 15:33:23 +00:00
* SugarCRM " logo and " Supercharged by SuiteCRM " logo. If the display of the logos is not
2018-08-01 19:14:25 +00:00
* reasonably feasible for technical reasons , the Appropriate Legal Notices must
* display the words " Powered by SugarCRM " and " Supercharged by SuiteCRM " .
*/
2013-09-23 19:30:44 +00:00
require_once ( 'modules/Configurator/Configurator.php' );
2020-01-22 13:51:48 +00:00
$admin = BeanFactory :: newBean ( 'Administration' );
2013-09-23 19:30:44 +00:00
$admin -> retrieveSettings ();
// Handle posts
2019-01-25 14:22:15 +00:00
if ( ! empty ( $_REQUEST [ 'process' ])) {
2013-09-23 19:30:44 +00:00
// Check the cleanup logic hook, make sure it is still there
2019-01-25 14:14:52 +00:00
check_logic_hook_file ( 'Users' , 'after_login' , array ( 1 , 'SugarFeed old feed entry remover' , 'modules/SugarFeed/SugarFeedFlush.php' , 'SugarFeedFlush' , 'flushStaleEntries' ));
2013-09-23 19:30:44 +00:00
// We have data posted
2019-01-25 14:22:15 +00:00
if ( $_REQUEST [ 'process' ] == 'true' ) {
2013-09-23 19:30:44 +00:00
// They want us to process it, the false will just fall outside of this statement
2019-01-25 14:22:15 +00:00
if ( $_REQUEST [ 'feed_enable' ] == '1' ) {
2013-09-23 19:30:44 +00:00
// The feed is enabled, pay attention to what categories should be enabled or disabled
2019-01-25 14:22:15 +00:00
if ( ! isset ( $db )) {
2013-09-23 19:30:44 +00:00
$db = DBManagerFactory :: getInstance ();
}
$ret = $db -> query ( " SELECT * FROM config WHERE category = 'sugarfeed' AND name LIKE 'module_%' " );
$current_modules = array ();
2019-01-25 14:22:15 +00:00
while ( $row = $db -> fetchByAssoc ( $ret )) {
2013-09-23 19:30:44 +00:00
$current_modules [ $row [ 'name' ]] = $row [ 'value' ];
}
$active_modules = $_REQUEST [ 'modules' ];
2019-01-25 14:22:15 +00:00
if ( ! is_array ( $active_modules )) {
2019-01-25 13:51:46 +00:00
$active_modules = array ();
}
2013-09-23 19:30:44 +00:00
2019-01-25 14:22:15 +00:00
foreach ( $active_modules as $name => $is_active ) {
2019-01-25 14:14:52 +00:00
$module = substr ( $name , 7 );
2013-09-23 19:30:44 +00:00
2019-01-25 14:22:15 +00:00
if ( $is_active == '1' ) {
2013-09-23 19:30:44 +00:00
// They are activating something that was disabled before
SugarFeed :: activateModuleFeed ( $module );
} else {
// They are disabling something that was active before
SugarFeed :: disableModuleFeed ( $module );
}
}
2019-01-25 14:14:52 +00:00
$admin -> saveSetting ( 'sugarfeed' , 'enabled' , '1' );
2013-09-23 19:30:44 +00:00
} else {
2019-01-25 14:14:52 +00:00
$admin -> saveSetting ( 'sugarfeed' , 'enabled' , '0' );
2013-09-23 19:30:44 +00:00
// Now we need to remove all of the logic hooks, so they don't continue to run
// We also need to leave the database alone, so they can enable/disable modules with the system disabled
$modulesWithFeeds = SugarFeed :: getAllFeedModules ();
2019-01-25 14:22:15 +00:00
foreach ( $modulesWithFeeds as $currFeedModule ) {
2019-01-25 14:14:52 +00:00
SugarFeed :: disableModuleFeed ( $currFeedModule , false );
2013-09-23 19:30:44 +00:00
}
}
2019-01-25 14:14:52 +00:00
$admin -> retrieveSettings ( false , true );
2013-09-23 19:30:44 +00:00
SugarFeed :: flushBackendCache ();
2019-01-25 13:51:46 +00:00
} else {
2019-01-25 14:22:15 +00:00
if ( $_REQUEST [ 'process' ] == 'deleteRecords' ) {
if ( ! isset ( $db )) {
2019-01-25 13:51:46 +00:00
$db = DBManagerFactory :: getInstance ();
}
2019-01-25 14:24:15 +00:00
$db -> query ( " UPDATE sugarfeed SET deleted = '1' " );
2019-01-25 14:14:52 +00:00
echo ( translate ( 'LBL_RECORDS_DELETED' , 'SugarFeed' ));
2013-09-23 19:30:44 +00:00
}
}
2019-01-25 14:22:15 +00:00
if ( $_REQUEST [ 'process' ] == 'true' || $_REQUEST [ 'process' ] == 'false' ) {
2013-09-23 19:30:44 +00:00
header ( 'Location: index.php?module=Administration&action=index' );
return ;
}
}
$sugar_smarty = new Sugar_Smarty ();
$sugar_smarty -> assign ( 'mod' , $mod_strings );
$sugar_smarty -> assign ( 'app' , $app_strings );
2019-01-25 14:22:15 +00:00
if ( isset ( $admin -> settings [ 'sugarfeed_enabled' ]) && $admin -> settings [ 'sugarfeed_enabled' ] == '1' ) {
2019-01-25 14:14:52 +00:00
$sugar_smarty -> assign ( 'enabled_checkbox' , 'checked' );
2013-09-23 19:30:44 +00:00
}
$possible_feeds = SugarFeed :: getAllFeedModules ();
$module_list = array ();
$userFeedEnabled = 0 ;
2019-01-25 14:22:15 +00:00
foreach ( $possible_feeds as $module ) {
2013-09-23 19:30:44 +00:00
$currModule = array ();
2019-01-25 14:22:15 +00:00
if ( isset ( $admin -> settings [ 'sugarfeed_module_' . $module ]) && $admin -> settings [ 'sugarfeed_module_' . $module ] == '1' ) {
2013-09-23 19:30:44 +00:00
$currModule [ 'enabled' ] = 1 ;
} else {
$currModule [ 'enabled' ] = 0 ;
}
$currModule [ 'module' ] = $module ;
2019-01-25 14:22:15 +00:00
if ( $module == 'UserFeed' ) {
2013-09-23 19:30:44 +00:00
// Fake module, need to handle specially
$userFeedEnabled = $currModule [ 'enabled' ];
continue ;
2018-07-31 14:24:44 +00:00
} else {
$currModule [ 'label' ] = $GLOBALS [ 'app_list_strings' ][ 'moduleList' ][ $module ];
2018-07-24 14:42:22 +00:00
}
2013-09-23 19:30:44 +00:00
$module_list [] = $currModule ;
}
2019-01-25 14:14:52 +00:00
$sugar_smarty -> assign ( 'module_list' , $module_list );
$sugar_smarty -> assign ( 'user_feed_enabled' , $userFeedEnabled );
2013-09-23 19:30:44 +00:00
echo getClassicModuleTitle (
2019-07-04 16:06:34 +00:00
" Administration " ,
array (
2019-01-25 14:14:52 +00:00
" <a href='index.php?module=Administration&action=index'> " . translate ( 'LBL_MODULE_NAME' , 'Administration' ) . " </a> " ,
2013-09-23 19:30:44 +00:00
$mod_strings [ 'LBL_MODULE_NAME' ],
2019-01-25 14:14:52 +00:00
),
2019-07-04 16:06:34 +00:00
false
2013-09-23 19:30:44 +00:00
);
$sugar_smarty -> display ( 'modules/SugarFeed/AdminSettings.tpl' );