]> git.tokkee.org Git - gosa.git/commitdiff

Code

Udpated Feedback dialog
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 7 May 2007 13:56:29 +0000 (13:56 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 7 May 2007 13:56:29 +0000 (13:56 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6281 594d385d-05f5-0310-b6e9-bd551577e9d8

setup/class_setupStep_Feedback.inc
setup/setup_feedback.tpl

index af3a91a79d8be6289c9044f381c9098d269bcabb..4a7b0c9b8c31de76b1c33dc52a9d1564a42aa2fc 100644 (file)
 class Step_Feedback  extends setup_step
 {
   var $languages      = array();
-  var $attributes     = array();
   var $header_image   = "images/welcome.png";
 
+  var $organization       = "";
+  var $eMail              = "";
+  var $name               = "";
+  var $subscribe          = TRUE;
+  var $use_gosa_announce  = TRUE;
+
+  var $get_started          = TRUE;
+  var $problems_encountered = "";
+  
+  var $first_use            = TRUE;
+  var $use_since            = "";
+
+  var $distribution         = "";
+  var $web_server           = "";
+  var $php_version          = "";
+
+  var $ldap_server          = "";
+  var $object_count         = "";
+    
+  var $want_to_see_next     = "";
+
+  var $features_used        = array();  
+  var $initialized          = FALSE; 
+
+  var $attributes = array("organization","eMail","name","subscribe","use_gosa_announce","get_started","problems_encountered","features_used",
+                          "first_use","use_since","distribution","web_server","php_version","ldap_server","object_count","want_to_see_next");
+  
+
   function Step_Feedback()
   {
     $this->is_enabled     = TRUE;
@@ -33,6 +60,52 @@ class Step_Feedback  extends setup_step
     $this->update_strings(); 
   }
 
+  function init()
+  {
+    $cv = $this->parent->captured_values;
+
+    /* Initialize values */
+    $this->use_since      = date("Y");
+    $this->organization   = preg_replace("/^[^=]*+=(.*),.*$/","\\1",$cv['base']);
+    $this->distribution   = PHP_OS."/".$_SERVER['SERVER_SOFTWARE']; 
+    $this->web_server     = $_SERVER['SERVER_SOFTWARE'];
+
+    $this->php_version    = PHP_VERSION;
+
+    /* On first call check for rid/sid base */
+    $cv = $this->parent->captured_values;
+    $ldap = new LDAP($cv['admin'],
+        $cv['password'],
+        $cv['connection'],
+        FALSE,
+        $cv['tls']);
+
+    $ldap->cd($cv['base']);
+    $ldap->search("(objectClass=*)",array("dn"));
+    $this->object_count=$ldap->count();
+
+    $oc = $ldap->get_objectclasses();
+
+  
+    $this->features_used                = array();
+    $this->features_used['posix']       = array("USED" => isset($oc['posixAccount']) , 
+                                                "NAME" => _("UNIX accounts/groups"));
+    $this->features_used['samba']       = array("USED" => isset($oc['sambaSamAccount']) || isset($oc['sambaAccount']) , 
+                                                "NAME" => _("Samba management"));
+    $this->features_used['mail']        = array("USED" => $cv['mail']  != "none", 
+                                                "NAME" => _("Mailsystem management"));
+    $this->features_used['fax']         = array("USED" => isset($oc['goFaxAccount']) , 
+                                                "NAME" => _("FAX system administration"));
+    $this->features_used['asterisk']    = array("USED" => isset($oc['goFonAccount']), 
+                                                "NAME" => _("Asterisk administration"));
+    $this->features_used['inventory']   = array("USED" => isset($oc['glpiAccount']) , 
+                                                "NAME" => _("System invetory"));
+    $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");
@@ -42,16 +115,121 @@ class Step_Feedback  extends setup_step
   
   function execute()
   {
+    if(!$this->initialized){
+      $this->initialized = TRUE;
+      $this->init();
+    }
+
+    $years = array();
+    for($i = date("Y") ; $i >= 2001; $i--){
+      $years[$i] = $i;
+    }
+
     $this->is_completed=TRUE;
     $smarty = get_smarty();
+
+    foreach($this->attributes as $attr){
+      $smarty->assign($attr, $this->$attr);
+    }
+    $smarty->assign("years",$years);
+    $smarty->assign("features_used",$this->features_used);
     $smarty->assign ("must", "<font class=\"must\">*</font>");
-    $smarty->assign('auth_id', session_id());
     return($smarty->fetch(get_template_path("setup_feedback.tpl",TRUE,dirname(__FILE__))));
   }
 
   function save_object()
   {
+    if(isset($_POST['step_feedback'])){
+      foreach($this->attributes as $attr){
+        if(isset($_POST[$attr])){
+          $this->$attr = get_post($attr);
+        }
+      }
+
+      if(isset($_POST['subscribe'])){
+        $this->subscribe = TRUE;
+      }else{
+        $this->subscribe = FALSE;
+      }
+
+      if(isset($_POST['use_gosa_announce'])){
+        $this->use_gosa_announce = TRUE;
+      }else{
+        $this->use_gosa_announce = FALSE;
+      }
+    
+      foreach($this->features_used as $key => $data){
+        if(isset($_POST['feature_'.$key])){
+          $this->features_used[$key]['USED'] = TRUE;
+        }else{
+          $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){
+
+      $str.= "\n\nSubscribe";
+      $str .= "\nOrganization: ".$this->organization; 
+      $str .= "\nName: ".$this->name;
+      $str .= "\neMail: ".$this->eMail;
+    }
+  
+    if($this->use_gosa_announce){
+
+      $str.= "\n\nFeedback";    
+  
+      if($this->get_started) {
+        $str .= "\nGet started: TRUE";
+      }else{
+        $str .= "\nGet started: FALSE";
+      }
+      $str .= "\nProblems : ".base64_encode($this->problems_encountered);
+
+      if($this->first_use){
+        $str .= "\nFirst use: TRUE";
+      }else{
+        $str .= "\nFirst use: FALSE";
+      }
+      $str .= "\nUsing GOsa since: ".$this->use_since;
+
+      $str .="\nDistribution: ".$this->distribution;
+      $str .="\nWeb Server: ".$this->web_server;
+      $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 .= "\n\nFeatures used";
+    foreach($this->features_used as $name => $data){
+      $str.="\n".$name.": ";
+      if($data['USED']){
+        $str .= "TRUE";
+      }else{
+        $str .= "FALSE";
+      }
+    }
 
+    return($str);  
   }
 }
 
index efaf46ad1e2c4e42417b7388d80acdc23ddc91a0..7d6ffaf2af788ac373d8717969b5f53ce3029ef0 100644 (file)
@@ -1,7 +1,7 @@
 <div class='default' style='margin:12px; '>  
 
        <h2>
-               <input type='checkbox' name='use_gosa_announce' value='1' class='center'>&nbsp;{t}Subscribe to the gosa-announce mailinglist{/t}
+               <input {if $subscribe} checked {/if} type='checkbox' name='subscribe' value='1' class='center'>&nbsp;{t}Subscribe to the gosa-announce mailinglist{/t}
        </h2>
 
        {t}When checking this option, GOsa will try to connect http://oss.gonicus.de in order to subscribe you to the gosa-announce mailing list. You've to confirm this by mail.{/t}
@@ -12,7 +12,7 @@
                                {t}Organization{/t}
                        </td>
                        <td>
-                               <input name='' type='text' value=''>
+                               <input name='organization' type='text' value='{$organization}' style='width:300px;'>
                        </td>
                </tr>
                <tr>
@@ -20,7 +20,7 @@
                                {t}Name{/t}
                        </td>
                        <td>
-                               <input name='' type='text' value=''>
+                               <input name='name' type='text' value='{$name}' style='width:300px;'>
                        </td>
                </tr>
                <tr>
@@ -28,7 +28,7 @@
                                {t}eMail{/t}{$must}
                        </td>
                        <td>
-                               <input name='' type='text' value=''>    
+                               <input name='eMail' type='text' value='{$eMail}' style='width:300px;'>  
                        </td>
                </tr>
        </table>
@@ -36,8 +36,8 @@
 
        <p>&nbsp;</p>
        <h2>
-               <input type='checkbox' name='use_gosa_announce' value='1' class='center'>&nbsp;{t}Send feedback to the GOsa project team{/t}
-       </h2>
+               <input {if $use_gosa_announce} checked {/if} type='checkbox' name='use_gosa_announce' value='1' class='center'>&nbsp;{t}Send feedback to the GOsa project team{/t}
+       </h2> 
        {t}When checking this option, GOsa will try to connect http://oss.gonicus.de in order to submit your form anonymously.{/t}
        <br><b>{t}Generic{/t}</b>
        <table> 
@@ -46,9 +46,9 @@
                                {t}Did the setup procedure help you to get started?{/t}   
                        </td>
                        <td>
-                               <input type='radio' name='get_started' value='1'>{t}Yes{/t}
+                               <input {if $get_started} checked {/if} type='radio' name='get_started' value='1'>{t}Yes{/t}
                                <br>
-                               <input type='radio' name='get_started' value='0'>{t}No{/t}
+                               <input {if !$get_started} checked {/if} type='radio' name='get_started' value='0'>{t}No{/t}
                        </td>
                </tr>
                <tr>
@@ -56,7 +56,7 @@
                                {t}If not, what problems did you encounter{/t}:
                        </td>
                        <td>
-                               <textarea name='problems_encountered' rows='4' cols='20'style='width:100%'></textarea>
+                               <textarea name='problems_encountered' rows='4' cols='20'style='width:100%'>{$problems_encountered}</textarea>
                        </td>
                </tr>
                <tr>
                                {t}Is this the first time you use GOsa?{/t}
                        </td>
                        <td>
-                               <input type='radio' name='first_use' value='1'>{t}Yes{/t}
+                               <input {if $first_use} checked {/if} type='radio' name='first_use' value='1'>{t}Yes{/t}
                                <br>
-                               <input type='radio' name='first_use' value='0'>{t}No{/t}
+                               <input {if !$first_use} checked {/if} type='radio' name='first_use' value='0'>{t}No{/t}
                        </td>   
                </tr>
                <tr>
                        <td></td>
                        <td>
                                {t}I use it since{/t}
-                               <select name='use_since_month' title='{t}Select the month since when you are using GOsa{/t}'> 
-                                       <option></option>
-                               </select>
-                               <select name='use_since_year' title='{t}Select the year since when you are using GOsa{/t}'> 
-                                       <option></option>
+                               <select name='use_since' title='{t}Select the year since when you are using GOsa{/t}'> 
+                                       {html_options options=$years}
                                </select>
                        </td>
                </tr>
@@ -86,7 +83,7 @@
                                {t}What operation system / distribution do you use?{/t}
                        </td>
                        <td>
-                               <input type='text' name='distribution' value=''>
+                               <input type='text' name='distribution' value='{$distribution}'>
                        </td>
                </tr>
                <tr>
@@ -94,7 +91,7 @@
                                {t}What web server do you use?{/t}
                        </td>
                        <td>
-                               <input type='text' name='distribution' value=''>
+                               <input type='text' name='web_server' value='{$web_server}'>
                        </td>
                </tr>
                <tr>
                                {t}What PHP version do you use?{/t}
                        </td>
                        <td>
-                               <input type='text' name='distribution' value=''>
+                               <input type='text' name='php_version' value='{$php_version}'>
                        </td>
                </tr>
        </table>
                <tr>
                        <td>{t}What kind of LDAP server(s) do you use?{/t}
                        </td>
-                       <td><input type='text' name='distribution' value=''>
+                       <td><input type='text' name='ldap_server' value='{$ldap_server}'>
                        </td>
                </tr>
                <tr>
                        <td>{t}How many objects are in your LDAP?{/t}
                        </td>
-                       <td><input type='text' name='distribution' value=''>
+                       <td><input type='text' name='object_count' value='{$object_count}'>
                        </td>
                </tr>
        </table>
                        <td>{t}What features of GOsa do you use?{/t}
                        </td>
                        <td>
-                               [ ] POSIX (UNIX accounts/groups)
-                               [ ] Samba management
-                               [ ] Mailsystem management
-                               [ ] FAX system administration
-                               [ ] Asterisk administration
-                               [ ] System invetory
-                               [ ] System-/Configmanagement
-                               [ ] Addressbook
+                               {foreach from=$features_used item=data key=key}
+                                       <input type='checkbox' name='feature_{$key}' {if $data.USED} checked {/if}>
+                                       {$data.NAME}<br>
+                               {/foreach}
                        </td>
                </tr>
                <tr>
                        <td>{t}What features do you want to see in next versions of GOsa?{/t}
                        </td>
-                       <td><textarea name='want_to_see_next'></textarea>
+                       <td><textarea name='want_to_see_next'>{$want_to_see_next}</textarea>
                        </td>
                </tr>
        </table>
 </div>
+<input type='submit' name='send_feedback' value='{t}Send feedback{/t}'>
+<input type='hidden' name='step_feedback' value='1'>