Code

Updating spanish translation for gosa 2.5
[gosa.git] / include / functions_cli.inc
1 <?php
3 function print_usage()
4 {
5         echo "Usage: gosa command [options] <attributes>\n";
6         echo "Commands:\n";
7         echo "\tcreate\t\tCreates an object under 'entry dn', the content\n";
8         echo "\t\t\tand type is set by the -plugin option\n";
9         echo "\tdelete\t\tRemoves the either the entry given by 'entry dn',\n";
10         echo "\t\t\tor removes a property set by the -plugin option\n";
11         echo "\tlist\t\tLists either all objects, object types given by\n";
12         echo "\t\t\tthe -plugin option or a single object given by\n";
13         echo "\t\t\tthe 'entry dn'. Use -list to specify the list type\n";
14         echo "\tmodify\t\tModifies the entry given by 'entry dn' using\n";
15         echo "\t\t\tthe object type given by the -plugin option\n";
16         echo "Options:\n";
17         echo "\t--location=name\tChoose the LDAP profile to work on\n";
18         echo "\t--entry-dn=<dn>\tDN to perform actions on\n";
19         echo "\t--entry-id=<id>\tID to perform actions on. This option is more fuzzy\n";
20         echo "\t\t\tthan the -entry-dn one. It depends on the selected plugin\n";
21         echo "\t\t\tand can be i.e. an uid in case of the user plugin or a cn\n";
22         echo "\t\t\tin case of a group or department\n";
23         echo "\t--list=<type>\tSpecifys the detail of the list command. Possible\n";
24         echo "\t\t\tvalues are 'summary' and 'ldif'. The list command defaults\n";
25         echo "\t\t\tto 'summary'\n";
26         echo "\t--modifyer=<id>\tSet the name of the person who's performing changes\n";
27         echo "\t--plugin=<name>\tSelect plugin to work with, use 'list'\n";
28         echo "\t\t\tto get a list of available plugins. Every plguin\n";
29         echo "\t\t\trequires one or more attributes to be set. You can\n";
30         echo "\t\t\tget the list of attributes by using '<name>-help'\n";
31 }
34 function get_plugin_list($config)
35 {
36         $plugins= array();
37         foreach($config->data['MENU'] as $plugin){
38                 foreach ($plugin as $value){
39                         if (isset($value['CLASS'])){
40                                 if (class_exists($value['CLASS'])){
41                                         $obj= new $value['CLASS']($config, 'new');
42                                         if (isset($obj->cli_summary)){
43                                                 $plugins[$value['CLASS']]= $obj->cli_summary;
44                                         } else {
45                                                 $plugins[$value['CLASS']]= "- no description -";
46                                         }
47                                 }
48                         }
49                 }
50         }
51         foreach($config->data['TABS'] as $plugin){
52                 foreach ($plugin as $value){
53                         if (isset($value['CLASS'])){
54                                 if (class_exists($value['CLASS'])){
55                                         $obj= new $value['CLASS']($config, 'new');
56                                         if (isset($obj->cli_summary)){
57                                                 $plugins[$value['CLASS']]= $obj->cli_summary;
58                                         } else {
59                                                 $plugins[$value['CLASS']]= "- no description -";
60                                         }
61                                 }
62                         }
63                 }
64         }
65         #ksort ($plugins);
67         return ($plugins);
68 }
71 function show_plugin_list($config)
72 {
73         printf ("\t%-25s%s\n", "Plugin", "Description");
74         $plugins= get_plugin_list($config);
75         foreach ($plugins as $plugin => $description){
76                 printf ("\t %-25s%s\n", $plugin, $description);
77         }
78 }
81 function show_plugin_help($plugin)
82 {
83         global $config;
85         $plugins= get_plugin_list($config);
86         if (!class_exists($plugin)){
87                 echo "Plugin '$plugin' does not exist\n";
88         } else {
89                 $obj= new $plugin($config, 'new');
90                 if (isset($obj->cli_summary)){
91                         echo $obj->cli_summary."\n\n";
92                 }
93                 if (isset($obj->cli_description)){
94                         echo $obj->cli_description."\n\n";
95                 }
96                 if (isset($obj->cli_parameters)){
97                         print_r ($obj->cli_parameters);
98                 } else {
99                         echo "There's no parameter description for this plugin, sorry.\n";
100                 }
101         }
102         
105 ?>