|
iTx Technologies offre gratuitement
|
||
[Vue sommaire] [Imprimer] [Vue textuelle]
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 - 2009 SugarCRM Inc. 6 * 7 * This program is free software; you can redistribute it and/or modify it under 8 * the terms of the GNU 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 General Public License for more 17 * details. 18 * 19 * You should have received a copy of the GNU 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 General Public License version 3. 30 * 31 * In accordance with Section 7(b) of the GNU 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 // this is a list of what values are expected for a given custom field type 39 // will eventually be moved to the SugarFields classes 40 $custom_field_meta = array( 41 'address' => array( 42 'default', 43 'duplicate_merge', 44 'help', 45 'label', 46 'label_value', 47 'len', 48 'name', 49 'reportable' 50 ), 51 'bool' => array( 52 'duplicate_merge', 53 'help', 54 'label', 55 'label_value', 56 'name', 57 'reportable' 58 ), 59 'currency' => array( 60 'duplicate_merge', 61 'help', 62 'label', 63 'label_value', 64 'name', 65 'reportable' 66 ), 67 'date' => array( 68 'audited', 69 'default_value', 70 'duplicate_merge', 71 'help', 72 'label', 73 'label_value', 74 'massupdate', 75 'name', 76 'reportable', 77 'required' 78 ), 79 'enum' => array( 80 'audited', 81 'default', 82 'duplicate_merge', 83 'help', 84 'label', 85 'label_value', 86 'massupdate', 87 'name', 88 'options', 89 'reportable', 90 'required' 91 ), 92 'float' => array( 93 'audited', 94 'default', 95 'duplicate_merge', 96 'help', 97 'label', 98 'label_value', 99 'len', 100 'name', 101 'precision', 102 'reportable', 103 'required' 104 ), 105 'html' => array( 106 'audited', 107 'duplicate_merge', 108 'ext4', 109 'help', 110 'label', 111 'label_value', 112 'name', 113 'reportable', 114 'required' 115 ), 116 'int' => array( 117 'audited', 118 'default', 119 'duplicate_merge', 120 'help', 121 'label', 122 'label_value', 123 'len', 124 'max', 125 'min', 126 'name', 127 'reportable', 128 'required' 129 ), 130 'multienum' => array( 131 'audited', 132 'default', 133 'duplicate_merge', 134 'help', 135 'label', 136 'label_value', 137 'massupdate', 138 'name', 139 'options', 140 'reportable', 141 'required' 142 ), 143 'phone' => array( 144 'audited', 145 'default', 146 'duplicate_merge', 147 'help', 148 'label', 149 'label_value', 150 'len', 151 'name', 152 'reportable', 153 'required' 154 ), 155 'radioenum' => array( 156 'audited', 157 'default', 158 'duplicate_merge', 159 'help', 160 'label', 161 'label_value', 162 'massupdate', 163 'name', 164 'options', 165 'reportable', 166 'required' 167 ), 168 'relate' => array( 169 'audited', 170 'duplicate_merge', 171 'ext2', 172 'help', 173 'label', 174 'label_value', 175 'name', 176 'reportable', 177 'required' 178 ), 179 'text' => array( 180 'audited', 181 'default', 182 'duplicate_merge', 183 'help', 184 'label', 185 'label_value', 186 'name', 187 'reportable', 188 'required' 189 ), 190 'varchar' => array( 191 'audited', 192 'default', 193 'duplicate_merge', 194 'help', 195 'label', 196 'label_value', 197 'len', 198 'name', 199 'reportable', 200 'required' 201 ) 202 ); 203 204 // create or update an existing custom field 205 $server->register( 206 'set_custom_field', 207 array( 208 'session' => 'xsd:string', 209 'module_name' => 'xsd:string', 210 'type' => 'xsd:string', 211 'properties' => 'tns:name_value_list', 212 'add_to_layout' => 'xsd:int', 213 ), 214 array( 215 'return' => 'tns:error_value' 216 ), 217 $NAMESPACE 218 ); 219 220 function set_custom_field($session, $module_name, $type, $properties, $add_to_layout) { 221 global $current_user; 222 global $beanList, $beanFiles; 223 global $custom_field_meta; 224 225 $error = new SoapError(); 226 227 $request_arr = array( 228 'action' => 'SaveField', 229 'is_update' => 'true', 230 'module' => 'ModuleBuilder', 231 'view_module' => $module_name, 232 'view_package' => 'studio' 233 ); 234 235 // ERROR CHECKING 236 if(!validate_authenticated($session)) { 237 $error->set_error('invalid_login'); 238 return $error->get_soap_array(); 239 } 240 241 if (!is_admin($current_user)) { 242 $error->set_error('no_admin'); 243 return $error->get_soap_array(); 244 } 245 246 if(empty($beanList[$module_name])){ 247 $error->set_error('no_module'); 248 return $error->get_soap_array(); 249 } 250 251 if (empty($custom_field_meta[$type])) { 252 $error->set_error('custom_field_type_not_supported'); 253 return $error->get_soap_array(); 254 } 255 256 $new_properties = array(); 257 foreach($properties as $value) { 258 $new_properties[$value['name']] = $value['value']; 259 } 260 261 foreach ($custom_field_meta[$type] as $property) { 262 if (!isset($new_properties[$property])) { 263 $error->set_error('custom_field_property_not_supplied'); 264 return $error->get_soap_array(); 265 } 266 267 $request_arr[$property] = $new_properties[$property]; 268 } 269 270 // $request_arr should now contain all the necessary information to create a custom field 271 // merge $request_arr with $_POST/$_REQUEST, where the action_saveField() method expects them 272 $_REQUEST = array_merge($_REQUEST, $request_arr); 273 $_POST = array_merge($_POST, $request_arr); 274 275 require_once ('include/MVC/Controller/SugarController.php'); 276 require_once ('modules/ModuleBuilder/controller.php'); 277 require_once ('modules/ModuleBuilder/parsers/ParserFactory.php'); 278 279 $mbc = new ModuleBuilderController(); 280 $mbc->setup(); 281 $mbc->action_SaveField(); 282 283 // add the field to the given module's EditView and DetailView layouts 284 if ($add_to_layout == 1) { 285 $layout_properties = array( 286 'name' => $new_properties['name'], 287 'label' => $new_properties['label'] 288 ); 289 290 if (isset($new_properties['customCode'])) { 291 $layout_properties['customCode'] = $new_properties['customCode']; 292 } 293 if (isset($new_properties['customLabel'])) { 294 $layout_properties['customLabel'] = $new_properties['customLabel']; 295 } 296 297 // add the field to the DetailView 298 $parser = ParserFactory::getParser('layoutview', FALSE); 299 $parser->init($module_name, 'DetailView', FALSE); 300 301 $parser->_addField($layout_properties); 302 $parser->writeWorkingFile(); 303 $parser->handleSave(); 304 305 unset($parser); 306 307 // add the field to the EditView 308 $parser = ParserFactory::getParser('layoutview', FALSE); 309 $parser->init($module_name, 'EditView', FALSE); 310 311 $parser->_addField($layout_properties); 312 $parser->writeWorkingFile(); 313 $parser->handleSave(); 314 } 315 316 return $error->get_soap_array(); 317 } 318 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
|
|
|
|