Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Release 6.3.0

  • Loading branch information...
commit 17402a817f45fdcc6d3152eca7e8e3e680de428a 1 parent 47ac7b4
John Mertic jmertic authored
Showing with 20,603 additions and 10,080 deletions.
  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 (657) changed.
1,102 ModuleInstall/ModuleInstaller.php
View
@@ -60,12 +60,14 @@ class ModuleInstaller{
var $silent = false;
var $base_dir = '';
var $modulesInPackage = array();
+ public $disabled_path = DISABLED_PATH;
function ModuleInstaller(){
$this->ms = new ModuleScanner();
$this->modules = get_module_dir_list();
$this->db = & DBManagerFactory::getInstance();
-
+ include("ModuleInstall/extensions.php");
+ $this->extensions = $extensions;
}
/*
@@ -87,6 +89,15 @@ function install($base_dir, $is_upgrade = false, $previous_version = ''){
}
}
+ // workaround for bug 45812 - refresh vardefs cache before unpacking to avoid partial vardefs in cache
+ global $beanList;
+ foreach ($this->modules as $module_name) {
+ if (!empty($beanList[$module_name])) {
+ $objectName = BeanFactory::getObjectName($module_name);
+ VardefManager::loadVardef($module_name, $objectName);
+ }
+ }
+
global $app_strings, $mod_strings;
$this->base_dir = $base_dir;
$total_steps = 5; //minimum number of steps with no tasks
@@ -94,19 +105,14 @@ function install($base_dir, $is_upgrade = false, $previous_version = ''){
$tasks = array(
'pre_execute',
'install_copy',
+ 'install_extensions',
'install_images',
- 'install_menus',
'install_dcactions',
- 'install_userpage',
'install_dashlets',
- 'install_administration',
'install_connectors',
- 'install_vardefs',
- 'install_layoutdefs',
'install_layoutfields',
'install_relationships',
- 'install_languages',
- 'install_logichooks',
+ 'enable_manifest_logichooks',
'post_execute',
'reset_opcodes',
);
@@ -136,41 +142,6 @@ function install($base_dir, $is_upgrade = false, $previous_version = ''){
}//fi
$this->id_name = $installdefs['id'];
$this->installdefs = $installdefs;
- $installed_modules = array();
- $tab_modules = array();
- if(isset($installdefs['beans'])){
- $str = "<?php \n //WARNING: The contents of this file are auto-generated\n";
- foreach($installdefs['beans'] as $bean){
- if(!empty($bean['module']) && !empty($bean['class']) && !empty($bean['path'])){
- $module = $bean['module'];
- $class = $bean['class'];
- $path = $bean['path'];
-
- $str .= "\$beanList['$module'] = '$class';\n";
- $str .= "\$beanFiles['$class'] = '$path';\n";
- if($bean['tab']){
- $str .= "\$moduleList[] = '$module';\n";
- $this->install_user_prefs($module, empty($bean['hide_by_default']));
- $tab_modules[] = $module;
- }else{
- $str .= "\$modules_exempt_from_availability_check['$module'] = '$module';\n";
- $str .= "\$modInvisList[] = '$module';\n";
- }
- $installed_modules[] = $module;
- }else{
- $errors[] = 'Bean array not well defined.';
- $this->abort($errors);
- }
- }
- $str.= "\n?>";
- if(!file_exists("custom/Extension/application/Ext/Include")){
- mkdir_recursive("custom/Extension/application/Ext/Include", true);
- }
- $out = sugar_fopen("custom/Extension/application/Ext/Include/$this->id_name.php", 'w');
- fwrite($out,$str);
- fclose($out);
- $this->rebuild_modules();
- }
if(!$this->silent){
$current_step++;
update_progress_bar('install', $current_step, $total_steps);
@@ -183,7 +154,7 @@ function install($base_dir, $is_upgrade = false, $previous_version = ''){
update_progress_bar('install', $current_step, $total_steps);
}
}
- $this->install_beans($installed_modules);
+ $this->install_beans($this->installed_modules);
if(!$this->silent){
$current_step++;
update_progress_bar('install', $total_steps, $total_steps);
@@ -218,18 +189,23 @@ function install($base_dir, $is_upgrade = false, $previous_version = ''){
include('custom/application/Ext/Include/modules.ext.php');
}
require_once("modules/Administration/upgrade_custom_relationships.php");
- upgrade_custom_relationships($installed_modules);
+ upgrade_custom_relationships($this->installed_modules);
$this->rebuild_all(true);
require_once('modules/Administration/QuickRepairAndRebuild.php');
$rac = new RepairAndClear();
- $rac->repairAndClearAll($selectedActions, $installed_modules,true, false);
+ $rac->repairAndClearAll($selectedActions, $this->installed_modules,true, false);
$this->rebuild_relationships();
- UpdateSystemTabs('Add',$tab_modules);
-
- //clear the unified_search_module.php file
+ UpdateSystemTabs('Add',$this->tab_modules);
+ //Clear out all the langauge cache files.
+ clearAllJsAndJsLangFilesWithoutOutput();
+ $cache_key = 'app_list_strings.'.$GLOBALS['current_language'];
+ sugar_cache_clear($cache_key );
+ sugar_cache_reset();
+
+ //clear the unified_search_module.php file
require_once('modules/Home/UnifiedSearchAdvanced.php');
- UnifiedSearchAdvanced::unlinkUnifiedSearchModulesFile();
-
+ UnifiedSearchAdvanced::unlinkUnifiedSearchModulesFile();
+
$this->log('<br><b>' . translate('LBL_MI_COMPLETE') . '</b>');
}else{
die("No \$installdefs Defined In $this->base_dir/manifest.php");
@@ -357,8 +333,290 @@ function uninstall_new_files($cp, $backup_path){
}
+ /**
+ * Get directory where module's extensions go
+ * @param string $module Module name
+ */
+ public function getExtDir($module)
+ {
+ if($module == 'application') {
+ return "custom/Extension/application/Ext";
+ } else {
+ return "custom/Extension/modules/$module/Ext";
+ }
+ }
+
+ /**
+ * Install file(s) into Ext/ part
+ * @param string $section Name of the install file section
+ * @param string $extname Name in Ext directory
+ * @param string $module This extension belongs to a specific module
+ */
+ public function installExt($section, $extname, $module = '')
+ {
+ if(isset($this->installdefs[$section])){
+ $this->log(sprintf(translate("LBL_MI_IN_EXT"), $section));
+ foreach($this->installdefs[$section] as $item){
+ if(isset($item['from'])) {
+ $from = str_replace('<basepath>', $this->base_dir, $item['from']);
+ } else {
+ $from = '';
+ }
+ if(!empty($module)) {
+ $item['to_module'] = $module;
+ }
+ $GLOBALS['log']->debug("Installing section $section from $from for " .$item['to_module'] );
+ if($item['to_module'] == 'application') {
+ $path = "custom/Extension/application/Ext/$extname";
+ } else {
+ $path = "custom/Extension/modules/{$item['to_module']}/Ext/$extname";
+ }
+ if(!file_exists($path)){
+ mkdir_recursive($path, true);
+ }
+ if(isset($item["name"])) {
+ $target = $item["name"];
+ } else if (!empty($from)){
+ $target = basename($from, ".php");
+ } else {
+ $target = $this->id_name;
+ }
+ if(!empty($from)) {
+ copy_recursive($from , "$path/$target.php");
+ }
+ }
+ }
+ }
+
+ /**
+ * Uninstall file(s) into Ext/ part
+ * @param string $section Name of the install file section
+ * @param string $extname Name in Ext directory
+ * @param string $module This extension belongs to a specific module
+ */
+ public function uninstallExt($section, $extname, $module = '')
+ {
+ if(isset($this->installdefs[$section])){
+ $this->log(sprintf(translate("LBL_MI_UN_EXT"), $section));
+ foreach($this->installdefs[$section] as $item){
+ if(isset($item['from'])) {
+ $from = str_replace('<basepath>', $this->base_dir, $item['from']);
+ } else {
+ $from = '';
+ }
+ if(!empty($module)) {
+ $item['to_module'] = $module;
+ }
+ $GLOBALS['log']->debug("Uninstalling section $section from $from for " .$item['to_module'] );
+ if($item['to_module'] == 'application') {
+ $path = "custom/Extension/application/Ext/$extname";
+ } else {
+ $path = "custom/Extension/modules/{$item['to_module']}/Ext/$extname";
+ }
+ if(isset($item["name"])) {
+ $target = $item["name"];
+ } else if (!empty($from)){
+ $target = basename($from, ".php");
+ } else {
+ $target = $this->id_name;
+ }
+ $disabled_path = $path.'/'.DISABLED_PATH;
+ if (file_exists("$path/$target.php")) {
+ rmdir_recursive("$path/$target.php");
+ } else if (file_exists("$disabled_path/$target.php")) {
+ rmdir_recursive("$disabled_path/$target.php");
+ } else if (!empty($from) && file_exists($path . '/'. basename($from))) {
+ rmdir_recursive( $path . '/'. basename($from));
+ } else if (!empty($from) && file_exists($disabled_path . '/'. basename($from))) {
+ rmdir_recursive( $disabled_path . '/'. basename($from));
+ }
+ }
+ }
+ }
+
+ /**
+ * Rebuild generic extension
+ * @param string $ext Extension directory
+ * @param string $filename Target filename
+ */
+ public function rebuildExt($ext, $filename)
+ {
+ $this->log(translate('LBL_MI_REBUILDING') . " $ext...");
+ $this->merge_files("Ext/$ext/", $filename);
+ }
+
+ /**
+ * Disable generic extension
+ * @param string $section Install file section name
+ * @param string $extname Extension directory
+ * @param string $module This extension belongs to a specific module
+ */
+ public function disableExt($section, $extname, $module = '')
+ {
+ if(isset($this->installdefs[$section])) {
+ foreach($this->installdefs[$section] as $item) {
+ if(isset($item['from'])) {
+ $from = str_replace('<basepath>', $this->base_dir, $item['from']);
+ } else {
+ $from = '';
+ }
+ if(!empty($module)) {
+ $item['to_module'] = $module;
+ }
+ $GLOBALS['log']->debug("Disabling $extname ... from $from for " .$item['to_module']);
+ if($item['to_module'] == 'application') {
+ $path = "custom/Extension/application/Ext/$extname";
+ } else {
+ $path = "custom/Extension/modules/{$item['to_module']}/Ext/$extname";
+ }
+ if(isset($item["name"])) {
+ $target = $item["name"];
+ } else if (!empty($from)){
+ $target = basename($from, ".php");
+ }else {
+ $target = $this->id_name;
+ }
+ $disabled_path = $path.'/'.DISABLED_PATH;
+ if (file_exists("$path/$target.php")) {
+ mkdir_recursive($disabled_path, true);
+ rename("$path/$target.php", "$disabled_path/$target.php");
+ } else if (!empty($from) && file_exists($path . '/'. basename($from))) {
+ mkdir_recursive($disabled_path, true);
+ rename( $path . '/'. basename($from), $disabled_path.'/'. basename($from));
+ }
+ }
+ }
+ }
+
+ /**
+ * Enable generic extension
+ * @param string $section Install file section name
+ * @param string $extname Extension directory
+ * @param string $module This extension belongs to a specific module
+ */
+ public function enableExt($section, $extname, $module = '')
+ {
+ if(isset($this->installdefs[$section])) {
+ foreach($this->installdefs[$section] as $item) {
+ if(isset($item['from'])) {
+ $from = str_replace('<basepath>', $this->base_dir, $item['from']);
+ } else {
+ $from = '';
+ }
+ if(!empty($module)) {
+ $item['to_module'] = $module;
+ }
+ $GLOBALS['log']->debug("Enabling $extname ... from $from for " .$item['to_module']);
+
+ if($item['to_module'] == 'application') {
+ $path = "custom/Extension/application/Ext/$extname";
+ } else {
+ $path = "custom/Extension/modules/{$item['to_module']}/Ext/$extname";
+ }
+ if(isset($item["name"])) {
+ $target = $item["name"];
+ } else if (!empty($from)){
+ $target = basename($from, ".php");
+ } else {
+ $target = $this->id_name;
+ }
+ if(!file_exists($path)) {
+ mkdir_recursive($path, true);
+ }
+ $disabled_path = $path.'/'.DISABLED_PATH;
+ if (file_exists("$disabled_path/$target.php")) {
+ rename("$disabled_path/$target.php", "$path/$target.php");
+ }
+ if (!empty($from) && file_exists($disabled_path . '/'. basename($from))) {
+ rename($disabled_path.'/'. basename($from), $path . '/'. basename($from));
+ }
+ }
+ }
+ }
+
+ public function install_extensions()
+ {
+ foreach($this->extensions as $extname => $ext) {
+ $install = "install_$extname";
+ if(method_exists($this, $install)) {
+ // non-standard function
+ $this->$install();
+ } else {
+ if(!empty($ext["section"])) {
+ $module = isset($ext['module'])?$ext['module']:'';
+ $this->installExt($ext["section"], $ext["extdir"], $module);
+ }
+ }
+ }
+ $this->rebuild_extensions();
+ }
+
+ public function uninstall_extensions()
+ {
+ foreach($this->extensions as $extname => $ext) {
+ $func = "uninstall_$extname";
+ if(method_exists($this, $func)) {
+ // non-standard function
+ $this->$func();
+ } else {
+ if(!empty($ext["section"])) {
+ $module = isset($ext['module'])?$ext['module']:'';
+ $this->uninstallExt($ext["section"], $ext["extdir"], $module);
+ }
+ }
+ }
+ $this->rebuild_extensions();
+ }
+
+ public function rebuild_extensions()
+ {
+ foreach($this->extensions as $extname => $ext) {
+ $func = "rebuild_$extname";
+ if(method_exists($this, $func)) {
+ // non-standard function
+ $this->$func();
+ } else {
+ $this->rebuildExt($ext["extdir"], $ext["file"]);
+ }
+ }
+ }
- function install_dashlets(){
+ public function disable_extensions()
+ {
+ foreach($this->extensions as $extname => $ext) {
+ $func = "disable_$extname";
+ if(method_exists($this, $func)) {
+ // non-standard install
+ $this->$func();
+ } else {
+ if(!empty($ext["section"])) {
+ $module = isset($ext['module'])?$ext['module']:'';
+ $this->disableExt($ext["section"], $ext["extdir"], $module);
+ }
+ }
+ }
+ $this->rebuild_extensions();
+ }
+
+ public function enable_extensions()
+ {
+ foreach($this->extensions as $extname => $ext) {
+ $func = "enable_$extname";
+ if(method_exists($this, $func)) {
+ // non-standard install
+ $this->$func();
+ } else {
+ if(!empty($ext["section"])) {
+ $module = isset($ext['module'])?$ext['module']:'';
+ $this->enableExt($ext["section"], $ext["extdir"], $module);
+ }
+ }
+ }
+ $this->rebuild_extensions();
+ }
+
+ function install_dashlets()
+ {
if(isset($this->installdefs['dashlets'])){
foreach($this->installdefs['dashlets'] as $cp){
$this->log(translate('LBL_MI_IN_DASHLETS') . $cp['name']);
@@ -397,49 +655,6 @@ function install_images(){
}
}
- function install_menus(){
- if(isset($this->installdefs['menu'])){
- $this->log(translate('LBL_MI_IN_MENUS'));
- foreach($this->installdefs['menu'] as $menu){
- $menu['from'] = str_replace('<basepath>', $this->base_dir, $menu['from']);
- $GLOBALS['log']->debug("Installing Menu ..." . $menu['from']. " for " .$menu['to_module'] );
- $path = 'custom/Extension/modules/' . $menu['to_module']. '/Ext/Menus';
- if($menu['to_module'] == 'application'){
- $path ='custom/Extension/' . $menu['to_module']. '/Ext/Menus';
- }
- if(!file_exists($path)){
- mkdir_recursive($path, true);
-
- }
- copy_recursive($menu['from'] , $path . '/'. $this->id_name . '.php');
- }
- $this->rebuild_menus();
- }
- }
-
- function uninstall_menus(){
- if(isset($this->installdefs['menu'])){
- $this->log(translate('LBL_MI_UN_MENUS'));
- foreach($this->installdefs['menu'] as $menu){
- $menu['from'] = str_replace('<basepath>', $this->base_dir, $menu['from']);
- $GLOBALS['log']->debug("Uninstalling Menu ..." . $menu['from']. " for " .$menu['to_module'] );
- $path = 'custom/Extension/modules/' . $menu['to_module']. '/Ext/Menus';
- if($menu['to_module'] == 'application'){
- $path ='custom/Extension/' . $menu['to_module']. '/Ext/Menus';
- }
- if (sugar_is_file($path . '/'. $this->id_name . '.php', 'w'))
- {
- rmdir_recursive( $path . '/'. $this->id_name . '.php');
- }
- else if (sugar_is_file($path . '/'. DISABLED_PATH . '/'. $this->id_name . '.php', 'w'))
- {
- rmdir_recursive( $path . '/'. DISABLED_PATH . '/'. $this->id_name . '.php');
- }
- }
- $this->rebuild_menus();
- }
- }
-
function install_dcactions(){
if(isset($this->installdefs['dcaction'])){
$this->log(translate('LBL_MI_IN_MENUS'));
@@ -476,39 +691,6 @@ function uninstall_dcactions(){
}
}
- function install_administration(){
- if(isset($this->installdefs['administration'])){
- $this->log(translate('LBL_MI_IN_ADMIN'));
- foreach($this->installdefs['administration'] as $administration){
- $administration['from'] = str_replace('<basepath>', $this->base_dir, $administration['from']);
- $GLOBALS['log']->debug("Installing Administration Section ..." . $administration['from'] );
- $path = 'custom/Extension/modules/Administration/Ext/Administration';
- if(!file_exists($path)){
- mkdir_recursive($path, true);
-
- }
- copy_recursive($administration['from'] , $path . '/'. $this->id_name . '.php');
- }
- $this->rebuild_administration();
- }
-
- }
- function uninstall_administration(){
- if(isset($this->installdefs['administration'])){
- $this->log(translate('LBL_MI_UN_ADMIN'));
- foreach($this->installdefs['administration'] as $administration){
- $administration['from'] = str_replace('<basepath>', $this->base_dir, $administration['from']);
- $GLOBALS['log']->debug("Uninstalling Administration Section ..." . $administration['from'] );
- $path = 'custom/Extension/modules/Administration/Ext/Administration';
- if (sugar_is_file($path . '/'. $this->id_name . '.php', "w"))
- rmdir_recursive( $path . '/'. $this->id_name . '.php');
- else if (sugar_is_file($path . '/'. DISABLED_PATH . "/" . $this->id_name . '.php', "w"))
- rmdir_recursive( $path . '/'. DISABLED_PATH . "/" . $this->id_name . '.php');
- }
- $this->rebuild_administration();
- }
- }
-
function install_connectors(){
if(isset($this->installdefs['connectors'])){
foreach($this->installdefs['connectors'] as $cp){
@@ -554,82 +736,8 @@ function uninstall_connectors(){
}
}
- function install_userpage(){
- if(isset($this->installdefs['user_page'])){
- $this->log(translate('LBL_MI_IN_USER'));
- foreach($this->installdefs['user_page'] as $userpage){
- $userpage['from'] = str_replace('<basepath>', $this->base_dir, $userpage['from']);
- $GLOBALS['log']->debug("Installing User Page Section ..." . $userpage['from'] );
- $path = 'custom/Extension/modules/Users/Ext/UserPage';
- if(!file_exists($path)){
- mkdir_recursive($path, true);
-
- }
- copy_recursive($userpage['from'] , $path . '/'. $this->id_name . '.php');
- }
- $this->rebuild_userpage();
- }
-
- }
- function uninstall_userpage(){
- if(isset($this->installdefs['user_page'])){
- $this->log(translate('LBL_MI_UN_USER') );
- foreach($this->installdefs['user_page'] as $userpage){
- $userpage['from'] = str_replace('<basepath>', $this->base_dir, $userpage['from']);
- $GLOBALS['log']->debug("Uninstalling User Page Section ..." . $userpage['from'] );
- $path = 'custom/Extension/modules/Users/Ext/UserPage';
- rmdir_recursive( $path . '/'. $this->id_name . '.php');
- }
- $this->rebuild_userpage();
- }
- }
-
- /*
- * ModuleInstaller->install_vardefs uses the vardefs section of the installdefs and copies from the 'from' path (replacing <basepath> as usual) to either
- * custom/Extension/modules/<module>/Ext/Vardefs or custom/Extension/<module>/Ext/Vardefs if the 'to_module' value in the installdefs is set to 'application'.
- * Finally rebuild_vardefs() is used to merge /Ext/Vardefs into vardefs.ext.php
- */
- function install_vardefs(){
- if(isset($this->installdefs['vardefs'])){
- $this->log(translate('LBL_MI_IN_VAR') );
- foreach($this->installdefs['vardefs'] as $vardefs){
- $vardefs['from'] = str_replace('<basepath>', $this->base_dir, $vardefs['from']);
- $this->install_vardef($vardefs['from'], $vardefs['to_module'], $this->id_name);
- }
- $this->rebuild_vardefs();
- }
- }
- function uninstall_vardefs(){
- if(isset($this->installdefs['vardefs'])){
- $this->log(translate('LBL_MI_UN_VAR') );
- foreach($this->installdefs['vardefs'] as $vardefs){
- $vardefs['from'] = str_replace('<basepath>', $this->base_dir, $vardefs['from']);
- $GLOBALS['log']->debug("Uninstalling Vardefs ..." . $vardefs['from'] . " for " .$vardefs['to_module']);
- $path = 'custom/Extension/modules/' . $vardefs['to_module']. '/Ext/Vardefs';
- if($vardefs['to_module'] == 'application'){
- $path ='custom/Extension/' . $vardefs['to_module']. '/Ext/Vardefs';
- }
- if(file_exists($path . '/'. $this->id_name . '.php'))
- {
- rmdir_recursive( $path . '/'. $this->id_name . '.php');
- }
- else if(file_exists($path . '/'. DISABLED_PATH . '/'. $this->id_name . '.php'))
- {
- rmdir_recursive($path . '/'. DISABLED_PATH . '/'. $this->id_name . '.php');
- }
- else if (file_exists($path . '/'. basename($vardefs['from'] )))
- {
- rmdir_recursive( $path . '/'. basename($vardefs['from'] ));
- }
- else if(file_exists($path . '/'. DISABLED_PATH . '/'. basename($vardefs['from'])))
- {
- rmdir_recursive($path . '/'. DISABLED_PATH . '/'. basename($vardefs['from']));
- }
- }
- $this->rebuild_vardefs();
- }
- }
- function install_vardef($from, $to_module){
+ function install_vardef($from, $to_module)
+ {
$GLOBALS['log']->debug("Installing Vardefs ..." . $from . " for " .$to_module);
$path = 'custom/Extension/modules/' . $to_module. '/Ext/Vardefs';
if($to_module == 'application'){
@@ -641,50 +749,6 @@ function install_vardef($from, $to_module){
copy_recursive($from , $path.'/'. basename($from));
}
- /*
- * ModuleInstaller->install_layoutdefs installs the $layout_defs variable (subpanel definitions) from Ext/Layoutdefs to the to_module location of
- * 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.
- */
- function install_layoutdefs(){
- if(isset($this->installdefs['layoutdefs'])){
- $this->log(translate('LBL_MI_IN_SUBPANEL') );
- foreach($this->installdefs['layoutdefs'] as $layoutdefs){
- $layoutdefs['from'] = str_replace('<basepath>', $this->base_dir, $layoutdefs['from']);
- $this->install_layoutdef($layoutdefs['from'], $layoutdefs['to_module'], $this->id_name);
- }
- $this->rebuild_layoutdefs();
- }
- }
- function uninstall_layoutdefs(){
- if(isset($this->installdefs['layoutdefs'])){
- $this->log(translate('LBL_MI_UN_SUBPANEL') );
- foreach($this->installdefs['layoutdefs'] as $layoutdefs){
- $layoutdefs['from'] = str_replace('<basepath>', $this->base_dir, $layoutdefs['from']);
- $GLOBALS['log']->debug("Uninstalling Layoutdefs ..." . $layoutdefs['from'] . " for " .$layoutdefs['to_module']);
- $path = 'custom/Extension/modules/' . $layoutdefs['to_module']. '/Ext/Layoutdefs';
- if($layoutdefs['to_module'] == 'application'){
- $path ='custom/Extension/' . $layoutdefs['to_module']. '/Ext/Layoutdefs';
- }
- if (file_exists($path . '/'. $this->id_name . '.php'))
- {
- rmdir_recursive( $path . '/'. $this->id_name . '.php');
- }
- else if (file_exists($path . '/'. DISABLED_PATH . '/' . $this->id_name . '.php'))
- {
- rmdir_recursive($path . '/'. DISABLED_PATH . '/' . $this->id_name . '.php');
- }
- else if (file_exists($path . '/'. basename($layoutdefs['from'] )))
- {
- rmdir_recursive( $path . '/'. basename($layoutdefs['from'] ));
- }
- else if(file_exists($path . '/'. DISABLED_PATH . '/'. basename($layoutdefs['from'])))
- {
- rmdir_recursive($path . '/'. DISABLED_PATH . '/'. basename($layoutdefs['from']));
- }
- }
- $this->rebuild_layoutdefs();
- }
- }
function install_layoutdef($from, $to_module){
$GLOBALS['log']->debug("Installing Layout Defs ..." . $from . " for " .$to_module);
$path = 'custom/Extension/modules/' . $to_module. '/Ext/Layoutdefs';
@@ -697,6 +761,7 @@ function install_layoutdef($from, $to_module){
copy_recursive($from , $path.'/'. basename($from));
}
+ // Non-standard - needs special rebuild call
function install_languages()
{
$languages = array();
@@ -724,6 +789,7 @@ function install_languages()
}
}
+ // Non-standard, needs special rebuild
function uninstall_languages(){
$languages = array();
if(isset($this->installdefs['language'])){
@@ -748,6 +814,81 @@ function uninstall_languages(){
}
}
+ // Non-standard, needs special rebuild
+ public function disable_languages()
+ {
+ if(isset($this->installdefs['language'])) {
+ $languages = $modules = array();
+ foreach($this->installdefs['language'] as $item) {
+ $from = str_replace('<basepath>', $this->base_dir, $item['from']);
+ $GLOBALS['log']->debug("Disabling Language {$item['language']}... from $from for " .$item['to_module']);
+ $modules[]=$item['to_module'];
+ $languages[$item['language']] = $item['language'];
+ if($item['to_module'] == 'application') {
+ $path = "custom/Extension/application/Ext/Language";
+ } else {
+ $path = "custom/Extension/modules/{$item['to_module']}/Ext/Language";
+ }
+ if(isset($item["name"])) {
+ $target = $item["name"];
+ } else {
+ $target = $this->id_name;
+ }
+ $target = "{$item['language']}.$target";
+
+ $disabled_path = $path.'/'.DISABLED_PATH;
+ if (file_exists("$path/$target.php")) {
+ mkdir_recursive($disabled_path, true);
+ rename("$path/$target.php", "$disabled_path/$target.php");
+ } else if (file_exists($path . '/'. basename($from))) {
+ mkdir_recursive($disabled_path, true);
+ rename( $path . '/'. basename($from), $disabled_path.'/'. basename($from));
+ }
+ }
+ $this->rebuild_languages($languages, $modules);
+ }
+ }
+
+ // Non-standard, needs special rebuild
+ public function enable_languages()
+ {
+ if(isset($this->installdefs['language'])) {
+ foreach($this->installdefs['language'] as $item) {
+ $from = str_replace('<basepath>', $this->base_dir, $item['from']);
+ $GLOBALS['log']->debug("Enabling Language {$item['language']}... from $from for " .$item['to_module']);
+ $modules[]=$item['to_module'];
+ $languages[$item['language']] = $item['language'];
+ if(!empty($module)) {
+ $item['to_module'] = $module;
+ }
+
+ if($item['to_module'] == 'application') {
+ $path = "custom/Extension/application/Ext/Language";
+ } else {
+ $path = "custom/Extension/modules/{$item['to_module']}/Ext/Language";
+ }
+ if(isset($item["name"])) {
+ $target = $item["name"];
+ } else {
+ $target = $this->id_name;
+ }
+ $target = "{$item['language']}.$target";
+
+ if(!file_exists($path)) {
+ mkdir_recursive($path, true);
+ }
+ $disabled_path = $path.'/'.DISABLED_PATH;
+ if (file_exists("$disabled_path/$target.php")) {
+ rename("$disabled_path/$target.php", "$path/$target.php");
+ }
+ if (file_exists($disabled_path . '/'. basename($from))) {
+ rename($disabled_path.'/'. basename($from), $path . '/'. basename($from));
+ }
+ }
+ $this->rebuild_languages($languages, $modules);
+ }
+ }
+
// Functions for adding and removing logic hooks from uploaded files
// 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
/* The module hook definition should look like this:
@@ -766,17 +907,7 @@ function uninstall_languages(){
... blah blah ...
);
*/
- function install_logichooks() {
- // Since the logic hook files get copied over with the rest of the module directory, we just need to enable them
- $this->enable_logichooks();
- }
-
- function uninstall_logichooks() {
- // Since the logic hook files get removed with the rest of the module directory, we just need to disable them
- $this->disable_logichooks();
- }
-
- function enable_logichooks() {
+ function enable_manifest_logichooks() {
if(empty($this->installdefs['logic_hooks']) || !is_array($this->installdefs['logic_hooks'])) {
return;
}
@@ -788,12 +919,11 @@ function enable_logichooks() {
}
}
- function disable_logichooks() {
+ function disable_manifest_logichooks() {
if(empty($this->installdefs['logic_hooks']) || !is_array($this->installdefs['logic_hooks'])) {
return;
}
-
foreach($this->installdefs['logic_hooks'] as $hook ) {
remove_logic_hook($hook['module'], $hook['hook'], array($hook['order'], $hook['description'], $hook['file'], $hook['class'], $hook['function']));
}
@@ -929,13 +1059,16 @@ function install_relationships ()
+
+ Relationship::delete_cache();
$this->rebuild_vardefs () ;
$this->rebuild_layoutdefs () ;
if ($save_table_dictionary)
{
$this->rebuild_tabledictionary () ;
}
-
+ require_once("data/Relationships/RelationshipFactory.php");
+ SugarRelationshipFactory::deleteCache();
}
}
@@ -1087,7 +1220,9 @@ function uninstall_relationships($include_studio_relationships = false){
//Find all the relatioships/relate fields involving this module.
$rels_to_remove = array();
foreach($beanList as $mod => $bean) {
- VardefManager::loadVardef($mod, $bean);
+ //Some modules like cases have a bean name that doesn't match the object name
+ $bean = BeanFactory::getObjectName($mod);
+ VardefManager::loadVardef($mod, $bean);
//We can skip modules that are in this package as they will be removed anyhow
if (!in_array($mod, $this->modulesInPackage) && !empty($dictionary[$bean]) && !empty($dictionary[$bean]['fields']))
{
@@ -1178,16 +1313,11 @@ function uninstall($base_dir){
'uninstall_relationships',
'uninstall_copy',
'uninstall_dcactions',
- 'uninstall_menus',
'uninstall_dashlets',
- 'uninstall_userpage',
- 'uninstall_administration',
'uninstall_connectors',
- 'uninstall_vardefs',
- 'uninstall_layoutdefs',
'uninstall_layoutfields',
- 'uninstall_languages',
- 'uninstall_logichooks',
+ 'uninstall_extensions',
+ 'disable_manifest_logichooks',
'post_uninstall',
);
$total_steps += count($tasks); //now the real number of steps
@@ -1204,7 +1334,6 @@ function uninstall($base_dir){
$this->id_name = $this->installdefs['id'];
$installed_modules = array();
if(isset($this->installdefs['beans'])){
-
foreach($this->installdefs['beans'] as $bean){
$installed_modules[] = $bean['module'];
@@ -1217,19 +1346,11 @@ function uninstall($base_dir){
$current_step++;
update_progress_bar('install', $total_steps, $total_steps);
}
- if (sugar_is_file("custom/Extension/application/Ext/Include/$this->id_name.php", 'w'))
- rmdir_recursive("custom/Extension/application/Ext/Include/$this->id_name.php");
- else if(sugar_is_file("custom/Extension/application/Ext/Include/" . DISABLED_PATH . "/$this->id_name.php", 'w'))
- rmdir_recursive("custom/Extension/application/Ext/Include/" . DISABLED_PATH . "/$this->id_name.php");
-
- $this->rebuild_modules();
}
if(!$this->silent){
$current_step++;
update_progress_bar('install', $current_step, $total_steps);
}
-
-
foreach($tasks as $task){
$this->$task();
if(!$this->silent){
@@ -1266,10 +1387,10 @@ function uninstall($base_dir){
UpdateSystemTabs('Restore',$installed_modules);
- //clear the unified_search_module.php file
+ //clear the unified_search_module.php file
require_once('modules/Home/UnifiedSearchAdvanced.php');
- UnifiedSearchAdvanced::unlinkUnifiedSearchModulesFile();
-
+ UnifiedSearchAdvanced::unlinkUnifiedSearchModulesFile();
+
$this->log('<br><b>' . translate('LBL_MI_COMPLETE') . '</b>');
if(!$this->silent){
update_progress_bar('install', $total_steps, $total_steps);
@@ -1279,7 +1400,8 @@ function uninstall($base_dir){
}
}
- function rebuild_languages($languages, $modules=""){
+ function rebuild_languages($languages = array(), $modules="")
+ {
foreach($languages as $language=>$value){
$this->log(translate('LBL_MI_REBUILDING') . " Language...$language");
$this->merge_files('Ext/Language/', $language.'.lang.ext.php', $language);
@@ -1290,24 +1412,12 @@ function rebuild_languages($languages, $modules=""){
}
}
sugar_cache_reset();
-
- }
-
- function rebuild_vardefs(){
- $this->log(translate('LBL_MI_REBUILDING') . " Vardefs...");
- $this->merge_files('Ext/Vardefs/', 'vardefs.ext.php');
- sugar_cache_reset();
}
- function rebuild_layoutdefs(){
- $this->log(translate('LBL_MI_REBUILDING') . " Layoutdefs...");
- $this->merge_files('Ext/Layoutdefs/', 'layoutdefs.ext.php');
-
- }
-
- function rebuild_menus(){
- $this->log(translate('LBL_MI_REBUILDING') . " Menus...");
- $this->merge_files('Ext/Menus/', 'menu.ext.php');
+ function rebuild_vardefs()
+ {
+ $this->rebuildExt("Vardefs", 'vardefs.ext.php');
+ sugar_cache_reset();
}
function rebuild_dashletcontainers(){
@@ -1315,22 +1425,9 @@ function rebuild_dashletcontainers(){
$this->merge_files('Ext/DashletContainer/Containers/', 'dcactions.ext.php');
}
- function rebuild_modules(){
- $this->log(translate('LBL_MI_REBUILDING') . " Modules...");
- $this->merge_files('Ext/Include/', 'modules.ext.php', '', true);
- }
-
- function rebuild_administration(){
- $this->log(translate('LBL_MI_REBUILDING') . " administration " . translate('LBL_MI_SECTION'));
- $this->merge_files('Ext/Administration/', 'administration.ext.php');
- }
- function rebuild_userpage(){
- $this->log(translate('LBL_MI_REBUILDING') . " User Page " . translate('LBL_MI_SECTION'));
- $this->merge_files('Ext/UserPage/', 'userpage.ext.php');
- }
- function rebuild_tabledictionary(){
- $this->log(translate('LBL_MI_REBUILDING') . " administration " . translate('LBL_MI_SECTION'));
- $this->merge_files('Ext/TableDictionary/', 'tabledictionary.ext.php');
+ function rebuild_tabledictionary()
+ {
+ $this->rebuildExt("TableDictionary", 'tabledictionary.ext.php');
}
function rebuild_relationships() {
@@ -1371,16 +1468,11 @@ function rebuild_all($silent=false){
$this->rebuild_modules();
$this->rebuild_languages($sugar_config['languages']);
- $this->rebuild_vardefs();
- $this->rebuild_layoutdefs();
- $this->rebuild_menus();
+ $this->rebuild_extensions();
$this->rebuild_dashletcontainers();
- $this->rebuild_userpage();
- $this->rebuild_administration();
$this->rebuild_relationships();
$this->rebuild_tabledictionary();
- //$this->repair_indices();
- $this->reset_opcodes();
+ $this->reset_opcodes();
sugar_cache_reset();
}
@@ -1424,9 +1516,9 @@ function merge_files($path, $name, $filter = '', $application = false){
$extension .= "\n?>";
if($shouldSave){
- if(!file_exists("custom/$extpath")){
- mkdir_recursive("custom/$extpath", true);
- }
+ if(!file_exists("custom/$extpath")) {
+ mkdir_recursive("custom/$extpath", true);
+ }
$out = sugar_fopen("custom/$extpath/$name", 'w');
fwrite($out,$extension);
fclose($out);
@@ -1473,6 +1565,43 @@ function merge_files($path, $name, $filter = '', $application = false){
}
+ function install_modules()
+ {
+ $this->installed_modules = array();
+ $this->tab_modules = array();
+ if(isset($this->installdefs['beans'])){
+ $str = "<?php \n //WARNING: The contents of this file are auto-generated\n";
+ foreach($this->installdefs['beans'] as $bean){
+ if(!empty($bean['module']) && !empty($bean['class']) && !empty($bean['path'])){
+ $module = $bean['module'];
+ $class = $bean['class'];
+ $path = $bean['path'];
+
+ $str .= "\$beanList['$module'] = '$class';\n";
+ $str .= "\$beanFiles['$class'] = '$path';\n";
+ if($bean['tab']){
+ $str .= "\$moduleList[] = '$module';\n";
+ $this->install_user_prefs($module, empty($bean['hide_by_default']));
+ $this->tab_modules[] = $module;
+ }else{
+ $str .= "\$modules_exempt_from_availability_check['$module'] = '$module';\n";
+ $str .= "\$report_include_modules['$module'] = '$module';\n";
+ $str .= "\$modInvisList[] = '$module';\n";
+ }
+ $this->installed_modules[] = $module;
+ }else{
+ $errors[] = 'Bean array not well defined.';
+ $this->abort($errors);
+ }
+ }
+ $str.= "\n?>";
+ if(!file_exists("custom/Extension/application/Ext/Include")){
+ mkdir_recursive("custom/Extension/application/Ext/Include", true);
+ }
+ file_put_contents("custom/Extension/application/Ext/Include/{$this->id_name}.php", $str);
+ }
+ }
+
/*
* ModuleInstaller->install_beans runs through the list of beans given, instantiates each bean, calls bean->create_tables, and then calls SugarBean::createRelationshipMeta for the
* bean/module.
@@ -1490,7 +1619,7 @@ function install_beans($beans){
if(is_subclass_of($mod, 'SugarBean') && $mod->disable_vardefs == false ){
$GLOBALS['log']->debug( "Creating Tables Bean : $bean");
$mod->create_tables();
- SugarBean::createRelationshipMeta($mod->getObjectName(), $mod->db,$mod->table_name,'',$mod->module_dir);
+ SugarBean::createRelationshipMeta($mod->getObjectName(), $mod->db,$mod->table_name,'',$mod->module_dir);
}
}else{
$GLOBALS['log']->debug( "File Does Not Exist:" . $beanFiles[$class] );
@@ -1739,15 +1868,10 @@ function enable($base_dir, $is_upgrade = false, $previous_version = ''){
$current_step = 0;
$tasks = array(
'enable_copy',
- 'enable_menus',
- 'enable_userpage',
'enable_dashlets',
- 'enable_administration',
- 'enable_vardefs',
- 'enable_layoutdefs',
'enable_relationships',
- 'enable_languages',
- 'enable_logichooks',
+ 'enable_extensions',
+ 'enable_manifest_logichooks',
'reset_opcodes',
);
$total_steps += count($tasks);
@@ -1779,12 +1903,6 @@ function enable($base_dir, $is_upgrade = false, $previous_version = ''){
foreach($this->installdefs['beans'] as $bean){
$installed_modules[] = $bean['module'];
}
- if(!file_exists("custom/Extension/application/Ext/Include")){
- mkdir_recursive("custom/Extension/application/Ext/Include", true);
- }
- if (file_exists("custom/Extension/application/Ext/Include/".DISABLED_PATH.'/'. $this->id_name . '.php'))
- rename("custom/Extension/application/Ext/Include/".DISABLED_PATH.'/'. $this->id_name . '.php',"custom/Extension/application/Ext/Include/$this->id_name.php");
- $this->rebuild_modules();
}
if(!$this->silent){
$current_step++;
@@ -1819,15 +1937,10 @@ function disable($base_dir){
$this->base_dir = $base_dir;
$tasks = array(
'disable_copy',
- 'disable_menus',
'disable_dashlets',
- 'disable_userpage',
- 'disable_administration',
- 'disable_vardefs',
- 'disable_layoutdefs',
'disable_relationships',
- 'disable_languages',
- 'disable_logichooks',
+ 'disable_extensions',
+ 'disable_manifest_logichooks',
'reset_opcodes',
);
$total_steps += count($tasks); //now the real number of steps
@@ -1846,16 +1959,6 @@ function disable($base_dir){
foreach($this->installdefs['beans'] as $bean){
$installed_modules[] = $bean['module'];
}
-
- mkdir_recursive("custom/Extension/application/Ext/Include/".DISABLED_PATH, true);
-
- //Clear any older disabled version
- if (file_exists("custom/Extension/application/Ext/Include/".DISABLED_PATH.'/'. $this->id_name . '.php'))
- rmdir_recursive("custom/Extension/application/Ext/Include/".DISABLED_PATH.'/'. $this->id_name . '.php');
-
- if (file_exists("custom/Extension/application/Ext/Include/$this->id_name.php"))
- rename("custom/Extension/application/Ext/Include/$this->id_name.php", "custom/Extension/application/Ext/Include/".DISABLED_PATH.'/'. $this->id_name . '.php');
- $this->rebuild_modules();
}
if(!$this->silent){
$current_step++;
@@ -1879,65 +1982,15 @@ function disable($base_dir){
die("No manifest.php Defined In $this->base_dir/manifest.php");
}
}
- function enable_vardef($to_module){
- if(isset($this->installdefs['vardefs'])){
- foreach($this->installdefs['vardefs'] as $vardefs){
- $GLOBALS['log']->debug("Enabling Vardefs ..." .$to_module);
- $path = 'custom/Extension/modules/' . $to_module. '/Ext/Vardefs';
- if($to_module == 'application'){
- $path ='custom/Extension/' . $to_module. '/Ext/Vardefs';
- }
- if(!file_exists($path)){
- mkdir_recursive($path, true);
- }
- if (file_exists($path . '/'.DISABLED_PATH.'/'. $this->id_name . '.php'))
- rename($path . '/'.DISABLED_PATH.'/'. $this->id_name . '.php', $path . '/'. $this->id_name . '.php');
- if (file_exists($path . '/'.DISABLED_PATH.'/'. basename($vardefs['from'])))
- rename($path . '/'.DISABLED_PATH.'/'. basename($vardefs['from']), $path . '/'. basename($vardefs['from']));
- }
- }
- }
- function enable_vardefs(){
- if(isset($this->installdefs['vardefs'])){
- foreach($this->installdefs['vardefs'] as $vardefs){
- $vardefs['from'] = str_replace('<basepath>', $this->base_dir, $vardefs['from']);
- $GLOBALS['log']->debug("Enabling Vardefs ..." . $vardefs['from'] . " for " .$vardefs['to_module']);
- $path = 'custom/Extension/modules/' . $vardefs['to_module']. '/Ext/Vardefs';
- if($vardefs['to_module'] == 'application'){
- $path ='custom/Extension/' . $vardefs['to_module']. '/Ext/Vardefs';
- }
- if(file_exists($path . '/'.DISABLED_PATH.'/'. $this->id_name . '.php'))
- rename( $path . '/'.DISABLED_PATH.'/'. $this->id_name . '.php', $path . '/'. $this->id_name . '.php');
-
- if (file_exists($path . '/'.DISABLED_PATH.'/'. basename($vardefs['from'])))
- rename($path . '/'.DISABLED_PATH.'/'. basename($vardefs['from']), $path . '/'. basename($vardefs['from']));
- }
- $this->rebuild_vardefs();
- }
+ function enable_vardef($to_module)
+ {
+ $this->enableExt("vardefs", "Vardefs", $to_module);
}
- function disable_vardefs(){
- $GLOBALS['log']->debug("Disabling Vardefs ".var_export($this->installdefs, true));
- if(isset($this->installdefs['vardefs'])){
- foreach($this->installdefs['vardefs'] as $vardefs){
- $vardefs['from'] = str_replace('<basepath>', $this->base_dir, $vardefs['from']);
- $GLOBALS['log']->debug("Disabling Vardefs ..." . $vardefs['from'] . " for " .$vardefs['to_module']);
- $path = 'custom/Extension/modules/' . $vardefs['to_module']. '/Ext/Vardefs';
- if($vardefs['to_module'] == 'application'){
- $path ='custom/Extension/' . $vardefs['to_module']. '/Ext/Vardefs';
- }
- if(file_exists($path . '/'. $this->id_name . '.php')) {
- mkdir_recursive($path . '/'.DISABLED_PATH, true);
- rename( $path . '/'. $this->id_name . '.php', $path . '/'.DISABLED_PATH.'/'. $this->id_name . '.php');
- }
- if(file_exists($path . '/'. basename($vardefs['from'])))
- {
- mkdir_recursive($path . '/'.DISABLED_PATH, true);
- rename( $path . '/'. basename($vardefs['from']), $path . '/'.DISABLED_PATH.'/'.basename($vardefs['from']));
- }
- }
- $this->rebuild_vardefs();
- }
+
+ function enable_layoutdef($to_module)
+ {
+ $this->enableExt("layoutdefs", "Layoutdefs", $to_module);
}
function enable_relationships(){
@@ -2014,127 +2067,6 @@ function disable_relationships($action = 'disable'){
}
}
- function enable_layoutdefs(){
- if(isset($this->installdefs['layoutdefs'])){
- foreach($this->installdefs['layoutdefs'] as $layoutdefs){
- $this->enable_layoutdef($layoutdefs['to_module'], $this->id_name);
- }
- $this->rebuild_layoutdefs();
- }
- }
- function enable_layoutdef($to_module){
- $GLOBALS['log']->debug("Enabling Layout Defs ..." .$to_module);
- if(isset($this->installdefs['layoutdefs'])){
- foreach($this->installdefs['layoutdefs'] as $layoutdefs){
- $path = 'custom/Extension/modules/' . $to_module. '/Ext/Layoutdefs';
- if($to_module == 'application'){
- $path ='custom/Extension/' . $to_module. '/Ext/Layoutdefs';
- }
- if (file_exists($path . '/'.DISABLED_PATH.'/'. $this->id_name . '.php'))
- {
- rename($path . '/'.DISABLED_PATH.'/'. $this->id_name . '.php', $path . '/'. $this->id_name . '.php');
- }
- if (file_exists($path . '/'.DISABLED_PATH.'/'. basename($layoutdefs['from'])))
- {
- rename($path . '/'.DISABLED_PATH.'/'. basename($layoutdefs['from']), $path . '/'. basename($layoutdefs['from']));
- }
- }
- }
- }
-
- function disable_layoutdefs(){
- if(isset($this->installdefs['layoutdefs'])){
- foreach($this->installdefs['layoutdefs'] as $layoutdefs){
- $layoutdefs['from'] = str_replace('<basepath>', $this->base_dir, $layoutdefs['from']);
- $GLOBALS['log']->debug("Disabling Layoutdefs ..." . $layoutdefs['from'] . " for " .$layoutdefs['to_module']);
- $path = 'custom/Extension/modules/' . $layoutdefs['to_module']. '/Ext/Layoutdefs';
- if($layoutdefs['to_module'] == 'application'){
- $path ='custom/Extension/' . $layoutdefs['to_module']. '/Ext/Layoutdefs';
- }
- if (file_exists($path . '/'. $this->id_name . '.php'))
- {
- mkdir_recursive($path . '/'.DISABLED_PATH, true);
- rename( $path . '/'. $this->id_name . '.php', $path . '/'.DISABLED_PATH.'/'. $this->id_name . '.php');
- }else if (file_exists($path . '/'. basename($layoutdefs['from'])))
- {
- mkdir_recursive($path . '/'.DISABLED_PATH, true);
- rename( $path . '/'. basename($layoutdefs['from']), $path . '/'.DISABLED_PATH.'/'. basename($layoutdefs['from']));
- }
- }
- $this->rebuild_layoutdefs();
- }
- }
-
- function enable_menus(){
- if(isset($this->installdefs['menu'])){
- foreach($this->installdefs['menu'] as $menu){
- $menu['from'] = str_replace('<basepath>', $this->base_dir, $menu['from']);
- $GLOBALS['log']->debug("Enabling Menu ..." . $menu['from']. " for " .$menu['to_module'] );
- $path = 'custom/Extension/modules/' . $menu['to_module']. '/Ext/Menus';
- if($menu['to_module'] == 'application'){
- $path ='custom/Extension/' . $menu['to_module']. '/Ext/Menus';
- }
-
- if(file_exists($path . '/'.DISABLED_PATH.'/'. $this->id_name . '.php')){
- rename($path . '/'.DISABLED_PATH.'/'. $this->id_name . '.php', $path . '/'. $this->id_name . '.php');
- }
-
- }
- $this->rebuild_menus();
- }
-
- }
-
- function disable_menus(){
- if(isset($this->installdefs['menu'])){
- foreach($this->installdefs['menu'] as $menu){
- $menu['from'] = str_replace('<basepath>', $this->base_dir, $menu['from']);
- $GLOBALS['log']->debug("Disabling Menu ..." . $menu['from']. " for " .$menu['to_module'] );
- $path = 'custom/Extension/modules/' . $menu['to_module']. '/Ext/Menus';
- if($menu['to_module'] == 'application'){
- $path ='custom/Extension/' . $menu['to_module']. '/Ext/Menus';
- }
- if (file_exists( $path . '/'. $this->id_name . '.php'))
- {
- mkdir_recursive($path . '/'.DISABLED_PATH, true);
- rename( $path . '/'. $this->id_name . '.php', $path . '/'.DISABLED_PATH.'/'. $this->id_name . '.php');
- }
- }
- $this->rebuild_menus();
- }
- }
-
- function enable_administration(){
- if(isset($this->installdefs['administration'])){
- foreach($this->installdefs['administration'] as $administration){
- $administration['from'] = str_replace('<basepath>', $this->base_dir, $administration['from']);
- $GLOBALS['log']->debug("Installing Administration Section ..." . $administration['from'] );
- $path = 'custom/Extension/modules/Administration/Ext/Administration';
-
- if(file_exists($path . '/'.DISABLED_PATH.'/'. $this->id_name . '.php')){
- rename($path . '/'.DISABLED_PATH.'/'. $this->id_name . '.php', $path . '/'. $this->id_name . '.php');
- }
- }
- $this->rebuild_administration();
- }
-
- }
- function disable_administration(){
- if(isset($this->installdefs['administration'])){
- foreach($this->installdefs['administration'] as $administration){
- $administration['from'] = str_replace('<basepath>', $this->base_dir, $administration['from']);
- $GLOBALS['log']->debug("Uninstalling Administration Section ..." . $administration['from'] );
- $path = 'custom/Extension/modules/Administration/Ext/Administration';
- if (file_exists($path . '/'. $this->id_name . '.php'))
- {
- mkdir_recursive($path . '/'.DISABLED_PATH, true);
- rename( $path . '/'. $this->id_name . '.php', $path . '/'.DISABLED_PATH.'/'. $this->id_name . '.php');
- }
- }
- $this->rebuild_administration();
- }
- }
-
function enable_dashlets(){
if(isset($this->installdefs['dashlets'])){
foreach($this->installdefs['dashlets'] as $cp){
@@ -2168,78 +2100,6 @@ function disable_dashlets(){
}
}
- function enable_languages(){
- $languages = array();
- if(isset($this->installdefs['language'])){
- foreach($this->installdefs['language'] as $packs){
- $languages[$packs['language']] = $packs['language'];
- $packs['from'] = str_replace('<basepath>', $this->base_dir, $packs['from']);
- $GLOBALS['log']->debug("Installing Language Pack ..." . $packs['from'] . " for " .$packs['to_module']);
- $path = 'custom/Extension/modules/' . $packs['to_module']. '/Ext/Language';
- if($packs['to_module'] == 'application'){
- $path ='custom/Extension/' . $packs['to_module']. '/Ext/Language';
- }
-
- if(!file_exists($path)){
- mkdir_recursive($path, true);
- }
- if (file_exists($path.'/'.DISABLED_PATH.'/'.$packs['language'].'.'. $this->id_name . '.php'))
- rename($path.'/'.DISABLED_PATH.'/'.$packs['language'].'.'. $this->id_name . '.php', $path.'/'.$packs['language'].'.'. $this->id_name . '.php');
- }
- $this->rebuild_languages($languages);
- }
- }
-
- function disable_languages(){
- $languages = array();
- if(isset($this->installdefs['language'])){
- foreach($this->installdefs['language'] as $packs){
- $languages[$packs['language']] = $packs['language'];
- $packs['from'] = str_replace('<basepath>', $this->base_dir, $packs['from']);
- $GLOBALS['log']->debug("Uninstalling Language Pack ..." . $packs['from'] . " for " .$packs['to_module']);
- $path = 'custom/Extension/modules/' . $packs['to_module']. '/Ext/Language';
- if($packs['to_module'] == 'application'){
- $path ='custom/Extension/' . $packs['to_module']. '/Ext/Language';
- }
- mkdir_recursive($path . '/'.DISABLED_PATH, true);
- if (file_exists($path.'/'.$packs['language'].'.'. $this->id_name . '.php'))
- rename($path.'/'.$packs['language'].'.'. $this->id_name . '.php', $path.'/'.DISABLED_PATH.'/'.$packs['language'].'.'. $this->id_name . '.php');
-
- }
- $this->rebuild_languages($languages);
- }
- }
-
- function enable_userpage(){
- if(isset($this->installdefs['user_page'])){
- foreach($this->installdefs['user_page'] as $userpage){
- $userpage['from'] = str_replace('<basepath>', $this->base_dir, $userpage['from']);
- $GLOBALS['log']->debug("Installing User Page Section ..." . $userpage['from'] );
- $path = 'custom/Extension/modules/Users/Ext/UserPage';
- if(file_exists($path . '/'.DISABLED_PATH.'/'. $this->id_name . '.php')){
- rename($path . '/'.DISABLED_PATH.'/'. $this->id_name . '.php', $path . '/'. $this->id_name . '.php');
- }
-
- }
- $this->rebuild_userpage();
- }
-
- }
- function disable_userpage(){
- if(isset($this->installdefs['user_page'])){
- foreach($this->installdefs['user_page'] as $userpage){
- $userpage['from'] = str_replace('<basepath>', $this->base_dir, $userpage['from']);
- $GLOBALS['log']->debug("Uninstalling User Page Section ..." . $userpage['from'] );
- $path = 'custom/Extension/modules/Users/Ext/UserPage';
- if (file_exists( $path . '/'. $this->id_name . '.php')) {
- mkdir_recursive($path . '/'.DISABLED_PATH, true);
- rename( $path . '/'. $this->id_name . '.php', $path . '/'.DISABLED_PATH.'/'. $this->id_name . '.php');
- }
- }
- $this->rebuild_userpage();
- }
- }
-
function enable_copy(){
//copy files back onto file system. first perform md5 check to determine if anything has been modified
//here we should just go through the files in the -restore directory and copy those back
@@ -2310,6 +2170,31 @@ public function reset_opcodes()
}
}
+ /**
+ * BC implementation to provide specific calls to extensions
+ */
+ public function __call($name, $args)
+ {
+ $nameparts = explode('_', $name);
+ // name is something_something
+ if(count($nameparts) == 2 && isset($this->extensions[$nameparts[1]])) {
+ $ext = $this->extensions[$nameparts[1]];
+ switch($nameparts[0]) {
+ case 'enable':
+ return $this->enableExt($ext['section'], $ext['extdir']);
+ case 'disable':
+ return $this->disableExt($ext['section'], $ext['extdir']);
+ case 'install':
+ return $this->installExt($ext['section'], $ext['extdir']);
+ case 'uninstall':
+ return $this->uninstallExt($ext['section'], $ext['extdir']);
+ case 'rebuild':
+ return $this->rebuildExt($ext['extdir'], $ext['file']);
+ }
+ }
+ sugar_die("Unknown method ModuleInstaller::$name called");
+ }
+
}
function UpdateSystemTabs($action, $installed_modules){
@@ -2343,9 +2228,6 @@ function UpdateSystemTabs($action, $installed_modules){
default:
break;
}
- }
+ }
}
-
-
-?>
175 ModuleInstall/ModuleScanner.php
View
@@ -1,4 +1,4 @@
-<?php
+<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
/*********************************************************************************
* SugarCRM Community Edition is a customer relationship management program developed by
@@ -53,11 +53,11 @@ class ModuleScanner{
'install_languages'=>'language',
'install_logichooks'=>'logic_hooks',
'post_execute'=>'post_execute',
-
+
);
-
+
private $blackListExempt = array();
-
+
private $validExt = array('png', 'gif', 'jpg', 'css', 'js', 'php', 'txt', 'html', 'htm', 'tpl', 'pdf', 'md5', 'xml');
private $blackList = array(
'popen',
@@ -120,9 +120,9 @@ class ModuleScanner{
'exec',
'system',
'shell_exec',
- 'passthru',
+ 'passthru',
'chgrp',
- 'chmod',
+ 'chmod',
'chwown',
'file_put_contents',
'file',
@@ -133,7 +133,7 @@ class ModuleScanner{
'filemtime',
'fileowner',
'fileperms',
- 'fopen',
+ 'fopen',
'is_executable',
'is_writable',
'is_writeable',
@@ -152,7 +152,7 @@ class ModuleScanner{
'call_user_func',
'call_user_func_array',
'create_function',
-
+
//mutliple files per function call
'copy',
@@ -182,14 +182,14 @@ public function printToWiki(){
echo "'''Default Extensions'''<br>";
foreach($this->validExt as $b){
echo '#' . $b . '<br>';
-
+
}
echo "'''Default Black Listed Functions'''<br>";
foreach($this->blackList as $b){
echo '#' . $b . '<br>';
-
+
}
-
+
}
public function __construct(){
@@ -202,42 +202,42 @@ public function __construct(){
if(!empty($GLOBALS['sugar_config']['moduleInstaller']['validExt'])){
$this->validExt = array_merge($this->validExt, $GLOBALS['sugar_config']['moduleInstaller']['validExt']);
}
-
+
}
private $issues = array();
private $pathToModule = '';
-
+
/**
*returns a list of issues
*/
public function getIssues(){
return $this->issues;
}
-
+
/**
*returns true or false if any issues were found
*/
public function hasIssues(){
return !empty($this->issues);
}
-
+
/**
*Ensures that a file has a valid extension
*/
private function isValidExtension($file){
$file = strtolower($file);
-
+
$extPos = strrpos($file, '.');
//make sure they don't override the files.md5
if($extPos === false || $file == 'files.md5')return false;
$ext = substr($file, $extPos + 1);
return in_array($ext, $this->validExt);
-
+
}
-
+
/**
- *Scans a directory and calls on scan file for each file
+ *Scans a directory and calls on scan file for each file
**/
public function scanDir($path){
static $startPath = '';
@@ -249,21 +249,40 @@ public function scanDir($path){
if(is_dir($next)){
if(substr($e, 0, 1) == '.')continue;
$this->scanDir($next);
- }else{
+ }else{
$issues = $this->scanFile($next);
-
-
+
+
}
}
return true;
}
-
-
+
+ /**
+ * Check if the file contents looks like PHP
+ * @param string $contents File contents
+ * @return boolean
+ */
+ protected function isPHPFile($contents)
+ {
+ if(stripos($contents, '<?php') !== false) return true;
+ for($tag=0;($tag = stripos($contents, '<?', $tag)) !== false;$tag++) {
+ if(strncasecmp(substr($contents, $tag, 13), '<?xml version', 13)) {
+ // <?xml version is OK, skip it
+ $tag++;
+ continue;
+ }
+ // found <?, it's PHP
+ return true;
+ }
+ return false;
+ }
+
/**
- * Given a file it will open it's contents and check if it is a PHP file (not safe to just rely on extensions) if it finds <?php tags it will use the tokenizer to scan the file
- * $var() and ` are always prevented then whatever is in the blacklist.
+ * Given a file it will open it's contents and check if it is a PHP file (not safe to just rely on extensions) if it finds <?php tags it will use the tokenizer to scan the file
+ * $var() and ` are always prevented then whatever is in the blacklist.
* It will also ensure that all files are of valid extension types
- *
+ *
*/
public function scanFile($file){
$issues = array();
@@ -273,8 +292,8 @@ public function scanFile($file){
return $issues;
}
$contents = file_get_contents($file);
- if(stripos($contents,'<?php') === false )return $issues;
- $tokens = token_get_all($contents);
+ if(!$this->isPHPFile($contents)) return $issues;
+ $tokens = @token_get_all($contents);
$checkFunction = false;
$possibleIssue = '';
$lastToken = false;
@@ -285,7 +304,7 @@ public function scanFile($file){
$issues['backtick'] = translate('ML_INVALID_FUNCTION') . " '`'";
case '(':
if($checkFunction)$issues[] = $possibleIssue;
- break;
+ break;
}
$checkFunction = false;
$possibleIssue = '';
@@ -301,8 +320,8 @@ public function scanFile($file){
$token[1] = strtolower($token[1]);
if(!in_array($token[1], $this->blackList))break;
if(in_array($token[1], $this->blackListExempt))break;
- if ($lastToken !== false &&
- ($lastToken[0] == T_NEW || $lastToken[0] == T_OBJECT_OPERATOR || $lastToken[0] == T_DOUBLE_COLON))
+ if ($lastToken !== false &&
+ ($lastToken[0] == T_NEW || $lastToken[0] == T_OBJECT_OPERATOR || $lastToken[0] == T_DOUBLE_COLON))
{
break;
}
@@ -310,7 +329,7 @@ public function scanFile($file){
$checkFunction = true;
$possibleIssue = translate('ML_INVALID_FUNCTION') . ' ' . $token[1] . '()';
break;
-
+
default:
$checkFunction = false;
$possibleIssue = '';
@@ -321,18 +340,18 @@ public function scanFile($file){
$lastToken = $token;
}
}
-
+
}
if(!empty($issues)){
$this->issues['file'][$file] = $issues;
}
-
- return $issues;
+
+ return $issues;
}