Changeset 1996
- Timestamp:
- 04/27/17 13:18:50 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LATMOS-Accounts/bin/la-create
r1044 r1996 12 12 la-create -- Tools to create object in LATMOS::Account system 13 13 14 =head1 SYNOPSIS14 =head1 USAGE 15 15 16 la-create [options] obj_id 16 la-create [options] [obj_id] 17 18 C<la-create> create objects inside database. 19 20 If no input file is given C<$EDITOR> program is launch with an empty template. 21 22 The object name must given except when creating C<user> object in SQL database 23 for which a try will be done from C<sn> and C<givenName>. 17 24 18 25 =cut … … 76 83 my ($fh) = @_; 77 84 my %attr = LATMOS::Accounts::Utils::parse_obj_file($fh); 78 if ( my $obj = $labase->get_object($otype, $objname)) {85 if ($objname && (my $obj = $labase->get_object($otype, $objname))) { 79 86 if ($allow_update) { 80 87 my $res = $obj->set_c_fields(%attr); … … 89 96 } 90 97 } else { 91 my $res = $labase->create_c_object($otype, $objname, %attr); 92 if($res) { 93 print "Changes applied\n"; 94 $labase->commit; 95 $LA->call_batch_sync; 96 return 1; 97 } 98 return 0; 98 if ($objname) { 99 my $res = $labase->create_c_object($otype, $objname, %attr); 100 if($res) { 101 print "Changes applied\n"; 102 $labase->commit; 103 $LA->call_batch_sync; 104 return 1; 105 } 106 return 0; 107 } else { 108 my $ochelper = $labase->ochelper($otype); 109 110 my $info = { 111 contents => { %attr }, 112 }; 113 if ($attr{name}) { 114 $info->{name}{content} = $attr{name}; 115 } 116 117 $ochelper->Automate($info) or 118 die "Cannot create object (not enough information ?)\n"; 119 } 99 120 } 100 121 }
Note: See TracChangeset
for help on using the changeset viewer.