Skip to content
This repository
Browse code

Release 6.3.0

  • Loading branch information...
commit 17402a817f45fdcc6d3152eca7e8e3e680de428a 1 parent 47ac7b4
John Mertic jmertic authored

Showing 659 changed files with 20,603 additions and 10,080 deletions. Show diff stats Hide diff stats

  1. +492 610 ModuleInstall/ModuleInstaller.php
  2. +97 78 ModuleInstall/ModuleScanner.php
  3. +2 2 ModuleInstall/PackageManager/tpls/ModuleLoaderListView.tpl
  4. +63 0 ModuleInstall/extensions.php
  5. +139 0 Zend/Gdata/Contacts.php
  6. +125 0 Zend/Gdata/Contacts/Extension/Address.php
  7. +91 0 Zend/Gdata/Contacts/Extension/Birthday.php
  8. +119 0 Zend/Gdata/Contacts/Extension/Email.php
  9. +91 0 Zend/Gdata/Contacts/Extension/Name.php
  10. +104 0 Zend/Gdata/Contacts/Extension/Organization.php
  11. +112 0 Zend/Gdata/Contacts/Extension/PhoneNumber.php
  12. +259 0 Zend/Gdata/Contacts/ListEntry.php
  13. +71 0 Zend/Gdata/Contacts/ListFeed.php
  14. +1 1  Zend/Oauth/Config.php
  15. +354 0 Zend/Oauth/Provider.php
  16. +193 0 data/BeanFactory.php
  17. +30 13 data/Link.php
  18. +615 0 data/Link2.php
  19. +114 0 data/Relationships/EmailAddressRelationship.php
  20. +530 0 data/Relationships/M2MRelationship.php
  21. +310 0 data/Relationships/One2MBeanRelationship.php
  22. +176 0 data/Relationships/One2MRelationship.php
  23. +111 0 data/Relationships/One2OneBeanRelationship.php
  24. +75 0 data/Relationships/One2OneRelationship.php
  25. +206 0 data/Relationships/RelationshipFactory.php
  26. +446 0 data/Relationships/SugarRelationship.php
  27. +278 239 data/SugarBean.php
  28. +7 11 download.php
  29. +16 1 export.php
  30. +577 481 files.md5
  31. +5 0 include/Dashlets/Dashlet.php
  32. +2 0  include/Dashlets/DashletGeneric.php
  33. +1 1  include/Dashlets/DashletGenericAutoRefresh.tpl
  34. +1 1  include/Dashlets/DashletGenericAutoRefreshDynamic.tpl
  35. +2 0  include/Dashlets/DashletGenericChart.php
  36. +4 1 include/Dashlets/DashletGenericChartConfigure.tpl
  37. +3 0  include/Dashlets/DashletGenericConfigure.tpl
  38. +6 5 include/Dashlets/DashletGenericDisplay.tpl
  39. +1 1  include/DetailView/DetailView.php
  40. +1 1  include/DetailView/DetailView.tpl
  41. +2 2 include/EditView/EditView.tpl
  42. +71 39 include/EditView/EditView2.php
  43. +12 3 include/EditView/SubpanelQuickCreate.php
  44. +143 0 include/EditView/SubpanelQuickEdit.php
  45. +3 3 include/EditView/SugarVCR.php
  46. +1 1  include/EditView/header.tpl
  47. +67 38 include/ListView/ListView.php
  48. +2 2 include/ListView/ListViewDCMenu.tpl
  49. +15 17 include/ListView/ListViewDisplay.php
  50. +9 3 include/ListView/ListViewFacade.php
  51. +42 8 include/ListView/ListViewGeneric.tpl
  52. +2 2 include/ListView/ListViewNoMassUpdate.tpl
  53. +1 2  include/ListView/ListViewSmarty.php
  54. +10 0 include/MVC/Controller/SugarController.php
  55. +4 0 include/MVC/Controller/action_view_map.php
  56. +22 8 include/MVC/SugarApplication.php
  57. +120 36 include/MVC/View/SugarView.php
  58. +63 0 include/MVC/View/views/view.ajaxui.php
  59. +33 14 include/MVC/View/views/view.config.php
  60. +5 2 include/MVC/View/views/view.detail.php
  61. +372 0 include/MVC/View/views/view.metadata.php
  62. +1 0  include/MVC/View/views/view.quickcreate.php
  63. +208 0 include/MVC/View/views/view.quickedit.php
  64. +1 1  include/MassUpdate.php
  65. +2 1  include/MySugar/DashletsDialog/DashletsDialog.php
  66. +4 4 include/MySugar/javascript/MySugar.js
  67. +63 56 include/MySugar/tpls/MySugar.tpl
  68. +4 4 include/MySugar/tpls/addDashletsDialog.tpl
  69. +3 0  include/OutboundEmail/OutboundEmail.php
  70. +21 0 include/Popups/PopupSmarty.php
  71. +4 4 include/Popups/tpls/PopupGeneric.tpl
  72. +3 3 include/SearchForm/SearchForm.php
  73. +7 2 include/SearchForm/SearchForm2.php
  74. +2 2 include/SearchForm/tpls/SearchFormGeneric.tpl
  75. +1 1  include/SearchForm/tpls/SearchFormGenericAdvanced.tpl
  76. +2 2 include/SearchForm/tpls/header.tpl
  77. +2 2 include/Smarty/plugins/function.overlib_includes.php
  78. +50 0 include/Smarty/plugins/function.sugar_ajax_url.php
  79. +21 13 include/Smarty/plugins/function.sugar_button.php
  80. +5 1 include/Smarty/plugins/function.sugar_field.php
  81. +2 2 include/Smarty/plugins/function.sugar_link.php
  82. +47 0 include/Smarty/plugins/modifier.lookup.php
  83. +66 0 include/Smarty/plugins/modifier.multienum_to_ac.php
  84. +4 2 include/SubPanel/SubPanel.php
  85. +1 1  include/SubPanel/SubPanelDynamic.html
  86. +16 10 include/SubPanel/SubPanelTiles.js
  87. +7 3 include/SubPanel/SubPanelTiles.php
  88. +7 0 include/SubPanel/SugarTab.php
  89. +1 1  include/SubPanel/tpls/singletabmenu.tpl
  90. +9 0 include/SugarCache/SugarCache.php
  91. +11 10 include/SugarCache/SugarCacheAPC.php
  92. +34 34 include/SugarCache/SugarCacheAbstract.php
  93. +17 15 include/SugarCache/SugarCacheFile.php
  94. +1 1  include/SugarCache/SugarCacheMemcache.php
  95. +4 4 include/SugarCache/SugarCacheMemcached.php
  96. +10 7 include/SugarCache/SugarCacheZend.php
  97. +2 2 include/SugarCharts/Jit/js/mySugarCharts.js
  98. +15 11 include/SugarCharts/Jit/tpls/DashletGenericChartScript.tpl
  99. +26 32 include/SugarCharts/Jit/tpls/chart.tpl
  100. +0 1  include/SugarCharts/JsChart.php
  101. +33 5 include/SugarDateTime.php
  102. +7 6 include/SugarEmailAddress/SugarEmailAddress.js
  103. +30 17 include/SugarEmailAddress/SugarEmailAddress.php
  104. +4 5 include/SugarFields/Fields/Address/EditView.tpl
  105. +6 8 include/SugarFields/Fields/Address/SugarFieldAddress.js
  106. +4 5 include/SugarFields/Fields/Address/en_us.EditView.tpl
  107. +82 2 include/SugarFields/Fields/Base/SugarFieldBase.php
  108. +8 6 include/SugarFields/Fields/Collection/CollectionEditView.tpl
  109. +1 1  include/SugarFields/Fields/Collection/CollectionEditViewRow.tpl
  110. +11 12 include/SugarFields/Fields/Collection/SugarFieldCollection.js
  111. +9 0 include/SugarFields/Fields/Collection/SugarFieldCollection.php
  112. +3 2 include/SugarFields/Fields/Collection/ViewSugarFieldCollection.php
  113. +310 9 include/SugarFields/Fields/Enum/EditView.tpl
  114. +2 3 include/SugarFields/Fields/File/EditView.tpl
  115. +9 0 include/SugarFields/Fields/File/SugarFieldFile.php
  116. +384 8 include/SugarFields/Fields/Multienum/EditView.tpl
  117. +5 1 include/SugarFields/Fields/Multienum/SugarFieldMultienum.php
  118. +26 31 include/SugarFields/Fields/Parent/EditView.tpl
  119. +41 16 include/SugarFields/Fields/Parent/SearchView.tpl
  120. +9 0 include/SugarFields/Fields/Parent/SugarFieldParent.php
  121. +2 0  include/SugarFields/Fields/Phone/SugarFieldPhone.php
  122. +3 1 include/SugarFields/Fields/Relate/DetailView.tpl
  123. +7 9 include/SugarFields/Fields/Relate/EditView.tpl
  124. +11 2 include/SugarFields/Fields/Relate/SugarFieldRelate.php
  125. +13 13 include/SugarLogger/SugarLogger.php
  126. +257 0 include/SugarOAuthServer.php
  127. +22 0 include/SugarObjects/LanguageManager.php
  128. +314 203 include/SugarObjects/VardefManager.php
  129. +1 1  include/SugarObjects/templates/basic/metadata/detailviewdefs.php
  130. +3 0  include/SugarObjects/templates/basic/vardefs.php
  131. +2 4 include/SugarObjects/templates/company/vardefs.php
  132. +1 2  include/SugarObjects/templates/file/metadata/editviewdefs.php
  133. +1 2  include/SugarObjects/templates/file/metadata/quickcreatedefs.php
  134. +1 1  include/SugarObjects/templates/person/vardefs.php
  135. +146 142 include/SugarTheme/SugarTheme.php
  136. +5 0 include/Sugar_Smarty.php
  137. +30 14 include/TimeDate.php
  138. +3 1 include/connectors/formatters/default/company_detail.js
  139. +0 1  include/connectors/sources/default/source.php
  140. +17 15 include/{SugarFields/Fields/Encrypt/SugarFieldEncrypt.php → connectors/sources/ext/eapm/eapm.php}
  141. +71 9 include/database/DBHelper.php
  142. +40 7 include/database/DBManager.php
  143. +15 13 include/database/DBManagerFactory.php
  144. +13 3 include/database/MssqlHelper.php
  145. +1 1  include/database/MssqlManager.php
  146. +10 0 include/database/MysqlHelper.php
  147. +11 0 include/database/SqlsrvHelper.php
  148. +3 0  include/database/SqlsrvManager.php
  149. +4 1 include/dir_inc.php
  150. +525 68 include/export_utils.php
  151. +1 0  include/externalAPI/Base/ExternalAPIBase.php
  152. +7 3 include/externalAPI/ExternalAPIFactory.php
  153. +39 19 include/formbase.php
  154. +1 0  include/generic/DeleteRelationship.php
  155. +1 0  include/generic/Save2.php
  156. +23 41 include/generic/SugarWidgets/SugarWidgetField.php
  157. +68 30 include/generic/SugarWidgets/SugarWidgetFieldcurrency.php
  158. +35 2 include/generic/SugarWidgets/SugarWidgetFieldenum.php
  159. +41 26 include/generic/SugarWidgets/SugarWidgetFieldname.php
  160. +196 231 include/generic/SugarWidgets/SugarWidgetReportField.php
  161. +78 0 include/generic/SugarWidgets/SugarWidgetSubPanelDeleteButton.php
  162. +16 22 include/generic/SugarWidgets/SugarWidgetSubPanelDetailViewLink.php
  163. +14 10 include/generic/SugarWidgets/SugarWidgetSubPanelEditButton.php
  164. +95 0 include/generic/SugarWidgets/SugarWidgetSubPanelRelFieldEditButton.php
  165. +27 27 include/generic/SugarWidgets/SugarWidgetSubPanelTopButton.php
  166. +4 2 include/generic/SugarWidgets/SugarWidgetSubPanelTopButtonQuickCreate.php
  167. +2 1  include/generic/SugarWidgets/SugarWidgetSubPanelTopCreateNoteButton.php
  168. +1 0  include/generic/SugarWidgets/SugarWidgetSubPanelTopCreateTaskButton.php
  169. +1 0  include/generic/SugarWidgets/SugarWidgetSubPanelTopScheduleCallButton.php
  170. +6 7 include/generic/SugarWidgets/SugarWidgetSubPanelTopScheduleMeetingButton.php
  171. +4 3 include/globalControlLinks.php
  172. BIN  include/images/configure.png
  173. BIN  include/images/create_users.png
  174. BIN  include/images/import.png
  175. BIN  include/images/poweredby_sugarcrm.png
  176. BIN  include/images/settings.png
  177. BIN  include/images/start.png
  178. BIN  include/images/university.png
  179. BIN  include/images/university2.png
  180. BIN  include/images/wiki.png
  181. +87 0 include/javascript/ajaxUI.js
  182. +3 2 include/javascript/calendar.js
  183. +42 0 include/javascript/importWizard.js
  184. +2 1  include/javascript/include.js
  185. +7 2 include/javascript/javascript.php
  186. +7 7 include/javascript/jsAlerts.php
  187. +2 1  include/javascript/jsclass_base.js
  188. +31 74 include/javascript/overlibmws.js
  189. +30 73 include/javascript/overlibmws_iframe.js
  190. +128 0 include/javascript/phpjs/get_html_translation_table.js
  191. +125 0 include/javascript/phpjs/html_entity_decode.js
  192. +123 0 include/javascript/phpjs/license.js
  193. +3 1 include/javascript/popup_helper.js
  194. +4 4 include/javascript/popup_parent_helper.js
  195. +7 7 include/javascript/quickCompose.js
  196. +9 7 include/javascript/quicksearch.js
  197. +63 36 include/javascript/sugar_3.js
  198. +1 1  include/javascript/sugar_connection_event_listener.js
  199. +544 45 include/javascript/sugar_grp1.js
  200. +8,549 6,743 include/javascript/sugar_grp1_yui.js
  201. +147 144 include/javascript/sugar_grp_emails.js
Sorry, we could not display the entire diff because too many files (659) changed.
1,102 ModuleInstall/ModuleInstaller.php
@@ -60,12 +60,14 @@ class ModuleInstaller{
60 60 var $silent = false;
61 61 var $base_dir = '';
62 62 var $modulesInPackage = array();
  63 + public $disabled_path = DISABLED_PATH;
63 64
64 65 function ModuleInstaller(){
65 66 $this->ms = new ModuleScanner();
66 67 $this->modules = get_module_dir_list();
67 68 $this->db = & DBManagerFactory::getInstance();
68   -
  69 + include("ModuleInstall/extensions.php");
  70 + $this->extensions = $extensions;
69 71 }
70 72
71 73 /*
@@ -87,6 +89,15 @@ function install($base_dir, $is_upgrade = false, $previous_version = ''){
87 89 }
88 90 }
89 91
  92 + // workaround for bug 45812 - refresh vardefs cache before unpacking to avoid partial vardefs in cache
  93 + global $beanList;
  94 + foreach ($this->modules as $module_name) {
  95 + if (!empty($beanList[$module_name])) {
  96 + $objectName = BeanFactory::getObjectName($module_name);
  97 + VardefManager::loadVardef($module_name, $objectName);
  98 + }
  99 + }
  100 +
90 101 global $app_strings, $mod_strings;
91 102 $this->base_dir = $base_dir;
92 103 $total_steps = 5; //minimum number of steps with no tasks
@@ -94,19 +105,14 @@ function install($base_dir, $is_upgrade = false, $previous_version = ''){
94 105 $tasks = array(
95 106 'pre_execute',
96 107 'install_copy',
  108 + 'install_extensions',
97 109 'install_images',
98   - 'install_menus',
99 110 'install_dcactions',
100   - 'install_userpage',
101 111 'install_dashlets',
102   - 'install_administration',
103 112 'install_connectors',
104   - 'install_vardefs',
105   - 'install_layoutdefs',
106 113 'install_layoutfields',
107 114 'install_relationships',
108   - 'install_languages',
109   - 'install_logichooks',
  115 + 'enable_manifest_logichooks',
110 116 'post_execute',
111 117 'reset_opcodes',
112 118 );
@@ -136,41 +142,6 @@ function install($base_dir, $is_upgrade = false, $previous_version = ''){
136 142 }//fi
137 143 $this->id_name = $installdefs['id'];
138 144 $this->installdefs = $installdefs;
139   - $installed_modules = array();
140   - $tab_modules = array();
141   - if(isset($installdefs['beans'])){
142   - $str = "<?php \n //WARNING: The contents of this file are auto-generated\n";
143   - foreach($installdefs['beans'] as $bean){
144   - if(!empty($bean['module']) && !empty($bean['class']) && !empty($bean['path'])){
145   - $module = $bean['module'];
146   - $class = $bean['class'];
147   - $path = $bean['path'];
148   -
149   - $str .= "\$beanList['$module'] = '$class';\n";
150   - $str .= "\$beanFiles['$class'] = '$path';\n";
151   - if($bean['tab']){
152   - $str .= "\$moduleList[] = '$module';\n";
153   - $this->install_user_prefs($module, empty($bean['hide_by_default']));
154   - $tab_modules[] = $module;
155   - }else{
156   - $str .= "\$modules_exempt_from_availability_check['$module'] = '$module';\n";
157   - $str .= "\$modInvisList[] = '$module';\n";
158   - }
159   - $installed_modules[] = $module;
160   - }else{
161   - $errors[] = 'Bean array not well defined.';
162   - $this->abort($errors);
163   - }
164   - }
165   - $str.= "\n?>";
166   - if(!file_exists("custom/Extension/application/Ext/Include")){
167   - mkdir_recursive("custom/Extension/application/Ext/Include", true);
168   - }
169   - $out = sugar_fopen("custom/Extension/application/Ext/Include/$this->id_name.php", 'w');
170   - fwrite($out,$str);
171   - fclose($out);
172   - $this->rebuild_modules();
173   - }
174 145 if(!$this->silent){
175 146 $current_step++;
176 147 update_progress_bar('install', $current_step, $total_steps);
@@ -183,7 +154,7 @@ function install($base_dir, $is_upgrade = false, $previous_version = ''){
183 154 update_progress_bar('install', $current_step, $total_steps);
184 155 }
185 156 }
186   - $this->install_beans($installed_modules);
  157 + $this->install_beans($this->installed_modules);
187 158 if(!$this->silent){
188 159 $current_step++;
189 160 update_progress_bar('install', $total_steps, $total_steps);
@@ -218,18 +189,23 @@ function install($base_dir, $is_upgrade = false, $previous_version = ''){
218 189 include('custom/application/Ext/Include/modules.ext.php');
219 190 }
220 191 require_once("modules/Administration/upgrade_custom_relationships.php");
221   - upgrade_custom_relationships($installed_modules);
  192 + upgrade_custom_relationships($this->installed_modules);
222 193 $this->rebuild_all(true);
223 194 require_once('modules/Administration/QuickRepairAndRebuild.php');
224 195 $rac = new RepairAndClear();
225   - $rac->repairAndClearAll($selectedActions, $installed_modules,true, false);
  196 + $rac->repairAndClearAll($selectedActions, $this->installed_modules,true, false);
226 197 $this->rebuild_relationships();
227   - UpdateSystemTabs('Add',$tab_modules);
228   -
229   - //clear the unified_search_module.php file
  198 + UpdateSystemTabs('Add',$this->tab_modules);
  199 + //Clear out all the langauge cache files.
  200 + clearAllJsAndJsLangFilesWithoutOutput();
  201 + $cache_key = 'app_list_strings.'.$GLOBALS['current_language'];
  202 + sugar_cache_clear($cache_key );
  203 + sugar_cache_reset();
  204 +
  205 + //clear the unified_search_module.php file
230 206 require_once('modules/Home/UnifiedSearchAdvanced.php');
231   - UnifiedSearchAdvanced::unlinkUnifiedSearchModulesFile();
232   -
  207 + UnifiedSearchAdvanced::unlinkUnifiedSearchModulesFile();
  208 +
233 209 $this->log('<br><b>' . translate('LBL_MI_COMPLETE') . '</b>');
234 210 }else{
235 211 die("No \$installdefs Defined In $this->base_dir/manifest.php");
@@ -357,8 +333,290 @@ function uninstall_new_files($cp, $backup_path){
357 333
358 334 }
359 335
  336 + /**
  337 + * Get directory where module's extensions go
  338 + * @param string $module Module name
  339 + */
  340 + public function getExtDir($module)
  341 + {
  342 + if($module == 'application') {
  343 + return "custom/Extension/application/Ext";
  344 + } else {
  345 + return "custom/Extension/modules/$module/Ext";
  346 + }
  347 + }
  348 +
  349 + /**
  350 + * Install file(s) into Ext/ part
  351 + * @param string $section Name of the install file section
  352 + * @param string $extname Name in Ext directory
  353 + * @param string $module This extension belongs to a specific module
  354 + */
  355 + public function installExt($section, $extname, $module = '')
  356 + {
  357 + if(isset($this->installdefs[$section])){
  358 + $this->log(sprintf(translate("LBL_MI_IN_EXT"), $section));
  359 + foreach($this->installdefs[$section] as $item){
  360 + if(isset($item['from'])) {
  361 + $from = str_replace('<basepath>', $this->base_dir, $item['from']);
  362 + } else {
  363 + $from = '';
  364 + }
  365 + if(!empty($module)) {
  366 + $item['to_module'] = $module;
  367 + }
  368 + $GLOBALS['log']->debug("Installing section $section from $from for " .$item['to_module'] );
  369 + if($item['to_module'] == 'application') {
  370 + $path = "custom/Extension/application/Ext/$extname";
  371 + } else {
  372 + $path = "custom/Extension/modules/{$item['to_module']}/Ext/$extname";
  373 + }
  374 + if(!file_exists($path)){
  375 + mkdir_recursive($path, true);
  376 + }
  377 + if(isset($item["name"])) {
  378 + $target = $item["name"];
  379 + } else if (!empty($from)){
  380 + $target = basename($from, ".php");
  381 + } else {
  382 + $target = $this->id_name;
  383 + }
  384 + if(!empty($from)) {
  385 + copy_recursive($from , "$path/$target.php");
  386 + }
  387 + }
  388 + }
  389 + }
  390 +
  391 + /**
  392 + * Uninstall file(s) into Ext/ part
  393 + * @param string $section Name of the install file section
  394 + * @param string $extname Name in Ext directory
  395 + * @param string $module This extension belongs to a specific module
  396 + */
  397 + public function uninstallExt($section, $extname, $module = '')
  398 + {
  399 + if(isset($this->installdefs[$section])){
  400 + $this->log(sprintf(translate("LBL_MI_UN_EXT"), $section));
  401 + foreach($this->installdefs[$section] as $item){
  402 + if(isset($item['from'])) {
  403 + $from = str_replace('<basepath>', $this->base_dir, $item['from']);
  404 + } else {
  405 + $from = '';
  406 + }
  407 + if(!empty($module)) {
  408 + $item['to_module'] = $module;
  409 + }
  410 + $GLOBALS['log']->debug("Uninstalling section $section from $from for " .$item['to_module'] );
  411 + if($item['to_module'] == 'application') {
  412 + $path = "custom/Extension/application/Ext/$extname";
  413 + } else {
  414 + $path = "custom/Extension/modules/{$item['to_module']}/Ext/$extname";
  415 + }
  416 + if(isset($item["name"])) {
  417 + $target = $item["name"];
  418 + } else if (!empty($from)){
  419 + $target = basename($from, ".php");
  420 + } else {
  421 + $target = $this->id_name;
  422 + }
  423 + $disabled_path = $path.'/'.DISABLED_PATH;
  424 + if (file_exists("$path/$target.php")) {
  425 + rmdir_recursive("$path/$target.php");
  426 + } else if (file_exists("$disabled_path/$target.php")) {
  427 + rmdir_recursive("$disabled_path/$target.php");
  428 + } else if (!empty($from) && file_exists($path . '/'. basename($from))) {
  429 + rmdir_recursive( $path . '/'. basename($from));
  430 + } else if (!empty($from) && file_exists($disabled_path . '/'. basename($from))) {
  431 + rmdir_recursive( $disabled_path . '/'. basename($from));
  432 + }
  433 + }
  434 + }
  435 + }
  436 +
  437 + /**
  438 + * Rebuild generic extension
  439 + * @param string $ext Extension directory
  440 + * @param string $filename Target filename
  441 + */
  442 + public function rebuildExt($ext, $filename)
  443 + {
  444 + $this->log(translate('LBL_MI_REBUILDING') . " $ext...");
  445 + $this->merge_files("Ext/$ext/", $filename);
  446 + }
  447 +
  448 + /**
  449 + * Disable generic extension
  450 + * @param string $section Install file section name
  451 + * @param string $extname Extension directory
  452 + * @param string $module This extension belongs to a specific module
  453 + */
  454 + public function disableExt($section, $extname, $module = '')
  455 + {
  456 + if(isset($this->installdefs[$section])) {
  457 + foreach($this->installdefs[$section] as $item) {
  458 + if(isset($item['from'])) {
  459 + $from = str_replace('<basepath>', $this->base_dir, $item['from']);
  460 + } else {
  461 + $from = '';
  462 + }
  463 + if(!empty($module)) {
  464 + $item['to_module'] = $module;
  465 + }
  466 + $GLOBALS['log']->debug("Disabling $extname ... from $from for " .$item['to_module']);
  467 + if($item['to_module'] == 'application') {
  468 + $path = "custom/Extension/application/Ext/$extname";
  469 + } else {
  470 + $path = "custom/Extension/modules/{$item['to_module']}/Ext/$extname";
  471 + }
  472 + if(isset($item["name"])) {
  473 + $target = $item["name"];
  474 + } else if (!empty($from)){
  475 + $target = basename($from, ".php");
  476 + }else {
  477 + $target = $this->id_name;
  478 + }
  479 + $disabled_path = $path.'/'.DISABLED_PATH;
  480 + if (file_exists("$path/$target.php")) {
  481 + mkdir_recursive($disabled_path, true);
  482 + rename("$path/$target.php", "$disabled_path/$target.php");
  483 + } else if (!empty($from) && file_exists($path . '/'. basename($from))) {
  484 + mkdir_recursive($disabled_path, true);
  485 + rename( $path . '/'. basename($from), $disabled_path.'/'. basename($from));
  486 + }
  487 + }
  488 + }
  489 + }
  490 +
  491 + /**
  492 + * Enable generic extension
  493 + * @param string $section Install file section name
  494 + * @param string $extname Extension directory
  495 + * @param string $module This extension belongs to a specific module
  496 + */
  497 + public function enableExt($section, $extname, $module = '')
  498 + {
  499 + if(isset($this->installdefs[$section])) {
  500 + foreach($this->installdefs[$section] as $item) {
  501 + if(isset($item['from'])) {
  502 + $from = str_replace('<basepath>', $this->base_dir, $item['from']);
  503 + } else {
  504 + $from = '';
  505 + }
  506 + if(!empty($module)) {
  507 + $item['to_module'] = $module;
  508 + }
  509 + $GLOBALS['log']->debug("Enabling $extname ... from $from for " .$item['to_module']);
  510 +
  511 + if($item['to_module'] == 'application') {
  512 + $path = "custom/Extension/application/Ext/$extname";
  513 + } else {
  514 + $path = "custom/Extension/modules/{$item['to_module']}/Ext/$extname";
  515 + }
  516 + if(isset($item["name"])) {
  517 + $target = $item["name"];
  518 + } else if (!empty($from)){
  519 + $target = basename($from, ".php");
  520 + } else {
  521 + $target = $this->id_name;
  522 + }
  523 + if(!file_exists($path)) {
  524 + mkdir_recursive($path, true);
  525 + }
  526 + $disabled_path = $path.'/'.DISABLED_PATH;
  527 + if (file_exists("$disabled_path/$target.php")) {
  528 + rename("$disabled_path/$target.php", "$path/$target.php");
  529 + }
  530 + if (!empty($from) && file_exists($disabled_path . '/'. basename($from))) {
  531 + rename($disabled_path.'/'. basename($from), $path . '/'. basename($from));
  532 + }
  533 + }
  534 + }
  535 + }
  536 +
  537 + public function install_extensions()
  538 + {
  539 + foreach($this->extensions as $extname => $ext) {
  540 + $install = "install_$extname";
  541 + if(method_exists($this, $install)) {
  542 + // non-standard function
  543 + $this->$install();
  544 + } else {
  545 + if(!empty($ext["section"])) {
  546 + $module = isset($ext['module'])?$ext['module']:'';
  547 + $this->installExt($ext["section"], $ext["extdir"], $module);
  548 + }
  549 + }
  550 + }
  551 + $this->rebuild_extensions();
  552 + }
  553 +
  554 + public function uninstall_extensions()
  555 + {
  556 + foreach($this->extensions as $extname => $ext) {
  557 + $func = "uninstall_$extname";
  558 + if(method_exists($this, $func)) {
  559 + // non-standard function
  560 + $this->$func();
  561 + } else {
  562 + if(!empty($ext["section"])) {
  563 + $module = isset($ext['module'])?$ext['module']:'';
  564 + $this->uninstallExt($ext["section"], $ext["extdir"], $module);
  565 + }
  566 + }
  567 + }
  568 + $this->rebuild_extensions();
  569 + }
  570 +
  571 + public function rebuild_extensions()
  572 + {
  573 + foreach($this->extensions as $extname => $ext) {
  574 + $func = "rebuild_$extname";
  575 + if(method_exists($this, $func)) {
  576 + // non-standard function
  577 + $this->$func();
  578 + } else {
  579 + $this->rebuildExt($ext["extdir"], $ext["file"]);
  580 + }
  581 + }
  582 + }
360 583
361   - function install_dashlets(){
  584 + public function disable_extensions()
  585 + {
  586 + foreach($this->extensions as $extname => $ext) {
  587 + $func = "disable_$extname";
  588 + if(method_exists($this, $func)) {
  589 + // non-standard install
  590 + $this->$func();
  591 + } else {
  592 + if(!empty($ext["section"])) {
  593 + $module = isset($ext['module'])?$ext['module']:'';
  594 + $this->disableExt($ext["section"], $ext["extdir"], $module);
  595 + }
  596 + }
  597 + }
  598 + $this->rebuild_extensions();
  599 + }
  600 +
  601 + public function enable_extensions()
  602 + {
  603 + foreach($this->extensions as $extname => $ext) {
  604 + $func = "enable_$extname";
  605 + if(method_exists($this, $func)) {
  606 + // non-standard install
  607 + $this->$func();
  608 + } else {
  609 + if(!empty($ext["section"])) {
  610 + $module = isset($ext['module'])?$ext['module']:'';
  611 + $this->enableExt($ext["section"], $ext["extdir"], $module);
  612 + }
  613 + }
  614 + }
  615 + $this->rebuild_extensions();
  616 + }
  617 +
  618 + function install_dashlets()
  619 + {
362 620 if(isset($this->installdefs['dashlets'])){
363 621 foreach($this->installdefs['dashlets'] as $cp){
364 622 $this->log(translate('LBL_MI_IN_DASHLETS') . $cp['name']);
@@ -397,49 +655,6 @@ function install_images(){
397 655 }
398 656 }
399 657
400   - function install_menus(){
401   - if(isset($this->installdefs['menu'])){
402   - $this->log(translate('LBL_MI_IN_MENUS'));
403   - foreach($this->installdefs['menu'] as $menu){
404   - $menu['from'] = str_replace('<basepath>', $this->base_dir, $menu['from']);
405   - $GLOBALS['log']->debug("Installing Menu ..." . $menu['from']. " for " .$menu['to_module'] );
406   - $path = 'custom/Extension/modules/' . $menu['to_module']. '/Ext/Menus';
407   - if($menu['to_module'] == 'application'){
408   - $path ='custom/Extension/' . $menu['to_module']. '/Ext/Menus';
409   - }
410   - if(!file_exists($path)){
411   - mkdir_recursive($path, true);
412   -
413   - }
414   - copy_recursive($menu['from'] , $path . '/'. $this->id_name . '.php');
415   - }
416   - $this->rebuild_menus();
417   - }
418   - }
419   -
420   - function uninstall_menus(){
421   - if(isset($this->installdefs['menu'])){
422   - $this->log(translate('LBL_MI_UN_MENUS'));
423   - foreach($this->installdefs['menu'] as $menu){
424   - $menu['from'] = str_replace('<basepath>', $this->base_dir, $menu['from']);
425   - $GLOBALS['log']->debug("Uninstalling Menu ..." . $menu['from']. " for " .$menu['to_module'] );
426   - $path = 'custom/Extension/modules/' . $menu['to_module']. '/Ext/Menus';
427   - if($menu['to_module'] == 'application'){
428   - $path ='custom/Extension/' . $menu['to_module']. '/Ext/Menus';
429   - }
430   - if (sugar_is_file($path . '/'. $this->id_name . '.php', 'w'))
431   - {
432   - rmdir_recursive( $path . '/'. $this->id_name . '.php');
433   - }
434   - else if (sugar_is_file($path . '/'. DISABLED_PATH . '/'. $this->id_name . '.php', 'w'))
435   - {
436   - rmdir_recursive( $path . '/'. DISABLED_PATH . '/'. $this->id_name . '.php');
437   - }
438   - }
439   - $this->rebuild_menus();
440   - }
441   - }
442   -
443 658 function install_dcactions(){
444 659 if(isset($this->installdefs['dcaction'])){
445 660 $this->log(translate('LBL_MI_IN_MENUS'));
@@ -476,39 +691,6 @@ function uninstall_dcactions(){
476 691 }
477 692 }
478 693
479   - function install_administration(){
480   - if(isset($this->installdefs['administration'])){
481   - $this->log(translate('LBL_MI_IN_ADMIN'));
482   - foreach($this->installdefs['administration'] as $administration){
483   - $administration['from'] = str_replace('<basepath>', $this->base_dir, $administration['from']);
484   - $GLOBALS['log']->debug("Installing Administration Section ..." . $administration['from'] );
485   - $path = 'custom/Extension/modules/Administration/Ext/Administration';
486   - if(!file_exists($path)){
487   - mkdir_recursive($path, true);
488   -
489   - }
490   - copy_recursive($administration['from'] , $path . '/'. $this->id_name . '.php');
491   - }
492   - $this->rebuild_administration();
493   - }
494   -
495   - }
496   - function uninstall_administration(){
497   - if(isset($this->installdefs['administration'])){
498   - $this->log(translate('LBL_MI_UN_ADMIN'));
499   - foreach($this->installdefs['administration'] as $administration){
500   - $administration['from'] = str_replace('<basepath>', $this->base_dir, $administration['from']);
501   - $GLOBALS['log']->debug("Uninstalling Administration Section ..." . $administration['from'] );
502   - $path = 'custom/Extension/modules/Administration/Ext/Administration';
503   - if (sugar_is_file($path . '/'. $this->id_name . '.php', "w"))
504   - rmdir_recursive( $path . '/'. $this->id_name . '.php');
505   - else if (sugar_is_file($path . '/'. DISABLED_PATH . "/" . $this->id_name . '.php', "w"))
506   - rmdir_recursive( $path . '/'. DISABLED_PATH . "/" . $this->id_name . '.php');
507   - }
508   - $this->rebuild_administration();
509   - }
510   - }
511   -
512 694 function install_connectors(){
513 695 if(isset($this->installdefs['connectors'])){
514 696 foreach($this->installdefs['connectors'] as $cp){
@@ -554,82 +736,8 @@ function uninstall_connectors(){
554 736 }
555 737 }
556 738
557   - function install_userpage(){
558   - if(isset($this->installdefs['user_page'])){
559   - $this->log(translate('LBL_MI_IN_USER'));
560   - foreach($this->installdefs['user_page'] as $userpage){
561   - $userpage['from'] = str_replace('<basepath>', $this->base_dir, $userpage['from']);
562   - $GLOBALS['log']->debug("Installing User Page Section ..." . $userpage['from'] );
563   - $path = 'custom/Extension/modules/Users/Ext/UserPage';
564   - if(!file_exists($path)){
565   - mkdir_recursive($path, true);
566   -
567   - }
568   - copy_recursive($userpage['from'] , $path . '/'. $this->id_name . '.php');
569   - }
570   - $this->rebuild_userpage();
571   - }
572   -
573   - }
574   - function uninstall_userpage(){
575   - if(isset($this->installdefs['user_page'])){
576   - $this->log(translate('LBL_MI_UN_USER') );
577   - foreach($this->installdefs['user_page'] as $userpage){
578   - $userpage['from'] = str_replace('<basepath>', $this->base_dir, $userpage['from']);
579   - $GLOBALS['log']->debug("Uninstalling User Page Section ..." . $userpage['from'] );
580   - $path = 'custom/Extension/modules/Users/Ext/UserPage';
581   - rmdir_recursive( $path . '/'. $this->id_name . '.php');
582   - }
583   - $this->rebuild_userpage();
584   - }
585   - }
586   -
587   - /*
588   - * ModuleInstaller->install_vardefs uses the vardefs section of the installdefs and copies from the 'from' path (replacing <basepath> as usual) to either
589   - * custom/Extension/modules/<module>/Ext/Vardefs or custom/Extension/<module>/Ext/Vardefs if the 'to_module' value in the installdefs is set to 'application'.
590   - * Finally rebuild_vardefs() is used to merge /Ext/Vardefs into vardefs.ext.php
591   - */
592   - function install_vardefs(){
593   - if(isset($this->installdefs['vardefs'])){
594   - $this->log(translate('LBL_MI_IN_VAR') );
595   - foreach($this->installdefs['vardefs'] as $vardefs){
596   - $vardefs['from'] = str_replace('<basepath>', $this->base_dir, $vardefs['from']);
597   - $this->install_vardef($vardefs['from'], $vardefs['to_module'], $this->id_name);
598   - }
599   - $this->rebuild_vardefs();
600   - }
601   - }
602   - function uninstall_vardefs(){
603   - if(isset($this->installdefs['vardefs'])){
604   - $this->log(translate('LBL_MI_UN_VAR') );
605   - foreach($this->installdefs['vardefs'] as $vardefs){
606   - $vardefs['from'] = str_replace('<basepath>', $this->base_dir, $vardefs['from']);
607   - $GLOBALS['log']->debug("Uninstalling Vardefs ..." . $vardefs['from'] . " for " .$vardefs['to_module']);
608   - $path = 'custom/Extension/modules/' . $vardefs['to_module']. '/Ext/Vardefs';
609   - if($vardefs['to_module'] == 'application'){
610   - $path ='custom/Extension/' . $vardefs['to_module']. '/Ext/Vardefs';
611   - }
612   - if(file_exists($path . '/'. $this->id_name . '.php'))
613   - {
614   - rmdir_recursive( $path . '/'. $this->id_name . '.php');
615   - }
616   - else if(file_exists($path . '/'. DISABLED_PATH . '/'. $this->id_name . '.php'))
617   - {
618   - rmdir_recursive($path . '/'. DISABLED_PATH . '/'. $this->id_name . '.php');
619   - }
620   - else if (file_exists($path . '/'. basename($vardefs['from'] )))
621   - {
622   - rmdir_recursive( $path . '/'. basename($vardefs['from'] ));
623   - }
624   - else if(file_exists($path . '/'. DISABLED_PATH . '/'. basename($vardefs['from'])))
625   - {
626   - rmdir_recursive($path . '/'. DISABLED_PATH . '/'. basename($vardefs['from']));
627   - }
628   - }
629   - $this->rebuild_vardefs();
630   - }
631   - }
632   - function install_vardef($from, $to_module){
  739 + function install_vardef($from, $to_module)
  740 + {
633 741 $GLOBALS['log']->debug("Installing Vardefs ..." . $from . " for " .$to_module);
634 742 $path = 'custom/Extension/modules/' . $to_module. '/Ext/Vardefs';
635 743 if($to_module == 'application'){
@@ -641,50 +749,6 @@ function install_vardef($from, $to_module){
641 749 copy_recursive($from , $path.'/'. basename($from));
642 750 }
643 751
644   - /*
645   - * ModuleInstaller->install_layoutdefs installs the $layout_defs variable (subpanel definitions) from Ext/Layoutdefs to the to_module location of
646   - * custom/Extension/modules/' . $to_module. '/Ext/Layoutdefs/<$module>.php. before calling rebuild_layoutdefs which merge_files Ext/Layoutdefs/, 'layoutdefs.ext.php'. Note that this is not used for the viewdefs in the metadata directory - they are installed through the install_copy() operation that just takes the contents of the module directory and places it in the /modules area.
647   - */
648   - function install_layoutdefs(){
649   - if(isset($this->installdefs['layoutdefs'])){
650   - $this->log(translate('LBL_MI_IN_SUBPANEL') );
651   - foreach($this->installdefs['layoutdefs'] as $layoutdefs){
652   - $layoutdefs['from'] = str_replace('<basepath>', $this->base_dir, $layoutdefs['from']);
653   - $this->install_layoutdef($layoutdefs['from'], $layoutdefs['to_module'], $this->id_name);
654   - }
655   - $this->rebuild_layoutdefs();
656   - }
657   - }
658   - function uninstall_layoutdefs(){
659   - if(isset($this->installdefs['layoutdefs'])){
660   - $this->log(translate('LBL_MI_UN_SUBPANEL') );
661   - foreach($this->installdefs['layoutdefs'] as $layoutdefs){
662   - $layoutdefs['from'] = str_replace('<basepath>', $this->base_dir, $layoutdefs['from']);
663   - $GLOBALS['log']->debug("Uninstalling Layoutdefs ..." . $layoutdefs['from'] . " for " .$layoutdefs['to_module']);
664   - $path = 'custom/Extension/modules/' . $layoutdefs['to_module']. '/Ext/Layoutdefs';
665   - if($layoutdefs['to_module'] == 'application'){
666   - $path ='custom/Extension/' . $layoutdefs['to_module']. '/Ext/Layoutdefs';
667   - }
668   - if (file_exists($path . '/'. $this->id_name . '.php'))
669   - {
670   - rmdir_recursive( $path . '/'. $this->id_name . '.php');
671   - }
672   - else if (file_exists($path . '/'. DISABLED_PATH . '/' . $this->id_name . '.php'))
673   - {
674   - rmdir_recursive($path . '/'. DISABLED_PATH . '/' . $this->id_name . '.php');
675   - }
676   - else if (file_exists($path . '/'. basename($layoutdefs['from'] )))
677   - {
678   - rmdir_recursive( $path . '/'. basename($layoutdefs['from'] ));
679   - }
680   - else if(file_exists($path . '/'. DISABLED_PATH . '/'. basename($layoutdefs['from'])))
681   - {
682   - rmdir_recursive($path . '/'. DISABLED_PATH . '/'. basename($layoutdefs['from']));
683   - }
684   - }
685   - $this->rebuild_layoutdefs();
686   - }
687   - }
688 752 function install_layoutdef($from, $to_module){
689 753 $GLOBALS['log']->debug("Installing Layout Defs ..." . $from . " for " .$to_module);
690 754 $path = 'custom/Extension/modules/' . $to_module. '/Ext/Layoutdefs';
@@ -697,6 +761,7 @@ function install_layoutdef($from, $to_module){
697 761 copy_recursive($from , $path.'/'. basename($from));
698 762 }
699 763
  764 + // Non-standard - needs special rebuild call
700 765 function install_languages()
701 766 {
702 767 $languages = array();
@@ -724,6 +789,7 @@ function install_languages()
724 789 }
725 790 }
726 791
  792 + // Non-standard, needs special rebuild
727 793 function uninstall_languages(){
728 794 $languages = array();
729 795 if(isset($this->installdefs['language'])){
@@ -748,6 +814,81 @@ function uninstall_languages(){
748 814 }
749 815 }
750 816
  817 + // Non-standard, needs special rebuild
  818 + public function disable_languages()
  819 + {
  820 + if(isset($this->installdefs['language'])) {
  821 + $languages = $modules = array();
  822 + foreach($this->installdefs['language'] as $item) {
  823 + $from = str_replace('<basepath>', $this->base_dir, $item['from']);
  824 + $GLOBALS['log']->debug("Disabling Language {$item['language']}... from $from for " .$item['to_module']);
  825 + $modules[]=$item['to_module'];
  826 + $languages[$item['language']] = $item['language'];
  827 + if($item['to_module'] == 'application') {
  828 + $path = "custom/Extension/application/Ext/Language";
  829 + } else {
  830 + $path = "custom/Extension/modules/{$item['to_module']}/Ext/Language";
  831 + }
  832 + if(isset($item["name"])) {
  833 + $target = $item["name"];
  834 + } else {
  835 + $target = $this->id_name;
  836 + }
  837 + $target = "{$item['language']}.$target";
  838 +
  839 + $disabled_path = $path.'/'.DISABLED_PATH;
  840 + if (file_exists("$path/$target.php")) {
  841 + mkdir_recursive($disabled_path, true);
  842 + rename("$path/$target.php", "$disabled_path/$target.php");
  843 + } else if (file_exists($path . '/'. basename($from))) {
  844 + mkdir_recursive($disabled_path, true);
  845 + rename( $path . '/'. basename($from), $disabled_path.'/'. basename($from));
  846 + }
  847 + }
  848 + $this->rebuild_languages($languages, $modules);
  849 + }
  850 + }
  851 +
  852 + // Non-standard, needs special rebuild
  853 + public function enable_languages()
  854 + {
  855 + if(isset($this->installdefs['language'])) {
  856 + foreach($this->installdefs['language'] as $item) {
  857 + $from = str_replace('<basepath>', $this->base_dir, $item['from']);
  858 + $GLOBALS['log']->debug("Enabling Language {$item['language']}... from $from for " .$item['to_module']);
  859 + $modules[]=$item['to_module'];
  860 + $languages[$item['language']] = $item['language'];
  861 + if(!empty($module)) {
  862 + $item['to_module'] = $module;
  863 + }
  864 +
  865 + if($item['to_module'] == 'application') {
  866 + $path = "custom/Extension/application/Ext/Language";
  867 + } else {
  868 + $path = "custom/Extension/modules/{$item['to_module']}/Ext/Language";
  869 + }
  870 + if(isset($item["name"])) {
  871 + $target = $item["name"];
  872 + } else {
  873 + $target = $this->id_name;
  874 + }
  875 + $target = "{$item['language']}.$target";
  876 +
  877 + if(!file_exists($path)) {
  878 + mkdir_recursive($path, true);
  879 + }
  880 + $disabled_path = $path.'/'.DISABLED_PATH;
  881 + if (file_exists("$disabled_path/$target.php")) {
  882 + rename("$disabled_path/$target.php", "$path/$target.php");
  883 + }
  884 + if (file_exists($disabled_path . '/'. basename($from))) {
  885 + rename($disabled_path.'/'. basename($from), $path . '/'. basename($from));
  886 + }
  887 + }
  888 + $this->rebuild_languages($languages, $modules);
  889 + }
  890 + }
  891 +
751 892 // Functions for adding and removing logic hooks from uploaded files
752 893 // Since one class/file can be used by multiple logic hooks, I'm not going to touch the file labeled in the logic_hook entry
753 894 /* The module hook definition should look like this:
@@ -766,17 +907,7 @@ function uninstall_languages(){
766 907 ... blah blah ...
767 908 );
768 909 */
769   - function install_logichooks() {
770   - // Since the logic hook files get copied over with the rest of the module directory, we just need to enable them
771   - $this->enable_logichooks();
772   - }
773   -
774   - function uninstall_logichooks() {
775   - // Since the logic hook files get removed with the rest of the module directory, we just need to disable them
776   - $this->disable_logichooks();
777   - }
778   -
779   - function enable_logichooks() {
  910 + function enable_manifest_logichooks() {
780 911 if(empty($this->installdefs['logic_hooks']) || !is_array($this->installdefs['logic_hooks'])) {
781 912 return;
782 913 }
@@ -788,12 +919,11 @@ function enable_logichooks() {
788 919 }
789 920 }
790 921
791   - function disable_logichooks() {
  922 + function disable_manifest_logichooks() {
792 923 if(empty($this->installdefs['logic_hooks']) || !is_array($this->installdefs['logic_hooks'])) {
793 924 return;
794 925 }
795 926
796   -
797 927 foreach($this->installdefs['logic_hooks'] as $hook ) {
798 928 remove_logic_hook($hook['module'], $hook['hook'], array($hook['order'], $hook['description'], $hook['file'], $hook['class'], $hook['function']));
799 929 }
@@ -929,13 +1059,16 @@ function install_relationships ()
929 1059
930 1060
931 1061
  1062 +
  1063 + Relationship::delete_cache();
932 1064 $this->rebuild_vardefs () ;
933 1065 $this->rebuild_layoutdefs () ;
934 1066 if ($save_table_dictionary)
935 1067 {
936 1068 $this->rebuild_tabledictionary () ;
937 1069 }
938   -
  1070 + require_once("data/Relationships/RelationshipFactory.php");
  1071 + SugarRelationshipFactory::deleteCache();
939 1072 }
940 1073 }
941 1074
@@ -1087,7 +1220,9 @@ function uninstall_relationships($include_studio_relationships = false){
1087 1220 //Find all the relatioships/relate fields involving this module.
1088 1221 $rels_to_remove = array();
1089 1222 foreach($beanList as $mod => $bean) {
1090   - VardefManager::loadVardef($mod, $bean);
  1223 + //Some modules like cases have a bean name that doesn't match the object name
  1224 + $bean = BeanFactory::getObjectName($mod);
  1225 + VardefManager::loadVardef($mod, $bean);
1091 1226 //We can skip modules that are in this package as they will be removed anyhow
1092 1227 if (!in_array($mod, $this->modulesInPackage) && !empty($dictionary[$bean]) && !empty($dictionary[$bean]['fields']))
1093 1228 {
@@ -1178,16 +1313,11 @@ function uninstall($base_dir){
1178 1313 'uninstall_relationships',
1179 1314 'uninstall_copy',
1180 1315 'uninstall_dcactions',
1181   - 'uninstall_menus',
1182 1316 'uninstall_dashlets',
1183   - 'uninstall_userpage',
1184   - 'uninstall_administration',
1185 1317 'uninstall_connectors',
1186   - 'uninstall_vardefs',
1187   - 'uninstall_layoutdefs',
1188 1318 'uninstall_layoutfields',
1189   - 'uninstall_languages',
1190   - 'uninstall_logichooks',
  1319 + 'uninstall_extensions',
  1320 + 'disable_manifest_logichooks',
1191 1321 'post_uninstall',
1192 1322 );
1193 1323 $total_steps += count($tasks); //now the real number of steps
@@ -1204,7 +1334,6 @@ function uninstall($base_dir){
1204 1334 $this->id_name = $this->installdefs['id'];
1205 1335 $installed_modules = array();
1206 1336 if(isset($this->installdefs['beans'])){
1207   -
1208 1337 foreach($this->installdefs['beans'] as $bean){
1209 1338
1210 1339 $installed_modules[] = $bean['module'];
@@ -1217,19 +1346,11 @@ function uninstall($base_dir){
1217 1346 $current_step++;
1218 1347 update_progress_bar('install', $total_steps, $total_steps);
1219 1348 }
1220   - if (sugar_is_file("custom/Extension/application/Ext/Include/$this->id_name.php", 'w'))
1221   - rmdir_recursive("custom/Extension/application/Ext/Include/$this->id_name.php");
1222   - else if(sugar_is_file("custom/Extension/application/Ext/Include/" . DISABLED_PATH . "/$this->id_name.php", 'w'))
1223   - rmdir_recursive("custom/Extension/application/Ext/Include/" . DISABLED_PATH . "/$this->id_name.php");
1224   -
1225   - $this->rebuild_modules();
1226 1349 }
1227 1350 if(!$this->silent){
1228 1351 $current_step++;
1229 1352 update_progress_bar('install', $current_step, $total_steps);
1230 1353 }
1231   -
1232   -
1233 1354 foreach($tasks as $task){
1234 1355 $this->$task();
1235 1356 if(!$this->silent){
@@ -1266,10 +1387,10 @@ function uninstall($base_dir){
1266 1387
1267 1388 UpdateSystemTabs('Restore',$installed_modules);
1268 1389
1269   - //clear the unified_search_module.php file
  1390 + //clear the unified_search_module.php file
1270 1391 require_once('modules/Home/UnifiedSearchAdvanced.php');
1271   - UnifiedSearchAdvanced::unlinkUnifiedSearchModulesFile();
1272   -
  1392 + UnifiedSearchAdvanced::unlinkUnifiedSearchModulesFile();
  1393 +
1273 1394 $this->log('<br><b>' . translate('LBL_MI_COMPLETE') . '</b>');
1274 1395 if(!$this->silent){
1275 1396 update_progress_bar('install', $total_steps, $total_steps);
@@ -1279,7 +1400,8 @@ function uninstall($base_dir){
1279 1400 }
1280 1401 }
1281 1402
1282   - function rebuild_languages($languages, $modules=""){
  1403 + function rebuild_languages($languages = array(), $modules="")
  1404 + {
1283 1405 foreach($languages as $language=>$value){
1284 1406 $this->log(translate('LBL_MI_REBUILDING') . " Language...$language");
1285 1407 $this->merge_files('Ext/Language/', $language.'.lang.ext.php', $language);
@@ -1290,24 +1412,12 @@ function rebuild_languages($languages, $modules=""){
1290 1412 }
1291 1413 }
1292 1414 sugar_cache_reset();
1293   -
1294   - }
1295   -
1296   - function rebuild_vardefs(){
1297   - $this->log(translate('LBL_MI_REBUILDING') . " Vardefs...");
1298   - $this->merge_files('Ext/Vardefs/', 'vardefs.ext.php');
1299   - sugar_cache_reset();
1300 1415 }
1301 1416
1302   - function rebuild_layoutdefs(){
1303   - $this->log(translate('LBL_MI_REBUILDING') . " Layoutdefs...");
1304   - $this->merge_files('Ext/Layoutdefs/', 'layoutdefs.ext.php');
1305   -
1306   - }
1307   -
1308   - function rebuild_menus(){
1309   - $this->log(translate('LBL_MI_REBUILDING') . " Menus...");
1310   - $this->merge_files('Ext/Menus/', 'menu.ext.php');
  1417 + function rebuild_vardefs()
  1418 + {
  1419 + $this->rebuildExt("Vardefs", 'vardefs.ext.php');
  1420 + sugar_cache_reset();
1311 1421 }
1312 1422
1313 1423 function rebuild_dashletcontainers(){
@@ -1315,22 +1425,9 @@ function rebuild_dashletcontainers(){
1315 1425 $this->merge_files('Ext/DashletContainer/Containers/', 'dcactions.ext.php');
1316 1426 }
1317 1427
1318   - function rebuild_modules(){
1319   - $this->log(translate('LBL_MI_REBUILDING') . " Modules...");
1320   - $this->merge_files('Ext/Include/', 'modules.ext.php', '', true);
1321   - }
1322   -
1323   - function rebuild_administration(){
1324   - $this->log(translate('LBL_MI_REBUILDING') . " administration " . translate('LBL_MI_SECTION'));
1325   - $this->merge_files('Ext/Administration/', 'administration.ext.php');
1326   - }
1327   - function rebuild_userpage(){
1328   - $this->log(translate('LBL_MI_REBUILDING') . " User Page " . translate('LBL_MI_SECTION'));
1329   - $this->merge_files('Ext/UserPage/', 'userpage.ext.php');
1330   - }
1331   - function rebuild_tabledictionary(){
1332   - $this->log(translate('LBL_MI_REBUILDING') . " administration " . translate('LBL_MI_SECTION'));
1333   - $this->merge_files('Ext/TableDictionary/', 'tabledictionary.ext.php');
  1428 + function rebuild_tabledictionary()
  1429 + {
  1430 + $this->rebuildExt("TableDictionary", 'tabledictionary.ext.php');
1334 1431 }
1335 1432
1336 1433 function rebuild_relationships() {
@@ -1371,16 +1468,11 @@ function rebuild_all($silent=false){
1371 1468 $this->rebuild_modules();
1372 1469
1373 1470 $this->rebuild_languages($sugar_config['languages']);
1374   - $this->rebuild_vardefs();
1375   - $this->rebuild_layoutdefs();
1376   - $this->rebuild_menus();
  1471 + $this->rebuild_extensions();
1377 1472 $this->rebuild_dashletcontainers();
1378   - $this->rebuild_userpage();
1379   - $this->rebuild_administration();
1380 1473 $this->rebuild_relationships();
1381 1474 $this->rebuild_tabledictionary();
1382   - //$this->repair_indices();
1383   - $this->reset_opcodes();
  1475 + $this->reset_opcodes();
1384 1476 sugar_cache_reset();
1385 1477 }
1386 1478
@@ -1424,9 +1516,9 @@ function merge_files($path, $name, $filter = '', $application = false){
1424 1516 $extension .= "\n?>";
1425 1517
1426 1518 if($shouldSave){
1427   - if(!file_exists("custom/$extpath")){
1428   - mkdir_recursive("custom/$extpath", true);
1429   - }
  1519 + if(!file_exists("custom/$extpath")) {
  1520 + mkdir_recursive("custom/$extpath", true);
  1521 + }
1430 1522 $out = sugar_fopen("custom/$extpath/$name", 'w');
1431 1523 fwrite($out,$extension);
1432 1524 fclose($out);
@@ -1473,6 +1565,43 @@ function merge_files($path, $name, $filter = '', $application = false){
1473 1565
1474 1566 }
1475 1567
  1568 + function install_modules()
  1569 + {
  1570 + $this->installed_modules = array();
  1571 + $this->tab_modules = array();
  1572 + if(isset($this->installdefs['beans'])){
  1573 + $str = "<?php \n //WARNING: The contents of this file are auto-generated\n";
  1574 + foreach($this->installdefs['beans'] as $bean){
  1575 + if(!empty($bean['module']) && !empty($bean['class']) && !empty($bean['path'])){
  1576 + $module = $bean['module'];
  1577 + $class = $bean['class'];
  1578 + $path = $bean['path'];
  1579 +
  1580 + $str .= "\$beanList['$module'] = '$class';\n";
  1581 + $str .= "\$beanFiles['$class'] = '$path';\n";
  1582 + if($bean['tab']){
  1583 + $str .= "\$moduleList[] = '$module';\n";
  1584 +