View | Details | Raw Unified | Return to bug 7805
Collapse All | Expand All

(-)a/C4/VirtualShelves.pm (-22 / +21 lines)
Lines 219-237 sub GetSomeShelfNames { Link Here
219
219
220
=head2 GetShelf
220
=head2 GetShelf
221
221
222
  (shelfnumber,shelfname,owner,category,sortfield) = &GetShelf($shelfnumber);
222
  (shelfnumber,shelfname,owner,category,sortfield,allow_add,allow_delete_own,allow_delete_other) = &GetShelf($shelfnumber);
223
223
224
Looks up information about the contents of virtual virtualshelves number
224
Returns the above-mentioned fields for passed virtual shelf number.
225
C<$shelfnumber>
226
227
Returns the database's information on 'virtualshelves' table.
228
225
229
=cut
226
=cut
230
227
231
sub GetShelf ($) {
228
sub GetShelf ($) {
232
    my ($shelfnumber) = @_;
229
    my ($shelfnumber) = @_;
233
    my $query = qq(
230
    my $query = qq(
234
        SELECT shelfnumber, shelfname, owner, category, sortfield
231
        SELECT shelfnumber, shelfname, owner, category, sortfield,
232
            allow_add, allow_delete_own, allow_delete_other
235
        FROM   virtualshelves
233
        FROM   virtualshelves
236
        WHERE  shelfnumber=?
234
        WHERE  shelfnumber=?
237
    );
235
    );
Lines 315-321 sub AddShelf { Link Here
315
313
316
    #initialize missing hash values to silence warnings
314
    #initialize missing hash values to silence warnings
317
    foreach('shelfname','category', 'sortfield', 'allow_add', 'allow_delete_own', 'allow_delete_other' ) {
315
    foreach('shelfname','category', 'sortfield', 'allow_add', 'allow_delete_own', 'allow_delete_other' ) {
318
        $hashref->{$_}= exists $hashref->{$_}? $hashref->{$_}||'': '';
316
        $hashref->{$_}= undef unless exists $hashref->{$_};
319
    }
317
    }
320
318
321
    return -1 unless _CheckShelfName($hashref->{shelfname}, $hashref->{category}, $owner, 0);
319
    return -1 unless _CheckShelfName($hashref->{shelfname}, $hashref->{category}, $owner, 0);
Lines 330-338 sub AddShelf { Link Here
330
    $owner,
328
    $owner,
331
    $hashref->{category},
329
    $hashref->{category},
332
    $hashref->{sortfield},
330
    $hashref->{sortfield},
333
    $hashref->{allow_add}||0,
331
    $hashref->{allow_add}//0,
334
    $hashref->{allow_delete_own}||1,
332
    $hashref->{allow_delete_own}//1,
335
    $hashref->{allow_delete_other}||0 );
333
    $hashref->{allow_delete_other}//0 );
336
    my $shelfnumber = $dbh->{'mysql_insertid'};
334
    my $shelfnumber = $dbh->{'mysql_insertid'};
337
    return $shelfnumber;
335
    return $shelfnumber;
338
}
336
}
Lines 397-412 sub ModShelf { Link Here
397
395
398
    #initialize missing hash values to silence warnings
396
    #initialize missing hash values to silence warnings
399
    foreach('shelfname','category', 'sortfield', 'allow_add', 'allow_delete_own', 'allow_delete_other' ) {
397
    foreach('shelfname','category', 'sortfield', 'allow_add', 'allow_delete_own', 'allow_delete_other' ) {
400
        $hashref->{$_}= exists $hashref->{$_}? $hashref->{$_}||'': '';
398
        $hashref->{$_}= undef unless exists $hashref->{$_};
401
    }
399
    }
402
400
403
    #if name or category changes, the name should be tested
401
    #if name or category changes, the name should be tested
404
    if($hashref->{shelfname} || $hashref->{category}) {
402
    if($hashref->{shelfname} || $hashref->{category}) {
405
        unless(_CheckShelfName(
403
        unless(_CheckShelfName(
406
        $hashref->{shelfname}||$oldrecord->{shelfname},
404
            $hashref->{shelfname}//$oldrecord->{shelfname},
407
        $hashref->{category}||$oldrecord->{category},
405
            $hashref->{category}//$oldrecord->{category},
408
        $oldrecord->{owner}, $shelfnumber )) {
406
            $oldrecord->{owner},
409
        return 0; #name check failed
407
            $shelfnumber )) {
408
                return 0; #name check failed
410
        }
409
        }
411
    }
410
    }
412
411
Lines 414-426 sub ModShelf { Link Here
414
    $query= "UPDATE virtualshelves SET shelfname=?, category=?, sortfield=?, allow_add=?, allow_delete_own=?, allow_delete_other=? WHERE shelfnumber=?";
413
    $query= "UPDATE virtualshelves SET shelfname=?, category=?, sortfield=?, allow_add=?, allow_delete_own=?, allow_delete_other=? WHERE shelfnumber=?";
415
    $sth = $dbh->prepare($query);
414
    $sth = $dbh->prepare($query);
416
    $sth->execute(
415
    $sth->execute(
417
    $hashref->{shelfname}||$oldrecord->{shelfname},
416
        $hashref->{shelfname}//$oldrecord->{shelfname},
418
    $hashref->{category}||$oldrecord->{category},
417
        $hashref->{category}//$oldrecord->{category},
419
    $hashref->{sortfield}||$oldrecord->{sortfield},
418
        $hashref->{sortfield}//$oldrecord->{sortfield},
420
    $hashref->{allow_add}||$oldrecord->{allow_add},
419
        $hashref->{allow_add}//$oldrecord->{allow_add},
421
    $hashref->{allow_delete_own}||$oldrecord->{allow_delete_own},
420
        $hashref->{allow_delete_own}//$oldrecord->{allow_delete_own},
422
    $hashref->{allow_delete_other}||$oldrecord->{allow_delete_other},
421
        $hashref->{allow_delete_other}//$oldrecord->{allow_delete_other},
423
    $shelfnumber );
422
        $shelfnumber );
424
    return $@? 0: 1;
423
    return $@? 0: 1;
425
}
424
}
426
425
(-)a/C4/VirtualShelves/Page.pm (-4 / +17 lines)
Lines 185-192 sub shelfpage { Link Here
185
                        last SWITCH;
185
                        last SWITCH;
186
                }
186
                }
187
                my $shelf = {
187
                my $shelf = {
188
                    'shelfname' => $query->param('shelfname'),
188
                    shelfname          => $query->param('shelfname'),
189
                    'sortfield' => $query->param('sortfield'),
189
                    sortfield          => $query->param('sortfield'),
190
                    allow_add          => $query->param('allow_add'),
191
                    allow_delete_own   => $query->param('allow_delete_own'),
192
                    allow_delete_other => $query->param('allow_delete_other'),
190
                };
193
                };
191
                if($query->param('category')) { #optional
194
                if($query->param('category')) { #optional
192
                    $shelf->{category}= $query->param('category');
195
                    $shelf->{category}= $query->param('category');
Lines 207-213 sub shelfpage { Link Here
207
            }
210
            }
208
        #Editing a shelf
211
        #Editing a shelf
209
        elsif ( $op eq 'modif' ) {
212
        elsif ( $op eq 'modif' ) {
210
                my ( $shelfnumber2, $shelfname, $owner, $category, $sortfield ) = GetShelf($shelfnumber);
213
                my ( $shelfnumber2, $shelfname, $owner, $category, $sortfield, $allow_add, $allow_delete_own, $allow_delete_other) = GetShelf($shelfnumber);
211
                my $member = GetMember( 'borrowernumber' => $owner );
214
                my $member = GetMember( 'borrowernumber' => $owner );
212
                my $ownername = defined($member) ? $member->{firstname} . " " . $member->{surname} : '';
215
                my $ownername = defined($member) ? $member->{firstname} . " " . $member->{surname} : '';
213
                $edit = 1;
216
                $edit = 1;
Lines 222-227 sub shelfpage { Link Here
222
                    "category$category" => 1,
225
                    "category$category" => 1,
223
                    category            => $category,
226
                    category            => $category,
224
                    "sort_$sortfield"   => 1,
227
                    "sort_$sortfield"   => 1,
228
                    allow_add           => $allow_add,
229
                    allow_delete_own    => $allow_delete_own,
230
                    allow_delete_other  => $allow_delete_other,
225
                );
231
                );
226
            }
232
            }
227
            last SWITCH;
233
            last SWITCH;
Lines 322-328 sub shelfpage { Link Here
322
                my $shelfnumber = AddShelf( {
328
                my $shelfnumber = AddShelf( {
323
                    shelfname => $newshelf,
329
                    shelfname => $newshelf,
324
                    sortfield => $query->param('sortfield'),
330
                    sortfield => $query->param('sortfield'),
325
                    category => $query->param('category') },
331
                    category => $query->param('category'),
332
                    allow_add => $query->param('allow_add'),
333
                    allow_delete_own => $query->param('allow_delete_own'),
334
                    allow_delete_other => $query->param('allow_delete_other'),
335
                    },
326
                    $query->param('owner') );
336
                    $query->param('owner') );
327
                $stay = 1;
337
                $stay = 1;
328
                if ( $shelfnumber == -1 ) {    #shelf already exists.
338
                if ( $shelfnumber == -1 ) {    #shelf already exists.
Lines 454-459 sub shelfpage { Link Here
454
        $edit
464
        $edit
455
      ) {
465
      ) {
456
        $template->param( seflag => 1 );
466
        $template->param( seflag => 1 );
467
        #This hack is just another argument for refactoring this script one day
468
        #At this point you are adding or editing a list; if you add, then you add a private list (by default) with permissions as below; if you edit, do not pass these permissions, they must come from the database
469
        $template->param( allow_add => 0, allow_delete_own => 1, allow_delete_other => 0) unless $shelfnumber;
457
    }
470
    }
458
471
459
#Next call updates the shelves for the Lists button.
472
#Next call updates the shelves for the Lists button.
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt (-3 / +39 lines)
Lines 115-120 function placeHold () { Link Here
115
[% INCLUDE 'header.inc' %]
115
[% INCLUDE 'header.inc' %]
116
[% INCLUDE 'cat-search.inc' %]
116
[% INCLUDE 'cat-search.inc' %]
117
117
118
[% BLOCK list_permissions %]
119
    <li>
120
        <label for="permissions">Permissions: </label>
121
        <select name="allow_add" id="allow_add">
122
            [% IF allow_add %]<option value="0">Do not allow</option>[% ELSE %]<option value="0" selected="selected">Do not allow</option>[% END %]
123
            [% IF allow_add %]<option value="1" selected="selected">Allow</option>[% ELSE %]<option value="1">Allow</option>[% END %]
124
        </select>
125
        &nbsp;<span>anyone else to add entries.</span>
126
    </li>
127
    <li>
128
        <label>&nbsp;</label>
129
        <select name="allow_delete_own" id="allow_delete_own">
130
            [% IF allow_delete_own %]<option value="0">Do not allow</option>[% ELSE %]<option value="0" selected="selected">Do not allow</option>[% END %]
131
            [% IF allow_delete_own %]<option value="1" selected="selected">Allow</option>[% ELSE %]<option value="1">Allow</option>[% END %]
132
        </select>
133
        &nbsp;<span>anyone to remove his own contributed entries.</span>
134
    </li>
135
    <li>
136
        <label>&nbsp;</label>
137
        <select name="allow_delete_other" id="allow_delete_other">
138
            [% IF allow_delete_other %]<option value="0">Do not allow</option>[% ELSE %]<option value="0" selected="selected">Do not allow</option>[% END %]
139
            [% IF allow_delete_other %]<option value="1" selected="selected">Allow</option>[% ELSE %]<option value="1">Allow</option>[% END %]
140
        </select>
141
        &nbsp;<span>anyone to remove other contributed entries.</span>
142
    </li>
143
[% END %]
144
118
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/virtualshelves/shelves.pl">Lists</a> [% IF ( category1 ) %] &rsaquo; [% IF ( viewshelf || edit ) %] <a href="/cgi-bin/koha/virtualshelves/shelves.pl?display=privateshelves">Your Lists</a> [% ELSE %] Your Lists [% END %] [% ELSIF ( category2 ) %] &rsaquo; [% IF ( viewshelf ) %] <a href="/cgi-bin/koha/virtualshelves/shelves.pl?display=publicshelves">Public Lists</a> [% ELSE %] Public Lists [% END %] [% ELSIF ( showprivateshelves ) %] &rsaquo; [% IF ( viewshelf || edit ) %] <a href="/cgi-bin/koha/virtualshelves/shelves.pl?display=privateshelves">Your Lists</a> [% ELSE %] Your Lists [% END %] [% ELSIF ( showpublicshelves ) %] &rsaquo; [% IF ( viewshelf || edit ) %] <a href="/cgi-bin/koha/virtualshelves/shelves.pl?display=publicshelves">Public Lists</a> [% ELSE %] Public Lists [% END %] [% END %]
145
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/virtualshelves/shelves.pl">Lists</a> [% IF ( category1 ) %] &rsaquo; [% IF ( viewshelf || edit ) %] <a href="/cgi-bin/koha/virtualshelves/shelves.pl?display=privateshelves">Your Lists</a> [% ELSE %] Your Lists [% END %] [% ELSIF ( category2 ) %] &rsaquo; [% IF ( viewshelf ) %] <a href="/cgi-bin/koha/virtualshelves/shelves.pl?display=publicshelves">Public Lists</a> [% ELSE %] Public Lists [% END %] [% ELSIF ( showprivateshelves ) %] &rsaquo; [% IF ( viewshelf || edit ) %] <a href="/cgi-bin/koha/virtualshelves/shelves.pl?display=privateshelves">Your Lists</a> [% ELSE %] Your Lists [% END %] [% ELSIF ( showpublicshelves ) %] &rsaquo; [% IF ( viewshelf || edit ) %] <a href="/cgi-bin/koha/virtualshelves/shelves.pl?display=publicshelves">Public Lists</a> [% ELSE %] Public Lists [% END %] [% END %]
119
146
120
[% IF ( viewshelf ) %]&rsaquo; Contents of <i>[% shelfname | html %]</i>[% END %][% IF ( shelves ) %] &rsaquo; Create New List[% END %][% IF ( edit ) %] &rsaquo; Edit List <i>[% shelfname | html %]</i>[% END %]</div>
147
[% IF ( viewshelf ) %]&rsaquo; Contents of <i>[% shelfname | html %]</i>[% END %][% IF ( shelves ) %] &rsaquo; Create New List[% END %][% IF ( edit ) %] &rsaquo; Edit List <i>[% shelfname | html %]</i>[% END %]</div>
Lines 153-158 function placeHold () { Link Here
153
                [% IF ( paramsloo.somedeleted) %]
180
                [% IF ( paramsloo.somedeleted) %]
154
                      <div class="dialog message">Warning: You could not delete all selected items from this shelf.</div>
181
                      <div class="dialog message">Warning: You could not delete all selected items from this shelf.</div>
155
                [% END %]
182
                [% END %]
183
                [% IF ( paramsloo.modifyfailure) %]
184
                      <div class="dialog message">ERROR: List could not be modified.</div>
185
                [% END %]
156
	</div>
186
	</div>
157
</div>
187
</div>
158
[% END %]
188
[% END %]
Lines 275-281 function placeHold () { Link Here
275
			<select name="category" id="category">
305
			<select name="category" id="category">
276
                  <option value="1">Private</option>
306
                  <option value="1">Private</option>
277
                  <option value="2">Public</option>
307
                  <option value="2">Public</option>
278
			</select></li></ol>
308
			</select></li>
309
            [% INCLUDE list_permissions %]
310
        </ol>
279
    [% END %]
311
    [% END %]
280
312
281
    [% IF ( edit ) %]
313
    [% IF ( edit ) %]
Lines 304-310 function placeHold () { Link Here
304
			[% ELSE %]
336
			[% ELSE %]
305
				<option value="2">Public</option>
337
				<option value="2">Public</option>
306
			[% END %]
338
			[% END %]
307
			</select></li></ol>
339
			</select></li>
340
            [% INCLUDE list_permissions %]
341
            </ol>
308
	[% END %]
342
	[% END %]
309
343
310
		</fieldset>
344
		</fieldset>
Lines 316-322 function placeHold () { Link Here
316
    <div class="yui-u">
350
    <div class="yui-u">
317
        <div class="help"><ul>
351
        <div class="help"><ul>
318
            <li>A <b>Private</b> List is managed by you and can be seen only by you.</li>
352
            <li>A <b>Private</b> List is managed by you and can be seen only by you.</li>
319
            <li> A <b>Public</b> List can be seen by everybody, but managed only by you.</li>
353
            <li>A <b>Public</b> List can be seen by everybody, but managed only by you.</li>
354
            <br/>
355
            <li>The owner of a list is always allowed to add entries, but needs permission to remove.</li>
320
        </ul>
356
        </ul>
321
        </div>
357
        </div>
322
    </div>
358
    </div>
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tt (-1 / +30 lines)
Lines 170-175 $(function() { Link Here
170
</script>
170
</script>
171
</head>
171
</head>
172
[% IF ( loggedinusername ) %]<body id="opac-userlists">[% ELSE %]<body id="opac-lists">[% END %]
172
[% IF ( loggedinusername ) %]<body id="opac-userlists">[% ELSE %]<body id="opac-lists">[% END %]
173
174
[% BLOCK list_permissions %]
175
    <li>
176
        <label for="permissions">Permissions: </label>
177
        <select name="allow_add" id="allow_add">
178
            [% IF allow_add %]<option value="0">Do not allow</option>[% ELSE %]<option value="0" selected="selected">Do not allow</option>[% END %]
179
            [% IF allow_add %]<option value="1" selected="selected">Allow</option>[% ELSE %]<option value="1">Allow</option>[% END %]
180
        </select>
181
        &nbsp;<span>anyone else to add entries. (The owner of a list is always allowed to add entries, but needs permission to remove.)</span>
182
    </li>
183
    <li>
184
        <label>&nbsp;</label>
185
        <select name="allow_delete_own" id="allow_delete_own">
186
            [% IF allow_delete_own %]<option value="0">Do not allow</option>[% ELSE %]<option value="0" selected="selected">Do not allow</option>[% END %]
187
            [% IF allow_delete_own %]<option value="1" selected="selected">Allow</option>[% ELSE %]<option value="1">Allow</option>[% END %]
188
        </select>
189
        &nbsp;<span>anyone to remove his own contributed entries.</span>
190
    </li>
191
    <li>
192
        <label>&nbsp;</label>
193
        <select name="allow_delete_other" id="allow_delete_other">
194
            [% IF allow_delete_other %]<option value="0">Do not allow</option>[% ELSE %]<option value="0" selected="selected">Do not allow</option>[% END %]
195
            [% IF allow_delete_other %]<option value="1" selected="selected">Allow</option>[% ELSE %]<option value="1">Allow</option>[% END %]
196
        </select>
197
        &nbsp;<span>anyone to remove other contributed entries.</span>
198
    </li>
199
[% END %]
200
173
[% IF ( OpacNav ) %]<div id="doc3" class="yui-t1">[% ELSIF ( loggedinusername ) %]<div id="doc3" class="yui-t1">[% ELSE %]<div id="doc3" class="yui-t7">[% END %]
201
[% IF ( OpacNav ) %]<div id="doc3" class="yui-t1">[% ELSIF ( loggedinusername ) %]<div id="doc3" class="yui-t1">[% ELSE %]<div id="doc3" class="yui-t7">[% END %]
174
    <div id="bd">
202
    <div id="bd">
175
      [% INCLUDE 'masthead.inc' %]
203
      [% INCLUDE 'masthead.inc' %]
Lines 445-450 $(function() { Link Here
445
                        </select>
473
                        </select>
446
			[% END %]
474
			[% END %]
447
                      </li>
475
                      </li>
476
                      [% INCLUDE list_permissions %]
448
                    </ol>
477
                    </ol>
449
                  </fieldset>
478
                  </fieldset>
450
                  <fieldset class="action"><input type="submit" value="Save" class="submit" /> [% IF ( showprivateshelves ) %]<a class="cancel" href="/cgi-bin/koha/opac-shelves.pl?shelfnumber=[% shelfnumber %]&amp;display=privateshelves">Cancel</a>[% ELSE %]<a class="cancel" href="/cgi-bin/koha/opac-shelves.pl?shelfnumber=[% shelfnumber %]">Cancel</a>[% END %]</fieldset>
479
                  <fieldset class="action"><input type="submit" value="Save" class="submit" /> [% IF ( showprivateshelves ) %]<a class="cancel" href="/cgi-bin/koha/opac-shelves.pl?shelfnumber=[% shelfnumber %]&amp;display=privateshelves">Cancel</a>[% ELSE %]<a class="cancel" href="/cgi-bin/koha/opac-shelves.pl?shelfnumber=[% shelfnumber %]">Cancel</a>[% END %]</fieldset>
Lines 633-638 $(function() { Link Here
633
			  [% END %]
662
			  [% END %]
634
                        </select>
663
                        </select>
635
                      </li>
664
                      </li>
665
                      [% INCLUDE list_permissions %]
636
                    </ol>
666
                    </ol>
637
                  </fieldset>
667
                  </fieldset>
638
                  <fieldset class="action">
668
                  <fieldset class="action">
639
- 

Return to bug 7805