Skip to content

Commit

Permalink
Dev: Allow plugins to set message when success is false
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Apr 26, 2016
1 parent 31590f2 commit ef2957b
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions application/controllers/admin/pluginmanager.php
Expand Up @@ -103,7 +103,16 @@ public function activate($id)
$iStatus = 1;
} else
{
Yii::app()->user->setFlash('error', gT('Failed to activate the plugin.'));
$customMessage = $result->get('message');
if ($customMessage)
{
Yii::app()->user->setFlash('error', $customMessage);
}
else
{
Yii::app()->user->setFlash('error', gT('Failed to activate the plugin.'));
}

$this->getController()->redirect(array('admin/pluginmanager/sa/index/'));
}
}
Expand Down Expand Up @@ -139,7 +148,16 @@ public function deactivate($id)
$iStatus = 0;
} else
{
Yii::app()->user->setFlash('error', gT('Failed to deactivate the plugin.'));
$customMessage = $result->get('message');
if ($customMessage)
{
Yii::app()->user->setFlash('error', $customMessage);
}
else
{
Yii::app()->user->setFlash('error', gT('Failed to activate the plugin.'));
}

$this->getController()->redirect(array('admin/pluginmanager/sa/index/'));
}
}
Expand Down

1 comment on commit ef2957b

@Shnoulle
Copy link
Collaborator

@Shnoulle Shnoulle commented on ef2957b Apr 27, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, attention with App()->user->setFlash : it allow only one flashMessage of each type. Then you can loose information.
It's the reason why App()->setFlashMessage was added : to allow to show multiple flasj message of same and different type.

There are discussion about this in Yii : http://www.yiiframework.com/wiki/111/using-setflash-for-displaying-various-kind-of-messages/ . And bootstrap include an extension for this (follow links on previous link)

PS : ee7e746 : adding core function here : multiple error aren't show before (or break DB save)

Please sign in to comment.