Last change
on this file since 2393 was
2094,
checked in by nanardon, 7 years ago
|
Allow to set allowed_values insde database instead config, this work only for SQL base
|
-
Property svn:executable set to
*
|
File size:
1.4 KB
|
Line | |
---|
1 | #!/usr/bin/perl |
---|
2 | |
---|
3 | use strict; |
---|
4 | use warnings; |
---|
5 | use LATMOS::Accounts; |
---|
6 | use Getopt::Long; |
---|
7 | use Pod::Usage; |
---|
8 | use Term::ReadKey; |
---|
9 | |
---|
10 | =head1 NAME |
---|
11 | |
---|
12 | la-sql-attrvalue - Set limited choice to attributes |
---|
13 | |
---|
14 | =head1 SYNOPSIS |
---|
15 | |
---|
16 | la-rename [options] attribute [value] |
---|
17 | |
---|
18 | =head1 OPTIONS |
---|
19 | |
---|
20 | =over 4 |
---|
21 | |
---|
22 | =item -c|--config configdir |
---|
23 | |
---|
24 | Use this configuration directory instead of the default one. |
---|
25 | |
---|
26 | =item -b|--base basename |
---|
27 | |
---|
28 | Query this specific base instead of the default one. |
---|
29 | |
---|
30 | =item -o|--otype otype |
---|
31 | |
---|
32 | Modify object having type 'otype', default is user |
---|
33 | |
---|
34 | =item -r|--remove |
---|
35 | |
---|
36 | Remove the given value (or all if no value are given) |
---|
37 | |
---|
38 | =back |
---|
39 | |
---|
40 | =cut |
---|
41 | |
---|
42 | GetOptions( |
---|
43 | 'c|config=s' => \my $config, |
---|
44 | 'b|base=s' => \my $base, |
---|
45 | 't|test' => \my $test, |
---|
46 | 'o|otype=s' => \my $otype, |
---|
47 | 'r|remove' => \my $remove, |
---|
48 | 'help' => sub { pod2usage(0) }, |
---|
49 | ) or pod2usage(); |
---|
50 | |
---|
51 | my ($attribute, @values) = @ARGV; |
---|
52 | |
---|
53 | if (!$attribute) { pod2usage(); } |
---|
54 | |
---|
55 | $otype ||= 'user'; |
---|
56 | |
---|
57 | my $LA = LATMOS::Accounts->new($config, noacl => 1); |
---|
58 | my $labase = $LA->base($base); |
---|
59 | $labase && $labase->load or die "Cannot load base\n"; |
---|
60 | |
---|
61 | if ($remove) { |
---|
62 | $labase->DelAttrValue($otype, $attribute, @values) or die "Cannot remove this value"; |
---|
63 | } else { |
---|
64 | if (@values) { |
---|
65 | $labase->AddAttrValue($otype, $attribute, @values) or die "Cannot add this value"; |
---|
66 | } |
---|
67 | |
---|
68 | print "Otype: $otype, Attribute: $attribute\n"; |
---|
69 | foreach ($labase->ListAttrValue($otype, $attribute)) { |
---|
70 | print "\t$_\n"; |
---|
71 | } |
---|
72 | } |
---|
73 | |
---|
74 | |
---|
75 | $labase->commit; |
---|
Note: See
TracBrowser
for help on using the repository browser.