From 8d2f561c6aa9bd9202dd14ea21e4e0aa56d4e2f1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Markus=20M=C3=A4chler?= <markus.maechler@bithost.ch>
Date: Mon, 27 Jul 2015 15:31:01 -0400
Subject: [PATCH] Adds success namespace to flash messages - Some CSS
 adjustments to jquerymobile to match.

---
 .../src/VuFind/Controller/AbstractRecord.php  | 14 ++++++-------
 .../src/VuFind/Controller/CartController.php  |  6 +++---
 .../src/VuFind/Controller/HoldsTrait.php      |  3 ++-
 .../VuFind/Controller/ILLRequestsTrait.php    |  2 +-
 .../Controller/LibraryCardsController.php     |  2 +-
 .../Controller/MyResearchController.php       | 20 +++++++++----------
 .../src/VuFind/Controller/Plugin/Holds.php    |  2 +-
 .../VuFind/Controller/Plugin/ILLRequests.php  |  2 +-
 .../Plugin/StorageRetrievalRequests.php       |  2 +-
 .../VuFind/Controller/SearchController.php    |  2 +-
 .../StorageRetrievalRequestsTrait.php         |  2 +-
 .../VuFind/View/Helper/Root/Flashmessages.php |  2 +-
 .../Controller/ConfigController.php           |  2 +-
 .../Controller/MaintenanceController.php      |  4 ++--
 .../VuFindAdmin/Controller/TagsController.php |  2 +-
 themes/jquerymobile/css/styles.css            |  8 ++++++--
 .../templates/myresearch/checkedout.phtml     |  2 +-
 17 files changed, 41 insertions(+), 36 deletions(-)

diff --git a/module/VuFind/src/VuFind/Controller/AbstractRecord.php b/module/VuFind/src/VuFind/Controller/AbstractRecord.php
index f6cd9e6fa36..f3cd99935d3 100644
--- a/module/VuFind/src/VuFind/Controller/AbstractRecord.php
+++ b/module/VuFind/src/VuFind/Controller/AbstractRecord.php
@@ -131,7 +131,7 @@ class AbstractRecord extends AbstractBase
                 $driver->getUniqueId(), $driver->getResourceSource(), true, $driver
             );
             $resource->addComment($comment, $user);
-            $this->flashMessenger()->setNamespace('info')
+            $this->flashMessenger()->setNamespace('success')
                 ->addMessage('add_comment_success');
         } else {
             $this->flashMessenger()->setNamespace('error')
@@ -155,7 +155,7 @@ class AbstractRecord extends AbstractBase
         $id = $this->params()->fromQuery('delete');
         $table = $this->getTable('Comments');
         if (!is_null($id) && $table->deleteIfOwnedByUser($id, $user)) {
-            $this->flashMessenger()->setNamespace('info')
+            $this->flashMessenger()->setNamespace('success')
                 ->addMessage('delete_comment_success');
         } else {
             $this->flashMessenger()->setNamespace('error')
@@ -188,7 +188,7 @@ 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('info')
+            $this->flashMessenger()->setNamespace('success')
                 ->addMessage(['msg' => 'add_tag_success']);
             return $this->redirectToRecord();
         }
@@ -222,7 +222,7 @@ class AbstractRecord extends AbstractBase
         // Save tags, if any:
         if ($tag = $this->params()->fromPost('tag')) {
             $driver->deleteTags($user, [$tag]);
-            $this->flashMessenger()->setNamespace('info')
+            $this->flashMessenger()->setNamespace('success')
                 ->addMessage(
                     [
                         'msg' => 'tags_deleted',
@@ -286,7 +286,7 @@ class AbstractRecord extends AbstractBase
         $driver->saveToFavorites($post, $user);
 
         // Display a success status message:
-        $this->flashMessenger()->setNamespace('info')
+        $this->flashMessenger()->setNamespace('success')
             ->addMessage('bulk_save_success');
 
         // redirect to followup url saved in saveAction
@@ -412,7 +412,7 @@ class AbstractRecord extends AbstractBase
                     $view->to, $view->from, $view->message, $driver,
                     $this->getViewRenderer(), $view->subject, $cc
                 );
-                $this->flashMessenger()->setNamespace('info')
+                $this->flashMessenger()->setNamespace('success')
                     ->addMessage('email_success');
                 return $this->redirectToRecord();
             } catch (MailException $e) {
@@ -456,7 +456,7 @@ class AbstractRecord extends AbstractBase
                     ['driver' => $driver, 'to' => $view->to]
                 );
                 $sms->text($view->provider, $view->to, null, $body);
-                $this->flashMessenger()->setNamespace('info')
+                $this->flashMessenger()->setNamespace('success')
                     ->addMessage('sms_success');
                 return $this->redirectToRecord();
             } catch (MailException $e) {
diff --git a/module/VuFind/src/VuFind/Controller/CartController.php b/module/VuFind/src/VuFind/Controller/CartController.php
index f957259695b..5a6d9f653b1 100644
--- a/module/VuFind/src/VuFind/Controller/CartController.php
+++ b/module/VuFind/src/VuFind/Controller/CartController.php
@@ -227,7 +227,7 @@ class CartController extends AbstractBase
                     $view->to, $view->from, $view->message,
                     $url, $this->getViewRenderer(), $view->subject, $cc
                 );
-                return $this->redirectToSource('info', 'email_success');
+                return $this->redirectToSource('success', 'email_success');
             } catch (MailException $e) {
                 $this->flashMessenger()->setNamespace('error')
                     ->addMessage($e->getMessage());
@@ -299,7 +299,7 @@ class CartController extends AbstractBase
                     'cart/export-success.phtml', ['url' => $url]
                 )
             ];
-            return $this->redirectToSource('info', $msg);
+            return $this->redirectToSource('success', $msg);
         }
 
         // Load the records:
@@ -387,7 +387,7 @@ class CartController extends AbstractBase
         if ($this->formWasSubmitted('submit')) {
             $this->favorites()
                 ->saveBulk($this->getRequest()->getPost()->toArray(), $user);
-            $this->flashMessenger()->setNamespace('info')
+            $this->flashMessenger()->setNamespace('success')
                 ->addMessage('bulk_save_success');
             $list = $this->params()->fromPost('list');
             if (!empty($list)) {
diff --git a/module/VuFind/src/VuFind/Controller/HoldsTrait.php b/module/VuFind/src/VuFind/Controller/HoldsTrait.php
index 2ce2c62f7ec..c48610e1719 100644
--- a/module/VuFind/src/VuFind/Controller/HoldsTrait.php
+++ b/module/VuFind/src/VuFind/Controller/HoldsTrait.php
@@ -134,7 +134,8 @@ trait HoldsTrait
                             '%%url%%' => $this->url()->fromRoute('myresearch-holds')
                         ],
                     ];
-                    $this->flashMessenger()->setNamespace('info')->addMessage($msg);
+                    $this->flashMessenger()->setNamespace('success')
+                        ->addMessage($msg);
                     return $this->redirectToRecord('#top');
                 } else {
                     // Failure: use flash messenger to display messages, stay on
diff --git a/module/VuFind/src/VuFind/Controller/ILLRequestsTrait.php b/module/VuFind/src/VuFind/Controller/ILLRequestsTrait.php
index 6dc78de9d9b..0436f4094dd 100644
--- a/module/VuFind/src/VuFind/Controller/ILLRequestsTrait.php
+++ b/module/VuFind/src/VuFind/Controller/ILLRequestsTrait.php
@@ -112,7 +112,7 @@ trait ILLRequestsTrait
 
             // Success: Go to Display ILL Requests
             if (isset($results['success']) && $results['success'] == true) {
-                $this->flashMessenger()->setNamespace('info')
+                $this->flashMessenger()->setNamespace('success')
                     ->addMessage('ill_request_place_success');
                 if ($this->inLightbox()) {
                     return false;
diff --git a/module/VuFind/src/VuFind/Controller/LibraryCardsController.php b/module/VuFind/src/VuFind/Controller/LibraryCardsController.php
index ad9020eaf67..5c99e5e1bc5 100644
--- a/module/VuFind/src/VuFind/Controller/LibraryCardsController.php
+++ b/module/VuFind/src/VuFind/Controller/LibraryCardsController.php
@@ -163,7 +163,7 @@ class LibraryCardsController extends AbstractBase
             $user->deleteLibraryCard($cardID);
 
             // Success Message
-            $this->flashMessenger()->setNamespace('info')
+            $this->flashMessenger()->setNamespace('success')
                 ->addMessage('Library Card Deleted');
             // Redirect to MyResearch library cards
             return $this->redirect()->toRoute('librarycards-home');
diff --git a/module/VuFind/src/VuFind/Controller/MyResearchController.php b/module/VuFind/src/VuFind/Controller/MyResearchController.php
index a93693644b5..4b11239b007 100644
--- a/module/VuFind/src/VuFind/Controller/MyResearchController.php
+++ b/module/VuFind/src/VuFind/Controller/MyResearchController.php
@@ -285,11 +285,11 @@ 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('info')
+            $this->flashMessenger()->setNamespace('success')
                 ->addMessage('search_save_success');
         } else if (($id = $this->params()->fromQuery('delete', false)) !== false) {
             $search->setSavedFlag($id, false);
-            $this->flashMessenger()->setNamespace('info')
+            $this->flashMessenger()->setNamespace('success')
                 ->addMessage('search_unsave_success');
         } else {
             throw new \Exception('Missing save and delete parameters.');
@@ -326,7 +326,7 @@ class MyResearchController extends AbstractBase
         if (!empty($homeLibrary)) {
             $user->changeHomeLibrary($homeLibrary);
             $this->getAuthManager()->updateSession($user);
-            $this->flashMessenger()->setNamespace('info')
+            $this->flashMessenger()->setNamespace('success')
                 ->addMessage('profile_update');
         }
 
@@ -409,7 +409,7 @@ class MyResearchController extends AbstractBase
         // Process the deletes if necessary:
         if ($this->formWasSubmitted('submit')) {
             $this->favorites()->delete($ids, $listID, $user);
-            $this->flashMessenger()->setNamespace('info')
+            $this->flashMessenger()->setNamespace('success')
                 ->addMessage('fav_delete_success');
             return $this->redirect()->toUrl($newUrl);
         }
@@ -460,12 +460,12 @@ class MyResearchController extends AbstractBase
             $table = $this->getTable('UserList');
             $list = $table->getExisting($listID);
             $list->removeResourcesById($user, [$id], $source);
-            $this->flashMessenger()->setNamespace('info')
+            $this->flashMessenger()->setNamespace('success')
                 ->addMessage('Item removed from list');
         } else {
             // ...My Favorites
             $user->removeResourcesById([$id], $source);
-            $this->flashMessenger()->setNamespace('info')
+            $this->flashMessenger()->setNamespace('success')
                 ->addMessage('Item removed from favorites');
         }
 
@@ -503,7 +503,7 @@ class MyResearchController extends AbstractBase
         if ($addToList > -1) {
             $driver->saveToFavorites(['list' => $addToList], $user);
         }
-        $this->flashMessenger()->setNamespace('info')
+        $this->flashMessenger()->setNamespace('success')
             ->addMessage('edit_list_success');
 
         $newUrl = is_null($listID)
@@ -801,7 +801,7 @@ class MyResearchController extends AbstractBase
                 $list->delete($this->getUser());
 
                 // Success Message
-                $this->flashMessenger()->setNamespace('info')
+                $this->flashMessenger()->setNamespace('success')
                     ->addMessage('fav_list_delete');
             } catch (\Exception $e) {
                 switch(get_class($e)) {
@@ -1245,7 +1245,7 @@ class MyResearchController extends AbstractBase
                         $this->translate('recovery_email_subject'),
                         $message
                     );
-                    $this->flashMessenger()->setNamespace('info')
+                    $this->flashMessenger()->setNamespace('success')
                         ->addMessage('recovery_email_sent');
                 } catch (MailException $e) {
                     $this->flashMessenger()->setNamespace('error')
@@ -1370,7 +1370,7 @@ class MyResearchController extends AbstractBase
         // Login
         $this->getAuthManager()->login($this->request);
         // Go to favorites
-        $this->flashMessenger()->setNamespace('info')
+        $this->flashMessenger()->setNamespace('success')
             ->addMessage('new_password_success');
         return $this->redirect()->toRoute('myresearch-home');
     }
diff --git a/module/VuFind/src/VuFind/Controller/Plugin/Holds.php b/module/VuFind/src/VuFind/Controller/Plugin/Holds.php
index 5ea4e300747..d00b0928653 100644
--- a/module/VuFind/src/VuFind/Controller/Plugin/Holds.php
+++ b/module/VuFind/src/VuFind/Controller/Plugin/Holds.php
@@ -147,7 +147,7 @@ class Holds extends AbstractRequestBase
                     // messages so we can avoid a double translation here.
                     $msg = $this->getController()
                         ->translate('hold_cancel_success_items');
-                    $flashMsg->setNamespace('info')->addMessage(
+                    $flashMsg->setNamespace('success')->addMessage(
                         $cancelResults['count'] . ' ' . $msg
                     );
                 }
diff --git a/module/VuFind/src/VuFind/Controller/Plugin/ILLRequests.php b/module/VuFind/src/VuFind/Controller/Plugin/ILLRequests.php
index 3df17289303..ce4d69e5319 100644
--- a/module/VuFind/src/VuFind/Controller/Plugin/ILLRequests.php
+++ b/module/VuFind/src/VuFind/Controller/Plugin/ILLRequests.php
@@ -164,7 +164,7 @@ class ILLRequests extends AbstractRequestBase
                     $msg = $this->getController()->translate(
                         'ill_request_cancel_success_items'
                     );
-                    $flashMsg->setNamespace('info')->addMessage(
+                    $flashMsg->setNamespace('success')->addMessage(
                         $cancelResults['count'] . ' ' . $msg
                     );
                 }
diff --git a/module/VuFind/src/VuFind/Controller/Plugin/StorageRetrievalRequests.php b/module/VuFind/src/VuFind/Controller/Plugin/StorageRetrievalRequests.php
index a7b7c09b4ab..74326488b16 100644
--- a/module/VuFind/src/VuFind/Controller/Plugin/StorageRetrievalRequests.php
+++ b/module/VuFind/src/VuFind/Controller/Plugin/StorageRetrievalRequests.php
@@ -164,7 +164,7 @@ class StorageRetrievalRequests extends AbstractRequestBase
                     $msg = $this->getController()->translate(
                         'storage_retrieval_request_cancel_success_items'
                     );
-                    $flashMsg->setNamespace('info')->addMessage(
+                    $flashMsg->setNamespace('success')->addMessage(
                         $cancelResults['count'] . ' ' . $msg
                     );
                 }
diff --git a/module/VuFind/src/VuFind/Controller/SearchController.php b/module/VuFind/src/VuFind/Controller/SearchController.php
index e0181673575..086f23b7c13 100644
--- a/module/VuFind/src/VuFind/Controller/SearchController.php
+++ b/module/VuFind/src/VuFind/Controller/SearchController.php
@@ -123,7 +123,7 @@ class SearchController extends AbstractSearch
                     $view->to, $view->from, $view->message,
                     $view->url, $this->getViewRenderer(), $view->subject, $cc
                 );
-                $this->flashMessenger()->setNamespace('info')
+                $this->flashMessenger()->setNamespace('success')
                     ->addMessage('email_success');
                 return $this->redirect()->toUrl($view->url);
             } catch (MailException $e) {
diff --git a/module/VuFind/src/VuFind/Controller/StorageRetrievalRequestsTrait.php b/module/VuFind/src/VuFind/Controller/StorageRetrievalRequestsTrait.php
index d31fac89ff1..f24affa0853 100644
--- a/module/VuFind/src/VuFind/Controller/StorageRetrievalRequestsTrait.php
+++ b/module/VuFind/src/VuFind/Controller/StorageRetrievalRequestsTrait.php
@@ -112,7 +112,7 @@ trait StorageRetrievalRequestsTrait
 
             // Success: Go to Display Storage Retrieval Requests
             if (isset($results['success']) && $results['success'] == true) {
-                $this->flashMessenger()->setNamespace('info')
+                $this->flashMessenger()->setNamespace('success')
                     ->addMessage('storage_retrieval_request_place_success');
                 if ($this->inLightbox()) {
                     return false;
diff --git a/module/VuFind/src/VuFind/View/Helper/Root/Flashmessages.php b/module/VuFind/src/VuFind/View/Helper/Root/Flashmessages.php
index 4dfd203fac8..3c37c2f173d 100644
--- a/module/VuFind/src/VuFind/View/Helper/Root/Flashmessages.php
+++ b/module/VuFind/src/VuFind/View/Helper/Root/Flashmessages.php
@@ -76,7 +76,7 @@ class Flashmessages extends AbstractHelper
     public function __invoke()
     {
         $html = '';
-        $namespaces = ['error', 'info'];
+        $namespaces = ['error', 'info', 'success'];
         foreach ($namespaces as $ns) {
             $this->fm->setNamespace($ns);
             $messages = array_merge(
diff --git a/module/VuFindAdmin/src/VuFindAdmin/Controller/ConfigController.php b/module/VuFindAdmin/src/VuFindAdmin/Controller/ConfigController.php
index 86c78df506c..85332d42590 100644
--- a/module/VuFindAdmin/src/VuFindAdmin/Controller/ConfigController.php
+++ b/module/VuFindAdmin/src/VuFindAdmin/Controller/ConfigController.php
@@ -65,7 +65,7 @@ class ConfigController extends AbstractAdmin
         $writer = new \VuFind\Config\Writer($configFile);
         $writer->set('System', 'autoConfigure', 1);
         if ($writer->save()) {
-            $this->flashMessenger()->setNamespace('info')
+            $this->flashMessenger()->setNamespace('success')
                 ->addMessage('Auto-configuration enabled.');
 
             // Reload config now that it has been edited (otherwise, old setting
diff --git a/module/VuFindAdmin/src/VuFindAdmin/Controller/MaintenanceController.php b/module/VuFindAdmin/src/VuFindAdmin/Controller/MaintenanceController.php
index 10ac05b7adc..7e8246d1ddc 100644
--- a/module/VuFindAdmin/src/VuFindAdmin/Controller/MaintenanceController.php
+++ b/module/VuFindAdmin/src/VuFindAdmin/Controller/MaintenanceController.php
@@ -66,7 +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('info')
+            $this->flashMessenger()->setNamespace('success')
                 ->addMessage('Cache(s) cleared.');
         }
         return $this->forwardTo('AdminMaintenance', 'Home');
@@ -139,7 +139,7 @@ class MaintenanceController extends AbstractAdmin
                 $search->delete($query);
                 $msg = str_replace('%%count%%', $count, $successString);
             }
-            $this->flashMessenger()->setNamespace('info')->addMessage($msg);
+            $this->flashMessenger()->setNamespace('success')->addMessage($msg);
         }
         return $this->forwardTo('AdminMaintenance', 'Home');
     }
diff --git a/module/VuFindAdmin/src/VuFindAdmin/Controller/TagsController.php b/module/VuFindAdmin/src/VuFindAdmin/Controller/TagsController.php
index 9a9370ad142..edd8fc7b1d5 100644
--- a/module/VuFindAdmin/src/VuFindAdmin/Controller/TagsController.php
+++ b/module/VuFindAdmin/src/VuFindAdmin/Controller/TagsController.php
@@ -180,7 +180,7 @@ class TagsController extends AbstractAdmin
             return $this->redirect()->toUrl($originUrl);
         }
 
-        $this->flashMessenger()->setNamespace('info')
+        $this->flashMessenger()->setNamespace('success')
             ->addMessage(
                 [
                     'msg' => 'tags_deleted',
diff --git a/themes/jquerymobile/css/styles.css b/themes/jquerymobile/css/styles.css
index ca6a408acdf..567d601081a 100644
--- a/themes/jquerymobile/css/styles.css
+++ b/themes/jquerymobile/css/styles.css
@@ -209,7 +209,7 @@ div.footer-text {
     padding:0 .5em .5em 20px;
 }
 
-.error, .alert, .info {
+.error, .alert, .info, .success {
   text-align:center;
   padding:10px 0;
   box-shadow:0 1px 0 #AAA,0 -1px 0 #FFF;
@@ -220,7 +220,11 @@ div.footer-text {
   border:1px solid #811;
 }
 .notice {color:#514721;}
-.success {color:#264409;}
+.success {
+  color:#264409;
+  background:#e6efc2;
+  border:1px solid #c6d880;
+}
 .info {
   color:#205791;
   background:#DEF;
diff --git a/themes/jquerymobile/templates/myresearch/checkedout.phtml b/themes/jquerymobile/templates/myresearch/checkedout.phtml
index addfc387aee..14ee8f9b5b3 100644
--- a/themes/jquerymobile/templates/myresearch/checkedout.phtml
+++ b/themes/jquerymobile/templates/myresearch/checkedout.phtml
@@ -34,7 +34,7 @@
           <? $renewDetails = $this->renewResult[$ilsDetails['item_id']]; ?>
           <? $prefix = isset($ilsDetails['title']) ? $ilsDetails['title'] : $ilsDetails['item_id']; ?>
           <? if (isset($renewDetails['success']) && $renewDetails['success']): ?>
-            <div class="info"><?=$this->escapeHtml($prefix . ': ') . $this->transEsc('renew_success')?></div>
+            <div class="success"><?=$this->escapeHtml($prefix . ': ') . $this->transEsc('renew_success')?></div>
           <? else: ?>
             <div class="error"><?=$this->escapeHtml($prefix . ': ') . $this->transEsc('renew_fail')?><? if (isset($renewDetails['sysMessage'])): ?>: <?=$this->escapeHtml($renewDetails['sysMessage'])?><? endif; ?></div>
           <? endif; ?>
-- 
GitLab