This patch, disallow the users to create frameworks without frameworkcode.
It adds some javascripts checks, and some perls checks(for non-javascript 
users).
---
 admin/biblio_framework.pl                          |   20 +++++++++++---------
 .../prog/en/modules/admin/biblio_framework.tmpl    |    6 ++++--
 2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/admin/biblio_framework.pl b/admin/biblio_framework.pl
index 3837ca5..77dc797 100755
--- a/admin/biblio_framework.pl
+++ b/admin/biblio_framework.pl
@@ -95,15 +95,17 @@ if ($op eq 'add_form') {
 # called by add_form, used to insert/modify data in DB
 } elsif ($op eq 'add_validate') {
        my $dbh = C4::Context->dbh;
-    if ($input->param('modif')) {
-        my $sth=$dbh->prepare("UPDATE biblio_framework SET frameworktext=? 
WHERE frameworkcode=?");
-        
$sth->execute($input->param('frameworktext'),$input->param('frameworkcode'));
-        $sth->finish;
-    } else {
-        my $sth=$dbh->prepare("INSERT into biblio_framework 
(frameworkcode,frameworktext) values (?,?)");
-        
$sth->execute($input->param('frameworkcode'),$input->param('frameworktext'));
-        $sth->finish;
-    }
+       if($input->param('frameworktext') and $input->param('frameworkcode')){
+        if ($input->param('modif')) {
+            my $sth=$dbh->prepare("UPDATE biblio_framework SET frameworktext=? 
WHERE frameworkcode=?");
+            
$sth->execute($input->param('frameworktext'),$input->param('frameworkcode'));
+            $sth->finish;
+        } else {
+            my $sth=$dbh->prepare("INSERT into biblio_framework 
(frameworkcode,frameworktext) values (?,?)");
+            
$sth->execute($input->param('frameworkcode'),$input->param('frameworktext'));
+            $sth->finish;
+        }
+       }
        print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; 
URL=biblio_framework.pl\"></html>";
        exit;
                                                                                
                        # END $OP eq ADD_VALIDATE
diff --git 
a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/biblio_framework.tmpl 
b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/biblio_framework.tmpl
index dc34b48..4935744 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/biblio_framework.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/biblio_framework.tmpl
@@ -52,7 +52,9 @@ function Check(f) {
         alertString2 += 
"\n------------------------------------------------------------------------------------\n";
         alertString2 += _alertString;
         alert(alertString2);
+        return false;
     }
+    return true;
 }
 //]]>
 </script>
@@ -93,7 +95,7 @@ function Check(f) {
 
 <!-- TMPL_IF NAME="add_form" -->
     <h1><!-- TMPL_IF NAME="frameworkcode" -->Modify framework text<!-- 
TMPL_ELSE -->Add framework<!-- /TMPL_IF --></h1>
-    <form action="<!-- TMPL_VAR NAME="script_name" -->" name="Aform" 
method="post">
+    <form action="<!-- TMPL_VAR NAME="script_name" -->" name="Aform" 
method="post" onsubmit="return Check(this);">
         <input type="hidden" name="op" value="add_validate" />
 <fieldset class="rows">        <ol>
        <!-- TMPL_IF NAME="frameworkcode" -->
@@ -104,7 +106,7 @@ function Check(f) {
        <!-- /TMPL_IF -->
         <li><label for="description">Description</label>
         <input type="text" name="frameworktext" id="description" size="40" 
maxlength="80" value="<!-- TMPL_VAR NAME="frameworktext" ESCAPE="HTML" -->" 
/></li></ol></fieldset>
-        <fieldset class="action">      <input type="submit" value="Submit" 
class="submit" onclick="Check(this.form)" /></fieldset>
+        <fieldset class="action">      <input type="submit" value="Submit" 
class="submit" /></fieldset>
     </form>
 <!-- /TMPL_IF -->
 
-- 
1.6.0.4

_______________________________________________
Koha-patches mailing list
[email protected]
http://lists.koha.org/mailman/listinfo/koha-patches

Reply via email to