Commit 7e57c87d authored by Côme Chilliet's avatar Côme Chilliet
Browse files

Fixes #5466 Added a conflict system

parent 83977fd8
......@@ -604,24 +604,14 @@ class msgPool {
*
* \param array $depends Contains all the settings disabled
*/
public static function featuresDisabled($name, $depends = "")
public static function featuresDisabled($name, array $depends = array(), array $conflicts = array())
{
if (($depends == "") || (is_array($depends) && count($depends) == 0)) {
return sprintf(_("This account has %s settings disabled. You can enable them by clicking below."), $name);
if (empty($depends) && empty($conflicts)) {
return sprintf(_('This account has %s settings disabled. You can enable them by clicking below.'), $name);
} elseif (!empty($depends)) {
return sprintf(_('This account has %s settings disabled. To enable them, you\'ll need to add the %s settings first!'), $name, implode(' / ', $depends));
} else {
if (count($depends) == 1) {
if (is_array($depends)) {
$depends = $depends[0];
}
return sprintf(_("This account has %s settings disabled. To enable them, you'll need to add the %s settings first!"), $name, $depends);
} else {
$deps = "";
foreach ($depends as $dep) {
$deps .= "$dep / ";
}
$deps = preg_replace("/ \/ $/", "", $deps);
return sprintf(_("This account has %s settings disabled. To enable them, you'll need to add the %s settings first!"), $name, $deps);
}
return sprintf(_('This account has %s settings disabled. To enable them, you\'ll need to disable the %s settings first!'), $name, implode(' / ', $conflicts));
}
}
......
......@@ -64,8 +64,9 @@ class pluglist {
$classes = get_declared_classes();
$index = 0;
$depends_infos = array();
$foreign_refs = array();
$depends_infos = array();
$conflicts_infos = array();
$foreign_refs = array();
foreach ($classes as $cname) {
$cmethods = get_class_methods($cname);
if (in_array_ics('plInfo', $cmethods)) {
......@@ -86,6 +87,9 @@ class pluglist {
if (isset($infos['plDepends'])) {
$depends_infos[] = $cname;
}
if (isset($infos['plConflicts'])) {
$conflicts_infos[] = $cname;
}
if (isset($infos['plForeignKeys'])) {
foreach ($infos['plForeignKeys'] as $ofield => &$pfks) {
if (!is_array($pfks)) {
......@@ -153,6 +157,19 @@ class pluglist {
}
}
}
foreach ($conflicts_infos as $cname) {
foreach ($this->info[$cname]['plConflicts'] as $conflict) {
if (isset($this->info[$conflict])) {
if (isset($this->info[$conflict]['plConflicts'])) {
if (!in_array($cname, $this->info[$conflict]['plConflicts'])) {
$this->info[$conflict]['plConflicts'][] = $cname;
}
} else {
$this->info[$conflict]['plConflicts'] = array($cname);
}
}
}
}
foreach ($foreign_refs as $cname => $refs) {
$this->info[$cname]['plForeignRefs'] = $refs;
}
......
......@@ -683,8 +683,9 @@ class simplePlugin
/* Show tab dialog headers */
$plInfo = pluglist::pluginInfos(get_class($this));
if ($this->parent !== NULL) {
$disabled = $this->acl_skip_write();
$depends = array();
$disabled = $this->acl_skip_write();
$depends = array();
$conflicts = array();
if ($this->is_account) {
if (isset($plInfo['plDepending'])) {
foreach ($plInfo['plDepending'] as $plugin) {
......@@ -714,9 +715,19 @@ class simplePlugin
}
}
}
if (isset($plInfo['plConflicts'])) {
foreach ($plInfo['plConflicts'] as $plugin) {
if (isset($this->parent->by_object[$plugin]) &&
$this->parent->by_object[$plugin]->is_account) {
$disabled = TRUE;
$conflictPlInfos = pluglist::pluginInfos($plugin);
$conflicts[] = $conflictPlInfos['plShortName'];
}
}
}
$this->header = $this->show_header(
msgPool::addFeaturesButton($plInfo['plShortName']),
msgPool::featuresDisabled($plInfo['plShortName'], $depends),
msgPool::featuresDisabled($plInfo['plShortName'], $depends, $conflicts),
$this->is_account,
$disabled,
get_class($this).'_modify_state'
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment