2 /*********************************************************************************
3 * SugarCRM Community Edition is a customer relationship management program developed by
4 * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
6 * This program is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU Affero General Public License version 3 as published by the
8 * Free Software Foundation with the addition of the following permission added
9 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
11 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
18 * You should have received a copy of the GNU Affero General Public License along with
19 * this program; if not, see http://www.gnu.org/licenses or write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
24 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
26 * The interactive user interfaces in modified source and object code versions
27 * of this program must display Appropriate Legal Notices, as required under
28 * Section 5 of the GNU Affero General Public License version 3.
30 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31 * these Appropriate Legal Notices must retain the display of the "Powered by
32 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
33 * technical reasons, the Appropriate Legal Notices must display the words
34 * "Powered by SugarCRM".
35 ********************************************************************************/
37 require_once ('modules/ModuleBuilder/MB/ModuleBuilder.php') ;
38 require_once ('modules/ModuleBuilder/parsers/ParserFactory.php') ;
39 require_once 'modules/ModuleBuilder/parsers/constants.php' ;
41 class ModuleBuilderController extends SugarController
43 var $action_remap = array ( ) ;
46 * Used by the _getModuleTitleParams() method calls in ModuleBuilder views to get the correct string
47 * for the section you are in
51 public static function getModuleTitle()
55 if(!empty($_REQUEST['type'])){
56 if ( $_REQUEST['type'] == 'studio' ) {
57 return $mod_strings['LBL_STUDIO'];
59 elseif ( $_REQUEST['type'] == 'sugarportal' ) {
60 return $mod_strings['LBL_SUGARPORTAL'];
62 elseif ( $_REQUEST['type'] == 'mb' ) {
63 return $mod_strings['LBL_MODULEBUILDER'];
65 elseif ( $_REQUEST['type'] == 'dropdowns') {
66 return $mod_strings['LBL_DROPDOWNEDITOR'];
68 elseif ( $_REQUEST['type'] == 'home' ) {
69 return $mod_strings['LBL_HOME'];
72 return $mod_strings['LBL_DEVELOPER_TOOLS'];
75 return $mod_strings['LBL_DEVELOPER_TOOLS'];
79 function fromModuleBuilder ()
81 return (isset ( $_REQUEST [ 'MB' ] ) && ($_REQUEST [ 'MB' ] == '1')) ;
85 $GLOBALS [ 'log' ]->info ( get_class($this).":" ) ;
87 $access = $current_user->getDeveloperModules();
88 if($current_user->isAdmin() || ($current_user->isDeveloperForAnyModule() && !isset($_REQUEST['view_module']) && (isset($_REQUEST['action']) && $_REQUEST['action'] != 'package'))||
89 (isset($_REQUEST['view_module']) && (in_array($_REQUEST['view_module'], $access)|| empty($_REQUEST['view_module']))) ||
90 (isset($_REQUEST['type']) && (($_REQUEST['type']=='dropdowns' && $current_user->isDeveloperForAnyModule())||
91 ($_REQUEST['type']=='studio' && displayStudioForCurrentUser() == true))))
93 $this->hasAccess = true;
97 $this->hasAccess = false;
103 function action_editLayout ()
105 switch ( strtolower ( $_REQUEST [ 'view' ] ))
109 case MB_QUICKCREATE :
110 $this->view = 'layoutView' ;
113 $this->view = 'listView' ;
115 case MB_BASICSEARCH :
116 case MB_ADVANCEDSEARCH :
117 $this->view = 'searchView' ;
120 case MB_DASHLETSEARCH :
121 $this->view = 'dashlet' ;
124 case MB_POPUPSEARCH :
125 $this->view = 'popupview' ;
128 $GLOBALS [ 'log' ]->fatal ( 'Action = editLayout with unknown view=' . $_REQUEST [ 'view' ] ) ;
133 function action_ViewTree ()
135 require_once ('modules/ModuleBuilder/MB/AjaxCompose.php') ;
136 switch ( $_REQUEST [ 'tree' ])
138 case 'ModuleBuilder' :
139 require_once ('modules/ModuleBuilder/MB/MBPackageTree.php') ;
140 $mbt = new MBPackageTree ( ) ;
143 require_once ('modules/ModuleBuilder/Module/StudioTree.php') ;
144 $mbt = new StudioTree ( ) ;
146 $ajax = new AjaxCompose ( ) ;
147 $ajax->addSection ( 'west', $mbt->getName (), $mbt->fetchNodes () ) ;
148 echo $ajax->getJavascript () ;
150 sugar_cleanup ( true ) ;
154 function action_SavePackage ()
156 $mb = new ModuleBuilder ( ) ;
157 $load = (! empty ( $_REQUEST [ 'original_name' ] )) ? $_REQUEST [ 'original_name' ] : $_REQUEST [ 'name' ] ;
158 if (! empty ( $load ))
160 $mb->getPackage ( $load ) ;
162 if (! empty ( $_REQUEST [ 'duplicate' ] ))
164 $result = $mb->packages [ $load ]->copy ( $_REQUEST [ 'name' ] ) ;
165 $load = $mb->packages [ $load ]->name ;
166 $mb->getPackage ( $load ) ;
168 $mb->packages [ $load ]->populateFromPost () ;
169 $mb->packages [ $load ]->loadModules () ;
171 if (! empty ( $_REQUEST [ 'original_name' ] ) && $_REQUEST [ 'original_name' ] != $_REQUEST [ 'name' ])
173 if (! $mb->packages [ $load ]->rename ( $_REQUEST [ 'name' ] ))
175 $mb->packages [ $load ]->name = $_REQUEST [ 'original_name' ] ;
176 $_REQUEST [ 'name' ] = $_REQUEST [ 'original_name' ] ;
179 $_REQUEST [ 'package' ] = $_REQUEST [ 'name' ] ;
180 $this->view = 'package' ;
184 function action_BuildPackage ()
186 $mb = new ModuleBuilder ( ) ;
187 $load = $_REQUEST [ 'name' ] ;
188 if (! empty ( $load ))
190 $mb->getPackage ( $load ) ;
191 $mb->packages [ $load ]->build () ;
195 function action_DeployPackage ()
197 if(defined('TEMPLATE_URL')){
199 SugarTemplateUtilities::disableCache();
202 $mb = new ModuleBuilder ( ) ;
203 $load = $_REQUEST [ 'package' ] ;
204 $message = $GLOBALS [ 'mod_strings' ] [ 'LBL_MODULE_DEPLOYED' ] ;
205 if (! empty ( $load ))
207 $zip = $mb->getPackage ( $load ) ;
208 require_once ('ModuleInstall/PackageManager/PackageManager.php') ;
209 $pm = new PackageManager ( ) ;
210 $info = $mb->packages [ $load ]->build ( false ) ;
211 mkdir_recursive ( $GLOBALS [ 'sugar_config' ] [ 'cache_dir' ] . '/upload/upgrades/module/') ;
212 rename ( $info [ 'zip' ], $GLOBALS [ 'sugar_config' ] [ 'cache_dir' ] . '/' . 'upload/upgrades/module/' . $info [ 'name' ] . '.zip' ) ;
213 copy ( $info [ 'manifest' ], $GLOBALS [ 'sugar_config' ] [ 'cache_dir' ] . '/' . 'upload/upgrades/module/' . $info [ 'name' ] . '-manifest.php' ) ;
214 $_REQUEST [ 'install_file' ] = $GLOBALS [ 'sugar_config' ] [ 'cache_dir' ] . '/' . 'upload/upgrades/module/' . $info [ 'name' ] . '.zip' ;
215 $GLOBALS [ 'mi_remove_tables' ] = false ;
216 $pm->performUninstall ( $load ) ;
217 //#23177 , js cache clear
218 clearAllJsAndJsLangFilesWithoutOutput();
219 //#30747, clear the cache in memory
220 $cache_key = 'app_list_strings.'.$GLOBALS['current_language'];
221 sugar_cache_clear($cache_key );
224 $pm->performInstall ( $_REQUEST [ 'install_file' ] , true);
226 //clear the unified_search_module.php file
227 require_once('modules/Home/UnifiedSearchAdvanced.php');
228 UnifiedSearchAdvanced::unlinkUnifiedSearchModulesFile();
231 global $current_user;
232 //clear workflow admin modules cache
233 if (isset($_SESSION['get_workflow_admin_modules_for_user'])) unset($_SESSION['get_workflow_admin_modules_for_user']);
235 //clear "is_admin_for_module" cache
236 $sessionVar = 'MLA_'.$current_user->user_name;
237 foreach ($mb->packages as $package) {
238 foreach ($package->modules as $module) {
239 $_SESSION[$sessionVar][$package->name . '_' . $module->name] = true;
244 $actions = ACLAction::getUserActions($current_user->id, true);
251 function action_ExportPackage ()
253 $mb = new ModuleBuilder ( ) ;
254 $load = $_REQUEST [ 'name' ] ;
255 $author = $_REQUEST [ 'author' ] ;
256 $description = $_REQUEST [ 'description' ] ;
257 $readme = $_REQUEST [ 'readme' ] ;
258 if (! empty ( $load ))
260 $mb->getPackage ( $load ) ;
261 $mb->packages [ $load ]->author = $author ;
262 $mb->packages [ $load ]->description = $description ;
263 $mb->packages [ $load ]->exportProject () ;
264 $mb->packages [ $load ]->readme = $readme ;
268 function action_DeletePackage ()
270 $mb = new ModuleBuilder ( ) ;
271 $mb->getPackage ( $_REQUEST [ 'package' ] ) ;
272 $mb->packages [ $_REQUEST [ 'package' ] ]->delete () ;
273 $this->view = 'deletepackage' ;
276 function action_SaveModule ()
278 $mb = new ModuleBuilder ( ) ;
279 $load = (! empty ( $_REQUEST [ 'original_name' ] )) ? $_REQUEST [ 'original_name' ] : $_REQUEST [ 'name' ] ;
280 if (! empty ( $load ))
282 $mb->getPackage ( $_REQUEST [ 'package' ] ) ;
283 $mb->packages [ $_REQUEST [ 'package' ] ]->getModule ( $load ) ;
284 $module = & $mb->packages [ $_REQUEST [ 'package' ] ]->modules [ $load ] ;
285 $module->populateFromPost () ;
287 if (! empty ( $_REQUEST [ 'duplicate' ] ))
289 $module->copy ( $_REQUEST [ 'name' ] ) ;
290 } else if (! empty ( $_REQUEST [ 'original_name' ] ) && $_REQUEST [ 'original_name' ] != $_REQUEST [ 'name' ])
292 if (! $module->rename ( $_REQUEST [ 'name' ] ))
294 $module->name = $_REQUEST [ 'original_name' ] ;
295 $_REQUEST [ 'name' ] = $_REQUEST [ 'original_name' ] ;
299 $_REQUEST [ 'view_package' ] = $_REQUEST [ 'package' ] ;
300 $_REQUEST [ 'view_module' ] = $module->name ;
301 $this->view = 'module' ;
305 function action_DeleteModule ()
307 $mb = new ModuleBuilder ( ) ;
308 $module = & $mb->getPackageModule ( $_REQUEST [ 'package' ], $_REQUEST [ 'view_module' ] ) ;
310 $this->view = 'package' ;
313 function action_saveLabels ()
315 require_once 'modules/ModuleBuilder/parsers/parser.label.php' ;
316 $parser = new ParserLabel ( $_REQUEST['view_module'] , isset ( $_REQUEST [ 'view_package' ] ) ? $_REQUEST [ 'view_package' ] : null ) ;
317 $parser->handleSave ( $_REQUEST, $_REQUEST [ 'selected_lang' ] ) ;
318 if (isset ( $_REQUEST [ 'view_package' ] )) //MODULE BUILDER
320 $this->view = 'modulelabels' ;
323 $this->view = isset ( $_REQUEST [ 'view' ] ) ? 'edit' : 'labels' ; // detect if we are being called by the LayoutEditor rather than the LabelEditor (set in view.layoutlabel.php)
327 function action_SaveLabel ()
329 if (! empty ( $_REQUEST [ 'view_module' ] ) && !empty($_REQUEST [ 'labelValue' ]))
331 $_REQUEST [ "label_" . $_REQUEST [ 'label' ] ] = $_REQUEST [ 'labelValue' ] ;
332 require_once 'modules/ModuleBuilder/parsers/parser.label.php' ;
333 $parser = new ParserLabel ( $_REQUEST['view_module'] , isset ( $_REQUEST [ 'view_package' ] ) ? $_REQUEST [ 'view_package' ] : null ) ;
334 $parser->handleSave ( $_REQUEST, $GLOBALS [ 'current_language' ] ) ;
337 $this->view = 'modulefields' ;
340 function action_ExportCustom ()
342 $modules = $_REQUEST [ 'modules' ] ;
343 $name = $_REQUEST [ 'name' ] ;
344 $author = $_REQUEST [ 'author' ] ;
345 $description = $_REQUEST [ 'description' ] ;
347 if (! empty ( $modules ) && ! empty ( $name ))
349 require_once ('modules/ModuleBuilder/MB/ModuleBuilder.php') ;
350 $mb = new MBPackage ( $name ) ;
351 $mb->author = $author ;
352 $mb->description = $description ;
353 $mb->exportCustom ( $modules, true, true ) ;
357 function action_SaveField ()
359 require_once ('modules/DynamicFields/FieldCases.php') ;
360 $field = get_widget ( $_REQUEST [ 'type' ] ) ;
361 $_REQUEST [ 'name' ] = trim ( $_REQUEST [ 'name' ] ) ;
363 $field->populateFromPost () ;
365 if (!isset ( $_REQUEST [ 'view_package' ] ))
367 require_once ('modules/DynamicFields/DynamicField.php') ;
368 if (! empty ( $_REQUEST [ 'view_module' ] ))
370 $module = $_REQUEST [ 'view_module' ] ;
372 $bean = loadBean($module);
375 $field_defs = $bean->field_defs;
376 if(isset($field_defs[$field->name. '_c']))
378 $GLOBALS['log']->error($GLOBALS['mod_strings']['ERROR_ALREADY_EXISTS'] . '[' . $field->name . ']');
379 sugar_die($GLOBALS['mod_strings']['ERROR_ALREADY_EXISTS']);
383 $df = new DynamicField ( $module ) ;
384 $class_name = $GLOBALS [ 'beanList' ] [ $module ] ;
385 require_once ($GLOBALS [ 'beanFiles' ] [ $class_name ]) ;
386 $mod = new $class_name ( ) ;
387 $df->setup ( $mod ) ;
389 $field->save ( $df ) ;
390 $this->action_SaveLabel () ;
391 include_once ('modules/Administration/QuickRepairAndRebuild.php') ;
393 $mod_strings['LBL_ALL_MODULES'] = 'all_modules';
394 $repair = new RepairAndClear();
395 $repair->repairAndClearAll(array('rebuildExtensions', 'clearVardefs', 'clearTpls'), array($class_name), true, false);
396 //#28707 ,clear all the js files in cache
397 $repair->module_list = array();
398 $repair->clearJsFiles();
402 $mb = new ModuleBuilder ( ) ;
403 $module = & $mb->getPackageModule ( $_REQUEST [ 'view_package' ], $_REQUEST [ 'view_module' ] ) ;
404 $field->save ( $module ) ;
405 $module->mbvardefs->save () ;
406 // get the module again to refresh the labels we might have saved with the $field->save (e.g., for address fields)
407 $module = & $mb->getPackageModule ( $_REQUEST [ 'view_package' ], $_REQUEST [ 'view_module' ] ) ;
408 if (isset ( $_REQUEST [ 'label' ] ) && isset ( $_REQUEST [ 'labelValue' ] ))
409 $module->setLabel ( $GLOBALS [ 'current_language' ], $_REQUEST [ 'label' ], $_REQUEST [ 'labelValue' ] ) ;
412 $this->view = 'modulefields' ;
415 function action_saveSugarField ()
418 require_once ('modules/DynamicFields/FieldCases.php') ;
419 $field = get_widget ( $_REQUEST [ 'type' ] ) ;
420 $_REQUEST [ 'name' ] = trim ( $_POST [ 'name' ] ) ;
422 $field->populateFromPost () ;
423 require_once ('modules/ModuleBuilder/parsers/StandardField.php') ;
424 $module = $_REQUEST [ 'view_module' ] ;
425 $df = new StandardField ( $module ) ;
426 $class_name = $GLOBALS [ 'beanList' ] [ $module ] ;
427 require_once ($GLOBALS [ 'beanFiles' ] [ $class_name ]) ;
428 $mod = new $class_name ( ) ;
429 $df->setup ( $mod ) ;
431 $field->module = $mod;
432 $field->save ( $df ) ;
433 $this->action_SaveLabel () ;
435 $MBmodStrings = $mod_strings;
436 $GLOBALS [ 'mod_strings' ] = return_module_language ( '', 'Administration' ) ;
438 include_once ('modules/Administration/QuickRepairAndRebuild.php') ;
439 $GLOBALS [ 'mod_strings' ]['LBL_ALL_MODULES'] = 'all_modules';
440 $_REQUEST['execute_sql'] = true;
442 $repair = new RepairAndClear();
443 $repair->repairAndClearAll(array('rebuildExtensions', 'clearVardefs', 'clearTpls'), array($class_name), true, false);
444 //#28707 ,clear all the js files in cache
445 $repair->module_list = array();
446 $repair->clearJsFiles();
449 // now clear the cache so that the results are immediately visible
450 include_once ('include/TemplateHandler/TemplateHandler.php') ;
451 TemplateHandler::clearCache ( $module ) ;
453 $GLOBALS [ 'mod_strings' ] = $MBmodStrings;
456 function action_RefreshField ()
458 require_once ('modules/DynamicFields/FieldCases.php') ;
459 $field = get_widget ( $_POST [ 'type' ] ) ;
460 $field->populateFromPost () ;
461 $this->view = 'modulefield' ;
464 function action_saveVisibility ()
466 $packageName = (isset ( $_REQUEST [ 'view_package' ] ) && (strtolower($_REQUEST['view_package']) != 'studio')) ? $_REQUEST [ 'view_package' ] : null ;
467 require_once 'modules/ModuleBuilder/parsers/ParserFactory.php' ;
468 $parser = ParserFactory::getParser ( MB_VISIBILITY, $_REQUEST [ 'view_module' ], $packageName ) ;
470 $json = getJSONobj();
471 $visibility_grid = $json->decode(html_entity_decode(rawurldecode($_REQUEST [ 'visibility_grid' ]), ENT_QUOTES) );
472 $parser->saveVisibility ( $_REQUEST [ 'fieldname' ] , $_REQUEST [ 'trigger' ] , $visibility_grid ) ;
474 echo $json->encode(array( "visibility_editor_{$_REQUEST['fieldname']}" => array("action" => "deactivate")));
477 function action_SaveRelationshipLabel (){
478 $selected_lang = (!empty($_REQUEST['relationship_lang'])?$_REQUEST['relationship_lang']:$_SESSION['authenticated_user_language']);
479 if (empty($_REQUEST [ 'view_package' ])){
480 require_once 'modules/ModuleBuilder/parsers/relationships/DeployedRelationships.php' ;
481 $relationships = new DeployedRelationships ( $_REQUEST [ 'view_module' ] ) ;
482 if (! empty ( $_REQUEST [ 'relationship_name' ] ))
484 if ($relationship = $relationships->get ( $_REQUEST [ 'relationship_name' ] )){
485 $metadata = $relationship->buildLabels(true);
486 require_once 'modules/ModuleBuilder/parsers/parser.label.php' ;
487 $parser = new ParserLabel ( $_REQUEST['view_module'] ) ;
488 $parser->handleSaveRelationshipLabels ( $metadata, $selected_lang ) ;
495 $this->view = 'relationships' ;
498 function action_SaveRelationship ()
500 if(!empty($GLOBALS['current_user']) && empty($GLOBALS['modListHeader']))
502 $GLOBALS['modListHeader'] = query_module_access_list($GLOBALS['current_user']);
505 if (empty($_REQUEST [ 'view_package' ]))
507 require_once 'modules/ModuleBuilder/parsers/relationships/DeployedRelationships.php' ;
508 $relationships = new DeployedRelationships ( $_REQUEST [ 'view_module' ] ) ;
511 $mb = new ModuleBuilder ( ) ;
512 $module = & $mb->getPackageModule ( $_REQUEST [ 'view_package' ], $_REQUEST [ 'view_module' ] ) ;
513 require_once 'modules/ModuleBuilder/parsers/relationships/UndeployedRelationships.php' ;
514 $relationships = new UndeployedRelationships ( $module->getModuleDir () ) ;
517 $relationships->addFromPost () ;
518 $relationships->save () ;
519 $GLOBALS['log']->debug("\n\nSTART BUILD");
520 if (empty($_REQUEST [ 'view_package' ])) {
521 $relationships->build () ;
523 LanguageManager::clearLanguageCache($_REQUEST [ 'view_module' ]);
525 $GLOBALS['log']->debug("\n\nEND BUILD");
527 $this->view = 'relationships' ;
530 function action_DeleteRelationship ()
532 if (isset ( $_REQUEST [ 'relationship_name' ] ))
534 if (empty($_REQUEST [ 'view_package' ] ))
536 require_once 'modules/ModuleBuilder/parsers/relationships/DeployedRelationships.php' ;
537 if (!empty($_REQUEST['remove_tables']))
538 $GLOBALS['mi_remove_tables'] = $_REQUEST['remove_tables'];
539 $relationships = new DeployedRelationships ( $_REQUEST [ 'view_module' ] ) ;
542 $mb = new ModuleBuilder ( ) ;
543 $module = & $mb->getPackageModule ( $_REQUEST [ 'view_package' ], $_REQUEST [ 'view_module' ] ) ;
544 require_once 'modules/ModuleBuilder/parsers/relationships/UndeployedRelationships.php' ;
545 $relationships = new UndeployedRelationships ( $module->getModuleDir () ) ;
547 $relationships->delete ( $_REQUEST [ 'relationship_name' ] ) ;
548 $relationships->save () ;
550 $this->view = 'relationships' ;
553 function action_SaveDropDown ()
555 require_once 'modules/ModuleBuilder/parsers/parser.dropdown.php' ;
556 $parser = new ParserDropDown ( ) ;
557 $parser->saveDropDown ( $_REQUEST ) ;
558 $this->view = 'dropdowns' ;
561 function action_DeleteField ()
563 require_once ('modules/DynamicFields/FieldCases.php') ;
564 $field = get_widget ( $_REQUEST [ 'type' ] ) ;
565 $field->name = $_REQUEST [ 'name' ] ;
566 if (!isset ( $_REQUEST [ 'view_package' ] ))
568 if (! empty ( $_REQUEST [ 'name' ] ) && ! empty ( $_REQUEST [ 'view_module' ] ))
570 require_once ('modules/DynamicFields/DynamicField.php') ;
571 $moduleName = $_REQUEST [ 'view_module' ] ;
572 $class_name = $GLOBALS [ 'beanList' ] [ $moduleName ] ;
573 require_once ($GLOBALS [ 'beanFiles' ] [ $class_name ]) ;
574 $seed = new $class_name ( ) ;
575 $df = new DynamicField ( $moduleName ) ;
576 $df->setup ( $seed ) ;
577 //Need to load the entire field_meta_data for some field types
578 $field = $df->getFieldWidget($moduleName, $field->name);
579 $field->delete ( $df ) ;
581 $GLOBALS [ 'mod_strings' ]['LBL_ALL_MODULES'] = 'all_modules';
582 $_REQUEST['execute_sql'] = true;
583 include_once ('modules/Administration/QuickRepairAndRebuild.php') ;
584 $repair = new RepairAndClear();
585 $repair->repairAndClearAll(array('rebuildExtensions', 'clearVardefs', 'clearTpls'), array($class_name), true, false);
586 require_once 'modules/ModuleBuilder/Module/StudioModuleFactory.php' ;
587 $module = StudioModuleFactory::getStudioModule( $moduleName ) ;
592 $mb = new ModuleBuilder ( ) ;
593 $module = & $mb->getPackageModule ( $_REQUEST [ 'view_package' ], $_REQUEST [ 'view_module' ] ) ;
594 $field->delete ( $module ) ;
597 $module->removeFieldFromLayouts( $field->name );
598 $this->view = 'modulefields' ;
601 function action_CloneField ()
603 $this->view_object_map [ 'field_name' ] = $_REQUEST [ 'name' ] ;
604 $this->view_object_map [ 'is_clone' ] = true ;
605 $this->view = 'modulefield' ;
608 function action_SaveAssistantPref ()
610 global $current_user ;
611 if (isset ( $_REQUEST [ 'pref_value' ] ))
613 if ($_REQUEST [ 'pref_value' ] == 'ignore')
615 $current_user->setPreference ( 'mb_assist', 'DISABLED', 0, 'Assistant' ) ;
618 $current_user->setPreference ( 'mb_assist', 'ENABLED', 0, 'Assistant' ) ;
620 $current_pref = $current_user->getPreference ( 'mb_assist', 'Assistant' ) ;
621 echo "Assistant.processUserPref('$current_pref')" ;
622 sugar_cleanup ( true ) ; //push preferences to DB.
629 function action_EditProperty ()
631 $this->view = 'property' ;
634 function action_saveProperty ()
636 require_once 'modules/ModuleBuilder/parsers/parser.label.php' ;
637 $modules = $_REQUEST['view_module'];
638 if(!empty($_REQUEST['subpanel'])){
639 $modules = $_REQUEST['subpanel'];
641 $parser = new ParserLabel ( $modules , isset ( $_REQUEST [ 'view_package' ] ) ? $_REQUEST [ 'view_package' ] : null ) ;
642 // if no language provided, then use the user's current language which is most likely what they intended
643 $language = (isset($_REQUEST [ 'selected_lang' ])) ? $_REQUEST [ 'selected_lang' ] : $GLOBALS['current_language'] ;
644 $parser->handleSave ( $_REQUEST, $language ) ;
645 $json = getJSONobj();
646 echo $json->encode(array("east" => array("action" => "deactivate")));
649 function action_editModule ()
651 $this->view = 'module' ;
654 function action_wizard ()
656 $this->view = 'wizard' ;
660 * Receive a layout through $_REQUEST and save it out to the working files directory
661 * Expects a series of $_REQUEST parameters all in the format $_REQUEST['slot-panel#-slot#-property']=value
664 function action_saveLayout ()
666 $parser = ParserFactory::getParser ( $_REQUEST [ 'view' ], $_REQUEST [ 'view_module' ], isset ( $_REQUEST [ 'view_package' ] ) ? $_REQUEST [ 'view_package' ] : null ) ;
667 $this->view = 'layoutview' ;
668 $parser->writeWorkingFile () ;
670 if(!empty($_REQUEST [ 'sync_detail_and_edit' ]) && $_REQUEST['sync_detail_and_edit'] != false && $_REQUEST['sync_detail_and_edit'] != "false"){
671 if(strtolower ($parser->_view) == MB_EDITVIEW){
672 $parser2 = ParserFactory::getParser ( MB_DETAILVIEW, $_REQUEST [ 'view_module' ], isset ( $_REQUEST [ 'view_package' ] ) ? $_REQUEST [ 'view_package' ] : null ) ;
673 $parser2->setUseTabs($parser->getUseTabs());
674 $parser2->writeWorkingFile () ;
679 function action_saveAndPublishLayout ()
681 $parser = ParserFactory::getParser ( $_REQUEST [ 'view' ], $_REQUEST [ 'view_module' ], isset ( $_REQUEST [ 'view_package' ] ) ? $_REQUEST [ 'view_package' ] : null ) ;
682 $this->view = 'layoutview' ;
683 $parser->handleSave () ;
685 if(!empty($_REQUEST [ 'sync_detail_and_edit' ]) && $_REQUEST['sync_detail_and_edit'] != false && $_REQUEST['sync_detail_and_edit'] != "false"){
686 if(strtolower ($parser->_view) == MB_EDITVIEW){
687 $parser2 = ParserFactory::getParser ( MB_DETAILVIEW, $_REQUEST [ 'view_module' ], isset ( $_REQUEST [ 'view_package' ] ) ? $_REQUEST [ 'view_package' ] : null ) ;
688 $parser2->setUseTabs($parser->getUseTabs());
689 $parser2->handleSave () ;
694 function action_manageBackups ()
699 function action_listViewSave ()
701 $GLOBALS [ 'log' ]->info ( "action_listViewSave" ) ;
703 $packageName = (isset ( $_REQUEST [ 'view_package' ] ) && (strtolower($_REQUEST['view_package']) != 'studio')) ? $_REQUEST [ 'view_package' ] : null ;
704 $subpanelName = (! empty ( $_REQUEST [ 'subpanel' ] )) ? $_REQUEST [ 'subpanel' ] : null ;
705 require_once 'modules/ModuleBuilder/parsers/ParserFactory.php' ;
706 $parser = ParserFactory::getParser ( $_REQUEST [ 'view' ], $_REQUEST [ 'view_module' ], $packageName, $subpanelName ) ;
707 $this->view = 'listView' ;
708 $parser->handleSave () ;
712 function action_dashletSave () {
713 $this->view = 'dashlet' ;
714 $packageName = (isset ( $_REQUEST [ 'view_package' ] ) && (strtolower($_REQUEST['view_package']) != 'studio')) ? $_REQUEST [ 'view_package' ] : null ;
715 require_once 'modules/ModuleBuilder/parsers/ParserFactory.php' ;
716 $parser = ParserFactory::getParser ( $_REQUEST [ 'view' ], $_REQUEST [ 'view_module' ], $packageName ) ;
717 $parser->handleSave () ;
720 function action_popupSave(){
721 $this->view = 'popupview' ;
722 $packageName = (isset ( $_REQUEST [ 'view_package' ] ) && (strtolower($_REQUEST['view_package']) != 'studio')) ? $_REQUEST [ 'view_package' ] : null ;
723 require_once 'modules/ModuleBuilder/parsers/ParserFactory.php' ;
724 $parser = ParserFactory::getParser ( $_REQUEST [ 'view' ], $_REQUEST [ 'view_module' ], $packageName ) ;
725 $parser->handleSave () ;
726 if(empty($packageName)){
727 include_once ('modules/Administration/QuickRepairAndRebuild.php') ;
729 $mod_strings['LBL_ALL_MODULES'] = 'all_modules';
730 $repair = new RepairAndClear();
731 $repair->show_output = false;
732 $class_name = $GLOBALS [ 'beanList' ] [ $_REQUEST [ 'view_module' ] ] ;
733 $repair->module_list = array($class_name);
734 $repair->clearTpls();
739 function action_searchViewSave ()
741 $packageName = (isset ( $_REQUEST [ 'view_package' ] )) ? $_REQUEST [ 'view_package' ] : null ;
742 require_once 'modules/ModuleBuilder/parsers/views/SearchViewMetaDataParser.php' ;
743 $parser = new SearchViewMetaDataParser ( $_REQUEST [ 'view' ], $_REQUEST [ 'view_module' ], $packageName ) ;
744 $parser->handleSave () ;
747 //Repair or create a custom SearchFields.php file as needed
748 $module_name = $_REQUEST [ 'view_module' ] ;
750 if (isset($beanList[$module_name]) && $beanList[$module_name]!="") {
751 $objectName = $beanList[$module_name];
752 if($objectName == 'aCase') // Bug 17614 - renamed aCase as Case in vardefs for backwards compatibililty with 451 modules
754 $objectName = 'Case';
757 //Load the vardefs for the module to pass to TemplateRange
758 VardefManager::loadVardef($module_name, $objectName, true);
760 $vardefs = $dictionary[$objectName]['fields'];
761 require_once('modules/DynamicFields/templates/Fields/TemplateRange.php');
762 TemplateRange::repairCustomSearchFields($vardefs, $module_name, $packageName);
764 $this->view = 'searchView' ;
767 function action_editLabels ()
769 if (isset ( $_REQUEST [ 'view_package' ] )) //MODULE BUILDER
771 $this->view = 'modulelabels';
773 $this->view = 'labels';
777 function action_get_app_list_string ()
779 require_once ('include/JSON.php') ;
780 $json = new JSON ( ) ;
781 if (isset ( $_REQUEST [ 'key' ] ) && ! empty ( $_REQUEST [ 'key' ] ))
783 $key = $_REQUEST [ 'key' ] ;
785 if (! empty ( $GLOBALS [ 'app_list_strings' ] [ $key ] ))
787 $value = $GLOBALS [ 'app_list_strings' ] [ $key ] ;
790 $package_strings = array ( ) ;
791 if (! empty ( $_REQUEST [ 'view_package' ] ) && $_REQUEST [ 'view_package' ] != 'studio' && ! empty ( $_REQUEST [ 'view_module' ] ))
793 require_once ('modules/ModuleBuilder/MB/ModuleBuilder.php') ;
794 $mb = new ModuleBuilder ( ) ;
795 $module = & $mb->getPackageModule ( $_REQUEST [ 'view_package' ], $_REQUEST [ 'view_module' ] ) ;
796 $lang = $GLOBALS [ 'current_language' ] ;
797 $module->mblanguage->generateAppStrings ( false ) ;
798 $package_strings = $module->mblanguage->appListStrings [ $lang . '.lang.php' ] ;
799 if (isset ( $package_strings [ $key ] ) && is_array ( $package_strings [ $key ] ))
801 $value = $package_strings [ $key ] ;
805 echo $json->encode ( $value ) ;
809 function action_history ()
811 $this->view = 'history' ;
814 function resetmodule()
816 $this->view = 'resetmodule';