]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/Configurator/controller.php
Release 6.1.4
[Github/sugarcrm.git] / modules / Configurator / controller.php
1 <?php
2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4  * SugarCRM 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         $this->view = 'fontmanager';
47     }
48     
49     /**
50      * Delete a font and go back to the font manager
51      */
52     function action_deleteFont(){
53         global $current_user;
54         if(!is_admin($current_user)){
55             sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']); 
56         }
57         $urlSTR = 'index.php?module=Configurator&action=FontManager';
58         if(!empty($_REQUEST['filename'])){
59             require_once('include/Sugarpdf/FontManager.php');
60             $fontManager = new FontManager();
61             $fontManager->filename = $_REQUEST['filename'];
62             if(!$fontManager->deleteFont()){
63                 $urlSTR .='&error='.urlencode(implode("<br>",$fontManager->errors));
64             }
65         }
66         header("Location: $urlSTR");
67     }
68     
69     function action_listview(){
70         $this->view = 'edit';
71     }
72     /**
73      * Show the addFont view
74      */
75     function action_addFontView(){
76         $this->view = 'addFontView';
77     }
78     /**
79      * Add a new font and show the addFontResult view
80      */
81     function action_addFont(){
82         global $current_user, $mod_strings;
83         if(!is_admin($current_user)){
84             sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']); 
85         }
86         if(empty($_FILES['pdf_metric_file']['name'])){
87             $this->errors[]=translate("ERR_MISSING_REQUIRED_FIELDS")." ".translate("LBL_PDF_METRIC_FILE", "Configurator");
88             $this->view = 'addFontView';
89             return;
90         }
91         if(empty($_FILES['pdf_font_file']['name'])){
92             $this->errors[]=translate("ERR_MISSING_REQUIRED_FIELDS")." ".translate("LBL_PDF_FONT_FILE", "Configurator");
93             $this->view = 'addFontView';
94             return;
95         }
96         $path_info = pathinfo($_FILES['pdf_font_file']['name']);
97         $path_info_metric = pathinfo($_FILES['pdf_metric_file']['name']);
98         if(($path_info_metric['extension']!="afm" && $path_info_metric['extension']!="ufm") || 
99         ($path_info['extension']!="ttf" && $path_info['extension']!="otf" && $path_info['extension']!="pfb")){
100             $this->errors[]=translate("JS_ALERT_PDF_WRONG_EXTENSION", "Configurator");
101             $this->view = 'addFontView';
102             return;
103         }
104         
105         if($_REQUEST['pdf_embedded'] == "false"){
106             if(empty($_REQUEST['pdf_cidinfo'])){
107                 $this->errors[]=translate("ERR_MISSING_CIDINFO", "Configurator");
108                 $this->view = 'addFontView';
109                 return;
110             }
111             $_REQUEST['pdf_embedded']=false;
112         }else{
113             $_REQUEST['pdf_embedded']=true;
114             $_REQUEST['pdf_cidinfo']="";
115         }
116         if(empty($_REQUEST['pdf_patch'])){
117             $_REQUEST['pdf_patch']="return array();";
118         }else{
119             $_REQUEST['pdf_patch']="return {$_REQUEST['pdf_patch']};";
120         }
121         $this->view = 'addFontResult';
122     }
123     function action_saveadminwizard()
124     {
125         $focus = new Administration();
126         $focus->retrieveSettings();
127         $focus->saveConfig();
128         
129         $configurator = new Configurator();
130         $configurator->populateFromPost();
131         $configurator->handleOverride();
132             $configurator->parseLoggerSettings();
133         $configurator->saveConfig();
134         
135         SugarApplication::redirect('index.php?module=Users&action=Wizard&skipwelcome=1');
136     }
137     
138     function action_saveconfig()
139     {
140         $configurator = new Configurator();
141         $configurator->saveConfig();
142         
143         $focus = new Administration();
144         $focus->saveConfig();
145         
146         // Clear the Contacts file b/c portal flag affects rendering
147         if (file_exists($GLOBALS['sugar_config']['cache_dir'].'modules/Contacts/EditView.tpl'))
148            unlink($GLOBALS['sugar_config']['cache_dir'].'modules/Contacts/EditView.tpl');
149         
150         SugarApplication::redirect('index.php?module=Administration&action=index');
151         }
152         
153         function action_detail()
154     {
155         $this->view = 'edit';
156     }
157 }