Updated fix for Bug 2170, Adding 'edititems' user-permission
authorOwen Leonard <oleonard@myacpl.org>
Mon, 13 Dec 2010 15:30:07 +0000 (15:30 +0000)
committerChris Cormack <chrisc@catalyst.net.nz>
Tue, 14 Dec 2010 00:10:57 +0000 (13:10 +1300)
This patch follows up on the addition of the 'edititems'
permission by adding a check of the new permission to places
in the interface which link to the edit item screen.

The catalogue toolbar had to be extensively re-worked in
order to ensure that the "New" and "Edit" menus would appear
(or not) whether or not edit_catalogue, edit_items, or
create_subscription permissions are on.

Revised for current HEAD

Signed-off-by: Colin Campbell <colin.campbell@ptfs-europe.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css
koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc
koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbooks.tmpl
koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tmpl
koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tmpl

index 55e61be..3f43f61 100644 (file)
@@ -437,6 +437,9 @@ ul.toolbar {
        padding-left : 0;
 }
 
+ul.toolbar button {
+       padding-bottom : 2px;
+}
 .yui-menu-button  {
        
 }
@@ -923,7 +926,8 @@ fieldset.rows .inputnote {
        background-repeat : no-repeat;
 }
 
-#placehold a {
+#placehold a,
+#placehold button {
        padding-left : 34px;
        background-image: url("../../img/toolbar-hold.gif");
        background-position : center left;
index 228ebf3..8d4e02e 100644 (file)
@@ -25,6 +25,7 @@
        }
        function printBiblio() {window.open('/cgi-bin/koha/catalogue/detailprint.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->','Print_Biblio','width=700,height=500,toolbar=false,scrollbars=yes');
        }
+<!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_catalogue" -->
 function confirm_deletion() {
                var count = <!-- TMPL_VAR NAME="count" -->;
         var is_confirmed;
@@ -44,6 +45,8 @@ function confirm_deletion() {
                return false;
        }
 }
+<!-- /TMPL_IF -->
+<!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_items" -->
 function confirm_items_deletion() {
         var count = <!-- TMPL_VAR NAME="count" -->;
         if(count > 0){
@@ -54,125 +57,147 @@ function confirm_items_deletion() {
             }
                }
 }
+<!-- /TMPL_IF -->
        // prepare DOM for YUI Toolbar
 
         $(document).ready(function() {
-           $("#edititems").parent().remove();
-           $("#duplicatebiblio").parent().remove();
+           <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_items" -->$("#edititems").parent().remove();
+               $("#newitem").parent().remove();<!-- /TMPL_IF -->
+           <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_catalogue" -->$("#duplicatebiblio").parent().remove();
                $("#deletebiblio").parent().remove();
-               $("#newitem").parent().remove();
-               $("#newsub").parent().remove();
-           $("#editmenuc").empty();
-               $("#newmenuc").empty();
-               $("#addtoshelfc").empty();
-               $("#printbiblioc").empty();
+               $("#z3950searchc").empty();<!-- /TMPL_IF -->
+               <!-- TMPL_IF NAME="CAN_user_serials_create_subscription" -->$("#newsub").parent().remove();<!-- /TMPL_IF -->
+           $("#newbiblio").parent().remove();
+               $("#editbiblio").parent().remove();
+               $("#addtoshelf").parent().remove();
+               $("#printbiblio").parent().remove();
+               $("#placehold").parent().remove();
                $("#export").remove();
-               $("#addtoshelfc").before("<li id=\"savemenuc\"><\/li>");
-               $("#z3950searchc").empty();
-           yuiToolbar();
         });
 
-       // YUI Toolbar Functions
-
-       function yuiToolbar() {
+       YAHOO.util.Event.onContentReady("cattoolbar", function () {
+               //      Menu for new record, new item, new subscription
                var newmenu = [
-                       {text: _("New Record"), url: "/cgi-bin/koha/cataloguing/addbiblio.pl" },
-                       {text: _("New Item"), url: "/cgi-bin/koha/cataloguing/additem.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->#additema" },
-                       {text: _("New Subscription"), url: "/cgi-bin/koha/serials/subscription-add.pl?biblionumber_for_new_subscription=<!-- TMPL_VAR NAME="biblionumber" -->"},
+                       <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_catalogue" -->{text: _("New Record"), url: "/cgi-bin/koha/cataloguing/addbiblio.pl" },<!-- /TMPL_IF -->
+                       <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_items" -->{text: _("New Item"), url: "/cgi-bin/koha/cataloguing/additem.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->#additema" },<!-- /TMPL_IF -->
+                       <!-- TMPL_IF NAME="CAN_user_serials_create_subscription" -->
+                       {text: _("New Subscription"), url: "/cgi-bin/koha/serials/subscription-add.pl?biblionumber_for_new_subscription=<!-- TMPL_VAR NAME="biblionumber" -->"},<!-- /TMPL_IF -->
                ];
-       
+               if(newmenu.length){
+                       new YAHOO.widget.Button({
+                               type: "menu",
+                               label: _("New"),
+                               id: "newmenuc",
+                               name: "newmenubutton",
+                               menu: newmenu,
+                               container: this
+                        });
+                }
            var editmenu = [
-               { text: _("Edit Record"), url: "/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&amp;frameworkcode=&amp;op=" },
-               { text: _("Edit Items"), url: "/cgi-bin/koha/cataloguing/additem.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->" },
-               { text: _("Attach Item"), url: "/cgi-bin/koha/cataloguing/moveitem.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->" },
-               { text: _("Edit as New (Duplicate)"), url: "/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&amp;frameworkcode=&amp;op=duplicate" },
-                       { text: _("Delete Record"), onclick: {fn: confirm_deletion }<!-- TMPL_IF NAME="count" -->,id:'disabled'<!-- /TMPL_IF --> },
-            { text: _("Delete all Items"), onclick: {fn: confirm_items_deletion }<!-- TMPL_UNLESS NAME="count" -->,id:'disabled'<!-- /TMPL_UNLESS --> }
+               <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_catalogue" -->{ text: _("Edit Record"), url: "/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&amp;frameworkcode=&amp;op=" },<!-- /TMPL_IF -->
+               <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_items" -->{ text: _("Edit Items"), url: "/cgi-bin/koha/cataloguing/additem.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->" },<!-- /TMPL_IF -->
+               <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_items" -->{ text: _("Attach Item"), url: "/cgi-bin/koha/cataloguing/moveitem.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->" },<!-- /TMPL_IF -->
+               <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_catalogue" -->{ text: _("Edit as New (Duplicate)"), url: "/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&amp;frameworkcode=&amp;op=duplicate" },<!-- /TMPL_IF -->
+                       <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_catalogue" -->{ text: _("Delete Record"), onclick: {fn: confirm_deletion }<!-- TMPL_IF NAME="count" -->,id:'disabled'<!-- /TMPL_IF --> },<!-- /TMPL_IF -->
+               <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_items" -->{ text: _("Delete all Items"), onclick: {fn: confirm_items_deletion } }<!-- /TMPL_IF -->
            ];
-               
+               if(editmenu.length){
+                       new YAHOO.widget.Button({
+                               type: "menu",
+                               label: _("Edit"),
+                               id: "editmenuc",
+                               name: "editmenubutton",
+                               menu: editmenu,
+                               container: this
+                        });
+               }
                var savemenu = [
-               { text: _("MODS (XML)"), url: "/cgi-bin/koha/catalogue/export.pl?format=mods&op=export&bib=<!-- TMPL_VAR NAME="biblionumber" -->" },
-               { text: _("Dublin Core (XML)"), url: "/cgi-bin/koha/catalogue/export.pl?format=dc&op=export&bib=<!-- TMPL_VAR NAME="biblionumber" -->" },
-               { text: _("MARCXML"), url: "/cgi-bin/koha/catalogue/export.pl?format=marcxml&op=export&bib=<!-- TMPL_VAR NAME="biblionumber" -->" },
-               { text: _("MARC (non-Unicode/MARC-8)"), url: "/cgi-bin/koha/catalogue/export.pl?format=marc8&op=export&bib=<!-- TMPL_VAR NAME="biblionumber" -->" },
-               { text: _("MARC (Unicode/UTF-8)"), url: "/cgi-bin/koha/catalogue/export.pl?format=utf8&op=export&bib=<!-- TMPL_VAR NAME="biblionumber" -->" }
-               ];
-
-               var addtomenu = [
-               { text: _("Cart"), onclick: { fn: addToCart } },
-               { text: _("List"),  onclick: { fn: addToShelf } }
+                       { text: _("MODS (XML)"), url: "/cgi-bin/koha/catalogue/export.pl?format=mods&op=export&bib=<!-- TMPL_VAR NAME="biblionumber" -->" },
+                       { text: _("Dublin Core (XML)"), url: "/cgi-bin/koha/catalogue/export.pl?format=dc&op=export&bib=<!-- TMPL_VAR NAME="biblionumber" -->" },
+                       { text: _("MARCXML"), url: "/cgi-bin/koha/catalogue/export.pl?format=marcxml&op=export&bib=<!-- TMPL_VAR NAME="biblionumber" -->" },
+                       { text: _("MARC (non-Unicode/MARC-8)"), url: "/cgi-bin/koha/catalogue/export.pl?format=marc8&op=export&bib=<!-- TMPL_VAR NAME="biblionumber" -->" },
+                       { text: _("MARC (Unicode/UTF-8)"), url: "/cgi-bin/koha/catalogue/export.pl?format=utf8&op=export&bib=<!-- TMPL_VAR NAME="biblionumber" -->" }
                ];
 
            new YAHOO.widget.Button({
                type: "menu",
                label: _("Save"),
+               id: "savemenuc",
                name: "savemenubutton",
                menu: savemenu,
-               container: "savemenuc"
-           });
-
-               new YAHOO.widget.Button({
-               type: "menu",
-               label: _("Edit"),
-               name: "editmenubutton",
-               menu: editmenu,
-               container: "editmenuc"
+               container: this
            });
 
-               new YAHOO.widget.Button({
-               type: "menu",
-               label: _("New"),
-               name: "newmenubutton",
-               menu: newmenu,
-               container: "newmenuc"
-           });
+           var addtomenu = [
+                       { text: _("Cart"), onclick: { fn: addToCart } },
+                       { text: _("List"),  onclick: { fn: addToShelf } }
+               ];
 
                new YAHOO.widget.Button({
                type: "menu",
                label: _("Add to"),
                name: "addtomenubutton",
                menu: addtomenu,
-               container: "addtoshelfc"
+               container: this
            });
 
                new YAHOO.widget.Button({
-                       id: "z3950search", 
+               id: "printbiblio",
+               type: "button",
+               label: _("Print"),
+               container: this,
+                       onclick: {fn: printBiblio }
+               });
+
+           new YAHOO.widget.Button({
+                       id: "placehold",
+                       type: "link",
+                       label: _("Place hold"),
+                       container: this,
+                       href: "/cgi-bin/koha/reserve/request.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->"
+            });
+           <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_catalogue" -->
+               new YAHOO.widget.Button({
+                       id: "z3950search",
                        type: "button", 
-                       label: _("Z39.50 Search"), 
-                       container: "z3950searchc",
+                       label: _("Z39.50 Search"),
+                       container: this,
                        onclick: {fn:function(){PopupZ3950()}}
                });
-
-               var printbiblioButton = new YAHOO.widget.Button({
-                                            id: "printbiblio", 
-                                            type: "button", 
-                                            label: _("Print"), 
-                                            container: "printbiblioc",
-                                                                                       onclick: {fn: printBiblio }
-                                        });
-
-           var newbiblioButton = new YAHOO.widget.Button("newbiblio");
-           var placeholdButton = new YAHOO.widget.Button("placehold");
-               
-       }
-
+               <!-- /TMPL_IF -->
+       });
        //]]>
        </script>
        
 <form method="post" name="f" id="f" action="/cgi-bin/koha/cataloguing/addbiblio.pl" onsubmit="return Check();">
 
-<ul class="toolbar">
+<ul class="toolbar" id="cattoolbar">
+
        <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_catalogue" -->
-       <li id="newmenuc"><a id="newbiblio" href="/cgi-bin/koha/cataloguing/addbiblio.pl">New Record</a></li>
+       <li><a id="newbiblio" href="/cgi-bin/koha/cataloguing/addbiblio.pl">New Record</a></li>
+       <!-- /TMPL_IF -->
+       <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_items" -->
        <li><a id="newitem" href="/cgi-bin/koha/cataloguing/additem.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->">New Item</a></li>
+       <!-- /TMPL_IF -->
+       <!-- TMPL_IF NAME="CAN_user_serials_create_subscription" -->
        <li><a id="newsub" href="/cgi-bin/koha/serials/subscription-add.pl?biblionumber_for_new_subscription=<!-- TMPL_VAR NAME="biblionumber" -->">New Subscription</a></li>
-       <li id="editmenuc"><a id="editbiblio" href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&amp;frameworkcode=<!--TMPL_VAR Name="current_framework" -->&amp;op=">Edit Record</a></li>
+       <!-- /TMPL_IF -->
+
+       <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_catalogue" -->
+       <li><a id="editbiblio" href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&amp;frameworkcode=<!--TMPL_VAR Name="current_framework" -->&amp;op=">Edit Record</a></li>
+       <!-- /TMPL_IF -->
+       <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_items" -->
        <li><a id="edititems" href="/cgi-bin/koha/cataloguing/additem.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->">Edit Items</a></li>
+       <!-- /TMPL_IF -->
+       <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_catalogue" -->
        <li><a id="duplicatebiblio" href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&amp;frameworkcode=<!--TMPL_VAR Name="current_framework" -->&amp;op=duplicate">Duplicate Record</a></li>
+       <!-- /TMPL_IF -->
+       <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_catalogue" -->
        <li><a id="deletebiblio" href="/cgi-bin/koha/cataloguing/addbiblio.pl?op=delete&amp;biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->">Delete</a></li>
        <!-- /TMPL_IF -->       
-       <li id="addtoshelfc"><a id="addtoshelf" href="/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->">Add to shelf</a></li>
-       <li id="printbiblioc"><a id="printbiblio" href="/cgi-bin/koha/catalogue/detailprint.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->">Print</a></li>
+
+       <li><a id="addtoshelf" href="/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->">Add to shelf</a></li>
+       <li><a id="printbiblio" href="/cgi-bin/koha/catalogue/detailprint.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->">Print</a></li>
        <!-- TMPL_IF NAME="CAN_user_reserveforothers" -->
        <!-- TMPL_UNLESS NAME="norequests" --><li><a id="placehold" href="/cgi-bin/koha/reserve/request.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->">Place Hold</a></li><!-- /TMPL_UNLESS -->
        <!-- /TMPL_IF -->
index ff4eb83..943d1fb 100644 (file)
@@ -36,9 +36,9 @@
         <tr>
             <th>Title</th>
             <th>Location</th>
-            <th>preview</th>
-            <th>&nbsp;</th>
-            <th>&nbsp;</th>
+            <th>Preview</th>
+            <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_catalogue" --><th>&nbsp;</th><!-- TMPL_ELSE --><!-- /TMPL_IF -->
+            <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_items" --><th>&nbsp;</th><!-- /TMPL_IF -->
         </tr>
     <!-- TMPL_LOOP NAME="resultsloop" -->
         <!-- TMPL_IF name="even" -->
                 </td>
                                <td> <a href="/cgi-bin/koha/catalogue/showmarc.pl?id=<!-- TMPL_VAR NAME="biblionumber" -->" title="MARC" rel="gb_page_center[600,500]">MARC</a> | <a href="/cgi-bin/koha/catalogue/showmarc.pl?viewas=card&amp;id=<!-- TMPL_VAR NAME="biblionumber" -->" title="MARC" rel="gb_page_center[600,500]">Card</a>
                 </td>
-                <td><!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_catalogue"--><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->">Edit biblio</a>
-                                       <!-- TMPL_ELSE --><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->" class="disabled" onclick="return false;">Edit biblio</a>
-                                       <!-- /TMPL_IF -->
-
-                </td>
-                <td>
-                    <a href="/cgi-bin/koha/cataloguing/additem.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->">Add/Edit Items</a>
-                </td>
+                <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_catalogue"--><td><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->">Edit biblio</a></td><!-- /TMPL_IF -->
+                <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_items" --><td><a href="/cgi-bin/koha/cataloguing/additem.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->">Add/Edit Items</a></td><!-- /TMPL_IF -->
             </tr>
     <!-- /TMPL_LOOP -->
     </table>
index 8f8bddb..61e901b 100644 (file)
@@ -162,7 +162,7 @@ for( x=0; x<allColumns.length; x++ ){
                    <!-- TMPL_LOOP name="not_deleted_loop" -->
                        <tr>
                            <td><!-- TMPL_VAR name="itemnumber" --></td>
-                           <td><a href="/cgi-bin/koha/cataloguing/additem.pl?op=edititem&amp;biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&amp;itemnumber=<!-- TMPL_VAR NAME="itemnumber" -->"><!-- TMPL_VAR name="barcode" --></a></td>
+                           <td><!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_items" --><a href="/cgi-bin/koha/cataloguing/additem.pl?op=edititem&amp;biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&amp;itemnumber=<!-- TMPL_VAR NAME="itemnumber" -->"><!-- TMPL_VAR name="barcode" --></a><!-- TMPL_ELSE --><!-- TMPL_VAR NAME="barcode" --><!-- /TMPL_IF --></td>
                            <td><!-- TMPL_IF name="book_on_loan" -->Item is checked out<!-- TMPL_ELSIF name="book_reserved" -->Item has a waiting hold<!-- /TMPL_IF --></td>
                        </tr>
                    <!-- /TMPL_LOOP -->
index a01e27f..1d6216a 100644 (file)
@@ -100,7 +100,7 @@ for( x=0; x<allColumns.length; x++ ){
     <ul>
     <!-- TMPL_LOOP NAME="simple_items_display" -->
   <li>
-      <a href="/cgi-bin/koha/cataloguing/additem.pl?op=edititem&amp;biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&amp;itemnumber=<!-- TMPL_VAR NAME="itemnumber" -->"><!-- TMPL_VAR NAME="barcode" --></a>
+      <!-- TMPL_IF NAME="CAN_user_editcatalogue_edit_items" --><a href="/cgi-bin/koha/cataloguing/additem.pl?op=edititem&amp;biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&amp;itemnumber=<!-- TMPL_VAR NAME="itemnumber" -->"><!-- TMPL_VAR NAME="barcode" --></a><!-- TMPL_ELSE --><!-- TMPL_VAR NAME="barcode" --><!-- /TMPL_IF -->
   </li>
     <!-- /TMPL_LOOP -->
     </ul>