]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/Connectors/views/view.displayproperties.php
Release 6.2.1
[Github/sugarcrm.git] / modules / Connectors / views / view.displayproperties.php
1 <?php
2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3
4 /*********************************************************************************
5  * SugarCRM Community Edition is a customer relationship management program developed by
6  * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
7  * 
8  * This program is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU Affero General Public License version 3 as published by the
10  * Free Software Foundation with the addition of the following permission added
11  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
12  * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
13  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
14  * 
15  * This program is distributed in the hope that it will be useful, but WITHOUT
16  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17  * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
18  * details.
19  * 
20  * You should have received a copy of the GNU Affero General Public License along with
21  * this program; if not, see http://www.gnu.org/licenses or write to the Free
22  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23  * 02110-1301 USA.
24  * 
25  * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
26  * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
27  * 
28  * The interactive user interfaces in modified source and object code versions
29  * of this program must display Appropriate Legal Notices, as required under
30  * Section 5 of the GNU Affero General Public License version 3.
31  * 
32  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
33  * these Appropriate Legal Notices must retain the display of the "Powered by
34  * SugarCRM" logo. If the display of the logo is not reasonably feasible for
35  * technical reasons, the Appropriate Legal Notices must display the words
36  * "Powered by SugarCRM".
37  ********************************************************************************/
38
39
40 require_once('include/MVC/View/views/view.list.php');
41 require_once('include/connectors/sources/SourceFactory.php');
42
43 class ViewDisplayProperties extends ViewList
44 {
45         /**
46          * @see SugarView::process()
47          */
48         public function process()
49         {
50                 $this->options['show_all'] = false;
51                 $this->options['show_javascript'] = true;
52                 $this->options['show_footer'] = false;
53                 $this->options['show_header'] = false;
54             parent::process();
55         }
56
57     /**
58          * @see SugarView::display()
59          */
60         public function display()
61         {
62         require_once('include/connectors/utils/ConnectorUtils.php');
63         $source = $_REQUEST['source_id'];
64         $sources = ConnectorUtils::getConnectors();
65         $modules_sources = ConnectorUtils::getDisplayConfig();
66         //$json = getJSONobj();
67
68         $enabled_modules = array();
69         $disabled_modules = array();
70
71         //Find all modules this source has been enabled for
72         foreach($modules_sources as $module=>$mapping) {
73                 foreach($modules_sources[$module] as $entry) {
74                         if($entry == $source) {
75                            $enabled_modules[$module] = $module;
76                         }
77                 }
78                 }
79
80
81         global $moduleList, $beanList;
82         //Do filtering here?
83         $count = 0;
84                 global $current_user;
85                 $access = $current_user->getDeveloperModules();
86             $d = dir('modules');
87                 while($e = $d->read()){
88                         if(substr($e, 0, 1) == '.' || !is_dir('modules/' . $e))continue;
89                         if(empty($enabled_modules[$e]) && file_exists('modules/' . $e . '/metadata/studio.php') && file_exists('modules/' . $e . '/metadata/detailviewdefs.php') && isset($GLOBALS [ 'beanList' ][$e]) && (in_array($e, $access) || is_admin($current_user))) // installed modules must also exist in the beanList
90                         {
91                                 $disabled_modules[$e] = $e;
92                         }
93                 }
94
95         $s = SourceFactory::getSource($source);
96         
97         // Not all sources can be connected to all modules
98         $enabled_modules = $s->filterAllowedModules($enabled_modules);
99         $disabled_modules = $s->filterAllowedModules($disabled_modules);
100
101                 asort($enabled_modules);
102         asort($disabled_modules);
103
104         //$enabled = $json->encode($enabled_modules);
105         //$disabled = $json->encode($disabled_modules);
106         //$script = "addTable('{$module}', '{$enabled}', '{$disabled}', '{$source}', '{$GLOBALS['theme']}');\n";
107         //$this->ss->assign('new_modules_sources', $modules_sources);
108         //$this->ss->assign('dynamic_script', $script);
109
110         $this->ss->assign('enabled_modules', $enabled_modules);
111         $this->ss->assign('disabled_modules', $disabled_modules);
112         $this->ss->assign('source_id', $source);
113         $this->ss->assign('mod', $GLOBALS['mod_strings']);
114         $this->ss->assign('APP', $GLOBALS['app_strings']);
115         $this->ss->assign('theme', $GLOBALS['theme']);
116             $this->ss->assign('external', !empty($sources[$source]['eapm']));
117             $this->ss->assign('externalOnly', !empty($sources[$source]['eapm']['only']));
118
119         // We don't want to tell the user to set the properties of the connector if there aren't any
120         $fields = $s->getRequiredConfigFields();
121             $this->ss->assign('externalHasProperties', !empty($fields));
122
123             $this->ss->assign('externalChecked', !empty($sources[$source]['eapm']['enabled'])?" checked":"");
124             echo $this->ss->fetch('modules/Connectors/tpls/display_properties.tpl');
125     }
126 }