- Timestamp:
- 03/17/15 18:31:05 (9 years ago)
- Location:
- branches/4.0
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.0
-
branches/4.0/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Aliases.pm
r1161 r1284 33 33 mandatory => 1, 34 34 multiple => 1, 35 notify => 1, 35 36 }, 36 37 finalpoint => { ro => 1, multiple => 1 }, -
branches/4.0/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Group.pm
r1238 r1284 62 62 groupname => { ro => 1 }, 63 63 managedBy => { 64 notify => 1, 64 65 reference => 'user', 65 66 can_values => sub { … … 71 72 }, 72 73 managedAlsoBy => { 74 notify => 1, 73 75 reference => 'user', 74 76 multiple => 1, … … 83 85 sutype => { 84 86 reference => 'sutype', 87 notify => 1, 85 88 }, 86 89 autoMemberFilter => { -
branches/4.0/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Nethost.pm
r1225 r1284 32 32 create => { ro => 1, inline => 1, }, 33 33 ip => { 34 notify => 1, 34 35 multiple => 1, 35 36 uniq => 1, … … 48 49 }, 49 50 macaddr => { 51 notify => 1, 50 52 multiple => 1, 51 53 uniq => 1, … … 56 58 }, 57 59 cname => { 60 notify => 1, 58 61 multiple => 1, uniq => 1, 59 62 input => sub { lc($_[0]) } 60 63 }, 61 owner => { 64 owner => { 65 notify => 1, 62 66 reference => 'user', 63 67 delayed => 1, -
branches/4.0/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Netzone.pm
r1064 r1284 34 34 date => { ro => 1, inline => 1, }, 35 35 create => { ro => 1, inline => 1, }, 36 net => { multiple => 1 },37 netExclude => { multiple => 1 },36 net => { multiple => 1, notify => 1, }, 37 netExclude => { multiple => 1, notify => 1, }, 38 38 group => { hide => 1 }, 39 39 allow_dyn => { -
branches/4.0/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/User.pm
r1219 r1284 51 51 mandatory => 1, 52 52 formopts => { length => 7 }, 53 notify => 1, 53 54 }, 54 55 uidnumber => { inline => 1, hide => 1, }, 55 gidNumber => { 56 gidNumber => { 57 notify => 1, 56 58 inline => 1, 57 59 iname => 'gidnumber', … … 83 85 inline => 1, 84 86 formtype => 'CHECKBOX', 87 notify => 1, 85 88 }, 86 89 locked => { 87 90 formtype => 'CHECKBOX', 88 91 formopts => { rawvalue => 1, }, 89 }, 90 expire => { inline => 1, formtype => 'DATE', }, 92 notify => 1, 93 }, 94 expire => { inline => 1, formtype => 'DATE', notify => 1, }, 91 95 name => { inline => 1, ro => 1, }, 92 96 cn => { … … 144 148 }, 145 149 reference => 'user', 150 notify => 1, 146 151 }, 147 152 department => { … … 149 154 can_values => sub { 150 155 $base->search_objects('group', 'sutype=dpmt') 151 } 156 }, 157 notify => 1, 152 158 }, 153 159 contratType => { … … 155 161 can_values => sub { 156 162 $base->search_objects('group', 'sutype=contrattype') 157 } 163 }, 164 notify => 1, 158 165 }, 159 166 site => { -
branches/4.0/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/objects.pm
r1153 r1284 101 101 } 102 102 } 103 $info->{exported} = { inline => 1, formtype => 'CHECKBOX', hide => 1, };103 $info->{exported} = { inline => 1, formtype => 'CHECKBOX', hide => 1, notify => 1 }; 104 104 $info->{unexported} = { inline => 1, formtype => 'CHECKBOX', }; 105 105 … … 178 178 $sth->execute(map { $first{$_} || undef } sort keys %first) or return; 179 179 180 $class->new($base, $id)->set_fields(%second); 180 my $obj = $class->new($base, $id); 181 $obj->objectlog('Create', 'Object created'); 182 foreach (keys %first) { 183 my $attr = $obj->attribute($_); 184 $obj->objectlog('Attribute', '%s set to %s', $_, ( 185 defined($data{$_}) 186 ? (ref $data{$_} 187 ? join(', ', @{ $data{$_} }) 188 : $data{$_}) 189 : '(none)')) 190 if ($attr->{notify}); 191 } 192 $obj->set_fields(%second); 181 193 182 194 1; … … 185 197 sub _delete { 186 198 my ($class, $base, $id) = @_; 199 200 my $obj = $base->get_object($class->type, $id) 201 or return; 202 $obj->objectlog('Delete', 'Object deleted'); 187 203 188 204 my $sthd = $base->db->prepare_cached( … … 199 215 my ($class, $base, $id, $newid) = @_; 200 216 217 { 218 my $obj = $base->get_object($class->type, $id) 219 or return; 220 $obj->objectlog('Rename', 'Object rename to %s', $newid); 221 } 222 201 223 my $sthr = $base->db->prepare_cached( 202 224 sprintf( … … 214 236 ); 215 237 return; 238 } 239 240 { 241 my $obj = $base->get_object($class->type, $newid) 242 or return; 243 $obj->objectlog('Rename', 'Object renamed from %s', $id); 216 244 } 217 245 1; … … 290 318 sub set_fields { 291 319 my ($self, %data) = @_; 292 my $updated_attributes = 0;320 my @updated_attributes = (); 293 321 my @fields; 294 322 my @vals; … … 309 337 push(@fields, sprintf("%s = ?", $self->db->quote_identifier($field))); 310 338 push(@vals, $data{$field}); 339 push(@updated_attributes, $field); 311 340 } else { 312 341 $ext{$field} = $data{$field}; … … 330 359 return; 331 360 }; 332 $updated_attributes = scalar(@fields);333 361 } 334 362 … … 399 427 $updated++; 400 428 } 401 $updated_attributes++if ($updated);429 push(@updated_attributes, $uattr) if ($updated); 402 430 } else { 403 431 my $res = $sthu->execute($ext{$uattr}, $okey, $uattr); … … 410 438 $self->base->db->errstr 411 439 ); 412 $updated_attributes++;413 440 return; 414 441 }; … … 423 450 $self->base->db->errstr 424 451 ); 425 $updated_attributes++;426 452 return; 427 453 }; 428 454 } 455 push(@updated_attributes, $uattr); 429 456 } 430 457 } else { … … 440 467 }; 441 468 } 442 $updated_attributes++;443 469 } 444 470 } 445 471 446 472 delete($self->base->{__cache}{"_" . $self->type}{$self->id}); 447 $updated_attributes; 473 $self->objectlog('Update', 'Attributes %s where updated', join(', ', @updated_attributes)) 474 if(@updated_attributes); 475 foreach (@updated_attributes) { 476 my $attr = $self->attribute($_); 477 $self->objectlog('Attribute', '%s set to %s', $_, ( 478 defined($data{$_}) 479 ? (ref $data{$_} 480 ? join(', ', @{ $data{$_} }) 481 : $data{$_}) 482 : '(none)')) 483 if ($attr->{notify}); 484 } 485 scalar(@updated_attributes); 448 486 } 449 487 … … 483 521 my $salt = join('', map { $salt_char[rand(scalar(@salt_char))] } (1 .. 8)); 484 522 my $res = $self->set_fields($field, crypt($clear_pass, '$1$' . $salt)); 523 my $asymencrypted = 0; 485 524 if ($res) { 486 525 … … 501 540 return; 502 541 } 542 $asymencrypted = 1; 503 543 } 504 544 $self->base->log(LA_NOTICE, … … 506 546 $self->id 507 547 ); 548 $self->objectlog('Password', 'user password has changed%s', ($asymencrypted ? ' and stored using internal key' : '')); 508 549 return 1; 509 550 } … … 708 749 } 709 750 710 751 =head2 objectlog 752 753 =cut 754 755 sub objectlog { 756 my ($self, $changetype, $message, @args) = @_; 757 758 my $sth = $self->base->db->prepare(q{ 759 INSERT into objectslogs (ikey, otype, name, changetype, username, message) 760 VALUES (?,?,?,?,?,?) 761 }); 762 763 $sth->execute( 764 $self->_get_ikey, 765 $self->type, 766 $self->id, 767 $changetype, 768 $self->base->user || '@Console', 769 sprintf($message, @args), 770 ); 771 } 711 772 712 773 1;
Note: See TracChangeset
for help on using the changeset viewer.