Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.2] [UX] Reset hidden postinstallation messages #37423

Closed
wants to merge 12 commits into from
Expand Up @@ -188,6 +188,23 @@ public function getItems()
return $result;
}

/**
* Get hidden messages
*
* @return array the hidden messages
*
* @since __DEPLOY_VERSION__
*/
public function getHidden(): array
{
$initial = (int) $this->getState('published', 1);
$this->setState('published', 0);
$result = $this->getItems();
$this->setState('published', $initial);

return $result;
}

/**
* Returns a count of all enabled messages from the #__postinstall_messages table
*
Expand Down Expand Up @@ -270,7 +287,7 @@ public function getExtensionName($eid)

$extension = $db->loadObject();

if (!is_object($extension))
if (!\is_object($extension))
{
return '';
}
Expand Down Expand Up @@ -378,7 +395,7 @@ protected function onProcessList(&$resultArray)
{
require_once $file;

$result = call_user_func($item->condition_method);
$result = \call_user_func($item->condition_method);

if ($result === false)
{
Expand All @@ -392,7 +409,7 @@ protected function onProcessList(&$resultArray)
{
$hash = $item->language_client_id . '-' . $item->language_extension;

if (!in_array($hash, $language_extensions))
if (!\in_array($hash, $language_extensions))
{
$language_extensions[] = $hash;
Factory::getApplication()->getLanguage()->load($item->language_extension, $item->language_client_id == 0 ? JPATH_SITE : JPATH_ADMINISTRATOR);
Expand Down Expand Up @@ -510,7 +527,7 @@ public function getComponentOptions()
public function addPostInstallationMessage(array $options)
{
// Make sure there are options set
if (!is_array($options))
if (!\is_array($options))
{
throw new \Exception('Post-installation message definitions must be of type array', 500);
}
Expand Down Expand Up @@ -565,7 +582,7 @@ public function addPostInstallationMessage(array $options)
}

// Make sure there's a valid type
if (!in_array($options['type'], array('message', 'link', 'action')))
if (!\in_array($options['type'], array('message', 'link', 'action')))
{
throw new \Exception('Post-installation message definitions need to declare a type of message, link or action', 500);
}
Expand Down
Expand Up @@ -40,6 +40,7 @@ public function display($tpl = null)
$model = $this->getModel();

$this->items = $model->getItems();
$this->hidden = $model->getHidden();

if (!\count($this->items))
{
Expand Down Expand Up @@ -78,6 +79,11 @@ private function toolbar()
if (!empty($this->items))
{
$toolbar->unpublish('message.hideAll', 'COM_POSTINSTALL_HIDE_ALL_MESSAGES');

if (!empty($this->hidden))
{
$toolbar->standardButton('refresh', 'COM_POSTINSTALL_EMPTYSTATE_BUTTON_ADD', 'message.reset');
}
}

// Options button.
Expand Down