Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
agallavardin
fusiondirectory-plugins
Commits
b2f58d58
Commit
b2f58d58
authored
Jul 07, 2016
by
Côme Chilliet
Browse files
Fixes
#4993
Added sections_order and attrs_order, and fixed shell
parent
c5473684
Changes
2
Hide whitespace changes
Inline
Side-by-side
webservice/contrib/bin/fusiondirectory-shell
View file @
b2f58d58
...
...
@@ -320,13 +320,17 @@ sub command_cat
{
my
(
$type
,
$path
,
$tab
)
=
@_
;
$path
=
complete_dn
(
$path
);
my
$fields
=
rpc_call
(
$client
,
'
fields
',
[
$sid
,
$type
,
$path
,
$tab
]);
my
$fields
=
rpc_call
(
$client
,
'
form
fields
',
[
$sid
,
$type
,
$path
,
$tab
]);
if
(
ref
$fields
eq
ref
{})
{
foreach
my
$section
(
values
%$fields
)
{
my
$sectionhash
=
$fields
->
{'
sections
'};
foreach
my
$sectionkey
(
@
{
$fields
->
{'
sections_order
'}}
)
{
my
$section
=
$sectionhash
->
{
$sectionkey
};
print
'
[
'
.
$section
->
{'
name
'}
.
'
]
'
.
"
\n
";
if
(
ref
$section
->
{'
attrs
'}
eq
ref
[]
)
{
foreach
my
$field
(
@
{
$section
->
{'
attrs
'}})
{
show_field
(
$field
);
if
(
ref
$section
->
{'
attrs_order
'}
eq
ref
[]
)
{
my
$hash
=
$section
->
{'
attrs
'};
foreach
my
$key
(
@
{
$section
->
{'
attrs_order
'}}
)
{
my
$field
=
$hash
->
{
$key
};
show_field
(
$key
,
$field
);
}
}
}
...
...
@@ -335,13 +339,13 @@ sub command_cat
sub
show_field
{
my
(
$field
)
=
@_
;
my
(
$ldapname
,
$field
)
=
@_
;
foreach
my
$type
(
@
{
$field
->
{'
type
'}})
{
if
(
grep
{
$type
eq
$_
}
('
StringAttribute
',
'
DisplayAttribute
'))
{
printf
("
\t
%-30s %s
\n
",
$field
->
{'
label
'}
.
'
[
'
.
$
field
->
{'
id
'}
.
'
]
'
.
'
:
',
$field
->
{'
value
'});
printf
("
\t
%-30s %s
\n
",
$field
->
{'
label
'}
.
'
[
'
.
$
ldapname
.
'
]
'
.
'
:
',
$field
->
{'
value
'});
return
;
}
elsif
(
grep
{
$type
eq
$_
}
('
SetAttribute
'))
{
printf
("
\t
%-30s
\n
",
$field
->
{'
label
'}
.
'
[
'
.
$
field
->
{'
id
'}
.
'
]
'
.
'
:
');
printf
("
\t
%-30s
\n
",
$field
->
{'
label
'}
.
'
[
'
.
$
ldapname
.
'
]
'
.
'
:
');
foreach
my
$value
(
@
{
$field
->
{'
value
'}})
{
if
(
ref
(
$value
)
eq
'
ARRAY
')
{
$value
=
Dumper
(
$value
);
...
...
@@ -351,9 +355,9 @@ sub show_field
return
;
}
elsif
(
grep
{
$type
eq
$_
}
('
OldPluginAttribute
'))
{
if
(
ref
(
$field
->
{'
value
'})
ne
'
ARRAY
')
{
printf
("
\t
%-30s %s
\n
",
$field
->
{'
label
'}
.
'
[
'
.
$
field
->
{'
id
'}
.
'
]
'
.
'
:
',
$field
->
{'
value
'});
printf
("
\t
%-30s %s
\n
",
$field
->
{'
label
'}
.
'
[
'
.
$
ldapname
.
'
]
'
.
'
:
',
$field
->
{'
value
'});
}
else
{
printf
("
\t
%-30s
\n
",
$field
->
{'
label
'}
.
'
[
'
.
$
field
->
{'
id
'}
.
'
]
'
.
'
:
');
printf
("
\t
%-30s
\n
",
$field
->
{'
label
'}
.
'
[
'
.
$
ldapname
.
'
]
'
.
'
:
');
foreach
my
$value
(
@
{
$field
->
{'
value
'}})
{
if
(
ref
(
$value
)
eq
'
ARRAY
')
{
$value
=
Dumper
(
$value
);
...
...
@@ -366,9 +370,9 @@ sub show_field
}
# Default display
if
(
ref
(
$field
->
{'
value
'})
ne
'
ARRAY
')
{
printf
("
\t
%-30s %s
\n
",
$field
->
{'
label
'}
.
'
[
'
.
$
field
->
{'
id
'}
.
'
]
'
.
'
:
',
$field
->
{'
value
'});
printf
("
\t
%-30s %s
\n
",
$field
->
{'
label
'}
.
'
[
'
.
$
ldapname
.
'
]
'
.
'
:
',
$field
->
{'
value
'});
}
else
{
printf
("
\t
%-30s %s
",
$field
->
{'
label
'}
.
'
[
'
.
$
field
->
{'
id
'}
.
'
]
'
.
'
:
',
Dumper
(
$field
->
{'
value
'}));
printf
("
\t
%-30s %s
",
$field
->
{'
label
'}
.
'
[
'
.
$
ldapname
.
'
]
'
.
'
:
',
Dumper
(
$field
->
{'
value
'}));
}
}
...
...
@@ -457,13 +461,17 @@ sub command_addtab
{
my
(
$type
,
$dn
,
$tab
,
@tabs
)
=
@_
;
$dn
=
complete_dn
(
$dn
);
my
$fields
=
rpc_call
(
$client
,
'
fields
',
[
$sid
,
$type
,
$dn
,
$tab
]);
my
$fields
=
rpc_call
(
$client
,
'
form
fields
',
[
$sid
,
$type
,
$dn
,
$tab
]);
my
%values
=
();
if
(
ref
$fields
eq
ref
{})
{
foreach
my
$section
(
values
%$fields
)
{
my
$sectionhash
=
$fields
->
{'
sections
'};
foreach
my
$sectionkey
(
@
{
$fields
->
{'
sections_order
'}}
)
{
my
$section
=
$sectionhash
->
{
$sectionkey
};
print
'
[
'
.
$section
->
{'
name
'}
.
'
]
'
.
"
\n
";
if
(
ref
$section
->
{'
attrs
'}
eq
ref
[]
)
{
foreach
my
$field
(
@
{
$section
->
{'
attrs
'}})
{
if
(
ref
$section
->
{'
attrs_order
'}
eq
ref
[]
)
{
my
$hash
=
$section
->
{'
attrs
'};
foreach
my
$key
(
@
{
$section
->
{'
attrs_order
'}}
)
{
my
$field
=
$hash
->
{
$key
};
if
(
$field
->
{'
required
'}
&&
!
$field
->
{'
disabled
'})
{
$values
{
$field
->
{'
id
'}}
=
ask_field
(
$field
);
}
...
...
@@ -490,12 +498,16 @@ sub command_setvalue
{
my
(
$type
,
$dn
,
$tab
,
$asked_field
,
@value
)
=
@_
;
$dn
=
complete_dn
(
$dn
);
my
$fields
=
rpc_call
(
$client
,
'
fields
',
[
$sid
,
$type
,
$dn
,
$tab
]);
my
$fields
=
rpc_call
(
$client
,
'
form
fields
',
[
$sid
,
$type
,
$dn
,
$tab
]);
my
%values
=
();
if
(
ref
$fields
eq
ref
{})
{
foreach
my
$section
(
values
%$fields
)
{
if
(
ref
$section
->
{'
attrs
'}
eq
ref
[]
)
{
foreach
my
$field
(
@
{
$section
->
{'
attrs
'}})
{
my
$sectionhash
=
$fields
->
{'
sections
'};
foreach
my
$sectionkey
(
@
{
$fields
->
{'
sections_order
'}}
)
{
my
$section
=
$sectionhash
->
{
$sectionkey
};
if
(
ref
$section
->
{'
attrs_order
'}
eq
ref
[]
)
{
my
$hash
=
$section
->
{'
attrs
'};
foreach
my
$key
(
@
{
$section
->
{'
attrs_order
'}}
)
{
my
$field
=
$hash
->
{
$key
};
if
(
$field
->
{'
id
'}
eq
$asked_field
)
{
if
(
scalar
(
@value
)
==
0
)
{
$values
{
$field
->
{'
id
'}}
=
ask_field
(
$field
);
...
...
@@ -521,12 +533,16 @@ sub command_addvalue
{
my
(
$type
,
$dn
,
$tab
,
$asked_field
,
$value
)
=
@_
;
$dn
=
complete_dn
(
$dn
);
my
$fields
=
rpc_call
(
$client
,
'
fields
',
[
$sid
,
$type
,
$dn
,
$tab
]);
my
$fields
=
rpc_call
(
$client
,
'
form
fields
',
[
$sid
,
$type
,
$dn
,
$tab
]);
my
%values
=
();
if
(
ref
$fields
eq
ref
{})
{
foreach
my
$section
(
values
%$fields
)
{
if
(
ref
$section
->
{'
attrs
'}
eq
ref
[]
)
{
foreach
my
$field
(
@
{
$section
->
{'
attrs
'}})
{
my
$sectionhash
=
$fields
->
{'
sections
'};
foreach
my
$sectionkey
(
@
{
$fields
->
{'
sections_order
'}}
)
{
my
$section
=
$sectionhash
->
{
$sectionkey
};
if
(
ref
$section
->
{'
attrs_order
'}
eq
ref
[]
)
{
my
$hash
=
$section
->
{'
attrs
'};
foreach
my
$key
(
@
{
$section
->
{'
attrs_order
'}}
)
{
my
$field
=
$hash
->
{
$key
};
if
(
$field
->
{'
id
'}
eq
$asked_field
)
{
if
(
grep
{
$_
eq
'
SetAttribute
'}
@
{
$field
->
{'
type
'}})
{
$values
{
$field
->
{'
id
'}}
=
$value
;
...
...
@@ -551,15 +567,19 @@ sub command_delvalue
{
my
(
$type
,
$dn
,
$tab
,
$asked_field
)
=
@_
;
$dn
=
complete_dn
(
$dn
);
my
$fields
=
rpc_call
(
$client
,
'
fields
',
[
$sid
,
$type
,
$dn
,
$tab
]);
my
$fields
=
rpc_call
(
$client
,
'
form
fields
',
[
$sid
,
$type
,
$dn
,
$tab
]);
my
%values
=
();
if
(
ref
$fields
eq
ref
{})
{
foreach
my
$section
(
values
%$fields
)
{
if
(
ref
$section
->
{'
attrs
'}
eq
ref
[]
)
{
foreach
my
$field
(
@
{
$section
->
{'
attrs
'}})
{
my
$sectionhash
=
$fields
->
{'
sections
'};
foreach
my
$sectionkey
(
@
{
$fields
->
{'
sections_order
'}}
)
{
my
$section
=
$sectionhash
->
{
$sectionkey
};
if
(
ref
$section
->
{'
attrs_order
'}
eq
ref
[]
)
{
my
$hash
=
$section
->
{'
attrs
'};
foreach
my
$key
(
@
{
$section
->
{'
attrs_order
'}}
)
{
my
$field
=
$hash
->
{
$key
};
if
(
$field
->
{'
id
'}
eq
$asked_field
)
{
if
(
grep
{
$_
eq
'
SetAttribute
'}
@
{
$field
->
{'
type
'}})
{
show_field
(
$field
);
show_field
(
$key
,
$field
);
my
$i
=
0
;
if
(
scalar
(
@
{
$field
->
{'
value
'}})
eq
0
)
{
return
'';
...
...
webservice/html/jsonrpc.php
View file @
b2f58d58
...
...
@@ -308,10 +308,10 @@ class fdRPCService
$attr
->
serializeAttribute
(
$attributes
,
TRUE
);
}
}
$section
[
'attrs'
]
=
$attributes
;
$section
[
'attrs'
]
=
$attributes
;
$section
[
'attrs_order'
]
=
array_keys
(
$attributes
);
}
unset
(
$section
);
return
$fields
;
}
else
{
/* fallback for old plugins */
$fields
=
array
(
'main'
=>
array
(
'attrs'
=>
array
(),
'name'
=>
_
(
'Plugin'
)));
...
...
@@ -327,8 +327,9 @@ class fdRPCService
);
}
}
return
$fields
;
$fields
[
'main'
][
'attrs_order'
]
=
array_keys
(
$fields
[
'main'
][
'attrs'
])
;
}
return
array
(
'sections'
=>
$fields
,
'sections_order'
=>
array_keys
(
$fields
));
}
/*!
...
...
@@ -392,6 +393,7 @@ class fdRPCService
}
}
$section
[
'attrs'
]
=
$attributes
;
$section
[
'attrs_order'
]
=
$attributes
;
}
unset
(
$section
);
}
else
{
...
...
@@ -402,8 +404,9 @@ class fdRPCService
$fields
[
'main'
][
'attrs'
][
$attr
]
=
$object
->
$attr
;
}
}
$fields
[
'main'
][
'attrs_order'
]
=
array_keys
(
$fields
[
'main'
][
'attrs'
]);
}
return
$fields
;
return
array
(
'sections'
=>
$fields
,
'sections_order'
=>
array_keys
(
$fields
))
;
}
/*!
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment