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 = get_admin_modules_for_user($current_user);
88 if(is_admin($current_user) || (is_admin_for_any_module($current_user) && !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' && is_admin_for_any_module($current_user))||
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();
234 function action_ExportPackage ()
236 $mb = new ModuleBuilder ( ) ;
237 $load = $_REQUEST [ 'name' ] ;
238 $author = $_REQUEST [ 'author' ] ;
239 $description = $_REQUEST [ 'description' ] ;
240 $readme = $_REQUEST [ 'readme' ] ;
241 if (! empty ( $load ))
243 $mb->getPackage ( $load ) ;
244 $mb->packages [ $load ]->author = $author ;
245 $mb->packages [ $load ]->description = $description ;
246 $mb->packages [ $load ]->exportProject () ;
247 $mb->packages [ $load ]->readme = $readme ;
251 function action_DeletePackage ()
253 $mb = new ModuleBuilder ( ) ;
254 $mb->getPackage ( $_REQUEST [ 'package' ] ) ;
255 $mb->packages [ $_REQUEST [ 'package' ] ]->delete () ;
256 $this->view = 'deletepackage' ;
259 function action_SaveModule ()
261 $mb = new ModuleBuilder ( ) ;
262 $load = (! empty ( $_REQUEST [ 'original_name' ] )) ? $_REQUEST [ 'original_name' ] : $_REQUEST [ 'name' ] ;
263 if (! empty ( $load ))
265 $mb->getPackage ( $_REQUEST [ 'package' ] ) ;
266 $mb->packages [ $_REQUEST [ 'package' ] ]->getModule ( $load ) ;
267 $module = & $mb->packages [ $_REQUEST [ 'package' ] ]->modules [ $load ] ;
268 $module->populateFromPost () ;
270 if (! empty ( $_REQUEST [ 'duplicate' ] ))
272 $module->copy ( $_REQUEST [ 'name' ] ) ;
273 } else if (! empty ( $_REQUEST [ 'original_name' ] ) && $_REQUEST [ 'original_name' ] != $_REQUEST [ 'name' ])
275 if (! $module->rename ( $_REQUEST [ 'name' ] ))
277 $module->name = $_REQUEST [ 'original_name' ] ;
278 $_REQUEST [ 'name' ] = $_REQUEST [ 'original_name' ] ;
282 $_REQUEST [ 'view_package' ] = $_REQUEST [ 'package' ] ;
283 $_REQUEST [ 'view_module' ] = $module->name ;
284 $this->view = 'module' ;
288 function action_DeleteModule ()
290 $mb = new ModuleBuilder ( ) ;
291 $module = & $mb->getPackageModule ( $_REQUEST [ 'package' ], $_REQUEST [ 'view_module' ] ) ;
293 $this->view = 'package' ;
296 function action_saveLabels ()
298 require_once 'modules/ModuleBuilder/parsers/parser.label.php' ;
299 $parser = new ParserLabel ( $_REQUEST['view_module'] , isset ( $_REQUEST [ 'view_package' ] ) ? $_REQUEST [ 'view_package' ] : null ) ;
300 $parser->handleSave ( $_REQUEST, $_REQUEST [ 'selected_lang' ] ) ;
301 if (isset ( $_REQUEST [ 'view_package' ] )) //MODULE BUILDER
303 $this->view = 'modulelabels' ;
306 $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)
310 function action_SaveLabel ()
312 if (! empty ( $_REQUEST [ 'view_module' ] ) && !empty($_REQUEST [ 'labelValue' ]))
314 $_REQUEST [ "label_" . $_REQUEST [ 'label' ] ] = $_REQUEST [ 'labelValue' ] ;
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, $GLOBALS [ 'current_language' ] ) ;
320 $this->view = 'modulefields' ;
323 function action_ExportCustom ()
325 $modules = $_REQUEST [ 'modules' ] ;
326 $name = $_REQUEST [ 'name' ] ;
327 $author = $_REQUEST [ 'author' ] ;
328 $description = $_REQUEST [ 'description' ] ;
330 if (! empty ( $modules ) && ! empty ( $name ))
332 require_once ('modules/ModuleBuilder/MB/ModuleBuilder.php') ;
333 $mb = new MBPackage ( $name ) ;
334 $mb->author = $author ;
335 $mb->description = $description ;
336 $mb->exportCustom ( $modules, true, true ) ;
340 function action_SaveField ()
342 require_once ('modules/DynamicFields/FieldCases.php') ;
343 $field = get_widget ( $_REQUEST [ 'type' ] ) ;
344 $_REQUEST [ 'name' ] = trim ( $_REQUEST [ 'name' ] ) ;
346 $field->populateFromPost () ;
348 if (!isset ( $_REQUEST [ 'view_package' ] ))
350 require_once ('modules/DynamicFields/DynamicField.php') ;
351 if (! empty ( $_REQUEST [ 'view_module' ] ))
353 $module = $_REQUEST [ 'view_module' ] ;
355 $bean = loadBean($module);
358 $field_defs = $bean->field_defs;
359 if(isset($field_defs[$field->name. '_c']))
361 $GLOBALS['log']->error($GLOBALS['mod_strings']['ERROR_ALREADY_EXISTS'] . '[' . $field->name . ']');
362 sugar_die($GLOBALS['mod_strings']['ERROR_ALREADY_EXISTS']);
366 $df = new DynamicField ( $module ) ;
367 $class_name = $GLOBALS [ 'beanList' ] [ $module ] ;
368 require_once ($GLOBALS [ 'beanFiles' ] [ $class_name ]) ;
369 $mod = new $class_name ( ) ;
370 $df->setup ( $mod ) ;
372 $field->save ( $df ) ;
373 $this->action_SaveLabel () ;
374 include_once ('modules/Administration/QuickRepairAndRebuild.php') ;
376 $mod_strings['LBL_ALL_MODULES'] = 'all_modules';
377 $repair = new RepairAndClear();
378 $repair->repairAndClearAll(array('rebuildExtensions', 'clearVardefs', 'clearTpls'), array($class_name), true, false);
379 //#28707 ,clear all the js files in cache
380 $repair->module_list = array();
381 $repair->clearJsFiles();
385 $mb = new ModuleBuilder ( ) ;
386 $module = & $mb->getPackageModule ( $_REQUEST [ 'view_package' ], $_REQUEST [ 'view_module' ] ) ;
387 $field->save ( $module ) ;
388 $module->mbvardefs->save () ;
389 // get the module again to refresh the labels we might have saved with the $field->save (e.g., for address fields)
390 $module = & $mb->getPackageModule ( $_REQUEST [ 'view_package' ], $_REQUEST [ 'view_module' ] ) ;
391 if (isset ( $_REQUEST [ 'label' ] ) && isset ( $_REQUEST [ 'labelValue' ] ))
392 $module->setLabel ( $GLOBALS [ 'current_language' ], $_REQUEST [ 'label' ], $_REQUEST [ 'labelValue' ] ) ;
395 $this->view = 'modulefields' ;
398 function action_saveSugarField ()
401 require_once ('modules/DynamicFields/FieldCases.php') ;
402 $field = get_widget ( $_REQUEST [ 'type' ] ) ;
403 $_REQUEST [ 'name' ] = trim ( $_POST [ 'name' ] ) ;
405 $field->populateFromPost () ;
406 require_once ('modules/ModuleBuilder/parsers/StandardField.php') ;
407 $module = $_REQUEST [ 'view_module' ] ;
408 $df = new StandardField ( $module ) ;
409 $class_name = $GLOBALS [ 'beanList' ] [ $module ] ;
410 require_once ($GLOBALS [ 'beanFiles' ] [ $class_name ]) ;
411 $mod = new $class_name ( ) ;
412 $df->setup ( $mod ) ;
414 $field->module = $mod;
415 $field->save ( $df ) ;
416 $this->action_SaveLabel () ;
418 $MBmodStrings = $mod_strings;
419 $GLOBALS [ 'mod_strings' ] = return_module_language ( '', 'Administration' ) ;
421 include_once ('modules/Administration/QuickRepairAndRebuild.php') ;
422 $GLOBALS [ 'mod_strings' ]['LBL_ALL_MODULES'] = 'all_modules';
423 $_REQUEST['execute_sql'] = true;
425 $repair = new RepairAndClear();
426 $repair->repairAndClearAll(array('rebuildExtensions', 'clearVardefs', 'clearTpls'), array($class_name), true, false);
427 //#28707 ,clear all the js files in cache
428 $repair->module_list = array();
429 $repair->clearJsFiles();
432 // now clear the cache so that the results are immediately visible
433 include_once ('include/TemplateHandler/TemplateHandler.php') ;
434 TemplateHandler::clearCache ( $module ) ;
436 $GLOBALS [ 'mod_strings' ] = $MBmodStrings;
439 function action_RefreshField ()
441 require_once ('modules/DynamicFields/FieldCases.php') ;
442 $field = get_widget ( $_POST [ 'type' ] ) ;
443 $field->populateFromPost () ;
444 $this->view = 'modulefield' ;
447 function action_saveVisibility ()
449 $packageName = (isset ( $_REQUEST [ 'view_package' ] ) && (strtolower($_REQUEST['view_package']) != 'studio')) ? $_REQUEST [ 'view_package' ] : null ;
450 require_once 'modules/ModuleBuilder/parsers/ParserFactory.php' ;
451 $parser = ParserFactory::getParser ( MB_VISIBILITY, $_REQUEST [ 'view_module' ], $packageName ) ;
453 $json = getJSONobj();
454 $visibility_grid = $json->decode(html_entity_decode(rawurldecode($_REQUEST [ 'visibility_grid' ]), ENT_QUOTES) );
455 $parser->saveVisibility ( $_REQUEST [ 'fieldname' ] , $_REQUEST [ 'trigger' ] , $visibility_grid ) ;
457 echo $json->encode(array( "visibility_editor_{$_REQUEST['fieldname']}" => array("action" => "deactivate")));
460 function action_SaveRelationshipLabel (){
461 $selected_lang = (!empty($_REQUEST['relationship_lang'])?$_REQUEST['relationship_lang']:$_SESSION['authenticated_user_language']);
462 if (empty($_REQUEST [ 'view_package' ])){
463 require_once 'modules/ModuleBuilder/parsers/relationships/DeployedRelationships.php' ;
464 $relationships = new DeployedRelationships ( $_REQUEST [ 'view_module' ] ) ;
465 if (! empty ( $_REQUEST [ 'relationship_name' ] ))
467 if ($relationship = $relationships->get ( $_REQUEST [ 'relationship_name' ] )){
468 $metadata = $relationship->buildLabels(true);
469 require_once 'modules/ModuleBuilder/parsers/parser.label.php' ;
470 $parser = new ParserLabel ( $_REQUEST['view_module'] ) ;
471 $parser->handleSaveRelationshipLabels ( $metadata, $selected_lang ) ;
478 $this->view = 'relationships' ;
481 function action_SaveRelationship ()
483 if(!empty($GLOBALS['current_user']) && empty($GLOBALS['modListHeader']))
485 $GLOBALS['modListHeader'] = query_module_access_list($GLOBALS['current_user']);
488 if (empty($_REQUEST [ 'view_package' ]))
490 require_once 'modules/ModuleBuilder/parsers/relationships/DeployedRelationships.php' ;
491 $relationships = new DeployedRelationships ( $_REQUEST [ 'view_module' ] ) ;
494 $mb = new ModuleBuilder ( ) ;
495 $module = & $mb->getPackageModule ( $_REQUEST [ 'view_package' ], $_REQUEST [ 'view_module' ] ) ;
496 require_once 'modules/ModuleBuilder/parsers/relationships/UndeployedRelationships.php' ;
497 $relationships = new UndeployedRelationships ( $module->getModuleDir () ) ;
500 $relationships->addFromPost () ;
501 $relationships->save () ;
502 $GLOBALS['log']->debug("\n\nSTART BUILD");
503 if (empty($_REQUEST [ 'view_package' ])) {
504 $relationships->build () ;
506 LanguageManager::clearLanguageCache($_REQUEST [ 'view_module' ]);
508 $GLOBALS['log']->debug("\n\nEND BUILD");
510 $this->view = 'relationships' ;
513 function action_DeleteRelationship ()
515 if (isset ( $_REQUEST [ 'relationship_name' ] ))
517 if (empty($_REQUEST [ 'view_package' ] ))
519 require_once 'modules/ModuleBuilder/parsers/relationships/DeployedRelationships.php' ;
520 if (!empty($_REQUEST['remove_tables']))
521 $GLOBALS['mi_remove_tables'] = $_REQUEST['remove_tables'];
522 $relationships = new DeployedRelationships ( $_REQUEST [ 'view_module' ] ) ;
525 $mb = new ModuleBuilder ( ) ;
526 $module = & $mb->getPackageModule ( $_REQUEST [ 'view_package' ], $_REQUEST [ 'view_module' ] ) ;
527 require_once 'modules/ModuleBuilder/parsers/relationships/UndeployedRelationships.php' ;
528 $relationships = new UndeployedRelationships ( $module->getModuleDir () ) ;
530 $relationships->delete ( $_REQUEST [ 'relationship_name' ] ) ;
531 $relationships->save () ;
533 $this->view = 'relationships' ;
536 function action_SaveDropDown ()
538 require_once 'modules/ModuleBuilder/parsers/parser.dropdown.php' ;
539 $parser = new ParserDropDown ( ) ;
540 $parser->saveDropDown ( $_REQUEST ) ;
541 $this->view = 'dropdowns' ;
544 function action_DeleteField ()
546 require_once ('modules/DynamicFields/FieldCases.php') ;
547 $field = get_widget ( $_REQUEST [ 'type' ] ) ;
548 $field->name = $_REQUEST [ 'name' ] ;
549 if (!isset ( $_REQUEST [ 'view_package' ] ))
551 if (! empty ( $_REQUEST [ 'name' ] ) && ! empty ( $_REQUEST [ 'view_module' ] ))
553 require_once ('modules/DynamicFields/DynamicField.php') ;
554 $moduleName = $_REQUEST [ 'view_module' ] ;
555 $class_name = $GLOBALS [ 'beanList' ] [ $moduleName ] ;
556 require_once ($GLOBALS [ 'beanFiles' ] [ $class_name ]) ;
557 $seed = new $class_name ( ) ;
558 $df = new DynamicField ( $moduleName ) ;
559 $df->setup ( $seed ) ;
560 //Need to load the entire field_meta_data for some field types
561 $field = $df->getFieldWidget($moduleName, $field->name);
562 $field->delete ( $df ) ;
564 $GLOBALS [ 'mod_strings' ]['LBL_ALL_MODULES'] = 'all_modules';
565 $_REQUEST['execute_sql'] = true;
566 include_once ('modules/Administration/QuickRepairAndRebuild.php') ;
567 $repair = new RepairAndClear();
568 $repair->repairAndClearAll(array('rebuildExtensions', 'clearVardefs', 'clearTpls'), array($class_name), true, false);
569 require_once 'modules/ModuleBuilder/Module/StudioModuleFactory.php' ;
570 $module = StudioModuleFactory::getStudioModule( $moduleName ) ;
575 $mb = new ModuleBuilder ( ) ;
576 $module = & $mb->getPackageModule ( $_REQUEST [ 'view_package' ], $_REQUEST [ 'view_module' ] ) ;
577 $field->delete ( $module ) ;
580 $module->removeFieldFromLayouts( $field->name );
581 $this->view = 'modulefields' ;
584 function action_CloneField ()
586 $this->view_object_map [ 'field_name' ] = $_REQUEST [ 'name' ] ;
587 $this->view_object_map [ 'is_clone' ] = true ;
588 $this->view = 'modulefield' ;
591 function action_SaveAssistantPref ()
593 global $current_user ;
594 if (isset ( $_REQUEST [ 'pref_value' ] ))
596 if ($_REQUEST [ 'pref_value' ] == 'ignore')
598 $current_user->setPreference ( 'mb_assist', 'DISABLED', 0, 'Assistant' ) ;
601 $current_user->setPreference ( 'mb_assist', 'ENABLED', 0, 'Assistant' ) ;
603 $current_pref = $current_user->getPreference ( 'mb_assist', 'Assistant' ) ;
604 echo "Assistant.processUserPref('$current_pref')" ;
605 sugar_cleanup ( true ) ; //push preferences to DB.
612 function action_EditProperty ()
614 $this->view = 'property' ;
617 function action_saveProperty ()
619 require_once 'modules/ModuleBuilder/parsers/parser.label.php' ;
620 $modules = $_REQUEST['view_module'];
621 if(!empty($_REQUEST['subpanel'])){
622 $modules = $_REQUEST['subpanel'];
624 $parser = new ParserLabel ( $modules , isset ( $_REQUEST [ 'view_package' ] ) ? $_REQUEST [ 'view_package' ] : null ) ;
625 // if no language provided, then use the user's current language which is most likely what they intended
626 $language = (isset($_REQUEST [ 'selected_lang' ])) ? $_REQUEST [ 'selected_lang' ] : $GLOBALS['current_language'] ;
627 $parser->handleSave ( $_REQUEST, $language ) ;
628 $json = getJSONobj();
629 echo $json->encode(array("east" => array("action" => "deactivate")));
632 function action_editModule ()
634 $this->view = 'module' ;
637 function action_wizard ()
639 $this->view = 'wizard' ;
643 * Receive a layout through $_REQUEST and save it out to the working files directory
644 * Expects a series of $_REQUEST parameters all in the format $_REQUEST['slot-panel#-slot#-property']=value
647 function action_saveLayout ()
649 $parser = ParserFactory::getParser ( $_REQUEST [ 'view' ], $_REQUEST [ 'view_module' ], isset ( $_REQUEST [ 'view_package' ] ) ? $_REQUEST [ 'view_package' ] : null ) ;
650 $this->view = 'layoutview' ;
651 $parser->writeWorkingFile () ;
653 if(!empty($_REQUEST [ 'sync_detail_and_edit' ]) && $_REQUEST['sync_detail_and_edit'] != false && $_REQUEST['sync_detail_and_edit'] != "false"){
654 if(strtolower ($parser->_view) == MB_EDITVIEW){
655 $parser2 = ParserFactory::getParser ( MB_DETAILVIEW, $_REQUEST [ 'view_module' ], isset ( $_REQUEST [ 'view_package' ] ) ? $_REQUEST [ 'view_package' ] : null ) ;
656 $parser2->setUseTabs($parser->getUseTabs());
657 $parser2->writeWorkingFile () ;
662 function action_saveAndPublishLayout ()
664 $parser = ParserFactory::getParser ( $_REQUEST [ 'view' ], $_REQUEST [ 'view_module' ], isset ( $_REQUEST [ 'view_package' ] ) ? $_REQUEST [ 'view_package' ] : null ) ;
665 $this->view = 'layoutview' ;
666 $parser->handleSave () ;
668 if(!empty($_REQUEST [ 'sync_detail_and_edit' ]) && $_REQUEST['sync_detail_and_edit'] != false && $_REQUEST['sync_detail_and_edit'] != "false"){
669 if(strtolower ($parser->_view) == MB_EDITVIEW){
670 $parser2 = ParserFactory::getParser ( MB_DETAILVIEW, $_REQUEST [ 'view_module' ], isset ( $_REQUEST [ 'view_package' ] ) ? $_REQUEST [ 'view_package' ] : null ) ;
671 $parser2->setUseTabs($parser->getUseTabs());
672 $parser2->handleSave () ;
677 function action_manageBackups ()
682 function action_listViewSave ()
684 $GLOBALS [ 'log' ]->info ( "action_listViewSave" ) ;
686 $packageName = (isset ( $_REQUEST [ 'view_package' ] ) && (strtolower($_REQUEST['view_package']) != 'studio')) ? $_REQUEST [ 'view_package' ] : null ;
687 $subpanelName = (! empty ( $_REQUEST [ 'subpanel' ] )) ? $_REQUEST [ 'subpanel' ] : null ;
688 require_once 'modules/ModuleBuilder/parsers/ParserFactory.php' ;
689 $parser = ParserFactory::getParser ( $_REQUEST [ 'view' ], $_REQUEST [ 'view_module' ], $packageName, $subpanelName ) ;
690 $this->view = 'listView' ;
691 $parser->handleSave () ;
695 function action_dashletSave () {
696 $this->view = 'dashlet' ;
697 $packageName = (isset ( $_REQUEST [ 'view_package' ] ) && (strtolower($_REQUEST['view_package']) != 'studio')) ? $_REQUEST [ 'view_package' ] : null ;
698 require_once 'modules/ModuleBuilder/parsers/ParserFactory.php' ;
699 $parser = ParserFactory::getParser ( $_REQUEST [ 'view' ], $_REQUEST [ 'view_module' ], $packageName ) ;
700 $parser->handleSave () ;
703 function action_popupSave(){
704 $this->view = 'popupview' ;
705 $packageName = (isset ( $_REQUEST [ 'view_package' ] ) && (strtolower($_REQUEST['view_package']) != 'studio')) ? $_REQUEST [ 'view_package' ] : null ;
706 require_once 'modules/ModuleBuilder/parsers/ParserFactory.php' ;
707 $parser = ParserFactory::getParser ( $_REQUEST [ 'view' ], $_REQUEST [ 'view_module' ], $packageName ) ;
708 $parser->handleSave () ;
709 if(empty($packageName)){
710 include_once ('modules/Administration/QuickRepairAndRebuild.php') ;
712 $mod_strings['LBL_ALL_MODULES'] = 'all_modules';
713 $repair = new RepairAndClear();
714 $repair->show_output = false;
715 $class_name = $GLOBALS [ 'beanList' ] [ $_REQUEST [ 'view_module' ] ] ;
716 $repair->module_list = array($class_name);
717 $repair->clearTpls();
722 function action_searchViewSave ()
724 $packageName = (isset ( $_REQUEST [ 'view_package' ] )) ? $_REQUEST [ 'view_package' ] : null ;
725 require_once 'modules/ModuleBuilder/parsers/views/SearchViewMetaDataParser.php' ;
726 $parser = new SearchViewMetaDataParser ( $_REQUEST [ 'view' ], $_REQUEST [ 'view_module' ], $packageName ) ;
727 $parser->handleSave () ;
728 $this->view = 'searchView' ;
731 function action_editLabels ()
733 if (isset ( $_REQUEST [ 'view_package' ] )) //MODULE BUILDER
735 $this->view = 'modulelabels';
737 $this->view = 'labels';
741 function action_get_app_list_string ()
743 require_once ('include/JSON.php') ;
744 $json = new JSON ( ) ;
745 if (isset ( $_REQUEST [ 'key' ] ) && ! empty ( $_REQUEST [ 'key' ] ))
747 $key = $_REQUEST [ 'key' ] ;
749 if (! empty ( $GLOBALS [ 'app_list_strings' ] [ $key ] ))
751 $value = $GLOBALS [ 'app_list_strings' ] [ $key ] ;
754 $package_strings = array ( ) ;
755 if (! empty ( $_REQUEST [ 'view_package' ] ) && $_REQUEST [ 'view_package' ] != 'studio' && ! empty ( $_REQUEST [ 'view_module' ] ))
757 require_once ('modules/ModuleBuilder/MB/ModuleBuilder.php') ;
758 $mb = new ModuleBuilder ( ) ;
759 $module = & $mb->getPackageModule ( $_REQUEST [ 'view_package' ], $_REQUEST [ 'view_module' ] ) ;
760 $lang = $GLOBALS [ 'current_language' ] ;
761 $module->mblanguage->generateAppStrings ( false ) ;
762 $package_strings = $module->mblanguage->appListStrings [ $lang . '.lang.php' ] ;
763 if (isset ( $package_strings [ $key ] ) && is_array ( $package_strings [ $key ] ))
765 $value = $package_strings [ $key ] ;
769 echo $json->encode ( $value ) ;
773 function action_history ()
775 $this->view = 'history' ;
778 function resetmodule()
780 $this->view = 'resetmodule';