[Koha-patches] [PATCH] Bug 10201 - Old OPAC patron update system should be removed

Owen Leonard oleonard at myacpl.org
Mon May 6 17:51:23 CEST 2013


The old pages for viewing and updating patron details in the OPAC have
been superceded by the new script opac-memberentry.pl. This patch
removes he old scripts and templates and corrects links to them.

This patch also removes reference to opac-userupdate.tt from
opac-patron-image.pl  and replaces the authentication process with one
which uses check_cookie_auth, based on the example of opac-tags.pl.

To test, edit a patron record and set the "Gone no address" flag. Log in
to the OPAC with that account and view the patron details page. The
warning about out of date contact information should link to the new
update page.

Next, attempt to place a hold. You should see the same warning, and it
should also link to the new update page.

Test the display of patron images: Log in as a user who has an image
associated with their account and navigate to
/cgi-bin/koha/opac-patron-image.pl. Their patron image should display.

A search of Koha source files should return no results for the missing
scripts or templates.
---
 .../opac-tmpl/prog/en/modules/opac-reserve.tt      |    4 +-
 koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt   |    2 +-
 .../opac-tmpl/prog/en/modules/opac-userdetails.tt  |   87 ---------
 .../opac-tmpl/prog/en/modules/opac-userupdate.tt   |  195 --------------------
 opac/opac-patron-image.pl                          |   25 ++-
 opac/opac-userdetails.pl                           |   56 ------
 opac/opac-userupdate.pl                            |  188 -------------------
 7 files changed, 14 insertions(+), 543 deletions(-)
 delete mode 100644 koha-tmpl/opac-tmpl/prog/en/modules/opac-userdetails.tt
 delete mode 100644 koha-tmpl/opac-tmpl/prog/en/modules/opac-userupdate.tt
 delete mode 100755 opac/opac-userdetails.pl
 delete mode 100755 opac/opac-userupdate.pl

diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-reserve.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-reserve.tt
index 65b177b..85f1c30 100644
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-reserve.tt
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-reserve.tt
@@ -166,8 +166,8 @@
         [% IF ( message ) %]
             [% IF ( GNA ) %]
               <div id="gna" class="dialog alert">
-                <p><strong>Sorry</strong>, you cannot place holds because the library doesn't have up-to-date <a href="/cgi-bin/koha/opac-userupdate.pl">contact information</a> on file.</p>
-              <p>Please contact your librarian, or use the <a href="/cgi-bin/koha/opac-userupdate.pl">online update form</a> to submit current information (<em>Please note:</em> there may be a delay in restoring your account if you submit online)</p>
+                <p><strong>Sorry</strong>, you cannot place holds because the library doesn't have up-to-date <a href="/cgi-bin/koha/opac-memberentry.pl">contact information</a> on file.</p>
+              <p>Please contact your librarian, or use the <a href="/cgi-bin/koha/opac-memberentry.pl">online update form</a> to submit current information (<em>Please note:</em> there may be a delay in restoring your account if you submit online)</p>
               </div>
             [% END %]
             [% IF ( lost ) %]
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt
index 96f6e8d..8b765f6 100644
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt
@@ -105,7 +105,7 @@ $.tablesorter.addParser({
                 <span id="userdebarred"><li><strong>Please note:</strong> Your account has been frozen[% IF ( BORROWER_INF.userdebarreddate ) %] until <span id="userdebarred_date">[% BORROWER_INF.userdebarreddate | $KohaDates %]</span>[% END %][% IF ( BORROWER_INF.debarredcomment ) %] with the comment <span id="userdebarred_comment">"[% BORROWER_INF.debarredcomment %]"</span>[% END %]. Usually the reason for freezing an account is old overdues or damage fees. If <a href="/cgi-bin/koha/opac-user.pl">your account page</a> shows your account to be clear, please contact the library.</li></span>
             [% END %]
             [% IF ( BORROWER_INF.gonenoaddress ) %]
-                <span id="gonenoaddress"><li><strong>Please note:</strong> According to our records, we don't have up-to-date [% UNLESS ( BORROWER_INF.OPACPatronDetails ) %]<a href="/cgi-bin/koha/opac-userupdate.pl">contact information</a>[% ELSE %]contact information[% END %] on file.  Please contact the library[% IF ( BORROWER_INF.OPACPatronDetails ) %] or use the <a href="/cgi-bin/koha/opac-userupdate.pl">online update form</a> to submit current information (<em>Please note:</em> there may be a delay in restoring your account if you submit online)[% END %].</li></span>
+                <span id="gonenoaddress"><li><strong>Please note:</strong> According to our records, we don't have up-to-date [% UNLESS ( BORROWER_INF.OPACPatronDetails ) %]<a href="/cgi-bin/koha/opac-memberentry.pl">contact information</a>[% ELSE %]contact information[% END %] on file.  Please contact the library[% IF ( BORROWER_INF.OPACPatronDetails ) %] or use the <a href="/cgi-bin/koha/opac-memberentry.pl">online update form</a> to submit current information (<em>Please note:</em> there may be a delay in restoring your account if you submit online)[% END %].</li></span>
             [% END %]
             [% IF ( BORROWER_INF.lost ) %]
                 <span id="lost"><li><strong>Please note: </strong> Your library card has been marked as lost or stolen. If this is an error, please contact the library.</li></span>
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-userdetails.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-userdetails.tt
deleted file mode 100644
index e695a7a..0000000
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-userdetails.tt
+++ /dev/null
@@ -1,87 +0,0 @@
-[% INCLUDE 'doc-head-open.inc' %][% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog ›  Your personal details
-[% INCLUDE 'doc-head-close.inc' %]
-</head>
-<body>
-<div id="doc3" class="yui-t1">
-   <div id="bd">
-[% INCLUDE 'masthead.inc' %]
-
-	<div id="yui-main">
-	<div class="yui-b"><div class="yui-g">
-
-<h3><a href="/cgi-bin/koha/opac-user.pl">[% firstname %] [% surname %]'s account</a> ⇢ Personal details</h3>
-
-<table>
-<tr><th scope="row">Name:</th><td> [% firstname %] [% surname %]</td></tr>
-<tr><th scope="row">
-Card number:</th><td>[% cardnumber %]</td></tr>
-</table>
-
-<table>
-<caption>Contact details</caption>
-<tr><th scope="row">Mailing address:</th><td>[% address %], [% city %]</td></tr>
-
-<tr><th scope="row">Permanent address:</th><td> [% B_address %], [% B_address2 %], [% B_city %]</td></tr>
-
-<tr><th scope="row">Primary phone:</th><td>[% IF ( phone ) %][% phone %][% ELSE %] [% END %]</td></tr>
-
-<tr><th scope="row">Secondary phone:</th><td>[% IF ( mobile ) %][% mobile %][% ELSE %] [% END %]</td></tr>
-
-<tr><th scope="row">Fax:</th><td>[% IF ( fax ) %][% fax %][% ELSE %] [% END %]</td></tr>
-
-<tr><th scope="row">Email:</th><td>[% IF ( email ) %]<a href="mailto:[% email %]">[% email %]</a>[% ELSE %] [% END %]</td></tr>
-
-</table>
-
-<table>
-<caption>Membership details</caption>
-<tr><th scope="row">Membership number:</th><td> [% borrowernumber %]</td></tr>
-
-<tr><th scope="row">Membership category:</th><td>  [% categorycode %]</td></tr>
-
-<!-- <td>Fee:</th><td>  /year, Paid</td> -->
-
-<tr><th scope="row">Joined:</th><td>[% dateenrolled %]</td></tr>
-
-<tr><th scope="row">Expires:</th><td>[% dateexpiry %]</td></tr>
-
-[% IF ( joiningbranch ) %]<tr><th>Joining library:</th><td>[% joiningbranch %]</td></tr>[% ELSE %] [% END %]</table>
-
-<table>
-<caption>Identity details</caption>
-<tr><th scope="row">DoB:</th><td> [% IF ( dateofbirth ) %][% dateofbirth %][% ELSE %] [% END %]</td></tr>
-
-<tr><th scope="row">Gender:</th><td>[% IF ( sex ) %][% sex %][% ELSE %] [% END %]</td></tr></table>
-
-[% IF ( contactname ) %]
-<table>
-<caption>Alternate contact details</caption>
-<tr><th scope="row">Alternate contact:</th><td> [% IF ( contactname ) %][% contactname %][% ELSE %] [% END %]</td></tr>
-
-<tr><th scope="row">Phone:</th><td> [% IF ( B_phone ) %][% B_phone %][% ELSE %] [% END %]</td></tr>
-
-<tr><th scope="row">Relationship:</th><td> [% IF ( relationship ) %][% relationship %][% ELSE %] [% END %]  </td></tr>
-
-<tr><th scope="row">Notes:</th><td> [% IF ( contactnote ) %][% contactnote %][% ELSE %] [% END %] </td></tr>
-
-<tr><th scope="row">Guarantor:</th><td> [% IF ( guarantorid ) %][% guarantorid %][% ELSE %] [% END %] </td></tr></table>
-
-[% ELSE %]
-<h4>No alternate contact on file.</h4>
-[% END %]
-
-<form action="/cgi-bin/koha/opac-userupdate.pl" method="post">
-<input type="submit" name="Modify" value="Modify Your Record" />
-</form>
-
-</div>
-</div>
-</div>
-<div class="yui-b">
-<div id="leftmenus" class="container">
-[% INCLUDE 'navigation.inc' %]
-[% INCLUDE 'usermenu.inc' %]
-</div>
-</div>
-</div>
-[% INCLUDE 'opac-bottom.inc' %]
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-userupdate.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-userupdate.tt
deleted file mode 100644
index 320b30b..0000000
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-userupdate.tt
+++ /dev/null
@@ -1,195 +0,0 @@
-[% USE KohaDates %]
-
-[% INCLUDE 'doc-head-open.inc' %][% IF ( LibraryNameTitle ) %][% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %][% ELSE %]Koha online[% END %] catalog ›  Your personal details
-[% INCLUDE 'doc-head-close.inc' %]
-</head>
-<body id="opac-userupdate">
-<div id="doc3" class="yui-t1">
-   <div id="bd">
-[% INCLUDE 'masthead.inc' %]
-
-	<div id="yui-main">
-	<div class="yui-b"><div class="yui-g" id="userupdate">
-
-<div id="userupdatecontainer" class="container">
-[% FOREACH BORROWER_INF IN BORROWER_INFO %]
-<h3><a href="/cgi-bin/koha/opac-user.pl">[% INCLUDE 'patron-title.inc' firstname = BORROWER_INF.firstname surname = BORROWER_INF.surname othernames = BORROWER_INF.othernames cardnumber = BORROWER_INF.cardnumber %]'s account</a> ⇢ Your personal details</h3>
-
-[% IF ( OPACPatronDetails ) %]
-<form action="/cgi-bin/koha/opac-userupdate.pl" method="get">
-<div class="yui-u first">
-<input type="hidden" name="modify" value="yes" />
-[% IF ( display_patron_image ) %]<p class="patronimage edit">
-    <img src="/cgi-bin/koha/opac-patron-image.pl" alt="" />
-</p>[% END %]
-<fieldset class="brief"><legend>Name</legend><ol>
-<li><label for="firstname">First name:</label> <input id="firstname" type="text" value="[% BORROWER_INF.firstname %]"  name="firstname" /></li>
-<li><label for="othernames">Other name:</label> <input id="othernames" type="text" value="[% BORROWER_INF.othernames %]"  name="othernames" /></li>
-<li><label for="surname">Last name:</label> <input id="surname" type="text" value="[% BORROWER_INF.surname %]"  name="surname" /></li>
-</ol>
-</fieldset>
-
-<fieldset class="brief"><legend>Contact information</legend>
-<ol>
-<li><label for="address">Address:</label>
-	<input id="streetnumber" size ="7" type="text" value="[% BORROWER_INF.streetnumber %]"  name="streetnumber" /> 
-	<input type="text" name="address" value="[% BORROWER_INF.address %]" id="address" />
-	<input type="text" name="address2" value="[% BORROWER_INF.address2 %]" id="address2" /></li>
-<li><label for="city">City:</label> <input id="city" type="text" value="[% BORROWER_INF.city %]"  name="city" /></li>
-<li><label for="state">State:</label> <input id="state" type="text" value="[% BORROWER_INF.state %]"  name="state" /></li>
-<li><label for="zipcode">Zip code: </label><input type="text" id="zipcode" value="[% BORROWER_INF.zipcode %]" name="zipcode" /></li>
-<li><label for="country">Country: </label><input type="text" id="country" value="[% BORROWER_INF.country %]" name="country" /></li>
-<li><label for="phone">Primary phone:</label> <input id="phone" type="text" value="[% BORROWER_INF.phone %]"  name="phone" /></li>
-<li><label for="mobile">Secondary phone:</label> <input id="mobile" type="text" value="[% BORROWER_INF.mobile %]"  name="mobile" /></li>
-<li><label for="phonepro">Other phone:</label> <input id="phonepro"  type="text" value="[% BORROWER_INF.phonepro %]"  name="phonepro" /></li>
-<li><label for="fax">Fax:</label> <input id="fax" type="text" value="[% BORROWER_INF.fax %]"  name="fax" /></li>
-<li><label for="emailaddress">Primary email:</label> <input id="emailaddress" type="text" value="[% BORROWER_INF.email %]"  name="emailaddress" /></li>
-<li><label for="emailpro">Secondary email:</label> <input id="emailpro" type="text" value="[% BORROWER_INF.emailpro %]"  name="emailpro" /></li>
-</ol>
-</fieldset>
-
-</div>
-<div class="yui-u">
-<fieldset class="brief">
-<legend>Alternate contact information</legend>
-<ol>
-<li>
-    <label for="B_streetaddress">Alternate address:</label>
-    <input id="B_streetnumber" size ="7" type="text" value="[% BORROWER_INF.B_streetnumber %]"  name="B_streetnumber" /> 
-    <input id="B_address" type="text" value="[% BORROWER_INF.B_address %]"  name="B_address" /> 
-    <input id="B_address2" type="text" value="[% BORROWER_INF.B_address2 %]"  name="B_address2" />
-</li>
-
-<li><label for="B_city">City:</label> <input id="B_city" type="text" value="[% BORROWER_INF.B_city %]"  name="B_city" /></li>
-<li><label for="B_state">State:</label> <input id="B_state" type="text" value="[% BORROWER_INF.B_state %]"  name="B_state" /></li>
-<li><label for="B_zipcode">Zip code:</label> <input type="text" id="B_zipcode" value="[% BORROWER_INF.B_zipcode %]" name="B_zipcode" /></li>
-<li><label for="B_country">Country:</label> <input type="text" id="B_country" value="[% BORROWER_INF.B_country %]" name="B_country" /></li>
-<li><label for="B_phone">Phone:</label> <input type="text" id="B_phone" value="[% BORROWER_INF.B_phone %]" name="B_phone" /></li>
-<li><label for="B_email">Email:</label> <input type="text" id="B_email" value="[% BORROWER_INF.B_email %]" name="B_email" /></li>
-</ol>
-</fieldset>
-<fieldset class="brief">
-<ol>
-<li><label for="dob">Date of birth: </label> <input id="dob" type="text" size="10" value="[% BORROWER_INF.dateofbirth | $KohaDates %]" name="dateofbirth" /></li>
-<li><label for="sex">Gender: </label> <select name="sex" id="sex"><option></option>
-[% IF ( BORROWER_INF.sex == 'F' ) %]<option value="F" selected="selected">Female</option>[% ELSE %]<option value="F">Female</option>[% END %]
-[% IF ( BORROWER_INF.sex == 'M' ) %]<option value="M" selected="selected">Male</option>[% ELSE %]<option value="M">Male</option>[% END %]
-</select></li>
-</ol></fieldset>
-<fieldset class="brief">
-<legend>Library use:</legend>
-<ol>
-	<li><label for="cardnumber">Card number:</label><input type="text" id="cardnumber" disabled="disabled" readonly="readonly" value="[% BORROWER_INF.cardnumber %]" /></li>
-    <li><label for="branchname">Home library:</label><input type="text" id="branchname" disabled="disabled" readonly="readonly" value="[% BORROWER_INF.branchname %]" /></li>
-    <li><label for="borrowernumber">Patron number:</label><input type="text" id="borrowernumber" disabled="disabled" readonly="readonly" value="[% BORROWER_INF.borrowernumber %]" /></li>
-    <li><label for="categorycode">Patron category:</label><input type="text" id="categorycode" disabled="disabled" readonly="readonly" value="[% BORROWER_INF.description %] ([% BORROWER_INF.categorycode %])" /></li>
-	<li><label for="dateenrolled">Joined: </label><input type="text" id="dateenrolled" disabled="disabled" readonly="readonly" value="[% BORROWER_INF.dateenrolled | $KohaDates %]" /></li>
-	<li><label for="dateexpiry">Expires: </label><input type="text" id="dateexpiry" disabled="disabled" readonly="readonly" value="[% BORROWER_INF.dateexpiry | $KohaDates %]" /></li>
-   [% IF ( BORROWER_INF.ExtendedPatronAttributes ) %]
-    [% FOREACH patron_attribute IN BORROWER_INF.patron_attributes %]
-        <li><label>[% patron_attribute.description %]</label>
-        [% IF ( patron_attribute.value_description ) %]
-            [% patron_attribute.value_description %]"
-        [% ELSE %]
-            [% patron_attribute.value |html_line_break %]
-        [% END %]
-        </li>
-    [% END %]
-   [% END %]
-</ol>
-</fieldset>
-<fieldset class="action">
-<p>Please make any necessary changes to your record.  Submitting the form will notify a library staff member, who will make the changes permanent.</p>
-<input type="submit" value="Submit Changes" /> <a class="cancel" href="/cgi-bin/koha/opac-user.pl">Cancel</a></fieldset>
-</div>
-
-</form>
-[% ELSE %]
-<p style="clear:left;padding:1em 0">To make changes to your record please contact the library.</p>
-<div class="yui-u first">
-[% IF ( display_patron_image ) %]<p class="patronimage">
-    <img src="/cgi-bin/koha/opac-patron-image.pl" alt="" />
-</p>[% END %]
-<fieldset class="rows">
-<legend>Contact information</legend>
-<ol>
-<li><span class="label">Name:</span> [% BORROWER_INF.firstname %] [% BORROWER_INF.surname %]</li>
-<li><span class="label">Other name:</span> [% BORROWER_INF.othernames %]</li>
-<li><span class="label">Address:</span> [% BORROWER_INF.streetnumber %] [% BORROWER_INF.address %]</li>
-<li><span class="label"> </span>[% BORROWER_INF.address2 %]</li>
-<li><span class="label">City:</span>  [% BORROWER_INF.city %]</li>
-<li><span class="label">State:</span>  [% BORROWER_INF.state %]</li>
-<li><span class="label">Zip code:</span>  [% BORROWER_INF.zipcode %]</li>
-<li><span class="label">Country:</span>  [% BORROWER_INF.country %]</li>
-<li><span class="label">Primary phone:</span>  [% BORROWER_INF.phone %]</li>
-<li><span class="label">Secondary phone:</span>  [% BORROWER_INF.mobile %]</li>
-<li><span class="label">Other phone:</span>  [% BORROWER_INF.phonepro %]</li>
-<li><span class="label">Fax:</span>  [% BORROWER_INF.fax %]</li>
-<li><span class="label">Primary email:</span>  [% BORROWER_INF.email %]</li>
-<li><span class="label">Secondary email:</span>  [% BORROWER_INF.emailpro %]</li>
-</ol>
-</fieldset>
-
-<fieldset class="rows">
-<legend>Personal information</legend>
-<ol>
-<li><span class="label">Date of birth:</span> [% BORROWER_INF.dateofbirth | $KohaDates %]</li>
-<li><span class="label">Gender:</span>
-[% IF ( sex == 'F' ) %]Female[% END %]
-[% IF ( sex == 'M' ) %]Male[% END %]
-</li>
-</ol>
-</fieldset>
-</div>
-
-<div class="yui-u">
-<fieldset class="rows">
-<legend>Alternate contact information</legend>
-<ol>
-<li><span class="label">Alternate address:</span> [% BORROWER_INF.B_streetnumber %] [% BORROWER_INF.B_address %] </li>
-<li><span class="label"> </span>[% BORROWER_INF.B_address2 %]</li>
-<li><span class="label">City:</span> [% BORROWER_INF.B_city %]</li>
-<li><span class="label">State:</span> [% BORROWER_INF.B_state %]</li>
-<li><span class="label">Zip code:</span> [% BORROWER_INF.B_zipcode %]</li>
-<li><span class="label">Country:</span> [% BORROWER_INF.B_country %]</li>
-<li><span class="label">Phone:</span> [% BORROWER_INF.B_phone %]</li>
-<li><span class="label">Email:</span> [% BORROWER_INF.B_email %]</li>
-</ol>
-</fieldset>
-
-<fieldset class="rows">
-<legend>Library use:</legend>
-<ol>
-<li><span class="label">Card number:</span> [% BORROWER_INF.cardnumber %]</li>
-<li><span class="label">Home library:</span> [% BORROWER_INF.branchname %]</li>
-<li><span class="label">Patron number:</span> [% BORROWER_INF.borrowernumber %]</li>
-<li><span class="label">Patron category:</span> [% BORROWER_INF.description %] ([% BORROWER_INF.categorycode %])</li>
-<li><span class="label">Joined:</span> [% BORROWER_INF.dateenrolled | $KohaDates %]</li>
-<li><span class="label">Expires:</span> [% BORROWER_INF.dateexpiry | $KohaDates %]</li>
-   [% IF ( BORROWER_INF.ExtendedPatronAttributes ) %]
-    [% FOREACH patron_attribute IN BORROWER_INF.patron_attributes %]
-        <li><span class="label">[% patron_attribute.description %]</span>
-        [% IF ( patron_attribute.value_description ) %]
-            [% patron_attribute.value_description %]
-        [% ELSE %]
-            [% patron_attribute.value %]
-        [% END %]
-        </li>
-    [% END %]
-   [% END %]
-</ol>
-</fieldset>
-</div>
-[% END %]
-[% END %]
-</div>
-</div>
-</div>
-</div>
-<div class="yui-b">
-<div id="leftmenus" class="container">
-[% INCLUDE 'navigation.inc' IsPatronPage=1 %]
-</div>
-</div>
-</div>
-[% INCLUDE 'opac-bottom.inc' %]
diff --git a/opac/opac-patron-image.pl b/opac/opac-patron-image.pl
index 1935bea..d1f4489 100755
--- a/opac/opac-patron-image.pl
+++ b/opac/opac-patron-image.pl
@@ -21,27 +21,24 @@
 use strict;
 use warnings;
 use C4::Members;
-use C4::Auth;
-my $query = new CGI;
+use CGI;
+use CGI::Cookie;  # need to check cookies before having CGI parse the POST request
+use C4::Auth qw(:DEFAULT check_cookie_auth);
 
-my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
-    {
-          template_name   => "opac-userupdate.tt",
-          query           => $query,
-          type            => "opac",
-          authnotrequired => 0,
-          flagsrequired   => { borrow => 1 },
-          debug           => 1,
-    }
-);
+my $query = new CGI;
 
 unless (C4::Context->preference('OPACpatronimages')) {
     print $query->header(status => '403 Forbidden - displaying patron images in the OPAC not enabled');
     exit;
 }
 
-my ($borrower)=GetMember('borrowernumber' => $borrowernumber);
-my $cardnumber = $borrower->{'cardnumber'};
+my $needed_flags;
+my %cookies = fetch CGI::Cookie;
+my $sessid = $cookies{'CGISESSID'}->value;
+my ($auth_status, $auth_sessid) = check_cookie_auth($sessid, $needed_flags);
+my $borrowernumber = C4::Context->userenv->{'number'};
+my $cardnumber = C4::Context->userenv->{'cardnumber'};
+
 my ($imagedata, $dberror) = GetPatronImage($cardnumber);
 
 if ($dberror) {
diff --git a/opac/opac-userdetails.pl b/opac/opac-userdetails.pl
deleted file mode 100755
index ac10002..0000000
--- a/opac/opac-userdetails.pl
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/usr/bin/perl
-
-# Copyright 2000-2002 Katipo Communications
-#
-# This file is part of Koha.
-#
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or (at your option) any later
-# version.
-#
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with Koha; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-use strict;
-use warnings;
-
-use CGI;
-
-use C4::Auth;
-use C4::Koha;
-use C4::Circulation;
-
-use C4::Output;
-use C4::Dates qw/format_date/;
-use C4::Members;
-
-my $query = new CGI;
-my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
-    {
-        template_name   => "opac-userdetails.tmpl",
-        query           => $query,
-        type            => "opac",
-        authnotrequired => 0,
-        flagsrequired   => { borrow => 1 },
-        debug           => 1,
-    }
-);
-
-# get borrower information ....
-my ( $borr ) = GetMemberDetails( $borrowernumber );
-
-$borr->{'dateenrolled'} = format_date( $borr->{'dateenrolled'} );
-$borr->{'dateexpiry'}       = format_date( $borr->{'dateexpiry'} );
-$borr->{'dateofbirth'}  = format_date( $borr->{'dateofbirth'} );
-$borr->{'ethnicity'}    = fixEthnicity( $borr->{'ethnicity'} );
-
-$template->param($borr);
-
-output_html_with_http_headers $query, $cookie, $template->output;
-
diff --git a/opac/opac-userupdate.pl b/opac/opac-userupdate.pl
deleted file mode 100755
index 3b90498..0000000
--- a/opac/opac-userupdate.pl
+++ /dev/null
@@ -1,188 +0,0 @@
-#!/usr/bin/perl
-
-# Copyright 2000-2002 Katipo Communications
-#
-# This file is part of Koha.
-#
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or (at your option) any later
-# version.
-#
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along
-# with Koha; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-
-use strict;
-use warnings;
-
-use CGI;
-use Mail::Sendmail;
-use Encode;
-
-use C4::Auth;    # checkauth, getborrowernumber.
-use C4::Context;
-use C4::Koha;
-use C4::Circulation;
-use C4::Output;
-use C4::Dates qw/format_date/;
-use C4::Members;
-use C4::Members::Attributes;
-use C4::Branch;
-
-my $query = new CGI;
-
-my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
-    {
-        template_name   => "opac-userupdate.tmpl",
-        query           => $query,
-        type            => "opac",
-        authnotrequired => 0,
-        flagsrequired   => { borrow => 1 },
-        debug           => 1,
-    }
-);
-
-# get borrower information ....
-my ( $borr ) = GetMemberDetails( $borrowernumber );
-my ( $patronemail ) = GetFirstValidEmailAddress($borrowernumber);
-my $lib = GetBranchDetail($borr->{'branchcode'});
-
-# handle the new information....
-# collect the form values and send an email.
-my @fields = (
-    'surname','firstname','othernames','streetnumber','address','address2','city','state','zipcode','country','phone','mobile','fax','phonepro', 'emailaddress','emailpro','B_streetnumber','B_address','B_address2','B_city','B_state','B_zipcode','B_country','B_phone','B_email','dateofbirth','sex'
-);
-my $update;
-my $updateemailaddress = $lib->{'branchemail'};
-$updateemailaddress = C4::Context->preference('KohaAdminEmailAddress') unless( $updateemailaddress =~ /\w+@\w+/);
-if ( !$updateemailaddress || $updateemailaddress eq '' ) {
-    warn
-"KohaAdminEmailAddress system preference not set.  Couldn't send patron update information for $borr->{'firstname'} $borr->{'surname'} (#$borrowernumber)\n";
-    my ($template) = get_template_and_user(
-        {
-            template_name   => "kohaerror.tmpl",
-            query           => $query,
-            type            => "opac",
-            authnotrequired => 1,
-            flagsrequired   => { borrow => 1 },
-            debug           => 1,
-        }
-    );
-
-    $template->param(
-        noadminemail => 1,
-    );
-
-    output_html_with_http_headers $query, $cookie, $template->output;
-    exit;
-}
-
-if ( !$patronemail || $patronemail eq '' ) {
-	$patronemail = $updateemailaddress;
-};
-
-if ( $query->param('modify') ) {
-
-    # get all the fields:
-    my $message = <<"EOF";
-Patron $borr->{'cardnumber'} has requested to change her/his personal details.
-Please check these new details and make the changes to these fields:
-
-EOF
-
-    my $streetnumber = $borr->{'streetnumber'} || '';
-    my $address = $borr->{'address'} || '';
-    my $address2 = $borr->{'address2'} || '';
-    my $B_streetnumber = $borr->{'B_streetnumber'} || '';
-    my $B_address = $borr->{'B_address'} || '';
-    my $B_address2 = $borr->{'B_address2'} || '';
-
-    foreach my $field (@fields) {
-        my $newfield = decode('utf-8',$query->param($field)) || '';
-        my $borrowerfield = '';
-        if($borr->{$field}) {
-            $borrowerfield = $borr->{$field};
-        }
-        
-        if($field eq "dateofbirth") {
-           $borrowerfield  = format_date( $borr->{'dateofbirth'} ) || '';
-        }
-
-        if($borrowerfield ne $newfield) {
-            $message .= $field . " : $borrowerfield  -->  $newfield\n";
-        }
-    }
-
-    $message .= "\nEdit this patron's record: http://".C4::Context->preference('staffClientBaseURL ')."/cgi-bin/koha/members/memberentry.pl?op=modify&borrowernumber=".$borr->{'borrowernumber'}."&categorycode=".$borr->{'categorycode'} if C4::Context->preference('staffClientBaseURL ');
-
-    $message .= "\n\nThanks,\nKoha\n\n";
-    my %mail = (
-        To      => $updateemailaddress,
-        From    => $patronemail,
-        Subject => "User Request for update of Record.",
-        Message => encode('utf-8', $message), # Mail::Sendmail doesn't like wide characters
-        'Content-Type' => 'text/plain; charset="utf-8"',
-    );
-
-    if ( sendmail %mail ) {
-
-        # do something if it works....
-        print $query->redirect('/cgi-bin/koha/opac-user.pl?patronupdate=sent');
-        exit;
-    }
-    else {
-
-        # do something if it doesnt work....
-        warn "Error sending mail: $Mail::Sendmail::error \n";
-    }
-}
-
-$borr->{'ethnicity'}    = fixEthnicity( $borr->{'ethnicity'} );
-$borr->{'branchname'}   = GetBranchName($borr->{'branchcode'});
-
-if (C4::Context->preference('ExtendedPatronAttributes')) {
-    my $attributes = C4::Members::Attributes::GetBorrowerAttributes($borrowernumber, 'opac');
-    if (scalar(@$attributes) > 0) {
-        $borr->{ExtendedPatronAttributes} = 1;
-        $borr->{patron_attributes} = $attributes;
-    }
-}
-
-my $checkin_prefs  = C4::Members::Messaging::GetMessagingPreferences({
-    borrowernumber => $borrowernumber,
-    message_name   => 'Item Checkout'
-});
-for ( keys %{ $checkin_prefs->{transports} }) {
-    $borr->{"items_returned_$_"} = 1;
-}
-my $checkout_prefs = C4::Members::Messaging::GetMessagingPreferences({
-    borrowernumber => $borrowernumber,
-    message_name   => 'Item Check-in'
-});
-for ( keys %{ $checkout_prefs->{transports} }) {
-    $borr->{"items_borrowed_$_"} = 1;
-}
-
-if (C4::Context->preference('OPACpatronimages')) {
-    my ($image, $dberror) = GetPatronImage($borr->{'cardnumber'});
-    if ($image) {
-        $template->param(
-            display_patron_image => 1
-        );
-    }
-}
-
-my @bordat;
-$bordat[0] = $borr;
-
-$template->param( 
-    BORROWER_INFO => \@bordat,
-    userupdateview => 1,
-);
-
-output_html_with_http_headers $query, $cookie, $template->output;
-- 
1.7.9.5


More information about the Koha-patches mailing list