diff --git a/administrator/components/com_postinstall/controllers/message.php b/administrator/components/com_postinstall/controllers/message.php index f7c3d3e9a4571..55685a7e1b6f6 100644 --- a/administrator/components/com_postinstall/controllers/message.php +++ b/administrator/components/com_postinstall/controllers/message.php @@ -40,6 +40,30 @@ public function reset() $this->setRedirect('index.php?option=com_postinstall&eid=' . $eid); } + /** + * Hides all post-installation messages of the specified extension. + * + * @return void + * + * @since __DEPLOY_VERSION__ + */ + public function hideAll() + { + /** @var PostinstallModelMessages $model */ + $model = $this->getThisModel(); + + $eid = (int) $model->getState('eid', '700', 'int'); + + if (empty($eid)) + { + $eid = 700; + } + + $model->hideMessages($eid); + + $this->setRedirect('index.php?option=com_postinstall&eid=' . $eid); + } + /** * Executes the action associated with an item. * diff --git a/administrator/components/com_postinstall/models/messages.php b/administrator/components/com_postinstall/models/messages.php index 7228f8d27077b..a08bdc4a33878 100644 --- a/administrator/components/com_postinstall/models/messages.php +++ b/administrator/components/com_postinstall/models/messages.php @@ -37,7 +37,7 @@ public function buildQuery($overrideLimits = false) // Force filter only enabled messages $published = $this->getState('published', 1, 'int'); - $query->where($db->qn('enabled') . ' = ' . $db->q($published)); + $query->where($db->qn('enabled') . ' = ' . (int) $published); return $query; } @@ -59,7 +59,7 @@ public function getExtensionName($eid) $query = $db->getQuery(true) ->select(array('name', 'element', 'client_id')) ->from($db->qn('#__extensions')) - ->where($db->qn('extension_id') . ' = ' . $db->q((int) $eid)); + ->where($db->qn('extension_id') . ' = ' . (int) $eid); $db->setQuery($query, 0, 1); @@ -100,8 +100,30 @@ public function resetMessages($eid) $query = $db->getQuery(true) ->update($db->qn('#__postinstall_messages')) - ->set($db->qn('enabled') . ' = ' . $db->q(1)) - ->where($db->qn('extension_id') . ' = ' . $db->q($eid)); + ->set($db->qn('enabled') . ' = 1') + ->where($db->qn('extension_id') . ' = ' . (int) $eid); + $db->setQuery($query); + + return $db->execute(); + } + + /** + * Hides all messages for an extension + * + * @param integer $eid The extension ID whose messages we'll hide + * + * @return mixed False if we fail, a db cursor otherwise + * + * @since __DEPLOY_VERSION__ + */ + public function hideMessages($eid) + { + $db = $this->getDbo(); + + $query = $db->getQuery(true) + ->update($db->qn('#__postinstall_messages')) + ->set($db->qn('enabled') . ' = 0') + ->where($db->qn('extension_id') . ' = ' . (int) $eid); $db->setQuery($query); return $db->execute(); @@ -420,7 +442,7 @@ public function addPostInstallationMessage(array $options) $query = $db->getQuery(true) ->select('*') ->from($db->qn($tableName)) - ->where($db->qn('extension_id') . ' = ' . $db->q($options['extension_id'])) + ->where($db->qn('extension_id') . ' = ' . (int) $options['extension_id']) ->where($db->qn('type') . ' = ' . $db->q($options['type'])) ->where($db->qn('title_key') . ' = ' . $db->q($options['title_key'])); @@ -449,7 +471,7 @@ public function addPostInstallationMessage(array $options) // Otherwise it's not the same row. Remove the old row before insert a new one. $query = $db->getQuery(true) ->delete($db->qn($tableName)) - ->where($db->q('extension_id') . ' = ' . $db->q($options['extension_id'])) + ->where($db->q('extension_id') . ' = ' . (int) $options['extension_id']) ->where($db->q('type') . ' = ' . $db->q($options['type'])) ->where($db->q('title_key') . ' = ' . $db->q($options['title_key'])); diff --git a/administrator/components/com_postinstall/views/messages/tmpl/default.php b/administrator/components/com_postinstall/views/messages/tmpl/default.php index 4e0f81a6a58df..b9c8b62b51c89 100644 --- a/administrator/components/com_postinstall/views/messages/tmpl/default.php +++ b/administrator/components/com_postinstall/views/messages/tmpl/default.php @@ -27,8 +27,9 @@ JHtml::_('formbehavior.chosen', 'select'); ?> -
+ + extension_options, 'eid', array('onchange' => 'this.form.submit()', 'class' => 'input-xlarge'), 'value', 'text', $this->eid, 'eid'); ?>
diff --git a/administrator/components/com_postinstall/views/messages/view.html.php b/administrator/components/com_postinstall/views/messages/view.html.php index b035633bf936f..86670acf16038 100644 --- a/administrator/components/com_postinstall/views/messages/view.html.php +++ b/administrator/components/com_postinstall/views/messages/view.html.php @@ -44,4 +44,25 @@ protected function onBrowse($tpl = null) return parent::onBrowse($tpl); } + + /** + * Executes on display of the page + * + * @param string $tpl Subtemplate to use + * + * @return boolean Return true to allow rendering of the page + * + * @since __DEPLOY_VERSION__ + */ + protected function onDisplay($tpl = null) + { + $return = parent::onDisplay($tpl); + + if (!empty($this->items)) + { + JToolbarHelper::custom('hideAll', 'unpublish.png', 'unpublish_f2.png', 'COM_POSTINSTALL_HIDE_ALL_MESSAGES', false); + } + + return $return; + } } diff --git a/administrator/language/en-GB/en-GB.com_postinstall.ini b/administrator/language/en-GB/en-GB.com_postinstall.ini index 64b0b109fdbe9..567782e093ac8 100644 --- a/administrator/language/en-GB/en-GB.com_postinstall.ini +++ b/administrator/language/en-GB/en-GB.com_postinstall.ini @@ -7,6 +7,7 @@ COM_POSTINSTALL="Post-installation Messages" COM_POSTINSTALL_BTN_HIDE="Hide this message" COM_POSTINSTALL_BTN_RESET="Reset Messages" COM_POSTINSTALL_CONFIGURATION="Post-installation Messages: Options" +COM_POSTINSTALL_HIDE_ALL_MESSAGES="Hide all messages" COM_POSTINSTALL_LBL_MESSAGES="Post-installation and Upgrade Messages" COM_POSTINSTALL_LBL_NOMESSAGES_DESC="You have read all the messages." COM_POSTINSTALL_LBL_NOMESSAGES_TITLE="No Messages"