From 2c2d17a3e508987f0d7bc27de37a89141db89925 Mon Sep 17 00:00:00 2001 From: Ere Maijala <ere.maijala@helsinki.fi> Date: Mon, 23 Mar 2015 14:52:04 -0400 Subject: [PATCH] Added multiple login target support to catalog login form. --- .../VuFind/src/VuFind/Controller/AbstractBase.php | 5 +++++ .../src/VuFind/Controller/MyResearchController.php | 9 +++++++-- .../templates/myresearch/cataloglogin.phtml | 10 +++++++++- .../templates/myresearch/cataloglogin.phtml | 14 +++++++++++++- .../templates/myresearch/cataloglogin.phtml | 14 +++++++++++++- 5 files changed, 47 insertions(+), 5 deletions(-) diff --git a/module/VuFind/src/VuFind/Controller/AbstractBase.php b/module/VuFind/src/VuFind/Controller/AbstractBase.php index e79136759de..db3c3733d45 100644 --- a/module/VuFind/src/VuFind/Controller/AbstractBase.php +++ b/module/VuFind/src/VuFind/Controller/AbstractBase.php @@ -417,6 +417,11 @@ class AbstractBase extends AbstractActionController if (($username = $this->params()->fromPost('cat_username', false)) && ($password = $this->params()->fromPost('cat_password', false)) ) { + // Check for multiple ILS target selection + $target = $this->params()->fromPost('target', false); + if ($target) { + $username = "$target.$username"; + } $patron = $ilsAuth->newCatalogLogin($username, $password); // If login failed, store a warning message: diff --git a/module/VuFind/src/VuFind/Controller/MyResearchController.php b/module/VuFind/src/VuFind/Controller/MyResearchController.php index 30ba1c8a564..fa50ddb1707 100644 --- a/module/VuFind/src/VuFind/Controller/MyResearchController.php +++ b/module/VuFind/src/VuFind/Controller/MyResearchController.php @@ -357,8 +357,13 @@ class MyResearchController extends AbstractBase */ public function catalogloginAction() { - // No special action needed -- just display form - return $this->createViewModel(); + // Connect to the ILS and check if multiple target support is available: + $targets = null; + $catalog = $this->getILS(); + if ($catalog->checkCapability('getLoginDrivers')) { + $targets = $catalog->getLoginDrivers(); + } + return $this->createViewModel(['targets' => $targets]); } /** diff --git a/themes/blueprint/templates/myresearch/cataloglogin.phtml b/themes/blueprint/templates/myresearch/cataloglogin.phtml index ddd308f2320..f23a1bb1f37 100644 --- a/themes/blueprint/templates/myresearch/cataloglogin.phtml +++ b/themes/blueprint/templates/myresearch/cataloglogin.phtml @@ -23,10 +23,18 @@ <?=$this->flashmessages()?> <p><?=$this->transEsc('cat_establish_account')?></p> <form method="post" action=""> + <? if ($this->targets !== null): ?> + <label class="displayBlock" for="login_target"><?=$this->transEsc('login_target')?>:</label> + <select id="login_target" name="target"> + <? foreach ($this->targets as $target): ?> + <option value="<?=$this->escapeHtmlAttr($target)?>"><?=$this->transEsc("source_$target", null, $target)?></option> + <? endforeach; ?> + </select> + <? endif; ?> <label class="displayBlock" for="profile_cat_username"><?=$this->transEsc('Library Catalog Username')?>:</label> <input id="profile_cat_username" type="text" name="cat_username" value="" size="25"/> <label class="displayBlock" for="profile_cat_password"><?=$this->transEsc('Library Catalog Password')?>:</label> - <input id="profile_cat_password" type="text" name="cat_password" value="" size="25"/> + <input id="profile_cat_password" type="password" name="cat_password" value="" size="25"/> <br/> <input type="submit" name="submit" value="<?=$this->transEsc('Save')?>"/> </form> diff --git a/themes/bootstrap3/templates/myresearch/cataloglogin.phtml b/themes/bootstrap3/templates/myresearch/cataloglogin.phtml index dda95948a51..9ce2993594a 100644 --- a/themes/bootstrap3/templates/myresearch/cataloglogin.phtml +++ b/themes/bootstrap3/templates/myresearch/cataloglogin.phtml @@ -21,6 +21,18 @@ <?=$this->flashmessages()?> <p><?=$this->transEsc('cat_establish_account')?></p> <form method="post" action="" class="form-horizontal"> + <? if ($this->targets !== null): ?> + <div class="form-group"> + <label class="col-sm-2 control-label" for="login_target"><?=$this->transEsc('login_target')?>:</label> + <div class="col-sm-10"> + <select id="login_target" name="target" class="form-control"> + <? foreach ($this->targets as $target): ?> + <option value="<?=$this->escapeHtmlAttr($target)?>"><?=$this->transEsc("source_$target", null, $target)?></option> + <? endforeach; ?> + </select> + </div> + </div> + <? endif; ?> <div class="form-group"> <label class="col-sm-2 control-label" for="profile_cat_username"><?=$this->transEsc('Library Catalog Username')?>:</label> <div class="col-sm-10"> @@ -30,7 +42,7 @@ <div class="form-group"> <label class="col-sm-2 control-label" for="profile_cat_password"><?=$this->transEsc('Library Catalog Password')?>:</label> <div class="col-sm-10"> - <input id="profile_cat_username" type="text" name="cat_password" value="" class="form-control"/> + <input id="profile_cat_username" type="password" name="cat_password" value="" class="form-control"/> </div> </div> <div class="form-group"> diff --git a/themes/jquerymobile/templates/myresearch/cataloglogin.phtml b/themes/jquerymobile/templates/myresearch/cataloglogin.phtml index 11cb63cdca8..855822c90dd 100644 --- a/themes/jquerymobile/templates/myresearch/cataloglogin.phtml +++ b/themes/jquerymobile/templates/myresearch/cataloglogin.phtml @@ -21,13 +21,25 @@ <?=$this->flashmessages()?> <p><?=$this->transEsc('cat_establish_account')?></p> <form method="post" data-ajax="false"> + + <? if ($this->targets !== null): ?> + <div data-role="fieldcontain"> + <label class="displayBlock" for="login_target"><?=$this->transEsc('login_target')?>:</label> + <select id="login_target" name="target"> + <? foreach ($this->targets as $target): ?> + <option value="<?=$this->escapeHtmlAttr($target)?>"><?=$this->transEsc("source_$target", null, $target)?></option> + <? endforeach; ?> + </select> + </div> + <? endif; ?> + <div data-role="fieldcontain"> <label class="displayBlock" for="profile_cat_username"><?=$this->transEsc('Library Catalog Username')?>:</label> <input id="profile_cat_username" type="text" name="cat_username" value="" size="25"/> </div> <div data-role="fieldcontain"> <label class="displayBlock" for="profile_cat_password"><?=$this->transEsc('Library Catalog Password')?>:</label> - <input id="profile_cat_password" type="text" name="cat_password" value="" size="25"/> + <input id="profile_cat_password" type="password" name="cat_password" value="" size="25"/> </div> <div data-role="fieldcontain"> <input type="submit" name="submit" value="<?=$this->transEsc('Save')?>"/> -- GitLab