diff --git a/administrator/components/com_postinstall/src/Controller/MessageController.php b/administrator/components/com_postinstall/src/Controller/MessageController.php index a1684fbce51fc..ff2fc8e82453e 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 79286558bf4d2..99fcfd0218c02 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 0cd1ea645508e..cb7fd12316a7c 100644 --- a/administrator/components/com_postinstall/tmpl/messages/default.php +++ b/administrator/components/com_postinstall/tmpl/messages/default.php @@ -26,25 +26,46 @@ items as $item) : ?> -
-
-

title_key); ?>

-

- version_introduced); ?> -

-
- description_key); ?> - type !== 'message') : ?> - - action_key); ?> - - - getIdentity()->authorise('core.edit.state', 'com_postinstall')) : ?> - - - - + enabled === 1) : ?> +
+
+

title_key); ?>

+

+ version_introduced); ?> +

+
+ description_key); ?> + type !== 'message') : ?> + + action_key); ?> + + + getIdentity()->authorise('core.edit.state', 'com_postinstall')) : ?> + + + + + + + +
+
-
-
+ enabled === 2) : ?> +
+
+

title_key); ?>

+
+ getIdentity()->authorise('core.edit.state', 'com_postinstall')) : ?> + + + + + + + +
+
+
+ diff --git a/administrator/language/en-GB/com_postinstall.ini b/administrator/language/en-GB/com_postinstall.ini index b9472b3bb7ec7..872d92be45f0c 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."