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 ********************************************************************************/
39 class ViewAdminsettings extends SugarView
42 * @see SugarView::_getModuleTab()
44 protected function _getModuleTab()
46 return 'Administration';
50 * @see SugarView::_getModuleTitleParams()
52 protected function _getModuleTitleParams($browserTitle = false)
57 "<a href='index.php?module=Administration&action=index'>".translate('LBL_MODULE_NAME','Administration')."</a>",
58 $mod_strings['LBL_MODULE_NAME'],
63 * @see SugarView::display()
65 public function display()
67 global $mod_strings, $app_strings;
69 $admin = new Administration();
70 $admin->retrieveSettings();
73 if ( !empty($_REQUEST['process']) ) {
74 // Check the cleanup logic hook, make sure it is still there
75 check_logic_hook_file('Users','after_login', array(1, 'SugarFeed old feed entry remover', 'modules/SugarFeed/SugarFeedFlush.php', 'SugarFeedFlush', 'flushStaleEntries'));
77 // We have data posted
78 if ( $_REQUEST['process'] == 'true' ) {
79 // They want us to process it, the false will just fall outside of this statement
80 if ( $_REQUEST['feed_enable'] == '1' ) {
81 // The feed is enabled, pay attention to what categories should be enabled or disabled
83 $db = DBManagerFactory::getInstance();
84 $ret = $db->query("SELECT * FROM config WHERE category = 'sugarfeed' AND name LIKE 'module_%'");
85 $current_modules = array();
86 while ( $row = $db->fetchByAssoc($ret) ) {
87 $current_modules[$row['name']] = $row['value'];
90 $active_modules = $_REQUEST['modules'];
91 if ( ! is_array($active_modules) ) { $active_modules = array(); }
93 foreach ( $active_modules as $name => $is_active ) {
94 $module = substr($name,7);
96 if ( $is_active == '1' ) {
97 // They are activating something that was disabled before
98 SugarFeed::activateModuleFeed($module);
100 // They are disabling something that was active before
101 SugarFeed::disableModuleFeed($module);
105 $admin->saveSetting('sugarfeed','enabled','1');
107 $admin->saveSetting('sugarfeed','enabled','0');
108 // Now we need to remove all of the logic hooks, so they don't continue to run
109 // We also need to leave the database alone, so they can enable/disable modules with the system disabled
110 $modulesWithFeeds = SugarFeed::getAllFeedModules();
112 foreach ( $modulesWithFeeds as $currFeedModule ) {
113 SugarFeed::disableModuleFeed($currFeedModule,FALSE);
117 $admin->retrieveSettings(FALSE,TRUE);
118 SugarFeed::flushBackendCache();
119 } else if ( $_REQUEST['process'] == 'deleteRecords' ) {
120 if ( ! isset($db) ) {
121 $db = DBManagerFactory::getInstance();
123 $db->query("UPDATE sugarfeed SET deleted = '1'");
124 echo(translate('LBL_RECORDS_DELETED','SugarFeed'));
129 if ( $_REQUEST['process'] == 'true' || $_REQUEST['process'] == 'false' ) {
130 header('Location: index.php?module=Administration&action=index');
135 $sugar_smarty = new Sugar_Smarty();
136 $sugar_smarty->assign('mod', $mod_strings);
137 $sugar_smarty->assign('app', $app_strings);
139 if ( isset($admin->settings['sugarfeed_enabled']) && $admin->settings['sugarfeed_enabled'] == '1' ) {
140 $sugar_smarty->assign('enabled_checkbox','checked');
143 $possible_feeds = SugarFeed::getAllFeedModules();
144 $module_list = array();
145 $userFeedEnabled = 0;
146 foreach ( $possible_feeds as $module ) {
147 $currModule = array();
148 if ( isset($admin->settings['sugarfeed_module_'.$module]) && $admin->settings['sugarfeed_module_'.$module] == '1' ) {
149 $currModule['enabled'] = 1;
151 $currModule['enabled'] = 0;
154 $currModule['module'] = $module;
155 if ( $module == 'UserFeed' ) {
156 // Fake module, need to handle specially
157 $userFeedEnabled = $currModule['enabled'];
160 $currModule['label'] = $GLOBALS['app_list_strings']['moduleList'][$module];
163 $module_list[] = $currModule;
165 $sugar_smarty->assign('module_list',$module_list);
166 $sugar_smarty->assign('user_feed_enabled',$userFeedEnabled);
168 echo getClassicModuleTitle(
171 "<a href='index.php?module=Administration&action=index'>".translate('LBL_MODULE_NAME','Administration')."</a>",
172 $mod_strings['LBL_MODULE_NAME'],
176 $sugar_smarty->display('modules/SugarFeed/tpls/AdminSettings.tpl');