Changeset 3007:f9d013776723 for inc/core/class.dc.modules.php
- Timestamp:
- 06/05/15 15:56:08 (10 years ago)
- Branch:
- default
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.