1 <?php
3 /*
4 This code is part of GOsa (https://gosa.gonicus.de)
5 Copyright (C) 2007 Fabian Hickert
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
23 class Step_Feedback extends setup_step
24 {
25 var $languages = array();
26 var $header_image = "images/welcome.png";
28 var $organization = "";
29 var $eMail = "";
30 var $name = "";
31 var $subscribe = TRUE;
32 var $use_gosa_announce = TRUE;
34 var $get_started = TRUE;
35 var $problems_encountered = "";
37 var $first_use = TRUE;
38 var $use_since = "";
40 var $distribution = "";
41 var $web_server = "";
42 var $php_version = "";
44 var $ldap_server = "";
45 var $object_count = "";
47 var $want_to_see_next = "";
49 var $features_used = array();
50 var $initialized = FALSE;
52 var $attributes = array("organization","eMail","name","subscribe","use_gosa_announce","get_started","problems_encountered","features_used",
53 "first_use","use_since","distribution","web_server","php_version","ldap_server","object_count","want_to_see_next");
56 function Step_Feedback()
57 {
58 $this->is_enabled = TRUE;
59 $this->is_active = TRUE;
60 $this->update_strings();
61 }
63 function init()
64 {
65 $cv = $this->parent->captured_values;
67 /* Initialize values */
68 $this->use_since = date("Y");
69 $this->organization = preg_replace("/^[^=]*+=(.*),.*$/","\\1",$cv['base']);
70 $this->distribution = PHP_OS."/".$_SERVER['SERVER_SOFTWARE'];
71 $this->web_server = $_SERVER['SERVER_SOFTWARE'];
73 $this->php_version = PHP_VERSION;
75 /* On first call check for rid/sid base */
76 $cv = $this->parent->captured_values;
77 $ldap = new LDAP($cv['admin'],
78 $cv['password'],
79 $cv['connection'],
80 FALSE,
81 $cv['tls']);
83 $ldap->cd($cv['base']);
84 $ldap->search("(objectClass=*)",array("dn"));
85 $this->object_count=$ldap->count();
87 $oc = $ldap->get_objectclasses();
90 $this->features_used = array();
91 $this->features_used['posix'] = array("USED" => isset($oc['posixAccount']) ,
92 "NAME" => _("UNIX accounts/groups"));
93 $this->features_used['samba'] = array("USED" => isset($oc['sambaSamAccount']) || isset($oc['sambaAccount']) ,
94 "NAME" => _("Samba management"));
95 $this->features_used['mail'] = array("USED" => $cv['mail'] != "none",
96 "NAME" => _("Mailsystem management"));
97 $this->features_used['fax'] = array("USED" => isset($oc['goFaxAccount']) ,
98 "NAME" => _("FAX system administration"));
99 $this->features_used['asterisk'] = array("USED" => isset($oc['goFonAccount']),
100 "NAME" => _("Asterisk administration"));
101 $this->features_used['inventory'] = array("USED" => isset($oc['glpiAccount']) ,
102 "NAME" => _("System invetory"));
103 $this->features_used['system'] = array("USED" => FALSE ,
104 "NAME" => _("System-/Configmanagement"));
105 $this->features_used['addressbook'] = array("USED" => FALSE ,
106 "NAME" => _("Addressbook"));
107 }
109 function update_strings()
110 {
111 $this->s_title = _("Notification and feedback");
112 $this->s_info = _("Get notifications or send feedback");
113 $this->s_title_long = _("Notification and feedback");
114 }
116 function execute()
117 {
118 if(!$this->initialized){
119 $this->initialized = TRUE;
120 $this->init();
121 }
123 $years = array();
124 for($i = date("Y") ; $i >= 2001; $i--){
125 $years[$i] = $i;
126 }
128 $this->is_completed=TRUE;
129 $smarty = get_smarty();
131 foreach($this->attributes as $attr){
132 $smarty->assign($attr, $this->$attr);
133 }
134 $smarty->assign("years",$years);
135 $smarty->assign("features_used",$this->features_used);
136 $smarty->assign ("must", "<font class=\"must\">*</font>");
137 return($smarty->fetch(get_template_path("setup_feedback.tpl",TRUE,dirname(__FILE__))));
138 }
140 function save_object()
141 {
142 if(isset($_POST['step_feedback'])){
143 foreach($this->attributes as $attr){
144 if(isset($_POST[$attr])){
145 $this->$attr = get_post($attr);
146 }
147 }
149 if(isset($_POST['subscribe'])){
150 $this->subscribe = TRUE;
151 }else{
152 $this->subscribe = FALSE;
153 }
155 if(isset($_POST['use_gosa_announce'])){
156 $this->use_gosa_announce = TRUE;
157 }else{
158 $this->use_gosa_announce = FALSE;
159 }
161 foreach($this->features_used as $key => $data){
162 if(isset($_POST['feature_'.$key])){
163 $this->features_used[$key]['USED'] = TRUE;
164 }else{
165 $this->features_used[$key]['USED'] = FALSE;
166 }
167 }
168 if(isset($_POST['send_feedback'])){
169 $str = $this->create_serialise_data_string();
171 $feedback_url = "http://dyn-111/hickert-test/feedback.php?data=".serialize($str);
172 $ret = fopen($feedback_url,"r");
173 $ret_value = fgets($ret,256);
174 fclose($ret);
176 if(!preg_match("/successfully/i",$ret_value)){
177 print_red(_("Could not send feedback."));
178 }
179 }
180 }
182 }
184 function create_serialise_data_string()
185 {
187 $str = "#FEEDBACK ".date("H:i:s d:m:Y");
188 if($this->subscribe){
190 $str.= "\n\nSubscribe";
191 $str .= "\nOrganization: ".$this->organization;
192 $str .= "\nName: ".$this->name;
193 $str .= "\neMail: ".$this->eMail;
194 }
196 if($this->use_gosa_announce){
198 $str.= "\n\nFeedback";
200 if($this->get_started) {
201 $str .= "\nGet started: TRUE";
202 }else{
203 $str .= "\nGet started: FALSE";
204 }
205 $str .= "\nProblems : ".base64_encode($this->problems_encountered);
207 if($this->first_use){
208 $str .= "\nFirst use: TRUE";
209 }else{
210 $str .= "\nFirst use: FALSE";
211 }
212 $str .= "\nUsing GOsa since: ".$this->use_since;
214 $str .="\nDistribution: ".$this->distribution;
215 $str .="\nWeb Server: ".$this->web_server;
216 $str .="\nPHP_Version: ".$this->php_version;
217 $str .="\nLDAP Server: ".$this->ldap_server;
218 $str .="\nObject count: ".$this->object_count;
219 $str .="\nMissing features: ".base64_encode($this->want_to_see_next);
220 }
222 $str .= "\n\nFeatures used";
223 foreach($this->features_used as $name => $data){
224 $str.="\n".$name.": ";
225 if($data['USED']){
226 $str .= "TRUE";
227 }else{
228 $str .= "FALSE";
229 }
230 }
232 return($str);
233 }
234 }
236 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
237 ?>