Changeset 3007:f9d013776723 for inc
- Timestamp:
- 06/05/15 15:56:08 (10 years ago)
- Branch:
- default
- Location:
- inc
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
inc/admin/lib.moduleslist.php
r2997 r3007 672 672 echo 673 673 '<td class="module-desc maximal">'.html::escapeHTML(__($module['desc'])); 674 if (in_array('deps', $cols)) { 675 676 if (isset($module['disable_also'])) { 677 echo 678 '<br/><span class="info">'.__('Disabling or removing this plugin will also disable the following plugins: '). 679 join(',',$module['disable_also']).'</span>'; 674 if (isset($module['cannot_disable']) && $module['enabled']) { 675 echo 676 '<br/><span class="info">'. 677 sprintf(__('This module cannot be disabled nor deleted, since the following modules are also enabled : %s'), 678 join(',',$module['cannot_disable'])). 679 '</span>'; 680 } 681 if (isset($module['cannot_enable']) && !$module['enabled']) { 682 echo 683 '<br/><span class="info">'. 684 __('This module cannot be enabled, because of the following reasons :'). 685 '<ul>'; 686 foreach ($module['cannot_enable'] as $m=>$reason) { 687 echo '<li>'.$reason.'</li>'; 680 688 } 689 echo '</ul>'. 690 '</span>'; 681 691 } 682 692 echo '</td>'; … … 815 825 816 826 # Deactivate 817 case 'activate': if ($this->core->auth->isSuperAdmin() && $module['root_writable'] ) {827 case 'activate': if ($this->core->auth->isSuperAdmin() && $module['root_writable'] && !isset($module['cannot_enable'])) { 818 828 $submits[] = 819 829 '<input type="submit" name="activate['.html::escapeHTML($id).']" value="'.__('Activate').'" />'; … … 821 831 822 832 # Activate 823 case 'deactivate': if ($this->core->auth->isSuperAdmin() && $module['root_writable'] ) {833 case 'deactivate': if ($this->core->auth->isSuperAdmin() && $module['root_writable'] && !isset($module['cannot_disable'])) { 824 834 $submits[] = 825 835 '<input type="submit" name="deactivate['.html::escapeHTML($id).']" value="'.__('Deactivate').'" class="reset" />'; … … 827 837 828 838 # Delete 829 case 'delete': if ($this->core->auth->isSuperAdmin() && $this->isDeletablePath($module['root']) ) {839 case 'delete': if ($this->core->auth->isSuperAdmin() && $this->isDeletablePath($module['root'])&& !isset($module['cannot_disable'])) { 830 840 $dev = !preg_match('!^'.$this->path_pattern.'!', $module['root']) && defined('DC_DEV') && DC_DEV ? ' debug' : ''; 831 841 $submits[] = -
inc/core/class.dc.modules.php
r2997 r3007 52 52 } 53 53 54 54 /** 55 * Checks all modules dependencies 56 * Fills in the following information in module : 57 * * cannot_enable : list reasons why module cannot be enabled. Not set if module can be enabled 58 * * cannot_disable : list reasons why module cannot be disabled. Not set if module can be disabled 59 * * implies : reverse dependencies 60 * @return array list of enabled modules with unmet dependencies, and that must be disabled. 61 */ 55 62 public function checkDependencies() { 56 63 $to_disable = array(); 57 64 foreach ($this->all_modules as $k => &$m) { 58 65 if (isset($m['requires'])) { 66 $missing = array(); 59 67 foreach ($m['requires'] as &$dep) { 60 $missing = array();61 68 if (!is_array($dep)) { 62 69 $dep = array($dep); 63 70 } 71 // grab missing dependencies 64 72 if (!isset($this->all_modules[$dep[0]])) { 65 73 // module not present 66 $missing[$dep[0]] = true; 67 } elseif (count($dep)>1 && version_compare($m['version'],$dep[1],'<')) { 74 $missing[$dep[0]] = sprintf(__("Requires module %s which is not installed"), $dep[0]); 75 } elseif ((count($dep)>1) && version_compare($this->all_modules[$dep[0]]['version'],$dep[1])==-1) { 76 echo "bla:".version_compare($this->all_modules[$dep[0]]['version'],$dep[1],'<'); 68 77 // module present, but version missing 69 $missing[$dep[0]] = $dep[1]; 78 $missing[$dep[0]] = sprintf(__("Requires module %s version %s, but version %s is installed"), $dep[0],$dep[1],$m['version']); 79 } elseif (!$this->all_modules[$dep[0]]['enabled']) { 80 // module disabled 81 $missing[$dep[0]] = sprintf(__("Requires module %s which is disabled"), $dep[0]); 70 82 } 71 if (count($missing)) { 72 $m['errors']=$missing; 73 $to_disable[]=$k; 74 } else { 75 $this->all_modules[$dep[0]]['disable_also'][]=$k; 76 $m['require_enable'][]=$dep[0]; 77 if (!$this->all_modules[$dep[0]]['enabled']) { 78 $to_disable[]=$k; 79 } 83 $this->all_modules[$dep[0]]['implies'][]=$k; 84 } 85 if (count($missing)) { 86 $m['cannot_enable']=$missing; 87 if ($m['enabled']) { 88 $to_disable[]=array('name' => $k,'reason'=> $missing); 80 89 } 81 90 } 82 91 } 83 92 } 93 // Check modules that cannot be disabled 94 foreach ($this->modules as $k => &$m) { 95 if (isset($m['implies']) && $m['enabled']) { 96 foreach ($m['implies'] as $im) { 97 if (isset($this->all_modules[$im]) && $this->all_modules[$im]['enabled']) { 98 $m['cannot_disable'][]=$im; 99 } 100 } 101 } 102 } 103 return $to_disable; 84 104 } 85 105
Note: See TracChangeset
for help on using the changeset viewer.