浏览代码

Resolves: bug 237356
Description: Move DS Admin Code into Admin Server
Fix Description: 1) Need to have $SILENT be greater than $CUSTOM so that dialog hiding works properly.
2) Need to have the ability to hide or show individual prompts in a dialog e.g. if using TLS/SSL, need to ask for the CA certificate filename, otherwise, not.
3) Need the ability to call a function to get the default yes or no answer for DialogYesNo
4) DialogYesNo should match answer case insensitively

Rich Megginson 18 年之前
父节点
当前提交
b74967d111
共有 2 个文件被更改,包括 18 次插入6 次删除
  1. 17 5
      ldap/admin/src/scripts/Dialog.pm
  2. 1 1
      ldap/admin/src/scripts/Setup.pm.in

+ 17 - 5
ldap/admin/src/scripts/Dialog.pm

@@ -107,12 +107,18 @@ sub isDisplayed {
 }
 
 # each prompt looks like this:
-# [ 'resource key', is pwd ]
+# [ 'resource key', is pwd, hide ]
 # The resource key is the string key of the resource
 # is pwd is optional - if present, the prompt is for a password
 # and should not echo the answer
+# hide is optional - if present and true, the prompt will not be displayed - this
+# is useful in cases where you may want to display or hide a subprompt depending
+# on the response to a main prompt
 # e.g.
 # ['RESOURCE_USERNAME'], ['RESOURCE_PASSWORD', 1], ['RESOURCE_PASSWORD_AGAIN', 1]
+# e.g.
+# ['USE_SECURITY'], ['CA_CERTIFICATE', 0, 0]
+# you can set the 0 to a 1 if the user has chosen to use security
 sub run {
     my $self = shift;
     my $resp = $DialogManager::SAME;
@@ -129,7 +135,7 @@ sub run {
         my $prompt = $prompts[$index];
         my $defaultans = $self->{defaultAns}($self, $index);
         my $ans;
-        if ($self->isDisplayed()) {
+        if ($self->isDisplayed() && !$promtpt->[2]) {
             $ans = $self->{manager}->showPrompt($prompt->[0], $defaultans, $prompt->[1]);
         } else {
             $ans = $defaultans;
@@ -201,7 +207,13 @@ sub defaultAns {
         return $self->{ans};
     }
     if (!exists($self->{default})) {
-        if ($self->{defaultIsYes}) {
+        my $isyes;
+        if (ref($self->{defaultIsYes}) eq 'CODE') {
+            $isyes = &{$self->{defaultIsYes}}($self);
+        } else {
+            $isyes = $self->{defaultIsYes};
+        }
+        if ($isyes) {
             $self->{default} = $self->{"manager"}->getText("yes");
         } else {
             $self->{default} = $self->{"manager"}->getText("no");
@@ -223,10 +235,10 @@ sub handleResponse {
     my $nno = $self->{"manager"}->getText("no");
 
     # the regexp allows us to use y or ye or yes for "yes"
-    if ($nno =~ /^$ans/) {
+    if ($nno =~ /^$ans/i) {
         $resp = $DialogManager::NEXT;
         $self->{ans} = $nno;
-    } elsif ($yes =~ /^$ans/) {
+    } elsif ($yes =~ /^$ans/i) {
         $resp = $DialogManager::NEXT;
         $self->{ans} = $yes;
     } else {

+ 1 - 1
ldap/admin/src/scripts/Setup.pm.in

@@ -71,10 +71,10 @@ use File::Temp qw(tempfile tempdir);
 use SetupLog;
 
 # the setup types
-$SILENT = 0;
 $EXPRESS = 1;
 $TYPICAL = 2;
 $CUSTOM = 3;
+$SILENT = 4;
 
 # process command line options
 Getopt::Long::Configure(qw(bundling)); # bundling allows -ddddd