2 /*********************************************************************************
3 * SugarCRM 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 ( $_REQUEST['type'] == 'studio' ) {
56 return $mod_strings['LBL_STUDIO'];
58 elseif ( $_REQUEST['type'] == 'sugarportal' ) {
59 return $mod_strings['LBL_SUGARPORTAL'];
61 elseif ( $_REQUEST['type'] == 'mb' ) {
62 return $mod_strings['LBL_MODULEBUILDER'];
64 elseif ( $_REQUEST['type'] == 'dropdowns') {
65 return $mod_strings['LBL_DROPDOWNEDITOR'];
67 elseif ( $_REQUEST['type'] == 'home' ) {
68 return $mod_strings['LBL_HOME'];
71 return $mod_strings['LBL_DEVELOPER_TOOLS'];
75 function fromModuleBuilder ()
77 return (isset ( $_REQUEST [ 'MB' ] ) && ($_REQUEST [ 'MB' ] == '1')) ;
81 $GLOBALS [ 'log' ]->info ( get_class($this).":" ) ;
83 $access = get_admin_modules_for_user($current_user);
84 if(is_admin($current_user) || (is_admin_for_any_module($current_user) && !isset($_REQUEST['view_module']) && (isset($_REQUEST['action']) && $_REQUEST['action'] != 'package'))||
85 (isset($_REQUEST['view_module']) && (in_array($_REQUEST['view_module'], $access)|| empty($_REQUEST['view_module']))) ||
86 (isset($_REQUEST['type']) && (($_REQUEST['type']=='dropdowns' && is_admin_for_any_module($current_user))||
87 ($_REQUEST['type']=='studio' && displayStudioForCurrentUser() == true))))
89 $this->hasAccess = true;
93 $this->hasAccess = false;
99 function action_editLayout ()
101 switch ( strtolower ( $_REQUEST [ 'view' ] ))
105 case MB_QUICKCREATE :
106 $this->view = 'layoutView' ;
109 $this->view = 'listView' ;
111 case MB_BASICSEARCH :
112 case MB_ADVANCEDSEARCH :
113 $this->view = 'searchView' ;
116 case MB_DASHLETSEARCH :
117 $this->view = 'dashlet' ;
120 case MB_POPUPSEARCH :
121 $this->view = 'popupview' ;
124 $GLOBALS [ 'log' ]->fatal ( 'Action = editLayout with unknown view=' . $_REQUEST [ 'view' ] ) ;
129 function action_ViewTree ()
131 require_once ('modules/ModuleBuilder/MB/AjaxCompose.php') ;
132 switch ( $_REQUEST [ 'tree' ])
134 case 'ModuleBuilder' :
135 require_once ('modules/ModuleBuilder/MB/MBPackageTree.php') ;
136 $mbt = new MBPackageTree ( ) ;
139 require_once ('modules/ModuleBuilder/Module/StudioTree.php') ;
140 $mbt = new StudioTree ( ) ;
142 $ajax = new AjaxCompose ( ) ;
143 $ajax->addSection ( 'west', $mbt->getName (), $mbt->fetchNodes () ) ;
144 echo $ajax->getJavascript () ;
146 sugar_cleanup ( true ) ;
150 function action_SavePackage ()
152 $mb = new ModuleBuilder ( ) ;
153 $load = (! empty ( $_REQUEST [ 'original_name' ] )) ? $_REQUEST [ 'original_name' ] : $_REQUEST [ 'name' ] ;
154 if (! empty ( $load ))
156 $mb->getPackage ( $load ) ;
158 if (! empty ( $_REQUEST [ 'duplicate' ] ))
160 $result = $mb->packages [ $load ]->copy ( $_REQUEST [ 'name' ] ) ;
161 $load = $mb->packages [ $load ]->name ;
162 $mb->getPackage ( $load ) ;
164 $mb->packages [ $load ]->populateFromPost () ;
165 $mb->packages [ $load ]->loadModules () ;
167 if (! empty ( $_REQUEST [ 'original_name' ] ) && $_REQUEST [ 'original_name' ] != $_REQUEST [ 'name' ])
169 if (! $mb->packages [ $load ]->rename ( $_REQUEST [ 'name' ] ))
171 $mb->packages [ $load ]->name = $_REQUEST [ 'original_name' ] ;
172 $_REQUEST [ 'name' ] = $_REQUEST [ 'original_name' ] ;
175 $_REQUEST [ 'package' ] = $_REQUEST [ 'name' ] ;
176 $this->view = 'package' ;
180 function action_BuildPackage ()
182 $mb = new ModuleBuilder ( ) ;
183 $load = $_REQUEST [ 'name' ] ;
184 if (! empty ( $load ))
186 $mb->getPackage ( $load ) ;
187 $mb->packages [ $load ]->build () ;
191 function action_DeployPackage ()
193 if(defined('TEMPLATE_URL')){
195 SugarTemplateUtilities::disableCache();
198 $mb = new ModuleBuilder ( ) ;
199 $load = $_REQUEST [ 'package' ] ;
200 $message = $GLOBALS [ 'mod_strings' ] [ 'LBL_MODULE_DEPLOYED' ] ;
201 if (! empty ( $load ))
203 $zip = $mb->getPackage ( $load ) ;
204 require_once ('ModuleInstall/PackageManager/PackageManager.php') ;
205 $pm = new PackageManager ( ) ;
206 $info = $mb->packages [ $load ]->build ( false ) ;
207 mkdir_recursive ( $GLOBALS [ 'sugar_config' ] [ 'cache_dir' ] . '/upload/upgrades/module/') ;
208 rename ( $info [ 'zip' ], $GLOBALS [ 'sugar_config' ] [ 'cache_dir' ] . '/' . 'upload/upgrades/module/' . $info [ 'name' ] . '.zip' ) ;
209 copy ( $info [ 'manifest' ], $GLOBALS [ 'sugar_config' ] [ 'cache_dir' ] . '/' . 'upload/upgrades/module/' . $info [ 'name' ] . '-manifest.php' ) ;
210 $_REQUEST [ 'install_file' ] = $GLOBALS [ 'sugar_config' ] [ 'cache_dir' ] . '/' . 'upload/upgrades/module/' . $info [ 'name' ] . '.zip' ;
211 $GLOBALS [ 'mi_remove_tables' ] = false ;
212 $pm->performUninstall ( $load ) ;
213 //#23177 , js cache clear
214 clearAllJsAndJsLangFilesWithoutOutput();
215 //#30747, clear the cache in memory
216 $cache_key = 'app_list_strings.'.$GLOBALS['current_language'];
217 sugar_cache_clear($cache_key );
220 $pm->performInstall ( $_REQUEST [ 'install_file' ] , true) ;
222 //clear the unified_search_module.php file
223 require_once('modules/Home/UnifiedSearchAdvanced.php');
224 UnifiedSearchAdvanced::unlinkUnifiedSearchModulesFile();
230 function action_ExportPackage ()
232 $mb = new ModuleBuilder ( ) ;
233 $load = $_REQUEST [ 'name' ] ;
234 $author = $_REQUEST [ 'author' ] ;
235 $description = $_REQUEST [ 'description' ] ;
236 $readme = $_REQUEST [ 'readme' ] ;
237 if (! empty ( $load ))
239 $mb->getPackage ( $load ) ;
240 $mb->packages [ $load ]->author = $author ;
241 $mb->packages [ $load ]->description = $description ;
242 $mb->packages [ $load ]->exportProject () ;
243 $mb->packages [ $load ]->readme = $readme ;
247 function action_DeletePackage ()
249 $mb = new ModuleBuilder ( ) ;
250 $mb->getPackage ( $_REQUEST [ 'package' ] ) ;
251 $mb->packages [ $_REQUEST [ 'package' ] ]->delete () ;
252 $this->view = 'deletepackage' ;
255 function action_SaveModule ()
257 $mb = new ModuleBuilder ( ) ;
258 $load = (! empty ( $_REQUEST [ 'original_name' ] )) ? $_REQUEST [ 'original_name' ] : $_REQUEST [ 'name' ] ;
259 if (! empty ( $load ))
261 $mb->getPackage ( $_REQUEST [ 'package' ] ) ;
262 $mb->packages [ $_REQUEST [ 'package' ] ]->getModule ( $load ) ;
263 $module = & $mb->packages [ $_REQUEST [ 'package' ] ]->modules [ $load ] ;
264 $module->populateFromPost () ;
266 if (! empty ( $_REQUEST [ 'duplicate' ] ))
268 $module->copy ( $_REQUEST [ 'name' ] ) ;
269 } else if (! empty ( $_REQUEST [ 'original_name' ] ) && $_REQUEST [ 'original_name' ] != $_REQUEST [ 'name' ])
271 if (! $module->rename ( $_REQUEST [ 'name' ] ))
273 $module->name = $_REQUEST [ 'original_name' ] ;
274 $_REQUEST [ 'name' ] = $_REQUEST [ 'original_name' ] ;
278 $_REQUEST [ 'view_package' ] = $_REQUEST [ 'package' ] ;
279 $_REQUEST [ 'view_module' ] = $module->name ;
280 $this->view = 'module' ;
284 function action_DeleteModule ()
286 $mb = new ModuleBuilder ( ) ;
287 $module = & $mb->getPackageModule ( $_REQUEST [ 'package' ], $_REQUEST [ 'view_module' ] ) ;
289 $this->view = 'package' ;
292 function action_saveLabels ()
294 require_once 'modules/ModuleBuilder/parsers/parser.label.php' ;
295 $parser = new ParserLabel ( $_REQUEST['view_module'] , isset ( $_REQUEST [ 'view_package' ] ) ? $_REQUEST [ 'view_package' ] : null ) ;
296 $parser->handleSave ( $_REQUEST, $_REQUEST [ 'selected_lang' ] ) ;
297 if (isset ( $_REQUEST [ 'view_package' ] )) //MODULE BUILDER
299 $this->view = 'modulelabels' ;
302 $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)
306 function action_SaveLabel ()
308 if (! empty ( $_REQUEST [ 'view_module' ] ) && !empty($_REQUEST [ 'labelValue' ]))
310 $_REQUEST [ "label_" . $_REQUEST [ 'label' ] ] = $_REQUEST [ 'labelValue' ] ;
311 require_once 'modules/ModuleBuilder/parsers/parser.label.php' ;
312 $parser = new ParserLabel ( $_REQUEST['view_module'] , isset ( $_REQUEST [ 'view_package' ] ) ? $_REQUEST [ 'view_package' ] : null ) ;
313 $parser->handleSave ( $_REQUEST, $GLOBALS [ 'current_language' ] ) ;
316 $this->view = 'modulefields' ;
319 function action_ExportCustom ()
321 $modules = $_REQUEST [ 'modules' ] ;
322 $name = $_REQUEST [ 'name' ] ;
323 $author = $_REQUEST [ 'author' ] ;
324 $description = $_REQUEST [ 'description' ] ;
326 if (! empty ( $modules ) && ! empty ( $name ))
328 require_once ('modules/ModuleBuilder/MB/ModuleBuilder.php') ;
329 $mb = new MBPackage ( $name ) ;
330 $mb->author = $author ;
331 $mb->description = $description ;
332 $mb->exportCustom ( $modules, true, true ) ;
336 function action_SaveField ()
338 require_once ('modules/DynamicFields/FieldCases.php') ;
339 $field = get_widget ( $_REQUEST [ 'type' ] ) ;
340 $_REQUEST [ 'name' ] = trim ( $_REQUEST [ 'name' ] ) ;
342 $field->populateFromPost () ;
344 if (!isset ( $_REQUEST [ 'view_package' ] ))
346 require_once ('modules/DynamicFields/DynamicField.php') ;
347 if (! empty ( $_REQUEST [ 'view_module' ] ))
349 $module = $_REQUEST [ 'view_module' ] ;
351 $bean = loadBean($module);
354 $field_defs = $bean->field_defs;
355 if(isset($field_defs[$field->name. '_c']))
357 $GLOBALS['log']->error($GLOBALS['mod_strings']['ERROR_ALREADY_EXISTS'] . '[' . $field->name . ']');
358 sugar_die($GLOBALS['mod_strings']['ERROR_ALREADY_EXISTS']);
362 $df = new DynamicField ( $module ) ;
363 $class_name = $GLOBALS [ 'beanList' ] [ $module ] ;
364 require_once ($GLOBALS [ 'beanFiles' ] [ $class_name ]) ;
365 $mod = new $class_name ( ) ;
366 $df->setup ( $mod ) ;
368 $field->save ( $df ) ;
369 $this->action_SaveLabel () ;
370 include_once ('modules/Administration/QuickRepairAndRebuild.php') ;
372 $mod_strings['LBL_ALL_MODULES'] = 'all_modules';
373 $repair = new RepairAndClear();
374 $repair->repairAndClearAll(array('rebuildExtensions', 'clearVardefs', 'clearTpls'), array($class_name), true, false);
375 //#28707 ,clear all the js files in cache
376 $repair->module_list = array();
377 $repair->clearJsFiles();
381 $mb = new ModuleBuilder ( ) ;
382 $module = & $mb->getPackageModule ( $_REQUEST [ 'view_package' ], $_REQUEST [ 'view_module' ] ) ;
383 $field->save ( $module ) ;
384 $module->mbvardefs->save () ;
385 // get the module again to refresh the labels we might have saved with the $field->save (e.g., for address fields)
386 $module = & $mb->getPackageModule ( $_REQUEST [ 'view_package' ], $_REQUEST [ 'view_module' ] ) ;
387 if (isset ( $_REQUEST [ 'label' ] ) && isset ( $_REQUEST [ 'labelValue' ] ))
388 $module->setLabel ( $GLOBALS [ 'current_language' ], $_REQUEST [ 'label' ], $_REQUEST [ 'labelValue' ] ) ;
391 $this->view = 'modulefields' ;
394 function action_saveSugarField ()
397 require_once ('modules/DynamicFields/FieldCases.php') ;
398 $field = get_widget ( $_REQUEST [ 'type' ] ) ;
399 $_REQUEST [ 'name' ] = trim ( $_POST [ 'name' ] ) ;
401 $field->populateFromPost () ;
402 require_once ('modules/ModuleBuilder/parsers/StandardField.php') ;
403 $module = $_REQUEST [ 'view_module' ] ;
404 $df = new StandardField ( $module ) ;
405 $class_name = $GLOBALS [ 'beanList' ] [ $module ] ;
406 require_once ($GLOBALS [ 'beanFiles' ] [ $class_name ]) ;
407 $mod = new $class_name ( ) ;
408 $df->setup ( $mod ) ;
410 $field->module = $mod;
411 $field->save ( $df ) ;
412 $this->action_SaveLabel () ;
414 $MBmodStrings = $mod_strings;
415 $GLOBALS [ 'mod_strings' ] = return_module_language ( '', 'Administration' ) ;
417 include_once ('modules/Administration/QuickRepairAndRebuild.php') ;
418 $GLOBALS [ 'mod_strings' ]['LBL_ALL_MODULES'] = 'all_modules';
419 $_REQUEST['execute_sql'] = true;
421 $repair = new RepairAndClear();
422 $repair->repairAndClearAll(array('rebuildExtensions', 'clearVardefs', 'clearTpls'), array($class_name), true, false);
423 //#28707 ,clear all the js files in cache
424 $repair->module_list = array();
425 $repair->clearJsFiles();
428 // now clear the cache so that the results are immediately visible
429 include_once ('include/TemplateHandler/TemplateHandler.php') ;
430 TemplateHandler::clearCache ( $module ) ;
432 $GLOBALS [ 'mod_strings' ] = $MBmodStrings;
435 function action_RefreshField ()
437 require_once ('modules/DynamicFields/FieldCases.php') ;
438 $field = get_widget ( $_POST [ 'type' ] ) ;
439 $field->populateFromPost () ;
440 $this->view = 'modulefield' ;
443 function action_saveVisibility ()
445 $packageName = (isset ( $_REQUEST [ 'view_package' ] ) && (strtolower($_REQUEST['view_package']) != 'studio')) ? $_REQUEST [ 'view_package' ] : null ;
446 require_once 'modules/ModuleBuilder/parsers/ParserFactory.php' ;
447 $parser = ParserFactory::getParser ( MB_VISIBILITY, $_REQUEST [ 'view_module' ], $packageName ) ;
449 $json = getJSONobj();
450 $visibility_grid = $json->decode(html_entity_decode(rawurldecode($_REQUEST [ 'visibility_grid' ]), ENT_QUOTES) );
451 $parser->saveVisibility ( $_REQUEST [ 'fieldname' ] , $_REQUEST [ 'trigger' ] , $visibility_grid ) ;
453 echo $json->encode(array( "visibility_editor_{$_REQUEST['fieldname']}" => array("action" => "deactivate")));
456 function action_SaveRelationshipLabel (){
457 $selected_lang = (!empty($_REQUEST['relationship_lang'])?$_REQUEST['relationship_lang']:$_SESSION['authenticated_user_language']);
458 if (empty($_REQUEST [ 'view_package' ])){
459 require_once 'modules/ModuleBuilder/parsers/relationships/DeployedRelationships.php' ;
460 $relationships = new DeployedRelationships ( $_REQUEST [ 'view_module' ] ) ;
461 if (! empty ( $_REQUEST [ 'relationship_name' ] ))
463 if ($relationship = $relationships->get ( $_REQUEST [ 'relationship_name' ] )){
464 $metadata = $relationship->buildLabels(true);
465 require_once 'modules/ModuleBuilder/parsers/parser.label.php' ;
466 $parser = new ParserLabel ( $_REQUEST['view_module'] ) ;
467 $parser->handleSaveRelationshipLabels ( $metadata, $selected_lang ) ;
474 $this->view = 'relationships' ;
477 function action_SaveRelationship ()
479 if(!empty($GLOBALS['current_user']) && empty($GLOBALS['modListHeader']))
481 $GLOBALS['modListHeader'] = query_module_access_list($GLOBALS['current_user']);
484 if (empty($_REQUEST [ 'view_package' ]))
486 require_once 'modules/ModuleBuilder/parsers/relationships/DeployedRelationships.php' ;
487 $relationships = new DeployedRelationships ( $_REQUEST [ 'view_module' ] ) ;
490 $mb = new ModuleBuilder ( ) ;
491 $module = & $mb->getPackageModule ( $_REQUEST [ 'view_package' ], $_REQUEST [ 'view_module' ] ) ;
492 require_once 'modules/ModuleBuilder/parsers/relationships/UndeployedRelationships.php' ;
493 $relationships = new UndeployedRelationships ( $module->getModuleDir () ) ;
496 $relationships->addFromPost () ;
497 $relationships->save () ;
498 $GLOBALS['log']->debug("\n\nSTART BUILD");
499 if (empty($_REQUEST [ 'view_package' ])) {
500 $relationships->build () ;
502 LanguageManager::clearLanguageCache($_REQUEST [ 'view_module' ]);
504 $GLOBALS['log']->debug("\n\nEND BUILD");
506 $this->view = 'relationships' ;
509 function action_DeleteRelationship ()
511 if (isset ( $_REQUEST [ 'relationship_name' ] ))
513 if (empty($_REQUEST [ 'view_package' ] ))
515 require_once 'modules/ModuleBuilder/parsers/relationships/DeployedRelationships.php' ;
516 if (!empty($_REQUEST['remove_tables']))
517 $GLOBALS['mi_remove_tables'] = $_REQUEST['remove_tables'];
518 $relationships = new DeployedRelationships ( $_REQUEST [ 'view_module' ] ) ;
521 $mb = new ModuleBuilder ( ) ;
522 $module = & $mb->getPackageModule ( $_REQUEST [ 'view_package' ], $_REQUEST [ 'view_module' ] ) ;
523 require_once 'modules/ModuleBuilder/parsers/relationships/UndeployedRelationships.php' ;
524 $relationships = new UndeployedRelationships ( $module->getModuleDir () ) ;
526 $relationships->delete ( $_REQUEST [ 'relationship_name' ] ) ;
527 $relationships->save () ;
529 $this->view = 'relationships' ;
532 function action_SaveDropDown ()
534 require_once 'modules/ModuleBuilder/parsers/parser.dropdown.php' ;
535 $parser = new ParserDropDown ( ) ;
536 $parser->saveDropDown ( $_REQUEST ) ;
537 $this->view = 'dropdowns' ;
540 function action_DeleteField ()
542 require_once ('modules/DynamicFields/FieldCases.php') ;
543 $field = get_widget ( $_REQUEST [ 'type' ] ) ;
544 $field->name = $_REQUEST [ 'name' ] ;
545 if (!isset ( $_REQUEST [ 'view_package' ] ))
547 if (! empty ( $_REQUEST [ 'name' ] ) && ! empty ( $_REQUEST [ 'view_module' ] ))
549 require_once ('modules/DynamicFields/DynamicField.php') ;
550 $moduleName = $_REQUEST [ 'view_module' ] ;
551 $class_name = $GLOBALS [ 'beanList' ] [ $moduleName ] ;
552 require_once ($GLOBALS [ 'beanFiles' ] [ $class_name ]) ;
553 $seed = new $class_name ( ) ;
554 $df = new DynamicField ( $moduleName ) ;
555 $df->setup ( $seed ) ;
556 //Need to load the entire field_meta_data for some field types
557 $field = $df->getFieldWidget($moduleName, $field->name);
558 $field->delete ( $df ) ;
560 $GLOBALS [ 'mod_strings' ]['LBL_ALL_MODULES'] = 'all_modules';
561 $_REQUEST['execute_sql'] = true;
562 include_once ('modules/Administration/QuickRepairAndRebuild.php') ;
563 $repair = new RepairAndClear();
564 $repair->repairAndClearAll(array('rebuildExtensions', 'clearVardefs', 'clearTpls'), array($class_name), true, false);
565 require_once 'modules/ModuleBuilder/Module/StudioModuleFactory.php' ;
566 $module = StudioModuleFactory::getStudioModule( $moduleName ) ;
571 $mb = new ModuleBuilder ( ) ;
572 $module = & $mb->getPackageModule ( $_REQUEST [ 'view_package' ], $_REQUEST [ 'view_module' ] ) ;
573 $field->delete ( $module ) ;
576 $module->removeFieldFromLayouts( $field->name );
577 $this->view = 'modulefields' ;
580 function action_CloneField ()
582 $this->view_object_map [ 'field_name' ] = $_REQUEST [ 'name' ] ;
583 $this->view_object_map [ 'is_clone' ] = true ;
584 $this->view = 'modulefield' ;
587 function action_SaveAssistantPref ()
589 global $current_user ;
590 if (isset ( $_REQUEST [ 'pref_value' ] ))
592 if ($_REQUEST [ 'pref_value' ] == 'ignore')
594 $current_user->setPreference ( 'mb_assist', 'DISABLED', 0, 'Assistant' ) ;
597 $current_user->setPreference ( 'mb_assist', 'ENABLED', 0, 'Assistant' ) ;
599 $current_pref = $current_user->getPreference ( 'mb_assist', 'Assistant' ) ;
600 echo "Assistant.processUserPref('$current_pref')" ;
601 sugar_cleanup ( true ) ; //push preferences to DB.
608 function action_EditProperty ()
610 $this->view = 'property' ;
613 function action_saveProperty ()
615 require_once 'modules/ModuleBuilder/parsers/parser.label.php' ;
616 $modules = $_REQUEST['view_module'];
617 if(!empty($_REQUEST['subpanel'])){
618 $modules = $_REQUEST['subpanel'];
620 $parser = new ParserLabel ( $modules , isset ( $_REQUEST [ 'view_package' ] ) ? $_REQUEST [ 'view_package' ] : null ) ;
621 // if no language provided, then use the user's current language which is most likely what they intended
622 $language = (isset($_REQUEST [ 'selected_lang' ])) ? $_REQUEST [ 'selected_lang' ] : $GLOBALS['current_language'] ;
623 $parser->handleSave ( $_REQUEST, $language ) ;
624 $json = getJSONobj();
625 echo $json->encode(array("east" => array("action" => "deactivate")));
628 function action_editModule ()
630 $this->view = 'module' ;
633 function action_wizard ()
635 $this->view = 'wizard' ;
639 * Receive a layout through $_REQUEST and save it out to the working files directory
640 * Expects a series of $_REQUEST parameters all in the format $_REQUEST['slot-panel#-slot#-property']=value
643 function action_saveLayout ()
645 $parser = ParserFactory::getParser ( $_REQUEST [ 'view' ], $_REQUEST [ 'view_module' ], isset ( $_REQUEST [ 'view_package' ] ) ? $_REQUEST [ 'view_package' ] : null ) ;
646 $this->view = 'layoutview' ;
647 $parser->writeWorkingFile () ;
649 if(!empty($_REQUEST [ 'sync_detail_and_edit' ]) && $_REQUEST['sync_detail_and_edit'] != false && $_REQUEST['sync_detail_and_edit'] != "false"){
650 if(strtolower ($parser->_view) == MB_EDITVIEW){
651 $parser2 = ParserFactory::getParser ( MB_DETAILVIEW, $_REQUEST [ 'view_module' ], isset ( $_REQUEST [ 'view_package' ] ) ? $_REQUEST [ 'view_package' ] : null ) ;
652 $parser2->setUseTabs($parser->getUseTabs());
653 $parser2->writeWorkingFile () ;
658 function action_saveAndPublishLayout ()
660 $parser = ParserFactory::getParser ( $_REQUEST [ 'view' ], $_REQUEST [ 'view_module' ], isset ( $_REQUEST [ 'view_package' ] ) ? $_REQUEST [ 'view_package' ] : null ) ;
661 $this->view = 'layoutview' ;
662 $parser->handleSave () ;
664 if(!empty($_REQUEST [ 'sync_detail_and_edit' ]) && $_REQUEST['sync_detail_and_edit'] != false && $_REQUEST['sync_detail_and_edit'] != "false"){
665 if(strtolower ($parser->_view) == MB_EDITVIEW){
666 $parser2 = ParserFactory::getParser ( MB_DETAILVIEW, $_REQUEST [ 'view_module' ], isset ( $_REQUEST [ 'view_package' ] ) ? $_REQUEST [ 'view_package' ] : null ) ;
667 $parser2->setUseTabs($parser->getUseTabs());
668 $parser2->handleSave () ;
673 function action_manageBackups ()
678 function action_listViewSave ()
680 $GLOBALS [ 'log' ]->info ( "action_listViewSave" ) ;
682 $packageName = (isset ( $_REQUEST [ 'view_package' ] ) && (strtolower($_REQUEST['view_package']) != 'studio')) ? $_REQUEST [ 'view_package' ] : null ;
683 $subpanelName = (! empty ( $_REQUEST [ 'subpanel' ] )) ? $_REQUEST [ 'subpanel' ] : null ;
684 require_once 'modules/ModuleBuilder/parsers/ParserFactory.php' ;
685 $parser = ParserFactory::getParser ( $_REQUEST [ 'view' ], $_REQUEST [ 'view_module' ], $packageName, $subpanelName ) ;
686 $this->view = 'listView' ;
687 $parser->handleSave () ;
691 function action_dashletSave () {
692 $this->view = 'dashlet' ;
693 $packageName = (isset ( $_REQUEST [ 'view_package' ] ) && (strtolower($_REQUEST['view_package']) != 'studio')) ? $_REQUEST [ 'view_package' ] : null ;
694 require_once 'modules/ModuleBuilder/parsers/ParserFactory.php' ;
695 $parser = ParserFactory::getParser ( $_REQUEST [ 'view' ], $_REQUEST [ 'view_module' ], $packageName ) ;
696 $parser->handleSave () ;
699 function action_popupSave(){
700 $this->view = 'popupview' ;
701 $packageName = (isset ( $_REQUEST [ 'view_package' ] ) && (strtolower($_REQUEST['view_package']) != 'studio')) ? $_REQUEST [ 'view_package' ] : null ;
702 require_once 'modules/ModuleBuilder/parsers/ParserFactory.php' ;
703 $parser = ParserFactory::getParser ( $_REQUEST [ 'view' ], $_REQUEST [ 'view_module' ], $packageName ) ;
704 $parser->handleSave () ;
705 if(empty($packageName)){
706 include_once ('modules/Administration/QuickRepairAndRebuild.php') ;
708 $mod_strings['LBL_ALL_MODULES'] = 'all_modules';
709 $repair = new RepairAndClear();
710 $repair->show_output = false;
711 $class_name = $GLOBALS [ 'beanList' ] [ $_REQUEST [ 'view_module' ] ] ;
712 $repair->module_list = array($class_name);
713 $repair->clearTpls();
718 function action_searchViewSave ()
720 $packageName = (isset ( $_REQUEST [ 'view_package' ] )) ? $_REQUEST [ 'view_package' ] : null ;
721 require_once 'modules/ModuleBuilder/parsers/views/SearchViewMetaDataParser.php' ;
722 $parser = new SearchViewMetaDataParser ( $_REQUEST [ 'view' ], $_REQUEST [ 'view_module' ], $packageName ) ;
723 $parser->handleSave () ;
724 $this->view = 'searchView' ;
727 function action_editLabels ()
729 if (isset ( $_REQUEST [ 'view_package' ] )) //MODULE BUILDER
731 $this->view = 'modulelabels';
733 $this->view = 'labels';
737 function action_get_app_list_string ()
739 require_once ('include/JSON.php') ;
740 $json = new JSON ( ) ;
741 if (isset ( $_REQUEST [ 'key' ] ) && ! empty ( $_REQUEST [ 'key' ] ))
743 $key = $_REQUEST [ 'key' ] ;
745 if (! empty ( $GLOBALS [ 'app_list_strings' ] [ $key ] ))
747 $value = $GLOBALS [ 'app_list_strings' ] [ $key ] ;
750 $package_strings = array ( ) ;
751 if (! empty ( $_REQUEST [ 'view_package' ] ) && $_REQUEST [ 'view_package' ] != 'studio' && ! empty ( $_REQUEST [ 'view_module' ] ))
753 require_once ('modules/ModuleBuilder/MB/ModuleBuilder.php') ;
754 $mb = new ModuleBuilder ( ) ;
755 $module = & $mb->getPackageModule ( $_REQUEST [ 'view_package' ], $_REQUEST [ 'view_module' ] ) ;
756 $lang = $GLOBALS [ 'current_language' ] ;
757 $module->mblanguage->generateAppStrings ( false ) ;
758 $package_strings = $module->mblanguage->appListStrings [ $lang . '.lang.php' ] ;
759 if (isset ( $package_strings [ $key ] ) && is_array ( $package_strings [ $key ] ))
761 $value = $package_strings [ $key ] ;
765 echo $json->encode ( $value ) ;
769 function action_history ()
771 $this->view = 'history' ;
774 function resetmodule()
776 $this->view = 'resetmodule';