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] Post-installation messages UX #38064

Merged
merged 5 commits into from Jun 15, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -74,6 +74,58 @@ public function unpublish()
$this->setRedirect('index.php?option=com_postinstall&eid=' . $eid);
}

/**
* Re-Publishes an archived post-installation message of the specified extension.
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
public function republish()
{
$model = $this->getModel('Messages', '', array('ignore_request' => true));

$id = $this->input->get('id');

$eid = (int) $model->getState('eid', $model->getJoomlaFilesExtensionId());

if (empty($eid))
{
$eid = $model->getJoomlaFilesExtensionId();
}

$model->setState('published', 1);
$model->republishMessage($id);

$this->setRedirect('index.php?option=com_postinstall&eid=' . $eid);
}

/**
* Archives a published post-installation message of the specified extension.
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
public function archive()
{
$model = $this->getModel('Messages', '', array('ignore_request' => true));
brianteeman marked this conversation as resolved.
Show resolved Hide resolved

$id = $this->input->get('id');

$eid = (int) $model->getState('eid', $model->getJoomlaFilesExtensionId());

if (empty($eid))
{
$eid = $model->getJoomlaFilesExtensionId();
}

$model->setState('published', 2);
$model->archiveMessage($id);

$this->setRedirect('index.php?option=com_postinstall&eid=' . $eid);
}

/**
* Executes the action associated with an item.
*
Expand Down
Expand Up @@ -120,6 +120,56 @@ public function unpublishMessage($id)
Factory::getCache()->clean('com_postinstall');
}

/**
* Archives specified post-install message
*
* @param integer $id The message id
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
public function archiveMessage($id)
{
$db = $this->getDbo();
$id = (int) $id;

$query = $db->getQuery(true);
$query
->update($db->quoteName('#__postinstall_messages'))
->set($db->quoteName('enabled') . ' = 2')
->where($db->quoteName('postinstall_message_id') . ' = :id')
->bind(':id', $id, ParameterType::INTEGER);
$db->setQuery($query);
$db->execute();
Factory::getCache()->clean('com_postinstall');
}

/**
* Republishes specified post-install message
*
* @param integer $id The message id
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
public function republishMessage($id)
{
$db = $this->getDbo();
$id = (int) $id;

$query = $db->getQuery(true);
$query
->update($db->quoteName('#__postinstall_messages'))
->set($db->quoteName('enabled') . ' = 1')
->where($db->quoteName('postinstall_message_id') . ' = :id')
->bind(':id', $id, ParameterType::INTEGER);
$db->setQuery($query);
$db->execute();
Factory::getCache()->clean('com_postinstall');
}

/**
* Returns a list of messages from the #__postinstall_messages table
*
Expand All @@ -131,10 +181,9 @@ public function getItems()
{
// Add a forced extension filtering to the list
$eid = (int) $this->getState('eid', $this->getJoomlaFilesExtensionId());
$published = (int) $this->getState('published', 1);

// Build a cache ID for the resulting data object
$cacheId = $eid . '.' . $published;
$cacheId = 'postinstall_messages.' . $eid;

$db = $this->getDatabase();
$query = $db->getQuery(true);
Expand All @@ -161,8 +210,7 @@ public function getItems()
->bind(':eid', $eid, ParameterType::INTEGER);

// Force filter only enabled messages
$query->where($db->quoteName('enabled') . ' = :published')
->bind(':published', $published, ParameterType::INTEGER);
$query->where($db->quoteName('enabled') . ' IN (1,2)');
$db->setQuery($query);

try
Expand Down
61 changes: 41 additions & 20 deletions administrator/components/com_postinstall/tmpl/messages/default.php
Expand Up @@ -26,25 +26,46 @@
</form>

<?php foreach ($this->items as $item) : ?>
<div class="card card-outline-secondary mb-3">
<div class="card-body">
<h3><?php echo Text::_($item->title_key); ?></h3>
<p class="small">
<?php echo Text::sprintf('COM_POSTINSTALL_LBL_SINCEVERSION', $item->version_introduced); ?>
</p>
<div>
<?php echo Text::_($item->description_key); ?>
<?php if ($item->type !== 'message') : ?>
<a href="<?php echo Route::_('index.php?option=com_postinstall&view=messages&task=message.action&id=' . $item->postinstall_message_id . '&' . $this->token . '=1'); ?>" class="btn btn-primary">
<?php echo Text::_($item->action_key); ?>
</a>
<?php endif; ?>
<?php if (Factory::getApplication()->getIdentity()->authorise('core.edit.state', 'com_postinstall')) : ?>
<a href="<?php echo Route::_('index.php?option=com_postinstall&view=messages&task=message.unpublish&id=' . $item->postinstall_message_id . '&' . $this->token . '=1'); ?>" class="btn btn-danger btn-sm">
<?php echo Text::_('COM_POSTINSTALL_BTN_HIDE'); ?>
</a>
<?php endif; ?>
<?php if($item->enabled === 1) : ?>
richard67 marked this conversation as resolved.
Show resolved Hide resolved
<div class="card card-outline-secondary mb-3">
<div class="card-body">
<h3><?php echo Text::_($item->title_key); ?></h3>
<p class="small">
<?php echo Text::sprintf('COM_POSTINSTALL_LBL_SINCEVERSION', $item->version_introduced); ?>
</p>
<div>
<?php echo Text::_($item->description_key); ?>
<?php if ($item->type !== 'message') : ?>
<a href="<?php echo Route::_('index.php?option=com_postinstall&view=messages&task=message.action&id=' . $item->postinstall_message_id . '&' . $this->token . '=1'); ?>" class="btn btn-primary">
<?php echo Text::_($item->action_key); ?>
</a>
<?php endif; ?>
<?php if (Factory::getApplication()->getIdentity()->authorise('core.edit.state', 'com_postinstall')) : ?>
<a href="<?php echo Route::_('index.php?option=com_postinstall&view=messages&task=message.unpublish&id=' . $item->postinstall_message_id . '&' . $this->token . '=1'); ?>" class="btn btn-danger btn-sm">
<?php echo Text::_('COM_POSTINSTALL_BTN_HIDE'); ?>
</a>
<a href="<?php echo Route::_('index.php?option=com_postinstall&view=messages&task=message.archive&id=' . $item->postinstall_message_id . '&' . $this->token . '=1'); ?>" class="btn btn-danger btn-sm">
<?php echo Text::_('COM_POSTINSTALL_BTN_ARCHIVE'); ?>
</a>
<?php endif; ?>
</div>
</div>
</div>
</div>
</div>
<?php elseif($item->enabled === 2) : ?>
richard67 marked this conversation as resolved.
Show resolved Hide resolved
<div class="card card-outline-secondary mb-3">
<div class="card-body">
<h3><?php echo Text::_($item->title_key); ?></h3>
<div>
<?php if (Factory::getApplication()->getIdentity()->authorise('core.edit.state', 'com_postinstall')) : ?>
<a href="<?php echo Route::_('index.php?option=com_postinstall&view=messages&task=message.unpublish&id=' . $item->postinstall_message_id . '&' . $this->token . '=1'); ?>" class="btn btn-danger btn-sm">
<?php echo Text::_('COM_POSTINSTALL_BTN_HIDE'); ?>
</a>
<a href="<?php echo Route::_('index.php?option=com_postinstall&view=messages&task=message.republish&id=' . $item->postinstall_message_id . '&' . $this->token . '=1'); ?>" class="btn btn-success btn-sm">
<?php echo Text::_('COM_POSTINSTALL_BTN_REPUBLISH'); ?>
</a>
<?php endif; ?>
</div>
</div>
</div>
<?php endif; ?>
<?php endforeach; ?>
2 changes: 2 additions & 0 deletions administrator/language/en-GB/com_postinstall.ini
Expand Up @@ -4,7 +4,9 @@
; Note : All ini files need to be saved as UTF-8

COM_POSTINSTALL="Post-installation Messages"
COM_POSTINSTALL_BTN_ARCHIVE="Archive"
COM_POSTINSTALL_BTN_HIDE="Hide this message"
COM_POSTINSTALL_BTN_REPUBLISH="Read Again"
COM_POSTINSTALL_CONFIGURATION="Post-installation Messages: Options"
COM_POSTINSTALL_EMPTYSTATE_BUTTON_ADD="Reset Messages"
COM_POSTINSTALL_EMPTYSTATE_CONTENT="You have read all the messages."
Expand Down