2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4 * SugarCRM Community Edition is a customer relationship management program developed by
5 * SugarCRM, Inc. Copyright (C) 2004-2012 SugarCRM Inc.
7 * This program is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU Affero General Public License version 3 as published by the
9 * Free Software Foundation with the addition of the following permission added
10 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
19 * You should have received a copy of the GNU Affero General Public License along with
20 * this program; if not, see http://www.gnu.org/licenses or write to the Free
21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
27 * The interactive user interfaces in modified source and object code versions
28 * of this program must display Appropriate Legal Notices, as required under
29 * Section 5 of the GNU Affero General Public License version 3.
31 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
32 * these Appropriate Legal Notices must retain the display of the "Powered by
33 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34 * technical reasons, the Appropriate Legal Notices must display the words
35 * "Powered by SugarCRM".
36 ********************************************************************************/
40 require_once('modules/Configurator/Configurator.php');
43 $admin = new Administration();
44 $admin->retrieveSettings();
47 if ( !empty($_REQUEST['process']) ) {
48 // Check the cleanup logic hook, make sure it is still there
49 check_logic_hook_file('Users','after_login', array(1, 'SugarFeed old feed entry remover', 'modules/SugarFeed/SugarFeedFlush.php', 'SugarFeedFlush', 'flushStaleEntries'));
51 // We have data posted
52 if ( $_REQUEST['process'] == 'true' ) {
53 // They want us to process it, the false will just fall outside of this statement
54 if ( $_REQUEST['feed_enable'] == '1' ) {
55 // The feed is enabled, pay attention to what categories should be enabled or disabled
58 $db = DBManagerFactory::getInstance();
60 $ret = $db->query("SELECT * FROM config WHERE category = 'sugarfeed' AND name LIKE 'module_%'");
61 $current_modules = array();
62 while ( $row = $db->fetchByAssoc($ret) ) {
63 $current_modules[$row['name']] = $row['value'];
66 $active_modules = $_REQUEST['modules'];
67 if ( ! is_array($active_modules) ) { $active_modules = array(); }
69 foreach ( $active_modules as $name => $is_active ) {
70 $module = substr($name,7);
72 if ( $is_active == '1' ) {
73 // They are activating something that was disabled before
74 SugarFeed::activateModuleFeed($module);
76 // They are disabling something that was active before
77 SugarFeed::disableModuleFeed($module);
81 $admin->saveSetting('sugarfeed','enabled','1');
83 $admin->saveSetting('sugarfeed','enabled','0');
84 // Now we need to remove all of the logic hooks, so they don't continue to run
85 // We also need to leave the database alone, so they can enable/disable modules with the system disabled
86 $modulesWithFeeds = SugarFeed::getAllFeedModules();
88 foreach ( $modulesWithFeeds as $currFeedModule ) {
89 SugarFeed::disableModuleFeed($currFeedModule,FALSE);
93 $admin->retrieveSettings(FALSE,TRUE);
94 SugarFeed::flushBackendCache();
95 } else if ( $_REQUEST['process'] == 'deleteRecords' ) {
97 $db = DBManagerFactory::getInstance();
99 $db->query("UPDATE sugarfeed SET deleted = '1'");
100 echo(translate('LBL_RECORDS_DELETED','SugarFeed'));
105 if ( $_REQUEST['process'] == 'true' || $_REQUEST['process'] == 'false' ) {
106 header('Location: index.php?module=Administration&action=index');
111 $sugar_smarty = new Sugar_Smarty();
112 $sugar_smarty->assign('mod', $mod_strings);
113 $sugar_smarty->assign('app', $app_strings);
115 if ( isset($admin->settings['sugarfeed_enabled']) && $admin->settings['sugarfeed_enabled'] == '1' ) {
116 $sugar_smarty->assign('enabled_checkbox','checked');
119 $possible_feeds = SugarFeed::getAllFeedModules();
120 $module_list = array();
121 $userFeedEnabled = 0;
122 foreach ( $possible_feeds as $module ) {
123 $currModule = array();
124 if ( isset($admin->settings['sugarfeed_module_'.$module]) && $admin->settings['sugarfeed_module_'.$module] == '1' ) {
125 $currModule['enabled'] = 1;
127 $currModule['enabled'] = 0;
130 $currModule['module'] = $module;
131 if ( $module == 'UserFeed' ) {
132 // Fake module, need to handle specially
133 $userFeedEnabled = $currModule['enabled'];
136 $currModule['label'] = $GLOBALS['app_list_strings']['moduleList'][$module];
139 $module_list[] = $currModule;
141 $sugar_smarty->assign('module_list',$module_list);
142 $sugar_smarty->assign('user_feed_enabled',$userFeedEnabled);
144 echo getClassicModuleTitle(
147 "<a href='index.php?module=Administration&action=index'>".translate('LBL_MODULE_NAME','Administration')."</a>",
148 $mod_strings['LBL_MODULE_NAME'],
152 $sugar_smarty->display('modules/SugarFeed/AdminSettings.tpl');