action_saveglobalsearchsettings()   A
last analyzed

Complexity

Conditions 3
Paths 8

Size

Total Lines 23
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12
Metric Value
cc 3
eloc 12
nc 8
nop 0
dl 0
loc 23
ccs 0
cts 20
cp 0
crap 12
rs 9.0856
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-2013 SugarCRM Inc.
6
7
 * SuiteCRM is an extension to SugarCRM Community Edition developed by Salesagility Ltd.
8
 * Copyright (C) 2011 - 2014 Salesagility Ltd.
9
 *
10
 * This program is free software; you can redistribute it and/or modify it under
11
 * the terms of the GNU Affero General Public License version 3 as published by the
12
 * Free Software Foundation with the addition of the following permission added
13
 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
14
 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
15
 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
16
 *
17
 * This program is distributed in the hope that it will be useful, but WITHOUT
18
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19
 * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
20
 * details.
21
 *
22
 * You should have received a copy of the GNU Affero General Public License along with
23
 * this program; if not, see http://www.gnu.org/licenses or write to the Free
24
 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25
 * 02110-1301 USA.
26
 *
27
 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
28
 * SW2-130, Cupertino, CA 95014, USA. or at email address [email protected].
29
 *
30
 * The interactive user interfaces in modified source and object code versions
31
 * of this program must display Appropriate Legal Notices, as required under
32
 * Section 5 of the GNU Affero General Public License version 3.
33
 *
34
 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
35
 * these Appropriate Legal Notices must retain the display of the "Powered by
36
 * SugarCRM" logo and "Supercharged by SuiteCRM" logo. If the display of the logos is not
37
 * reasonably feasible for  technical reasons, the Appropriate Legal Notices must
38
 * display the words  "Powered by SugarCRM" and "Supercharged by SuiteCRM".
39
 ********************************************************************************/
40
41
42
class AdministrationController extends SugarController
43
{
44
    public function action_savetabs()
45
    {
46
        require_once('include/SubPanel/SubPanelDefinitions.php');
47
        require_once('modules/MySettings/TabController.php');
48
49
50
        global $current_user, $app_strings;
51
52
        if (!is_admin($current_user)) sugar_die($app_strings['ERR_NOT_ADMIN']);
53
54
        // handle the tabs listing
55
        $toDecode = html_entity_decode  ($_REQUEST['enabled_tabs'], ENT_QUOTES);
56
        $enabled_tabs = json_decode($toDecode);
57
        $tabs = new TabController();
58
        $tabs->set_system_tabs($enabled_tabs);
59
        $tabs->set_users_can_edit(isset($_REQUEST['user_edit_tabs']) && $_REQUEST['user_edit_tabs'] == 1);
60
61
        // handle the subpanels
62
        if(isset($_REQUEST['disabled_tabs'])) {
63
            $disabledTabs = json_decode(html_entity_decode($_REQUEST['disabled_tabs'], ENT_QUOTES));
64
            $disabledTabsKeyArray = TabController::get_key_array($disabledTabs);
65
            SubPanelDefinitions::set_hidden_subpanels($disabledTabsKeyArray);
66
        }
67
68
        header("Location: index.php?module=Administration&action=ConfigureTabs");
69
    }
70
71
    public function action_savelanguages()
72
    {
73
        global $sugar_config;
74
        $toDecode = html_entity_decode  ($_REQUEST['disabled_langs'], ENT_QUOTES);
75
        $disabled_langs = json_decode($toDecode);
76
        $toDecode = html_entity_decode  ($_REQUEST['enabled_langs'], ENT_QUOTES);
77
        $enabled_langs = json_decode($toDecode);
78
        $cfg = new Configurator();
79
        $cfg->config['disabled_languages'] = join(',', $disabled_langs);
80
        // TODO: find way to enforce order
81
        $cfg->handleOverride();
82
        header("Location: index.php?module=Administration&action=Languages");
83
    }
84
85
86
    /**
87
     * action_saveglobalsearchsettings
88
     *
89
     * This method handles saving the selected modules to display in the Global Search Settings.
90
     * It instantiates an instance of UnifiedSearchAdvanced and then calls the saveGlobalSearchSettings
91
     * method.
92
     *
93
     */
94
    public function action_saveglobalsearchsettings()
95
    {
96
		 global $current_user, $app_strings;
97
98
		 if (!is_admin($current_user))
99
		 {
100
		     sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']);
101
		 }
102
103
    	 try
104
         {
105
	    	 require_once('modules/Home/UnifiedSearchAdvanced.php');
106
	    	 $unifiedSearchAdvanced = new UnifiedSearchAdvanced();
107
	    	 $unifiedSearchAdvanced->saveGlobalSearchSettings();
108
109
             $return = 'true';
110
            echo $return;
111
    	 }
112
         catch (Exception $ex)
113
         {
114
    	 	 echo "false";
115
    	 }
116
    }
117
118
    /**
119
     *
120
     * Merge current FTS config with the new passed parameters:
121
     *
122
     * We want to merge the current $sugar_config settings with those passed in
123
     * to be able to add additional parameters which are currently not supported
124
     * in the UI (i.e. additional curl settings for elastic search for auth)
125
     *
126
     * @param array $config
0 ignored issues
show
Documentation introduced by
There is no parameter named $config. Did you maybe mean $newConfig?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
127
     * @return array
128
     */
129
    protected function mergeFtsConfig($type, $newConfig)
130
    {
131
        $currentConfig = SugarConfig::getInstance()->get("full_text_engine.{$type}", array());
132
        return array_merge($currentConfig, $newConfig);
133
    }
134
135
    public function action_UpdateAjaxUI()
136
    {
137
        require_once('modules/Configurator/Configurator.php');
138
        $cfg = new Configurator();
139
        $disabled = json_decode(html_entity_decode  ($_REQUEST['disabled_modules'], ENT_QUOTES));
140
        $cfg->config['addAjaxBannedModules'] = empty($disabled) ? FALSE : $disabled;
141
        $cfg->handleOverride();
142
        $this->view = "configureajaxui";
143
    }
144
145
146
    /*
147
     * action_callRebuildSprites
148
     *
149
     * This method is responsible for actually running the SugarSpriteBuilder class to rebuild the sprites.
150
     * It is called from the ajax request issued by RebuildSprites.php.
151
     */
152
    public function action_callRebuildSprites()
153
    {
154
        global $current_user;
155
        $this->view = 'ajax';
156
        if(function_exists('imagecreatetruecolor'))
157
        {
158
            if(is_admin($current_user))
159
            {
160
                require_once('modules/UpgradeWizard/uw_utils.php');
161
                rebuildSprites(false);
162
            }
163
        } else {
164
            echo $mod_strings['LBL_SPRITES_NOT_SUPPORTED'];
165
            $GLOBALS['log']->error($mod_strings['LBL_SPRITES_NOT_SUPPORTED']);
166
        }
167
    }
168
}
169