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

(-)a/C4/VirtualShelves.pm (-21 / +20 lines)
Lines 215-233 sub GetSomeShelfNames { Link Here
215
215
216
=head2 GetShelf
216
=head2 GetShelf
217
217
218
  (shelfnumber,shelfname,owner,category,sortfield) = &GetShelf($shelfnumber);
218
  (shelfnumber,shelfname,owner,category,sortfield,allow_add,allow_delete_own,allow_delete_other) = &GetShelf($shelfnumber);
219
219
220
Looks up information about the contents of virtual virtualshelves number
220
Returns the above-mentioned fields for passed virtual shelf number.
221
C<$shelfnumber>
222
223
Returns the database's information on 'virtualshelves' table.
224
221
225
=cut
222
=cut
226
223
227
sub GetShelf ($) {
224
sub GetShelf ($) {
228
    my ($shelfnumber) = @_;
225
    my ($shelfnumber) = @_;
229
    my $query = qq(
226
    my $query = qq(
230
        SELECT shelfnumber, shelfname, owner, category, sortfield
227
        SELECT shelfnumber, shelfname, owner, category, sortfield,
228
            allow_add, allow_delete_own, allow_delete_other
231
        FROM   virtualshelves
229
        FROM   virtualshelves
232
        WHERE  shelfnumber=?
230
        WHERE  shelfnumber=?
233
    );
231
    );
Lines 311-317 sub AddShelf { Link Here
311
309
312
    #initialize missing hash values to silence warnings
310
    #initialize missing hash values to silence warnings
313
    foreach('shelfname','category', 'sortfield', 'allow_add', 'allow_delete_own', 'allow_delete_other' ) {
311
    foreach('shelfname','category', 'sortfield', 'allow_add', 'allow_delete_own', 'allow_delete_other' ) {
314
        $hashref->{$_}= exists $hashref->{$_}? $hashref->{$_}||'': '';
312
        $hashref->{$_}= undef unless exists $hashref->{$_};
315
    }
313
    }
316
314
317
    return -1 unless _CheckShelfName($hashref->{shelfname}, $hashref->{category}, $owner, 0);
315
    return -1 unless _CheckShelfName($hashref->{shelfname}, $hashref->{category}, $owner, 0);
Lines 326-334 sub AddShelf { Link Here
326
        $owner,
324
        $owner,
327
        $hashref->{category},
325
        $hashref->{category},
328
        $hashref->{sortfield},
326
        $hashref->{sortfield},
329
        $hashref->{allow_add}||0,
327
        $hashref->{allow_add}//0,
330
        $hashref->{allow_delete_own}||1,
328
        $hashref->{allow_delete_own}//1,
331
        $hashref->{allow_delete_other}||0 );
329
        $hashref->{allow_delete_other}//0 );
332
    my $shelfnumber = $dbh->{'mysql_insertid'};
330
    my $shelfnumber = $dbh->{'mysql_insertid'};
333
    return $shelfnumber;
331
    return $shelfnumber;
334
}
332
}
Lines 393-408 sub ModShelf { Link Here
393
391
394
    #initialize missing hash values to silence warnings
392
    #initialize missing hash values to silence warnings
395
    foreach('shelfname','category', 'sortfield', 'allow_add', 'allow_delete_own', 'allow_delete_other' ) {
393
    foreach('shelfname','category', 'sortfield', 'allow_add', 'allow_delete_own', 'allow_delete_other' ) {
396
        $hashref->{$_}= exists $hashref->{$_}? $hashref->{$_}||'': '';
394
        $hashref->{$_}= undef unless exists $hashref->{$_};
397
    }
395
    }
398
396
399
    #if name or category changes, the name should be tested
397
    #if name or category changes, the name should be tested
400
    if($hashref->{shelfname} || $hashref->{category}) {
398
    if($hashref->{shelfname} || $hashref->{category}) {
401
        unless(_CheckShelfName(
399
        unless(_CheckShelfName(
402
        $hashref->{shelfname}||$oldrecord->{shelfname},
400
            $hashref->{shelfname}//$oldrecord->{shelfname},
403
        $hashref->{category}||$oldrecord->{category},
401
            $hashref->{category}//$oldrecord->{category},
404
        $oldrecord->{owner}, $shelfnumber )) {
402
            $oldrecord->{owner},
405
        return 0; #name check failed
403
            $shelfnumber )) {
404
                return 0; #name check failed
406
        }
405
        }
407
    }
406
    }
408
407
Lines 410-421 sub ModShelf { Link Here
410
    $query= "UPDATE virtualshelves SET shelfname=?, category=?, sortfield=?, allow_add=?, allow_delete_own=?, allow_delete_other=? WHERE shelfnumber=?";
409
    $query= "UPDATE virtualshelves SET shelfname=?, category=?, sortfield=?, allow_add=?, allow_delete_own=?, allow_delete_other=? WHERE shelfnumber=?";
411
    $sth = $dbh->prepare($query);
410
    $sth = $dbh->prepare($query);
412
    $sth->execute(
411
    $sth->execute(
413
        $hashref->{shelfname}||$oldrecord->{shelfname},
412
        $hashref->{shelfname}//$oldrecord->{shelfname},
414
        $hashref->{category}||$oldrecord->{category},
413
        $hashref->{category}//$oldrecord->{category},
415
        $hashref->{sortfield}||$oldrecord->{sortfield},
414
        $hashref->{sortfield}//$oldrecord->{sortfield},
416
        $hashref->{allow_add}||$oldrecord->{allow_add},
415
        $hashref->{allow_add}//$oldrecord->{allow_add},
417
        $hashref->{allow_delete_own}||$oldrecord->{allow_delete_own},
416
        $hashref->{allow_delete_own}//$oldrecord->{allow_delete_own},
418
        $hashref->{allow_delete_other}||$oldrecord->{allow_delete_other},
417
        $hashref->{allow_delete_other}//$oldrecord->{allow_delete_other},
419
        $shelfnumber );
418
        $shelfnumber );
420
    return $@? 0: 1;
419
    return $@? 0: 1;
421
}
420
}
(-)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 (-2 / +37 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 %]
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 %]
144
<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
145
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>
146
[% 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) %]
179
                [% IF ( paramsloo.somedeleted) %]
154
                      <div class="dialog message">Warning: You could not delete all selected items from this shelf.</div>
180
                      <div class="dialog message">Warning: You could not delete all selected items from this shelf.</div>
155
                [% END %]
181
                [% END %]
182
                [% IF ( paramsloo.modifyfailure) %]
183
                      <div class="dialog message">ERROR: List could not be modified.</div>
184
                [% END %]
156
	</div>
185
	</div>
157
</div>
186
</div>
158
[% END %]
187
[% END %]
Lines 275-281 function placeHold () { Link Here
275
			<select name="category" id="category">
304
			<select name="category" id="category">
276
                  <option value="1">Private</option>
305
                  <option value="1">Private</option>
277
                  <option value="2">Public</option>
306
                  <option value="2">Public</option>
278
			</select></li></ol>
307
			</select></li>
308
            [% INCLUDE list_permissions %]
309
        </ol>
279
    [% END %]
310
    [% END %]
280
311
281
    [% IF ( edit ) %]
312
    [% IF ( edit ) %]
Lines 304-310 function placeHold () { Link Here
304
			[% ELSE %]
335
			[% ELSE %]
305
				<option value="2">Public</option>
336
				<option value="2">Public</option>
306
			[% END %]
337
			[% END %]
307
			</select></li></ol>
338
			</select></li>
339
            [% INCLUDE list_permissions %]
340
            </ol>
308
	[% END %]
341
	[% END %]
309
342
310
		</fieldset>
343
		</fieldset>
Lines 317-322 function placeHold () { Link Here
317
        <div class="help"><ul>
350
        <div class="help"><ul>
318
            <li>A <b>Private</b> list is managed by you and can be seen only by you.</li>
351
            <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>
352
            <li> A <b>Public</b> list can be seen by everybody, but managed only by you.</li>
353
            <br/>
354
            <li>The owner of a list is always allowed to add entries, but needs permission to remove.</li>
320
        </ul>
355
        </ul>
321
        </div>
356
        </div>
322
    </div>
357
    </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