]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/Configurator/controller.php
Release 6.4.0
[Github/sugarcrm.git] / modules / Configurator / controller.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-2011 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 require_once('include/MVC/Controller/SugarController.php');
40 class ConfiguratorController extends SugarController
41 {
42     /**
43      * Go to the font manager view
44      */
45     function action_FontManager(){
46         global $current_user;
47         if(!is_admin($current_user)){
48             sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']); 
49         }
50         $this->view = 'fontmanager';
51     }
52
53     /**
54      * Delete a font and go back to the font manager
55      */
56     function action_deleteFont(){
57         global $current_user;
58         if(!is_admin($current_user)){
59             sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']);
60         }
61         $urlSTR = 'index.php?module=Configurator&action=FontManager';
62         if(!empty($_REQUEST['filename'])){
63             require_once('include/Sugarpdf/FontManager.php');
64             $fontManager = new FontManager();
65             $fontManager->filename = $_REQUEST['filename'];
66             if(!$fontManager->deleteFont()){
67                 $urlSTR .='&error='.urlencode(implode("<br>",$fontManager->errors));
68             }
69         }
70         header("Location: $urlSTR");
71     }
72
73     function action_listview(){
74         global $current_user;
75         if(!is_admin($current_user)){
76             sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']); 
77         }
78         $this->view = 'edit';
79     }
80     /**
81      * Show the addFont view
82      */
83     function action_addFontView(){
84         global $current_user;
85         if(!is_admin($current_user)){
86             sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']); 
87         }
88         $this->view = 'addFontView';
89     }
90     /**
91      * Add a new font and show the addFontResult view
92      */
93     function action_addFont(){
94         global $current_user, $mod_strings;
95         if(!is_admin($current_user)){
96             sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']);
97         }
98         if(empty($_FILES['pdf_metric_file']['name'])){
99             $this->errors[]=translate("ERR_MISSING_REQUIRED_FIELDS")." ".translate("LBL_PDF_METRIC_FILE", "Configurator");
100             $this->view = 'addFontView';
101             return;
102         }
103         if(empty($_FILES['pdf_font_file']['name'])){
104             $this->errors[]=translate("ERR_MISSING_REQUIRED_FIELDS")." ".translate("LBL_PDF_FONT_FILE", "Configurator");
105             $this->view = 'addFontView';
106             return;
107         }
108         $path_info = pathinfo($_FILES['pdf_font_file']['name']);
109         $path_info_metric = pathinfo($_FILES['pdf_metric_file']['name']);
110         if(($path_info_metric['extension']!="afm" && $path_info_metric['extension']!="ufm") ||
111         ($path_info['extension']!="ttf" && $path_info['extension']!="otf" && $path_info['extension']!="pfb")){
112             $this->errors[]=translate("JS_ALERT_PDF_WRONG_EXTENSION", "Configurator");
113             $this->view = 'addFontView';
114             return;
115         }
116
117         if($_REQUEST['pdf_embedded'] == "false"){
118             if(empty($_REQUEST['pdf_cidinfo'])){
119                 $this->errors[]=translate("ERR_MISSING_CIDINFO", "Configurator");
120                 $this->view = 'addFontView';
121                 return;
122             }
123             $_REQUEST['pdf_embedded']=false;
124         }else{
125             $_REQUEST['pdf_embedded']=true;
126             $_REQUEST['pdf_cidinfo']="";
127         }
128         if(empty($_REQUEST['pdf_patch'])){
129             $_REQUEST['pdf_patch']="return array();";
130         }else{
131             $_REQUEST['pdf_patch']="return {$_REQUEST['pdf_patch']};";
132         }
133         $this->view = 'addFontResult';
134     }
135     function action_saveadminwizard()
136     {
137         global $current_user;
138         if(!is_admin($current_user)){
139             sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']); 
140         }
141         $focus = new Administration();
142         $focus->retrieveSettings();
143         $focus->saveConfig();
144
145         $configurator = new Configurator();
146         $configurator->populateFromPost();
147         $configurator->handleOverride();
148         $configurator->parseLoggerSettings();
149         $configurator->saveConfig();
150
151         // Bug 37310 - Delete any existing currency that matches the one we've just set the default to during the admin wizard
152         $currency = new Currency;
153         $currency->retrieve($currency->retrieve_id_by_name($_REQUEST['default_currency_name']));
154         if ( !empty($currency->id)
155                 && $currency->symbol == $_REQUEST['default_currency_symbol']
156                 && $currency->iso4217 == $_REQUEST['default_currency_iso4217'] ) {
157             $currency->deleted = 1;
158             $currency->save();
159         }
160
161         SugarApplication::redirect('index.php?module=Users&action=Wizard&skipwelcome=1');
162     }
163
164     function action_saveconfig()
165     {
166         global $current_user;
167         if(!is_admin($current_user)){
168             sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']); 
169         }
170         $configurator = new Configurator();
171         $configurator->saveConfig();
172
173         $focus = new Administration();
174         $focus->saveConfig();
175
176         // Clear the Contacts file b/c portal flag affects rendering
177         if (file_exists($cachedfile = sugar_cached('modules/Contacts/EditView.tpl')))
178            unlink($cachedfile);
179
180         SugarApplication::redirect('index.php?module=Administration&action=index');
181     }
182
183     function action_detail()
184     {
185         global $current_user;
186         if(!is_admin($current_user)){
187             sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']); 
188         }
189         $this->view = 'edit';
190     }
191 }