diff --git a/module/VuFind/src/VuFind/Controller/AbstractBase.php b/module/VuFind/src/VuFind/Controller/AbstractBase.php index db3c3733d45230c8f721375e3159433575b45d23..f5afe675596423d645a8ff5430b862b2232bced3 100644 --- a/module/VuFind/src/VuFind/Controller/AbstractBase.php +++ b/module/VuFind/src/VuFind/Controller/AbstractBase.php @@ -385,7 +385,7 @@ class AbstractBase extends AbstractActionController $this->followup()->store($extras, $url); } if (!empty($msg)) { - $this->flashMessenger()->setNamespace('error')->addMessage($msg); + $this->flashMessenger()->addMessage($msg, 'error'); } // Set a flag indicating that we are forcing login: @@ -426,8 +426,7 @@ class AbstractBase extends AbstractActionController // If login failed, store a warning message: if (!$patron) { - $this->flashMessenger()->setNamespace('error') - ->addMessage('Invalid Patron Login'); + $this->flashMessenger()->addMessage('Invalid Patron Login', 'error'); } } else { // If no credentials were provided, try the stored values: diff --git a/module/VuFind/src/VuFind/Controller/AbstractRecord.php b/module/VuFind/src/VuFind/Controller/AbstractRecord.php index f3cd99935d3a8a8ad4e179ce81d07cfa94722310..7c3cc7aa35fce7e6eb278220301336f4412b899f 100644 --- a/module/VuFind/src/VuFind/Controller/AbstractRecord.php +++ b/module/VuFind/src/VuFind/Controller/AbstractRecord.php @@ -131,11 +131,9 @@ class AbstractRecord extends AbstractBase $driver->getUniqueId(), $driver->getResourceSource(), true, $driver ); $resource->addComment($comment, $user); - $this->flashMessenger()->setNamespace('success') - ->addMessage('add_comment_success'); + $this->flashMessenger()->addMessage('add_comment_success', 'success'); } else { - $this->flashMessenger()->setNamespace('error') - ->addMessage('add_comment_fail_blank'); + $this->flashMessenger()->addMessage('add_comment_fail_blank', 'error'); } return $this->redirectToRecord('', 'UserComments'); @@ -155,11 +153,9 @@ class AbstractRecord extends AbstractBase $id = $this->params()->fromQuery('delete'); $table = $this->getTable('Comments'); if (!is_null($id) && $table->deleteIfOwnedByUser($id, $user)) { - $this->flashMessenger()->setNamespace('success') - ->addMessage('delete_comment_success'); + $this->flashMessenger()->addMessage('delete_comment_success', 'success'); } else { - $this->flashMessenger()->setNamespace('error') - ->addMessage('delete_comment_failure'); + $this->flashMessenger()->addMessage('delete_comment_failure', 'error'); } return $this->redirectToRecord('', 'UserComments'); } @@ -188,8 +184,8 @@ class AbstractRecord extends AbstractBase if ($tags = $this->params()->fromPost('tag')) { $tagParser = $this->getServiceLocator()->get('VuFind\Tags'); $driver->addTags($user, $tagParser->parse($tags)); - $this->flashMessenger()->setNamespace('success') - ->addMessage(['msg' => 'add_tag_success']); + $this->flashMessenger() + ->addMessage(['msg' => 'add_tag_success'], 'success'); return $this->redirectToRecord(); } @@ -222,13 +218,12 @@ class AbstractRecord extends AbstractBase // Save tags, if any: if ($tag = $this->params()->fromPost('tag')) { $driver->deleteTags($user, [$tag]); - $this->flashMessenger()->setNamespace('success') - ->addMessage( - [ - 'msg' => 'tags_deleted', - 'tokens' => ['%count%' => 1] - ] - ); + $this->flashMessenger()->addMessage( + [ + 'msg' => 'tags_deleted', + 'tokens' => ['%count%' => 1] + ], 'success' + ); } return $this->redirectToRecord(); @@ -286,8 +281,7 @@ class AbstractRecord extends AbstractBase $driver->saveToFavorites($post, $user); // Display a success status message: - $this->flashMessenger()->setNamespace('success') - ->addMessage('bulk_save_success'); + $this->flashMessenger()->addMessage('bulk_save_success', 'success'); // redirect to followup url saved in saveAction if ($url = $this->getFollowupUrl()) { @@ -412,12 +406,10 @@ class AbstractRecord extends AbstractBase $view->to, $view->from, $view->message, $driver, $this->getViewRenderer(), $view->subject, $cc ); - $this->flashMessenger()->setNamespace('success') - ->addMessage('email_success'); + $this->flashMessenger()->addMessage('email_success', 'success'); return $this->redirectToRecord(); } catch (MailException $e) { - $this->flashMessenger()->setNamespace('error') - ->addMessage($e->getMessage()); + $this->flashMessenger()->addMessage($e->getMessage(), 'error'); } } @@ -456,12 +448,10 @@ class AbstractRecord extends AbstractBase ['driver' => $driver, 'to' => $view->to] ); $sms->text($view->provider, $view->to, null, $body); - $this->flashMessenger()->setNamespace('success') - ->addMessage('sms_success'); + $this->flashMessenger()->addMessage('sms_success', 'success'); return $this->redirectToRecord(); } catch (MailException $e) { - $this->flashMessenger()->setNamespace('error') - ->addMessage($e->getMessage()); + $this->flashMessenger()->addMessage($e->getMessage(), 'error'); } } @@ -497,8 +487,8 @@ class AbstractRecord extends AbstractBase $export = $this->getServiceLocator()->get('VuFind\Export'); if (empty($format) || !$export->recordSupportsFormat($driver, $format)) { if (!empty($format)) { - $this->flashMessenger()->setNamespace('error') - ->addMessage('export_invalid_format'); + $this->flashMessenger() + ->addMessage('export_invalid_format', 'error'); } $view->setTemplate('record/export-menu'); return $view; diff --git a/module/VuFind/src/VuFind/Controller/AbstractSearch.php b/module/VuFind/src/VuFind/Controller/AbstractSearch.php index 955150fe9bb19ddbc9da957578624f202051141c..85d166f3b7db70277abb0da1e0169fc3a4bd3dbb 100644 --- a/module/VuFind/src/VuFind/Controller/AbstractSearch.php +++ b/module/VuFind/src/VuFind/Controller/AbstractSearch.php @@ -385,8 +385,7 @@ class AbstractSearch extends AbstractBase $searchTable = $this->getTable('Search'); $search = $searchTable->select(['id' => $searchId])->current(); if (empty($search)) { - $this->flashMessenger()->setNamespace('error') - ->addMessage('advSearchError_notFound'); + $this->flashMessenger()->addMessage('advSearchError_notFound', 'error'); return false; } @@ -394,8 +393,7 @@ class AbstractSearch extends AbstractBase $user = $this->getUser(); $sessId = $this->getServiceLocator()->get('VuFind\SessionManager')->getId(); if ($search->session_id != $sessId && $search->user_id != $user->id) { - $this->flashMessenger()->setNamespace('error') - ->addMessage('advSearchError_noRights'); + $this->flashMessenger()->addMessage('advSearchError_noRights', 'error'); return false; } @@ -408,8 +406,8 @@ class AbstractSearch extends AbstractBase try { $savedSearch->getParams()->convertToAdvancedSearch(); } catch (\Exception $ex) { - $this->flashMessenger()->setNamespace('error') - ->addMessage('advSearchError_notAdvanced'); + $this->flashMessenger() + ->addMessage('advSearchError_notAdvanced', 'error'); return false; } } diff --git a/module/VuFind/src/VuFind/Controller/CartController.php b/module/VuFind/src/VuFind/Controller/CartController.php index 5a6d9f653b1acea236e846248b5d4fee3fc593a6..a4b48af277aed744ec2d6550d5938f90a4765594 100644 --- a/module/VuFind/src/VuFind/Controller/CartController.php +++ b/module/VuFind/src/VuFind/Controller/CartController.php @@ -128,8 +128,7 @@ class CartController extends AbstractBase $msg = $this->translate('bookbag_full_msg') . ". " . $addItems['notAdded'] . " " . $this->translate('items_already_in_bookbag') . "."; - $this->flashMessenger()->setNamespace('info') - ->addMessage($msg); + $this->flashMessenger()->addMessage($msg, 'info'); } } } @@ -229,8 +228,7 @@ class CartController extends AbstractBase ); return $this->redirectToSource('success', 'email_success'); } catch (MailException $e) { - $this->flashMessenger()->setNamespace('error') - ->addMessage($e->getMessage()); + $this->flashMessenger()->addMessage($e->getMessage(), 'error'); } } @@ -312,8 +310,8 @@ class CartController extends AbstractBase // No legal export options? Display a warning: if (empty($view->exportOptions)) { - $this->flashMessenger()->setNamespace('error') - ->addMessage('bulk_export_not_supported'); + $this->flashMessenger() + ->addMessage('bulk_export_not_supported', 'error'); } return $view; } @@ -387,8 +385,7 @@ class CartController extends AbstractBase if ($this->formWasSubmitted('submit')) { $this->favorites() ->saveBulk($this->getRequest()->getPost()->toArray(), $user); - $this->flashMessenger()->setNamespace('success') - ->addMessage('bulk_save_success'); + $this->flashMessenger()->addMessage('bulk_save_success', 'success'); $list = $this->params()->fromPost('list'); if (!empty($list)) { return $this->redirect()->toRoute('userList', ['id' => $list]); @@ -418,9 +415,8 @@ class CartController extends AbstractBase public function redirectToSource($flashNamespace = null, $flashMsg = null) { // Set flash message if requested: - if (!is_null($flashNamespace) && !empty($flashMsg)) { - $this->flashMessenger()->setNamespace($flashNamespace) - ->addMessage($flashMsg); + if (null !== $flashNamespace && !empty($flashMsg)) { + $this->flashMessenger()->addMessage($flashMsg, $flashNamespace); } // If we entered the controller in the expected way (i.e. via the diff --git a/module/VuFind/src/VuFind/Controller/ConfirmController.php b/module/VuFind/src/VuFind/Controller/ConfirmController.php index c6b09e0c27aa20eae294322c1a6c9c4a7ebd47ad..4e856675f890fa807ba49353c218bd63c2e28df5 100644 --- a/module/VuFind/src/VuFind/Controller/ConfirmController.php +++ b/module/VuFind/src/VuFind/Controller/ConfirmController.php @@ -53,8 +53,6 @@ class ConfirmController extends AbstractBase // Assign Flash Messages if (isset($data['messages'])) { - $this->flashMessenger()->setNamespace('info'); - foreach ($data['messages'] as $message) { $flash = (true === is_array($message)) ? [ @@ -62,7 +60,7 @@ class ConfirmController extends AbstractBase 'tokens' => $message['tokens'] ] : $message; - $this->flashMessenger()->addMessage($flash); + $this->flashMessenger()->addMessage($flash, 'info'); } } diff --git a/module/VuFind/src/VuFind/Controller/HoldsTrait.php b/module/VuFind/src/VuFind/Controller/HoldsTrait.php index c48610e17193583da4bd16c76978a0e6174e1632..f1cd573568ecb6f8f7dbfbeb62acf24b965b73d7 100644 --- a/module/VuFind/src/VuFind/Controller/HoldsTrait.php +++ b/module/VuFind/src/VuFind/Controller/HoldsTrait.php @@ -45,8 +45,7 @@ trait HoldsTrait */ public function blockedholdAction() { - $this->flashMessenger()->setNamespace('error') - ->addMessage('hold_error_blocked'); + $this->flashMessenger()->addMessage('hold_error_blocked', 'error'); return $this->redirectToRecord('#top'); } @@ -107,13 +106,12 @@ trait HoldsTrait $gatheredDetails, $extraHoldFields, $requestGroups ); if (!$valid) { - $this->flashMessenger()->setNamespace('error') - ->addMessage('hold_invalid_request_group'); + $this->flashMessenger() + ->addMessage('hold_invalid_request_group', 'error'); } elseif (!$this->holds()->validatePickUpInput( $gatheredDetails['pickUpLocation'], $extraHoldFields, $pickup )) { - $this->flashMessenger()->setNamespace('error') - ->addMessage('hold_invalid_pickup'); + $this->flashMessenger()->addMessage('hold_invalid_pickup', 'error'); } else { // If we made it this far, we're ready to place the hold; // if successful, we will redirect and can stop here. @@ -134,19 +132,18 @@ trait HoldsTrait '%%url%%' => $this->url()->fromRoute('myresearch-holds') ], ]; - $this->flashMessenger()->setNamespace('success') - ->addMessage($msg); + $this->flashMessenger()->addMessage($msg, 'success'); return $this->redirectToRecord('#top'); } else { // Failure: use flash messenger to display messages, stay on // the current form. if (isset($results['status'])) { - $this->flashMessenger()->setNamespace('error') - ->addMessage($results['status']); + $this->flashMessenger() + ->addMessage($results['status'], 'error'); } if (isset($results['sysMessage'])) { - $this->flashMessenger()->setNamespace('error') - ->addMessage($results['sysMessage']); + $this->flashMessenger() + ->addMessage($results['sysMessage'], 'error'); } } } diff --git a/module/VuFind/src/VuFind/Controller/ILLRequestsTrait.php b/module/VuFind/src/VuFind/Controller/ILLRequestsTrait.php index 0436f4094dd0b17b76138e0ff22692479b494e6a..97720e3a9342a4cc7ee8e986873eb31b42f6ba47 100644 --- a/module/VuFind/src/VuFind/Controller/ILLRequestsTrait.php +++ b/module/VuFind/src/VuFind/Controller/ILLRequestsTrait.php @@ -45,8 +45,7 @@ trait ILLRequestsTrait */ public function blockedILLRequestAction() { - $this->flashMessenger()->setNamespace('error') - ->addMessage('ill_request_error_blocked'); + $this->flashMessenger()->addMessage('ill_request_error_blocked', 'error'); return $this->redirectToRecord('#top'); } @@ -112,8 +111,8 @@ trait ILLRequestsTrait // Success: Go to Display ILL Requests if (isset($results['success']) && $results['success'] == true) { - $this->flashMessenger()->setNamespace('success') - ->addMessage('ill_request_place_success'); + $this->flashMessenger() + ->addMessage('ill_request_place_success', 'success'); if ($this->inLightbox()) { return false; } @@ -124,12 +123,12 @@ trait ILLRequestsTrait // Failure: use flash messenger to display messages, stay on // the current form. if (isset($results['status'])) { - $this->flashMessenger()->setNamespace('error') - ->addMessage($results['status']); + $this->flashMessenger() + ->addMessage($results['status'], 'error'); } if (isset($results['sysMessage'])) { - $this->flashMessenger()->setNamespace('error') - ->addMessage($results['sysMessage']); + $this->flashMessenger() + ->addMessage($results['sysMessage'], 'error'); } } } diff --git a/module/VuFind/src/VuFind/Controller/InstallController.php b/module/VuFind/src/VuFind/Controller/InstallController.php index 05fedd3a7488870a6bae278177f8c29b9bee63af..71ee2fb58c28f0bf6985650dbec03a02ea99789a 100644 --- a/module/VuFind/src/VuFind/Controller/InstallController.php +++ b/module/VuFind/src/VuFind/Controller/InstallController.php @@ -258,7 +258,7 @@ class InstallController extends AbstractBase if (!$this->phpVersionIsNewEnough()) { $msg = "VuFind requires PHP version 5.3.3 or newer; you are running " . phpversion() . ". Please upgrade."; - $this->flashMessenger()->setNamespace('error')->addMessage($msg); + $this->flashMessenger()->addMessage($msg, 'error'); $problems++; } @@ -270,7 +270,7 @@ class InstallController extends AbstractBase . " this. For details on how to do this, see " . "http://vufind.org/wiki/vufind2:installation_notes " . "and look at the PHP installation instructions for your platform."; - $this->flashMessenger()->setNamespace('error')->addMessage($msg); + $this->flashMessenger()->addMessage($msg, 'error'); $problems++; } @@ -282,7 +282,7 @@ class InstallController extends AbstractBase . " For details on how to do this, see " . "http://vufind.org/wiki/vufind2:installation_notes " . "and look at the PHP installation instructions for your platform."; - $this->flashMessenger()->setNamespace('error')->addMessage($msg); + $this->flashMessenger()->addMessage($msg, 'error'); $problems++; } @@ -294,7 +294,7 @@ class InstallController extends AbstractBase . " this. For details on how to do this, see " . "http://vufind.org/wiki/vufind2:installation_notes " . "and look at the PHP installation instructions for your platform."; - $this->flashMessenger()->setNamespace('error')->addMessage($msg); + $this->flashMessenger()->addMessage($msg, 'error'); $problems++; } @@ -305,7 +305,7 @@ class InstallController extends AbstractBase . " For details on how to do this, see " . "http://vufind.org/wiki/vufind2:installation_notes " . "and look at the PHP installation instructions for your platform."; - $this->flashMessenger()->setNamespace('error')->addMessage($msg); + $this->flashMessenger()->addMessage($msg, 'error'); $problems++; } @@ -330,20 +330,20 @@ class InstallController extends AbstractBase $skip = $this->params()->fromPost('printsql', 'nope') == 'Skip'; if (!preg_match('/^\w*$/', $view->dbname)) { - $this->flashMessenger()->setNamespace('error') - ->addMessage('Database name must be alphanumeric.'); + $this->flashMessenger() + ->addMessage('Database name must be alphanumeric.', 'error'); } else if (!preg_match('/^\w*$/', $view->dbuser)) { - $this->flashMessenger()->setNamespace('error') - ->addMessage('Database user must be alphanumeric.'); + $this->flashMessenger() + ->addMessage('Database user must be alphanumeric.', 'error'); } else if ($skip || $this->formWasSubmitted('submit')) { $newpass = $this->params()->fromPost('dbpass'); $newpassConf = $this->params()->fromPost('dbpassconfirm'); if ((empty($newpass) || empty($newpassConf))) { - $this->flashMessenger()->setNamespace('error') - ->addMessage('Password fields must not be blank.'); + $this->flashMessenger() + ->addMessage('Password fields must not be blank.', 'error'); } else if ($newpass != $newpassConf) { - $this->flashMessenger()->setNamespace('error') - ->addMessage('Password fields must match.'); + $this->flashMessenger() + ->addMessage('Password fields must match.', 'error'); } else { // Connect to database: $connection = $view->driver . '://' . $view->dbrootuser . ':' @@ -355,11 +355,11 @@ class InstallController extends AbstractBase $db = $this->getServiceLocator()->get('VuFind\DbAdapterFactory') ->getAdapterFromConnectionString("{$connection}/{$dbName}"); } catch (\Exception $e) { - $this->flashMessenger()->setNamespace('error') + $this->flashMessenger() ->addMessage( 'Problem initializing database adapter; ' . 'check for missing ' . $view->driver - . ' library . Details: ' . $e->getMessage() + . ' library . Details: ' . $e->getMessage(), 'error' ); return $view; } @@ -419,8 +419,7 @@ class InstallController extends AbstractBase } return $this->redirect()->toRoute('install-home'); } catch (\Exception $e) { - $this->flashMessenger()->setNamespace('error') - ->addMessage($e->getMessage()); + $this->flashMessenger()->addMessage($e->getMessage(), 'error'); } } } @@ -729,7 +728,7 @@ class InstallController extends AbstractBase $userConfirmation = $this->params()->fromPost('fix-user-table', 'Unset'); if ($userConfirmation == 'No') { $msg = 'Security upgrade aborted.'; - $this->flashMessenger()->setNamespace('error')->addMessage($msg); + $this->flashMessenger()->addMessage($msg, 'error'); return $this->redirect()->toRoute('install-home'); } @@ -788,7 +787,7 @@ class InstallController extends AbstractBase } } $msg = count($rows) . ' user row(s) encrypted.'; - $this->flashMessenger()->setNamespace('info')->addMessage($msg); + $this->flashMessenger()->addMessage($msg, 'info'); } return $this->redirect()->toRoute('install-home'); } diff --git a/module/VuFind/src/VuFind/Controller/LibraryCardsController.php b/module/VuFind/src/VuFind/Controller/LibraryCardsController.php index 5c99e5e1bc5a1d4f2a9cca8ded0c5b8e97f1d20b..4b5ac6632d16c9b60b03690f2ed72fdf60b5b097 100644 --- a/module/VuFind/src/VuFind/Controller/LibraryCardsController.php +++ b/module/VuFind/src/VuFind/Controller/LibraryCardsController.php @@ -163,8 +163,7 @@ class LibraryCardsController extends AbstractBase $user->deleteLibraryCard($cardID); // Success Message - $this->flashMessenger()->setNamespace('success') - ->addMessage('Library Card Deleted'); + $this->flashMessenger()->addMessage('Library Card Deleted', 'success'); // Redirect to MyResearch library cards return $this->redirect()->toRoute('librarycards-home'); } @@ -217,8 +216,8 @@ class LibraryCardsController extends AbstractBase $password = $this->params()->fromPost('password', ''); if (!$username || !$password) { - $this->flashMessenger()->setNamespace('error') - ->addMessage('authentication_error_blank'); + $this->flashMessenger() + ->addMessage('authentication_error_blank', 'error'); return false; } @@ -230,8 +229,8 @@ class LibraryCardsController extends AbstractBase $catalog = $this->getILS(); $patron = $catalog->patronLogin($username, $password); if (!$patron) { - $this->flashMessenger()->setNamespace('error') - ->addMessage('authentication_error_invalid'); + $this->flashMessenger() + ->addMessage('authentication_error_invalid', 'error'); return false; } @@ -241,8 +240,7 @@ class LibraryCardsController extends AbstractBase $id == 'NEW' ? null : $id, $cardName, $username, $password ); } catch(\VuFind\Exception\LibraryCard $e) { - $this->flashMessenger()->setNamespace('error') - ->addMessage($e->getMessage()); + $this->flashMessenger()->addMessage($e->getMessage(), 'error'); return false; } diff --git a/module/VuFind/src/VuFind/Controller/MissingrecordController.php b/module/VuFind/src/VuFind/Controller/MissingrecordController.php index de95dddfab1c193e948f4888c8b667c8626bfb6c..a2d746dd080ecb616032c484caa4eff304aa7bf7 100644 --- a/module/VuFind/src/VuFind/Controller/MissingrecordController.php +++ b/module/VuFind/src/VuFind/Controller/MissingrecordController.php @@ -45,8 +45,7 @@ class MissingrecordController extends AbstractBase */ public function homeAction() { - $this->flashMessenger()->setNamespace('error') - ->addMessage('Cannot find record'); + $this->flashMessenger()->addMessage('Cannot find record', 'error'); return $this->createViewModel(); } } diff --git a/module/VuFind/src/VuFind/Controller/MyResearchController.php b/module/VuFind/src/VuFind/Controller/MyResearchController.php index 4b11239b007180b71b8c803a3c922daff5315b19..32b0fbaaefbf9bd431f8dad0fb36ca6448b73e35 100644 --- a/module/VuFind/src/VuFind/Controller/MyResearchController.php +++ b/module/VuFind/src/VuFind/Controller/MyResearchController.php @@ -63,7 +63,7 @@ class MyResearchController extends AbstractBase ) { $msg = 'authentication_error_loggedout'; } - $this->flashMessenger()->setNamespace('error')->addMessage($msg); + $this->flashMessenger()->addMessage($msg, 'error'); } /** @@ -169,8 +169,7 @@ class MyResearchController extends AbstractBase $this->getAuthManager()->create($this->getRequest()); return $this->forwardTo('MyResearch', 'Home'); } catch (AuthException $e) { - $this->flashMessenger()->setNamespace('error') - ->addMessage($e->getMessage()); + $this->flashMessenger()->addMessage($e->getMessage(), 'error'); } } else { // If we are not processing a submission, we need to simply display @@ -285,12 +284,10 @@ class MyResearchController extends AbstractBase $search = $this->getTable('Search'); if (($id = $this->params()->fromQuery('save', false)) !== false) { $search->setSavedFlag($id, true, $user->id); - $this->flashMessenger()->setNamespace('success') - ->addMessage('search_save_success'); + $this->flashMessenger()->addMessage('search_save_success', 'success'); } else if (($id = $this->params()->fromQuery('delete', false)) !== false) { $search->setSavedFlag($id, false); - $this->flashMessenger()->setNamespace('success') - ->addMessage('search_unsave_success'); + $this->flashMessenger()->addMessage('search_unsave_success', 'success'); } else { throw new \Exception('Missing save and delete parameters.'); } @@ -326,8 +323,7 @@ class MyResearchController extends AbstractBase if (!empty($homeLibrary)) { $user->changeHomeLibrary($homeLibrary); $this->getAuthManager()->updateSession($user); - $this->flashMessenger()->setNamespace('success') - ->addMessage('profile_update'); + $this->flashMessenger()->addMessage('profile_update', 'success'); } // Begin building view object: @@ -401,16 +397,14 @@ class MyResearchController extends AbstractBase ? $this->params()->fromPost('ids') : $this->params()->fromPost('idsAll'); if (!is_array($ids) || empty($ids)) { - $this->flashMessenger()->setNamespace('error') - ->addMessage('bulk_noitems_advice'); + $this->flashMessenger()->addMessage('bulk_noitems_advice', 'error'); return $this->redirect()->toUrl($newUrl); } // Process the deletes if necessary: if ($this->formWasSubmitted('submit')) { $this->favorites()->delete($ids, $listID, $user); - $this->flashMessenger()->setNamespace('success') - ->addMessage('fav_delete_success'); + $this->flashMessenger()->addMessage('fav_delete_success', 'success'); return $this->redirect()->toUrl($newUrl); } @@ -460,13 +454,12 @@ class MyResearchController extends AbstractBase $table = $this->getTable('UserList'); $list = $table->getExisting($listID); $list->removeResourcesById($user, [$id], $source); - $this->flashMessenger()->setNamespace('success') - ->addMessage('Item removed from list'); + $this->flashMessenger()->addMessage('Item removed from list', 'success'); } else { // ...My Favorites $user->removeResourcesById([$id], $source); - $this->flashMessenger()->setNamespace('success') - ->addMessage('Item removed from favorites'); + $this->flashMessenger() + ->addMessage('Item removed from favorites', 'success'); } // All done -- return true to indicate success. @@ -503,8 +496,7 @@ class MyResearchController extends AbstractBase if ($addToList > -1) { $driver->saveToFavorites(['list' => $addToList], $user); } - $this->flashMessenger()->setNamespace('success') - ->addMessage('edit_list_success'); + $this->flashMessenger()->addMessage('edit_list_success', 'success'); $newUrl = is_null($listID) ? $this->url()->fromRoute('myresearch-favorites') @@ -722,8 +714,7 @@ class MyResearchController extends AbstractBase switch(get_class($e)) { case 'VuFind\Exception\ListPermission': case 'VuFind\Exception\MissingField': - $this->flashMessenger()->setNamespace('error') - ->addMessage($e->getMessage()); + $this->flashMessenger()->addMessage($e->getMessage(), 'error'); return false; case 'VuFind\Exception\LoginRequired': return $this->forceLogin(); @@ -801,8 +792,7 @@ class MyResearchController extends AbstractBase $list->delete($this->getUser()); // Success Message - $this->flashMessenger()->setNamespace('success') - ->addMessage('fav_list_delete'); + $this->flashMessenger()->addMessage('fav_list_delete', 'success'); } catch (\Exception $e) { switch(get_class($e)) { case 'VuFind\Exception\LoginRequired': @@ -1167,8 +1157,7 @@ class MyResearchController extends AbstractBase // Make sure we're configured to do this $this->setUpAuthenticationFromRequest(); if (!$this->getAuthManager()->supportsRecovery()) { - $this->flashMessenger()->setNamespace('error') - ->addMessage('recovery_disabled'); + $this->flashMessenger()->addMessage('recovery_disabled', 'error'); return $this->redirect()->toRoute('myresearch-home'); } if ($this->getUser()) { @@ -1191,8 +1180,8 @@ class MyResearchController extends AbstractBase if ($user) { $this->sendRecoveryEmail($user, $this->getConfig()); } else { - $this->flashMessenger()->setNamespace('error') - ->addMessage('recovery_user_not_found'); + $this->flashMessenger() + ->addMessage('recovery_user_not_found', 'error'); } } return $view; @@ -1210,8 +1199,7 @@ class MyResearchController extends AbstractBase { // If we can't find a user if (null == $user) { - $this->flashMessenger()->setNamespace('error') - ->addMessage('recovery_user_not_found'); + $this->flashMessenger()->addMessage('recovery_user_not_found', 'error'); } else { // Make sure we've waiting long enough $hashtime = $this->getHashAge($user->verify_hash); @@ -1219,8 +1207,7 @@ class MyResearchController extends AbstractBase ? $config->Authentication->recover_interval : 60; if (time() - $hashtime < $recoveryInterval) { - $this->flashMessenger()->setNamespace('error') - ->addMessage('recovery_too_soon'); + $this->flashMessenger()->addMessage('recovery_too_soon', 'error'); } else { // Attempt to send the email try { @@ -1245,11 +1232,10 @@ class MyResearchController extends AbstractBase $this->translate('recovery_email_subject'), $message ); - $this->flashMessenger()->setNamespace('success') - ->addMessage('recovery_email_sent'); + $this->flashMessenger() + ->addMessage('recovery_email_sent', 'success'); } catch (MailException $e) { - $this->flashMessenger()->setNamespace('error') - ->addMessage($e->getMessage()); + $this->flashMessenger()->addMessage($e->getMessage(), 'error'); } } } @@ -1271,8 +1257,8 @@ class MyResearchController extends AbstractBase ? $config->Authentication->recover_hash_lifetime : 1209600; // Two weeks if (time() - $hashtime > $hashLifetime) { - $this->flashMessenger()->setNamespace('error') - ->addMessage('recovery_expired_hash'); + $this->flashMessenger() + ->addMessage('recovery_expired_hash', 'error'); return $this->forwardTo('MyResearch', 'Login'); } else { $table = $this->getTable('User'); @@ -1292,8 +1278,7 @@ class MyResearchController extends AbstractBase } } } - $this->flashMessenger()->setNamespace('error') - ->addMessage('recovery_invalid_hash'); + $this->flashMessenger()->addMessage('recovery_invalid_hash', 'error'); return $this->forwardTo('MyResearch', 'Login'); } @@ -1326,14 +1311,13 @@ class MyResearchController extends AbstractBase } // Missing or invalid hash if (false == $userFromHash) { - $this->flashMessenger()->setNamespace('error') - ->addMessage('recovery_user_not_found'); + $this->flashMessenger()->addMessage('recovery_user_not_found', 'error'); // Force login or restore hash $post->username = false; return $this->forwardTo('MyResearch', 'Recover'); } elseif ($userFromHash->username !== $post->username) { - $this->flashMessenger()->setNamespace('error') - ->addMessage('authentication_error_invalid'); + $this->flashMessenger() + ->addMessage('authentication_error_invalid', 'error'); $userFromHash->updateHash(); $view->username = $userFromHash->username; $view->hash = $userFromHash->verify_hash; @@ -1351,8 +1335,8 @@ class MyResearchController extends AbstractBase $valid = false; } if (!$valid) { - $this->flashMessenger()->setNamespace('error') - ->addMessage('authentication_error_invalid'); + $this->flashMessenger() + ->addMessage('authentication_error_invalid', 'error'); $view->verifyold = true; return $view; } @@ -1361,8 +1345,7 @@ class MyResearchController extends AbstractBase try { $user = $this->getAuthManager()->updatePassword($this->getRequest()); } catch (AuthException $e) { - $this->flashMessenger()->setNamespace('error') - ->addMessage($e->getMessage()); + $this->flashMessenger()->addMessage($e->getMessage(), 'error'); return $view; } // Update hash to prevent reusing hash @@ -1370,8 +1353,7 @@ class MyResearchController extends AbstractBase // Login $this->getAuthManager()->login($this->request); // Go to favorites - $this->flashMessenger()->setNamespace('success') - ->addMessage('new_password_success'); + $this->flashMessenger()->addMessage('new_password_success', 'success'); return $this->redirect()->toRoute('myresearch-home'); } @@ -1387,8 +1369,7 @@ class MyResearchController extends AbstractBase } // If not submitted, are we logged in? if (!$this->getAuthManager()->supportsPasswordChange()) { - $this->flashMessenger()->setNamespace('error') - ->addMessage('recovery_new_disabled'); + $this->flashMessenger()->addMessage('recovery_new_disabled', 'error'); return $this->redirect()->toRoute('home'); } $view = $this->createViewModel($this->params()->fromPost()); diff --git a/module/VuFind/src/VuFind/Controller/Plugin/Holds.php b/module/VuFind/src/VuFind/Controller/Plugin/Holds.php index d00b0928653e90963959b4dd51ff0cffd0f1d083..ecb2d1b2d95afb9dd52ebfd5fd1fb80c1af38f3d 100644 --- a/module/VuFind/src/VuFind/Controller/Plugin/Holds.php +++ b/module/VuFind/src/VuFind/Controller/Plugin/Holds.php @@ -129,8 +129,7 @@ class Holds extends AbstractRequestBase // If the user input contains a value not found in the session // whitelist, something has been tampered with -- abort the process. if (!in_array($info, $this->getSession()->validIds)) { - $flashMsg->setNamespace('error') - ->addMessage('error_inconsistent_parameters'); + $flashMsg->addMessage('error_inconsistent_parameters', 'error'); return []; } } @@ -140,21 +139,21 @@ class Holds extends AbstractRequestBase ['details' => $details, 'patron' => $patron] ); if ($cancelResults == false) { - $flashMsg->setNamespace('error')->addMessage('hold_cancel_fail'); + $flashMsg->addMessage('hold_cancel_fail', 'error'); } else { if ($cancelResults['count'] > 0) { // TODO : add a mechanism for inserting tokens into translated // messages so we can avoid a double translation here. $msg = $this->getController() ->translate('hold_cancel_success_items'); - $flashMsg->setNamespace('success')->addMessage( - $cancelResults['count'] . ' ' . $msg + $flashMsg->addMessage( + $cancelResults['count'] . ' ' . $msg, 'success' ); } return $cancelResults; } } else { - $flashMsg->setNamespace('error')->addMessage('hold_empty_selection'); + $flashMsg->addMessage('hold_empty_selection', 'error'); } return []; } diff --git a/module/VuFind/src/VuFind/Controller/Plugin/ILLRequests.php b/module/VuFind/src/VuFind/Controller/Plugin/ILLRequests.php index ce4d69e531954297907620f752c1eb6b5a740c4a..840581e38303514655d0d1da52794a2e096a6c97 100644 --- a/module/VuFind/src/VuFind/Controller/Plugin/ILLRequests.php +++ b/module/VuFind/src/VuFind/Controller/Plugin/ILLRequests.php @@ -143,8 +143,7 @@ class ILLRequests extends AbstractRequestBase // If the user input contains a value not found in the session // whitelist, something has been tampered with -- abort the process. if (!in_array($info, $this->getSession()->validIds)) { - $flashMsg->setNamespace('error') - ->addMessage('error_inconsistent_parameters'); + $flashMsg->addMessage('error_inconsistent_parameters', 'error'); return []; } } @@ -154,9 +153,7 @@ class ILLRequests extends AbstractRequestBase ['details' => $details, 'patron' => $patron] ); if ($cancelResults == false) { - $flashMsg->setNamespace('error')->addMessage( - 'ill_request_cancel_fail' - ); + $flashMsg->addMessage('ill_request_cancel_fail', 'error'); } else { if ($cancelResults['count'] > 0) { // TODO : add a mechanism for inserting tokens into translated @@ -164,16 +161,14 @@ class ILLRequests extends AbstractRequestBase $msg = $this->getController()->translate( 'ill_request_cancel_success_items' ); - $flashMsg->setNamespace('success')->addMessage( - $cancelResults['count'] . ' ' . $msg + $flashMsg->addMessage( + $cancelResults['count'] . ' ' . $msg, 'success' ); } return $cancelResults; } } else { - $flashMsg->setNamespace('error')->addMessage( - 'ill_request_empty_selection' - ); + $flashMsg->addMessage('ill_request_empty_selection', 'error'); } return []; } diff --git a/module/VuFind/src/VuFind/Controller/Plugin/NewItems.php b/module/VuFind/src/VuFind/Controller/Plugin/NewItems.php index 2a48d52974420e52129fa24e91e1522d7c44a5d9..118cb545c24fac9afd34544f102c33536ac9c39f 100644 --- a/module/VuFind/src/VuFind/Controller/Plugin/NewItems.php +++ b/module/VuFind/src/VuFind/Controller/Plugin/NewItems.php @@ -86,7 +86,7 @@ class NewItems extends AbstractPlugin $limit = $params->getQueryIDLimit(); if (count($bibIDs) > $limit) { $bibIDs = array_slice($bibIDs, 0, $limit); - $flash->setNamespace('info')->addMessage('too_many_new_items'); + $flash->addMessage('too_many_new_items', 'info'); } return $bibIDs; diff --git a/module/VuFind/src/VuFind/Controller/Plugin/Recaptcha.php b/module/VuFind/src/VuFind/Controller/Plugin/Recaptcha.php index 88d49b257a62093e799f87ee9a6031511de5a56d..7aeb62f07c2225920744a60a3bb8382e1b6c88f1 100644 --- a/module/VuFind/src/VuFind/Controller/Plugin/Recaptcha.php +++ b/module/VuFind/src/VuFind/Controller/Plugin/Recaptcha.php @@ -127,8 +127,8 @@ class Recaptcha extends AbstractPlugin $captchaPassed = $response && $response->isValid(); if (!$captchaPassed) { if ($this->errorMode == 'flash') { - $this->getController()->flashMessenger()->setNamespace('error') - ->addMessage('recaptcha_not_passed'); + $this->getController()->flashMessenger() + ->addMessage('recaptcha_not_passed', 'error'); } else { throw new \Exception('recaptcha_not_passed'); } diff --git a/module/VuFind/src/VuFind/Controller/Plugin/Renewals.php b/module/VuFind/src/VuFind/Controller/Plugin/Renewals.php index d3ac6d9e6a40a769c2512444f6a464e24f72b795..d8761edcfe1983b44c4ab4e176a1284dc07d3485 100644 --- a/module/VuFind/src/VuFind/Controller/Plugin/Renewals.php +++ b/module/VuFind/src/VuFind/Controller/Plugin/Renewals.php @@ -105,7 +105,7 @@ class Renewals extends AbstractPlugin && is_array($renewResult['blocks']) ) { foreach ($renewResult['blocks'] as $block) { - $flashMsg->setNamespace('info')->addMessage($block); + $flashMsg->addMessage($block, 'info'); } } @@ -113,11 +113,11 @@ class Renewals extends AbstractPlugin return $renewResult['details']; } else { // System failure: - $flashMsg->setNamespace('error')->addMessage('renew_error'); + $flashMsg->addMessage('renew_error', 'error'); } } else if (!empty($all) || !empty($selected)) { // Button was clicked but no items were selected: - $flashMsg->setNamespace('error')->addMessage('renew_empty_selection'); + $flashMsg->addMessage('renew_empty_selection', 'error'); } return []; diff --git a/module/VuFind/src/VuFind/Controller/Plugin/StorageRetrievalRequests.php b/module/VuFind/src/VuFind/Controller/Plugin/StorageRetrievalRequests.php index 74326488b163922f9f9021004b48858f7b8cd7a0..3db780ef50d994a711889279cca51932185d3f09 100644 --- a/module/VuFind/src/VuFind/Controller/Plugin/StorageRetrievalRequests.php +++ b/module/VuFind/src/VuFind/Controller/Plugin/StorageRetrievalRequests.php @@ -143,8 +143,7 @@ class StorageRetrievalRequests extends AbstractRequestBase // If the user input contains a value not found in the session // whitelist, something has been tampered with -- abort the process. if (!in_array($info, $this->getSession()->validIds)) { - $flashMsg->setNamespace('error') - ->addMessage('error_inconsistent_parameters'); + $flashMsg->addMessage('error_inconsistent_parameters', 'error'); return []; } } @@ -154,9 +153,8 @@ class StorageRetrievalRequests extends AbstractRequestBase ['details' => $details, 'patron' => $patron] ); if ($cancelResults == false) { - $flashMsg->setNamespace('error')->addMessage( - 'storage_retrieval_request_cancel_fail' - ); + $flashMsg + ->addMessage('storage_retrieval_request_cancel_fail', 'error'); } else { if ($cancelResults['count'] > 0) { // TODO : add a mechanism for inserting tokens into translated @@ -164,16 +162,15 @@ class StorageRetrievalRequests extends AbstractRequestBase $msg = $this->getController()->translate( 'storage_retrieval_request_cancel_success_items' ); - $flashMsg->setNamespace('success')->addMessage( - $cancelResults['count'] . ' ' . $msg + $flashMsg->addMessage( + $cancelResults['count'] . ' ' . $msg, 'success' ); } return $cancelResults; } } else { - $flashMsg->setNamespace('error')->addMessage( - 'storage_retrieval_request_empty_selection' - ); + $flashMsg + ->addMessage('storage_retrieval_request_empty_selection', 'error'); } return []; } diff --git a/module/VuFind/src/VuFind/Controller/SearchController.php b/module/VuFind/src/VuFind/Controller/SearchController.php index 086f23b7c130a557060ffaea7e0be642ba721425..27a5056cdb728a2839e29a4d9037de643842e53e 100644 --- a/module/VuFind/src/VuFind/Controller/SearchController.php +++ b/module/VuFind/src/VuFind/Controller/SearchController.php @@ -123,12 +123,10 @@ class SearchController extends AbstractSearch $view->to, $view->from, $view->message, $view->url, $this->getViewRenderer(), $view->subject, $cc ); - $this->flashMessenger()->setNamespace('success') - ->addMessage('email_success'); + $this->flashMessenger()->addMessage('email_success', 'success'); return $this->redirect()->toUrl($view->url); } catch (MailException $e) { - $this->flashMessenger()->setNamespace('error') - ->addMessage($e->getMessage()); + $this->flashMessenger()->addMessage($e->getMessage(), 'error'); } } return $view; @@ -452,8 +450,7 @@ class SearchController extends AbstractSearch ->getQueryIDLimit(); if (count($bibIDs) > $limit) { $bibIDs = array_slice($bibIDs, 0, $limit); - $this->flashMessenger()->setNamespace('info') - ->addMessage('too_many_reserves'); + $this->flashMessenger()->addMessage('too_many_reserves', 'info'); } // Use standard search action with override parameter to show results: diff --git a/module/VuFind/src/VuFind/Controller/StorageRetrievalRequestsTrait.php b/module/VuFind/src/VuFind/Controller/StorageRetrievalRequestsTrait.php index f24affa0853258936ad5d15adcebbf0dd75bb918..28ca30f16312c79bbca4652a0582c3a5317a0d54 100644 --- a/module/VuFind/src/VuFind/Controller/StorageRetrievalRequestsTrait.php +++ b/module/VuFind/src/VuFind/Controller/StorageRetrievalRequestsTrait.php @@ -45,8 +45,8 @@ trait StorageRetrievalRequestsTrait */ public function blockedStorageRetrievalRequestAction() { - $this->flashMessenger()->setNamespace('error') - ->addMessage('storage_retrieval_request_error_blocked'); + $this->flashMessenger() + ->addMessage('storage_retrieval_request_error_blocked', 'error'); return $this->redirectToRecord('#top'); } @@ -112,8 +112,9 @@ trait StorageRetrievalRequestsTrait // Success: Go to Display Storage Retrieval Requests if (isset($results['success']) && $results['success'] == true) { - $this->flashMessenger()->setNamespace('success') - ->addMessage('storage_retrieval_request_place_success'); + $this->flashMessenger()->addMessage( + 'storage_retrieval_request_place_success', 'success' + ); if ($this->inLightbox()) { return false; } @@ -124,12 +125,11 @@ trait StorageRetrievalRequestsTrait // Failure: use flash messenger to display messages, stay on // the current form. if (isset($results['status'])) { - $this->flashMessenger()->setNamespace('error') - ->addMessage($results['status']); + $this->flashMessenger()->addMessage($results['status'], 'error'); } if (isset($results['sysMessage'])) { - $this->flashMessenger()->setNamespace('error') - ->addMessage($results['sysMessage']); + $this->flashMessenger() + ->addMessage($results['sysMessage'], 'error'); } } } diff --git a/module/VuFind/src/VuFind/Controller/UpgradeController.php b/module/VuFind/src/VuFind/Controller/UpgradeController.php index 86cab730e63b82f1e5f4c5c6b8175760fa2e74eb..872481a570bce4c73bf80368e69f6c9ade95978c 100644 --- a/module/VuFind/src/VuFind/Controller/UpgradeController.php +++ b/module/VuFind/src/VuFind/Controller/UpgradeController.php @@ -175,20 +175,20 @@ class UpgradeController extends AbstractBase // Block upgrade when encountering common errors: if (empty($this->cookie->oldVersion)) { - $this->flashMessenger()->setNamespace('error') - ->addMessage('Cannot determine source version.'); + $this->flashMessenger() + ->addMessage('Cannot determine source version.', 'error'); unset($this->cookie->oldVersion); return $this->forwardTo('Upgrade', 'Error'); } if (empty($this->cookie->newVersion)) { - $this->flashMessenger()->setNamespace('error') - ->addMessage('Cannot determine destination version.'); + $this->flashMessenger() + ->addMessage('Cannot determine destination version.', 'error'); unset($this->cookie->newVersion); return $this->forwardTo('Upgrade', 'Error'); } if ($this->cookie->newVersion == $this->cookie->oldVersion) { - $this->flashMessenger()->setNamespace('error') - ->addMessage('Cannot upgrade version to itself.'); + $this->flashMessenger() + ->addMessage('Cannot upgrade version to itself.', 'error'); unset($this->cookie->newVersion); return $this->forwardTo('Upgrade', 'Error'); } @@ -221,8 +221,9 @@ class UpgradeController extends AbstractBase } catch (\Exception $e) { $extra = is_a($e, 'VuFind\Exception\FileAccess') ? ' Check file permissions.' : ''; - $this->flashMessenger()->setNamespace('error') - ->addMessage('Config upgrade failed: ' . $e->getMessage() . $extra); + $this->flashMessenger()->addMessage( + 'Config upgrade failed: ' . $e->getMessage() . $extra, 'error' + ); return $this->forwardTo('Upgrade', 'Error'); } } @@ -391,8 +392,9 @@ class UpgradeController extends AbstractBase return $this->forwardTo('Upgrade', 'FixDuplicateTags'); } } catch (\Exception $e) { - $this->flashMessenger()->setNamespace('error') - ->addMessage('Database upgrade failed: ' . $e->getMessage()); + $this->flashMessenger()->addMessage( + 'Database upgrade failed: ' . $e->getMessage(), 'error' + ); return $this->forwardTo('Upgrade', 'Error'); } @@ -449,8 +451,9 @@ class UpgradeController extends AbstractBase $this->session->dbRootPass = $pass; return $this->forwardTo('Upgrade', 'FixDatabase'); } catch (\Exception $e) { - $this->flashMessenger()->setNamespace('error') - ->addMessage('Could not connect; please try again.'); + $this->flashMessenger()->addMessage( + 'Could not connect; please try again.', 'error' + ); } } } @@ -493,14 +496,14 @@ class UpgradeController extends AbstractBase if ($this->formWasSubmitted('submit')) { $user = $this->params()->fromPost('username'); if (empty($user)) { - $this->flashMessenger()->setNamespace('error') - ->addMessage('Username must not be empty.'); + $this->flashMessenger() + ->addMessage('Username must not be empty.', 'error'); } else { $userTable = $this->getTable('User'); $user = $userTable->getByUsername($user, false); if (empty($user) || !is_object($user) || !isset($user->id)) { - $this->flashMessenger()->setNamespace('error') - ->addMessage("User {$user} not found."); + $this->flashMessenger() + ->addMessage("User {$user} not found.", 'error'); } else { $table = $this->getTable('ResourceTags'); $table->assignAnonymousTags($user->id); @@ -598,12 +601,13 @@ class UpgradeController extends AbstractBase $dir = $this->params()->fromPost('sourcedir'); if (!empty($dir)) { if (!is_dir($dir)) { - $this->flashMessenger()->setNamespace('error') - ->addMessage($dir . ' does not exist.'); + $this->flashMessenger() + ->addMessage($dir . ' does not exist.', 'error'); } else if (!file_exists($dir . '/build.xml')) { - $this->flashMessenger()->setNamespace('error')->addMessage( + $this->flashMessenger()->addMessage( 'Could not find build.xml in source directory;' - . ' upgrade does not support VuFind versions prior to 1.1.' + . ' upgrade does not support VuFind versions prior to 1.1.', + 'error' ); } else { $this->cookie->sourceDir = rtrim($dir, '\/'); @@ -629,11 +633,12 @@ class UpgradeController extends AbstractBase $this->cookie->newVersion = $this->getVersion(realpath(APPLICATION_PATH)); if (floor($version) != 2) { - $this->flashMessenger()->setNamespace('error') - ->addMessage('Illegal version number.'); + $this->flashMessenger() + ->addMessage('Illegal version number.', 'error'); } else if ($version >= $this->cookie->newVersion) { - $this->flashMessenger()->setNamespace('error')->addMessage( - "Source version must be less than {$this->cookie->newVersion}." + $this->flashMessenger()->addMessage( + "Source version must be less than {$this->cookie->newVersion}.", + 'error' ); } else { $this->cookie->oldVersion = $version; @@ -700,8 +705,7 @@ class UpgradeController extends AbstractBase (array)$this->session->warnings ); foreach ($allWarnings as $warning) { - $this->flashMessenger()->setNamespace('info') - ->addMessage($warning); + $this->flashMessenger()->addMessage($warning, 'info'); } return $this->createViewModel( diff --git a/module/VuFind/src/VuFind/View/Helper/Root/Flashmessages.php b/module/VuFind/src/VuFind/View/Helper/Root/Flashmessages.php index 3c37c2f173daf4e796de8f8a9eac5860ad795cf0..287ab727d71e0dd8966a8c08215c7039f0a1c3b6 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/Flashmessages.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/Flashmessages.php @@ -78,9 +78,8 @@ class Flashmessages extends AbstractHelper $html = ''; $namespaces = ['error', 'info', 'success']; foreach ($namespaces as $ns) { - $this->fm->setNamespace($ns); $messages = array_merge( - $this->fm->getMessages(), $this->fm->getCurrentMessages() + $this->fm->getMessages($ns), $this->fm->getCurrentMessages($ns) ); foreach (array_unique($messages, SORT_REGULAR) as $msg) { $html .= '<div class="' . $this->getClassForNamespace($ns) . '">'; @@ -108,8 +107,8 @@ class Flashmessages extends AbstractHelper } $html .= '</div>'; } - $this->fm->clearMessages(); - $this->fm->clearCurrentMessages(); + $this->fm->clearMessages($ns); + $this->fm->clearCurrentMessages($ns); } return $html; } diff --git a/module/VuFind/src/VuFind/View/Helper/Root/Recaptcha.php b/module/VuFind/src/VuFind/View/Helper/Root/Recaptcha.php index 7d324e90a14a7cd16b9fc64cca058a040583190b..a9ac553126f36419b01792d0de5579129d23edc8 100644 --- a/module/VuFind/src/VuFind/View/Helper/Root/Recaptcha.php +++ b/module/VuFind/src/VuFind/View/Helper/Root/Recaptcha.php @@ -26,7 +26,7 @@ * @link http://vufind.org/wiki/vufind2:developer_manual Wiki */ namespace VuFind\View\Helper\Root; -use Zend\View\Helper\AbstractHelper, Zend\Mvc\Controller\Plugin\FlashMessenger; +use Zend\View\Helper\AbstractHelper; /** * Recaptcha view helper diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/Controller/Plugin/NewItemsTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/Controller/Plugin/NewItemsTest.php index 9395d29c6d4cdb1940b270e688ad5a08f8647832..3a3c6be689ac0fae394d5358f43ab48d6ba390d2 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/Controller/Plugin/NewItemsTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/Controller/Plugin/NewItemsTest.php @@ -67,10 +67,8 @@ class NewItemsTest extends TestCase public function testGetBibIDsFromCatalogWithIDLimit() { $flash = $this->getMock('Zend\Mvc\Controller\Plugin\FlashMessenger'); - $flash->expects($this->once())->method('setNamespace') - ->with($this->equalTo('info'))->will($this->returnValue($flash)); $flash->expects($this->once())->method('addMessage') - ->with($this->equalTo('too_many_new_items')); + ->with($this->equalTo('too_many_new_items'), $this->equalTo('info')); $config = new Config(['result_pages' => 10]); $newItems = new NewItems($config); $bibs = $newItems->getBibIDsFromCatalog( diff --git a/module/VuFindAdmin/src/VuFindAdmin/Controller/ConfigController.php b/module/VuFindAdmin/src/VuFindAdmin/Controller/ConfigController.php index 85332d425909490ad606487cf95c9902794e299e..d72702db6b04fca84b357ae9947e2c89cfad144d 100644 --- a/module/VuFindAdmin/src/VuFindAdmin/Controller/ConfigController.php +++ b/module/VuFindAdmin/src/VuFindAdmin/Controller/ConfigController.php @@ -65,21 +65,19 @@ class ConfigController extends AbstractAdmin $writer = new \VuFind\Config\Writer($configFile); $writer->set('System', 'autoConfigure', 1); if ($writer->save()) { - $this->flashMessenger()->setNamespace('success') - ->addMessage('Auto-configuration enabled.'); + $this->flashMessenger() + ->addMessage('Auto-configuration enabled.', 'success'); // Reload config now that it has been edited (otherwise, old setting // will persist in cache): $this->getServiceLocator()->get('VuFind\Config')->reload('config'); } else { - $this->flashMessenger()->setNamespace('error') - ->addMessage( - 'Could not enable auto-configuration; check permissions on ' - . $configFile . '.' - ); + $this->flashMessenger()->addMessage( + 'Could not enable auto-configuration; check permissions on ' + . $configFile . '.', 'error' + ); } return $this->forwardTo('AdminConfig', 'Home'); } -} - +} \ No newline at end of file diff --git a/module/VuFindAdmin/src/VuFindAdmin/Controller/MaintenanceController.php b/module/VuFindAdmin/src/VuFindAdmin/Controller/MaintenanceController.php index 7e8246d1ddce85165f6478dd62ec4b63e4cb71a3..14e5ff4d9c4f06b36e13a4bfdab9c6631c66b6ef 100644 --- a/module/VuFindAdmin/src/VuFindAdmin/Controller/MaintenanceController.php +++ b/module/VuFindAdmin/src/VuFindAdmin/Controller/MaintenanceController.php @@ -66,8 +66,7 @@ class MaintenanceController extends AbstractAdmin // If cache is unset, we didn't go through the loop above, so no message // needs to be displayed. if (isset($cache)) { - $this->flashMessenger()->setNamespace('success') - ->addMessage('Cache(s) cleared.'); + $this->flashMessenger()->addMessage('Cache(s) cleared.', 'success'); } return $this->forwardTo('AdminMaintenance', 'Home'); } @@ -120,13 +119,12 @@ class MaintenanceController extends AbstractAdmin { $daysOld = intval($this->params()->fromQuery('daysOld', $minAge)); if ($daysOld < $minAge) { - $this->flashMessenger()->setNamespace('error') - ->addMessage( - str_replace( - '%%age%%', $minAge, - 'Expiration age must be at least %%age%% days.' - ) - ); + $this->flashMessenger()->addMessage( + str_replace( + '%%age%%', $minAge, + 'Expiration age must be at least %%age%% days.' + ), 'error' + ); } else { $search = $this->getTable($table); if (!method_exists($search, 'getExpiredQuery')) { @@ -139,7 +137,7 @@ class MaintenanceController extends AbstractAdmin $search->delete($query); $msg = str_replace('%%count%%', $count, $successString); } - $this->flashMessenger()->setNamespace('success')->addMessage($msg); + $this->flashMessenger()->addMessage($msg, 'success'); } return $this->forwardTo('AdminMaintenance', 'Home'); } diff --git a/module/VuFindAdmin/src/VuFindAdmin/Controller/TagsController.php b/module/VuFindAdmin/src/VuFindAdmin/Controller/TagsController.php index edd8fc7b1d52729a1540a11f3adf8861952a0366..9509916f5676ef4da01667f286e39bf2ae5f5b87 100644 --- a/module/VuFindAdmin/src/VuFindAdmin/Controller/TagsController.php +++ b/module/VuFindAdmin/src/VuFindAdmin/Controller/TagsController.php @@ -162,8 +162,7 @@ class TagsController extends AbstractAdmin : $this->params()->fromPost('idsAll'); if (!is_array($ids) || empty($ids)) { - $this->flashMessenger()->setNamespace('error') - ->addMessage('bulk_noitems_advice'); + $this->flashMessenger()->addMessage('bulk_noitems_advice', 'error'); return $this->redirect()->toUrl($originUrl); } @@ -175,18 +174,16 @@ class TagsController extends AbstractAdmin } if (0 == $delete) { - $this->flashMessenger()->setNamespace('error') - ->addMessage('tags_delete_fail'); + $this->flashMessenger()->addMessage('tags_delete_fail', 'error'); return $this->redirect()->toUrl($originUrl); } - $this->flashMessenger()->setNamespace('success') - ->addMessage( - [ - 'msg' => 'tags_deleted', - 'tokens' => ['%count%' => $delete] - ] - ); + $this->flashMessenger()->addMessage( + [ + 'msg' => 'tags_deleted', + 'tokens' => ['%count%' => $delete] + ], 'success' + ); return $this->redirect()->toUrl($originUrl); }