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 ( ) ;
45 function fromModuleBuilder ()
47 return (isset ( $_REQUEST [ 'MB' ] ) && ($_REQUEST [ 'MB' ] == '1')) ;
51 $GLOBALS [ 'log' ]->info ( get_class($this).":" ) ;
53 $access = get_admin_modules_for_user($current_user);
54 if(is_admin($current_user) || (is_admin_for_any_module($current_user) && !isset($_REQUEST['view_module']) && (isset($_REQUEST['action']) && $_REQUEST['action'] != 'package'))||
55 (isset($_REQUEST['view_module']) && (in_array($_REQUEST['view_module'], $access)|| empty($_REQUEST['view_module']))) ||
56 (isset($_REQUEST['type']) && (($_REQUEST['type']=='dropdowns' && is_admin_for_any_module($current_user))||
57 ($_REQUEST['type']=='studio' && displayStudioForCurrentUser() == true))))
59 $this->hasAccess = true;
63 $this->hasAccess = false;
69 function action_editLayout ()
71 switch ( strtolower ( $_REQUEST [ 'view' ] ))
76 $this->view = 'layoutView' ;
79 $this->view = 'listView' ;
82 case MB_ADVANCEDSEARCH :
83 $this->view = 'searchView' ;
86 case MB_DASHLETSEARCH :
87 $this->view = 'dashlet' ;
91 $this->view = 'popupview' ;
94 $GLOBALS [ 'log' ]->fatal ( 'Action = editLayout with unknown view=' . $_REQUEST [ 'view' ] ) ;
99 function action_ViewTree ()
101 require_once ('modules/ModuleBuilder/MB/AjaxCompose.php') ;
102 switch ( $_REQUEST [ 'tree' ])
104 case 'ModuleBuilder' :
105 require_once ('modules/ModuleBuilder/MB/MBPackageTree.php') ;
106 $mbt = new MBPackageTree ( ) ;
109 require_once ('modules/ModuleBuilder/Module/StudioTree.php') ;
110 $mbt = new StudioTree ( ) ;
112 $ajax = new AjaxCompose ( ) ;
113 $ajax->addSection ( 'west', $mbt->getName (), $mbt->fetchNodes () ) ;
114 echo $ajax->getJavascript () ;
116 sugar_cleanup ( true ) ;
120 function action_SavePackage ()
122 $mb = new ModuleBuilder ( ) ;
123 $load = (! empty ( $_REQUEST [ 'original_name' ] )) ? $_REQUEST [ 'original_name' ] : $_REQUEST [ 'name' ] ;
124 if (! empty ( $load ))
126 $mb->getPackage ( $load ) ;
128 if (! empty ( $_REQUEST [ 'duplicate' ] ))
130 $result = $mb->packages [ $load ]->copy ( $_REQUEST [ 'name' ] ) ;
131 $load = $mb->packages [ $load ]->name ;
132 $mb->getPackage ( $load ) ;
134 $mb->packages [ $load ]->populateFromPost () ;
135 $mb->packages [ $load ]->loadModules () ;
137 if (! empty ( $_REQUEST [ 'original_name' ] ) && $_REQUEST [ 'original_name' ] != $_REQUEST [ 'name' ])
139 if (! $mb->packages [ $load ]->rename ( $_REQUEST [ 'name' ] ))
141 $mb->packages [ $load ]->name = $_REQUEST [ 'original_name' ] ;
142 $_REQUEST [ 'name' ] = $_REQUEST [ 'original_name' ] ;
145 $_REQUEST [ 'package' ] = $_REQUEST [ 'name' ] ;
146 $this->view = 'package' ;
150 function action_BuildPackage ()
152 $mb = new ModuleBuilder ( ) ;
153 $load = $_REQUEST [ 'name' ] ;
154 if (! empty ( $load ))
156 $mb->getPackage ( $load ) ;
157 $mb->packages [ $load ]->build () ;
161 function action_DeployPackage ()
163 if(defined('TEMPLATE_URL')){
165 SugarTemplateUtilities::disableCache();
168 $mb = new ModuleBuilder ( ) ;
169 $load = $_REQUEST [ 'package' ] ;
170 $message = $GLOBALS [ 'mod_strings' ] [ 'LBL_MODULE_DEPLOYED' ] ;
171 if (! empty ( $load ))
173 $zip = $mb->getPackage ( $load ) ;
174 require_once ('ModuleInstall/PackageManager/PackageManager.php') ;
175 $pm = new PackageManager ( ) ;
176 $info = $mb->packages [ $load ]->build ( false ) ;
177 mkdir_recursive ( $GLOBALS [ 'sugar_config' ] [ 'cache_dir' ] . '/upload/upgrades/module/') ;
178 rename ( $info [ 'zip' ], $GLOBALS [ 'sugar_config' ] [ 'cache_dir' ] . '/' . 'upload/upgrades/module/' . $info [ 'name' ] . '.zip' ) ;
179 copy ( $info [ 'manifest' ], $GLOBALS [ 'sugar_config' ] [ 'cache_dir' ] . '/' . 'upload/upgrades/module/' . $info [ 'name' ] . '-manifest.php' ) ;
180 $_REQUEST [ 'install_file' ] = $GLOBALS [ 'sugar_config' ] [ 'cache_dir' ] . '/' . 'upload/upgrades/module/' . $info [ 'name' ] . '.zip' ;
181 $GLOBALS [ 'mi_remove_tables' ] = false ;
182 $pm->performUninstall ( $load ) ;
183 //#23177 , js cache clear
184 clearAllJsAndJsLangFilesWithoutOutput();
185 //#30747, clear the cache in memoy
186 $cache_key = 'app_list_strings.'.$GLOBALS['current_language'];
187 sugar_cache_clear($cache_key );
190 $pm->performInstall ( $_REQUEST [ 'install_file' ] , true) ;
196 function action_ExportPackage ()
198 $mb = new ModuleBuilder ( ) ;
199 $load = $_REQUEST [ 'name' ] ;
200 $author = $_REQUEST [ 'author' ] ;
201 $description = $_REQUEST [ 'description' ] ;
202 $readme = $_REQUEST [ 'readme' ] ;
203 if (! empty ( $load ))
205 $mb->getPackage ( $load ) ;
206 $mb->packages [ $load ]->author = $author ;
207 $mb->packages [ $load ]->description = $description ;
208 $mb->packages [ $load ]->exportProject () ;
209 $mb->packages [ $load ]->readme = $readme ;
213 function action_DeletePackage ()
215 $mb = new ModuleBuilder ( ) ;
216 $mb->getPackage ( $_REQUEST [ 'package' ] ) ;
217 $mb->packages [ $_REQUEST [ 'package' ] ]->delete () ;
218 $this->view = 'deletepackage' ;
221 function action_SaveModule ()
223 $mb = new ModuleBuilder ( ) ;
224 $load = (! empty ( $_REQUEST [ 'original_name' ] )) ? $_REQUEST [ 'original_name' ] : $_REQUEST [ 'name' ] ;
225 if (! empty ( $load ))
227 $mb->getPackage ( $_REQUEST [ 'package' ] ) ;
228 $mb->packages [ $_REQUEST [ 'package' ] ]->getModule ( $load ) ;
229 $module = & $mb->packages [ $_REQUEST [ 'package' ] ]->modules [ $load ] ;
230 $module->populateFromPost () ;
232 if (! empty ( $_REQUEST [ 'duplicate' ] ))
234 $module->copy ( $_REQUEST [ 'name' ] ) ;
235 } else if (! empty ( $_REQUEST [ 'original_name' ] ) && $_REQUEST [ 'original_name' ] != $_REQUEST [ 'name' ])
237 if (! $module->rename ( $_REQUEST [ 'name' ] ))
239 $module->name = $_REQUEST [ 'original_name' ] ;
240 $_REQUEST [ 'name' ] = $_REQUEST [ 'original_name' ] ;
244 $_REQUEST [ 'view_package' ] = $_REQUEST [ 'package' ] ;
245 $_REQUEST [ 'view_module' ] = $module->name ;
246 $this->view = 'module' ;
250 function action_DeleteModule ()
252 $mb = new ModuleBuilder ( ) ;
253 $module = & $mb->getPackageModule ( $_REQUEST [ 'package' ], $_REQUEST [ 'view_module' ] ) ;
255 $this->view = 'package' ;
258 function action_saveLabels ()
260 require_once 'modules/ModuleBuilder/parsers/parser.label.php' ;
261 $parser = new ParserLabel ( $_REQUEST['view_module'] , isset ( $_REQUEST [ 'view_package' ] ) ? $_REQUEST [ 'view_package' ] : null ) ;
262 $parser->handleSave ( $_REQUEST, $_REQUEST [ 'selected_lang' ] ) ;
263 if (isset ( $_REQUEST [ 'view_package' ] )) //MODULE BUILDER
265 $this->view = 'modulelabels' ;
268 $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)
272 function action_SaveLabel ()
274 if (! empty ( $_REQUEST [ 'view_module' ] ) && !empty($_REQUEST [ 'labelValue' ]))
276 $_REQUEST [ "label_" . $_REQUEST [ 'label' ] ] = $_REQUEST [ 'labelValue' ] ;
277 require_once 'modules/ModuleBuilder/parsers/parser.label.php' ;
278 $parser = new ParserLabel ( $_REQUEST['view_module'] , isset ( $_REQUEST [ 'view_package' ] ) ? $_REQUEST [ 'view_package' ] : null ) ;
279 $parser->handleSave ( $_REQUEST, $GLOBALS [ 'current_language' ] ) ;
282 $this->view = 'modulefields' ;
285 function action_ExportCustom ()
287 $modules = $_REQUEST [ 'modules' ] ;
288 $name = $_REQUEST [ 'name' ] ;
289 $author = $_REQUEST [ 'author' ] ;
290 $description = $_REQUEST [ 'description' ] ;
292 if (! empty ( $modules ) && ! empty ( $name ))
294 require_once ('modules/ModuleBuilder/MB/ModuleBuilder.php') ;
295 $mb = new MBPackage ( $name ) ;
296 $mb->author = $author ;
297 $mb->description = $description ;
298 $mb->exportCustom ( $modules, true, true ) ;
302 function action_SaveField ()
304 require_once ('modules/DynamicFields/FieldCases.php') ;
305 $field = get_widget ( $_REQUEST [ 'type' ] ) ;
306 $_REQUEST [ 'name' ] = trim ( $_POST [ 'name' ] ) ;
308 $field->populateFromPost () ;
310 if (!isset ( $_REQUEST [ 'view_package' ] ))
312 require_once ('modules/DynamicFields/DynamicField.php') ;
313 if (! empty ( $_REQUEST [ 'view_module' ] ))
315 $module = $_REQUEST [ 'view_module' ] ;
316 $df = new DynamicField ( $module ) ;
317 $class_name = $GLOBALS [ 'beanList' ] [ $module ] ;
318 require_once ($GLOBALS [ 'beanFiles' ] [ $class_name ]) ;
319 $mod = new $class_name ( ) ;
320 $df->setup ( $mod ) ;
322 $field->save ( $df ) ;
323 $this->action_SaveLabel () ;
324 include_once ('modules/Administration/QuickRepairAndRebuild.php') ;
326 $mod_strings['LBL_ALL_MODULES'] = 'all_modules';
327 $repair = new RepairAndClear();
328 $repair->repairAndClearAll(array('rebuildExtensions', 'clearVardefs', 'clearTpls'), array($class_name), true, false);
329 //#28707 ,clear all the js files in cache
330 $repair->module_list = array();
331 $repair->clearJsFiles();
335 $mb = new ModuleBuilder ( ) ;
336 $module = & $mb->getPackageModule ( $_REQUEST [ 'view_package' ], $_REQUEST [ 'view_module' ] ) ;
337 $field->save ( $module ) ;
338 $module->mbvardefs->save () ;
339 // get the module again to refresh the labels we might have saved with the $field->save (e.g., for address fields)
340 $module = & $mb->getPackageModule ( $_REQUEST [ 'view_package' ], $_REQUEST [ 'view_module' ] ) ;
341 if (isset ( $_REQUEST [ 'label' ] ) && isset ( $_REQUEST [ 'labelValue' ] ))
342 $module->setLabel ( $GLOBALS [ 'current_language' ], $_REQUEST [ 'label' ], $_REQUEST [ 'labelValue' ] ) ;
345 $this->view = 'modulefields' ;
348 function action_saveSugarField ()
351 require_once ('modules/DynamicFields/FieldCases.php') ;
352 $field = get_widget ( $_REQUEST [ 'type' ] ) ;
353 $_REQUEST [ 'name' ] = trim ( $_POST [ 'name' ] ) ;
355 $field->populateFromPost () ;
356 require_once ('modules/ModuleBuilder/parsers/StandardField.php') ;
357 $module = $_REQUEST [ 'view_module' ] ;
358 $df = new StandardField ( $module ) ;
359 $class_name = $GLOBALS [ 'beanList' ] [ $module ] ;
360 require_once ($GLOBALS [ 'beanFiles' ] [ $class_name ]) ;
361 $mod = new $class_name ( ) ;
362 $df->setup ( $mod ) ;
364 $field->module = $mod;
365 $field->save ( $df ) ;
366 $this->action_SaveLabel () ;
368 $MBmodStrings = $mod_strings;
369 $GLOBALS [ 'mod_strings' ] = return_module_language ( '', 'Administration' ) ;
371 include_once ('modules/Administration/QuickRepairAndRebuild.php') ;
372 $GLOBALS [ 'mod_strings' ]['LBL_ALL_MODULES'] = 'all_modules';
373 $_REQUEST['execute_sql'] = true;
375 $repair = new RepairAndClear();
376 $repair->repairAndClearAll(array('rebuildExtensions', 'clearVardefs', 'clearTpls'), array($class_name), true, false);
377 //#28707 ,clear all the js files in cache
378 $repair->module_list = array();
379 $repair->clearJsFiles();
382 // now clear the cache so that the results are immediately visible
383 include_once ('include/TemplateHandler/TemplateHandler.php') ;
384 TemplateHandler::clearCache ( $module ) ;
386 $GLOBALS [ 'mod_strings' ] = $MBmodStrings;
389 function action_RefreshField ()
391 require_once ('modules/DynamicFields/FieldCases.php') ;
392 $field = get_widget ( $_POST [ 'type' ] ) ;
393 $field->populateFromPost () ;
394 $this->view = 'modulefield' ;
397 function action_saveVisibility ()
399 $packageName = (isset ( $_REQUEST [ 'view_package' ] ) && (strtolower($_REQUEST['view_package']) != 'studio')) ? $_REQUEST [ 'view_package' ] : null ;
400 require_once 'modules/ModuleBuilder/parsers/ParserFactory.php' ;
401 $parser = ParserFactory::getParser ( MB_VISIBILITY, $_REQUEST [ 'view_module' ], $packageName ) ;
403 $json = getJSONobj();
404 $visibility_grid = $json->decode(html_entity_decode(rawurldecode($_REQUEST [ 'visibility_grid' ]), ENT_QUOTES) );
405 $parser->saveVisibility ( $_REQUEST [ 'fieldname' ] , $_REQUEST [ 'trigger' ] , $visibility_grid ) ;
407 echo $json->encode(array( "visibility_editor_{$_REQUEST['fieldname']}" => array("action" => "deactivate")));
410 function action_SaveRelationshipLabel (){
411 $selected_lang = (!empty($_REQUEST['relationship_lang'])?$_REQUEST['relationship_lang']:$_SESSION['authenticated_user_language']);
412 if (empty($_REQUEST [ 'view_package' ])){
413 require_once 'modules/ModuleBuilder/parsers/relationships/DeployedRelationships.php' ;
414 $relationships = new DeployedRelationships ( $_REQUEST [ 'view_module' ] ) ;
415 if (! empty ( $_REQUEST [ 'relationship_name' ] ))
417 if ($relationship = $relationships->get ( $_REQUEST [ 'relationship_name' ] )){
418 $metadata = $relationship->buildLabels(true);
419 require_once 'modules/ModuleBuilder/parsers/parser.label.php' ;
420 $parser = new ParserLabel ( $_REQUEST['view_module'] ) ;
421 $parser->handleSaveRelationshipLabels ( $metadata, $selected_lang ) ;
428 $this->view = 'relationships' ;
431 function action_SaveRelationship ()
433 if(!empty($GLOBALS['current_user']) && empty($GLOBALS['modListHeader']))
435 $GLOBALS['modListHeader'] = query_module_access_list($GLOBALS['current_user']);
438 if (empty($_REQUEST [ 'view_package' ]))
440 require_once 'modules/ModuleBuilder/parsers/relationships/DeployedRelationships.php' ;
441 $relationships = new DeployedRelationships ( $_REQUEST [ 'view_module' ] ) ;
444 $mb = new ModuleBuilder ( ) ;
445 $module = & $mb->getPackageModule ( $_REQUEST [ 'view_package' ], $_REQUEST [ 'view_module' ] ) ;
446 require_once 'modules/ModuleBuilder/parsers/relationships/UndeployedRelationships.php' ;
447 $relationships = new UndeployedRelationships ( $module->getModuleDir () ) ;
450 $relationships->addFromPost () ;
451 $relationships->save () ;
452 $GLOBALS['log']->debug("\n\nSTART BUILD");
453 if (empty($_REQUEST [ 'view_package' ])) {
454 $relationships->build () ;
456 LanguageManager::clearLanguageCache($_REQUEST [ 'view_module' ]);
458 $GLOBALS['log']->debug("\n\nEND BUILD");
460 $this->view = 'relationships' ;
463 function action_DeleteRelationship ()
465 if (isset ( $_REQUEST [ 'relationship_name' ] ))
467 if (empty($_REQUEST [ 'view_package' ] ))
469 require_once 'modules/ModuleBuilder/parsers/relationships/DeployedRelationships.php' ;
470 if (!empty($_REQUEST['remove_tables']))
471 $GLOBALS['mi_remove_tables'] = $_REQUEST['remove_tables'];
472 $relationships = new DeployedRelationships ( $_REQUEST [ 'view_module' ] ) ;
475 $mb = new ModuleBuilder ( ) ;
476 $module = & $mb->getPackageModule ( $_REQUEST [ 'view_package' ], $_REQUEST [ 'view_module' ] ) ;
477 require_once 'modules/ModuleBuilder/parsers/relationships/UndeployedRelationships.php' ;
478 $relationships = new UndeployedRelationships ( $module->getModuleDir () ) ;
480 $relationships->delete ( $_REQUEST [ 'relationship_name' ] ) ;
481 $relationships->save () ;
483 $this->view = 'relationships' ;
486 function action_SaveDropDown ()
488 require_once 'modules/ModuleBuilder/parsers/parser.dropdown.php' ;
489 $parser = new ParserDropDown ( ) ;
490 $parser->saveDropDown ( $_REQUEST ) ;
491 $this->view = 'dropdowns' ;
494 function action_DeleteField ()
496 require_once ('modules/DynamicFields/FieldCases.php') ;
497 $field = get_widget ( $_POST [ 'type' ] ) ;
498 $field->name = $_REQUEST [ 'name' ] ;
499 if (!isset ( $_REQUEST [ 'view_package' ] ))
501 if (! empty ( $_REQUEST [ 'name' ] ) && ! empty ( $_REQUEST [ 'view_module' ] ))
503 require_once ('modules/DynamicFields/DynamicField.php') ;
504 $moduleName = $_REQUEST [ 'view_module' ] ;
505 $class_name = $GLOBALS [ 'beanList' ] [ $moduleName ] ;
506 require_once ($GLOBALS [ 'beanFiles' ] [ $class_name ]) ;
507 $seed = new $class_name ( ) ;
508 $df = new DynamicField ( $moduleName ) ;
509 $df->setup ( $seed ) ;
510 //Need to load the entire field_meta_data for some field types
511 $field = $df->getFieldWidget($moduleName, $field->name);
512 $field->delete ( $df ) ;
514 $GLOBALS [ 'mod_strings' ]['LBL_ALL_MODULES'] = 'all_modules';
515 $_REQUEST['execute_sql'] = true;
516 include_once ('modules/Administration/QuickRepairAndRebuild.php') ;
517 $repair = new RepairAndClear();
518 $repair->repairAndClearAll(array('rebuildExtensions', 'clearVardefs', 'clearTpls'), array($class_name), true, false);
519 require_once 'modules/ModuleBuilder/Module/StudioModuleFactory.php' ;
520 $module = StudioModuleFactory::getStudioModule( $moduleName ) ;
525 $mb = new ModuleBuilder ( ) ;
526 $module = & $mb->getPackageModule ( $_REQUEST [ 'view_package' ], $_REQUEST [ 'view_module' ] ) ;
527 $field->delete ( $module ) ;
530 $module->removeFieldFromLayouts( $field->name );
531 $this->view = 'modulefields' ;
534 function action_CloneField ()
536 $this->view_object_map [ 'field_name' ] = $_REQUEST [ 'name' ] ;
537 $this->view_object_map [ 'is_clone' ] = true ;
538 $this->view = 'modulefield' ;
541 function action_SaveAssistantPref ()
543 global $current_user ;
544 if (isset ( $_REQUEST [ 'pref_value' ] ))
546 if ($_REQUEST [ 'pref_value' ] == 'ignore')
548 $current_user->setPreference ( 'mb_assist', 'DISABLED', 0, 'Assistant' ) ;
551 $current_user->setPreference ( 'mb_assist', 'ENABLED', 0, 'Assistant' ) ;
553 $current_pref = $current_user->getPreference ( 'mb_assist', 'Assistant' ) ;
554 echo "Assistant.processUserPref('$current_pref')" ;
555 sugar_cleanup ( true ) ; //push preferences to DB.
562 function action_EditProperty ()
564 $this->view = 'property' ;
567 function action_saveProperty ()
569 require_once 'modules/ModuleBuilder/parsers/parser.label.php' ;
570 $modules = $_REQUEST['view_module'];
571 if(!empty($_REQUEST['subpanel'])){
572 $modules = $_REQUEST['subpanel'];
574 $parser = new ParserLabel ( $modules , isset ( $_REQUEST [ 'view_package' ] ) ? $_REQUEST [ 'view_package' ] : null ) ;
575 // if no language provided, then use the user's current language which is most likely what they intended
576 $language = (isset($_REQUEST [ 'selected_lang' ])) ? $_REQUEST [ 'selected_lang' ] : $GLOBALS['current_language'] ;
577 $parser->handleSave ( $_REQUEST, $language ) ;
578 $json = getJSONobj();
579 echo $json->encode(array("east" => array("action" => "deactivate")));
582 function action_editModule ()
584 $this->view = 'module' ;
587 function action_wizard ()
589 $this->view = 'wizard' ;
593 * Receive a layout through $_REQUEST and save it out to the working files directory
594 * Expects a series of $_REQUEST parameters all in the format $_REQUEST['slot-panel#-slot#-property']=value
597 function action_saveLayout ()
599 $parser = ParserFactory::getParser ( $_REQUEST [ 'view' ], $_REQUEST [ 'view_module' ], isset ( $_REQUEST [ 'view_package' ] ) ? $_REQUEST [ 'view_package' ] : null ) ;
600 $this->view = 'layoutview' ;
601 $parser->writeWorkingFile () ;
604 function action_saveAndPublishLayout ()
606 $parser = ParserFactory::getParser ( $_REQUEST [ 'view' ], $_REQUEST [ 'view_module' ], isset ( $_REQUEST [ 'view_package' ] ) ? $_REQUEST [ 'view_package' ] : null ) ;
607 $this->view = 'layoutview' ;
608 $parser->handleSave () ;
611 function action_manageBackups ()
616 function action_listViewSave ()
618 $GLOBALS [ 'log' ]->info ( "action_listViewSave" ) ;
620 $packageName = (isset ( $_REQUEST [ 'view_package' ] ) && (strtolower($_REQUEST['view_package']) != 'studio')) ? $_REQUEST [ 'view_package' ] : null ;
621 $subpanelName = (! empty ( $_REQUEST [ 'subpanel' ] )) ? $_REQUEST [ 'subpanel' ] : null ;
622 require_once 'modules/ModuleBuilder/parsers/ParserFactory.php' ;
623 $parser = ParserFactory::getParser ( $_REQUEST [ 'view' ], $_REQUEST [ 'view_module' ], $packageName, $subpanelName ) ;
624 $this->view = 'listView' ;
625 $parser->handleSave () ;
629 function action_dashletSave () {
630 $this->view = 'dashlet' ;
631 $packageName = (isset ( $_REQUEST [ 'view_package' ] ) && (strtolower($_REQUEST['view_package']) != 'studio')) ? $_REQUEST [ 'view_package' ] : null ;
632 require_once 'modules/ModuleBuilder/parsers/ParserFactory.php' ;
633 $parser = ParserFactory::getParser ( $_REQUEST [ 'view' ], $_REQUEST [ 'view_module' ], $packageName ) ;
634 $parser->handleSave () ;
637 function action_popupSave(){
638 $this->view = 'popupview' ;
639 $packageName = (isset ( $_REQUEST [ 'view_package' ] ) && (strtolower($_REQUEST['view_package']) != 'studio')) ? $_REQUEST [ 'view_package' ] : null ;
640 require_once 'modules/ModuleBuilder/parsers/ParserFactory.php' ;
641 $parser = ParserFactory::getParser ( $_REQUEST [ 'view' ], $_REQUEST [ 'view_module' ], $packageName ) ;
642 $parser->handleSave () ;
643 if(empty($packageName)){
644 include_once ('modules/Administration/QuickRepairAndRebuild.php') ;
646 $mod_strings['LBL_ALL_MODULES'] = 'all_modules';
647 $repair = new RepairAndClear();
648 $repair->show_output = false;
649 $class_name = $GLOBALS [ 'beanList' ] [ $_REQUEST [ 'view_module' ] ] ;
650 $repair->module_list = array($class_name);
651 $repair->clearTpls();
656 function action_searchViewSave ()
658 $packageName = (isset ( $_REQUEST [ 'view_package' ] )) ? $_REQUEST [ 'view_package' ] : null ;
659 require_once 'modules/ModuleBuilder/parsers/views/SearchViewMetaDataParser.php' ;
660 $parser = new SearchViewMetaDataParser ( $_REQUEST [ 'view' ], $_REQUEST [ 'view_module' ], $packageName ) ;
661 $parser->handleSave () ;
662 $this->view = 'searchView' ;
665 function action_editLabels ()
667 if (isset ( $_REQUEST [ 'view_package' ] )) //MODULE BUILDER
669 $this->view = 'modulelabels';
671 $this->view = 'labels';
675 function action_get_app_list_string ()
677 require_once ('include/JSON.php') ;
678 $json = new JSON ( ) ;
679 if (isset ( $_REQUEST [ 'key' ] ) && ! empty ( $_REQUEST [ 'key' ] ))
681 $key = $_REQUEST [ 'key' ] ;
683 if (! empty ( $GLOBALS [ 'app_list_strings' ] [ $key ] ))
685 $value = $GLOBALS [ 'app_list_strings' ] [ $key ] ;
688 $package_strings = array ( ) ;
689 if (! empty ( $_REQUEST [ 'view_package' ] ) && $_REQUEST [ 'view_package' ] != 'studio' && ! empty ( $_REQUEST [ 'view_module' ] ))
691 require_once ('modules/ModuleBuilder/MB/ModuleBuilder.php') ;
692 $mb = new ModuleBuilder ( ) ;
693 $module = & $mb->getPackageModule ( $_REQUEST [ 'view_package' ], $_REQUEST [ 'view_module' ] ) ;
694 $lang = $GLOBALS [ 'current_language' ] ;
695 $module->mblanguage->generateAppStrings ( false ) ;
696 $package_strings = $module->mblanguage->appListStrings [ $lang . '.lang.php' ] ;
697 if (isset ( $package_strings [ $key ] ) && is_array ( $package_strings [ $key ] ))
699 $value = $package_strings [ $key ] ;
703 echo $json->encode ( $value ) ;
707 function action_history ()
709 $this->view = 'history' ;
712 function resetmodule()
714 $this->view = 'resetmodule';