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 #2488

Closed
jgerman-bot opened this issue Jun 16, 2022 · 0 comments · Fixed by #2490
Closed

[4.2] Post-installation messages UX #2488

jgerman-bot opened this issue Jun 16, 2022 · 0 comments · Fixed by #2490

Comments

@jgerman-bot
Copy link

New language relevant PR in upstream repo: joomla/joomla-cms#38064 Here are the upstream changes:

Click to expand the diff!
diff --git a/administrator/components/com_postinstall/src/Controller/MessageController.php b/administrator/components/com_postinstall/src/Controller/MessageController.php
index a1684fbce51f..ff2fc8e82453 100644
--- a/administrator/components/com_postinstall/src/Controller/MessageController.php
+++ b/administrator/components/com_postinstall/src/Controller/MessageController.php
@@ -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));
+
+		$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.
 	 *
diff --git a/administrator/components/com_postinstall/src/Model/MessagesModel.php b/administrator/components/com_postinstall/src/Model/MessagesModel.php
index 79286558bf4d..99fcfd0218c0 100644
--- a/administrator/components/com_postinstall/src/Model/MessagesModel.php
+++ b/administrator/components/com_postinstall/src/Model/MessagesModel.php
@@ -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
 	 *
@@ -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);
@@ -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
diff --git a/administrator/components/com_postinstall/tmpl/messages/default.php b/administrator/components/com_postinstall/tmpl/messages/default.php
index 0cd1ea645508..cb7fd12316a7 100644
--- a/administrator/components/com_postinstall/tmpl/messages/default.php
+++ b/administrator/components/com_postinstall/tmpl/messages/default.php
@@ -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) : ?>
+		<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) : ?>
+		<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; ?>
diff --git a/administrator/language/en-GB/com_postinstall.ini b/administrator/language/en-GB/com_postinstall.ini
index b9472b3bb7ec..872d92be45f0 100644
--- a/administrator/language/en-GB/com_postinstall.ini
+++ b/administrator/language/en-GB/com_postinstall.ini
@@ -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."
tecpromotion added a commit to tecpromotion/joomla that referenced this issue Jun 16, 2022
@tecpromotion tecpromotion linked a pull request Jun 16, 2022 that will close this issue
heelc29 added a commit that referenced this issue Jun 16, 2022
* add two new strings

* fix #2488

* Update administrator/language/de-DE/com_postinstall.ini

Co-authored-by: heelc29 <66922325+heelc29@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

3 participants