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

(-)a/C4/Members.pm (+10 lines)
Lines 41-46 use Koha::DateUtils; Link Here
41
use Koha::Borrower::Debarments qw(IsDebarred);
41
use Koha::Borrower::Debarments qw(IsDebarred);
42
use Text::Unaccent qw( unac_string );
42
use Text::Unaccent qw( unac_string );
43
use Koha::AuthUtils qw(hash_password);
43
use Koha::AuthUtils qw(hash_password);
44
use Koha::Database;
44
45
45
our ($VERSION,@ISA,@EXPORT,@EXPORT_OK,$debug);
46
our ($VERSION,@ISA,@EXPORT,@EXPORT_OK,$debug);
46
47
Lines 807-812 sub AddMember { Link Here
807
        $data{'dateenrolled'} = C4::Dates->new()->output("iso");
808
        $data{'dateenrolled'} = C4::Dates->new()->output("iso");
808
    }
809
    }
809
810
811
    my $patron_category =
812
      Koha::Database->new()->schema()->resultset('Category')
813
      ->find( $data{'categorycode'} );
814
    $data{'privacy'} =
815
        $patron_category->default_privacy() eq 'default' ? 1
816
      : $patron_category->default_privacy() eq 'never'   ? 2
817
      : $patron_category->default_privacy() eq 'forever' ? 0
818
      :                                                    undef;
819
810
    # create a disabled account if no password provided
820
    # create a disabled account if no password provided
811
    $data{'password'} = ($data{'password'})? hash_password($data{'password'}) : '!';
821
    $data{'password'} = ($data{'password'})? hash_password($data{'password'}) : '!';
812
    $data{'borrowernumber'}=InsertInTable("borrowers",\%data);
822
    $data{'borrowernumber'}=InsertInTable("borrowers",\%data);
(-)a/Koha/Schema/Result/Category.pm (-23 / +21 lines)
Lines 1-21 Link Here
1
use utf8;
2
package Koha::Schema::Result::Category;
1
package Koha::Schema::Result::Category;
3
2
4
# Created by DBIx::Class::Schema::Loader
3
# Created by DBIx::Class::Schema::Loader
5
# DO NOT MODIFY THE FIRST PART OF THIS FILE
4
# DO NOT MODIFY THE FIRST PART OF THIS FILE
6
5
7
=head1 NAME
8
9
Koha::Schema::Result::Category
10
11
=cut
12
13
use strict;
6
use strict;
14
use warnings;
7
use warnings;
15
8
16
use base 'DBIx::Class::Core';
9
use base 'DBIx::Class::Core';
17
10
18
=head1 TABLE: C<categories>
11
12
=head1 NAME
13
14
Koha::Schema::Result::Category
19
15
20
=cut
16
=cut
21
17
Lines 43-49 __PACKAGE__->table("categories"); Link Here
43
=head2 enrolmentperioddate
39
=head2 enrolmentperioddate
44
40
45
  data_type: 'date'
41
  data_type: 'date'
46
  datetime_undef_if_invalid: 1
47
  is_nullable: 1
42
  is_nullable: 1
48
43
49
=head2 upperagelimit
44
=head2 upperagelimit
Lines 102-107 __PACKAGE__->table("categories"); Link Here
102
  is_nullable: 0
97
  is_nullable: 0
103
  size: 1
98
  size: 1
104
99
100
=head2 default_privacy
101
102
  data_type: 'enum'
103
  default_value: 'default'
104
  extra: {list => ["default","never","forever"]}
105
  is_nullable: 0
106
105
=cut
107
=cut
106
108
107
__PACKAGE__->add_columns(
109
__PACKAGE__->add_columns(
Lines 112-118 __PACKAGE__->add_columns( Link Here
112
  "enrolmentperiod",
114
  "enrolmentperiod",
113
  { data_type => "smallint", is_nullable => 1 },
115
  { data_type => "smallint", is_nullable => 1 },
114
  "enrolmentperioddate",
116
  "enrolmentperioddate",
115
  { data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
117
  { data_type => "date", is_nullable => 1 },
116
  "upperagelimit",
118
  "upperagelimit",
117
  { data_type => "smallint", is_nullable => 1 },
119
  { data_type => "smallint", is_nullable => 1 },
118
  "dateofbirthrequired",
120
  "dateofbirthrequired",
Lines 133-150 __PACKAGE__->add_columns( Link Here
133
  { data_type => "tinyint", default_value => 0, is_nullable => 0 },
135
  { data_type => "tinyint", default_value => 0, is_nullable => 0 },
134
  "category_type",
136
  "category_type",
135
  { data_type => "varchar", default_value => "A", is_nullable => 0, size => 1 },
137
  { data_type => "varchar", default_value => "A", is_nullable => 0, size => 1 },
138
  "default_privacy",
139
  {
140
    data_type => "enum",
141
    default_value => "default",
142
    extra => { list => ["default", "never", "forever"] },
143
    is_nullable => 0,
144
  },
136
);
145
);
137
138
=head1 PRIMARY KEY
139
140
=over 4
141
142
=item * L</categorycode>
143
144
=back
145
146
=cut
147
148
__PACKAGE__->set_primary_key("categorycode");
146
__PACKAGE__->set_primary_key("categorycode");
149
147
150
=head1 RELATIONS
148
=head1 RELATIONS
Lines 225-232 __PACKAGE__->might_have( Link Here
225
);
223
);
226
224
227
225
228
# Created by DBIx::Class::Schema::Loader v0.07025 @ 2013-10-14 20:56:21
226
# Created by DBIx::Class::Schema::Loader v0.07000 @ 2013-12-05 08:14:03
229
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:lert5/PnaztNZ9rmoGc2Gg
227
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:fQEm4xRLHEY1L2/KqCzi0Q
230
228
231
229
232
# You can replace this text with custom content, and it will be preserved on regeneration
230
# You can replace this text with custom content, and it will be preserved on regeneration
(-)a/admin/categorie.pl (-23 / +26 lines)
Lines 94-100 if ($op eq 'add_form') { Link Here
94
    my @selected_branches;
94
    my @selected_branches;
95
	if ($categorycode) {
95
	if ($categorycode) {
96
		my $dbh = C4::Context->dbh;
96
		my $dbh = C4::Context->dbh;
97
		my $sth=$dbh->prepare("select categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,issuelimit,reservefee,hidelostitems,overduenoticerequired,category_type from categories where categorycode=?");
97
        my $sth=$dbh->prepare("SELECT * FROM categories WHERE categorycode = ?");
98
		$sth->execute($categorycode);
98
		$sth->execute($categorycode);
99
		$data=$sth->fetchrow_hashref;
99
		$data=$sth->fetchrow_hashref;
100
100
Lines 119-140 if ($op eq 'add_form') { Link Here
119
        };
119
        };
120
    }
120
    }
121
121
122
	$template->param(description        => $data->{'description'},
122
    $template->param(
123
				enrolmentperiod         => $data->{'enrolmentperiod'},
123
        description           => $data->{'description'},
124
				enrolmentperioddate     => C4::Dates::format_date($data->{'enrolmentperioddate'}),
124
        upperagelimit         => $data->{'upperagelimit'},
125
				upperagelimit           => $data->{'upperagelimit'},
125
        dateofbirthrequired   => $data->{'dateofbirthrequired'},
126
				dateofbirthrequired     => $data->{'dateofbirthrequired'},
126
        enrolmentfee          => sprintf( "%.2f", $data->{'enrolmentfee'} ),
127
				enrolmentfee            => sprintf("%.2f",$data->{'enrolmentfee'}),
127
        overduenoticerequired => $data->{'overduenoticerequired'},
128
				overduenoticerequired   => $data->{'overduenoticerequired'},
128
        issuelimit            => $data->{'issuelimit'},
129
				issuelimit              => $data->{'issuelimit'},
129
        reservefee            => sprintf( "%.2f", $data->{'reservefee'} ),
130
				reservefee              => sprintf("%.2f",$data->{'reservefee'}),
130
        hidelostitems         => $data->{'hidelostitems'},
131
                                hidelostitems           => $data->{'hidelostitems'},
131
        category_type         => $data->{'category_type'},
132
				category_type           => $data->{'category_type'},
132
        SMSSendDriver         => C4::Context->preference("SMSSendDriver"),
133
                SMSSendDriver => C4::Context->preference("SMSSendDriver"),
133
        branches_loop         => \@branches_loop,
134
                TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"),
134
        default_privacy       => $data->{'default_privacy'},
135
				"type_".$data->{'category_type'} => 1,
135
        enrolmentperiod       => $data->{'enrolmentperiod'},
136
                branches_loop           => \@branches_loop,
136
        enrolmentperioddate =>
137
				);
137
          C4::Dates::format_date( $data->{'enrolmentperioddate'} ),
138
        TalkingTechItivaPhone =>
139
          C4::Context->preference("TalkingTechItivaPhoneNotification"),
140
        "type_" . $data->{'category_type'} => 1,
141
    );
142
138
    if (C4::Context->preference('EnhancedMessagingPreferences')) {
143
    if (C4::Context->preference('EnhancedMessagingPreferences')) {
139
        C4::Form::MessagingPreferences::set_form_values({ categorycode => $categorycode } , $template);
144
        C4::Form::MessagingPreferences::set_form_values({ categorycode => $categorycode } , $template);
140
    }
145
    }
Lines 150-157 if ($op eq 'add_form') { Link Here
150
	}
155
	}
151
	
156
	
152
	if ($is_a_modif) {
157
	if ($is_a_modif) {
153
            my $sth=$dbh->prepare("UPDATE categories SET description=?,enrolmentperiod=?, enrolmentperioddate=?,upperagelimit=?,dateofbirthrequired=?,enrolmentfee=?,reservefee=?,hidelostitems=?,overduenoticerequired=?,category_type=? WHERE categorycode=?");
158
            my $sth=$dbh->prepare("UPDATE categories SET description=?,enrolmentperiod=?, enrolmentperioddate=?,upperagelimit=?,dateofbirthrequired=?,enrolmentfee=?,reservefee=?,hidelostitems=?,overduenoticerequired=?,category_type=?, default_privacy=? WHERE categorycode=?");
154
            $sth->execute(map { $input->param($_) } ('description','enrolmentperiod','enrolmentperioddate','upperagelimit','dateofbirthrequired','enrolmentfee','reservefee','hidelostitems','overduenoticerequired','category_type','categorycode'));
159
            $sth->execute(map { $input->param($_) } ('description','enrolmentperiod','enrolmentperioddate','upperagelimit','dateofbirthrequired','enrolmentfee','reservefee','hidelostitems','overduenoticerequired','category_type','default_privacy','categorycode'));
155
            my @branches = $input->param("branches");
160
            my @branches = $input->param("branches");
156
            if ( @branches ) {
161
            if ( @branches ) {
157
                $sth = $dbh->prepare("DELETE FROM categories_branches WHERE categorycode = ?");
162
                $sth = $dbh->prepare("DELETE FROM categories_branches WHERE categorycode = ?");
Lines 168-178 if ($op eq 'add_form') { Link Here
168
                    $sth->execute;
173
                    $sth->execute;
169
                }
174
                }
170
            }
175
            }
171
            $sth->finish;
172
        } else {
176
        } else {
173
            my $sth=$dbh->prepare("INSERT INTO categories  (categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,reservefee,hidelostitems,overduenoticerequired,category_type) values (?,?,?,?,?,?,?,?,?,?,?)");
177
            my $sth=$dbh->prepare("INSERT INTO categories  (categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,reservefee,hidelostitems,overduenoticerequired,category_type,default_privacy) values (?,?,?,?,?,?,?,?,?,?,?,?)");
174
            $sth->execute(map { $input->param($_) } ('categorycode','description','enrolmentperiod','enrolmentperioddate','upperagelimit','dateofbirthrequired','enrolmentfee','reservefee','hidelostitems','overduenoticerequired','category_type'));
178
            $sth->execute(map { $input->param($_) } ('categorycode','description','enrolmentperiod','enrolmentperioddate','upperagelimit','dateofbirthrequired','enrolmentfee','reservefee','hidelostitems','overduenoticerequired','category_type', 'default_privacy'));
175
            $sth->finish;
176
        }
179
        }
177
    if (C4::Context->preference('EnhancedMessagingPreferences')) {
180
    if (C4::Context->preference('EnhancedMessagingPreferences')) {
178
        C4::Form::MessagingPreferences::handle_form_action($input, 
181
        C4::Form::MessagingPreferences::handle_form_action($input, 
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 463-468 CREATE TABLE `categories` ( -- this table shows information related to Koha patr Link Here
463
  `reservefee` decimal(28,6) default NULL, -- cost to place holds
463
  `reservefee` decimal(28,6) default NULL, -- cost to place holds
464
  `hidelostitems` tinyint(1) NOT NULL default '0', -- are lost items shown to this category (1 for yes, 0 for no)
464
  `hidelostitems` tinyint(1) NOT NULL default '0', -- are lost items shown to this category (1 for yes, 0 for no)
465
  `category_type` varchar(1) NOT NULL default 'A', -- type of Koha patron (Adult, Child, Professional, Organizational, Statistical, Staff)
465
  `category_type` varchar(1) NOT NULL default 'A', -- type of Koha patron (Adult, Child, Professional, Organizational, Statistical, Staff)
466
  `default_privacy` ENUM( 'default', 'never', 'forever' ) NOT NULL DEFAULT 'default', -- Default privacy setting for this patron category
466
  PRIMARY KEY  (`categorycode`),
467
  PRIMARY KEY  (`categorycode`),
467
  UNIQUE KEY `categorycode` (`categorycode`)
468
  UNIQUE KEY `categorycode` (`categorycode`)
468
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
469
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
(-)a/installer/data/mysql/updatedatabase.pl (+6 lines)
Lines 7824-7829 if ( CheckVersion($DBversion) ) { Link Here
7824
    SetVersion($DBversion);
7824
    SetVersion($DBversion);
7825
}
7825
}
7826
7826
7827
$DBversion = "3.15.00.XXX";
7828
if(CheckVersion($DBversion)) {
7829
    $dbh->do("ALTER TABLE categories ADD default_privacy ENUM( 'default', 'never', 'forever' ) NOT NULL DEFAULT 'default'");
7830
    print "Upgrade to $DBversion done (Bug 6254 - can't set patron privacy by default)\n";
7831
    SetVersion($DBversion);
7832
}
7827
7833
7828
=head1 FUNCTIONS
7834
=head1 FUNCTIONS
7829
7835
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt (-1 / +20 lines)
Lines 203-208 Link Here
203
        <span>Select All if this category type must to be displayed all the time. Otherwise select librairies you want to associate with this value.
203
        <span>Select All if this category type must to be displayed all the time. Otherwise select librairies you want to associate with this value.
204
        </span>
204
        </span>
205
    </li>
205
    </li>
206
    <li>
207
        <label for="default_privacy">Default privacy: </label>
208
        <select id="default_privacy" name="default_privacy">
209
            [% SWITCH default_privacy %]
210
            [% CASE 'forever' %]
211
                <option value="default">Default</option>
212
                <option value="never">Never</option>
213
                <option value="forever" selected="selected">Forever</option>
214
            [% CASE 'never' %]
215
                <option value="default">Default</option>
216
                <option value="never" selected="selected">Never</option>
217
                <option value="forever">Forever</option>
218
            [% CASE %]
219
                <option value="default" selected="selected">Default</option>
220
                <option value="never">Never</option>
221
                <option value="forever">Forever</option>
222
            [% END %]
223
        </select>
224
        <span>Controls how long a patrons checkout history is kept for new patrons of this category. "Default" lets the library decide, "Never" anonymizes checkouts on return, and "Forever" keeps a patron's checkout history indefinitely.</span>
225
    </li>
206
    </ol>
226
    </ol>
207
</fieldset>
227
</fieldset>
208
228
209
- 

Return to bug 6254