Code

Cache results from get_module_departments.
[gosa.git] / setup / class_setupStep_Feedback.inc
index 4a7b0c9b8c31de76b1c33dc52a9d1564a42aa2fc..fbcfb4c97bfeb4d4be04e70f0d9e5d973ab05ac6 100644 (file)
@@ -28,9 +28,10 @@ class Step_Feedback  extends setup_step
   var $organization       = "";
   var $eMail              = "";
   var $name               = "";
-  var $subscribe          = TRUE;
-  var $use_gosa_announce  = TRUE;
+  var $subscribe          = FALSE;
+  var $use_gosa_announce  = FALSE;
 
+  var $feedback_url         = "http://oss.gonicus.de/gosa-feedback/";
   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"));
@@ -99,19 +98,21 @@ class Step_Feedback  extends setup_step
     $this->features_used['asterisk']    = array("USED" => isset($oc['goFonAccount']), 
                                                 "NAME" => _("Asterisk administration"));
     $this->features_used['inventory']   = array("USED" => isset($oc['glpiAccount']) , 
-                                                "NAME" => _("System invetory"));
+                                                "NAME" => _("System inventory"));
     $this->features_used['system']      = array("USED" => FALSE , 
                                                 "NAME" => _("System-/Configmanagement"));
     $this->features_used['addressbook'] = array("USED" => FALSE , 
                                                 "NAME" => _("Addressbook"));
   }
 
+
   function update_strings()
   {
-    $this->s_title      = _("Feedback");
-    $this->s_info       = _("In order to keep you up to date, you can simply check some of the options below.");
-    $this->s_title_long = _("Notification and registration");
+    $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,38 @@ class Step_Feedback  extends setup_step
       $this->init();
     }
 
+    $additional_info ="";
+
+    if(isset($_POST['send_feedback'])){
+
+      $msgs = $this->check_feedback();
+      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("/successful/i",$ret_value)){
+            print_red(_("Error while sending your feedback. The service is possible temporary unavailable"));
+          }else{
+            $additional_info = "<font color='green'>"._("Feedback sucessfully send")."</font>";
+          }
+        }
+        @fclose($ret);
+      }
+    }
+
     $years = array();
     for($i = date("Y") ; $i >= 2001; $i--){
       $years[$i] = $i;
@@ -133,10 +166,27 @@ class Step_Feedback  extends setup_step
     }
     $smarty->assign("years",$years);
     $smarty->assign("features_used",$this->features_used);
+    $smarty->assign("additional_info",$additional_info);
     $smarty->assign ("must", "<font class=\"must\">*</font>");
     return($smarty->fetch(get_template_path("setup_feedback.tpl",TRUE,dirname(__FILE__))));
   }
 
+
+  function check_feedback()
+  {
+    $msgs = array();
+    if(!is_email($this->eMail) || empty($this->eMail)){
+      $msgs[] = _("Please specify a valid email address.");
+    }
+
+    if(!$this->subscribe && !$this->use_gosa_announce){
+      $msgs[] = _("You should have enabled at least one option, to subscribe or send your feedback.");
+    }
+
+    return($msgs);
+  }
+  
+
   function save_object()
   {
     if(isset($_POST['step_feedback'])){
@@ -165,25 +215,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){
 
@@ -202,7 +239,7 @@ class Step_Feedback  extends setup_step
       }else{
         $str .= "\nGet started: FALSE";
       }
-      $str .= "\nProblems : ".base64_encode($this->problems_encountered);
+      $str .= "\nProblems : ".($this->problems_encountered);
 
       if($this->first_use){
         $str .= "\nFirst use: TRUE";
@@ -216,7 +253,7 @@ class Step_Feedback  extends setup_step
       $str .="\nPHP_Version: ".$this->php_version;
       $str .="\nLDAP Server: ".$this->ldap_server;
       $str .="\nObject count: ".$this->object_count;
-      $str .="\nMissing features: ".base64_encode($this->want_to_see_next);
+      $str .="\nMissing features: ".($this->want_to_see_next);
     }
 
     $str .= "\n\nFeatures used";