]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/SugarFeed/AdminSettings.php
Release 6.5.0
[Github/sugarcrm.git] / modules / SugarFeed / AdminSettings.php
1 <?php
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.
6  * 
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.
13  * 
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
17  * details.
18  * 
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
22  * 02110-1301 USA.
23  * 
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.
26  * 
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.
30  * 
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  ********************************************************************************/
37
38
39
40 require_once('modules/Configurator/Configurator.php');
41
42
43 $admin = new Administration();
44 $admin->retrieveSettings();
45
46 // Handle posts
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'));
50
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
56
57             if ( ! isset($db) ) {
58                 $db = DBManagerFactory::getInstance();
59             }
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'];
64             }
65             
66             $active_modules = $_REQUEST['modules'];
67             if ( ! is_array($active_modules) ) { $active_modules = array(); }
68             
69             foreach ( $active_modules as $name => $is_active ) {
70                 $module = substr($name,7);
71                 
72                 if ( $is_active == '1' ) {
73                     // They are activating something that was disabled before
74                     SugarFeed::activateModuleFeed($module);
75                 } else {
76                     // They are disabling something that was active before
77                     SugarFeed::disableModuleFeed($module);
78                 }
79             }
80             
81             $admin->saveSetting('sugarfeed','enabled','1');
82         } else {
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();
87             
88             foreach ( $modulesWithFeeds as $currFeedModule ) {
89                 SugarFeed::disableModuleFeed($currFeedModule,FALSE);
90             }
91         }
92
93         $admin->retrieveSettings(FALSE,TRUE);
94         SugarFeed::flushBackendCache();
95     } else if ( $_REQUEST['process'] == 'deleteRecords' ) {
96         if ( ! isset($db) ) {
97             $db = DBManagerFactory::getInstance();
98         }
99         $db->query("UPDATE sugarfeed SET deleted = '1'");        
100         echo(translate('LBL_RECORDS_DELETED','SugarFeed'));
101     }
102
103
104
105     if ( $_REQUEST['process'] == 'true' || $_REQUEST['process'] == 'false' ) {
106         header('Location: index.php?module=Administration&action=index');
107         return;
108     }
109 }
110
111 $sugar_smarty   = new Sugar_Smarty();
112 $sugar_smarty->assign('mod', $mod_strings);
113 $sugar_smarty->assign('app', $app_strings);
114
115 if ( isset($admin->settings['sugarfeed_enabled']) && $admin->settings['sugarfeed_enabled'] == '1' ) {
116     $sugar_smarty->assign('enabled_checkbox','checked');
117 }
118
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;
126     } else {
127         $currModule['enabled'] = 0;
128     }
129
130     $currModule['module'] = $module;
131     if ( $module == 'UserFeed' ) {
132         // Fake module, need to handle specially
133         $userFeedEnabled = $currModule['enabled'];
134         continue;
135     } else {
136         $currModule['label'] = $GLOBALS['app_list_strings']['moduleList'][$module];
137     }
138
139     $module_list[] = $currModule;
140 }
141 $sugar_smarty->assign('module_list',$module_list);
142 $sugar_smarty->assign('user_feed_enabled',$userFeedEnabled);
143
144 echo getClassicModuleTitle(
145         "Administration", 
146         array(
147             "<a href='index.php?module=Administration&action=index'>".translate('LBL_MODULE_NAME','Administration')."</a>",
148            $mod_strings['LBL_MODULE_NAME'],
149            ), 
150         false
151         );
152 $sugar_smarty->display('modules/SugarFeed/AdminSettings.tpl');
153