Completed
Push — 1.11.x ( 4463da...cd5efc )
by José
55:32 queued 28:22
created
main/exercise/Hpdownload.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -23,14 +23,14 @@  discard block
 block discarded – undo
23 23
 //Event::event_download($doc_url);
24 24
 if (isset($_course['path'])) {
25 25
     $course_path = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
26
-	$full_file_name = $course_path.Security::remove_XSS($doc_url);
26
+    $full_file_name = $course_path.Security::remove_XSS($doc_url);
27 27
 } else {
28 28
     $course_path = api_get_path(SYS_COURSE_PATH).$cid.'/document';
29
-	$full_file_name = $course_path.Security::remove_XSS($doc_url);
29
+    $full_file_name = $course_path.Security::remove_XSS($doc_url);
30 30
 }
31 31
 
32 32
 if(!is_file($full_file_name)) {
33
-	exit;
33
+    exit;
34 34
 }
35 35
 
36 36
 if (!Security::check_abs_path($full_file_name, $course_path.'/')) {
@@ -41,16 +41,16 @@  discard block
 block discarded – undo
41 41
 $extension=strtolower($extension[sizeof($extension)-1]);
42 42
 
43 43
 switch($extension) {
44
-	case 'gz':		$content_type='application/x-gzip';			break;
45
-	case 'zip':		$content_type='application/zip';			break;
46
-	case 'pdf':		$content_type='application/pdf';			break;
47
-	case 'png':		$content_type='image/png';					break;
48
-	case 'gif':		$content_type='image/gif';					break;
49
-	case 'jpg':		$content_type='image/jpeg';					break;
50
-	case 'txt':		$content_type='text/plain';					break;
51
-	case 'htm':		$content_type='text/html';					break;
52
-	case 'html':	$content_type='text/html';					break;
53
-	default:		$content_type='application/octet-stream';	break;
44
+    case 'gz':		$content_type='application/x-gzip';			break;
45
+    case 'zip':		$content_type='application/zip';			break;
46
+    case 'pdf':		$content_type='application/pdf';			break;
47
+    case 'png':		$content_type='image/png';					break;
48
+    case 'gif':		$content_type='image/gif';					break;
49
+    case 'jpg':		$content_type='image/jpeg';					break;
50
+    case 'txt':		$content_type='text/plain';					break;
51
+    case 'htm':		$content_type='text/html';					break;
52
+    case 'html':	$content_type='text/html';					break;
53
+    default:		$content_type='application/octet-stream';	break;
54 54
 }
55 55
 
56 56
 header('Content-disposition: filename='.$filename);
@@ -68,30 +68,30 @@  discard block
 block discarded – undo
68 68
 */
69 69
 
70 70
 if ($content_type == 'text/html') {
71
-	$directory_name = dirname($full_file_name);
71
+    $directory_name = dirname($full_file_name);
72 72
 
73
-	$dir=str_replace(array('\\',$_configuration['root_sys']."courses/".$_course['path'].'/document'),array('/',''),$directory_name);
73
+    $dir=str_replace(array('\\',$_configuration['root_sys']."courses/".$_course['path'].'/document'),array('/',''),$directory_name);
74 74
 
75
-	if($dir[strlen($dir)-1] != '/') {
76
-		$dir.='/';
77
-	}
75
+    if($dir[strlen($dir)-1] != '/') {
76
+        $dir.='/';
77
+    }
78 78
 
79 79
 
80
-	//Parse whole file at one
81
-	$fp = fopen($full_file_name, "r");
82
-	$file_content = fread ($fp, filesize ($full_file_name));
83
-	fclose($fp);
80
+    //Parse whole file at one
81
+    $fp = fopen($full_file_name, "r");
82
+    $file_content = fread ($fp, filesize ($full_file_name));
83
+    fclose($fp);
84 84
     $exercisePath = api_get_self();
85
-  	$exfile = explode('/',$exercisePath);
86
-  	$exfile = $exfile[sizeof($exfile)-1];
87
-  	$exercisePath = substr($exercisePath,0,strpos($exercisePath,$exfile));
88
-  	$exercisePath = $exercisePath;
85
+        $exfile = explode('/',$exercisePath);
86
+        $exfile = $exfile[sizeof($exfile)-1];
87
+        $exercisePath = substr($exercisePath,0,strpos($exercisePath,$exfile));
88
+        $exercisePath = $exercisePath;
89 89
 
90
-		$content = $file_content;
91
-		$mit = "function Finish(){";
90
+        $content = $file_content;
91
+        $mit = "function Finish(){";
92 92
 
93
-		$js_content = "var SaveScoreVariable = 0; // This variable included by Dokeos System\n".
94
-		"function mySaveScore() // This function included by Dokeos System\n".
93
+        $js_content = "var SaveScoreVariable = 0; // This variable included by Dokeos System\n".
94
+        "function mySaveScore() // This function included by Dokeos System\n".
95 95
 "{\n".
96 96
 "   if (SaveScoreVariable==0)\n".
97 97
 "		{\n".
@@ -109,23 +109,23 @@  discard block
 block discarded – undo
109 109
 "// Must be included \n".
110 110
 "function Finish(){\n".
111 111
 " mySaveScore();";
112
-		$newcontent = str_replace($mit,$js_content,$content);
112
+        $newcontent = str_replace($mit,$js_content,$content);
113 113
 
114
-		$prehref="javascript:void(0);";
115
-		$posthref = api_get_path(WEB_CODE_PATH) . "main/exercise/Hpdownload.php?doc_url=".$doc_url."&cid=".$cid."&uid=".$uid;
116
-		$newcontent = str_replace($prehref,$posthref,$newcontent);
114
+        $prehref="javascript:void(0);";
115
+        $posthref = api_get_path(WEB_CODE_PATH) . "main/exercise/Hpdownload.php?doc_url=".$doc_url."&cid=".$cid."&uid=".$uid;
116
+        $newcontent = str_replace($prehref,$posthref,$newcontent);
117 117
 
118 118
 
119
-		$prehref="class=\"GridNum\" onclick=";
120
-		$posthref="class=\"GridNum\" onMouseover=";
121
-		$newcontent = str_replace($prehref,$posthref,$newcontent);
119
+        $prehref="class=\"GridNum\" onclick=";
120
+        $posthref="class=\"GridNum\" onMouseover=";
121
+        $newcontent = str_replace($prehref,$posthref,$newcontent);
122 122
 
123 123
 
124
-		header('Content-length: '.strlen($newcontent));
125
-		// Dipsp.
126
-		echo $newcontent;
124
+        header('Content-length: '.strlen($newcontent));
125
+        // Dipsp.
126
+        echo $newcontent;
127 127
 
128
-	exit();
128
+    exit();
129 129
 }
130 130
 
131 131
 //normal case, all non-html files
Please login to merge, or discard this patch.
main/webservices/cm_webservice.php 1 patch
Indentation   +137 added lines, -137 removed lines patch added patch discarded remove patch
@@ -82,12 +82,12 @@  discard block
 block discarded – undo
82 82
  */
83 83
 interface WSCMErrorHandler
84 84
 {
85
-	/**
86
-	 * Handle method
87
-	 *
88
-	 * @param WSError Error
89
-	 */
90
-	public function handle($error);
85
+    /**
86
+     * Handle method
87
+     *
88
+     * @param WSError Error
89
+     */
90
+    public function handle($error);
91 91
 }
92 92
 
93 93
 /**
@@ -95,57 +95,57 @@  discard block
 block discarded – undo
95 95
  */
96 96
 class WSCM
97 97
 {
98
-	/**
99
-	 * Chamilo configuration
100
-	 *
101
-	 * @var array
102
-	 */
103
-	protected $_configuration;
98
+    /**
99
+     * Chamilo configuration
100
+     *
101
+     * @var array
102
+     */
103
+    protected $_configuration;
104 104
 
105
-	/**
106
-	 * Constructor
107
-	 */
108
-	public function __construct()
105
+    /**
106
+     * Constructor
107
+     */
108
+    public function __construct()
109 109
     {
110
-		$this->_configuration = $GLOBALS['_configuration'];
111
-	}
110
+        $this->_configuration = $GLOBALS['_configuration'];
111
+    }
112 112
 
113
-	/**
114
-	 * Verifies the API key
115
-	 *
116
-	 * @param string Secret key
117
-	 * @return mixed WSError in case of failure, null in case of success
118
-	 */
119
-	protected function verifyKey($secret_key)
113
+    /**
114
+     * Verifies the API key
115
+     *
116
+     * @param string Secret key
117
+     * @return mixed WSError in case of failure, null in case of success
118
+     */
119
+    protected function verifyKey($secret_key)
120 120
     {
121
-		$ip = trim($_SERVER['REMOTE_ADDR']);
122
-		// if we are behind a reverse proxy, assume it will send the
123
-		// HTTP_X_FORWARDED_FOR header and use this IP instead
124
-		if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
125
-		  list($ip1,$ip2) = split(',',$_SERVER['HTTP_X_FORWARDED_FOR']);
126
-		  $ip = trim($ip1);
127
-		}
128
-		$security_key = $ip.$this->_configuration['security_key'];
121
+        $ip = trim($_SERVER['REMOTE_ADDR']);
122
+        // if we are behind a reverse proxy, assume it will send the
123
+        // HTTP_X_FORWARDED_FOR header and use this IP instead
124
+        if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
125
+            list($ip1,$ip2) = split(',',$_SERVER['HTTP_X_FORWARDED_FOR']);
126
+            $ip = trim($ip1);
127
+        }
128
+        $security_key = $ip.$this->_configuration['security_key'];
129 129
 
130
-		if(!api_is_valid_secret_key($secret_key, $security_key)) {
131
-			return new WSCMError(1, "API key is invalid");
132
-		} else {
133
-			return null;
134
-		}
135
-	}
130
+        if(!api_is_valid_secret_key($secret_key, $security_key)) {
131
+            return new WSCMError(1, "API key is invalid");
132
+        } else {
133
+            return null;
134
+        }
135
+    }
136 136
 
137
-	/**
138
-	 * Verifies if the user is valid
139
-	 *
140
-	 * @param <String> $username of the user in chamilo
141
-	 * @param <String> $pass of the same user (in MD5 of SHA)
142
-	 *
143
-	 * return "valid" if username e password are correct! Else, return a message error
144
-	 */
145
-	public function verifyUserPass($username, $pass)
137
+    /**
138
+     * Verifies if the user is valid
139
+     *
140
+     * @param <String> $username of the user in chamilo
141
+     * @param <String> $pass of the same user (in MD5 of SHA)
142
+     *
143
+     * return "valid" if username e password are correct! Else, return a message error
144
+     */
145
+    public function verifyUserPass($username, $pass)
146 146
     {
147
-		$login = $username;
148
-		$password = $pass;
147
+        $login = $username;
148
+        $password = $pass;
149 149
 
150 150
         $userRepo = UserManager::getRepository();
151 151
         /** @var User $uData */
@@ -178,17 +178,17 @@  discard block
 block discarded – undo
178 178
             }
179 179
         }
180 180
         return get_lang('InvalidId');
181
-	}
181
+    }
182 182
 
183
-	/**
184
-	 * Gets the real user id based on the user id field name and value.
185
-	 * Note that if the user id field name is "chamilo_user_id", it will use the user id
186
-	 * in the system database
187
-	 *
188
-	 * @param string User id field name
189
-	 * @param string User id value
190
-	 * @return mixed System user id if the user was found, WSError otherwise
191
-	 */
183
+    /**
184
+     * Gets the real user id based on the user id field name and value.
185
+     * Note that if the user id field name is "chamilo_user_id", it will use the user id
186
+     * in the system database
187
+     *
188
+     * @param string User id field name
189
+     * @param string User id value
190
+     * @return mixed System user id if the user was found, WSError otherwise
191
+     */
192 192
     protected function getUserId($user_id_field_name, $user_id_value)
193 193
     {
194 194
         if ($user_id_field_name == "chamilo_user_id") {
@@ -210,16 +210,16 @@  discard block
 block discarded – undo
210 210
         }
211 211
     }
212 212
 
213
-	/**
214
-	 * Gets the real course id based on the course id field name and value.
215
-	 * Note that if the course id field name is "chamilo_course_id", it will use the course id
216
-	 * in the system database
217
-	 *
218
-	 * @param string Course id field name
219
-	 * @param string Course id value
220
-	 * @return mixed System course id if the course was found, WSError otherwise
221
-	 */
222
-	protected function getCourseId($course_id_field_name, $course_id_value)
213
+    /**
214
+     * Gets the real course id based on the course id field name and value.
215
+     * Note that if the course id field name is "chamilo_course_id", it will use the course id
216
+     * in the system database
217
+     *
218
+     * @param string Course id field name
219
+     * @param string Course id value
220
+     * @return mixed System course id if the course was found, WSError otherwise
221
+     */
222
+    protected function getCourseId($course_id_field_name, $course_id_value)
223 223
     {
224 224
         if ($course_id_field_name == "chamilo_course_id") {
225 225
             if (CourseManager::get_course_code_from_course_id($course_id_value) != null) {
@@ -238,78 +238,78 @@  discard block
 block discarded – undo
238 238
                 return $courseId;
239 239
             }
240 240
         }
241
-	}
241
+    }
242 242
 
243
-	/**
244
-	 * Gets the real session id based on the session id field name and value.
245
-	 * Note that if the session id field name is "chamilo_session_id", it will use the session id
246
-	 * in the system database
247
-	 *
248
-	 * @param string Session id field name
249
-	 * @param string Session id value
250
-	 * @return mixed System session id if the session was found, WSError otherwise
251
-	 */
252
-	protected function getSessionId($session_id_field_name, $session_id_value)
253
-	{
254
-		if ($session_id_field_name == "chamilo_session_id") {
255
-			$session = SessionManager::fetch((int)$session_id_value);
256
-			if(!empty($session)) {
257
-				return intval($session_id_value);
258
-			} else {
259
-				return new WSCMError(300, "Session not found");
260
-			}
261
-		} else {
262
-			$session_id = SessionManager::getSessionIdFromOriginalId(
263
-				$session_id_value,
264
-				$session_id_field_name
265
-			);
266
-			if($session_id == 0) {
267
-				return new WSCMError(300, "Session not found");
268
-			} else {
269
-				return $session_id;
270
-			}
271
-		}
272
-	}
243
+    /**
244
+     * Gets the real session id based on the session id field name and value.
245
+     * Note that if the session id field name is "chamilo_session_id", it will use the session id
246
+     * in the system database
247
+     *
248
+     * @param string Session id field name
249
+     * @param string Session id value
250
+     * @return mixed System session id if the session was found, WSError otherwise
251
+     */
252
+    protected function getSessionId($session_id_field_name, $session_id_value)
253
+    {
254
+        if ($session_id_field_name == "chamilo_session_id") {
255
+            $session = SessionManager::fetch((int)$session_id_value);
256
+            if(!empty($session)) {
257
+                return intval($session_id_value);
258
+            } else {
259
+                return new WSCMError(300, "Session not found");
260
+            }
261
+        } else {
262
+            $session_id = SessionManager::getSessionIdFromOriginalId(
263
+                $session_id_value,
264
+                $session_id_field_name
265
+            );
266
+            if($session_id == 0) {
267
+                return new WSCMError(300, "Session not found");
268
+            } else {
269
+                return $session_id;
270
+            }
271
+        }
272
+    }
273 273
 
274
-	/**
275
-	 * Handles an error by calling the WSError error handler
276
-	 *
277
-	 * @param WSError Error
278
-	 */
279
-	protected function handleError($error)
280
-	{
281
-		$handler = WSCMError::getErrorHandler();
282
-		$handler->handle($error);
283
-	}
274
+    /**
275
+     * Handles an error by calling the WSError error handler
276
+     *
277
+     * @param WSError Error
278
+     */
279
+    protected function handleError($error)
280
+    {
281
+        $handler = WSCMError::getErrorHandler();
282
+        $handler->handle($error);
283
+    }
284 284
 
285
-	/**
286
-	 * Gets a successful result
287
-	 *
288
-	 * @return array Array with a code of 0 and a message 'Operation was successful'
289
-	 */
290
-	protected function getSuccessfulResult()
291
-	{
292
-		return array('code' => 0, 'message' => 'Operation was successful');
293
-	}
285
+    /**
286
+     * Gets a successful result
287
+     *
288
+     * @return array Array with a code of 0 and a message 'Operation was successful'
289
+     */
290
+    protected function getSuccessfulResult()
291
+    {
292
+        return array('code' => 0, 'message' => 'Operation was successful');
293
+    }
294 294
 
295
-	/**
296
-	 * Test function. Returns the string success
297
-	 *
298
-	 * @return string Success
299
-	 */
300
-	public function test()
301
-	{
302
-		return "success";
303
-	}
295
+    /**
296
+     * Test function. Returns the string success
297
+     *
298
+     * @return string Success
299
+     */
300
+    public function test()
301
+    {
302
+        return "success";
303
+    }
304 304
 
305
-	/**
306
-	 * *Strictly* reverts PHP's nl2br() effects (whether it was used in XHTML mode or not)
307
-	 * @param <type> $string
308
-	 * @return <type> $string
309
-	 */
310
-	public function nl2br_revert($string)
305
+    /**
306
+     * *Strictly* reverts PHP's nl2br() effects (whether it was used in XHTML mode or not)
307
+     * @param <type> $string
308
+     * @return <type> $string
309
+     */
310
+    public function nl2br_revert($string)
311 311
     {
312
-		return preg_replace('`<br(?: /)?>([\\n\\r])`', '$1', $string);
313
-	}
312
+        return preg_replace('`<br(?: /)?>([\\n\\r])`', '$1', $string);
313
+    }
314 314
 }
315 315
 
Please login to merge, or discard this patch.
main/webservices/cm_webservice_user.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -13,21 +13,21 @@  discard block
 block discarded – undo
13 13
 
14 14
     public function find_id_user($username, $password, $name)
15 15
     {
16
-         if ($this->verifyUserPass($username, $password) == "valid") {
16
+            if ($this->verifyUserPass($username, $password) == "valid") {
17 17
             $listResult = "#";
18 18
 
19 19
             $listArrayResult = Array();
20 20
             $listArray = Array();
21 21
 
22 22
             $list = $this->get_user_list_like_start(array('firstname'=>$name), array('firstname'));
23
-             foreach ($list as $userData) {
24
-                 $listArray[] = $userData['user_id'];
25
-             }
23
+                foreach ($list as $userData) {
24
+                    $listArray[] = $userData['user_id'];
25
+                }
26 26
 
27 27
             $list = $this->get_user_list_like_start(array('lastname'=>$name), array('firstname'));
28
-             foreach ($list as $userData) {
29
-                 $listArray[] = $userData['user_id'];
30
-             }
28
+                foreach ($list as $userData) {
29
+                    $listArray[] = $userData['user_id'];
30
+                }
31 31
 
32 32
             $list = $this->get_user_list_like_start(array('email'=>$name), array('firstname'));
33 33
             foreach ($list as $userData) {
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
     {
90 90
         global $charset;
91 91
         if ($this->verifyUserPass($username, $password) == "valid") {
92
-		    $user_id = UserManager::get_user_id_from_username($username);
92
+            $user_id = UserManager::get_user_id_from_username($username);
93 93
             $message_title = get_lang('Invitation');
94 94
             $count_is_true = SocialManager::send_invitation_friend($user_id,$userfriend_id, $message_title, $content_message);
95 95
 
@@ -129,14 +129,14 @@  discard block
 block discarded – undo
129 129
 
130 130
 
131 131
     /**
132
-    * Get a list of users of which the given conditions match with a LIKE '%cond%'
133
-    * @param array $conditions a list of condition (exemple : status=>STUDENT)
134
-    * @param array $order_by a list of fields on which sort
135
-    * @return array An array with all users of the platform.
136
-    * @todo optional course code parameter, optional sorting parameters...
132
+     * Get a list of users of which the given conditions match with a LIKE '%cond%'
133
+     * @param array $conditions a list of condition (exemple : status=>STUDENT)
134
+     * @param array $order_by a list of fields on which sort
135
+     * @return array An array with all users of the platform.
136
+     * @todo optional course code parameter, optional sorting parameters...
137 137
      *@todo Use the UserManager class
138 138
      * @todo security filter order by
139
-    */
139
+     */
140 140
     private static function get_user_list_like_start($conditions = array(), $order_by = array())
141 141
     {
142 142
         $user_table = Database :: get_main_table(TABLE_MAIN_USER);
Please login to merge, or discard this patch.
main/gradebook/lib/be/studentpublicationlink.class.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -195,7 +195,7 @@
 block discarded – undo
195 195
         $parentId = !$assignment ? 0 : $assignment->getId();
196 196
 
197 197
         if (empty($session)) {
198
-           $dql = 'SELECT a FROM ChamiloCourseBundle:CStudentPublication a
198
+            $dql = 'SELECT a FROM ChamiloCourseBundle:CStudentPublication a
199 199
                    WHERE
200 200
                         a.cId = :course AND
201 201
                         a.active = :active AND
Please login to merge, or discard this patch.
main/exercise/hotpotatoes_exercise_result.class.php 1 patch
Indentation   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -14,15 +14,15 @@  discard block
 block discarded – undo
14 14
     //stores the results
15 15
     private $results = array();
16 16
 
17
-	/**
18
-	 * Gets the results of all students (or just one student if access is limited)
19
-	 * @param	string		The document path (for HotPotatoes retrieval)
20
-	 * @param	integer		User ID. Optional. If no user ID is provided, we take all the results. Defauts to null
21
-	 * @param string $document_path
22
-	 */
23
-	public function getExercisesReporting($document_path, $hotpotato_name)
17
+    /**
18
+     * Gets the results of all students (or just one student if access is limited)
19
+     * @param	string		The document path (for HotPotatoes retrieval)
20
+     * @param	integer		User ID. Optional. If no user ID is provided, we take all the results. Defauts to null
21
+     * @param string $document_path
22
+     */
23
+    public function getExercisesReporting($document_path, $hotpotato_name)
24 24
     {
25
-		$return = array();
25
+        $return = array();
26 26
         $TBL_USER = Database::get_main_table(TABLE_MAIN_USER);
27 27
         $TBL_TRACK_HOTPOTATOES	= Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
28 28
 
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
         $hotpotato_name  = Database::escape_string($hotpotato_name);
35 35
 
36 36
         if (!empty($exercise_id)) {
37
-          $session_id_and .= " AND exe_exo_id = $exercise_id ";
37
+            $session_id_and .= " AND exe_exo_id = $exercise_id ";
38 38
         }
39 39
 
40 40
         if (empty($user_id)) {
@@ -111,25 +111,25 @@  discard block
 block discarded – undo
111 111
         $this->results = $return;
112 112
 
113 113
         return true;
114
-	}
114
+    }
115 115
 
116 116
 
117
-	/**
118
-	 * Exports the complete report as a CSV file
119
-	 * @param	string		Document path inside the document tool
120
-	 * @param	integer		Optional user ID
121
-	 * @param	boolean		Whether to include user fields or not
122
-	 * @return	boolean		False on error
123
-	 */
124
-	public function exportCompleteReportCSV($document_path = '', $hotpotato_name)
117
+    /**
118
+     * Exports the complete report as a CSV file
119
+     * @param	string		Document path inside the document tool
120
+     * @param	integer		Optional user ID
121
+     * @param	boolean		Whether to include user fields or not
122
+     * @return	boolean		False on error
123
+     */
124
+    public function exportCompleteReportCSV($document_path = '', $hotpotato_name)
125 125
     {
126
-		global $charset;
127
-		$this->getExercisesReporting($document_path, $hotpotato_name);
128
-		$filename = 'exercise_results_'.date('YmdGis').'.csv';
129
-		if (!empty($user_id)) {
130
-			$filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.csv';
131
-		}
132
-		$data = '';
126
+        global $charset;
127
+        $this->getExercisesReporting($document_path, $hotpotato_name);
128
+        $filename = 'exercise_results_'.date('YmdGis').'.csv';
129
+        if (!empty($user_id)) {
130
+            $filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.csv';
131
+        }
132
+        $data = '';
133 133
 
134 134
         if (api_is_western_name_order()) {
135 135
             if(!empty($this->results[0]['first_name'])) {
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
         }
149 149
         $data .= get_lang('Email').';';
150 150
 
151
-		/*if ($export_user_fields) {
151
+        /*if ($export_user_fields) {
152 152
 			//show user fields section with a big th colspan that spans over all fields
153 153
 			$extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
154 154
 			$num = count($extra_user_fields);
@@ -157,25 +157,25 @@  discard block
 block discarded – undo
157 157
 			}
158 158
 		}*/
159 159
 
160
-		$data .= get_lang('Title').';';
161
-		$data .= get_lang('StartDate').';';
162
-		$data .= get_lang('Score').';';
163
-		$data .= get_lang('Total').';';
164
-		$data .= "\n";
160
+        $data .= get_lang('Title').';';
161
+        $data .= get_lang('StartDate').';';
162
+        $data .= get_lang('Score').';';
163
+        $data .= get_lang('Total').';';
164
+        $data .= "\n";
165 165
 
166
-		//results
167
-		foreach($this->results as $row) {
166
+        //results
167
+        foreach($this->results as $row) {
168 168
             if (api_is_western_name_order()) {
169
-              $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
170
-              $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
169
+                $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
170
+                $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
171 171
             } else {
172
-              $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
173
-              $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
172
+                $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset)).';';
173
+                $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
174 174
             }
175 175
 
176 176
             $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)).';';
177 177
 
178
-			/*if ($export_user_fields) {
178
+            /*if ($export_user_fields) {
179 179
 				//show user fields data, if any, for this user
180 180
 				$user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
181 181
 				foreach($user_fields_values as $value) {
@@ -183,40 +183,40 @@  discard block
 block discarded – undo
183 183
 				}
184 184
 			}*/
185 185
 
186
-			$data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';';
187
-			$data .= str_replace("\r\n",'  ',$row['exe_date']).';';
188
-			$data .= str_replace("\r\n",'  ',$row['result']).';';
189
-			$data .= str_replace("\r\n",'  ',$row['max']).';';
190
-			$data .= "\n";
191
-		}
192
-
193
-		//output the results
194
-		$len = strlen($data);
195
-		header('Content-type: application/octet-stream');
196
-		header('Content-Type: application/force-download');
197
-		header('Content-length: '.$len);
198
-		if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) {
199
-			header('Content-Disposition: filename= '.$filename);
200
-		} else {
201
-			header('Content-Disposition: attachment; filename= '.$filename);
202
-		}
203
-		if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
204
-			header('Pragma: ');
205
-			header('Cache-Control: ');
206
-			header('Cache-Control: public'); // IE cannot download from sessions without a cache
207
-		}
208
-		header('Content-Description: '.$filename);
209
-		header('Content-transfer-encoding: binary');
210
-		// @todo add this utf-8 header for all csv files
211
-		echo "\xEF\xBB\xBF";  // force utf-8 header of csv file
212
-		echo $data;
213
-		return true;
214
-	}
215
-
216
-	/**
217
-	 * Exports the complete report as an XLS file
218
-	 * @return	boolean		False on error
219
-	 */
186
+            $data .= str_replace("\r\n",'  ',api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';';
187
+            $data .= str_replace("\r\n",'  ',$row['exe_date']).';';
188
+            $data .= str_replace("\r\n",'  ',$row['result']).';';
189
+            $data .= str_replace("\r\n",'  ',$row['max']).';';
190
+            $data .= "\n";
191
+        }
192
+
193
+        //output the results
194
+        $len = strlen($data);
195
+        header('Content-type: application/octet-stream');
196
+        header('Content-Type: application/force-download');
197
+        header('Content-length: '.$len);
198
+        if (preg_match("/MSIE 5.5/", $_SERVER['HTTP_USER_AGENT'])) {
199
+            header('Content-Disposition: filename= '.$filename);
200
+        } else {
201
+            header('Content-Disposition: attachment; filename= '.$filename);
202
+        }
203
+        if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
204
+            header('Pragma: ');
205
+            header('Cache-Control: ');
206
+            header('Cache-Control: public'); // IE cannot download from sessions without a cache
207
+        }
208
+        header('Content-Description: '.$filename);
209
+        header('Content-transfer-encoding: binary');
210
+        // @todo add this utf-8 header for all csv files
211
+        echo "\xEF\xBB\xBF";  // force utf-8 header of csv file
212
+        echo $data;
213
+        return true;
214
+    }
215
+
216
+    /**
217
+     * Exports the complete report as an XLS file
218
+     * @return	boolean		False on error
219
+     */
220 220
     public function exportCompleteReportXLS(
221 221
         $document_path = '',
222 222
         $user_id = null,
@@ -225,36 +225,36 @@  discard block
 block discarded – undo
225 225
         $exercise_id = 0,
226 226
         $hotpotato_name = null
227 227
     ) {
228
-		global $charset;
229
-		$this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name);
230
-		$filename = 'exercise_results_'.api_get_local_time().'.xls';
231
-		if (!empty($user_id)) {
232
-			$filename = 'exercise_results_user_'.$user_id.'_'.api_get_local_time().'.xls';
233
-		}
228
+        global $charset;
229
+        $this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name);
230
+        $filename = 'exercise_results_'.api_get_local_time().'.xls';
231
+        if (!empty($user_id)) {
232
+            $filename = 'exercise_results_user_'.$user_id.'_'.api_get_local_time().'.xls';
233
+        }
234 234
 
235 235
         $spreadsheet = new PHPExcel();
236 236
         $spreadsheet->setActiveSheetIndex(0);
237 237
         $worksheet = $spreadsheet->getActiveSheet();
238 238
 
239 239
 
240
-		$line = 0;
241
-		$column = 0; //skip the first column (row titles)
240
+        $line = 0;
241
+        $column = 0; //skip the first column (row titles)
242 242
 
243
-		// check if exists column 'user'
244
-		$with_column_user = false;
245
-		foreach ($this->results as $result) {
246
-			if (!empty($result['last_name']) && !empty($result['first_name'])) {
247
-				$with_column_user = true;
248
-				break;
249
-			}
250
-		}
243
+        // check if exists column 'user'
244
+        $with_column_user = false;
245
+        foreach ($this->results as $result) {
246
+            if (!empty($result['last_name']) && !empty($result['first_name'])) {
247
+                $with_column_user = true;
248
+                break;
249
+            }
250
+        }
251 251
 
252
-		if ($with_column_user) {
253
-		    $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Email'));
254
-		    $column++;
252
+        if ($with_column_user) {
253
+            $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Email'));
254
+            $column++;
255 255
             if (api_is_western_name_order()) {
256
-    			$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('FirstName'));
257
-    			$column++;
256
+                $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('FirstName'));
257
+                $column++;
258 258
                 $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('LastName'));
259 259
                 $column++;
260 260
             } else {
@@ -263,14 +263,14 @@  discard block
 block discarded – undo
263 263
                 $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('FirstName'));
264 264
                 $column++;
265 265
             }
266
-		}
266
+        }
267 267
 
268
-		if ($export_user_fields) {
269
-			//show user fields section with a big th colspan that spans over all fields
270
-			$extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
268
+        if ($export_user_fields) {
269
+            //show user fields section with a big th colspan that spans over all fields
270
+            $extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
271 271
 
272
-			//show the fields names for user fields
273
-			foreach ($extra_user_fields as $field) {
272
+            //show the fields names for user fields
273
+            foreach ($extra_user_fields as $field) {
274 274
                 $worksheet->setCellValueByColumnAndRow(
275 275
                     $column,
276 276
                     $line,
@@ -280,27 +280,27 @@  discard block
 block discarded – undo
280 280
                         $charset
281 281
                     )
282 282
                 );
283
-				$column++;
284
-			}
285
-		}
283
+                $column++;
284
+            }
285
+        }
286 286
 
287
-		$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Title'));
288
-		$column++;
289
-		$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('StartDate'));
287
+        $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Title'));
288
+        $column++;
289
+        $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('StartDate'));
290 290
         $column++;
291 291
         $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('EndDate'));
292 292
         $column++;
293 293
         $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Duration').' ('.get_lang('MinMinutes').')');
294
-		$column++;
295
-		$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Score'));
296
-		$column++;
297
-		$worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Total'));
298
-		$column++;
294
+        $column++;
295
+        $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Score'));
296
+        $column++;
297
+        $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Total'));
298
+        $column++;
299 299
         $worksheet->setCellValueByColumnAndRow($column, $line, get_lang('Status'));
300
-		$line++;
300
+        $line++;
301 301
 
302
-		foreach ($this->results as $row) {
303
-			$column = 0;
302
+        foreach ($this->results as $row) {
303
+            $column = 0;
304 304
 
305 305
             if ($with_column_user) {
306 306
                 $worksheet->setCellValueByColumnAndRow(
@@ -325,38 +325,38 @@  discard block
 block discarded – undo
325 325
                     $worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset));
326 326
                     $column++;
327 327
                 }
328
-			}
328
+            }
329 329
 
330
-			if ($export_user_fields) {
331
-				//show user fields data, if any, for this user
332
-				$user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
333
-				foreach($user_fields_values as $value) {
334
-					$worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset));
335
-					$column++;
336
-				}
337
-			}
330
+            if ($export_user_fields) {
331
+                //show user fields data, if any, for this user
332
+                $user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
333
+                foreach($user_fields_values as $value) {
334
+                    $worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset));
335
+                    $column++;
336
+                }
337
+            }
338 338
 
339
-			$worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset));
340
-			$column++;
341
-			$worksheet->setCellValueByColumnAndRow($column, $line, $row['start_date']);
339
+            $worksheet->setCellValueByColumnAndRow($column, $line, api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset));
340
+            $column++;
341
+            $worksheet->setCellValueByColumnAndRow($column, $line, $row['start_date']);
342 342
             $column++;
343
-			$worksheet->setCellValueByColumnAndRow($column, $line, $row['end_date']);
343
+            $worksheet->setCellValueByColumnAndRow($column, $line, $row['end_date']);
344
+            $column++;
345
+            $worksheet->setCellValueByColumnAndRow($column, $line, $row['duration']);
346
+            $column++;
347
+            $worksheet->setCellValueByColumnAndRow($column, $line, $row['result']);
348
+            $column++;
349
+            $worksheet->setCellValueByColumnAndRow($column, $line, $row['max']);
344 350
             $column++;
345
-			$worksheet->setCellValueByColumnAndRow($column, $line, $row['duration']);
346
-			$column++;
347
-			$worksheet->setCellValueByColumnAndRow($column, $line, $row['result']);
348
-			$column++;
349
-			$worksheet->setCellValueByColumnAndRow($column, $line, $row['max']);
350
-			$column++;
351 351
             $worksheet->setCellValueByColumnAndRow($column, $line, $row['status']);
352
-			$line++;
353
-		}
352
+            $line++;
353
+        }
354 354
 
355 355
         $file = api_get_path(SYS_ARCHIVE_PATH).api_replace_dangerous_char($filename);
356 356
         $writer = new PHPExcel_Writer_Excel2007($spreadsheet);
357 357
         $writer->save($file);
358 358
         DocumentManager::file_send_for_download($file, true, $filename);
359 359
 
360
-		return true;
361
-	}
360
+        return true;
361
+    }
362 362
 }
Please login to merge, or discard this patch.
main/inc/lib/tracking.lib.php 1 patch
Indentation   +849 added lines, -849 removed lines patch added patch discarded remove patch
@@ -314,8 +314,8 @@  discard block
 block discarded – undo
314 314
                     $extend_link = '';
315 315
                     if (!empty($inter_num)) {
316 316
                         $extend_link = Display::url(
317
-                              Display::return_icon('visible.gif', get_lang('HideAttemptView')),
318
-                              api_get_self() . '?action=stats&fold_id=' . $my_item_id . $url_suffix
317
+                                Display::return_icon('visible.gif', get_lang('HideAttemptView')),
318
+                                api_get_self() . '?action=stats&fold_id=' . $my_item_id . $url_suffix
319 319
                         );
320 320
                     }
321 321
                     $title = $row['mytitle'];
@@ -1370,7 +1370,7 @@  discard block
 block discarded – undo
1370 1370
                 $newDate = new DateTime('-30 days', new DateTimeZone('UTC'));
1371 1371
                 $condition_time = " AND (login_date >= '{$newDate->format('Y-m-d H:i:s')}'";
1372 1372
                 $condition_time .= "AND logout_date <= '{$today->format('Y-m-d H:i:s')}') ";
1373
-               break;
1373
+                break;
1374 1374
             case 'custom':
1375 1375
                 if (!empty($start_date) && !empty($end_date)) {
1376 1376
                     $start_date = Database::escape_string($start_date);
@@ -1380,10 +1380,10 @@  discard block
 block discarded – undo
1380 1380
                 break;
1381 1381
         }
1382 1382
 
1383
-    	$sql = 'SELECT SUM(TIMESTAMPDIFF(SECOND, login_date, logout_date)) diff
1383
+        $sql = 'SELECT SUM(TIMESTAMPDIFF(SECOND, login_date, logout_date)) diff
1384 1384
     	        FROM '.$tbl_track_login.'
1385 1385
                 WHERE '.$userCondition.$condition_time;
1386
-    	$rs = Database::query($sql);
1386
+        $rs = Database::query($sql);
1387 1387
         $row = Database::fetch_array($rs, 'ASSOC');
1388 1388
         $diff = $row['diff'];
1389 1389
 
@@ -1405,18 +1405,18 @@  discard block
 block discarded – undo
1405 1405
     public static function get_time_spent_on_the_course($user_id, $courseId, $session_id = 0)
1406 1406
     {
1407 1407
         $courseId = intval($courseId);
1408
-    	$session_id  = intval($session_id);
1409
-
1410
-    	$tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1411
-    	if (is_array($user_id)) {
1412
-    	    $user_id = array_map('intval', $user_id);
1413
-    		$condition_user = " AND user_id IN (".implode(',',$user_id).") ";
1414
-    	} else {
1415
-    		$user_id = intval($user_id);
1416
-    		$condition_user = " AND user_id = $user_id ";
1417
-    	}
1418
-
1419
-    	$sql = "SELECT
1408
+        $session_id  = intval($session_id);
1409
+
1410
+        $tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1411
+        if (is_array($user_id)) {
1412
+            $user_id = array_map('intval', $user_id);
1413
+            $condition_user = " AND user_id IN (".implode(',',$user_id).") ";
1414
+        } else {
1415
+            $user_id = intval($user_id);
1416
+            $condition_user = " AND user_id = $user_id ";
1417
+        }
1418
+
1419
+        $sql = "SELECT
1420 1420
     	        SUM(UNIX_TIMESTAMP(logout_course_date) - UNIX_TIMESTAMP(login_course_date)) as nb_seconds
1421 1421
                 FROM $tbl_track_course
1422 1422
                 WHERE UNIX_TIMESTAMP(logout_course_date) > UNIX_TIMESTAMP(login_course_date) ";
@@ -1431,9 +1431,9 @@  discard block
 block discarded – undo
1431 1431
 
1432 1432
         $sql .= $condition_user;
1433 1433
         $rs = Database::query($sql);
1434
-    	$row = Database::fetch_array($rs);
1434
+        $row = Database::fetch_array($rs);
1435 1435
 
1436
-    	return $row['nb_seconds'];
1436
+        return $row['nb_seconds'];
1437 1437
     }
1438 1438
 
1439 1439
     /**
@@ -1444,25 +1444,25 @@  discard block
 block discarded – undo
1444 1444
      */
1445 1445
     public static function get_first_connection_date($student_id)
1446 1446
     {
1447
-    	$tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1448
-    	$sql = 'SELECT login_date
1447
+        $tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1448
+        $sql = 'SELECT login_date
1449 1449
     	        FROM ' . $tbl_track_login . '
1450 1450
                 WHERE login_user_id = ' . intval($student_id) . '
1451 1451
                 ORDER BY login_date ASC
1452 1452
                 LIMIT 0,1';
1453 1453
 
1454
-    	$rs = Database::query($sql);
1455
-    	if (Database::num_rows($rs)>0) {
1456
-    		if ($first_login_date = Database::result($rs, 0, 0)) {
1454
+        $rs = Database::query($sql);
1455
+        if (Database::num_rows($rs)>0) {
1456
+            if ($first_login_date = Database::result($rs, 0, 0)) {
1457 1457
                 return api_convert_and_format_date(
1458 1458
                     $first_login_date,
1459 1459
                     DATE_FORMAT_SHORT,
1460 1460
                     date_default_timezone_get()
1461 1461
                 );
1462
-    		}
1463
-    	}
1462
+            }
1463
+        }
1464 1464
 
1465
-    	return false;
1465
+        return false;
1466 1466
     }
1467 1467
 
1468 1468
     /**
@@ -1475,38 +1475,38 @@  discard block
 block discarded – undo
1475 1475
      */
1476 1476
     public static function get_last_connection_date($student_id, $warning_message = false, $return_timestamp = false)
1477 1477
     {
1478
-    	$table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1479
-    	$sql = 'SELECT login_date
1478
+        $table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
1479
+        $sql = 'SELECT login_date
1480 1480
     	        FROM ' . $table . '
1481 1481
                 WHERE login_user_id = ' . intval($student_id) . '
1482 1482
                 ORDER BY login_date
1483 1483
                 DESC LIMIT 0,1';
1484 1484
 
1485
-    	$rs = Database::query($sql);
1486
-    	if (Database::num_rows($rs) > 0) {
1487
-    		if ($last_login_date = Database::result($rs, 0, 0)) {
1488
-    			$last_login_date = api_get_local_time($last_login_date);
1489
-    			if ($return_timestamp) {
1490
-    				return api_strtotime($last_login_date,'UTC');
1491
-    			} else {
1492
-    				if (!$warning_message) {
1493
-    					return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1494
-    				} else {
1495
-    					$timestamp = api_strtotime($last_login_date,'UTC');
1496
-    					$currentTimestamp = time();
1497
-
1498
-    					//If the last connection is > than 7 days, the text is red
1499
-    					//345600 = 7 days in seconds
1500
-    					if ($currentTimestamp - $timestamp > 604800) {
1501
-    						return '<span style="color: #F00;">' . api_format_date($last_login_date, DATE_FORMAT_SHORT) . '</span>';
1502
-    					} else {
1503
-    						return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1504
-    					}
1505
-    				}
1506
-    			}
1507
-    		}
1508
-    	}
1509
-    	return false;
1485
+        $rs = Database::query($sql);
1486
+        if (Database::num_rows($rs) > 0) {
1487
+            if ($last_login_date = Database::result($rs, 0, 0)) {
1488
+                $last_login_date = api_get_local_time($last_login_date);
1489
+                if ($return_timestamp) {
1490
+                    return api_strtotime($last_login_date,'UTC');
1491
+                } else {
1492
+                    if (!$warning_message) {
1493
+                        return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1494
+                    } else {
1495
+                        $timestamp = api_strtotime($last_login_date,'UTC');
1496
+                        $currentTimestamp = time();
1497
+
1498
+                        //If the last connection is > than 7 days, the text is red
1499
+                        //345600 = 7 days in seconds
1500
+                        if ($currentTimestamp - $timestamp > 604800) {
1501
+                            return '<span style="color: #F00;">' . api_format_date($last_login_date, DATE_FORMAT_SHORT) . '</span>';
1502
+                        } else {
1503
+                            return api_format_date($last_login_date, DATE_FORMAT_SHORT);
1504
+                        }
1505
+                    }
1506
+                }
1507
+            }
1508
+        }
1509
+        return false;
1510 1510
     }
1511 1511
 
1512 1512
     /**
@@ -1560,30 +1560,30 @@  discard block
 block discarded – undo
1560 1560
         $session_id = 0,
1561 1561
         $convert_date = true
1562 1562
     ) {
1563
-    	$student_id  = intval($student_id);
1563
+        $student_id  = intval($student_id);
1564 1564
         $courseId = intval($courseId);
1565
-    	$session_id  = intval($session_id);
1565
+        $session_id  = intval($session_id);
1566 1566
 
1567
-    	$tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1568
-    	$sql = 'SELECT login_course_date
1567
+        $tbl_track_login = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1568
+        $sql = 'SELECT login_course_date
1569 1569
     	        FROM '.$tbl_track_login.'
1570 1570
                 WHERE
1571 1571
                     user_id = '.$student_id.' AND
1572 1572
                     c_id = '.$courseId.' AND
1573 1573
                     session_id = '.$session_id.'
1574 1574
                 ORDER BY login_course_date ASC LIMIT 0,1';
1575
-    	$rs = Database::query($sql);
1576
-    	if (Database::num_rows($rs) > 0) {
1577
-    		if ($first_login_date = Database::result($rs, 0, 0)) {
1578
-    			if ($convert_date) {
1579
-    				return api_convert_and_format_date($first_login_date, DATE_FORMAT_SHORT);
1580
-    			} else {
1581
-    				return $first_login_date;
1582
-    			}
1583
-    		}
1584
-    	}
1585
-
1586
-    	return false;
1575
+        $rs = Database::query($sql);
1576
+        if (Database::num_rows($rs) > 0) {
1577
+            if ($first_login_date = Database::result($rs, 0, 0)) {
1578
+                if ($convert_date) {
1579
+                    return api_convert_and_format_date($first_login_date, DATE_FORMAT_SHORT);
1580
+                } else {
1581
+                    return $first_login_date;
1582
+                }
1583
+            }
1584
+        }
1585
+
1586
+        return false;
1587 1587
     }
1588 1588
 
1589 1589
     /**
@@ -1599,13 +1599,13 @@  discard block
 block discarded – undo
1599 1599
         $session_id = 0,
1600 1600
         $convert_date = true
1601 1601
     ) {
1602
-    	// protect data
1603
-    	$student_id  = intval($student_id);
1602
+        // protect data
1603
+        $student_id  = intval($student_id);
1604 1604
         $courseId = $courseInfo['real_id'];
1605
-    	$session_id  = intval($session_id);
1605
+        $session_id  = intval($session_id);
1606 1606
 
1607
-    	$tbl_track_e_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
1608
-    	$sql = 'SELECT access_date
1607
+        $tbl_track_e_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
1608
+        $sql = 'SELECT access_date
1609 1609
                 FROM '.$tbl_track_e_access.'
1610 1610
                 WHERE   access_user_id = '.$student_id.' AND
1611 1611
                         c_id = "'.$courseId.'" AND
@@ -1613,39 +1613,39 @@  discard block
 block discarded – undo
1613 1613
                 ORDER BY access_date DESC
1614 1614
                 LIMIT 0,1';
1615 1615
 
1616
-    	$rs = Database::query($sql);
1617
-    	if (Database::num_rows($rs) > 0) {
1618
-    		if ($last_login_date = Database::result($rs, 0, 0)) {
1616
+        $rs = Database::query($sql);
1617
+        if (Database::num_rows($rs) > 0) {
1618
+            if ($last_login_date = Database::result($rs, 0, 0)) {
1619 1619
                 if (empty($last_login_date)) {
1620 1620
                     return false;
1621 1621
                 }
1622 1622
                 //see #5736
1623 1623
                 $last_login_date_timestamp = api_strtotime($last_login_date);
1624
-    			$now = time();
1625
-    			//If the last connection is > than 7 days, the text is red
1626
-    			//345600 = 7 days in seconds
1627
-    			if ($now - $last_login_date_timestamp > 604800) {
1628
-    				if ($convert_date) {
1624
+                $now = time();
1625
+                //If the last connection is > than 7 days, the text is red
1626
+                //345600 = 7 days in seconds
1627
+                if ($now - $last_login_date_timestamp > 604800) {
1628
+                    if ($convert_date) {
1629 1629
                         $last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT);
1630 1630
                         $icon = api_is_allowed_to_edit() ?
1631 1631
                             '<a href="'.api_get_path(WEB_CODE_PATH).'announcements/announcements.php?action=add&remind_inactive='.$student_id.'&cidReq='.$courseInfo['code'].'" title="'.get_lang('RemindInactiveUser').'">
1632 1632
                               '.Display::return_icon('messagebox_warning.gif').'
1633 1633
                              </a>'
1634 1634
                             : null;
1635
-    					return $icon. Display::label($last_login_date, 'warning');
1636
-    				} else {
1637
-    					return $last_login_date;
1638
-    				}
1639
-    			} else {
1640
-    				if ($convert_date) {
1641
-    					return api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT);
1642
-    				} else {
1643
-    					return $last_login_date;
1644
-    				}
1645
-    			}
1646
-    		}
1647
-    	}
1648
-    	return false;
1635
+                        return $icon. Display::label($last_login_date, 'warning');
1636
+                    } else {
1637
+                        return $last_login_date;
1638
+                    }
1639
+                } else {
1640
+                    if ($convert_date) {
1641
+                        return api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT);
1642
+                    } else {
1643
+                        return $last_login_date;
1644
+                    }
1645
+                }
1646
+            }
1647
+        }
1648
+        return false;
1649 1649
     }
1650 1650
 
1651 1651
     /**
@@ -1659,11 +1659,11 @@  discard block
 block discarded – undo
1659 1659
     public static function get_course_connections_count($courseId, $session_id = 0, $start = 0, $stop = null)
1660 1660
     {
1661 1661
         if ($start < 0) {
1662
-    		$start = 0;
1663
-    	}
1664
-    	if (!isset($stop) or ($stop < 0)) {
1665
-    		$stop = api_get_utc_datetime();
1666
-    	}
1662
+            $start = 0;
1663
+        }
1664
+        if (!isset($stop) or ($stop < 0)) {
1665
+            $stop = api_get_utc_datetime();
1666
+        }
1667 1667
 
1668 1668
         // Given we're storing in cache, round the start and end times
1669 1669
         // to the lower minute
@@ -1672,11 +1672,11 @@  discard block
 block discarded – undo
1672 1672
         $roundedStart = Database::escape_string($roundedStart);
1673 1673
         $roundedStop = Database::escape_string($roundedStop);
1674 1674
 
1675
-    	$month_filter = " AND login_course_date > '$roundedStart' AND login_course_date < '$roundedStop' ";
1675
+        $month_filter = " AND login_course_date > '$roundedStart' AND login_course_date < '$roundedStop' ";
1676 1676
 
1677 1677
         $courseId = intval($courseId);
1678
-    	$session_id  = intval($session_id);
1679
-    	$count = 0;
1678
+        $session_id  = intval($session_id);
1679
+        $count = 0;
1680 1680
         $tbl_track_e_course_access = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
1681 1681
         $sql =  "SELECT count(*) as count_connections
1682 1682
                 FROM $tbl_track_e_course_access
@@ -1715,7 +1715,7 @@  discard block
 block discarded – undo
1715 1715
             }
1716 1716
         }
1717 1717
 
1718
-    	return $count;
1718
+        return $count;
1719 1719
     }
1720 1720
 
1721 1721
     /**
@@ -1726,25 +1726,25 @@  discard block
 block discarded – undo
1726 1726
      */
1727 1727
     public static function count_course_per_student($user_id, $include_sessions = true)
1728 1728
     {
1729
-    	$user_id = intval($user_id);
1730
-    	$tbl_course_rel_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
1731
-    	$tbl_session_course_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
1729
+        $user_id = intval($user_id);
1730
+        $tbl_course_rel_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
1731
+        $tbl_session_course_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
1732 1732
 
1733
-    	$sql = 'SELECT DISTINCT c_id
1733
+        $sql = 'SELECT DISTINCT c_id
1734 1734
                 FROM ' . $tbl_course_rel_user . '
1735 1735
                 WHERE user_id = ' . $user_id.' AND relation_type<>'.COURSE_RELATION_TYPE_RRHH;
1736
-    	$rs = Database::query($sql);
1737
-    	$nb_courses = Database::num_rows($rs);
1736
+        $rs = Database::query($sql);
1737
+        $nb_courses = Database::num_rows($rs);
1738 1738
 
1739
-    	if ($include_sessions) {
1740
-    		$sql = 'SELECT DISTINCT c_id
1739
+        if ($include_sessions) {
1740
+            $sql = 'SELECT DISTINCT c_id
1741 1741
                     FROM ' . $tbl_session_course_rel_user . '
1742 1742
                     WHERE user_id = ' . $user_id;
1743
-    		$rs = Database::query($sql);
1744
-    		$nb_courses += Database::num_rows($rs);
1745
-    	}
1743
+            $rs = Database::query($sql);
1744
+            $nb_courses += Database::num_rows($rs);
1745
+        }
1746 1746
 
1747
-    	return $nb_courses;
1747
+        return $nb_courses;
1748 1748
     }
1749 1749
 
1750 1750
     /**
@@ -1775,25 +1775,25 @@  discard block
 block discarded – undo
1775 1775
         $into_lp = 0
1776 1776
     ) {
1777 1777
         $course_code = Database::escape_string($course_code);
1778
-    	$course_info = api_get_course_info($course_code);
1779
-    	if (!empty($course_info)) {
1780
-    		// table definition
1781
-    		$tbl_course_quiz     = Database::get_course_table(TABLE_QUIZ_TEST);
1782
-    		$tbl_stats_exercise  = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1783
-
1784
-    		// Compose a filter based on optional exercise given
1785
-    		$condition_quiz = "";
1786
-    		if (!empty($exercise_id)) {
1787
-    			$exercise_id = intval($exercise_id);
1788
-    			$condition_quiz =" AND id = $exercise_id ";
1789
-    		}
1790
-
1791
-    		// Compose a filter based on optional session id given
1792
-    		$condition_session = "";
1793
-    		if (isset($session_id)) {
1794
-    			$session_id = intval($session_id);
1795
-    			$condition_session = " AND session_id = $session_id ";
1796
-    		}
1778
+        $course_info = api_get_course_info($course_code);
1779
+        if (!empty($course_info)) {
1780
+            // table definition
1781
+            $tbl_course_quiz     = Database::get_course_table(TABLE_QUIZ_TEST);
1782
+            $tbl_stats_exercise  = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1783
+
1784
+            // Compose a filter based on optional exercise given
1785
+            $condition_quiz = "";
1786
+            if (!empty($exercise_id)) {
1787
+                $exercise_id = intval($exercise_id);
1788
+                $condition_quiz =" AND id = $exercise_id ";
1789
+            }
1790
+
1791
+            // Compose a filter based on optional session id given
1792
+            $condition_session = "";
1793
+            if (isset($session_id)) {
1794
+                $session_id = intval($session_id);
1795
+                $condition_session = " AND session_id = $session_id ";
1796
+            }
1797 1797
             if ($active_filter == 1) {
1798 1798
                 $condition_active = 'AND active <> -1';
1799 1799
             } elseif ($active_filter == 0) {
@@ -1809,7 +1809,7 @@  discard block
 block discarded – undo
1809 1809
                 $select_lp_id = ', orig_lp_id as lp_id ';
1810 1810
             }
1811 1811
 
1812
-    		$sql = "SELECT count(id) FROM $tbl_course_quiz
1812
+            $sql = "SELECT count(id) FROM $tbl_course_quiz
1813 1813
     				WHERE c_id = {$course_info['real_id']} $condition_active $condition_quiz ";
1814 1814
             $count_quiz = 0;
1815 1815
             $countQuizResult = Database::query($sql);
@@ -1817,21 +1817,21 @@  discard block
 block discarded – undo
1817 1817
                 $count_quiz = Database::fetch_row($countQuizResult);
1818 1818
             }
1819 1819
 
1820
-    		if (!empty($count_quiz[0]) && !empty($student_id)) {
1821
-    			if (is_array($student_id)) {
1820
+            if (!empty($count_quiz[0]) && !empty($student_id)) {
1821
+                if (is_array($student_id)) {
1822 1822
                     $student_id = array_map('intval', $student_id);
1823
-    				$condition_user = " AND exe_user_id IN (".implode(',', $student_id).") ";
1824
-    			} else {
1823
+                    $condition_user = " AND exe_user_id IN (".implode(',', $student_id).") ";
1824
+                } else {
1825 1825
                     $student_id = intval($student_id);
1826
-    				$condition_user = " AND exe_user_id = '$student_id' ";
1827
-    			}
1826
+                    $condition_user = " AND exe_user_id = '$student_id' ";
1827
+                }
1828 1828
 
1829
-    			if (empty($exercise_id)) {
1830
-    				$sql = "SELECT id FROM $tbl_course_quiz
1829
+                if (empty($exercise_id)) {
1830
+                    $sql = "SELECT id FROM $tbl_course_quiz
1831 1831
     						WHERE c_id = {$course_info['real_id']} $condition_active $condition_quiz";
1832 1832
                     $result = Database::query($sql);
1833 1833
                     $exercise_list = array();
1834
-    				$exercise_id = null;
1834
+                    $exercise_id = null;
1835 1835
                     if (!empty($result) && Database::num_rows($result)) {
1836 1836
                         while ($row = Database::fetch_array($result)) {
1837 1837
                             $exercise_list[] = $row['id'];
@@ -1840,11 +1840,11 @@  discard block
 block discarded – undo
1840 1840
                     if (!empty($exercise_list)) {
1841 1841
                         $exercise_id = implode("','",$exercise_list);
1842 1842
                     }
1843
-    			}
1843
+                }
1844 1844
 
1845
-    			$count_quiz = Database::fetch_row(Database::query($sql));
1845
+                $count_quiz = Database::fetch_row(Database::query($sql));
1846 1846
 
1847
-    			$sql = "SELECT
1847
+                $sql = "SELECT
1848 1848
     			        SUM(exe_result/exe_weighting*100) as avg_score,
1849 1849
     			        COUNT(*) as num_attempts
1850 1850
     			        $select_lp_id
@@ -1858,20 +1858,20 @@  discard block
 block discarded – undo
1858 1858
                             $condition_into_lp
1859 1859
                         ORDER BY exe_date DESC";
1860 1860
 
1861
-    			$res = Database::query($sql);
1862
-    			$row = Database::fetch_array($res);
1863
-    			$quiz_avg_score = null;
1861
+                $res = Database::query($sql);
1862
+                $row = Database::fetch_array($res);
1863
+                $quiz_avg_score = null;
1864 1864
 
1865
-    			if (!empty($row['avg_score'])) {
1866
-    				$quiz_avg_score = round($row['avg_score'],2);
1867
-    			}
1865
+                if (!empty($row['avg_score'])) {
1866
+                    $quiz_avg_score = round($row['avg_score'],2);
1867
+                }
1868 1868
 
1869
-    			if(!empty($row['num_attempts'])) {
1870
-    				$quiz_avg_score = round($quiz_avg_score / $row['num_attempts'], 2);
1871
-    			}
1872
-    			if (is_array($student_id)) {
1873
-    				$quiz_avg_score = round($quiz_avg_score / count($student_id), 2);
1874
-    			}
1869
+                if(!empty($row['num_attempts'])) {
1870
+                    $quiz_avg_score = round($quiz_avg_score / $row['num_attempts'], 2);
1871
+                }
1872
+                if (is_array($student_id)) {
1873
+                    $quiz_avg_score = round($quiz_avg_score / count($student_id), 2);
1874
+                }
1875 1875
                 if ($into_lp == 0) {
1876 1876
                     return $quiz_avg_score;
1877 1877
                 } else {
@@ -1894,9 +1894,9 @@  discard block
 block discarded – undo
1894 1894
                         return array($quiz_avg_score, null);
1895 1895
                     }
1896 1896
                 }
1897
-    		}
1898
-    	}
1899
-    	return null;
1897
+            }
1898
+        }
1899
+        return null;
1900 1900
     }
1901 1901
 
1902 1902
     /**
@@ -1929,15 +1929,15 @@  discard block
 block discarded – undo
1929 1929
         $find_all_lp = 0
1930 1930
     ) {
1931 1931
         $courseId = intval($courseId);
1932
-    	$student_id  = intval($student_id);
1933
-    	$exercise_id = intval($exercise_id);
1934
-    	$session_id  = intval($session_id);
1932
+        $student_id  = intval($student_id);
1933
+        $exercise_id = intval($exercise_id);
1934
+        $session_id  = intval($session_id);
1935 1935
 
1936
-    	$lp_id = intval($lp_id);
1936
+        $lp_id = intval($lp_id);
1937 1937
         $lp_item_id = intval($lp_item_id);
1938
-    	$tbl_stats_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1938
+        $tbl_stats_exercises = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
1939 1939
 
1940
-    	$sql = "SELECT COUNT(ex.exe_id) as essais FROM $tbl_stats_exercises AS ex
1940
+        $sql = "SELECT COUNT(ex.exe_id) as essais FROM $tbl_stats_exercises AS ex
1941 1941
                 WHERE  ex.c_id = $courseId
1942 1942
                 AND ex.exe_exo_id = $exercise_id
1943 1943
                 AND status = ''
@@ -1952,11 +1952,11 @@  discard block
 block discarded – undo
1952 1952
                 AND orig_lp_item_id = $lp_item_id";
1953 1953
         }
1954 1954
 
1955
-    	$rs = Database::query($sql);
1956
-    	$row = Database::fetch_row($rs);
1957
-    	$count_attempts = $row[0];
1955
+        $rs = Database::query($sql);
1956
+        $row = Database::fetch_row($rs);
1957
+        $count_attempts = $row[0];
1958 1958
 
1959
-    	return $count_attempts;
1959
+        return $count_attempts;
1960 1960
     }
1961 1961
 
1962 1962
     /**
@@ -1966,7 +1966,7 @@  discard block
 block discarded – undo
1966 1966
      * @param int    $user_id
1967 1967
      * @param int    $courseId
1968 1968
      * @param int    $session_id
1969
-    */
1969
+     */
1970 1970
     public static function get_exercise_student_progress($exercise_list, $user_id, $courseId, $session_id)
1971 1971
     {
1972 1972
         $courseId = intval($courseId);
@@ -3634,8 +3634,8 @@  discard block
 block discarded – undo
3634 3634
 
3635 3635
         $condition_session = '';
3636 3636
         if (isset($session_id)) {
3637
-             $session_id = intval($session_id);
3638
-             $condition_session = ' AND f.session_id = '. $session_id;
3637
+                $session_id = intval($session_id);
3638
+                $condition_session = ' AND f.session_id = '. $session_id;
3639 3639
         }
3640 3640
 
3641 3641
         $groupId = intval($groupId);
@@ -5564,9 +5564,9 @@  discard block
 block discarded – undo
5564 5564
     }
5565 5565
 
5566 5566
     /**
5567
-    * @param FormValidator $form
5568
-    * @return mixed
5569
-    */
5567
+     * @param FormValidator $form
5568
+     * @return mixed
5569
+     */
5570 5570
     public static function setUserSearchForm($form)
5571 5571
     {
5572 5572
         global $_configuration;
@@ -5961,26 +5961,26 @@  discard block
 block discarded – undo
5961 5961
         $session_id = api_get_session_id();
5962 5962
         $course_id = api_get_course_int_id();
5963 5963
 
5964
-    	$table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
5965
-    	$table_user = Database :: get_main_table(TABLE_MAIN_USER);
5964
+        $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
5965
+        $table_user = Database :: get_main_table(TABLE_MAIN_USER);
5966 5966
 
5967
-    	$sql = "SELECT count(tool) AS total_number_of_items
5967
+        $sql = "SELECT count(tool) AS total_number_of_items
5968 5968
     	        FROM $table_item_property track_resource, $table_user user
5969 5969
     	        WHERE
5970 5970
                     track_resource.c_id = $course_id AND
5971 5971
                     track_resource.insert_user_id = user.user_id AND
5972 5972
                     session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id ");
5973 5973
 
5974
-    	if (isset($_GET['keyword'])) {
5975
-    		$keyword = Database::escape_string(trim($_GET['keyword']));
5976
-    		$sql .= " AND (
5974
+        if (isset($_GET['keyword'])) {
5975
+            $keyword = Database::escape_string(trim($_GET['keyword']));
5976
+            $sql .= " AND (
5977 5977
     		            user.username LIKE '%".$keyword."%' OR
5978 5978
     		            lastedit_type LIKE '%".$keyword."%' OR
5979 5979
     		            tool LIKE '%".$keyword."%'
5980 5980
                     )";
5981
-    	}
5981
+        }
5982 5982
 
5983
-    	$sql .= " AND tool IN (
5983
+        $sql .= " AND tool IN (
5984 5984
     	            'document',
5985 5985
     	            'learnpath',
5986 5986
     	            'quiz',
@@ -5992,10 +5992,10 @@  discard block
 block discarded – undo
5992 5992
     	            'thematic_advance',
5993 5993
     	            'thematic_plan'
5994 5994
                 )";
5995
-    	$res = Database::query($sql);
5996
-    	$obj = Database::fetch_object($res);
5995
+        $res = Database::query($sql);
5996
+        $obj = Database::fetch_object($res);
5997 5997
 
5998
-    	return $obj->total_number_of_items;
5998
+        return $obj->total_number_of_items;
5999 5999
     }
6000 6000
 
6001 6001
     /**
@@ -6010,12 +6010,12 @@  discard block
 block discarded – undo
6010 6010
         $session_id = api_get_session_id();
6011 6011
         $course_id = api_get_course_int_id();
6012 6012
 
6013
-    	$table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
6014
-    	$table_user = Database :: get_main_table(TABLE_MAIN_USER);
6015
-    	$table_session = Database :: get_main_table(TABLE_MAIN_SESSION);
6016
-    	$session_id = intval($session_id);
6013
+        $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
6014
+        $table_user = Database :: get_main_table(TABLE_MAIN_USER);
6015
+        $table_session = Database :: get_main_table(TABLE_MAIN_SESSION);
6016
+        $session_id = intval($session_id);
6017 6017
 
6018
-    	$sql = "SELECT
6018
+        $sql = "SELECT
6019 6019
                     tool as col0,
6020 6020
                     lastedit_type as col1,
6021 6021
                     ref as ref,
@@ -6029,16 +6029,16 @@  discard block
 block discarded – undo
6029 6029
                   track_resource.insert_user_id = user.user_id AND
6030 6030
                   session_id " .(empty($session_id) ? ' IS NULL ' : " = $session_id ");
6031 6031
 
6032
-    	if (isset($_GET['keyword'])) {
6033
-    		$keyword = Database::escape_string(trim($_GET['keyword']));
6034
-    		$sql .= " AND (
6032
+        if (isset($_GET['keyword'])) {
6033
+            $keyword = Database::escape_string(trim($_GET['keyword']));
6034
+            $sql .= " AND (
6035 6035
     		            user.username LIKE '%".$keyword."%' OR
6036 6036
     		            lastedit_type LIKE '%".$keyword."%' OR
6037 6037
     		            tool LIKE '%".$keyword."%'
6038 6038
                      ) ";
6039
-    	}
6039
+        }
6040 6040
 
6041
-    	$sql .= " AND tool IN (
6041
+        $sql .= " AND tool IN (
6042 6042
     	            'document',
6043 6043
     	            'learnpath',
6044 6044
     	            'quiz',
@@ -6051,41 +6051,41 @@  discard block
 block discarded – undo
6051 6051
     	            'thematic_plan'
6052 6052
                 )";
6053 6053
 
6054
-    	if ($column == 0) {
6055
-    		$column = '0';
6056
-    	}
6057
-    	if ($column != '' && $direction != '') {
6058
-    		if ($column != 2 && $column != 4) {
6059
-    			$sql .= " ORDER BY col$column $direction";
6060
-    		}
6061
-    	} else {
6062
-    		$sql .= " ORDER BY col5 DESC ";
6063
-    	}
6054
+        if ($column == 0) {
6055
+            $column = '0';
6056
+        }
6057
+        if ($column != '' && $direction != '') {
6058
+            if ($column != 2 && $column != 4) {
6059
+                $sql .= " ORDER BY col$column $direction";
6060
+            }
6061
+        } else {
6062
+            $sql .= " ORDER BY col5 DESC ";
6063
+        }
6064 6064
 
6065 6065
         $from = intval($from);
6066 6066
         $number_of_items = intval($number_of_items);
6067 6067
 
6068
-    	$sql .= " LIMIT $from, $number_of_items ";
6069
-
6070
-    	$res = Database::query($sql);
6071
-    	$resources = array();
6072
-    	$thematic_tools = array('thematic', 'thematic_advance', 'thematic_plan');
6073
-    	while ($row = Database::fetch_array($res)) {
6074
-    		$ref = $row['ref'];
6075
-    		$table_name = TrackingCourseLog::get_tool_name_table($row['col0']);
6076
-    		$table_tool = Database :: get_course_table($table_name['table_name']);
6068
+        $sql .= " LIMIT $from, $number_of_items ";
6077 6069
 
6078
-    		$id = $table_name['id_tool'];
6079
-    		$recorset = false;
6080
-
6081
-    		if (in_array($row['col0'], array('thematic_plan', 'thematic_advance'))) {
6082
-    			$tbl_thematic = Database :: get_course_table(TABLE_THEMATIC);
6083
-    			$sql = "SELECT thematic_id FROM $table_tool
6070
+        $res = Database::query($sql);
6071
+        $resources = array();
6072
+        $thematic_tools = array('thematic', 'thematic_advance', 'thematic_plan');
6073
+        while ($row = Database::fetch_array($res)) {
6074
+            $ref = $row['ref'];
6075
+            $table_name = TrackingCourseLog::get_tool_name_table($row['col0']);
6076
+            $table_tool = Database :: get_course_table($table_name['table_name']);
6077
+
6078
+            $id = $table_name['id_tool'];
6079
+            $recorset = false;
6080
+
6081
+            if (in_array($row['col0'], array('thematic_plan', 'thematic_advance'))) {
6082
+                $tbl_thematic = Database :: get_course_table(TABLE_THEMATIC);
6083
+                $sql = "SELECT thematic_id FROM $table_tool
6084 6084
     			        WHERE c_id = $course_id AND id = $ref";
6085
-    			$rs_thematic  = Database::query($sql);
6086
-    			if (Database::num_rows($rs_thematic)) {
6087
-    				$row_thematic = Database::fetch_array($rs_thematic);
6088
-    				$thematic_id = $row_thematic['thematic_id'];
6085
+                $rs_thematic  = Database::query($sql);
6086
+                if (Database::num_rows($rs_thematic)) {
6087
+                    $row_thematic = Database::fetch_array($rs_thematic);
6088
+                    $thematic_id = $row_thematic['thematic_id'];
6089 6089
 
6090 6090
                     $sql = "SELECT session.id, session.name, user.username
6091 6091
                             FROM $tbl_thematic t, $table_session session, $table_user user
@@ -6094,9 +6094,9 @@  discard block
 block discarded – undo
6094 6094
                               t.session_id = session.id AND
6095 6095
                               session.id_coach = user.user_id AND
6096 6096
                               t.id = $thematic_id";
6097
-    				$recorset = Database::query($sql);
6098
-    			}
6099
-    		} else {
6097
+                    $recorset = Database::query($sql);
6098
+                }
6099
+            } else {
6100 6100
                 $sql = "SELECT session.id, session.name, user.username
6101 6101
                           FROM $table_tool tool, $table_session session, $table_user user
6102 6102
     			          WHERE
@@ -6104,134 +6104,134 @@  discard block
 block discarded – undo
6104 6104
     			              tool.session_id = session.id AND
6105 6105
     			              session.id_coach = user.user_id AND
6106 6106
     			              tool.$id = $ref";
6107
-    			$recorset = Database::query($sql);
6108
-    		}
6109
-
6110
-    		if (!empty($recorset)) {
6111
-    			$obj = Database::fetch_object($recorset);
6112
-
6113
-    			$name_session = '';
6114
-    			$coach_name = '';
6115
-    			if (!empty($obj)) {
6116
-    				$name_session = $obj->name;
6117
-    				$coach_name   = $obj->username;
6118
-    			}
6119
-
6120
-    			$url_tool = api_get_path(WEB_CODE_PATH).$table_name['link_tool'];
6121
-    			$row[0] = '';
6122
-    			if ($row['col6'] != 2) {
6123
-    				if (in_array($row['col0'], $thematic_tools)) {
6124
-
6125
-    					$exp_thematic_tool = explode('_', $row['col0']);
6126
-    					$thematic_tool_title = '';
6127
-    					if (is_array($exp_thematic_tool)) {
6128
-    						foreach ($exp_thematic_tool as $exp) {
6129
-    							$thematic_tool_title .= api_ucfirst($exp);
6130
-    						}
6131
-    					} else {
6132
-    						$thematic_tool_title = api_ucfirst($row['col0']);
6133
-    					}
6134
-
6135
-    					$row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'&action=thematic_details">'.get_lang($thematic_tool_title).'</a>';
6136
-    				} else {
6137
-    					$row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'">'.get_lang('Tool'.api_ucfirst($row['col0'])).'</a>';
6138
-    				}
6139
-    			} else {
6140
-    				$row[0] = api_ucfirst($row['col0']);
6141
-    			}
6142
-    			$row[1] = get_lang($row[1]);
6143
-    			$row[6] = api_convert_and_format_date($row['col5'], null, date_default_timezone_get());
6144
-    			$row[5] = '';
6145
-    			//@todo Improve this code please
6146
-    			switch ($table_name['table_name']) {
6147
-    				case 'document':
6148
-    					$sql = "SELECT tool.title as title FROM $table_tool tool
6107
+                $recorset = Database::query($sql);
6108
+            }
6109
+
6110
+            if (!empty($recorset)) {
6111
+                $obj = Database::fetch_object($recorset);
6112
+
6113
+                $name_session = '';
6114
+                $coach_name = '';
6115
+                if (!empty($obj)) {
6116
+                    $name_session = $obj->name;
6117
+                    $coach_name   = $obj->username;
6118
+                }
6119
+
6120
+                $url_tool = api_get_path(WEB_CODE_PATH).$table_name['link_tool'];
6121
+                $row[0] = '';
6122
+                if ($row['col6'] != 2) {
6123
+                    if (in_array($row['col0'], $thematic_tools)) {
6124
+
6125
+                        $exp_thematic_tool = explode('_', $row['col0']);
6126
+                        $thematic_tool_title = '';
6127
+                        if (is_array($exp_thematic_tool)) {
6128
+                            foreach ($exp_thematic_tool as $exp) {
6129
+                                $thematic_tool_title .= api_ucfirst($exp);
6130
+                            }
6131
+                        } else {
6132
+                            $thematic_tool_title = api_ucfirst($row['col0']);
6133
+                        }
6134
+
6135
+                        $row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'&action=thematic_details">'.get_lang($thematic_tool_title).'</a>';
6136
+                    } else {
6137
+                        $row[0] = '<a href="'.$url_tool.'?'.api_get_cidreq().'">'.get_lang('Tool'.api_ucfirst($row['col0'])).'</a>';
6138
+                    }
6139
+                } else {
6140
+                    $row[0] = api_ucfirst($row['col0']);
6141
+                }
6142
+                $row[1] = get_lang($row[1]);
6143
+                $row[6] = api_convert_and_format_date($row['col5'], null, date_default_timezone_get());
6144
+                $row[5] = '';
6145
+                //@todo Improve this code please
6146
+                switch ($table_name['table_name']) {
6147
+                    case 'document':
6148
+                        $sql = "SELECT tool.title as title FROM $table_tool tool
6149 6149
                                 WHERE c_id = $course_id AND id = $ref";
6150
-    					$rs_document = Database::query($sql);
6151
-    					$obj_document = Database::fetch_object($rs_document);
6150
+                        $rs_document = Database::query($sql);
6151
+                        $obj_document = Database::fetch_object($rs_document);
6152 6152
                         if ($obj_document) {
6153 6153
                             $row[5] = $obj_document->title;
6154 6154
                         }
6155
-    					break;
6156
-    				case 'announcement':
6155
+                        break;
6156
+                    case 'announcement':
6157 6157
                         $sql = "SELECT title FROM $table_tool
6158 6158
                                 WHERE c_id = $course_id AND id = $ref";
6159
-    					$rs_document = Database::query($sql);
6160
-    					$obj_document = Database::fetch_object($rs_document);
6159
+                        $rs_document = Database::query($sql);
6160
+                        $obj_document = Database::fetch_object($rs_document);
6161 6161
                         if ($obj_document) {
6162 6162
                             $row[5] = $obj_document->title;
6163 6163
                         }
6164
-    					break;
6165
-    				case 'glossary':
6164
+                        break;
6165
+                    case 'glossary':
6166 6166
                         $sql = "SELECT name FROM $table_tool
6167 6167
     					        WHERE c_id = $course_id AND glossary_id = $ref";
6168
-    					$rs_document = Database::query($sql);
6169
-    					$obj_document = Database::fetch_object($rs_document);
6168
+                        $rs_document = Database::query($sql);
6169
+                        $obj_document = Database::fetch_object($rs_document);
6170 6170
                         if ($obj_document) {
6171 6171
                             $row[5] = $obj_document->name;
6172 6172
                         }
6173
-    					break;
6174
-    				case 'lp':
6173
+                        break;
6174
+                    case 'lp':
6175 6175
                         $sql = "SELECT name
6176 6176
                                 FROM $table_tool WHERE c_id = $course_id AND id = $ref";
6177
-    					$rs_document = Database::query($sql);
6178
-    					$obj_document = Database::fetch_object($rs_document);
6179
-    					$row[5] = $obj_document->name;
6180
-    					break;
6181
-    				case 'quiz':
6177
+                        $rs_document = Database::query($sql);
6178
+                        $obj_document = Database::fetch_object($rs_document);
6179
+                        $row[5] = $obj_document->name;
6180
+                        break;
6181
+                    case 'quiz':
6182 6182
                         $sql = "SELECT title FROM $table_tool
6183 6183
                                 WHERE c_id = $course_id AND id = $ref";
6184
-    					$rs_document = Database::query($sql);
6185
-    					$obj_document = Database::fetch_object($rs_document);
6184
+                        $rs_document = Database::query($sql);
6185
+                        $obj_document = Database::fetch_object($rs_document);
6186 6186
                         if ($obj_document) {
6187 6187
                             $row[5] = $obj_document->title;
6188 6188
                         }
6189
-    					break;
6190
-    				case 'course_description':
6189
+                        break;
6190
+                    case 'course_description':
6191 6191
                         $sql = "SELECT title FROM $table_tool
6192 6192
                                 WHERE c_id = $course_id AND id = $ref";
6193
-    					$rs_document = Database::query($sql);
6194
-    					$obj_document = Database::fetch_object($rs_document);
6193
+                        $rs_document = Database::query($sql);
6194
+                        $obj_document = Database::fetch_object($rs_document);
6195 6195
                         if ($obj_document) {
6196 6196
                             $row[5] = $obj_document->title;
6197 6197
                         }
6198
-    					break;
6199
-    				case 'thematic':
6200
-    					$rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6201
-    					if (Database::num_rows($rs) > 0) {
6202
-    						$obj = Database::fetch_object($rs);
6198
+                        break;
6199
+                    case 'thematic':
6200
+                        $rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6201
+                        if (Database::num_rows($rs) > 0) {
6202
+                            $obj = Database::fetch_object($rs);
6203 6203
                             if ($obj) {
6204 6204
                                 $row[5] = $obj->title;
6205 6205
                             }
6206
-    					}
6207
-    					break;
6208
-    				case 'thematic_advance':
6209
-    					$rs = Database::query("SELECT content FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6210
-    					if (Database::num_rows($rs) > 0) {
6211
-    						$obj = Database::fetch_object($rs);
6206
+                        }
6207
+                        break;
6208
+                    case 'thematic_advance':
6209
+                        $rs = Database::query("SELECT content FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6210
+                        if (Database::num_rows($rs) > 0) {
6211
+                            $obj = Database::fetch_object($rs);
6212 6212
                             if ($obj) {
6213 6213
                                 $row[5] = $obj->content;
6214 6214
                             }
6215
-    					}
6216
-    					break;
6217
-    				case 'thematic_plan':
6218
-    					$rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6219
-    					if (Database::num_rows($rs) > 0) {
6220
-    						$obj = Database::fetch_object($rs);
6215
+                        }
6216
+                        break;
6217
+                    case 'thematic_plan':
6218
+                        $rs = Database::query("SELECT title FROM $table_tool WHERE c_id = $course_id AND id = $ref");
6219
+                        if (Database::num_rows($rs) > 0) {
6220
+                            $obj = Database::fetch_object($rs);
6221 6221
                             if ($obj) {
6222 6222
                                 $row[5] = $obj->title;
6223 6223
                             }
6224
-    					}
6225
-    					break;
6226
-    				default:
6227
-    					break;
6228
-    			}
6229
-
6230
-    			$row2 = $name_session;
6231
-    			if (!empty($coach_name)) {
6232
-    				$row2 .= '<br />'.get_lang('Coach').': '.$coach_name;
6233
-    			}
6234
-    			$row[2] = $row2;
6224
+                        }
6225
+                        break;
6226
+                    default:
6227
+                        break;
6228
+                }
6229
+
6230
+                $row2 = $name_session;
6231
+                if (!empty($coach_name)) {
6232
+                    $row2 .= '<br />'.get_lang('Coach').': '.$coach_name;
6233
+                }
6234
+                $row[2] = $row2;
6235 6235
                 if (!empty($row['col3'])) {
6236 6236
                     $userInfo = api_get_user_info($row['user_id']);
6237 6237
                     $row['col3'] = Display::url(
@@ -6247,11 +6247,11 @@  discard block
 block discarded – undo
6247 6247
                     $row[4] = $ip;
6248 6248
                 }
6249 6249
 
6250
-    			$resources[] = $row;
6251
-    		}
6252
-    	}
6250
+                $resources[] = $row;
6251
+            }
6252
+        }
6253 6253
 
6254
-    	return $resources;
6254
+        return $resources;
6255 6255
     }
6256 6256
 
6257 6257
     /**
@@ -6261,63 +6261,63 @@  discard block
 block discarded – undo
6261 6261
      */
6262 6262
     public static function get_tool_name_table($tool)
6263 6263
     {
6264
-    	switch ($tool) {
6265
-    		case 'document':
6266
-    			$table_name = TABLE_DOCUMENT;
6267
-    			$link_tool = 'document/document.php';
6268
-    			$id_tool = 'id';
6269
-    			break;
6270
-    		case 'learnpath':
6271
-    			$table_name = TABLE_LP_MAIN;
6272
-    			$link_tool = 'lp/lp_controller.php';
6273
-    			$id_tool = 'id';
6274
-    			break;
6275
-    		case 'quiz':
6276
-    			$table_name = TABLE_QUIZ_TEST;
6277
-    			$link_tool = 'exercise/exercise.php';
6278
-    			$id_tool = 'id';
6279
-    			break;
6280
-    		case 'glossary':
6281
-    			$table_name = TABLE_GLOSSARY;
6282
-    			$link_tool = 'glossary/index.php';
6283
-    			$id_tool = 'glossary_id';
6284
-    			break;
6285
-    		case 'link':
6286
-    			$table_name = TABLE_LINK;
6287
-    			$link_tool = 'link/link.php';
6288
-    			$id_tool = 'id';
6289
-    			break;
6290
-    		case 'course_description':
6291
-    			$table_name = TABLE_COURSE_DESCRIPTION;
6292
-    			$link_tool = 'course_description/';
6293
-    			$id_tool = 'id';
6294
-    			break;
6295
-    		case 'announcement':
6296
-    			$table_name = TABLE_ANNOUNCEMENT;
6297
-    			$link_tool = 'announcements/announcements.php';
6298
-    			$id_tool = 'id';
6299
-    			break;
6300
-    		case 'thematic':
6301
-    			$table_name = TABLE_THEMATIC;
6302
-    			$link_tool = 'course_progress/index.php';
6303
-    			$id_tool = 'id';
6304
-    			break;
6305
-    		case 'thematic_advance':
6306
-    			$table_name = TABLE_THEMATIC_ADVANCE;
6307
-    			$link_tool = 'course_progress/index.php';
6308
-    			$id_tool = 'id';
6309
-    			break;
6310
-    		case 'thematic_plan':
6311
-    			$table_name = TABLE_THEMATIC_PLAN;
6312
-    			$link_tool = 'course_progress/index.php';
6313
-    			$id_tool = 'id';
6314
-    			break;
6315
-    		default:
6316
-    			$table_name = $tool;
6317
-    		break;
6318
-    	}
6319
-
6320
-    	return array(
6264
+        switch ($tool) {
6265
+            case 'document':
6266
+                $table_name = TABLE_DOCUMENT;
6267
+                $link_tool = 'document/document.php';
6268
+                $id_tool = 'id';
6269
+                break;
6270
+            case 'learnpath':
6271
+                $table_name = TABLE_LP_MAIN;
6272
+                $link_tool = 'lp/lp_controller.php';
6273
+                $id_tool = 'id';
6274
+                break;
6275
+            case 'quiz':
6276
+                $table_name = TABLE_QUIZ_TEST;
6277
+                $link_tool = 'exercise/exercise.php';
6278
+                $id_tool = 'id';
6279
+                break;
6280
+            case 'glossary':
6281
+                $table_name = TABLE_GLOSSARY;
6282
+                $link_tool = 'glossary/index.php';
6283
+                $id_tool = 'glossary_id';
6284
+                break;
6285
+            case 'link':
6286
+                $table_name = TABLE_LINK;
6287
+                $link_tool = 'link/link.php';
6288
+                $id_tool = 'id';
6289
+                break;
6290
+            case 'course_description':
6291
+                $table_name = TABLE_COURSE_DESCRIPTION;
6292
+                $link_tool = 'course_description/';
6293
+                $id_tool = 'id';
6294
+                break;
6295
+            case 'announcement':
6296
+                $table_name = TABLE_ANNOUNCEMENT;
6297
+                $link_tool = 'announcements/announcements.php';
6298
+                $id_tool = 'id';
6299
+                break;
6300
+            case 'thematic':
6301
+                $table_name = TABLE_THEMATIC;
6302
+                $link_tool = 'course_progress/index.php';
6303
+                $id_tool = 'id';
6304
+                break;
6305
+            case 'thematic_advance':
6306
+                $table_name = TABLE_THEMATIC_ADVANCE;
6307
+                $link_tool = 'course_progress/index.php';
6308
+                $id_tool = 'id';
6309
+                break;
6310
+            case 'thematic_plan':
6311
+                $table_name = TABLE_THEMATIC_PLAN;
6312
+                $link_tool = 'course_progress/index.php';
6313
+                $id_tool = 'id';
6314
+                break;
6315
+            default:
6316
+                $table_name = $tool;
6317
+            break;
6318
+        }
6319
+
6320
+        return array(
6321 6321
             'table_name' => $table_name,
6322 6322
             'link_tool' => $link_tool,
6323 6323
             'id_tool' => $id_tool
@@ -6326,45 +6326,45 @@  discard block
 block discarded – undo
6326 6326
 
6327 6327
     public static function display_additional_profile_fields()
6328 6328
     {
6329
-    	// getting all the extra profile fields that are defined by the platform administrator
6330
-    	$extra_fields = UserManager :: get_extra_fields(0,50,5,'ASC');
6331
-
6332
-    	// creating the form
6333
-    	$return = '<form action="courseLog.php" method="get" name="additional_profile_field_form" id="additional_profile_field_form">';
6334
-
6335
-    	// the select field with the additional user profile fields (= this is where we select the field of which we want to see
6336
-    	// the information the users have entered or selected.
6337
-    	$return .= '<select name="additional_profile_field">';
6338
-    	$return .= '<option value="-">'.get_lang('SelectFieldToAdd').'</option>';
6339
-    	$extra_fields_to_show = 0;
6340
-    	foreach ($extra_fields as $key=>$field) {
6341
-    		// show only extra fields that are visible + and can be filtered, added by J.Montoya
6342
-    		if ($field[6]==1 && $field[8] == 1) {
6343
-    			if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field'] ) {
6344
-    				$selected = 'selected="selected"';
6345
-    			} else {
6346
-    				$selected = '';
6347
-    			}
6348
-    			$extra_fields_to_show++;
6349
-    			$return .= '<option value="'.$field[0].'" '.$selected.'>'.$field[3].'</option>';
6350
-    		}
6351
-    	}
6352
-    	$return .= '</select>';
6353
-
6354
-    	// the form elements for the $_GET parameters (because the form is passed through GET
6355
-    	foreach ($_GET as $key=>$value){
6356
-    		if ($key <> 'additional_profile_field')    {
6357
-    			$return .= '<input type="hidden" name="'.Security::remove_XSS($key).'" value="'.Security::remove_XSS($value).'" />';
6358
-    		}
6359
-    	}
6360
-    	// the submit button
6361
-    	$return .= '<button class="save" type="submit">'.get_lang('AddAdditionalProfileField').'</button>';
6362
-    	$return .= '</form>';
6363
-    	if ($extra_fields_to_show > 0) {
6364
-    		return $return;
6365
-    	} else {
6366
-    		return '';
6367
-    	}
6329
+        // getting all the extra profile fields that are defined by the platform administrator
6330
+        $extra_fields = UserManager :: get_extra_fields(0,50,5,'ASC');
6331
+
6332
+        // creating the form
6333
+        $return = '<form action="courseLog.php" method="get" name="additional_profile_field_form" id="additional_profile_field_form">';
6334
+
6335
+        // the select field with the additional user profile fields (= this is where we select the field of which we want to see
6336
+        // the information the users have entered or selected.
6337
+        $return .= '<select name="additional_profile_field">';
6338
+        $return .= '<option value="-">'.get_lang('SelectFieldToAdd').'</option>';
6339
+        $extra_fields_to_show = 0;
6340
+        foreach ($extra_fields as $key=>$field) {
6341
+            // show only extra fields that are visible + and can be filtered, added by J.Montoya
6342
+            if ($field[6]==1 && $field[8] == 1) {
6343
+                if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field'] ) {
6344
+                    $selected = 'selected="selected"';
6345
+                } else {
6346
+                    $selected = '';
6347
+                }
6348
+                $extra_fields_to_show++;
6349
+                $return .= '<option value="'.$field[0].'" '.$selected.'>'.$field[3].'</option>';
6350
+            }
6351
+        }
6352
+        $return .= '</select>';
6353
+
6354
+        // the form elements for the $_GET parameters (because the form is passed through GET
6355
+        foreach ($_GET as $key=>$value){
6356
+            if ($key <> 'additional_profile_field')    {
6357
+                $return .= '<input type="hidden" name="'.Security::remove_XSS($key).'" value="'.Security::remove_XSS($value).'" />';
6358
+            }
6359
+        }
6360
+        // the submit button
6361
+        $return .= '<button class="save" type="submit">'.get_lang('AddAdditionalProfileField').'</button>';
6362
+        $return .= '</form>';
6363
+        if ($extra_fields_to_show > 0) {
6364
+            return $return;
6365
+        } else {
6366
+            return '';
6367
+        }
6368 6368
     }
6369 6369
 
6370 6370
     /**
@@ -6383,31 +6383,31 @@  discard block
 block discarded – undo
6383 6383
      */
6384 6384
     public static function get_addtional_profile_information_of_field_by_user($field_id, $users)
6385 6385
     {
6386
-    	// Database table definition
6387
-    	$table_user = Database::get_main_table(TABLE_MAIN_USER);
6388
-    	$table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
6386
+        // Database table definition
6387
+        $table_user = Database::get_main_table(TABLE_MAIN_USER);
6388
+        $table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
6389 6389
         $extraField = Database::get_main_table(TABLE_EXTRA_FIELD);
6390
-    	$result_extra_field = UserManager::get_extra_field_information($field_id);
6391
-
6392
-    	if (!empty($users)) {
6393
-    		if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG ) {
6394
-    			foreach($users as $user_id) {
6395
-    				$user_result = UserManager::get_user_tags($user_id, $field_id);
6396
-    				$tag_list = array();
6397
-    				foreach($user_result as $item) {
6398
-    					$tag_list[] = $item['tag'];
6399
-    				}
6400
-    				$return[$user_id][] = implode(', ',$tag_list);
6401
-    			}
6402
-    		} else {
6403
-    			$new_user_array = array();
6404
-    			foreach ($users as $user_id) {
6405
-    				$new_user_array[]= "'".$user_id."'";
6406
-    			}
6407
-    			$users = implode(',',$new_user_array);
6390
+        $result_extra_field = UserManager::get_extra_field_information($field_id);
6391
+
6392
+        if (!empty($users)) {
6393
+            if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG ) {
6394
+                foreach($users as $user_id) {
6395
+                    $user_result = UserManager::get_user_tags($user_id, $field_id);
6396
+                    $tag_list = array();
6397
+                    foreach($user_result as $item) {
6398
+                        $tag_list[] = $item['tag'];
6399
+                    }
6400
+                    $return[$user_id][] = implode(', ',$tag_list);
6401
+                }
6402
+            } else {
6403
+                $new_user_array = array();
6404
+                foreach ($users as $user_id) {
6405
+                    $new_user_array[]= "'".$user_id."'";
6406
+                }
6407
+                $users = implode(',',$new_user_array);
6408 6408
                 $extraFieldType = EntityExtraField::USER_FIELD_TYPE;
6409
-    			// Selecting only the necessary information NOT ALL the user list
6410
-    			$sql = "SELECT user.user_id, v.value
6409
+                // Selecting only the necessary information NOT ALL the user list
6410
+                $sql = "SELECT user.user_id, v.value
6411 6411
     			        FROM $table_user user
6412 6412
     			        INNER JOIN $table_user_field_values v
6413 6413
                         ON (user.user_id = v.item_id)
@@ -6418,27 +6418,27 @@  discard block
 block discarded – undo
6418 6418
                             v.field_id=".intval($field_id)." AND
6419 6419
                             user.user_id IN ($users)";
6420 6420
 
6421
-    			$result = Database::query($sql);
6422
-    			while($row = Database::fetch_array($result)) {
6423
-    				// get option value for field type double select by id
6424
-    				if (!empty($row['value'])) {
6425
-    					if ($result_extra_field['field_type'] ==
6421
+                $result = Database::query($sql);
6422
+                while($row = Database::fetch_array($result)) {
6423
+                    // get option value for field type double select by id
6424
+                    if (!empty($row['value'])) {
6425
+                        if ($result_extra_field['field_type'] ==
6426 6426
                             ExtraField::FIELD_TYPE_DOUBLE_SELECT
6427 6427
                         ) {
6428
-    						$id_double_select = explode(';', $row['value']);
6429
-    						if (is_array($id_double_select)) {
6430
-    							$value1 = $result_extra_field['options'][$id_double_select[0]]['option_value'];
6431
-    							$value2 = $result_extra_field['options'][$id_double_select[1]]['option_value'];
6432
-    							$row['value'] = ($value1.';'.$value2);
6433
-    						}
6434
-    					}
6435
-    				}
6436
-    				// get other value from extra field
6437
-    				$return[$row['user_id']][] = $row['value'];
6438
-    			}
6439
-    		}
6440
-    	}
6441
-    	return $return;
6428
+                            $id_double_select = explode(';', $row['value']);
6429
+                            if (is_array($id_double_select)) {
6430
+                                $value1 = $result_extra_field['options'][$id_double_select[0]]['option_value'];
6431
+                                $value2 = $result_extra_field['options'][$id_double_select[1]]['option_value'];
6432
+                                $row['value'] = ($value1.';'.$value2);
6433
+                            }
6434
+                        }
6435
+                    }
6436
+                    // get other value from extra field
6437
+                    $return[$row['user_id']][] = $row['value'];
6438
+                }
6439
+            }
6440
+        }
6441
+        return $return;
6442 6442
     }
6443 6443
 
6444 6444
     /**
@@ -6447,18 +6447,18 @@  discard block
 block discarded – undo
6447 6447
      */
6448 6448
     public function count_student_in_course()
6449 6449
     {
6450
-    	global $nbStudents;
6451
-    	return $nbStudents;
6450
+        global $nbStudents;
6451
+        return $nbStudents;
6452 6452
     }
6453 6453
 
6454 6454
     public function sort_users($a, $b)
6455 6455
     {
6456
-    	return strcmp(trim(api_strtolower($a[$_SESSION['tracking_column']])), trim(api_strtolower($b[$_SESSION['tracking_column']])));
6456
+        return strcmp(trim(api_strtolower($a[$_SESSION['tracking_column']])), trim(api_strtolower($b[$_SESSION['tracking_column']])));
6457 6457
     }
6458 6458
 
6459 6459
     public function sort_users_desc($a, $b)
6460 6460
     {
6461
-    	return strcmp( trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
6461
+        return strcmp( trim(api_strtolower($b[$_SESSION['tracking_column']])), trim(api_strtolower($a[$_SESSION['tracking_column']])));
6462 6462
     }
6463 6463
 
6464 6464
     /**
@@ -6467,8 +6467,8 @@  discard block
 block discarded – undo
6467 6467
      */
6468 6468
     public static function get_number_of_users()
6469 6469
     {
6470
-    	global $user_ids;
6471
-    	return count($user_ids);
6470
+        global $user_ids;
6471
+        return count($user_ids);
6472 6472
     }
6473 6473
 
6474 6474
     /**
@@ -6484,37 +6484,37 @@  discard block
 block discarded – undo
6484 6484
     {
6485 6485
         global $user_ids, $course_code, $additional_user_profile_info, $export_csv, $is_western_name_order, $csv_content, $session_id;
6486 6486
 
6487
-    	$course_code = Database::escape_string($course_code);
6488
-    	$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
6489
-    	$tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
6487
+        $course_code = Database::escape_string($course_code);
6488
+        $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
6489
+        $tbl_url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
6490 6490
 
6491
-    	$access_url_id = api_get_current_access_url_id();
6491
+        $access_url_id = api_get_current_access_url_id();
6492 6492
 
6493
-    	// get all users data from a course for sortable with limit
6494
-    	if (is_array($user_ids)) {
6495
-    		$user_ids = array_map('intval', $user_ids);
6496
-    		$condition_user = " WHERE user.user_id IN (".implode(',',$user_ids).") ";
6497
-    	} else {
6498
-    		$user_ids = intval($user_ids);
6499
-    		$condition_user = " WHERE user.user_id = $user_ids ";
6500
-    	}
6493
+        // get all users data from a course for sortable with limit
6494
+        if (is_array($user_ids)) {
6495
+            $user_ids = array_map('intval', $user_ids);
6496
+            $condition_user = " WHERE user.user_id IN (".implode(',',$user_ids).") ";
6497
+        } else {
6498
+            $user_ids = intval($user_ids);
6499
+            $condition_user = " WHERE user.user_id = $user_ids ";
6500
+        }
6501 6501
 
6502
-    	if (!empty($_GET['user_keyword'])) {
6503
-    		$keyword = trim(Database::escape_string($_GET['user_keyword']));
6504
-    		$condition_user .=  " AND (
6502
+        if (!empty($_GET['user_keyword'])) {
6503
+            $keyword = trim(Database::escape_string($_GET['user_keyword']));
6504
+            $condition_user .=  " AND (
6505 6505
                 user.firstname LIKE '%".$keyword."%' OR
6506 6506
                 user.lastname LIKE '%".$keyword."%'  OR
6507 6507
                 user.username LIKE '%".$keyword."%'  OR
6508 6508
                 user.email LIKE '%".$keyword."%'
6509 6509
              ) ";
6510
-    	}
6510
+        }
6511 6511
 
6512 6512
         $url_table = null;
6513 6513
         $url_condition = null;
6514
-    	if (api_is_multiple_url_enabled()) {
6515
-    		$url_table = ", ".$tbl_url_rel_user." as url_users";
6516
-    		$url_condition = " AND user.user_id = url_users.user_id AND access_url_id='$access_url_id'";
6517
-    	}
6514
+        if (api_is_multiple_url_enabled()) {
6515
+            $url_table = ", ".$tbl_url_rel_user." as url_users";
6516
+            $url_condition = " AND user.user_id = url_users.user_id AND access_url_id='$access_url_id'";
6517
+        }
6518 6518
 
6519 6519
         $invitedUsersCondition = '';
6520 6520
 
@@ -6522,7 +6522,7 @@  discard block
 block discarded – undo
6522 6522
             $invitedUsersCondition = " AND user.status != " . INVITEE;
6523 6523
         }
6524 6524
 
6525
-    	$sql = "SELECT  user.user_id as user_id,
6525
+        $sql = "SELECT  user.user_id as user_id,
6526 6526
                     user.official_code  as col0,
6527 6527
                     user.lastname       as col1,
6528 6528
                     user.firstname      as col2,
@@ -6530,16 +6530,16 @@  discard block
 block discarded – undo
6530 6530
                 FROM $tbl_user as user $url_table
6531 6531
     	        $condition_user $url_condition $invitedUsersCondition";
6532 6532
 
6533
-    	if (!in_array($direction, array('ASC','DESC'))) {
6534
-    		$direction = 'ASC';
6535
-    	}
6533
+        if (!in_array($direction, array('ASC','DESC'))) {
6534
+            $direction = 'ASC';
6535
+        }
6536 6536
 
6537
-    	$column = intval($column);
6538
-    	$from = intval($from);
6539
-    	$number_of_items = intval($number_of_items);
6537
+        $column = intval($column);
6538
+        $from = intval($from);
6539
+        $number_of_items = intval($number_of_items);
6540 6540
 
6541
-    	$sql .= " ORDER BY col$column $direction ";
6542
-    	$sql .= " LIMIT $from,$number_of_items";
6541
+        $sql .= " ORDER BY col$column $direction ";
6542
+        $sql .= " LIMIT $from,$number_of_items";
6543 6543
 
6544 6544
         $res = Database::query($sql);
6545 6545
         $users = array();
@@ -6573,7 +6573,7 @@  discard block
 block discarded – undo
6573 6573
             }
6574 6574
         }
6575 6575
 
6576
-    	while ($user = Database::fetch_array($res, 'ASSOC')) {
6576
+        while ($user = Database::fetch_array($res, 'ASSOC')) {
6577 6577
             $courseInfo = api_get_course_info($course_code);
6578 6578
             $courseId = $courseInfo['real_id'];
6579 6579
 
@@ -6604,10 +6604,10 @@  discard block
 block discarded – undo
6604 6604
                 $session_id
6605 6605
             );
6606 6606
 
6607
-    		if (empty($avg_student_progress)) {
6607
+            if (empty($avg_student_progress)) {
6608 6608
                 $avg_student_progress = 0;
6609
-    		}
6610
-    		$user['average_progress'] = $avg_student_progress.'%';
6609
+            }
6610
+            $user['average_progress'] = $avg_student_progress.'%';
6611 6611
 
6612 6612
             $total_user_exercise = Tracking::get_exercise_student_progress(
6613 6613
                 $total_exercises,
@@ -6627,11 +6627,11 @@  discard block
 block discarded – undo
6627 6627
 
6628 6628
             $user['exercise_average_best_attempt'] = $total_user_exercise;
6629 6629
 
6630
-    		if (is_numeric($avg_student_score)) {
6631
-    			$user['student_score']  = $avg_student_score.'%';
6632
-    		} else {
6633
-    			$user['student_score']  = $avg_student_score;
6634
-    		}
6630
+            if (is_numeric($avg_student_score)) {
6631
+                $user['student_score']  = $avg_student_score.'%';
6632
+            } else {
6633
+                $user['student_score']  = $avg_student_score;
6634
+            }
6635 6635
 
6636 6636
             $user['count_assignments'] = Tracking::count_student_assignments(
6637 6637
                 $user['user_id'],
@@ -6654,29 +6654,29 @@  discard block
 block discarded – undo
6654 6654
                 $session_id
6655 6655
             );
6656 6656
 
6657
-    		// we need to display an additional profile field
6658
-    		$user['additional'] = '';
6657
+            // we need to display an additional profile field
6658
+            $user['additional'] = '';
6659 6659
 
6660
-    		if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) {
6661
-    			if (isset($additional_user_profile_info[$user['user_id']]) &&
6660
+            if (isset($_GET['additional_profile_field']) && is_numeric($_GET['additional_profile_field'])) {
6661
+                if (isset($additional_user_profile_info[$user['user_id']]) &&
6662 6662
                     is_array($additional_user_profile_info[$user['user_id']])
6663 6663
                 ) {
6664
-    				$user['additional'] = implode(', ', $additional_user_profile_info[$user['user_id']]);
6665
-    			}
6666
-    		}
6664
+                    $user['additional'] = implode(', ', $additional_user_profile_info[$user['user_id']]);
6665
+                }
6666
+            }
6667 6667
 
6668 6668
             if (empty($session_id)) {
6669 6669
                 $user['survey'] = (isset($survey_user_list[$user['user_id']]) ? $survey_user_list[$user['user_id']] : 0) .' / '.$total_surveys;
6670 6670
             }
6671 6671
 
6672
-    		$user['link'] = '<center>
6672
+            $user['link'] = '<center>
6673 6673
                              <a href="../mySpace/myStudents.php?student='.$user['user_id'].'&details=true&course='.$course_code.'&origin=tracking_course&id_session='.$session_id.'">
6674 6674
     		                 '.Display::return_icon('2rightarrow.png').'
6675 6675
     		                 </a>
6676 6676
                          </center>';
6677 6677
 
6678
-    		// store columns in array $users
6679
-    		$is_western_name_order = api_is_western_name_order();
6678
+            // store columns in array $users
6679
+            $is_western_name_order = api_is_western_name_order();
6680 6680
             $user_row = array();
6681 6681
             $user_row[]= $user['official_code']; //0
6682 6682
             if ($is_western_name_order) {
@@ -6712,21 +6712,21 @@  discard block
 block discarded – undo
6712 6712
 
6713 6713
             $users[] = $user_row;
6714 6714
 
6715
-    		if ($export_csv) {
6716
-    		    if (empty($session_id)) {
6715
+            if ($export_csv) {
6716
+                if (empty($session_id)) {
6717 6717
                     $user_row = array_map('strip_tags', $user_row);
6718
-    			    unset($user_row[14]);
6719
-    			    unset($user_row[15]);
6718
+                    unset($user_row[14]);
6719
+                    unset($user_row[15]);
6720 6720
                 } else {
6721 6721
                     $user_row = array_map('strip_tags', $user_row);
6722 6722
                     unset($user_row[13]);
6723 6723
                     unset($user_row[14]);
6724 6724
                 }
6725 6725
 
6726
-    			$csv_content[] = $user_row;
6727
-    		}
6728
-    	}
6729
-    	return $users;
6726
+                $csv_content[] = $user_row;
6727
+            }
6728
+        }
6729
+        return $users;
6730 6730
     }
6731 6731
 }
6732 6732
 
@@ -6744,18 +6744,18 @@  discard block
 block discarded – undo
6744 6744
      */
6745 6745
     public static function display_login_tracking_info($view, $user_id, $course_id, $session_id = 0)
6746 6746
     {
6747
-    	$MonthsLong = $GLOBALS['MonthsLong'];
6748
-
6749
-    	// protected data
6750
-    	$user_id = intval($user_id);
6751
-    	$session_id = intval($session_id);
6752
-    	$course_id = Database::escape_string($course_id);
6753
-
6754
-    	$track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
6755
-    	$tempView = $view;
6756
-    	if(substr($view,0,1) == '1') {
6757
-    		$new_view = substr_replace($view,'0',0,1);
6758
-    		echo "
6747
+        $MonthsLong = $GLOBALS['MonthsLong'];
6748
+
6749
+        // protected data
6750
+        $user_id = intval($user_id);
6751
+        $session_id = intval($session_id);
6752
+        $course_id = Database::escape_string($course_id);
6753
+
6754
+        $track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
6755
+        $tempView = $view;
6756
+        if(substr($view,0,1) == '1') {
6757
+            $new_view = substr_replace($view,'0',0,1);
6758
+            echo "
6759 6759
                 <tr>
6760 6760
                     <td valign='top'>
6761 6761
                     <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font>" .
@@ -6763,9 +6763,9 @@  discard block
 block discarded – undo
6763 6763
                     </td>
6764 6764
                 </tr>
6765 6765
                 ";
6766
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LoginsDetails')."<br>";
6766
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LoginsDetails')."<br>";
6767 6767
 
6768
-    		$sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
6768
+            $sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
6769 6769
                         FROM $track_access_table
6770 6770
                         WHERE access_user_id = $user_id
6771 6771
                         AND c_id = $course_id
@@ -6773,11 +6773,11 @@  discard block
 block discarded – undo
6773 6773
                         GROUP BY YEAR(access_date),MONTH(access_date)
6774 6774
                         ORDER BY YEAR(access_date),MONTH(access_date) ASC";
6775 6775
 
6776
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6777
-    		$results = getManyResults3Col($sql);
6776
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6777
+            $results = getManyResults3Col($sql);
6778 6778
 
6779
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6780
-    		echo "<tr>
6779
+            echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6780
+            echo "<tr>
6781 6781
                     <td class='secLine'>
6782 6782
                     ".get_lang('LoginsTitleMonthColumn')."
6783 6783
                     </td>
@@ -6785,36 +6785,36 @@  discard block
 block discarded – undo
6785 6785
                     ".get_lang('LoginsTitleCountColumn')."
6786 6786
                     </td>
6787 6787
                 </tr>";
6788
-    		$total = 0;
6789
-    		if (is_array($results)) {
6790
-    			for($j = 0 ; $j < count($results) ; $j++) {
6791
-    				echo "<tr>";
6792
-    				echo "<td class='content'><a href='logins_details.php?uInfo=".$user_id."&reqdate=".$results[$j][0]."&view=".Security::remove_XSS($view)."'>".$MonthsLong[date('n', $results[$j][0])-1].' '.date('Y', $results[$j][0])."</a></td>";
6793
-    				echo "<td valign='top' align='right' class='content'>".$results[$j][1]."</td>";
6794
-    				echo"</tr>";
6795
-    				$total = $total + $results[$j][1];
6796
-    			}
6797
-    			echo "<tr>";
6798
-    			echo "<td>".get_lang('Total')."</td>";
6799
-    			echo "<td align='right' class='content'>".$total."</td>";
6800
-    			echo"</tr>";
6801
-    		} else {
6802
-    			echo "<tr>";
6803
-    			echo "<td colspan='2'><center>".get_lang('NoResult')."</center></td>";
6804
-    			echo"</tr>";
6805
-    		}
6806
-    		echo "</table>";
6807
-    		echo "</td></tr>";
6808
-    	} else {
6809
-    		$new_view = substr_replace($view,'1',0,1);
6810
-    		echo "
6788
+            $total = 0;
6789
+            if (is_array($results)) {
6790
+                for($j = 0 ; $j < count($results) ; $j++) {
6791
+                    echo "<tr>";
6792
+                    echo "<td class='content'><a href='logins_details.php?uInfo=".$user_id."&reqdate=".$results[$j][0]."&view=".Security::remove_XSS($view)."'>".$MonthsLong[date('n', $results[$j][0])-1].' '.date('Y', $results[$j][0])."</a></td>";
6793
+                    echo "<td valign='top' align='right' class='content'>".$results[$j][1]."</td>";
6794
+                    echo"</tr>";
6795
+                    $total = $total + $results[$j][1];
6796
+                }
6797
+                echo "<tr>";
6798
+                echo "<td>".get_lang('Total')."</td>";
6799
+                echo "<td align='right' class='content'>".$total."</td>";
6800
+                echo"</tr>";
6801
+            } else {
6802
+                echo "<tr>";
6803
+                echo "<td colspan='2'><center>".get_lang('NoResult')."</center></td>";
6804
+                echo"</tr>";
6805
+            }
6806
+            echo "</table>";
6807
+            echo "</td></tr>";
6808
+        } else {
6809
+            $new_view = substr_replace($view,'1',0,1);
6810
+            echo "
6811 6811
                 <tr>
6812 6812
                     <td valign='top'>
6813 6813
                     +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=".$user_id."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('LoginsAndAccessTools')."</a>
6814 6814
                     </td>
6815 6815
                 </tr>
6816 6816
             ";
6817
-    	}
6817
+        }
6818 6818
     }
6819 6819
 
6820 6820
     /**
@@ -6827,38 +6827,38 @@  discard block
 block discarded – undo
6827 6827
      */
6828 6828
     public static function display_exercise_tracking_info($view, $user_id, $courseCode)
6829 6829
     {
6830
-    	global $TBL_TRACK_HOTPOTATOES, $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $dateTimeFormatLong;
6830
+        global $TBL_TRACK_HOTPOTATOES, $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $dateTimeFormatLong;
6831 6831
         $courseId = api_get_course_int_id($courseCode);
6832
-    	if(substr($view,1,1) == '1') {
6833
-    		$new_view = substr_replace($view,'0',1,1);
6834
-    		echo "<tr>
6832
+        if(substr($view,1,1) == '1') {
6833
+            $new_view = substr_replace($view,'0',1,1);
6834
+            echo "<tr>
6835 6835
                     <td valign='top'>
6836 6836
                         <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('ExercicesResults')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=01000'>".get_lang('ExportAsCSV')."</a>]
6837 6837
                     </td>
6838 6838
                 </tr>";
6839
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('ExercicesDetails')."<br />";
6839
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('ExercicesDetails')."<br />";
6840 6840
 
6841
-    		$sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6841
+            $sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6842 6842
                     FROM $TABLECOURSE_EXERCICES AS ce , $TABLETRACK_EXERCICES AS te
6843 6843
                     WHERE te.c_id = $courseId
6844 6844
                         AND te.exe_user_id = ".intval($user_id)."
6845 6845
                         AND te.exe_exo_id = ce.id
6846 6846
                     ORDER BY ce.title ASC, te.exe_date ASC";
6847 6847
 
6848
-    		$hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6848
+            $hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
6849 6849
                         FROM $TBL_TRACK_HOTPOTATOES AS te
6850 6850
                         WHERE te.exe_user_id = '".intval($user_id)."' AND te.c_id = $courseId
6851 6851
                         ORDER BY te.c_id ASC, te.exe_date ASC";
6852 6852
 
6853
-    		$hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
6853
+            $hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
6854 6854
 
6855
-    		$NoTestRes = 0;
6856
-    		$NoHPTestRes = 0;
6855
+            $NoTestRes = 0;
6856
+            $NoHPTestRes = 0;
6857 6857
 
6858
-    		echo "<tr>\n<td style='padding-left : 40px;padding-right : 40px;'>\n";
6859
-    		$results = StatsUtils::getManyResultsXCol($sql, 4);
6860
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>\n";
6861
-    		echo "
6858
+            echo "<tr>\n<td style='padding-left : 40px;padding-right : 40px;'>\n";
6859
+            $results = StatsUtils::getManyResultsXCol($sql, 4);
6860
+            echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>\n";
6861
+            echo "
6862 6862
                 <tr bgcolor='#E6E6E6'>
6863 6863
                     <td>
6864 6864
                     ".get_lang('ExercicesTitleExerciceColumn')."
@@ -6871,28 +6871,28 @@  discard block
 block discarded – undo
6871 6871
                     </td>
6872 6872
                 </tr>";
6873 6873
 
6874
-    		if (is_array($results)) {
6875
-    			for($i = 0; $i < sizeof($results); $i++) {
6876
-    				$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
6877
-    				echo "<tr>\n";
6878
-    				echo "<td class='content'>".$results[$i][0]."</td>\n";
6879
-    				echo "<td class='content'>".$display_date."</td>\n";
6880
-    				echo "<td valign='top' align='right' class='content'>".$results[$i][1]." / ".$results[$i][2]."</td>\n";
6881
-    				echo "</tr>\n";
6882
-    			}
6883
-    		} else {
6884
-    			// istvan begin
6885
-    			$NoTestRes = 1;
6886
-    		}
6887
-
6888
-    		// The Result of Tests
6889
-    		if (is_array($hpresults)) {
6890
-    			for($i = 0; $i < sizeof($hpresults); $i++) {
6891
-    				$title = GetQuizName($hpresults[$i][0],'');
6892
-    				if ($title == '')
6893
-    				$title = basename($hpresults[$i][0]);
6894
-    				$display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
6895
-    				?>
6874
+            if (is_array($results)) {
6875
+                for($i = 0; $i < sizeof($results); $i++) {
6876
+                    $display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
6877
+                    echo "<tr>\n";
6878
+                    echo "<td class='content'>".$results[$i][0]."</td>\n";
6879
+                    echo "<td class='content'>".$display_date."</td>\n";
6880
+                    echo "<td valign='top' align='right' class='content'>".$results[$i][1]." / ".$results[$i][2]."</td>\n";
6881
+                    echo "</tr>\n";
6882
+                }
6883
+            } else {
6884
+                // istvan begin
6885
+                $NoTestRes = 1;
6886
+            }
6887
+
6888
+            // The Result of Tests
6889
+            if (is_array($hpresults)) {
6890
+                for($i = 0; $i < sizeof($hpresults); $i++) {
6891
+                    $title = GetQuizName($hpresults[$i][0],'');
6892
+                    if ($title == '')
6893
+                    $title = basename($hpresults[$i][0]);
6894
+                    $display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
6895
+                    ?>
6896 6896
                     <tr>
6897 6897
                         <td class="content"><?php echo $title; ?></td>
6898 6898
                         <td class="content" align="center"><?php echo $display_date; ?></td>
@@ -6902,26 +6902,26 @@  discard block
 block discarded – undo
6902 6902
 
6903 6903
                     <?php
6904 6904
                 }
6905
-    		} else {
6906
-    			$NoHPTestRes = 1;
6907
-    		}
6908
-
6909
-    		if ($NoTestRes == 1 && $NoHPTestRes == 1) {
6910
-    			echo "<tr>\n";
6911
-    			echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>\n";
6912
-    			echo "</tr>\n";
6913
-    		}
6914
-    		echo "</table>";
6915
-    		echo "</td>\n</tr>\n";
6916
-    	} else {
6917
-    		$new_view = substr_replace($view,'1',1,1);
6918
-    		echo "
6905
+            } else {
6906
+                $NoHPTestRes = 1;
6907
+            }
6908
+
6909
+            if ($NoTestRes == 1 && $NoHPTestRes == 1) {
6910
+                echo "<tr>\n";
6911
+                echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>\n";
6912
+                echo "</tr>\n";
6913
+            }
6914
+            echo "</table>";
6915
+            echo "</td>\n</tr>\n";
6916
+        } else {
6917
+            $new_view = substr_replace($view,'1',1,1);
6918
+            echo "
6919 6919
                 <tr>
6920 6920
                     <td valign='top'>
6921 6921
                         +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=$user_id&view=".$new_view."' class='specialLink'>".get_lang('ExercicesResults')."</a>
6922 6922
                     </td>
6923 6923
                 </tr>";
6924
-    	}
6924
+        }
6925 6925
     }
6926 6926
 
6927 6927
     /**
@@ -6930,27 +6930,27 @@  discard block
 block discarded – undo
6930 6930
      */
6931 6931
     public static function display_student_publications_tracking_info($view, $user_id, $course_id)
6932 6932
     {
6933
-    	global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
6933
+        global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
6934 6934
         $_course = api_get_course_info_by_id($course_id);
6935 6935
 
6936
-    	if (substr($view,2,1) == '1') {
6937
-    		$new_view = substr_replace($view,'0',2,1);
6938
-    		echo "<tr>
6936
+        if (substr($view,2,1) == '1') {
6937
+            $new_view = substr_replace($view,'0',2,1);
6938
+            echo "<tr>
6939 6939
                     <td valign='top'>
6940 6940
                     <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('WorkUploads')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=00100'>".get_lang('ExportAsCSV')."</a>]
6941 6941
                     </td>
6942 6942
                 </tr>";
6943
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('WorksDetails')."<br>";
6944
-    		$sql = "SELECT u.upload_date, w.title, w.author,w.url
6943
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('WorksDetails')."<br>";
6944
+            $sql = "SELECT u.upload_date, w.title, w.author,w.url
6945 6945
                     FROM $TABLETRACK_UPLOADS u , $TABLECOURSE_WORK w
6946 6946
                     WHERE u.upload_work_id = w.id
6947 6947
                         AND u.upload_user_id = '".intval($user_id)."'
6948 6948
                         AND u.c_id = '".intval($course_id)."'
6949 6949
                     ORDER BY u.upload_date DESC";
6950
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6951
-    		$results = StatsUtils::getManyResultsXCol($sql,4);
6952
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6953
-    		echo "<tr>
6950
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
6951
+            $results = StatsUtils::getManyResultsXCol($sql,4);
6952
+            echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
6953
+            echo "<tr>
6954 6954
                     <td class='secLine' width='40%'>
6955 6955
                     ".get_lang('WorkTitle')."
6956 6956
                     </td>
@@ -6961,35 +6961,35 @@  discard block
 block discarded – undo
6961 6961
                     ".get_lang('Date')."
6962 6962
                     </td>
6963 6963
                 </tr>";
6964
-    		if (is_array($results)) {
6965
-    			for($j = 0 ; $j < count($results) ; $j++) {
6966
-    				$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
6967
-    				$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
6968
-    				echo "<tr>";
6969
-    				echo "<td class='content'>"
6970
-    				."<a href ='".$pathToFile."'>".$results[$j][1]."</a>"
6971
-    				."</td>";
6972
-    				echo "<td class='content'>".$results[$j][2]."</td>";
6973
-    				echo "<td class='content'>".$beautifulDate."</td>";
6974
-    				echo"</tr>";
6975
-    			}
6976
-    		} else {
6977
-    			echo "<tr>";
6978
-    			echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>";
6979
-    			echo"</tr>";
6980
-    		}
6981
-    		echo "</table>";
6982
-    		echo "</td></tr>";
6983
-    	} else {
6984
-    		$new_view = substr_replace($view,'1',2,1);
6985
-    		echo "
6964
+            if (is_array($results)) {
6965
+                for($j = 0 ; $j < count($results) ; $j++) {
6966
+                    $pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
6967
+                    $beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
6968
+                    echo "<tr>";
6969
+                    echo "<td class='content'>"
6970
+                    ."<a href ='".$pathToFile."'>".$results[$j][1]."</a>"
6971
+                    ."</td>";
6972
+                    echo "<td class='content'>".$results[$j][2]."</td>";
6973
+                    echo "<td class='content'>".$beautifulDate."</td>";
6974
+                    echo"</tr>";
6975
+                }
6976
+            } else {
6977
+                echo "<tr>";
6978
+                echo "<td colspan='3'><center>".get_lang('NoResult')."</center></td>";
6979
+                echo"</tr>";
6980
+            }
6981
+            echo "</table>";
6982
+            echo "</td></tr>";
6983
+        } else {
6984
+            $new_view = substr_replace($view,'1',2,1);
6985
+            echo "
6986 6986
                 <tr>
6987 6987
                     <td valign='top'>
6988 6988
                     +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('WorkUploads')."</a>
6989 6989
                     </td>
6990 6990
                 </tr>
6991 6991
             ";
6992
-    	}
6992
+        }
6993 6993
     }
6994 6994
 
6995 6995
     /**
@@ -6998,55 +6998,55 @@  discard block
 block discarded – undo
6998 6998
      */
6999 6999
     public static function display_links_tracking_info($view, $user_id, $courseCode)
7000 7000
     {
7001
-    	global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
7001
+        global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
7002 7002
         $courseId = api_get_course_int_id($courseCode);
7003
-    	if (substr($view,3,1) == '1') {
7004
-    		$new_view = substr_replace($view,'0',3,1);
7005
-    		echo "
7003
+        if (substr($view,3,1) == '1') {
7004
+            $new_view = substr_replace($view,'0',3,1);
7005
+            echo "
7006 7006
                 <tr>
7007 7007
                         <td valign='top'>
7008 7008
                         <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('LinksAccess')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=00010'>".get_lang('ExportAsCSV')."</a>]
7009 7009
                         </td>
7010 7010
                 </tr>
7011 7011
             ";
7012
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LinksDetails')."<br>";
7013
-    		$sql = "SELECT cl.title, cl.url
7012
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('LinksDetails')."<br>";
7013
+            $sql = "SELECT cl.title, cl.url
7014 7014
                     FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl
7015 7015
                     WHERE sl.links_link_id = cl.id
7016 7016
                         AND sl.c_id = $courseId
7017 7017
                         AND sl.links_user_id = ".intval($user_id)."
7018 7018
                     GROUP BY cl.title, cl.url";
7019
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
7020
-    		$results = StatsUtils::getManyResults2Col($sql);
7021
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
7022
-    		echo "<tr>
7019
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
7020
+            $results = StatsUtils::getManyResults2Col($sql);
7021
+            echo "<table cellpadding='2' cellspacing='1' border='0' align=center>";
7022
+            echo "<tr>
7023 7023
                     <td class='secLine'>
7024 7024
                     ".get_lang('LinksTitleLinkColumn')."
7025 7025
                     </td>
7026 7026
                 </tr>";
7027
-    		if (is_array($results)) {
7028
-    			for($j = 0 ; $j < count($results) ; $j++) {
7029
-    				echo "<tr>";
7030
-    				echo "<td class='content'><a href='".$results[$j][1]."'>".$results[$j][0]."</a></td>";
7031
-    				echo"</tr>";
7032
-    			}
7033
-    		} else {
7034
-    			echo "<tr>";
7035
-    			echo "<td ><center>".get_lang('NoResult')."</center></td>";
7036
-    			echo"</tr>";
7037
-    		}
7038
-    		echo "</table>";
7039
-    		echo "</td></tr>";
7040
-    	} else {
7041
-    		$new_view = substr_replace($view,'1',3,1);
7042
-    		echo "
7027
+            if (is_array($results)) {
7028
+                for($j = 0 ; $j < count($results) ; $j++) {
7029
+                    echo "<tr>";
7030
+                    echo "<td class='content'><a href='".$results[$j][1]."'>".$results[$j][0]."</a></td>";
7031
+                    echo"</tr>";
7032
+                }
7033
+            } else {
7034
+                echo "<tr>";
7035
+                echo "<td ><center>".get_lang('NoResult')."</center></td>";
7036
+                echo"</tr>";
7037
+            }
7038
+            echo "</table>";
7039
+            echo "</td></tr>";
7040
+        } else {
7041
+            $new_view = substr_replace($view,'1',3,1);
7042
+            echo "
7043 7043
                 <tr>
7044 7044
                     <td valign='top'>
7045 7045
                     +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('LinksAccess')."</a>
7046 7046
                     </td>
7047 7047
                 </tr>
7048 7048
             ";
7049
-    	}
7049
+        }
7050 7050
     }
7051 7051
 
7052 7052
     /**
@@ -7059,61 +7059,61 @@  discard block
 block discarded – undo
7059 7059
      */
7060 7060
     public static function display_document_tracking_info($view, $user_id, $course_code, $session_id = 0)
7061 7061
     {
7062
-    	// protect data
7062
+        // protect data
7063 7063
         $user_id = intval($user_id);
7064 7064
         $courseId = api_get_course_int_id($course_code);
7065
-    	$session_id = intval($session_id);
7065
+        $session_id = intval($session_id);
7066 7066
 
7067
-    	$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7068
-    	if(substr($view,4,1) == '1') {
7069
-    		$new_view = substr_replace($view,'0',4,1);
7070
-    		echo "
7067
+        $downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7068
+        if(substr($view,4,1) == '1') {
7069
+            $new_view = substr_replace($view,'0',4,1);
7070
+            echo "
7071 7071
                 <tr>
7072 7072
                     <td valign='top'>
7073 7073
                     <font color='#0000FF'>-&nbsp;&nbsp;&nbsp;</font><b>".get_lang('DocumentsAccess')."</b>&nbsp;&nbsp;&nbsp;[<a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."'>".get_lang('Close')."</a>]&nbsp;&nbsp;&nbsp;[<a href='userLogCSV.php?".api_get_cidreq()."&uInfo=".Security::remove_XSS($_GET['uInfo'])."&view=00001'>".get_lang('ExportAsCSV')."</a>]
7074 7074
                     </td>
7075 7075
                 </tr>
7076 7076
             ";
7077
-    		echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('DocumentsDetails')."<br>";
7077
+            echo "<tr><td style='padding-left : 40px;' valign='top'>".get_lang('DocumentsDetails')."<br>";
7078 7078
 
7079
-    		$sql = "SELECT down_doc_path
7079
+            $sql = "SELECT down_doc_path
7080 7080
                     FROM $downloads_table
7081 7081
                     WHERE c_id = $courseId
7082 7082
                         AND down_user_id = $user_id
7083 7083
                         AND down_session_id = $session_id
7084 7084
                     GROUP BY down_doc_path";
7085 7085
 
7086
-    		echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
7087
-    		$results = StatsUtils::getManyResults1Col($sql);
7088
-    		echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>";
7089
-    		echo "<tr>
7086
+            echo "<tr><td style='padding-left : 40px;padding-right : 40px;'>";
7087
+            $results = StatsUtils::getManyResults1Col($sql);
7088
+            echo "<table cellpadding='2' cellspacing='1' border='0' align='center'>";
7089
+            echo "<tr>
7090 7090
                     <td class='secLine'>
7091 7091
                     ".get_lang('DocumentsTitleDocumentColumn')."
7092 7092
                     </td>
7093 7093
                 </tr>";
7094
-    		if (is_array($results)) {
7095
-    			for($j = 0 ; $j < count($results) ; $j++) {
7096
-    				echo "<tr>";
7097
-    				echo "<td class='content'>".$results[$j]."</td>";
7098
-    				echo"</tr>";
7099
-    			}
7100
-    		} else {
7101
-    			echo "<tr>";
7102
-    			echo "<td><center>".get_lang('NoResult')."</center></td>";
7103
-    			echo"</tr>";
7104
-    		}
7105
-    		echo "</table>";
7106
-    		echo "</td></tr>";
7107
-    	} else {
7108
-    		$new_view = substr_replace($view,'1',4,1);
7109
-    		echo "
7094
+            if (is_array($results)) {
7095
+                for($j = 0 ; $j < count($results) ; $j++) {
7096
+                    echo "<tr>";
7097
+                    echo "<td class='content'>".$results[$j]."</td>";
7098
+                    echo"</tr>";
7099
+                }
7100
+            } else {
7101
+                echo "<tr>";
7102
+                echo "<td><center>".get_lang('NoResult')."</center></td>";
7103
+                echo"</tr>";
7104
+            }
7105
+            echo "</table>";
7106
+            echo "</td></tr>";
7107
+        } else {
7108
+            $new_view = substr_replace($view,'1',4,1);
7109
+            echo "
7110 7110
                 <tr>
7111 7111
                     <td valign='top'>
7112 7112
                     +<font color='#0000FF'>&nbsp;&nbsp;</font><a href='".api_get_self()."?uInfo=".Security::remove_XSS($user_id)."&view=".Security::remove_XSS($new_view)."' class='specialLink'>".get_lang('DocumentsAccess')."</a>
7113 7113
                     </td>
7114 7114
                 </tr>
7115 7115
             ";
7116
-    	}
7116
+        }
7117 7117
     }
7118 7118
 
7119 7119
     /**
@@ -7170,43 +7170,43 @@  discard block
 block discarded – undo
7170 7170
      */
7171 7171
     public function display_login_tracking_info($view, $user_id, $course_id, $session_id = 0)
7172 7172
     {
7173
-    	$MonthsLong = $GLOBALS['MonthsLong'];
7174
-    	$track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
7175
-
7176
-    	// protected data
7177
-    	$user_id    = intval($user_id);
7178
-    	$session_id = intval($session_id);
7179
-    	$course_id  = intval($course_id);
7180
-
7181
-    	$tempView = $view;
7182
-    	if (substr($view,0,1) == '1') {
7183
-    		$new_view = substr_replace($view,'0',0,1);
7184
-    		$title[1]= get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
7185
-    		$sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
7173
+        $MonthsLong = $GLOBALS['MonthsLong'];
7174
+        $track_access_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
7175
+
7176
+        // protected data
7177
+        $user_id    = intval($user_id);
7178
+        $session_id = intval($session_id);
7179
+        $course_id  = intval($course_id);
7180
+
7181
+        $tempView = $view;
7182
+        if (substr($view,0,1) == '1') {
7183
+            $new_view = substr_replace($view,'0',0,1);
7184
+            $title[1]= get_lang('LoginsAndAccessTools').get_lang('LoginsDetails');
7185
+            $sql = "SELECT UNIX_TIMESTAMP(access_date), count(access_date)
7186 7186
                     FROM $track_access_table
7187 7187
                     WHERE access_user_id = $user_id
7188 7188
                     AND c_id = $course_id
7189 7189
                     AND access_session_id = $session_id
7190 7190
                     GROUP BY YEAR(access_date),MONTH(access_date)
7191 7191
                     ORDER BY YEAR(access_date),MONTH(access_date) ASC";
7192
-    		//$results = getManyResults2Col($sql);
7193
-    		$results = getManyResults3Col($sql);
7194
-    		$title_line= get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
7195
-    		$line='';
7196
-    		$total = 0;
7197
-    		if (is_array($results)) {
7198
-    			for($j = 0 ; $j < count($results) ; $j++) {
7199
-    				$line .= $results[$j][0].';'.$results[$j][1]."\n";
7200
-    				$total = $total + $results[$j][1];
7201
-    			}
7202
-    			$line .= get_lang('Total').";".$total."\n";
7203
-    		} else {
7204
-    			$line= get_lang('NoResult')."</center></td>";
7205
-    		}
7206
-    	} else {
7207
-    		$new_view = substr_replace($view,'1',0,1);
7208
-    	}
7209
-    	return array($title_line, $line);
7192
+            //$results = getManyResults2Col($sql);
7193
+            $results = getManyResults3Col($sql);
7194
+            $title_line= get_lang('LoginsTitleMonthColumn').';'.get_lang('LoginsTitleCountColumn')."\n";
7195
+            $line='';
7196
+            $total = 0;
7197
+            if (is_array($results)) {
7198
+                for($j = 0 ; $j < count($results) ; $j++) {
7199
+                    $line .= $results[$j][0].';'.$results[$j][1]."\n";
7200
+                    $total = $total + $results[$j][1];
7201
+                }
7202
+                $line .= get_lang('Total').";".$total."\n";
7203
+            } else {
7204
+                $line= get_lang('NoResult')."</center></td>";
7205
+            }
7206
+        } else {
7207
+            $new_view = substr_replace($view,'1',0,1);
7208
+        }
7209
+        return array($title_line, $line);
7210 7210
     }
7211 7211
 
7212 7212
     /**
@@ -7219,67 +7219,67 @@  discard block
 block discarded – undo
7219 7219
      */
7220 7220
     public function display_exercise_tracking_info($view, $userId, $courseCode)
7221 7221
     {
7222
-    	global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $TABLETRACK_HOTPOTATOES, $dateTimeFormatLong;
7222
+        global $TABLECOURSE_EXERCICES, $TABLETRACK_EXERCICES, $TABLETRACK_HOTPOTATOES, $dateTimeFormatLong;
7223 7223
         $courseId = api_get_course_int_id($courseCode);
7224 7224
         $userId = intval($userId);
7225
-    	if (substr($view,1,1) == '1') {
7226
-    		$new_view = substr_replace($view,'0',1,1);
7227
-    		$title[1] = get_lang('ExercicesDetails');
7228
-    		$line = '';
7229
-    		$sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
7225
+        if (substr($view,1,1) == '1') {
7226
+            $new_view = substr_replace($view,'0',1,1);
7227
+            $title[1] = get_lang('ExercicesDetails');
7228
+            $line = '';
7229
+            $sql = "SELECT ce.title, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
7230 7230
                     FROM $TABLECOURSE_EXERCICES AS ce , $TABLETRACK_EXERCICES AS te
7231 7231
                     WHERE te.c_id = $courseId
7232 7232
                         AND te.exe_user_id = $userId
7233 7233
                         AND te.exe_exo_id = ce.id
7234 7234
                     ORDER BY ce.title ASC, te.exe_date ASC";
7235 7235
 
7236
-    		$hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
7236
+            $hpsql = "SELECT te.exe_name, te.exe_result , te.exe_weighting, UNIX_TIMESTAMP(te.exe_date)
7237 7237
                         FROM $TABLETRACK_HOTPOTATOES AS te
7238 7238
                         WHERE te.exe_user_id = '$userId' AND te.c_id = $courseId
7239 7239
                         ORDER BY te.c_id ASC, te.exe_date ASC";
7240 7240
 
7241
-    		$hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
7241
+            $hpresults = StatsUtils::getManyResultsXCol($hpsql, 4);
7242 7242
 
7243
-    		$NoTestRes = 0;
7244
-    		$NoHPTestRes = 0;
7243
+            $NoTestRes = 0;
7244
+            $NoHPTestRes = 0;
7245 7245
 
7246
-    		$results = StatsUtils::getManyResultsXCol($sql, 4);
7247
-    		$title_line = get_lang('ExercicesTitleExerciceColumn').";".get_lang('Date').';'.get_lang('ExercicesTitleScoreColumn')."\n";
7246
+            $results = StatsUtils::getManyResultsXCol($sql, 4);
7247
+            $title_line = get_lang('ExercicesTitleExerciceColumn').";".get_lang('Date').';'.get_lang('ExercicesTitleScoreColumn')."\n";
7248 7248
 
7249
-    		if (is_array($results)) {
7250
-    			for($i = 0; $i < sizeof($results); $i++)
7251
-    			{
7252
-    				$display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
7253
-    				$line .= $results[$i][0].";".$display_date.";".$results[$i][1]." / ".$results[$i][2]."\n";
7254
-    			}
7255
-    		} else {
7249
+            if (is_array($results)) {
7250
+                for($i = 0; $i < sizeof($results); $i++)
7251
+                {
7252
+                    $display_date = api_convert_and_format_date($results[$i][3], null, date_default_timezone_get());
7253
+                    $line .= $results[$i][0].";".$display_date.";".$results[$i][1]." / ".$results[$i][2]."\n";
7254
+                }
7255
+            } else {
7256 7256
                 // istvan begin
7257
-    			$NoTestRes = 1;
7258
-    		}
7259
-
7260
-    		// The Result of Tests
7261
-    		if (is_array($hpresults)) {
7262
-    			for($i = 0; $i < sizeof($hpresults); $i++) {
7263
-    				$title = GetQuizName($hpresults[$i][0],'');
7264
-
7265
-    				if ($title == '')
7266
-    				$title = basename($hpresults[$i][0]);
7267
-
7268
-    				$display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
7269
-
7270
-    				$line .= $title.';'.$display_date.';'.$hpresults[$i][1].'/'.$hpresults[$i][2]."\n";
7271
-    			}
7272
-    		} else {
7273
-    			$NoHPTestRes = 1;
7274
-    		}
7275
-
7276
-    		if ($NoTestRes == 1 && $NoHPTestRes == 1) {
7277
-    			$line=get_lang('NoResult');
7278
-    		}
7279
-    	} else {
7280
-    		$new_view = substr_replace($view,'1',1,1);
7281
-    	}
7282
-    	return array($title_line, $line);
7257
+                $NoTestRes = 1;
7258
+            }
7259
+
7260
+            // The Result of Tests
7261
+            if (is_array($hpresults)) {
7262
+                for($i = 0; $i < sizeof($hpresults); $i++) {
7263
+                    $title = GetQuizName($hpresults[$i][0],'');
7264
+
7265
+                    if ($title == '')
7266
+                    $title = basename($hpresults[$i][0]);
7267
+
7268
+                    $display_date = api_convert_and_format_date($hpresults[$i][3], null, date_default_timezone_get());
7269
+
7270
+                    $line .= $title.';'.$display_date.';'.$hpresults[$i][1].'/'.$hpresults[$i][2]."\n";
7271
+                }
7272
+            } else {
7273
+                $NoHPTestRes = 1;
7274
+            }
7275
+
7276
+            if ($NoTestRes == 1 && $NoHPTestRes == 1) {
7277
+                $line=get_lang('NoResult');
7278
+            }
7279
+        } else {
7280
+            $new_view = substr_replace($view,'1',1,1);
7281
+        }
7282
+        return array($title_line, $line);
7283 7283
     }
7284 7284
 
7285 7285
     /**
@@ -7288,37 +7288,37 @@  discard block
 block discarded – undo
7288 7288
      */
7289 7289
     public function display_student_publications_tracking_info($view, $user_id, $course_id)
7290 7290
     {
7291
-    	global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
7291
+        global $TABLETRACK_UPLOADS, $TABLECOURSE_WORK;
7292 7292
         $_course = api_get_course_info();
7293 7293
         $user_id = intval($user_id);
7294 7294
         $course_id = intval($course_id);
7295 7295
 
7296
-    	if (substr($view,2,1) == '1') {
7297
-    		$sql = "SELECT u.upload_date, w.title, w.author, w.url
7296
+        if (substr($view,2,1) == '1') {
7297
+            $sql = "SELECT u.upload_date, w.title, w.author, w.url
7298 7298
                     FROM $TABLETRACK_UPLOADS u , $TABLECOURSE_WORK w
7299 7299
                     WHERE
7300 7300
                         u.upload_work_id = w.id AND
7301 7301
                         u.upload_user_id = '$user_id' AND
7302 7302
                         u.c_id = '$course_id'
7303 7303
                     ORDER BY u.upload_date DESC";
7304
-    		$results = StatsUtils::getManyResultsXCol($sql,4);
7305
-
7306
-    		$title[1]=get_lang('WorksDetails');
7307
-    		$line='';
7308
-    		$title_line=get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n";
7309
-
7310
-    		if (is_array($results)) {
7311
-    			for($j = 0 ; $j < count($results) ; $j++) {
7312
-    				$pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
7313
-    				$beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
7314
-    				$line .= $results[$j][1].";".$results[$j][2].";".$beautifulDate."\n";
7315
-    			}
7316
-
7317
-    		} else {
7318
-    			$line= get_lang('NoResult');
7319
-    		}
7320
-    	}
7321
-    	return array($title_line, $line);
7304
+            $results = StatsUtils::getManyResultsXCol($sql,4);
7305
+
7306
+            $title[1]=get_lang('WorksDetails');
7307
+            $line='';
7308
+            $title_line=get_lang('WorkTitle').";".get_lang('WorkAuthors').";".get_lang('Date')."\n";
7309
+
7310
+            if (is_array($results)) {
7311
+                for($j = 0 ; $j < count($results) ; $j++) {
7312
+                    $pathToFile = api_get_path(WEB_COURSE_PATH).$_course['path']."/".$results[$j][3];
7313
+                    $beautifulDate = api_convert_and_format_date($results[$j][0], null, date_default_timezone_get());
7314
+                    $line .= $results[$j][1].";".$results[$j][2].";".$beautifulDate."\n";
7315
+                }
7316
+
7317
+            } else {
7318
+                $line= get_lang('NoResult');
7319
+            }
7320
+        }
7321
+        return array($title_line, $line);
7322 7322
     }
7323 7323
 
7324 7324
     /**
@@ -7327,32 +7327,32 @@  discard block
 block discarded – undo
7327 7327
      */
7328 7328
     public function display_links_tracking_info($view, $userId, $courseCode)
7329 7329
     {
7330
-    	global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
7330
+        global $TABLETRACK_LINKS, $TABLECOURSE_LINKS;
7331 7331
         $courseId = api_get_course_int_id($courseCode);
7332 7332
         $userId = intval($userId);
7333 7333
         $line = null;
7334
-    	if (substr($view,3,1) == '1') {
7335
-    		$new_view = substr_replace($view,'0',3,1);
7336
-    		$title[1]=get_lang('LinksDetails');
7337
-    		$sql = "SELECT cl.title, cl.url
7334
+        if (substr($view,3,1) == '1') {
7335
+            $new_view = substr_replace($view,'0',3,1);
7336
+            $title[1]=get_lang('LinksDetails');
7337
+            $sql = "SELECT cl.title, cl.url
7338 7338
                         FROM $TABLETRACK_LINKS AS sl, $TABLECOURSE_LINKS AS cl
7339 7339
                         WHERE sl.links_link_id = cl.id
7340 7340
                             AND sl.c_id = $courseId
7341 7341
                             AND sl.links_user_id = $userId
7342 7342
                         GROUP BY cl.title, cl.url";
7343
-    		$results = StatsUtils::getManyResults2Col($sql);
7344
-    		$title_line= get_lang('LinksTitleLinkColumn')."\n";
7345
-    		if (is_array($results)) {
7346
-    			for ($j = 0 ; $j < count($results) ; $j++) {
7347
-    				$line .= $results[$j][0]."\n";
7348
-    			}
7349
-    		} else {
7350
-    			$line=get_lang('NoResult');
7351
-    		}
7352
-    	} else {
7353
-    		$new_view = substr_replace($view,'1',3,1);
7354
-    	}
7355
-    	return array($title_line, $line);
7343
+            $results = StatsUtils::getManyResults2Col($sql);
7344
+            $title_line= get_lang('LinksTitleLinkColumn')."\n";
7345
+            if (is_array($results)) {
7346
+                for ($j = 0 ; $j < count($results) ; $j++) {
7347
+                    $line .= $results[$j][0]."\n";
7348
+                }
7349
+            } else {
7350
+                $line=get_lang('NoResult');
7351
+            }
7352
+        } else {
7353
+            $new_view = substr_replace($view,'1',3,1);
7354
+        }
7355
+        return array($title_line, $line);
7356 7356
     }
7357 7357
 
7358 7358
     /**
@@ -7365,38 +7365,38 @@  discard block
 block discarded – undo
7365 7365
      */
7366 7366
     public function display_document_tracking_info($view, $user_id, $courseCode, $session_id = 0)
7367 7367
     {
7368
-    	// protect data
7369
-    	$user_id     = intval($user_id);
7368
+        // protect data
7369
+        $user_id     = intval($user_id);
7370 7370
         $courseId = api_get_course_int_id($courseCode);
7371
-    	$session_id = intval($session_id);
7371
+        $session_id = intval($session_id);
7372 7372
 
7373
-    	$downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7373
+        $downloads_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
7374 7374
 
7375
-    	if (substr($view,4,1) == '1') {
7376
-    		$new_view = substr_replace($view,'0',4,1);
7377
-    		$title[1]= get_lang('DocumentsDetails');
7375
+        if (substr($view,4,1) == '1') {
7376
+            $new_view = substr_replace($view,'0',4,1);
7377
+            $title[1]= get_lang('DocumentsDetails');
7378 7378
 
7379
-    		$sql = "SELECT down_doc_path
7379
+            $sql = "SELECT down_doc_path
7380 7380
                         FROM $downloads_table
7381 7381
                         WHERE c_id = $courseId
7382 7382
                             AND down_user_id = $user_id
7383 7383
                             AND down_session_id = $session_id
7384 7384
                         GROUP BY down_doc_path";
7385 7385
 
7386
-    		$results = StatsUtils::getManyResults1Col($sql);
7387
-    		$title_line = get_lang('DocumentsTitleDocumentColumn')."\n";
7386
+            $results = StatsUtils::getManyResults1Col($sql);
7387
+            $title_line = get_lang('DocumentsTitleDocumentColumn')."\n";
7388 7388
             $line = null;
7389
-    		if (is_array($results)) {
7390
-    			for ($j = 0 ; $j < count($results) ; $j++) {
7391
-    				$line .= $results[$j]."\n";
7392
-    			}
7393
-    		} else {
7394
-    			$line = get_lang('NoResult');
7395
-    		}
7396
-    	} else {
7397
-    		$new_view = substr_replace($view,'1',4,1);
7398
-    	}
7399
-    	return array($title_line, $line);
7389
+            if (is_array($results)) {
7390
+                for ($j = 0 ; $j < count($results) ; $j++) {
7391
+                    $line .= $results[$j]."\n";
7392
+                }
7393
+            } else {
7394
+                $line = get_lang('NoResult');
7395
+            }
7396
+        } else {
7397
+            $new_view = substr_replace($view,'1',4,1);
7398
+        }
7399
+        return array($title_line, $line);
7400 7400
     }
7401 7401
 
7402 7402
     /**
Please login to merge, or discard this patch.
main/exercise/hotspot_actionscript.as.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -32,10 +32,10 @@  discard block
 block discarded – undo
32 32
 
33 33
 // Query db for answers
34 34
 if ($answer_type==HOT_SPOT_DELINEATION) {
35
-	$sql = "SELECT iid, id, answer, hotspot_coordinates, hotspot_type, ponderation FROM $TBL_ANSWERS
35
+    $sql = "SELECT iid, id, answer, hotspot_coordinates, hotspot_type, ponderation FROM $TBL_ANSWERS
36 36
 	        WHERE c_id = $course_id AND question_id = ".intval($questionId)." AND hotspot_type = 'delineation' ORDER BY iid";
37 37
 } else {
38
-	$sql = "SELECT iid, id, answer, hotspot_coordinates, hotspot_type, ponderation FROM $TBL_ANSWERS
38
+    $sql = "SELECT iid, id, answer, hotspot_coordinates, hotspot_type, ponderation FROM $TBL_ANSWERS
39 39
 	        WHERE c_id = $course_id AND question_id = ".intval($questionId)." ORDER BY iid";
40 40
 }
41 41
 $result = Database::query($sql);
@@ -77,37 +77,37 @@  discard block
 block discarded – undo
77 77
     $hotSpot['iid'] = $hotspot['iid'];
78 78
     $hotSpot['answer'] = $hotspot['answer'];
79 79
 
80
-	// Square or rectancle
81
-	if ($hotspot['hotspot_type'] == 'square' )
82
-	{
80
+    // Square or rectancle
81
+    if ($hotspot['hotspot_type'] == 'square' )
82
+    {
83 83
         $hotSpot['type'] = 'square';
84
-	}
85
-	// Circle or ovale
86
-	if ($hotspot['hotspot_type'] == 'circle')
87
-	{
84
+    }
85
+    // Circle or ovale
86
+    if ($hotspot['hotspot_type'] == 'circle')
87
+    {
88 88
         $hotSpot['type'] = 'circle';
89
-	}
90
-	// Polygon
91
-	if ($hotspot['hotspot_type'] == 'poly')
92
-	{
89
+    }
90
+    // Polygon
91
+    if ($hotspot['hotspot_type'] == 'poly')
92
+    {
93 93
         $hotSpot['type'] = 'poly';
94
-	}
95
-	// Delineation
96
-	if ($hotspot['hotspot_type'] == 'delineation')
97
-	{
94
+    }
95
+    // Delineation
96
+    if ($hotspot['hotspot_type'] == 'delineation')
97
+    {
98 98
         $hotSpot['type'] = 'delineation';
99
-	}
100
-	// No error
101
-	if ($hotspot['hotspot_type'] == 'noerror')
102
-	{
99
+    }
100
+    // No error
101
+    if ($hotspot['hotspot_type'] == 'noerror')
102
+    {
103 103
         $hotSpot['type'] = 'noerror';
104
-	}
104
+    }
105 105
 
106
-	// This is a good answer, count + 1 for nmbr of clicks
107
-	if ($hotspot['hotspot_type'] > 0)
108
-	{
109
-		$nmbrTries++;
110
-	}
106
+    // This is a good answer, count + 1 for nmbr of clicks
107
+    if ($hotspot['hotspot_type'] > 0)
108
+    {
109
+        $nmbrTries++;
110
+    }
111 111
 
112 112
     $hotSpot['coord'] = $hotspot['hotspot_coordinates'];
113 113
 
Please login to merge, or discard this patch.
src/Chamilo/CoreBundle/Entity/ExtraField.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -253,9 +253,9 @@
 block discarded – undo
253 253
         return $this;
254 254
     }
255 255
 
256
-     /**
257
-     * @return boolean
258
-     */
256
+        /**
257
+         * @return boolean
258
+         */
259 259
     public function isChangeable()
260 260
     {
261 261
         return $this->changeable;
Please login to merge, or discard this patch.
main/inc/lib/nusoap/class.soap_server.php 1 patch
Indentation   +1020 added lines, -1020 removed lines patch added patch discarded remove patch
@@ -12,1079 +12,1079 @@  discard block
 block discarded – undo
12 12
 */
13 13
 class nusoap_server extends nusoap_base
14 14
 {
15
-	/**
16
-	 * HTTP headers of request
17
-	 * @var array
18
-	 * @access private
19
-	 */
20
-	var $headers = array();
21
-	/**
22
-	 * HTTP request
23
-	 * @var string
24
-	 * @access private
25
-	 */
26
-	var $request = '';
27
-	/**
28
-	 * SOAP headers from request (incomplete namespace resolution; special characters not escaped) (text)
29
-	 * @var string
30
-	 * @access public
31
-	 */
32
-	var $requestHeaders = '';
33
-	/**
34
-	 * SOAP Headers from request (parsed)
35
-	 * @var mixed
36
-	 * @access public
37
-	 */
38
-	var $requestHeader = NULL;
39
-	/**
40
-	 * SOAP body request portion (incomplete namespace resolution; special characters not escaped) (text)
41
-	 * @var string
42
-	 * @access public
43
-	 */
44
-	var $document = '';
45
-	/**
46
-	 * SOAP payload for request (text)
47
-	 * @var string
48
-	 * @access public
49
-	 */
50
-	var $requestSOAP = '';
51
-	/**
52
-	 * requested method namespace URI
53
-	 * @var string
54
-	 * @access private
55
-	 */
56
-	var $methodURI = '';
57
-	/**
58
-	 * name of method requested
59
-	 * @var string
60
-	 * @access private
61
-	 */
62
-	var $methodname = '';
63
-	/**
64
-	 * method parameters from request
65
-	 * @var array
66
-	 * @access private
67
-	 */
68
-	var $methodparams = array();
69
-	/**
70
-	 * SOAP Action from request
71
-	 * @var string
72
-	 * @access private
73
-	 */
74
-	var $SOAPAction = '';
75
-	/**
76
-	 * character set encoding of incoming (request) messages
77
-	 * @var string
78
-	 * @access public
79
-	 */
80
-	var $xml_encoding = '';
81
-	/**
82
-	 * toggles whether the parser decodes element content w/ utf8_decode()
83
-	 * @var boolean
84
-	 * @access public
85
-	 */
15
+    /**
16
+     * HTTP headers of request
17
+     * @var array
18
+     * @access private
19
+     */
20
+    var $headers = array();
21
+    /**
22
+     * HTTP request
23
+     * @var string
24
+     * @access private
25
+     */
26
+    var $request = '';
27
+    /**
28
+     * SOAP headers from request (incomplete namespace resolution; special characters not escaped) (text)
29
+     * @var string
30
+     * @access public
31
+     */
32
+    var $requestHeaders = '';
33
+    /**
34
+     * SOAP Headers from request (parsed)
35
+     * @var mixed
36
+     * @access public
37
+     */
38
+    var $requestHeader = NULL;
39
+    /**
40
+     * SOAP body request portion (incomplete namespace resolution; special characters not escaped) (text)
41
+     * @var string
42
+     * @access public
43
+     */
44
+    var $document = '';
45
+    /**
46
+     * SOAP payload for request (text)
47
+     * @var string
48
+     * @access public
49
+     */
50
+    var $requestSOAP = '';
51
+    /**
52
+     * requested method namespace URI
53
+     * @var string
54
+     * @access private
55
+     */
56
+    var $methodURI = '';
57
+    /**
58
+     * name of method requested
59
+     * @var string
60
+     * @access private
61
+     */
62
+    var $methodname = '';
63
+    /**
64
+     * method parameters from request
65
+     * @var array
66
+     * @access private
67
+     */
68
+    var $methodparams = array();
69
+    /**
70
+     * SOAP Action from request
71
+     * @var string
72
+     * @access private
73
+     */
74
+    var $SOAPAction = '';
75
+    /**
76
+     * character set encoding of incoming (request) messages
77
+     * @var string
78
+     * @access public
79
+     */
80
+    var $xml_encoding = '';
81
+    /**
82
+     * toggles whether the parser decodes element content w/ utf8_decode()
83
+     * @var boolean
84
+     * @access public
85
+     */
86 86
     var $decode_utf8 = true;
87 87
 
88
-	/**
89
-	 * HTTP headers of response
90
-	 * @var array
91
-	 * @access public
92
-	 */
93
-	var $outgoing_headers = array();
94
-	/**
95
-	 * HTTP response
96
-	 * @var string
97
-	 * @access private
98
-	 */
99
-	var $response = '';
100
-	/**
101
-	 * SOAP headers for response (text or array of soapval or associative array)
102
-	 * @var mixed
103
-	 * @access public
104
-	 */
105
-	var $responseHeaders = '';
106
-	/**
107
-	 * SOAP payload for response (text)
108
-	 * @var string
109
-	 * @access private
110
-	 */
111
-	var $responseSOAP = '';
112
-	/**
113
-	 * method return value to place in response
114
-	 * @var mixed
115
-	 * @access private
116
-	 */
117
-	var $methodreturn = false;
118
-	/**
119
-	 * whether $methodreturn is a string of literal XML
120
-	 * @var boolean
121
-	 * @access public
122
-	 */
123
-	var $methodreturnisliteralxml = false;
124
-	/**
125
-	 * SOAP fault for response (or false)
126
-	 * @var mixed
127
-	 * @access private
128
-	 */
129
-	var $fault = false;
130
-	/**
131
-	 * text indication of result (for debugging)
132
-	 * @var string
133
-	 * @access private
134
-	 */
135
-	var $result = 'successful';
88
+    /**
89
+     * HTTP headers of response
90
+     * @var array
91
+     * @access public
92
+     */
93
+    var $outgoing_headers = array();
94
+    /**
95
+     * HTTP response
96
+     * @var string
97
+     * @access private
98
+     */
99
+    var $response = '';
100
+    /**
101
+     * SOAP headers for response (text or array of soapval or associative array)
102
+     * @var mixed
103
+     * @access public
104
+     */
105
+    var $responseHeaders = '';
106
+    /**
107
+     * SOAP payload for response (text)
108
+     * @var string
109
+     * @access private
110
+     */
111
+    var $responseSOAP = '';
112
+    /**
113
+     * method return value to place in response
114
+     * @var mixed
115
+     * @access private
116
+     */
117
+    var $methodreturn = false;
118
+    /**
119
+     * whether $methodreturn is a string of literal XML
120
+     * @var boolean
121
+     * @access public
122
+     */
123
+    var $methodreturnisliteralxml = false;
124
+    /**
125
+     * SOAP fault for response (or false)
126
+     * @var mixed
127
+     * @access private
128
+     */
129
+    var $fault = false;
130
+    /**
131
+     * text indication of result (for debugging)
132
+     * @var string
133
+     * @access private
134
+     */
135
+    var $result = 'successful';
136 136
 
137
-	/**
138
-	 * assoc array of operations => opData; operations are added by the register()
139
-	 * method or by parsing an external WSDL definition
140
-	 * @var array
141
-	 * @access private
142
-	 */
143
-	var $operations = array();
144
-	/**
145
-	 * wsdl instance (if one)
146
-	 * @var mixed
147
-	 * @access private
148
-	 */
149
-	var $wsdl = false;
150
-	/**
151
-	 * URL for WSDL (if one)
152
-	 * @var mixed
153
-	 * @access private
154
-	 */
155
-	var $externalWSDLURL = false;
156
-	/**
157
-	 * whether to append debug to response as XML comment
158
-	 * @var boolean
159
-	 * @access public
160
-	 */
161
-	var $debug_flag = false;
137
+    /**
138
+     * assoc array of operations => opData; operations are added by the register()
139
+     * method or by parsing an external WSDL definition
140
+     * @var array
141
+     * @access private
142
+     */
143
+    var $operations = array();
144
+    /**
145
+     * wsdl instance (if one)
146
+     * @var mixed
147
+     * @access private
148
+     */
149
+    var $wsdl = false;
150
+    /**
151
+     * URL for WSDL (if one)
152
+     * @var mixed
153
+     * @access private
154
+     */
155
+    var $externalWSDLURL = false;
156
+    /**
157
+     * whether to append debug to response as XML comment
158
+     * @var boolean
159
+     * @access public
160
+     */
161
+    var $debug_flag = false;
162 162
 
163 163
 
164
-	/**
165
-	* constructor
166
-    * the optional parameter is a path to a WSDL file that you'd like to bind the server instance to.
167
-	*
168
-    * @param mixed $wsdl file path or URL (string), or wsdl instance (object)
169
-	* @access   public
170
-	*/
171
-	function __construct($wsdl=false)
164
+    /**
165
+     * constructor
166
+     * the optional parameter is a path to a WSDL file that you'd like to bind the server instance to.
167
+     *
168
+     * @param mixed $wsdl file path or URL (string), or wsdl instance (object)
169
+     * @access   public
170
+     */
171
+    function __construct($wsdl=false)
172 172
     {
173
-		parent::__construct();
174
-		// turn on debugging?
175
-		global $debug;
176
-		global $HTTP_SERVER_VARS;
173
+        parent::__construct();
174
+        // turn on debugging?
175
+        global $debug;
176
+        global $HTTP_SERVER_VARS;
177 177
 
178
-		if (isset($_SERVER)) {
179
-			$this->debug("_SERVER is defined:");
180
-			$this->appendDebug($this->varDump($_SERVER));
181
-		} elseif (isset($HTTP_SERVER_VARS)) {
182
-			$this->debug("HTTP_SERVER_VARS is defined:");
183
-			$this->appendDebug($this->varDump($HTTP_SERVER_VARS));
184
-		} else {
185
-			$this->debug("Neither _SERVER nor HTTP_SERVER_VARS is defined.");
186
-		}
178
+        if (isset($_SERVER)) {
179
+            $this->debug("_SERVER is defined:");
180
+            $this->appendDebug($this->varDump($_SERVER));
181
+        } elseif (isset($HTTP_SERVER_VARS)) {
182
+            $this->debug("HTTP_SERVER_VARS is defined:");
183
+            $this->appendDebug($this->varDump($HTTP_SERVER_VARS));
184
+        } else {
185
+            $this->debug("Neither _SERVER nor HTTP_SERVER_VARS is defined.");
186
+        }
187 187
 
188
-		if (isset($debug)) {
189
-			$this->debug("In nusoap_server, set debug_flag=$debug based on global flag");
190
-			$this->debug_flag = $debug;
191
-		} elseif (isset($_SERVER['QUERY_STRING'])) {
192
-			$qs = explode('&', $_SERVER['QUERY_STRING']);
193
-			foreach ($qs as $v) {
194
-				if (substr($v, 0, 6) == 'debug=') {
195
-					$this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #1");
196
-					$this->debug_flag = substr($v, 6);
197
-				}
198
-			}
199
-		} elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
200
-			$qs = explode('&', $HTTP_SERVER_VARS['QUERY_STRING']);
201
-			foreach ($qs as $v) {
202
-				if (substr($v, 0, 6) == 'debug=') {
203
-					$this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #2");
204
-					$this->debug_flag = substr($v, 6);
205
-				}
206
-			}
207
-		}
188
+        if (isset($debug)) {
189
+            $this->debug("In nusoap_server, set debug_flag=$debug based on global flag");
190
+            $this->debug_flag = $debug;
191
+        } elseif (isset($_SERVER['QUERY_STRING'])) {
192
+            $qs = explode('&', $_SERVER['QUERY_STRING']);
193
+            foreach ($qs as $v) {
194
+                if (substr($v, 0, 6) == 'debug=') {
195
+                    $this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #1");
196
+                    $this->debug_flag = substr($v, 6);
197
+                }
198
+            }
199
+        } elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
200
+            $qs = explode('&', $HTTP_SERVER_VARS['QUERY_STRING']);
201
+            foreach ($qs as $v) {
202
+                if (substr($v, 0, 6) == 'debug=') {
203
+                    $this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #2");
204
+                    $this->debug_flag = substr($v, 6);
205
+                }
206
+            }
207
+        }
208 208
 
209
-		// wsdl
210
-		if($wsdl){
211
-			$this->debug("In nusoap_server, WSDL is specified");
212
-			if (is_object($wsdl) && (get_class($wsdl) == 'wsdl')) {
213
-				$this->wsdl = $wsdl;
209
+        // wsdl
210
+        if($wsdl){
211
+            $this->debug("In nusoap_server, WSDL is specified");
212
+            if (is_object($wsdl) && (get_class($wsdl) == 'wsdl')) {
213
+                $this->wsdl = $wsdl;
214 214
                 $this->wsdl->soap_defencoding = $this->soap_defencoding;
215
-				$this->externalWSDLURL = $this->wsdl->wsdl;
216
-				$this->debug('Use existing wsdl instance from ' . $this->externalWSDLURL);
217
-			} else {
218
-				$this->debug('Create wsdl from ' . $wsdl);
219
-				$this->wsdl = new wsdl($wsdl);
215
+                $this->externalWSDLURL = $this->wsdl->wsdl;
216
+                $this->debug('Use existing wsdl instance from ' . $this->externalWSDLURL);
217
+            } else {
218
+                $this->debug('Create wsdl from ' . $wsdl);
219
+                $this->wsdl = new wsdl($wsdl);
220 220
                 $this->wsdl->soap_defencoding = $this->soap_defencoding;
221
-				$this->externalWSDLURL = $wsdl;
222
-			}
223
-			$this->appendDebug($this->wsdl->getDebug());
224
-			$this->wsdl->clearDebug();
225
-			if($err = $this->wsdl->getError()){
226
-				die('WSDL ERROR: '.$err);
227
-			}
228
-		}
229
-	}
221
+                $this->externalWSDLURL = $wsdl;
222
+            }
223
+            $this->appendDebug($this->wsdl->getDebug());
224
+            $this->wsdl->clearDebug();
225
+            if($err = $this->wsdl->getError()){
226
+                die('WSDL ERROR: '.$err);
227
+            }
228
+        }
229
+    }
230 230
 
231
-	/**
232
-	* processes request and returns response
233
-	*
234
-	* @param    string $data usually is the value of $HTTP_RAW_POST_DATA
235
-	* @access   public
236
-	*/
237
-	function service($data){
238
-		global $HTTP_SERVER_VARS;
231
+    /**
232
+     * processes request and returns response
233
+     *
234
+     * @param    string $data usually is the value of $HTTP_RAW_POST_DATA
235
+     * @access   public
236
+     */
237
+    function service($data){
238
+        global $HTTP_SERVER_VARS;
239 239
 
240
-		if (isset($_SERVER['REQUEST_METHOD'])) {
241
-			$rm = $_SERVER['REQUEST_METHOD'];
242
-		} elseif (isset($HTTP_SERVER_VARS['REQUEST_METHOD'])) {
243
-			$rm = $HTTP_SERVER_VARS['REQUEST_METHOD'];
244
-		} else {
245
-			$rm = '';
246
-		}
240
+        if (isset($_SERVER['REQUEST_METHOD'])) {
241
+            $rm = $_SERVER['REQUEST_METHOD'];
242
+        } elseif (isset($HTTP_SERVER_VARS['REQUEST_METHOD'])) {
243
+            $rm = $HTTP_SERVER_VARS['REQUEST_METHOD'];
244
+        } else {
245
+            $rm = '';
246
+        }
247 247
 
248
-		if (isset($_SERVER['QUERY_STRING'])) {
249
-			$qs = $_SERVER['QUERY_STRING'];
250
-		} elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
251
-			$qs = $HTTP_SERVER_VARS['QUERY_STRING'];
252
-		} else {
253
-			$qs = '';
254
-		}
255
-		$this->debug("In service, request method=$rm query string=$qs strlen(\$data)=" . strlen($data));
248
+        if (isset($_SERVER['QUERY_STRING'])) {
249
+            $qs = $_SERVER['QUERY_STRING'];
250
+        } elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
251
+            $qs = $HTTP_SERVER_VARS['QUERY_STRING'];
252
+        } else {
253
+            $qs = '';
254
+        }
255
+        $this->debug("In service, request method=$rm query string=$qs strlen(\$data)=" . strlen($data));
256 256
 
257
-		if ($rm == 'POST') {
258
-			$this->debug("In service, invoke the request");
259
-			$this->parse_request($data);
260
-			if (! $this->fault) {
261
-				$this->invoke_method();
262
-			}
263
-			if (! $this->fault) {
264
-				$this->serialize_return();
265
-			}
266
-			$this->send_response();
267
-		} elseif (preg_match('/wsdl/', $qs) ){
268
-			$this->debug("In service, this is a request for WSDL");
269
-			if ($this->externalWSDLURL){
270
-              if (strpos($this->externalWSDLURL, "http://") !== false) { // assume URL
271
-				$this->debug("In service, re-direct for WSDL");
272
-				header('Location: '.$this->externalWSDLURL);
273
-              } else { // assume file
274
-				$this->debug("In service, use file passthru for WSDL");
257
+        if ($rm == 'POST') {
258
+            $this->debug("In service, invoke the request");
259
+            $this->parse_request($data);
260
+            if (! $this->fault) {
261
+                $this->invoke_method();
262
+            }
263
+            if (! $this->fault) {
264
+                $this->serialize_return();
265
+            }
266
+            $this->send_response();
267
+        } elseif (preg_match('/wsdl/', $qs) ){
268
+            $this->debug("In service, this is a request for WSDL");
269
+            if ($this->externalWSDLURL){
270
+                if (strpos($this->externalWSDLURL, "http://") !== false) { // assume URL
271
+                $this->debug("In service, re-direct for WSDL");
272
+                header('Location: '.$this->externalWSDLURL);
273
+                } else { // assume file
274
+                $this->debug("In service, use file passthru for WSDL");
275 275
                 header("Content-Type: text/xml\r\n");
276
-				$pos = strpos($this->externalWSDLURL, "file://");
277
-				if ($pos === false) {
278
-					$filename = $this->externalWSDLURL;
279
-				} else {
280
-					$filename = substr($this->externalWSDLURL, $pos + 7);
281
-				}
276
+                $pos = strpos($this->externalWSDLURL, "file://");
277
+                if ($pos === false) {
278
+                    $filename = $this->externalWSDLURL;
279
+                } else {
280
+                    $filename = substr($this->externalWSDLURL, $pos + 7);
281
+                }
282 282
                 $fp = fopen($this->externalWSDLURL, 'r');
283 283
                 fpassthru($fp);
284
-              }
285
-			} elseif ($this->wsdl) {
286
-				$this->debug("In service, serialize WSDL");
284
+                }
285
+            } elseif ($this->wsdl) {
286
+                $this->debug("In service, serialize WSDL");
287 287
                 header("Content-Type: text/xml; charset=".$this->soap_defencoding."\r\n");
288
-				print $this->wsdl->serialize($this->debug_flag);
289
-				if ($this->debug_flag) {
290
-					$this->debug('wsdl:');
291
-					$this->appendDebug($this->varDump($this->wsdl));
292
-					print $this->getDebugAsXMLComment();
293
-				}
294
-			} else {
295
-				$this->debug("In service, there is no WSDL");
288
+                print $this->wsdl->serialize($this->debug_flag);
289
+                if ($this->debug_flag) {
290
+                    $this->debug('wsdl:');
291
+                    $this->appendDebug($this->varDump($this->wsdl));
292
+                    print $this->getDebugAsXMLComment();
293
+                }
294
+            } else {
295
+                $this->debug("In service, there is no WSDL");
296 296
                 header("Content-Type: text/html; charset=".$this->soap_defencoding."\r\n");
297
-				print "This service does not provide WSDL";
298
-			}
299
-		} elseif ($this->wsdl) {
300
-			$this->debug("In service, return Web description");
301
-			print $this->wsdl->webDescription();
302
-		} else {
303
-			$this->debug("In service, no Web description");
304
-			header("Content-Type: text/html; charset=ISO-8859-1\r\n");
305
-			print "This service does not provide a Web description";
306
-		}
307
-	}
297
+                print "This service does not provide WSDL";
298
+            }
299
+        } elseif ($this->wsdl) {
300
+            $this->debug("In service, return Web description");
301
+            print $this->wsdl->webDescription();
302
+        } else {
303
+            $this->debug("In service, no Web description");
304
+            header("Content-Type: text/html; charset=ISO-8859-1\r\n");
305
+            print "This service does not provide a Web description";
306
+        }
307
+    }
308 308
 
309
-	/**
310
-	* parses HTTP request headers.
311
-	*
312
-	* The following fields are set by this function (when successful)
313
-	*
314
-	* headers
315
-	* request
316
-	* xml_encoding
317
-	* SOAPAction
318
-	*
319
-	* @access   private
320
-	*/
321
-	function parse_http_headers() {
322
-		global $HTTP_SERVER_VARS;
309
+    /**
310
+     * parses HTTP request headers.
311
+     *
312
+     * The following fields are set by this function (when successful)
313
+     *
314
+     * headers
315
+     * request
316
+     * xml_encoding
317
+     * SOAPAction
318
+     *
319
+     * @access   private
320
+     */
321
+    function parse_http_headers() {
322
+        global $HTTP_SERVER_VARS;
323 323
 
324
-		$this->request = '';
325
-		$this->SOAPAction = '';
326
-		if(function_exists('getallheaders')){
327
-			$this->debug("In parse_http_headers, use getallheaders");
328
-			$headers = getallheaders();
329
-			foreach($headers as $k=>$v){
330
-				$k = strtolower($k);
331
-				$this->headers[$k] = $v;
332
-				$this->request .= "$k: $v\r\n";
333
-				$this->debug("$k: $v");
334
-			}
335
-			// get SOAPAction header
336
-			if(isset($this->headers['soapaction'])){
337
-				$this->SOAPAction = str_replace('"','',$this->headers['soapaction']);
338
-			}
339
-			// get the character encoding of the incoming request
340
-			if(isset($this->headers['content-type']) && strpos($this->headers['content-type'],'=')){
341
-				$enc = str_replace('"','',substr(strstr($this->headers["content-type"],'='),1));
342
-				if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
343
-					$this->xml_encoding = strtoupper($enc);
344
-				} else {
345
-					$this->xml_encoding = 'US-ASCII';
346
-				}
347
-			} else {
348
-				// should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
349
-				$this->xml_encoding = 'ISO-8859-1';
350
-			}
351
-		} elseif(isset($_SERVER) && is_array($_SERVER)){
352
-			$this->debug("In parse_http_headers, use _SERVER");
353
-			foreach ($_SERVER as $k => $v) {
354
-				if (substr($k, 0, 5) == 'HTTP_') {
355
-					$k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5))));
356
-				} else {
357
-					$k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k)));
358
-				}
359
-				if ($k == 'soapaction') {
360
-					// get SOAPAction header
361
-					$k = 'SOAPAction';
362
-					$v = str_replace('"', '', $v);
363
-					$v = str_replace('\\', '', $v);
364
-					$this->SOAPAction = $v;
365
-				} else if ($k == 'content-type') {
366
-					// get the character encoding of the incoming request
367
-					if (strpos($v, '=')) {
368
-						$enc = substr(strstr($v, '='), 1);
369
-						$enc = str_replace('"', '', $enc);
370
-						$enc = str_replace('\\', '', $enc);
371
-						if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) {
372
-							$this->xml_encoding = strtoupper($enc);
373
-						} else {
374
-							$this->xml_encoding = 'US-ASCII';
375
-						}
376
-					} else {
377
-						// should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
378
-						$this->xml_encoding = 'ISO-8859-1';
379
-					}
380
-				}
381
-				$this->headers[$k] = $v;
382
-				$this->request .= "$k: $v\r\n";
383
-				$this->debug("$k: $v");
384
-			}
385
-		} elseif (is_array($HTTP_SERVER_VARS)) {
386
-			$this->debug("In parse_http_headers, use HTTP_SERVER_VARS");
387
-			foreach ($HTTP_SERVER_VARS as $k => $v) {
388
-				if (substr($k, 0, 5) == 'HTTP_') {
389
-					$k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5)))); 	                                         $k = strtolower(substr($k, 5));
390
-				} else {
391
-					$k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k))); 	                                         $k = strtolower($k);
392
-				}
393
-				if ($k == 'soapaction') {
394
-					// get SOAPAction header
395
-					$k = 'SOAPAction';
396
-					$v = str_replace('"', '', $v);
397
-					$v = str_replace('\\', '', $v);
398
-					$this->SOAPAction = $v;
399
-				} else if ($k == 'content-type') {
400
-					// get the character encoding of the incoming request
401
-					if (strpos($v, '=')) {
402
-						$enc = substr(strstr($v, '='), 1);
403
-						$enc = str_replace('"', '', $enc);
404
-						$enc = str_replace('\\', '', $enc);
405
-						if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) {
406
-							$this->xml_encoding = strtoupper($enc);
407
-						} else {
408
-							$this->xml_encoding = 'US-ASCII';
409
-						}
410
-					} else {
411
-						// should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
412
-						$this->xml_encoding = 'ISO-8859-1';
413
-					}
414
-				}
415
-				$this->headers[$k] = $v;
416
-				$this->request .= "$k: $v\r\n";
417
-				$this->debug("$k: $v");
418
-			}
419
-		} else {
420
-			$this->debug("In parse_http_headers, HTTP headers not accessible");
421
-			$this->setError("HTTP headers not accessible");
422
-		}
423
-	}
324
+        $this->request = '';
325
+        $this->SOAPAction = '';
326
+        if(function_exists('getallheaders')){
327
+            $this->debug("In parse_http_headers, use getallheaders");
328
+            $headers = getallheaders();
329
+            foreach($headers as $k=>$v){
330
+                $k = strtolower($k);
331
+                $this->headers[$k] = $v;
332
+                $this->request .= "$k: $v\r\n";
333
+                $this->debug("$k: $v");
334
+            }
335
+            // get SOAPAction header
336
+            if(isset($this->headers['soapaction'])){
337
+                $this->SOAPAction = str_replace('"','',$this->headers['soapaction']);
338
+            }
339
+            // get the character encoding of the incoming request
340
+            if(isset($this->headers['content-type']) && strpos($this->headers['content-type'],'=')){
341
+                $enc = str_replace('"','',substr(strstr($this->headers["content-type"],'='),1));
342
+                if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
343
+                    $this->xml_encoding = strtoupper($enc);
344
+                } else {
345
+                    $this->xml_encoding = 'US-ASCII';
346
+                }
347
+            } else {
348
+                // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
349
+                $this->xml_encoding = 'ISO-8859-1';
350
+            }
351
+        } elseif(isset($_SERVER) && is_array($_SERVER)){
352
+            $this->debug("In parse_http_headers, use _SERVER");
353
+            foreach ($_SERVER as $k => $v) {
354
+                if (substr($k, 0, 5) == 'HTTP_') {
355
+                    $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5))));
356
+                } else {
357
+                    $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k)));
358
+                }
359
+                if ($k == 'soapaction') {
360
+                    // get SOAPAction header
361
+                    $k = 'SOAPAction';
362
+                    $v = str_replace('"', '', $v);
363
+                    $v = str_replace('\\', '', $v);
364
+                    $this->SOAPAction = $v;
365
+                } else if ($k == 'content-type') {
366
+                    // get the character encoding of the incoming request
367
+                    if (strpos($v, '=')) {
368
+                        $enc = substr(strstr($v, '='), 1);
369
+                        $enc = str_replace('"', '', $enc);
370
+                        $enc = str_replace('\\', '', $enc);
371
+                        if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) {
372
+                            $this->xml_encoding = strtoupper($enc);
373
+                        } else {
374
+                            $this->xml_encoding = 'US-ASCII';
375
+                        }
376
+                    } else {
377
+                        // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
378
+                        $this->xml_encoding = 'ISO-8859-1';
379
+                    }
380
+                }
381
+                $this->headers[$k] = $v;
382
+                $this->request .= "$k: $v\r\n";
383
+                $this->debug("$k: $v");
384
+            }
385
+        } elseif (is_array($HTTP_SERVER_VARS)) {
386
+            $this->debug("In parse_http_headers, use HTTP_SERVER_VARS");
387
+            foreach ($HTTP_SERVER_VARS as $k => $v) {
388
+                if (substr($k, 0, 5) == 'HTTP_') {
389
+                    $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5)))); 	                                         $k = strtolower(substr($k, 5));
390
+                } else {
391
+                    $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k))); 	                                         $k = strtolower($k);
392
+                }
393
+                if ($k == 'soapaction') {
394
+                    // get SOAPAction header
395
+                    $k = 'SOAPAction';
396
+                    $v = str_replace('"', '', $v);
397
+                    $v = str_replace('\\', '', $v);
398
+                    $this->SOAPAction = $v;
399
+                } else if ($k == 'content-type') {
400
+                    // get the character encoding of the incoming request
401
+                    if (strpos($v, '=')) {
402
+                        $enc = substr(strstr($v, '='), 1);
403
+                        $enc = str_replace('"', '', $enc);
404
+                        $enc = str_replace('\\', '', $enc);
405
+                        if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) {
406
+                            $this->xml_encoding = strtoupper($enc);
407
+                        } else {
408
+                            $this->xml_encoding = 'US-ASCII';
409
+                        }
410
+                    } else {
411
+                        // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
412
+                        $this->xml_encoding = 'ISO-8859-1';
413
+                    }
414
+                }
415
+                $this->headers[$k] = $v;
416
+                $this->request .= "$k: $v\r\n";
417
+                $this->debug("$k: $v");
418
+            }
419
+        } else {
420
+            $this->debug("In parse_http_headers, HTTP headers not accessible");
421
+            $this->setError("HTTP headers not accessible");
422
+        }
423
+    }
424 424
 
425
-	/**
426
-	* parses a request
427
-	*
428
-	* The following fields are set by this function (when successful)
429
-	*
430
-	* headers
431
-	* request
432
-	* xml_encoding
433
-	* SOAPAction
434
-	* request
435
-	* requestSOAP
436
-	* methodURI
437
-	* methodname
438
-	* methodparams
439
-	* requestHeaders
440
-	* document
441
-	*
442
-	* This sets the fault field on error
443
-	*
444
-	* @param    string $data XML string
445
-	* @access   private
446
-	*/
447
-	function parse_request($data='') {
448
-		$this->debug('entering parse_request()');
449
-		$this->parse_http_headers();
450
-		$this->debug('got character encoding: '.$this->xml_encoding);
451
-		// uncompress if necessary
452
-		if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] != '') {
453
-			$this->debug('got content encoding: ' . $this->headers['content-encoding']);
454
-			if ($this->headers['content-encoding'] == 'deflate' || $this->headers['content-encoding'] == 'gzip') {
455
-		    	// if decoding works, use it. else assume data wasn't gzencoded
456
-				if (function_exists('gzuncompress')) {
457
-					if ($this->headers['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) {
458
-						$data = $degzdata;
459
-					} elseif ($this->headers['content-encoding'] == 'gzip' && $degzdata = gzinflate(substr($data, 10))) {
460
-						$data = $degzdata;
461
-					} else {
462
-						$this->fault('SOAP-ENV:Client', 'Errors occurred when trying to decode the data');
463
-						return;
464
-					}
465
-				} else {
466
-					$this->fault('SOAP-ENV:Client', 'This Server does not support compressed data');
467
-					return;
468
-				}
469
-			}
470
-		}
471
-		$this->request .= "\r\n".$data;
472
-		$data = $this->parseRequest($this->headers, $data);
473
-		$this->requestSOAP = $data;
474
-		$this->debug('leaving parse_request');
475
-	}
425
+    /**
426
+     * parses a request
427
+     *
428
+     * The following fields are set by this function (when successful)
429
+     *
430
+     * headers
431
+     * request
432
+     * xml_encoding
433
+     * SOAPAction
434
+     * request
435
+     * requestSOAP
436
+     * methodURI
437
+     * methodname
438
+     * methodparams
439
+     * requestHeaders
440
+     * document
441
+     *
442
+     * This sets the fault field on error
443
+     *
444
+     * @param    string $data XML string
445
+     * @access   private
446
+     */
447
+    function parse_request($data='') {
448
+        $this->debug('entering parse_request()');
449
+        $this->parse_http_headers();
450
+        $this->debug('got character encoding: '.$this->xml_encoding);
451
+        // uncompress if necessary
452
+        if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] != '') {
453
+            $this->debug('got content encoding: ' . $this->headers['content-encoding']);
454
+            if ($this->headers['content-encoding'] == 'deflate' || $this->headers['content-encoding'] == 'gzip') {
455
+                // if decoding works, use it. else assume data wasn't gzencoded
456
+                if (function_exists('gzuncompress')) {
457
+                    if ($this->headers['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) {
458
+                        $data = $degzdata;
459
+                    } elseif ($this->headers['content-encoding'] == 'gzip' && $degzdata = gzinflate(substr($data, 10))) {
460
+                        $data = $degzdata;
461
+                    } else {
462
+                        $this->fault('SOAP-ENV:Client', 'Errors occurred when trying to decode the data');
463
+                        return;
464
+                    }
465
+                } else {
466
+                    $this->fault('SOAP-ENV:Client', 'This Server does not support compressed data');
467
+                    return;
468
+                }
469
+            }
470
+        }
471
+        $this->request .= "\r\n".$data;
472
+        $data = $this->parseRequest($this->headers, $data);
473
+        $this->requestSOAP = $data;
474
+        $this->debug('leaving parse_request');
475
+    }
476 476
 
477
-	/**
478
-	* invokes a PHP function for the requested SOAP method
479
-	*
480
-	* The following fields are set by this function (when successful)
481
-	*
482
-	* methodreturn
483
-	*
484
-	* Note that the PHP function that is called may also set the following
485
-	* fields to affect the response sent to the client
486
-	*
487
-	* responseHeaders
488
-	* outgoing_headers
489
-	*
490
-	* This sets the fault field on error
491
-	*
492
-	* @access   private
493
-	*/
494
-	function invoke_method() {
495
-		$this->debug('in invoke_method, methodname=' . $this->methodname . ' methodURI=' . $this->methodURI . ' SOAPAction=' . $this->SOAPAction);
477
+    /**
478
+     * invokes a PHP function for the requested SOAP method
479
+     *
480
+     * The following fields are set by this function (when successful)
481
+     *
482
+     * methodreturn
483
+     *
484
+     * Note that the PHP function that is called may also set the following
485
+     * fields to affect the response sent to the client
486
+     *
487
+     * responseHeaders
488
+     * outgoing_headers
489
+     *
490
+     * This sets the fault field on error
491
+     *
492
+     * @access   private
493
+     */
494
+    function invoke_method() {
495
+        $this->debug('in invoke_method, methodname=' . $this->methodname . ' methodURI=' . $this->methodURI . ' SOAPAction=' . $this->SOAPAction);
496 496
 
497
-		//
498
-		// if you are debugging in this area of the code, your service uses a class to implement methods,
499
-		// you use SOAP RPC, and the client is .NET, please be aware of the following...
500
-		// when the .NET wsdl.exe utility generates a proxy, it will remove the '.' or '..' from the
501
-		// method name.  that is fine for naming the .NET methods.  it is not fine for properly constructing
502
-		// the XML request and reading the XML response.  you need to add the RequestElementName and
503
-		// ResponseElementName to the System.Web.Services.Protocols.SoapRpcMethodAttribute that wsdl.exe
504
-		// generates for the method.  these parameters are used to specify the correct XML element names
505
-		// for .NET to use, i.e. the names with the '.' in them.
506
-		//
507
-		$orig_methodname = $this->methodname;
508
-		if ($this->wsdl) {
509
-			if ($this->opData = $this->wsdl->getOperationData($this->methodname)) {
510
-				$this->debug('in invoke_method, found WSDL operation=' . $this->methodname);
511
-				$this->appendDebug('opData=' . $this->varDump($this->opData));
512
-			} elseif ($this->opData = $this->wsdl->getOperationDataForSoapAction($this->SOAPAction)) {
513
-				// Note: hopefully this case will only be used for doc/lit, since rpc services should have wrapper element
514
-				$this->debug('in invoke_method, found WSDL soapAction=' . $this->SOAPAction . ' for operation=' . $this->opData['name']);
515
-				$this->appendDebug('opData=' . $this->varDump($this->opData));
516
-				$this->methodname = $this->opData['name'];
517
-			} else {
518
-				$this->debug('in invoke_method, no WSDL for operation=' . $this->methodname);
519
-				$this->fault('SOAP-ENV:Client', "Operation '" . $this->methodname . "' is not defined in the WSDL for this service");
520
-				return;
521
-			}
522
-		} else {
523
-			$this->debug('in invoke_method, no WSDL to validate method');
524
-		}
497
+        //
498
+        // if you are debugging in this area of the code, your service uses a class to implement methods,
499
+        // you use SOAP RPC, and the client is .NET, please be aware of the following...
500
+        // when the .NET wsdl.exe utility generates a proxy, it will remove the '.' or '..' from the
501
+        // method name.  that is fine for naming the .NET methods.  it is not fine for properly constructing
502
+        // the XML request and reading the XML response.  you need to add the RequestElementName and
503
+        // ResponseElementName to the System.Web.Services.Protocols.SoapRpcMethodAttribute that wsdl.exe
504
+        // generates for the method.  these parameters are used to specify the correct XML element names
505
+        // for .NET to use, i.e. the names with the '.' in them.
506
+        //
507
+        $orig_methodname = $this->methodname;
508
+        if ($this->wsdl) {
509
+            if ($this->opData = $this->wsdl->getOperationData($this->methodname)) {
510
+                $this->debug('in invoke_method, found WSDL operation=' . $this->methodname);
511
+                $this->appendDebug('opData=' . $this->varDump($this->opData));
512
+            } elseif ($this->opData = $this->wsdl->getOperationDataForSoapAction($this->SOAPAction)) {
513
+                // Note: hopefully this case will only be used for doc/lit, since rpc services should have wrapper element
514
+                $this->debug('in invoke_method, found WSDL soapAction=' . $this->SOAPAction . ' for operation=' . $this->opData['name']);
515
+                $this->appendDebug('opData=' . $this->varDump($this->opData));
516
+                $this->methodname = $this->opData['name'];
517
+            } else {
518
+                $this->debug('in invoke_method, no WSDL for operation=' . $this->methodname);
519
+                $this->fault('SOAP-ENV:Client', "Operation '" . $this->methodname . "' is not defined in the WSDL for this service");
520
+                return;
521
+            }
522
+        } else {
523
+            $this->debug('in invoke_method, no WSDL to validate method');
524
+        }
525 525
 
526
-		// if a . is present in $this->methodname, we see if there is a class in scope,
527
-		// which could be referred to. We will also distinguish between two deliminators,
528
-		// to allow methods to be called a the class or an instance
529
-		if (strpos($this->methodname, '..') > 0) {
530
-			$delim = '..';
531
-		} else if (strpos($this->methodname, '.') > 0) {
532
-			$delim = '.';
533
-		} else {
534
-			$delim = '';
535
-		}
536
-		$this->debug("in invoke_method, delim=$delim");
526
+        // if a . is present in $this->methodname, we see if there is a class in scope,
527
+        // which could be referred to. We will also distinguish between two deliminators,
528
+        // to allow methods to be called a the class or an instance
529
+        if (strpos($this->methodname, '..') > 0) {
530
+            $delim = '..';
531
+        } else if (strpos($this->methodname, '.') > 0) {
532
+            $delim = '.';
533
+        } else {
534
+            $delim = '';
535
+        }
536
+        $this->debug("in invoke_method, delim=$delim");
537 537
 
538
-		$class = '';
539
-		$method = '';
540
-		if (strlen($delim) > 0 && substr_count($this->methodname, $delim) == 1) {
541
-			$try_class = substr($this->methodname, 0, strpos($this->methodname, $delim));
542
-			if (class_exists($try_class)) {
543
-				// get the class and method name
544
-				$class = $try_class;
545
-				$method = substr($this->methodname, strpos($this->methodname, $delim) + strlen($delim));
546
-				$this->debug("in invoke_method, class=$class method=$method delim=$delim");
547
-			} else {
548
-				$this->debug("in invoke_method, class=$try_class not found");
549
-			}
550
-		} else {
551
-			$try_class = '';
552
-			$this->debug("in invoke_method, no class to try");
553
-		}
538
+        $class = '';
539
+        $method = '';
540
+        if (strlen($delim) > 0 && substr_count($this->methodname, $delim) == 1) {
541
+            $try_class = substr($this->methodname, 0, strpos($this->methodname, $delim));
542
+            if (class_exists($try_class)) {
543
+                // get the class and method name
544
+                $class = $try_class;
545
+                $method = substr($this->methodname, strpos($this->methodname, $delim) + strlen($delim));
546
+                $this->debug("in invoke_method, class=$class method=$method delim=$delim");
547
+            } else {
548
+                $this->debug("in invoke_method, class=$try_class not found");
549
+            }
550
+        } else {
551
+            $try_class = '';
552
+            $this->debug("in invoke_method, no class to try");
553
+        }
554 554
 
555
-		// does method exist?
556
-		if ($class == '') {
557
-			if (!function_exists($this->methodname)) {
558
-				$this->debug("in invoke_method, function '$this->methodname' not found!");
559
-				$this->result = 'fault: method not found';
560
-				$this->fault('SOAP-ENV:Client',"method '$this->methodname'('$orig_methodname') not defined in service('$try_class' '$delim')");
561
-				return;
562
-			}
563
-		} else {
564
-			$method_to_compare = (substr(phpversion(), 0, 2) == '4.') ? strtolower($method) : $method;
565
-			if (!in_array($method_to_compare, get_class_methods($class))) {
566
-				$this->debug("in invoke_method, method '$this->methodname' not found in class '$class'!");
567
-				$this->result = 'fault: method not found';
568
-				$this->fault('SOAP-ENV:Client',"method '$this->methodname'/'$method_to_compare'('$orig_methodname') not defined in service/'$class'('$try_class' '$delim')");
569
-				return;
570
-			}
571
-		}
555
+        // does method exist?
556
+        if ($class == '') {
557
+            if (!function_exists($this->methodname)) {
558
+                $this->debug("in invoke_method, function '$this->methodname' not found!");
559
+                $this->result = 'fault: method not found';
560
+                $this->fault('SOAP-ENV:Client',"method '$this->methodname'('$orig_methodname') not defined in service('$try_class' '$delim')");
561
+                return;
562
+            }
563
+        } else {
564
+            $method_to_compare = (substr(phpversion(), 0, 2) == '4.') ? strtolower($method) : $method;
565
+            if (!in_array($method_to_compare, get_class_methods($class))) {
566
+                $this->debug("in invoke_method, method '$this->methodname' not found in class '$class'!");
567
+                $this->result = 'fault: method not found';
568
+                $this->fault('SOAP-ENV:Client',"method '$this->methodname'/'$method_to_compare'('$orig_methodname') not defined in service/'$class'('$try_class' '$delim')");
569
+                return;
570
+            }
571
+        }
572 572
 
573
-		// evaluate message, getting back parameters
574
-		// verify that request parameters match the method's signature
575
-		if(! $this->verify_method($this->methodname,$this->methodparams)){
576
-			// debug
577
-			$this->debug('ERROR: request not verified against method signature');
578
-			$this->result = 'fault: request failed validation against method signature';
579
-			// return fault
580
-			$this->fault('SOAP-ENV:Client',"Operation '$this->methodname' not defined in service.");
581
-			return;
582
-		}
573
+        // evaluate message, getting back parameters
574
+        // verify that request parameters match the method's signature
575
+        if(! $this->verify_method($this->methodname,$this->methodparams)){
576
+            // debug
577
+            $this->debug('ERROR: request not verified against method signature');
578
+            $this->result = 'fault: request failed validation against method signature';
579
+            // return fault
580
+            $this->fault('SOAP-ENV:Client',"Operation '$this->methodname' not defined in service.");
581
+            return;
582
+        }
583 583
 
584
-		// if there are parameters to pass
585
-		$this->debug('in invoke_method, params:');
586
-		$this->appendDebug($this->varDump($this->methodparams));
587
-		$this->debug("in invoke_method, calling '$this->methodname'");
588
-		if (!function_exists('call_user_func_array')) {
589
-			if ($class == '') {
590
-				$this->debug('in invoke_method, calling function using eval()');
591
-				$funcCall = "\$this->methodreturn = $this->methodname(";
592
-			} else {
593
-				if ($delim == '..') {
594
-					$this->debug('in invoke_method, calling class method using eval()');
595
-					$funcCall = "\$this->methodreturn = ".$class."::".$method."(";
596
-				} else {
597
-					$this->debug('in invoke_method, calling instance method using eval()');
598
-					// generate unique instance name
599
-					$instname = "\$inst_".time();
600
-					$funcCall = $instname." = new ".$class."(); ";
601
-					$funcCall .= "\$this->methodreturn = ".$instname."->".$method."(";
602
-				}
603
-			}
604
-			if ($this->methodparams) {
605
-				foreach ($this->methodparams as $param) {
606
-					if (is_array($param) || is_object($param)) {
607
-						$this->fault('SOAP-ENV:Client', 'NuSOAP does not handle complexType parameters correctly when using eval; call_user_func_array must be available');
608
-						return;
609
-					}
610
-					$funcCall .= "\"$param\",";
611
-				}
612
-				$funcCall = substr($funcCall, 0, -1);
613
-			}
614
-			$funcCall .= ');';
615
-			$this->debug('in invoke_method, function call: '.$funcCall);
616
-			@eval($funcCall);
617
-		} else {
618
-			if ($class == '') {
619
-				$this->debug('in invoke_method, calling function using call_user_func_array()');
620
-				$call_arg = "$this->methodname";	// straight assignment changes $this->methodname to lower case after call_user_func_array()
621
-			} elseif ($delim == '..') {
622
-				$this->debug('in invoke_method, calling class method using call_user_func_array()');
623
-				$call_arg = array ($class, $method);
624
-			} else {
625
-				$this->debug('in invoke_method, calling instance method using call_user_func_array()');
626
-				$instance = new $class ();
627
-				$call_arg = array(&$instance, $method);
628
-			}
629
-			if (is_array($this->methodparams)) {
630
-				$this->methodreturn = call_user_func_array($call_arg, array_values($this->methodparams));
631
-			} else {
632
-				$this->methodreturn = call_user_func_array($call_arg, array());
633
-			}
634
-		}
584
+        // if there are parameters to pass
585
+        $this->debug('in invoke_method, params:');
586
+        $this->appendDebug($this->varDump($this->methodparams));
587
+        $this->debug("in invoke_method, calling '$this->methodname'");
588
+        if (!function_exists('call_user_func_array')) {
589
+            if ($class == '') {
590
+                $this->debug('in invoke_method, calling function using eval()');
591
+                $funcCall = "\$this->methodreturn = $this->methodname(";
592
+            } else {
593
+                if ($delim == '..') {
594
+                    $this->debug('in invoke_method, calling class method using eval()');
595
+                    $funcCall = "\$this->methodreturn = ".$class."::".$method."(";
596
+                } else {
597
+                    $this->debug('in invoke_method, calling instance method using eval()');
598
+                    // generate unique instance name
599
+                    $instname = "\$inst_".time();
600
+                    $funcCall = $instname." = new ".$class."(); ";
601
+                    $funcCall .= "\$this->methodreturn = ".$instname."->".$method."(";
602
+                }
603
+            }
604
+            if ($this->methodparams) {
605
+                foreach ($this->methodparams as $param) {
606
+                    if (is_array($param) || is_object($param)) {
607
+                        $this->fault('SOAP-ENV:Client', 'NuSOAP does not handle complexType parameters correctly when using eval; call_user_func_array must be available');
608
+                        return;
609
+                    }
610
+                    $funcCall .= "\"$param\",";
611
+                }
612
+                $funcCall = substr($funcCall, 0, -1);
613
+            }
614
+            $funcCall .= ');';
615
+            $this->debug('in invoke_method, function call: '.$funcCall);
616
+            @eval($funcCall);
617
+        } else {
618
+            if ($class == '') {
619
+                $this->debug('in invoke_method, calling function using call_user_func_array()');
620
+                $call_arg = "$this->methodname";	// straight assignment changes $this->methodname to lower case after call_user_func_array()
621
+            } elseif ($delim == '..') {
622
+                $this->debug('in invoke_method, calling class method using call_user_func_array()');
623
+                $call_arg = array ($class, $method);
624
+            } else {
625
+                $this->debug('in invoke_method, calling instance method using call_user_func_array()');
626
+                $instance = new $class ();
627
+                $call_arg = array(&$instance, $method);
628
+            }
629
+            if (is_array($this->methodparams)) {
630
+                $this->methodreturn = call_user_func_array($call_arg, array_values($this->methodparams));
631
+            } else {
632
+                $this->methodreturn = call_user_func_array($call_arg, array());
633
+            }
634
+        }
635 635
         $this->debug('in invoke_method, methodreturn:');
636 636
         $this->appendDebug($this->varDump($this->methodreturn));
637
-		$this->debug("in invoke_method, called method $this->methodname, received data of type ".gettype($this->methodreturn));
638
-	}
637
+        $this->debug("in invoke_method, called method $this->methodname, received data of type ".gettype($this->methodreturn));
638
+    }
639 639
 
640
-	/**
641
-	* serializes the return value from a PHP function into a full SOAP Envelope
642
-	*
643
-	* The following fields are set by this function (when successful)
644
-	*
645
-	* responseSOAP
646
-	*
647
-	* This sets the fault field on error
648
-	*
649
-	* @access   private
650
-	*/
651
-	function serialize_return() {
652
-		$this->debug('Entering serialize_return methodname: ' . $this->methodname . ' methodURI: ' . $this->methodURI);
653
-		// if fault
654
-		if (isset($this->methodreturn) && is_object($this->methodreturn) && ((get_class($this->methodreturn) == 'soap_fault') || (get_class($this->methodreturn) == 'nusoap_fault'))) {
655
-			$this->debug('got a fault object from method');
656
-			$this->fault = $this->methodreturn;
657
-			return;
658
-		} elseif ($this->methodreturnisliteralxml) {
659
-			$return_val = $this->methodreturn;
660
-		// returned value(s)
661
-		} else {
662
-			$this->debug('got a(n) '.gettype($this->methodreturn).' from method');
663
-			$this->debug('serializing return value');
664
-			if($this->wsdl){
665
-				$opParams = "";
666
-				if (sizeof($this->opData['output']['parts']) > 1) {
667
-					$this->debug('more than one output part, so use the method return unchanged');
668
-			    	$opParams = $this->methodreturn;
669
-			    } elseif (sizeof($this->opData['output']['parts']) == 1) {
670
-					$this->debug('exactly one output part, so wrap the method return in a simple array');
671
-					// TODO: verify that it is not already wrapped!
672
-			    	//foreach ($this->opData['output']['parts'] as $name => $type) {
673
-					//	$this->debug('wrap in element named ' . $name);
674
-			    	//}
675
-			    	$opParams = array($this->methodreturn);
676
-			    }
677
-			    $return_val = $this->wsdl->serializeRPCParameters($this->methodname,'output',$opParams);
678
-			    $this->appendDebug($this->wsdl->getDebug());
679
-			    $this->wsdl->clearDebug();
680
-				if($errstr = $this->wsdl->getError()){
681
-					$this->debug('got wsdl error: '.$errstr);
682
-					$this->fault('SOAP-ENV:Server', 'unable to serialize result');
683
-					return;
684
-				}
685
-			} else {
686
-				if (isset($this->methodreturn)) {
687
-					$return_val = $this->serialize_val($this->methodreturn, 'return');
688
-				} else {
689
-					$return_val = '';
690
-					$this->debug('in absence of WSDL, assume void return for backward compatibility');
691
-				}
692
-			}
693
-		}
694
-		$this->debug('return value:');
695
-		$this->appendDebug($this->varDump($return_val));
640
+    /**
641
+     * serializes the return value from a PHP function into a full SOAP Envelope
642
+     *
643
+     * The following fields are set by this function (when successful)
644
+     *
645
+     * responseSOAP
646
+     *
647
+     * This sets the fault field on error
648
+     *
649
+     * @access   private
650
+     */
651
+    function serialize_return() {
652
+        $this->debug('Entering serialize_return methodname: ' . $this->methodname . ' methodURI: ' . $this->methodURI);
653
+        // if fault
654
+        if (isset($this->methodreturn) && is_object($this->methodreturn) && ((get_class($this->methodreturn) == 'soap_fault') || (get_class($this->methodreturn) == 'nusoap_fault'))) {
655
+            $this->debug('got a fault object from method');
656
+            $this->fault = $this->methodreturn;
657
+            return;
658
+        } elseif ($this->methodreturnisliteralxml) {
659
+            $return_val = $this->methodreturn;
660
+        // returned value(s)
661
+        } else {
662
+            $this->debug('got a(n) '.gettype($this->methodreturn).' from method');
663
+            $this->debug('serializing return value');
664
+            if($this->wsdl){
665
+                $opParams = "";
666
+                if (sizeof($this->opData['output']['parts']) > 1) {
667
+                    $this->debug('more than one output part, so use the method return unchanged');
668
+                    $opParams = $this->methodreturn;
669
+                } elseif (sizeof($this->opData['output']['parts']) == 1) {
670
+                    $this->debug('exactly one output part, so wrap the method return in a simple array');
671
+                    // TODO: verify that it is not already wrapped!
672
+                    //foreach ($this->opData['output']['parts'] as $name => $type) {
673
+                    //	$this->debug('wrap in element named ' . $name);
674
+                    //}
675
+                    $opParams = array($this->methodreturn);
676
+                }
677
+                $return_val = $this->wsdl->serializeRPCParameters($this->methodname,'output',$opParams);
678
+                $this->appendDebug($this->wsdl->getDebug());
679
+                $this->wsdl->clearDebug();
680
+                if($errstr = $this->wsdl->getError()){
681
+                    $this->debug('got wsdl error: '.$errstr);
682
+                    $this->fault('SOAP-ENV:Server', 'unable to serialize result');
683
+                    return;
684
+                }
685
+            } else {
686
+                if (isset($this->methodreturn)) {
687
+                    $return_val = $this->serialize_val($this->methodreturn, 'return');
688
+                } else {
689
+                    $return_val = '';
690
+                    $this->debug('in absence of WSDL, assume void return for backward compatibility');
691
+                }
692
+            }
693
+        }
694
+        $this->debug('return value:');
695
+        $this->appendDebug($this->varDump($return_val));
696 696
 
697
-		$this->debug('serializing response');
698
-		if ($this->wsdl) {
699
-			$this->debug('have WSDL for serialization: style is ' . $this->opData['style']);
700
-			if ($this->opData['style'] == 'rpc') {
701
-				$this->debug('style is rpc for serialization: use is ' . $this->opData['output']['use']);
702
-				if ($this->opData['output']['use'] == 'literal') {
703
-					// http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html R2735 says rpc/literal accessor elements should not be in a namespace
704
-					if ($this->methodURI) {
705
-						$payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>";
706
-					} else {
707
-						$payload = '<'.$this->methodname.'Response>'.$return_val.'</'.$this->methodname.'Response>';
708
-					}
709
-				} else {
710
-					if ($this->methodURI) {
711
-						$payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>";
712
-					} else {
713
-						$payload = '<'.$this->methodname.'Response>'.$return_val.'</'.$this->methodname.'Response>';
714
-					}
715
-				}
716
-			} else {
717
-				$this->debug('style is not rpc for serialization: assume document');
718
-				$payload = $return_val;
719
-			}
720
-		} else {
721
-			$this->debug('do not have WSDL for serialization: assume rpc/encoded');
722
-			$payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>";
723
-		}
724
-		$this->result = 'successful';
725
-		if($this->wsdl){
726
-			//if($this->debug_flag){
727
-            	$this->appendDebug($this->wsdl->getDebug());
697
+        $this->debug('serializing response');
698
+        if ($this->wsdl) {
699
+            $this->debug('have WSDL for serialization: style is ' . $this->opData['style']);
700
+            if ($this->opData['style'] == 'rpc') {
701
+                $this->debug('style is rpc for serialization: use is ' . $this->opData['output']['use']);
702
+                if ($this->opData['output']['use'] == 'literal') {
703
+                    // http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html R2735 says rpc/literal accessor elements should not be in a namespace
704
+                    if ($this->methodURI) {
705
+                        $payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>";
706
+                    } else {
707
+                        $payload = '<'.$this->methodname.'Response>'.$return_val.'</'.$this->methodname.'Response>';
708
+                    }
709
+                } else {
710
+                    if ($this->methodURI) {
711
+                        $payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>";
712
+                    } else {
713
+                        $payload = '<'.$this->methodname.'Response>'.$return_val.'</'.$this->methodname.'Response>';
714
+                    }
715
+                }
716
+            } else {
717
+                $this->debug('style is not rpc for serialization: assume document');
718
+                $payload = $return_val;
719
+            }
720
+        } else {
721
+            $this->debug('do not have WSDL for serialization: assume rpc/encoded');
722
+            $payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>";
723
+        }
724
+        $this->result = 'successful';
725
+        if($this->wsdl){
726
+            //if($this->debug_flag){
727
+                $this->appendDebug($this->wsdl->getDebug());
728 728
             //	}
729
-			if (isset($this->opData['output']['encodingStyle'])) {
730
-				$encodingStyle = $this->opData['output']['encodingStyle'];
731
-			} else {
732
-				$encodingStyle = '';
733
-			}
734
-			// Added: In case we use a WSDL, return a serialized env. WITH the usedNamespaces.
735
-			$this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders,$this->wsdl->usedNamespaces,$this->opData['style'],$this->opData['output']['use'],$encodingStyle);
736
-		} else {
737
-			$this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders);
738
-		}
739
-		$this->debug("Leaving serialize_return");
740
-	}
729
+            if (isset($this->opData['output']['encodingStyle'])) {
730
+                $encodingStyle = $this->opData['output']['encodingStyle'];
731
+            } else {
732
+                $encodingStyle = '';
733
+            }
734
+            // Added: In case we use a WSDL, return a serialized env. WITH the usedNamespaces.
735
+            $this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders,$this->wsdl->usedNamespaces,$this->opData['style'],$this->opData['output']['use'],$encodingStyle);
736
+        } else {
737
+            $this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders);
738
+        }
739
+        $this->debug("Leaving serialize_return");
740
+    }
741 741
 
742
-	/**
743
-	* sends an HTTP response
744
-	*
745
-	* The following fields are set by this function (when successful)
746
-	*
747
-	* outgoing_headers
748
-	* response
749
-	*
750
-	* @access   private
751
-	*/
752
-	function send_response() {
753
-		$this->debug('Enter send_response');
754
-		if ($this->fault) {
755
-			$payload = $this->fault->serialize();
756
-			$this->outgoing_headers[] = "HTTP/1.0 500 Internal Server Error";
757
-			$this->outgoing_headers[] = "Status: 500 Internal Server Error";
758
-		} else {
759
-			$payload = $this->responseSOAP;
760
-			// Some combinations of PHP+Web server allow the Status
761
-			// to come through as a header.  Since OK is the default
762
-			// just do nothing.
763
-			// $this->outgoing_headers[] = "HTTP/1.0 200 OK";
764
-			// $this->outgoing_headers[] = "Status: 200 OK";
765
-		}
742
+    /**
743
+     * sends an HTTP response
744
+     *
745
+     * The following fields are set by this function (when successful)
746
+     *
747
+     * outgoing_headers
748
+     * response
749
+     *
750
+     * @access   private
751
+     */
752
+    function send_response() {
753
+        $this->debug('Enter send_response');
754
+        if ($this->fault) {
755
+            $payload = $this->fault->serialize();
756
+            $this->outgoing_headers[] = "HTTP/1.0 500 Internal Server Error";
757
+            $this->outgoing_headers[] = "Status: 500 Internal Server Error";
758
+        } else {
759
+            $payload = $this->responseSOAP;
760
+            // Some combinations of PHP+Web server allow the Status
761
+            // to come through as a header.  Since OK is the default
762
+            // just do nothing.
763
+            // $this->outgoing_headers[] = "HTTP/1.0 200 OK";
764
+            // $this->outgoing_headers[] = "Status: 200 OK";
765
+        }
766 766
         // add debug data if in debug mode
767
-		if(isset($this->debug_flag) && $this->debug_flag){
768
-        	$payload .= $this->getDebugAsXMLComment();
767
+        if(isset($this->debug_flag) && $this->debug_flag){
768
+            $payload .= $this->getDebugAsXMLComment();
769
+        }
770
+        $this->outgoing_headers[] = "Server: $this->title Server v$this->version";
771
+        preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
772
+        $this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (".$rev[1].")";
773
+        // Let the Web server decide about this
774
+        //$this->outgoing_headers[] = "Connection: Close\r\n";
775
+        $payload = $this->getHTTPBody($payload);
776
+        $type = $this->getHTTPContentType();
777
+        $charset = $this->getHTTPContentTypeCharset();
778
+        $this->outgoing_headers[] = "Content-Type: $type" . ($charset ? '; charset=' . $charset : '');
779
+        //begin code to compress payload - by John
780
+        // NOTE: there is no way to know whether the Web server will also compress
781
+        // this data.
782
+        if (strlen($payload) > 1024 && isset($this->headers) && isset($this->headers['accept-encoding'])) {
783
+            if (strstr($this->headers['accept-encoding'], 'gzip')) {
784
+                if (function_exists('gzencode')) {
785
+                    if (isset($this->debug_flag) && $this->debug_flag) {
786
+                        $payload .= "<!-- Content being gzipped -->";
787
+                    }
788
+                    $this->outgoing_headers[] = "Content-Encoding: gzip";
789
+                    $payload = gzencode($payload);
790
+                } else {
791
+                    if (isset($this->debug_flag) && $this->debug_flag) {
792
+                        $payload .= "<!-- Content will not be gzipped: no gzencode -->";
793
+                    }
794
+                }
795
+            } elseif (strstr($this->headers['accept-encoding'], 'deflate')) {
796
+                // Note: MSIE requires gzdeflate output (no Zlib header and checksum),
797
+                // instead of gzcompress output,
798
+                // which conflicts with HTTP 1.1 spec (http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.5)
799
+                if (function_exists('gzdeflate')) {
800
+                    if (isset($this->debug_flag) && $this->debug_flag) {
801
+                        $payload .= "<!-- Content being deflated -->";
802
+                    }
803
+                    $this->outgoing_headers[] = "Content-Encoding: deflate";
804
+                    $payload = gzdeflate($payload);
805
+                } else {
806
+                    if (isset($this->debug_flag) && $this->debug_flag) {
807
+                        $payload .= "<!-- Content will not be deflated: no gzcompress -->";
808
+                    }
809
+                }
810
+            }
769 811
         }
770
-		$this->outgoing_headers[] = "Server: $this->title Server v$this->version";
771
-		preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
772
-		$this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (".$rev[1].")";
773
-		// Let the Web server decide about this
774
-		//$this->outgoing_headers[] = "Connection: Close\r\n";
775
-		$payload = $this->getHTTPBody($payload);
776
-		$type = $this->getHTTPContentType();
777
-		$charset = $this->getHTTPContentTypeCharset();
778
-		$this->outgoing_headers[] = "Content-Type: $type" . ($charset ? '; charset=' . $charset : '');
779
-		//begin code to compress payload - by John
780
-		// NOTE: there is no way to know whether the Web server will also compress
781
-		// this data.
782
-		if (strlen($payload) > 1024 && isset($this->headers) && isset($this->headers['accept-encoding'])) {
783
-			if (strstr($this->headers['accept-encoding'], 'gzip')) {
784
-				if (function_exists('gzencode')) {
785
-					if (isset($this->debug_flag) && $this->debug_flag) {
786
-						$payload .= "<!-- Content being gzipped -->";
787
-					}
788
-					$this->outgoing_headers[] = "Content-Encoding: gzip";
789
-					$payload = gzencode($payload);
790
-				} else {
791
-					if (isset($this->debug_flag) && $this->debug_flag) {
792
-						$payload .= "<!-- Content will not be gzipped: no gzencode -->";
793
-					}
794
-				}
795
-			} elseif (strstr($this->headers['accept-encoding'], 'deflate')) {
796
-				// Note: MSIE requires gzdeflate output (no Zlib header and checksum),
797
-				// instead of gzcompress output,
798
-				// which conflicts with HTTP 1.1 spec (http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.5)
799
-				if (function_exists('gzdeflate')) {
800
-					if (isset($this->debug_flag) && $this->debug_flag) {
801
-						$payload .= "<!-- Content being deflated -->";
802
-					}
803
-					$this->outgoing_headers[] = "Content-Encoding: deflate";
804
-					$payload = gzdeflate($payload);
805
-				} else {
806
-					if (isset($this->debug_flag) && $this->debug_flag) {
807
-						$payload .= "<!-- Content will not be deflated: no gzcompress -->";
808
-					}
809
-				}
810
-			}
811
-		}
812
-		//end code
813
-		$this->outgoing_headers[] = "Content-Length: ".strlen($payload);
814
-		reset($this->outgoing_headers);
815
-		foreach($this->outgoing_headers as $hdr){
816
-			header($hdr, false);
817
-		}
818
-		print $payload;
819
-		$this->response = join("\r\n",$this->outgoing_headers)."\r\n\r\n".$payload;
820
-	}
812
+        //end code
813
+        $this->outgoing_headers[] = "Content-Length: ".strlen($payload);
814
+        reset($this->outgoing_headers);
815
+        foreach($this->outgoing_headers as $hdr){
816
+            header($hdr, false);
817
+        }
818
+        print $payload;
819
+        $this->response = join("\r\n",$this->outgoing_headers)."\r\n\r\n".$payload;
820
+    }
821 821
 
822
-	/**
823
-	* takes the value that was created by parsing the request
824
-	* and compares to the method's signature, if available.
825
-	*
826
-	* @param	string	$operation	The operation to be invoked
827
-	* @param	array	$request	The array of parameter values
828
-	* @return	boolean	Whether the operation was found
829
-	* @access   private
830
-	*/
831
-	function verify_method($operation,$request){
832
-		if(isset($this->wsdl) && is_object($this->wsdl)){
833
-			if($this->wsdl->getOperationData($operation)){
834
-				return true;
835
-			}
836
-	    } elseif(isset($this->operations[$operation])){
837
-			return true;
838
-		}
839
-		return false;
840
-	}
822
+    /**
823
+     * takes the value that was created by parsing the request
824
+     * and compares to the method's signature, if available.
825
+     *
826
+     * @param	string	$operation	The operation to be invoked
827
+     * @param	array	$request	The array of parameter values
828
+     * @return	boolean	Whether the operation was found
829
+     * @access   private
830
+     */
831
+    function verify_method($operation,$request){
832
+        if(isset($this->wsdl) && is_object($this->wsdl)){
833
+            if($this->wsdl->getOperationData($operation)){
834
+                return true;
835
+            }
836
+        } elseif(isset($this->operations[$operation])){
837
+            return true;
838
+        }
839
+        return false;
840
+    }
841 841
 
842
-	/**
843
-	* processes SOAP message received from client
844
-	*
845
-	* @param	array	$headers	The HTTP headers
846
-	* @param	string	$data		unprocessed request data from client
847
-	* @return	mixed	value of the message, decoded into a PHP type
848
-	* @access   private
849
-	*/
842
+    /**
843
+     * processes SOAP message received from client
844
+     *
845
+     * @param	array	$headers	The HTTP headers
846
+     * @param	string	$data		unprocessed request data from client
847
+     * @return	mixed	value of the message, decoded into a PHP type
848
+     * @access   private
849
+     */
850 850
     function parseRequest($headers, $data) {
851
-		$this->debug('Entering parseRequest() for data of length ' . strlen($data) . ' headers:');
852
-		$this->appendDebug($this->varDump($headers));
853
-    	if (!isset($headers['content-type'])) {
854
-			$this->setError('Request not of type text/xml (no content-type header)');
855
-			return false;
856
-    	}
857
-		if (!strstr($headers['content-type'], 'text/xml')) {
858
-			$this->setError('Request not of type text/xml');
859
-			return false;
860
-		}
861
-		if (strpos($headers['content-type'], '=')) {
862
-			$enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
863
-			$this->debug('Got response encoding: ' . $enc);
864
-			if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
865
-				$this->xml_encoding = strtoupper($enc);
866
-			} else {
867
-				$this->xml_encoding = 'US-ASCII';
868
-			}
869
-		} else {
870
-			// should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
871
-			$this->xml_encoding = 'ISO-8859-1';
872
-		}
873
-		$this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser');
874
-		// parse response, get soap parser obj
875
-		$parser = new nusoap_parser($data,$this->xml_encoding,'',$this->decode_utf8);
851
+        $this->debug('Entering parseRequest() for data of length ' . strlen($data) . ' headers:');
852
+        $this->appendDebug($this->varDump($headers));
853
+        if (!isset($headers['content-type'])) {
854
+            $this->setError('Request not of type text/xml (no content-type header)');
855
+            return false;
856
+        }
857
+        if (!strstr($headers['content-type'], 'text/xml')) {
858
+            $this->setError('Request not of type text/xml');
859
+            return false;
860
+        }
861
+        if (strpos($headers['content-type'], '=')) {
862
+            $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
863
+            $this->debug('Got response encoding: ' . $enc);
864
+            if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
865
+                $this->xml_encoding = strtoupper($enc);
866
+            } else {
867
+                $this->xml_encoding = 'US-ASCII';
868
+            }
869
+        } else {
870
+            // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
871
+            $this->xml_encoding = 'ISO-8859-1';
872
+        }
873
+        $this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser');
874
+        // parse response, get soap parser obj
875
+        $parser = new nusoap_parser($data,$this->xml_encoding,'',$this->decode_utf8);
876 876
 
877
-		// parser debug
878
-		$this->debug("parser debug: \n".$parser->getDebug());
879
-		// if fault occurred during message parsing
880
-		if($err = $parser->getError()){
881
-			$this->result = 'fault: error in msg parsing: '.$err;
882
-			$this->fault('SOAP-ENV:Client',"error in msg parsing:\n".$err);
883
-		// else successfully parsed request into soapval object
884
-		} else {
885
-			// get/set methodname
886
-			$this->methodURI = $parser->root_struct_namespace;
887
-			$this->methodname = $parser->root_struct_name;
888
-			$this->debug('methodname: '.$this->methodname.' methodURI: '.$this->methodURI);
889
-			$this->debug('calling parser->get_soapbody()');
890
-			$this->methodparams = $parser->get_soapbody();
891
-			// get SOAP headers
892
-			$this->requestHeaders = $parser->getHeaders();
893
-			// get SOAP Header
894
-			$this->requestHeader = $parser->get_soapheader();
877
+        // parser debug
878
+        $this->debug("parser debug: \n".$parser->getDebug());
879
+        // if fault occurred during message parsing
880
+        if($err = $parser->getError()){
881
+            $this->result = 'fault: error in msg parsing: '.$err;
882
+            $this->fault('SOAP-ENV:Client',"error in msg parsing:\n".$err);
883
+        // else successfully parsed request into soapval object
884
+        } else {
885
+            // get/set methodname
886
+            $this->methodURI = $parser->root_struct_namespace;
887
+            $this->methodname = $parser->root_struct_name;
888
+            $this->debug('methodname: '.$this->methodname.' methodURI: '.$this->methodURI);
889
+            $this->debug('calling parser->get_soapbody()');
890
+            $this->methodparams = $parser->get_soapbody();
891
+            // get SOAP headers
892
+            $this->requestHeaders = $parser->getHeaders();
893
+            // get SOAP Header
894
+            $this->requestHeader = $parser->get_soapheader();
895 895
             // add document for doclit support
896 896
             $this->document = $parser->document;
897
-		}
898
-	 }
897
+        }
898
+        }
899 899
 
900
-	/**
901
-	* gets the HTTP body for the current response.
902
-	*
903
-	* @param string $soapmsg The SOAP payload
904
-	* @return string The HTTP body, which includes the SOAP payload
905
-	* @access private
906
-	*/
907
-	function getHTTPBody($soapmsg) {
908
-		return $soapmsg;
909
-	}
900
+    /**
901
+     * gets the HTTP body for the current response.
902
+     *
903
+     * @param string $soapmsg The SOAP payload
904
+     * @return string The HTTP body, which includes the SOAP payload
905
+     * @access private
906
+     */
907
+    function getHTTPBody($soapmsg) {
908
+        return $soapmsg;
909
+    }
910 910
 
911
-	/**
912
-	* gets the HTTP content type for the current response.
913
-	*
914
-	* Note: getHTTPBody must be called before this.
915
-	*
916
-	* @return string the HTTP content type for the current response.
917
-	* @access private
918
-	*/
919
-	function getHTTPContentType() {
920
-		return 'text/xml';
921
-	}
911
+    /**
912
+     * gets the HTTP content type for the current response.
913
+     *
914
+     * Note: getHTTPBody must be called before this.
915
+     *
916
+     * @return string the HTTP content type for the current response.
917
+     * @access private
918
+     */
919
+    function getHTTPContentType() {
920
+        return 'text/xml';
921
+    }
922 922
 
923
-	/**
924
-	* gets the HTTP content type charset for the current response.
925
-	* returns false for non-text content types.
926
-	*
927
-	* Note: getHTTPBody must be called before this.
928
-	*
929
-	* @return string the HTTP content type charset for the current response.
930
-	* @access private
931
-	*/
932
-	function getHTTPContentTypeCharset() {
933
-		return $this->soap_defencoding;
934
-	}
923
+    /**
924
+     * gets the HTTP content type charset for the current response.
925
+     * returns false for non-text content types.
926
+     *
927
+     * Note: getHTTPBody must be called before this.
928
+     *
929
+     * @return string the HTTP content type charset for the current response.
930
+     * @access private
931
+     */
932
+    function getHTTPContentTypeCharset() {
933
+        return $this->soap_defencoding;
934
+    }
935 935
 
936
-	/**
937
-	* add a method to the dispatch map (this has been replaced by the register method)
938
-	*
939
-	* @param    string $methodname
940
-	* @param    string $in array of input values
941
-	* @param    string $out array of output values
942
-	* @access   public
943
-	* @deprecated
944
-	*/
945
-	function add_to_map($methodname,$in,$out){
946
-			$this->operations[$methodname] = array('name' => $methodname,'in' => $in,'out' => $out);
947
-	}
936
+    /**
937
+     * add a method to the dispatch map (this has been replaced by the register method)
938
+     *
939
+     * @param    string $methodname
940
+     * @param    string $in array of input values
941
+     * @param    string $out array of output values
942
+     * @access   public
943
+     * @deprecated
944
+     */
945
+    function add_to_map($methodname,$in,$out){
946
+            $this->operations[$methodname] = array('name' => $methodname,'in' => $in,'out' => $out);
947
+    }
948 948
 
949
-	/**
950
-	* register a service function with the server
951
-	*
952
-	* @param    string $name the name of the PHP function, class.method or class..method
953
-	* @param    array $in assoc array of input values: key = param name, value = param type
954
-	* @param    array $out assoc array of output values: key = param name, value = param type
955
-	* @param	mixed $namespace the element namespace for the method or false
956
-	* @param	mixed $soapaction the soapaction for the method or false
957
-	* @param	mixed $style optional (rpc|document) or false Note: when 'document' is specified, parameter and return wrappers are created for you automatically
958
-	* @param	mixed $use optional (encoded|literal) or false
959
-	* @param	string $documentation optional Description to include in WSDL
960
-	* @param	string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
961
-	* @access   public
962
-	*/
963
-	function register($name,$in=array(),$out=array(),$namespace=false,$soapaction=false,$style=false,$use=false,$documentation='',$encodingStyle=''){
964
-		global $HTTP_SERVER_VARS;
949
+    /**
950
+     * register a service function with the server
951
+     *
952
+     * @param    string $name the name of the PHP function, class.method or class..method
953
+     * @param    array $in assoc array of input values: key = param name, value = param type
954
+     * @param    array $out assoc array of output values: key = param name, value = param type
955
+     * @param	mixed $namespace the element namespace for the method or false
956
+     * @param	mixed $soapaction the soapaction for the method or false
957
+     * @param	mixed $style optional (rpc|document) or false Note: when 'document' is specified, parameter and return wrappers are created for you automatically
958
+     * @param	mixed $use optional (encoded|literal) or false
959
+     * @param	string $documentation optional Description to include in WSDL
960
+     * @param	string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
961
+     * @access   public
962
+     */
963
+    function register($name,$in=array(),$out=array(),$namespace=false,$soapaction=false,$style=false,$use=false,$documentation='',$encodingStyle=''){
964
+        global $HTTP_SERVER_VARS;
965 965
 
966
-		if($this->externalWSDLURL){
967
-			die('You cannot bind to an external WSDL file, and register methods outside of it! Please choose either WSDL or no WSDL.');
968
-		}
969
-		if (! $name) {
970
-			die('You must specify a name when you register an operation');
971
-		}
972
-		if (!is_array($in)) {
973
-			die('You must provide an array for operation inputs');
974
-		}
975
-		if (!is_array($out)) {
976
-			die('You must provide an array for operation outputs');
977
-		}
978
-		if(false == $namespace) {
979
-		}
980
-		if(false == $soapaction) {
981
-			if (isset($_SERVER)) {
982
-				$SERVER_NAME = $_SERVER['SERVER_NAME'];
983
-				$SCRIPT_NAME = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
984
-				$HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off');
985
-			} elseif (isset($HTTP_SERVER_VARS)) {
986
-				$SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME'];
987
-				$SCRIPT_NAME = isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME'];
988
-				$HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off';
989
-			} else {
990
-				$this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
991
-			}
992
-        	if ($HTTPS == '1' || $HTTPS == 'on') {
993
-        		$SCHEME = 'https';
994
-        	} else {
995
-        		$SCHEME = 'http';
996
-        	}
997
-			$soapaction = "$SCHEME://$SERVER_NAME$SCRIPT_NAME/$name";
998
-		}
999
-		if(false == $style) {
1000
-			$style = "rpc";
1001
-		}
1002
-		if(false == $use) {
1003
-			$use = "encoded";
1004
-		}
1005
-		if ($use == 'encoded' && $encodingStyle == '') {
1006
-			$encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
1007
-		}
966
+        if($this->externalWSDLURL){
967
+            die('You cannot bind to an external WSDL file, and register methods outside of it! Please choose either WSDL or no WSDL.');
968
+        }
969
+        if (! $name) {
970
+            die('You must specify a name when you register an operation');
971
+        }
972
+        if (!is_array($in)) {
973
+            die('You must provide an array for operation inputs');
974
+        }
975
+        if (!is_array($out)) {
976
+            die('You must provide an array for operation outputs');
977
+        }
978
+        if(false == $namespace) {
979
+        }
980
+        if(false == $soapaction) {
981
+            if (isset($_SERVER)) {
982
+                $SERVER_NAME = $_SERVER['SERVER_NAME'];
983
+                $SCRIPT_NAME = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
984
+                $HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off');
985
+            } elseif (isset($HTTP_SERVER_VARS)) {
986
+                $SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME'];
987
+                $SCRIPT_NAME = isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME'];
988
+                $HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off';
989
+            } else {
990
+                $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
991
+            }
992
+            if ($HTTPS == '1' || $HTTPS == 'on') {
993
+                $SCHEME = 'https';
994
+            } else {
995
+                $SCHEME = 'http';
996
+            }
997
+            $soapaction = "$SCHEME://$SERVER_NAME$SCRIPT_NAME/$name";
998
+        }
999
+        if(false == $style) {
1000
+            $style = "rpc";
1001
+        }
1002
+        if(false == $use) {
1003
+            $use = "encoded";
1004
+        }
1005
+        if ($use == 'encoded' && $encodingStyle == '') {
1006
+            $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
1007
+        }
1008 1008
 
1009
-		$this->operations[$name] = array(
1010
-	    'name' => $name,
1011
-	    'in' => $in,
1012
-	    'out' => $out,
1013
-	    'namespace' => $namespace,
1014
-	    'soapaction' => $soapaction,
1015
-	    'style' => $style);
1009
+        $this->operations[$name] = array(
1010
+        'name' => $name,
1011
+        'in' => $in,
1012
+        'out' => $out,
1013
+        'namespace' => $namespace,
1014
+        'soapaction' => $soapaction,
1015
+        'style' => $style);
1016 1016
         if($this->wsdl){
1017
-        	$this->wsdl->addOperation($name,$in,$out,$namespace,$soapaction,$style,$use,$documentation,$encodingStyle);
1018
-	    }
1019
-		return true;
1020
-	}
1017
+            $this->wsdl->addOperation($name,$in,$out,$namespace,$soapaction,$style,$use,$documentation,$encodingStyle);
1018
+        }
1019
+        return true;
1020
+    }
1021 1021
 
1022
-	/**
1023
-	* Specify a fault to be returned to the client.
1024
-	* This also acts as a flag to the server that a fault has occured.
1025
-	*
1026
-	* @param	string $faultcode
1027
-	* @param	string $faultstring
1028
-	* @param	string $faultactor
1029
-	* @param	string $faultdetail
1030
-	* @access   public
1031
-	*/
1032
-	function fault($faultcode,$faultstring,$faultactor='',$faultdetail=''){
1033
-		if ($faultdetail == '' && $this->debug_flag) {
1034
-			$faultdetail = $this->getDebug();
1035
-		}
1036
-		$this->fault = new nusoap_fault($faultcode,$faultactor,$faultstring,$faultdetail);
1037
-		$this->fault->soap_defencoding = $this->soap_defencoding;
1038
-	}
1022
+    /**
1023
+     * Specify a fault to be returned to the client.
1024
+     * This also acts as a flag to the server that a fault has occured.
1025
+     *
1026
+     * @param	string $faultcode
1027
+     * @param	string $faultstring
1028
+     * @param	string $faultactor
1029
+     * @param	string $faultdetail
1030
+     * @access   public
1031
+     */
1032
+    function fault($faultcode,$faultstring,$faultactor='',$faultdetail=''){
1033
+        if ($faultdetail == '' && $this->debug_flag) {
1034
+            $faultdetail = $this->getDebug();
1035
+        }
1036
+        $this->fault = new nusoap_fault($faultcode,$faultactor,$faultstring,$faultdetail);
1037
+        $this->fault->soap_defencoding = $this->soap_defencoding;
1038
+    }
1039 1039
 
1040 1040
     /**
1041
-    * Sets up wsdl object.
1042
-    * Acts as a flag to enable internal WSDL generation
1043
-    *
1044
-    * @param string $serviceName, name of the service
1045
-    * @param mixed $namespace optional 'tns' service namespace or false
1046
-    * @param mixed $endpoint optional URL of service endpoint or false
1047
-    * @param string $style optional (rpc|document) WSDL style (also specified by operation)
1048
-    * @param string $transport optional SOAP transport
1049
-    * @param mixed $schemaTargetNamespace optional 'types' targetNamespace for service schema or false
1050
-    */
1041
+     * Sets up wsdl object.
1042
+     * Acts as a flag to enable internal WSDL generation
1043
+     *
1044
+     * @param string $serviceName, name of the service
1045
+     * @param mixed $namespace optional 'tns' service namespace or false
1046
+     * @param mixed $endpoint optional URL of service endpoint or false
1047
+     * @param string $style optional (rpc|document) WSDL style (also specified by operation)
1048
+     * @param string $transport optional SOAP transport
1049
+     * @param mixed $schemaTargetNamespace optional 'types' targetNamespace for service schema or false
1050
+     */
1051 1051
     function configureWSDL($serviceName,$namespace = false,$endpoint = false,$style='rpc', $transport = 'http://schemas.xmlsoap.org/soap/http', $schemaTargetNamespace = false)
1052 1052
     {
1053
-    	global $HTTP_SERVER_VARS;
1053
+        global $HTTP_SERVER_VARS;
1054 1054
 
1055
-		if (isset($_SERVER)) {
1056
-			$SERVER_NAME = $_SERVER['SERVER_NAME'];
1057
-			$SERVER_PORT = $_SERVER['SERVER_PORT'];
1058
-			$SCRIPT_NAME = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
1059
-			$HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off');
1060
-		} elseif (isset($HTTP_SERVER_VARS)) {
1061
-			$SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME'];
1062
-			$SERVER_PORT = $HTTP_SERVER_VARS['SERVER_PORT'];
1063
-			$SCRIPT_NAME = isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME'];
1064
-			$HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off';
1065
-		} else {
1066
-			$this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
1067
-		}
1068
-		// If server name has port number attached then strip it (else port number gets duplicated in WSDL output) (occurred using lighttpd and FastCGI)
1069
-		$colon = strpos($SERVER_NAME,":");
1070
-		if ($colon) {
1071
-		    $SERVER_NAME = substr($SERVER_NAME, 0, $colon);
1072
-		}
1073
-		if ($SERVER_PORT == 80) {
1074
-			$SERVER_PORT = '';
1075
-		} else {
1076
-			$SERVER_PORT = ':' . $SERVER_PORT;
1077
-		}
1055
+        if (isset($_SERVER)) {
1056
+            $SERVER_NAME = $_SERVER['SERVER_NAME'];
1057
+            $SERVER_PORT = $_SERVER['SERVER_PORT'];
1058
+            $SCRIPT_NAME = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
1059
+            $HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off');
1060
+        } elseif (isset($HTTP_SERVER_VARS)) {
1061
+            $SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME'];
1062
+            $SERVER_PORT = $HTTP_SERVER_VARS['SERVER_PORT'];
1063
+            $SCRIPT_NAME = isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME'];
1064
+            $HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off';
1065
+        } else {
1066
+            $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
1067
+        }
1068
+        // If server name has port number attached then strip it (else port number gets duplicated in WSDL output) (occurred using lighttpd and FastCGI)
1069
+        $colon = strpos($SERVER_NAME,":");
1070
+        if ($colon) {
1071
+            $SERVER_NAME = substr($SERVER_NAME, 0, $colon);
1072
+        }
1073
+        if ($SERVER_PORT == 80) {
1074
+            $SERVER_PORT = '';
1075
+        } else {
1076
+            $SERVER_PORT = ':' . $SERVER_PORT;
1077
+        }
1078 1078
         if(false == $namespace) {
1079 1079
             $namespace = "http://$SERVER_NAME/soap/$serviceName";
1080 1080
         }
1081 1081
 
1082 1082
         if(false == $endpoint) {
1083
-        	if ($HTTPS == '1' || $HTTPS == 'on') {
1084
-        		$SCHEME = 'https';
1085
-        	} else {
1086
-        		$SCHEME = 'http';
1087
-        	}
1083
+            if ($HTTPS == '1' || $HTTPS == 'on') {
1084
+                $SCHEME = 'https';
1085
+            } else {
1086
+                $SCHEME = 'http';
1087
+            }
1088 1088
             $endpoint = "$SCHEME://$SERVER_NAME$SERVER_PORT$SCRIPT_NAME";
1089 1089
         }
1090 1090
 
@@ -1094,28 +1094,28 @@  discard block
 block discarded – undo
1094 1094
 
1095 1095
         $this->wsdl = new wsdl();
1096 1096
         $this->wsdl->soap_defencoding = $this->soap_defencoding;
1097
-		$this->wsdl->serviceName = $serviceName;
1097
+        $this->wsdl->serviceName = $serviceName;
1098 1098
         $this->wsdl->endpoint = $endpoint;
1099
-		$this->wsdl->namespaces['tns'] = $namespace;
1100
-		$this->wsdl->namespaces['soap'] = 'http://schemas.xmlsoap.org/wsdl/soap/';
1101
-		$this->wsdl->namespaces['wsdl'] = 'http://schemas.xmlsoap.org/wsdl/';
1102
-		if ($schemaTargetNamespace != $namespace) {
1103
-			$this->wsdl->namespaces['types'] = $schemaTargetNamespace;
1104
-		}
1099
+        $this->wsdl->namespaces['tns'] = $namespace;
1100
+        $this->wsdl->namespaces['soap'] = 'http://schemas.xmlsoap.org/wsdl/soap/';
1101
+        $this->wsdl->namespaces['wsdl'] = 'http://schemas.xmlsoap.org/wsdl/';
1102
+        if ($schemaTargetNamespace != $namespace) {
1103
+            $this->wsdl->namespaces['types'] = $schemaTargetNamespace;
1104
+        }
1105 1105
         $this->wsdl->schemas[$schemaTargetNamespace][0] = new nusoap_xmlschema('', '', $this->wsdl->namespaces);
1106 1106
         if ($style == 'document') {
1107
-	        $this->wsdl->schemas[$schemaTargetNamespace][0]->schemaInfo['elementFormDefault'] = 'qualified';
1107
+            $this->wsdl->schemas[$schemaTargetNamespace][0]->schemaInfo['elementFormDefault'] = 'qualified';
1108 1108
         }
1109 1109
         $this->wsdl->schemas[$schemaTargetNamespace][0]->schemaTargetNamespace = $schemaTargetNamespace;
1110 1110
         $this->wsdl->schemas[$schemaTargetNamespace][0]->imports['http://schemas.xmlsoap.org/soap/encoding/'][0] = array('location' => '', 'loaded' => true);
1111 1111
         $this->wsdl->schemas[$schemaTargetNamespace][0]->imports['http://schemas.xmlsoap.org/wsdl/'][0] = array('location' => '', 'loaded' => true);
1112 1112
         $this->wsdl->bindings[$serviceName.'Binding'] = array(
1113
-        	'name'=>$serviceName.'Binding',
1113
+            'name'=>$serviceName.'Binding',
1114 1114
             'style'=>$style,
1115 1115
             'transport'=>$transport,
1116 1116
             'portType'=>$serviceName.'PortType');
1117 1117
         $this->wsdl->ports[$serviceName.'Port'] = array(
1118
-        	'binding'=>$serviceName.'Binding',
1118
+            'binding'=>$serviceName.'Binding',
1119 1119
             'location'=>$endpoint,
1120 1120
             'bindingType'=>'http://schemas.xmlsoap.org/wsdl/soap/');
1121 1121
     }
Please login to merge, or discard this patch.