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.
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 require_once('include/MVC/Controller/SugarController.php');
40 class ConfiguratorController extends SugarController
43 * Go to the font manager view
45 function action_FontManager(){
47 if(!is_admin($current_user)){
48 sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']);
50 $this->view = 'fontmanager';
54 * Delete a font and go back to the font manager
56 function action_deleteFont(){
58 if(!is_admin($current_user)){
59 sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']);
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));
70 header("Location: $urlSTR");
73 function action_listview(){
75 if(!is_admin($current_user)){
76 sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']);
81 * Show the addFont view
83 function action_addFontView(){
85 if(!is_admin($current_user)){
86 sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']);
88 $this->view = 'addFontView';
91 * Add a new font and show the addFontResult view
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']);
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';
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';
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';
117 if($_REQUEST['pdf_embedded'] == "false"){
118 if(empty($_REQUEST['pdf_cidinfo'])){
119 $this->errors[]=translate("ERR_MISSING_CIDINFO", "Configurator");
120 $this->view = 'addFontView';
123 $_REQUEST['pdf_embedded']=false;
125 $_REQUEST['pdf_embedded']=true;
126 $_REQUEST['pdf_cidinfo']="";
128 if(empty($_REQUEST['pdf_patch'])){
129 $_REQUEST['pdf_patch']="return array();";
131 $_REQUEST['pdf_patch']="return {$_REQUEST['pdf_patch']};";
133 $this->view = 'addFontResult';
135 function action_saveadminwizard()
137 global $current_user;
138 if(!is_admin($current_user)){
139 sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']);
141 $focus = new Administration();
142 $focus->retrieveSettings();
143 $focus->saveConfig();
145 $configurator = new Configurator();
146 $configurator->populateFromPost();
147 $configurator->handleOverride();
148 $configurator->parseLoggerSettings();
149 $configurator->saveConfig();
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;
161 SugarApplication::redirect('index.php?module=Users&action=Wizard&skipwelcome=1');
164 function action_saveconfig()
166 global $current_user;
167 if(!is_admin($current_user)){
168 sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']);
170 $configurator = new Configurator();
171 $configurator->saveConfig();
173 $focus = new Administration();
174 $focus->saveConfig();
176 // Clear the Contacts file b/c portal flag affects rendering
177 if (file_exists($cachedfile = sugar_cached('modules/Contacts/EditView.tpl')))
180 SugarApplication::redirect('index.php?module=Administration&action=index');
183 function action_detail()
185 global $current_user;
186 if(!is_admin($current_user)){
187 sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']);
189 $this->view = 'edit';