Code

Some feedback updates
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 8 May 2007 07:47:49 +0000 (07:47 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 8 May 2007 07:47:49 +0000 (07:47 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6288 594d385d-05f5-0310-b6e9-bd551577e9d8

setup/class_setupStep_Feedback.inc

index beb81dfe131e31a2de3ceab40116b38cdf452e25..59849117f9dcd9b4fe111cdc414e21c004f2e0d9 100644 (file)
@@ -31,6 +31,7 @@ class Step_Feedback  extends setup_step
   var $subscribe          = TRUE;
   var $use_gosa_announce  = TRUE;
 
+  var $feedback_url         = "https://oss.gonicus.de/feedback/send.php";
   var $get_started          = TRUE;
   var $problems_encountered = "";
   
@@ -60,6 +61,7 @@ class Step_Feedback  extends setup_step
     $this->update_strings(); 
   }
 
+
   function init()
   {
     $cv = $this->parent->captured_values;
@@ -67,9 +69,8 @@ class Step_Feedback  extends setup_step
     /* Initialize values */
     $this->use_since      = date("Y");
     $this->organization   = preg_replace("/^[^=]*+=(.*),.*$/","\\1",$cv['base']);
-    $this->distribution   = PHP_OS."/".$_SERVER['SERVER_SOFTWARE']; 
+    $this->distribution   = "";
     $this->web_server     = $_SERVER['SERVER_SOFTWARE'];
-
     $this->php_version    = PHP_VERSION;
 
     /* On first call check for rid/sid base */
@@ -79,14 +80,12 @@ class Step_Feedback  extends setup_step
         $cv['connection'],
         FALSE,
         $cv['tls']);
-
     $ldap->cd($cv['base']);
     $ldap->search("(objectClass=*)",array("dn"));
     $this->object_count=$ldap->count();
 
+    /* Preselect used features */
     $oc = $ldap->get_objectclasses();
-
-  
     $this->features_used                = array();
     $this->features_used['posix']       = array("USED" => isset($oc['posixAccount']) , 
                                                 "NAME" => _("UNIX accounts/groups"));
@@ -106,12 +105,14 @@ class Step_Feedback  extends setup_step
                                                 "NAME" => _("Addressbook"));
   }
 
+
   function update_strings()
   {
     $this->s_title      = _("Notification and feedback");
     $this->s_info       = _("Get notifications or send feedback");
     $this->s_title_long = _("Notification and feedback");
   }
+
   
   function execute()
   {
@@ -120,6 +121,34 @@ class Step_Feedback  extends setup_step
       $this->init();
     }
 
+    if(isset($_POST['send_feedback'])){
+
+      $msgs = $this->check();
+      if(count($msgs)){
+        foreach($msgs as $msg){
+          print_red($msg);
+        }
+      }else{
+        $str = $this->create_serialise_data_string(); 
+        $feedback_url = $this->feedback_url."?data=".base64_encode($str);
+
+        $ret = @fopen($feedback_url,"r");
+
+        if(!$ret){
+          print_red(sprintf(_("Could not connect to feedback server (%s). There is possibly no connection to the internet."),$this->feedback_url));
+        }else{
+          $ret_value="";
+          while($ret && !feof($ret)){
+            $ret_value.= fgets($ret,256);
+          }
+          if(!preg_match("/successfully/i",$ret_value)){
+            print_red(sprintf(_("Could not send feedback. Script said '%s'."),$ret_value));
+          }
+        }
+        @fclose($ret);
+      }
+    }
+
     $years = array();
     for($i = date("Y") ; $i >= 2001; $i--){
       $years[$i] = $i;
@@ -137,6 +166,17 @@ class Step_Feedback  extends setup_step
     return($smarty->fetch(get_template_path("setup_feedback.tpl",TRUE,dirname(__FILE__))));
   }
 
+
+  function check()
+  {
+    $msgs = array();
+    if(!is_email($this->eMail) || empty($this->eMail)){
+      $msgs[] = _("Please specify a valid email address.");
+    }
+    return($msgs);
+  }
+  
+
   function save_object()
   {
     if(isset($_POST['step_feedback'])){
@@ -165,25 +205,12 @@ class Step_Feedback  extends setup_step
           $this->features_used[$key]['USED'] = FALSE;
         }
       }
-      if(isset($_POST['send_feedback'])){
-        $str = $this->create_serialise_data_string();  
-      
-        $feedback_url = "http://dyn-111/hickert-test/feedback.php?data=".serialize($str);
-        $ret = fopen($feedback_url,"r");
-        $ret_value = fgets($ret,256);
-        fclose($ret);
-
-        if(!preg_match("/successfully/i",$ret_value)){
-          print_red(_("Could not send feedback."));
-        }
-      }
     }
-
   }
 
+
   function create_serialise_data_string()
   {
-
     $str = "#FEEDBACK ".date("H:i:s d:m:Y");
     if($this->subscribe){