Passed
Push — 1.10.x ( 08890a...2189d7 )
by Yannick
116:38 queued 75:46
created
app/Migrations/AbstractMigrationChamilo.php 1 patch
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -124,7 +124,7 @@
 block discarded – undo
124 124
     }
125 125
 
126 126
     /**
127
-     * @param $variable
127
+     * @param string $variable
128 128
      * @return mixed
129 129
      */
130 130
     public function getConfigurationValue($variable)
Please login to merge, or discard this patch.
main/admin/group_list.php 2 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -204,7 +204,6 @@  discard block
 block discarded – undo
204 204
  * lock = the user can no longer use this account
205 205
  * @author Patrick Cool <[email protected]>, Ghent University
206 206
  * @param int $active the current state of the account
207
- * @param int $user_id The user id
208 207
  * @param string $url_params
209 208
  * @return string Some HTML-code with the lock/unlock button
210 209
  */
@@ -236,7 +235,7 @@  discard block
 block discarded – undo
236 235
  * @author Patrick Cool <[email protected]>, Ghent University
237 236
  * @param int $status, do we want to lock the user ($status=lock) or unlock it ($status=unlock)
238 237
  * @param int $user_id The user id
239
- * @return language variable
238
+ * @return string|null variable
240 239
  */
241 240
 function lock_unlock_user($status, $user_id) {
242 241
     $user_table = Database :: get_main_table(TABLE_MAIN_USER);
Please login to merge, or discard this patch.
Indentation   -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,6 @@
 block discarded – undo
16 16
  * @author Patrick Cool
17 17
  * @author René Haentjens, added CSV file import (October 2004)
18 18
  * @package chamilo.link
19
-
20 19
  */
21 20
 
22 21
 // Including libraries
Please login to merge, or discard this patch.
main/admin/settings.lib.php 1 patch
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -907,7 +907,7 @@  discard block
 block discarded – undo
907 907
  * display the edit and delete icons in the sortable table
908 908
  *
909 909
  * @param integer $id the id of the template
910
- * @return html code for the link to edit and delete the template
910
+ * @return string code for the link to edit and delete the template
911 911
  *
912 912
  * @author Patrick Cool <[email protected]>, Ghent University, Belgium
913 913
  * @version August 2008
@@ -923,7 +923,7 @@  discard block
 block discarded – undo
923 923
  * Display the image of the template in the sortable table
924 924
  *
925 925
  * @param string $image the image
926
- * @return html code for the image
926
+ * @return string code for the image
927 927
  *
928 928
  * @author Patrick Cool <[email protected]>, Ghent University, Belgium
929 929
  * @version August 2008
@@ -1120,7 +1120,7 @@  discard block
 block discarded – undo
1120 1120
 /**
1121 1121
  * Returns an array containing the list of options used to populate the gradebook_number_decimals variable
1122 1122
  * This function is called through a call_user_func() in the generate_settings_form function.
1123
- * @return array List of gradebook_number_decimals options
1123
+ * @return string[] List of gradebook_number_decimals options
1124 1124
  *
1125 1125
  * @author Guillaume Viguier <[email protected]>
1126 1126
  */
Please login to merge, or discard this patch.
main/admin/sub_language_add.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
  * @param   string  ISO code (fr_FR, ...)
29 29
  * @param   int     Whether the sublanguage is published (0=unpublished, 1=published)
30 30
  * @param   int     ID del idioma padre
31
- * @return  int     New sub language ID or false on error
31
+ * @return  false|string     New sub language ID or false on error
32 32
  */
33 33
 function add_sub_language ($original_name,$english_name,$isocode,$sublanguage_available,$parent_id) {
34 34
     $tbl_admin_languages    = Database :: get_main_table(TABLE_MAIN_LANGUAGE);
Please login to merge, or discard this patch.
Indentation   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -62,43 +62,43 @@  discard block
 block discarded – undo
62 62
  *       inside the add_sub_language function.
63 63
  */
64 64
 function check_if_language_exist ($original_name, $english_name, $isocode, $sublanguage_available) {
65
-	$tbl_admin_languages 	= Database :: get_main_table(TABLE_MAIN_LANGUAGE);
66
-	$sql_original_name='SELECT count(*) AS count_original_name FROM '.$tbl_admin_languages.' WHERE original_name="'.Database::escape_string($original_name).'" ';
67
-	$sql_english_name='SELECT count(*) AS count_english_name FROM '.$tbl_admin_languages.' WHERE english_name="'.Database::escape_string($english_name).'" ';
68
-	//$sql_isocode='SELECT count(*) AS count_isocode FROM '.$tbl_admin_languages.' WHERE isocode="'.Database::escape_string($isocode).'" ';
69
-	$rs_original_name=Database::query($sql_original_name);
70
-	$rs_english_name=Database::query($sql_english_name);
71
-	//$rs_isocode=Database::query($sql_isocode);
72
-	$count_original_name=Database::result($rs_original_name,0,'count_original_name');
73
-	$count_english_name=Database::result($rs_english_name,0,'count_english_name');
74
-	//$count_isocode=Database::result($rs_isocode,0,'count_isocode');
75
-	$has_error=false;
76
-	$message_information=array();
65
+    $tbl_admin_languages 	= Database :: get_main_table(TABLE_MAIN_LANGUAGE);
66
+    $sql_original_name='SELECT count(*) AS count_original_name FROM '.$tbl_admin_languages.' WHERE original_name="'.Database::escape_string($original_name).'" ';
67
+    $sql_english_name='SELECT count(*) AS count_english_name FROM '.$tbl_admin_languages.' WHERE english_name="'.Database::escape_string($english_name).'" ';
68
+    //$sql_isocode='SELECT count(*) AS count_isocode FROM '.$tbl_admin_languages.' WHERE isocode="'.Database::escape_string($isocode).'" ';
69
+    $rs_original_name=Database::query($sql_original_name);
70
+    $rs_english_name=Database::query($sql_english_name);
71
+    //$rs_isocode=Database::query($sql_isocode);
72
+    $count_original_name=Database::result($rs_original_name,0,'count_original_name');
73
+    $count_english_name=Database::result($rs_english_name,0,'count_english_name');
74
+    //$count_isocode=Database::result($rs_isocode,0,'count_isocode');
75
+    $has_error=false;
76
+    $message_information=array();
77 77
 
78
-	if ($count_original_name==1) {
79
-		$has_error=true;
80
-		$message_information['original_name']=true;
81
-	}
82
-	if ($count_english_name==1) {
83
-		$has_error=true;
84
-		$message_information['english_name']=true;
85
-	}
78
+    if ($count_original_name==1) {
79
+        $has_error=true;
80
+        $message_information['original_name']=true;
81
+    }
82
+    if ($count_english_name==1) {
83
+        $has_error=true;
84
+        $message_information['english_name']=true;
85
+    }
86 86
 
87
-	$iso_list = api_get_platform_isocodes();
88
-	$iso_list = array_values($iso_list);
87
+    $iso_list = api_get_platform_isocodes();
88
+    $iso_list = array_values($iso_list);
89 89
 
90
-	if (!in_array($isocode, $iso_list)) {
91
-		$has_error=true;
92
-		$message_information['isocode']=true;
93
-	}
94
-	if ($has_error===true) {
95
-		$message_information['execute_add']=false;
96
-	}
97
-	if ($has_error===false) {
98
-		$message_information['execute_add']=true;
99
-	}
90
+    if (!in_array($isocode, $iso_list)) {
91
+        $has_error=true;
92
+        $message_information['isocode']=true;
93
+    }
94
+    if ($has_error===true) {
95
+        $message_information['execute_add']=false;
96
+    }
97
+    if ($has_error===false) {
98
+        $message_information['execute_add']=true;
99
+    }
100 100
 
101
-	return $message_information;
101
+    return $message_information;
102 102
 }
103 103
 
104 104
 /**
@@ -109,50 +109,50 @@  discard block
 block discarded – undo
109 109
  * @todo    deprecate this function and use the static method directly
110 110
  */
111 111
 function check_if_exist_language_by_id ($language_id) {
112
-	return SubLanguageManager::check_if_exist_language_by_id($language_id);
112
+    return SubLanguageManager::check_if_exist_language_by_id($language_id);
113 113
 }
114 114
 /**
115
- * Check if the given language is a parent of any sub-language
116
- * @param   int     Language ID of the presumed parent
117
- * @return  bool    True if this language has children, false otherwise
118
- */
115
+     * Check if the given language is a parent of any sub-language
116
+     * @param   int     Language ID of the presumed parent
117
+     * @return  bool    True if this language has children, false otherwise
118
+     */
119 119
 function ckeck_if_is_parent_of_sub_language ($parent_id) {
120
-	$sql='SELECT count(*) AS count FROM language WHERE parent_id= '.intval($parent_id).'';
121
-	$rs=Database::query($sql);
122
-	if (Database::num_rows($rs)>0 && Database::result($rs,0,'count')==1) {
123
-		return true;
124
-	} else {
125
-		return false;
126
-	}
120
+    $sql='SELECT count(*) AS count FROM language WHERE parent_id= '.intval($parent_id).'';
121
+    $rs=Database::query($sql);
122
+    if (Database::num_rows($rs)>0 && Database::result($rs,0,'count')==1) {
123
+        return true;
124
+    } else {
125
+        return false;
126
+    }
127 127
 }
128 128
 /**
129
- * Get all information of sub-language
130
- * @param   int     Parent language ID
131
- * @param   int     Child language ID
132
- * @return  array
133
- */
129
+     * Get all information of sub-language
130
+     * @param   int     Parent language ID
131
+     * @param   int     Child language ID
132
+     * @return  array
133
+     */
134 134
 function allow_get_all_information_of_sub_language ($parent_id,$sub_language_id) {
135
-	return SubLanguageManager::get_all_information_of_sub_language($parent_id,$sub_language_id);
135
+    return SubLanguageManager::get_all_information_of_sub_language($parent_id,$sub_language_id);
136 136
 }
137 137
 /*end declare functions*/
138 138
 
139 139
 //add data
140 140
 
141 141
 if (isset($_GET['sub_language_id']) && $_GET['sub_language_id']==strval(intval($_GET['sub_language_id']))) {
142
-	$language_name=SubLanguageManager::get_name_of_language_by_id($_GET['sub_language_id']);
143
-		if (check_if_exist_language_by_id ($_GET['sub_language_id'])===true) {
144
-			$sub_language_id=$_GET['sub_language_id'];
145
-			$sub_language_id_exist=true;
146
-		} else {
147
-			$sub_language_id_exist=false;
148
-		}
142
+    $language_name=SubLanguageManager::get_name_of_language_by_id($_GET['sub_language_id']);
143
+        if (check_if_exist_language_by_id ($_GET['sub_language_id'])===true) {
144
+            $sub_language_id=$_GET['sub_language_id'];
145
+            $sub_language_id_exist=true;
146
+        } else {
147
+            $sub_language_id_exist=false;
148
+        }
149 149
 
150 150
 }
151 151
 $language_details = array();
152 152
 $language_name='';
153 153
 if (isset($_GET['id']) && $_GET['id']==strval(intval($_GET['id']))) {
154 154
         $language_details = SubLanguageManager::get_all_information_of_language($_GET['id']);
155
-	$language_name = $language_details['original_name'];
155
+    $language_name = $language_details['original_name'];
156 156
         if (check_if_exist_language_by_id ($_GET['id'])===true) {
157 157
             $parent_id=$_GET['id'];
158 158
             $language_id_exist=true;
@@ -160,67 +160,67 @@  discard block
 block discarded – undo
160 160
             $language_id_exist=false;
161 161
         }
162 162
 } else {
163
-	$language_id_exist=false;
163
+    $language_id_exist=false;
164 164
 }
165 165
 
166 166
 //removed and register
167 167
 
168 168
 if ((isset($_GET['id']) && $_GET['id']==strval(intval($_GET['id']))) && (isset($_GET['sub_language_id']) && $_GET['sub_language_id']==strval(intval($_GET['sub_language_id'])))) {
169
-	if (check_if_exist_language_by_id($_GET['id'])===true && check_if_exist_language_by_id($_GET['sub_language_id'])===true) {
170
-	 	$get_all_information=allow_get_all_information_of_sub_language ($_GET['id'],$_GET['sub_language_id']);
171
-		$original_name=$get_all_information['original_name'];
172
-		$english_name=$get_all_information['english_name'];
173
-		$isocode=$get_all_information['isocode'];
169
+    if (check_if_exist_language_by_id($_GET['id'])===true && check_if_exist_language_by_id($_GET['sub_language_id'])===true) {
170
+            $get_all_information=allow_get_all_information_of_sub_language ($_GET['id'],$_GET['sub_language_id']);
171
+        $original_name=$get_all_information['original_name'];
172
+        $english_name=$get_all_information['english_name'];
173
+        $isocode=$get_all_information['isocode'];
174 174
 
175
-	}
175
+    }
176 176
 }
177 177
 
178 178
 $language_name=get_lang('CreateSubLanguageForLanguage').' ( '.strtolower($language_name).' )';
179 179
 
180 180
 if (ckeck_if_is_parent_of_sub_language($parent_id)===true && isset($_GET['action']) && $_GET['action']=='deletesublanguage') {
181
-	$language_name=get_lang('DeleteSubLanguage');
181
+    $language_name=get_lang('DeleteSubLanguage');
182 182
 }
183 183
 
184 184
 $msg = '';
185 185
 
186 186
 if (isset($_POST['SubmitAddNewLanguage'])) {
187
-	$original_name=$_POST['original_name'];
188
-	$english_name=$_POST['english_name'];
189
-	$isocode=$_POST['isocode'];
190
-	$english_name=str_replace(' ','_',$english_name);
191
-	$isocode=str_replace(' ','_',$isocode);
187
+    $original_name=$_POST['original_name'];
188
+    $english_name=$_POST['english_name'];
189
+    $isocode=$_POST['isocode'];
190
+    $english_name=str_replace(' ','_',$english_name);
191
+    $isocode=str_replace(' ','_',$isocode);
192 192
 
193
-	$sublanguage_available=$_POST['sub_language_is_visible'];
194
-	$check_information=array();
195
-	$check_information=check_if_language_exist($original_name,$english_name,$isocode,$sublanguage_available);
196
-	foreach ($check_information as $index_information => $value_information) {
197
-		$allow_insert_info=false;
198
-		if ($index_information=='original_name') {
199
-			$msg .= Display::return_message(get_lang('AlreadyExists').' "'.get_lang('OriginalName').'" '.'('.$original_name.')','error');
200
-		}
201
-		if ($index_information=='english_name') {
202
-			$msg .= Display::return_message(get_lang('AlreadyExists').' "'.get_lang('EnglishName').'" '.'('.$english_name.')','error');
203
-		}
204
-		if ($index_information=='isocode') {
205
-			$msg .= Display::return_message(get_lang('CodeDoesNotExists').': '.$isocode.'','error');
206
-		}
207
-		if ($index_information=='execute_add' && $value_information===true) {
208
-			$allow_insert_info=true;
209
-		}
210
-	}
193
+    $sublanguage_available=$_POST['sub_language_is_visible'];
194
+    $check_information=array();
195
+    $check_information=check_if_language_exist($original_name,$english_name,$isocode,$sublanguage_available);
196
+    foreach ($check_information as $index_information => $value_information) {
197
+        $allow_insert_info=false;
198
+        if ($index_information=='original_name') {
199
+            $msg .= Display::return_message(get_lang('AlreadyExists').' "'.get_lang('OriginalName').'" '.'('.$original_name.')','error');
200
+        }
201
+        if ($index_information=='english_name') {
202
+            $msg .= Display::return_message(get_lang('AlreadyExists').' "'.get_lang('EnglishName').'" '.'('.$english_name.')','error');
203
+        }
204
+        if ($index_information=='isocode') {
205
+            $msg .= Display::return_message(get_lang('CodeDoesNotExists').': '.$isocode.'','error');
206
+        }
207
+        if ($index_information=='execute_add' && $value_information===true) {
208
+            $allow_insert_info=true;
209
+        }
210
+    }
211 211
 
212
-	if (strlen($original_name)>0 && strlen($english_name)>0 && strlen($isocode)>0) {
213
-		if ($allow_insert_info===true && $language_id_exist===true) {
214
-			$english_name=str_replace(' ','_',$english_name);
212
+    if (strlen($original_name)>0 && strlen($english_name)>0 && strlen($isocode)>0) {
213
+        if ($allow_insert_info===true && $language_id_exist===true) {
214
+            $english_name=str_replace(' ','_',$english_name);
215 215
                         //Fixes BT#1636
216 216
                         $english_name=api_strtolower($english_name);
217 217
 
218
-			$isocode=str_replace(' ','_',$isocode);
219
-			$str_info='<br/>'.get_lang('OriginalName').' : '.$original_name.'<br/>'.get_lang('EnglishName').' : '.$english_name.'<br/>'.get_lang('PlatformCharsetTitle').' : '.$isocode;
218
+            $isocode=str_replace(' ','_',$isocode);
219
+            $str_info='<br/>'.get_lang('OriginalName').' : '.$original_name.'<br/>'.get_lang('EnglishName').' : '.$english_name.'<br/>'.get_lang('PlatformCharsetTitle').' : '.$isocode;
220 220
 
221
-			$mkdir_result=SubLanguageManager::add_language_directory($english_name);
222
-			if ($mkdir_result) {
223
-			  	$sl_id = add_sub_language($original_name,$english_name,$isocode,$sublanguage_available,$parent_id);
221
+            $mkdir_result=SubLanguageManager::add_language_directory($english_name);
222
+            if ($mkdir_result) {
223
+                    $sl_id = add_sub_language($original_name,$english_name,$isocode,$sublanguage_available,$parent_id);
224 224
                                 if ($sl_id === false) {
225 225
                                     SubLanguageManager::remove_language_directory($english_name);
226 226
                                     $msg .= Display::return_message(get_lang('LanguageDirectoryNotWriteableContactAdmin'),'error');
@@ -232,17 +232,17 @@  discard block
 block discarded – undo
232 232
                                     require 'sub_language.php';
233 233
                                     exit();
234 234
                                 }
235
-			} else {
236
-			    $msg .= Display::return_message(get_lang('LanguageDirectoryNotWriteableContactAdmin'),'error');
237
-			}
238
-		} else {
239
-			if ($language_id_exist===false) {
240
-				$msg .= Display::return_message(get_lang('LanguageParentNotExist'),'error');
241
-			}
242
-		}
243
-	} else {
235
+            } else {
236
+                $msg .= Display::return_message(get_lang('LanguageDirectoryNotWriteableContactAdmin'),'error');
237
+            }
238
+        } else {
239
+            if ($language_id_exist===false) {
240
+                $msg .= Display::return_message(get_lang('LanguageParentNotExist'),'error');
241
+            }
242
+        }
243
+    } else {
244 244
             $msg .= Display::return_message(get_lang('FormHasErrorsPleaseComplete'),'error');
245
-	}
245
+    }
246 246
 }
247 247
 
248 248
 Display :: display_header($language_name);
@@ -250,51 +250,51 @@  discard block
 block discarded – undo
250 250
 echo $msg;
251 251
 
252 252
 if (isset($_POST['SubmitAddDeleteLanguage'])) {
253
-	$rs = SubLanguageManager::remove_sub_language($_GET['id'], $_GET['sub_language_id']);
254
-	if ($rs===true) {
255
-		Display::display_confirmation_message(get_lang('TheSubLanguageHasBeenRemoved'));
256
-	} else {
257
-		Display::display_error_message(get_lang('TheSubLanguageHasNotBeenRemoved'));
258
-	}
253
+    $rs = SubLanguageManager::remove_sub_language($_GET['id'], $_GET['sub_language_id']);
254
+    if ($rs===true) {
255
+        Display::display_confirmation_message(get_lang('TheSubLanguageHasBeenRemoved'));
256
+    } else {
257
+        Display::display_error_message(get_lang('TheSubLanguageHasNotBeenRemoved'));
258
+    }
259 259
 }
260 260
 // ckeck_if_is_parent_of_sub_language($parent_id)===false
261 261
 //
262 262
 if (isset($_GET['action']) && $_GET['action']=='definenewsublanguage') {
263
-	$text = $language_name;
264
-	$form = new FormValidator('addsublanguage', 'post', 'sub_language_add.php?id='.Security::remove_XSS($_GET['id']).'&action=definenewsublanguage');
265
-	$class='add';
266
-	$form->addElement('header', '', $text);
267
-	$form->addElement('text', 'original_name', get_lang('OriginalName'),'class="input_titles"');
268
-	$form->addRule('original_name', get_lang('ThisFieldIsRequired'), 'required');
269
-	$form->addElement('text', 'english_name', get_lang('EnglishName'),'class="input_titles"');
270
-	$form->addRule('english_name', get_lang('ThisFieldIsRequired'), 'required');
271
-	$form->addElement('text', 'isocode', get_lang('ISOCode'), 'class="input_titles"');
272
-	$form->addRule('isocode', get_lang('ThisFieldIsRequired'), 'required');
273
-	$form->addElement('static', null, '&nbsp;', '<i>en, es, fr</i>');
274
-	$form->addElement('checkbox', 'sub_language_is_visible', '', get_lang('Visibility'));
275
-	$form->addButtonCreate(get_lang('CreateSubLanguage'), 'SubmitAddNewLanguage');
263
+    $text = $language_name;
264
+    $form = new FormValidator('addsublanguage', 'post', 'sub_language_add.php?id='.Security::remove_XSS($_GET['id']).'&action=definenewsublanguage');
265
+    $class='add';
266
+    $form->addElement('header', '', $text);
267
+    $form->addElement('text', 'original_name', get_lang('OriginalName'),'class="input_titles"');
268
+    $form->addRule('original_name', get_lang('ThisFieldIsRequired'), 'required');
269
+    $form->addElement('text', 'english_name', get_lang('EnglishName'),'class="input_titles"');
270
+    $form->addRule('english_name', get_lang('ThisFieldIsRequired'), 'required');
271
+    $form->addElement('text', 'isocode', get_lang('ISOCode'), 'class="input_titles"');
272
+    $form->addRule('isocode', get_lang('ThisFieldIsRequired'), 'required');
273
+    $form->addElement('static', null, '&nbsp;', '<i>en, es, fr</i>');
274
+    $form->addElement('checkbox', 'sub_language_is_visible', '', get_lang('Visibility'));
275
+    $form->addButtonCreate(get_lang('CreateSubLanguage'), 'SubmitAddNewLanguage');
276 276
         //$values['original_name'] = $language_details['original_name'].'...'; -> cannot be used because of quickform filtering (freeze)
277 277
         $values['english_name'] = $language_details['english_name'].'2';
278 278
         $values['isocode'] = $language_details['isocode'];
279 279
         $form->setDefaults($values);
280
-	$form->display();
280
+    $form->display();
281 281
 } else {
282
-	if (isset($_GET['action']) && $_GET['action']=='deletesublanguage') {
283
-		$text=$language_name;
284
-		$form = new FormValidator('deletesublanguage', 'post', 'sub_language_add.php?id='.Security::remove_XSS($_GET['id']).'&sub_language_id='.Security::remove_XSS($_GET['sub_language_id']));
285
-		$class='minus';
286
-		$form->addElement('header', '', $text);
287
-		$form->addElement('static', '', get_lang('OriginalName'),$original_name);
288
-		$form->addElement('static', '', get_lang('EnglishName'),$english_name);
289
-		$form->addElement('static', '', get_lang('PlatformCharsetTitle'),$isocode);
290
-		$form->addButtonCreate(get_lang('DeleteSubLanguage'), 'SubmitAddDeleteLanguage');
291
-		$form->display();
292
-	}
293
-	if (isset($_GET['action']) && $_GET['action']=='definenewsublanguage') {
294
-		Display::display_normal_message(get_lang('TheSubLanguageForThisLanguageHasBeenAdded'));
295
-	}
282
+    if (isset($_GET['action']) && $_GET['action']=='deletesublanguage') {
283
+        $text=$language_name;
284
+        $form = new FormValidator('deletesublanguage', 'post', 'sub_language_add.php?id='.Security::remove_XSS($_GET['id']).'&sub_language_id='.Security::remove_XSS($_GET['sub_language_id']));
285
+        $class='minus';
286
+        $form->addElement('header', '', $text);
287
+        $form->addElement('static', '', get_lang('OriginalName'),$original_name);
288
+        $form->addElement('static', '', get_lang('EnglishName'),$english_name);
289
+        $form->addElement('static', '', get_lang('PlatformCharsetTitle'),$isocode);
290
+        $form->addButtonCreate(get_lang('DeleteSubLanguage'), 'SubmitAddDeleteLanguage');
291
+        $form->display();
292
+    }
293
+    if (isset($_GET['action']) && $_GET['action']=='definenewsublanguage') {
294
+        Display::display_normal_message(get_lang('TheSubLanguageForThisLanguageHasBeenAdded'));
295
+    }
296 296
 }
297 297
 /**
298
- * Footer
299
- */
298
+     * Footer
299
+     */
300 300
 Display :: display_footer();
Please login to merge, or discard this patch.
main/admin/user_list.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -286,7 +286,7 @@
 block discarded – undo
286 286
 *	This function defines globals.
287 287
 *   @param  int     $userId
288 288
  *
289
-*   @return bool    False on failure, redirection on success
289
+*   @return false|null    False on failure, redirection on success
290 290
 *	@author Evie Embrechts
291 291
 *   @author Yannick Warnier <[email protected]>
292 292
 */
Please login to merge, or discard this patch.
Indentation   +131 added lines, -131 removed lines patch added patch discarded remove patch
@@ -239,8 +239,8 @@  discard block
 block discarded – undo
239 239
         if (isset($keywordListValues['keyword_status']) &&
240 240
             $keywordListValues['keyword_status'] == PLATFORM_ADMIN
241 241
         ) {
242
-           $query_admin_table = " , $admin_table a ";
243
-           $keyword_admin = ' AND a.user_id = u.id ';
242
+            $query_admin_table = " , $admin_table a ";
243
+            $keyword_admin = ' AND a.user_id = u.id ';
244 244
             $keywordListValues['keyword_status'] = '%';
245 245
         }
246 246
 
@@ -306,13 +306,13 @@  discard block
 block discarded – undo
306 306
     $firstname = $userInfo['firstname'];
307 307
     $lastname = $userInfo['lastname'];
308 308
 
309
-	if (api_is_western_name_order()) {
310
-		$message = sprintf(get_lang('AttemptingToLoginAs'),$firstname,$lastname, $userId);
311
-	} else {
312
-		$message = sprintf(get_lang('AttemptingToLoginAs'), $lastname, $firstname, $userId);
313
-	}
309
+    if (api_is_western_name_order()) {
310
+        $message = sprintf(get_lang('AttemptingToLoginAs'),$firstname,$lastname, $userId);
311
+    } else {
312
+        $message = sprintf(get_lang('AttemptingToLoginAs'), $lastname, $firstname, $userId);
313
+    }
314 314
 
315
-	if ($userId) {
315
+    if ($userId) {
316 316
 
317 317
         // Logout the current user
318 318
         LoginDelete(api_get_user_id());
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
         Display :: display_footer();
348 348
         exit;
349 349
 
350
-	}
350
+    }
351 351
 }
352 352
 
353 353
 /**
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
     }*/
386 386
 
387 387
     if (!in_array($direction, array('ASC','DESC'))) {
388
-    	$direction = 'ASC';
388
+        $direction = 'ASC';
389 389
     }
390 390
     $column = intval($column);
391 391
     $from 	= intval($from);
@@ -396,23 +396,23 @@  discard block
 block discarded – undo
396 396
         $sql .= " WHERE u.creator_id = ".api_get_user_id();
397 397
     }
398 398
 
399
-	$sql .= " ORDER BY col$column $direction ";
400
-	$sql .= " LIMIT $from,$number_of_items";
399
+    $sql .= " ORDER BY col$column $direction ";
400
+    $sql .= " LIMIT $from,$number_of_items";
401 401
 
402
-	$res = Database::query($sql);
402
+    $res = Database::query($sql);
403 403
 
404
-	$users = array ();
404
+    $users = array ();
405 405
     $t = time();
406
-	while ($user = Database::fetch_row($res)) {
407
-		$userPicture = UserManager::getUserPicture($user[0], USER_IMAGE_SIZE_SMALL);
408
-		$photo = '<img src="'.$userPicture.'" width="22" height="22" alt="'.api_get_person_name($user[2], $user[3]).'" title="'.api_get_person_name($user[2], $user[3]).'" />';
406
+    while ($user = Database::fetch_row($res)) {
407
+        $userPicture = UserManager::getUserPicture($user[0], USER_IMAGE_SIZE_SMALL);
408
+        $photo = '<img src="'.$userPicture.'" width="22" height="22" alt="'.api_get_person_name($user[2], $user[3]).'" title="'.api_get_person_name($user[2], $user[3]).'" />';
409 409
 
410 410
         if ($user[7] == 1 && !empty($user[10])) {
411 411
             // check expiration date
412 412
             $expiration_time = convert_sql_date($user[10]);
413 413
             // if expiration date is passed, store a special value for active field
414 414
             if ($expiration_time < $t) {
415
-        	   $user[7] = '-1';
415
+                $user[7] = '-1';
416 416
             }
417 417
         }
418 418
 
@@ -430,9 +430,9 @@  discard block
 block discarded – undo
430 430
             api_get_local_time($user[9]),
431 431
             $user[0]
432 432
         );
433
-	}
433
+    }
434 434
 
435
-	return $users;
435
+    return $users;
436 436
 }
437 437
 
438 438
 /**
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
 * @return string HTML-code with a mailto-link
442 442
 */
443 443
 function email_filter($email) {
444
-	return Display :: encrypted_mailto_link($email, $email);
444
+    return Display :: encrypted_mailto_link($email, $email);
445 445
 }
446 446
 
447 447
 /**
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
 * @return string HTML-code with a mailto-link
451 451
 */
452 452
 function user_filter($name, $params, $row) {
453
-	return '<a href="'.api_get_path(WEB_PATH).'whoisonline.php?origin=user_list&id='.$row[0].'">'.$name.'</a>';
453
+    return '<a href="'.api_get_path(WEB_PATH).'whoisonline.php?origin=user_list&id='.$row[0].'">'.$name.'</a>';
454 454
 }
455 455
 
456 456
 /**
@@ -461,84 +461,84 @@  discard block
 block discarded – undo
461 461
  * @return string Some HTML-code with modify-buttons
462 462
  */
463 463
 function modify_filter($user_id, $url_params, $row) {
464
-	global $charset, $_admins_list;
465
-	$is_admin   = in_array($user_id,$_admins_list);
466
-	$statusname = api_get_status_langvars();
467
-	$user_is_anonymous = false;
464
+    global $charset, $_admins_list;
465
+    $is_admin   = in_array($user_id,$_admins_list);
466
+    $statusname = api_get_status_langvars();
467
+    $user_is_anonymous = false;
468 468
     $current_user_status_label = $row['7'];
469 469
 
470
-	if ($current_user_status_label == $statusname[ANONYMOUS]) {
471
-		$user_is_anonymous =true;
472
-	}
473
-	$result = '';
474
-	if (!$user_is_anonymous) {
475
-		$icon = Display::return_icon('course.png', get_lang('Courses'), array('onmouseout' => 'clear_course_list (\'div_'.$user_id.'\')'));
476
-		$result .= '<a href="javascript:void(0)" onclick="load_course_list(\'div_'.$user_id.'\','.$user_id.')" >
470
+    if ($current_user_status_label == $statusname[ANONYMOUS]) {
471
+        $user_is_anonymous =true;
472
+    }
473
+    $result = '';
474
+    if (!$user_is_anonymous) {
475
+        $icon = Display::return_icon('course.png', get_lang('Courses'), array('onmouseout' => 'clear_course_list (\'div_'.$user_id.'\')'));
476
+        $result .= '<a href="javascript:void(0)" onclick="load_course_list(\'div_'.$user_id.'\','.$user_id.')" >
477 477
 			        '.$icon.'
478 478
 					<div class="blackboard_hide" id="div_'.$user_id.'">&nbsp;&nbsp;</div>
479 479
 					</a>';
480 480
 
481 481
         $icon = Display::return_icon('session.png', get_lang('Sessions'), array('onmouseout' => 'clear_session_list (\'div_s_'.$user_id.'\')'));
482
-		$result .= '<a href="javascript:void(0)" onclick="load_session_list(\'div_s_'.$user_id.'\','.$user_id.')" >
482
+        $result .= '<a href="javascript:void(0)" onclick="load_session_list(\'div_s_'.$user_id.'\','.$user_id.')" >
483 483
 					'.$icon.'
484 484
 					<div class="blackboard_hide" id="div_s_'.$user_id.'">&nbsp;&nbsp;</div>
485 485
 					</a>';
486
-	} else {
487
-		$result .= Display::return_icon('course_na.png',get_lang('Courses')).'&nbsp;&nbsp;';
488
-		$result .= Display::return_icon('course_na.png',get_lang('Sessions')).'&nbsp;&nbsp;';
489
-	}
486
+    } else {
487
+        $result .= Display::return_icon('course_na.png',get_lang('Courses')).'&nbsp;&nbsp;';
488
+        $result .= Display::return_icon('course_na.png',get_lang('Sessions')).'&nbsp;&nbsp;';
489
+    }
490 490
 
491
-	if (api_is_platform_admin()) {
492
-		if (!$user_is_anonymous) {
493
-			$result .= '<a href="user_information.php?user_id='.$user_id.'">'.Display::return_icon('synthese_view.gif', get_lang('Info')).'</a>&nbsp;&nbsp;';
494
-		} else {
495
-			$result .= Display::return_icon('synthese_view_na.gif', get_lang('Info')).'&nbsp;&nbsp;';
496
-		}
497
-	}
491
+    if (api_is_platform_admin()) {
492
+        if (!$user_is_anonymous) {
493
+            $result .= '<a href="user_information.php?user_id='.$user_id.'">'.Display::return_icon('synthese_view.gif', get_lang('Info')).'</a>&nbsp;&nbsp;';
494
+        } else {
495
+            $result .= Display::return_icon('synthese_view_na.gif', get_lang('Info')).'&nbsp;&nbsp;';
496
+        }
497
+    }
498 498
 
499 499
     //only allow platform admins to login_as, or session admins only for students (not teachers nor other admins)
500 500
     if (api_is_platform_admin() || (api_is_session_admin() && $current_user_status_label == $statusname[STUDENT])) {
501
-    	if (!$user_is_anonymous) {
501
+        if (!$user_is_anonymous) {
502 502
             if (api_global_admin_can_edit_admin($user_id)) {
503 503
                 $result .= '<a href="user_list.php?action=login_as&user_id='.$user_id.'&sec_token='.$_SESSION['sec_token'].'">'.Display::return_icon('login_as.png', get_lang('LoginAs')).'</a>&nbsp;&nbsp;';
504 504
             } else {
505 505
                 $result .= Display::return_icon('login_as_na.png', get_lang('LoginAs')).'&nbsp;&nbsp;';
506 506
             }
507
-    	} else {
508
-    		$result .= Display::return_icon('login_as_na.png', get_lang('LoginAs')).'&nbsp;&nbsp;';
509
-    	}
507
+        } else {
508
+            $result .= Display::return_icon('login_as_na.png', get_lang('LoginAs')).'&nbsp;&nbsp;';
509
+        }
510 510
     } else {
511
-    	$result .= Display::return_icon('login_as_na.png', get_lang('LoginAs')).'&nbsp;&nbsp;';
511
+        $result .= Display::return_icon('login_as_na.png', get_lang('LoginAs')).'&nbsp;&nbsp;';
512 512
     }
513 513
 
514
-	if ($current_user_status_label != $statusname[STUDENT]) {
515
-		$result .= Display::return_icon('statistics_na.gif', get_lang('Reporting')).'&nbsp;&nbsp;';
516
-	} else {
517
-		$result .= '<a href="../mySpace/myStudents.php?student='.$user_id.'">'.Display::return_icon('statistics.gif', get_lang('Reporting')).'</a>&nbsp;&nbsp;';
518
-	}
514
+    if ($current_user_status_label != $statusname[STUDENT]) {
515
+        $result .= Display::return_icon('statistics_na.gif', get_lang('Reporting')).'&nbsp;&nbsp;';
516
+    } else {
517
+        $result .= '<a href="../mySpace/myStudents.php?student='.$user_id.'">'.Display::return_icon('statistics.gif', get_lang('Reporting')).'</a>&nbsp;&nbsp;';
518
+    }
519 519
 
520
-	if (api_is_platform_admin(true)) {
520
+    if (api_is_platform_admin(true)) {
521 521
         $editProfileUrl = Display::getProfileEditionLink($user_id, true);
522 522
 
523 523
         if (!$user_is_anonymous && api_global_admin_can_edit_admin($user_id, null, true)) {
524 524
             $result .= '<a href="' . $editProfileUrl . '">'.Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>&nbsp;';
525
-		} else {
525
+        } else {
526 526
             $result .= Display::return_icon('edit_na.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>&nbsp;';
527
-		}
528
-	}
527
+        }
528
+    }
529 529
 
530
-	if ($is_admin) {
531
-		$result .= Display::return_icon('admin_star.png', get_lang('IsAdministrator'),array('width'=> ICON_SIZE_SMALL, 'heigth'=> ICON_SIZE_SMALL));
532
-	} else {
533
-		$result .= Display::return_icon('admin_star_na.png', get_lang('IsNotAdministrator'));
534
-	}
530
+    if ($is_admin) {
531
+        $result .= Display::return_icon('admin_star.png', get_lang('IsAdministrator'),array('width'=> ICON_SIZE_SMALL, 'heigth'=> ICON_SIZE_SMALL));
532
+    } else {
533
+        $result .= Display::return_icon('admin_star_na.png', get_lang('IsNotAdministrator'));
534
+    }
535 535
 
536
-	// actions for assigning sessions, courses or users
537
-	if (api_is_session_admin()) {
538
-		/*if ($row[0] == api_get_user_id()) {
536
+    // actions for assigning sessions, courses or users
537
+    if (api_is_session_admin()) {
538
+        /*if ($row[0] == api_get_user_id()) {
539 539
 			$result .= '<a href="dashboard_add_sessions_to_user.php?user='.$user_id.'">'.Display::return_icon('view_more_stats.gif', get_lang('AssignSessions')).'</a>&nbsp;&nbsp;';
540 540
 		}*/
541
-	} else {
541
+    } else {
542 542
         if ($current_user_status_label == $statusname[SESSIONADMIN]) {
543 543
             $result .= Display::url(
544 544
                 Display::return_icon('view_more_stats.gif', get_lang('AssignSessions')),
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
                 );
569 569
             }
570 570
         }
571
-	}
571
+    }
572 572
 
573 573
     if (api_is_platform_admin()) {
574 574
         $result .= ' <a href="'.api_get_path(WEB_AJAX_PATH).'agenda.ajax.php?a=get_user_agenda&user_id='.$user_id.'&modal_size=lg" class="agenda_opener ajax">'.
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
             }
587 587
         }
588 588
     }
589
-	return $result;
589
+    return $result;
590 590
 }
591 591
 
592 592
 
@@ -619,10 +619,10 @@  discard block
 block discarded – undo
619 619
     if ($action == 'edit') {
620 620
         $result = Display::return_icon($image.'.png', get_lang('AccountExpired'), array(), 16);
621 621
     } elseif ($row['0']<>$_user['user_id']) {
622
-    	// you cannot lock yourself out otherwise you could disable all the accounts including your own => everybody is locked out and nobody can change it anymore.
623
-		$result = Display::return_icon($image.'.png', get_lang(ucfirst($action)), array('onclick'=>'active_user(this);', 'id'=>'img_'.$row['0']), 16).'</a>';
624
-	}
625
-	return $result;
622
+        // you cannot lock yourself out otherwise you could disable all the accounts including your own => everybody is locked out and nobody can change it anymore.
623
+        $result = Display::return_icon($image.'.png', get_lang(ucfirst($action)), array('onclick'=>'active_user(this);', 'id'=>'img_'.$row['0']), 16).'</a>';
624
+    }
625
+    return $result;
626 626
 }
627 627
 
628 628
 /**
@@ -635,8 +635,8 @@  discard block
 block discarded – undo
635 635
  * @author Patrick Cool <[email protected]>, Ghent University, Belgium
636 636
  */
637 637
 function status_filter($status) {
638
-	$statusname = api_get_status_langvars();
639
-	return $statusname[$status];
638
+    $statusname = api_get_status_langvars();
639
+    return $statusname[$status];
640 640
 }
641 641
 
642 642
 if (isset($_GET['keyword']) || isset($_GET['keyword_firstname'])) {
@@ -652,8 +652,8 @@  discard block
 block discarded – undo
652 652
 
653 653
 if (!empty($action)) {
654 654
     $check = Security::check_token('get');
655
-	if ($check) {
656
-		switch ($action) {
655
+    if ($check) {
656
+        switch ($action) {
657 657
             case 'add_user_to_my_url':
658 658
                 $user_id = $_REQUEST["user_id"];
659 659
                 $result = UrlManager::add_user_to_url($user_id, $current_access_url_id);
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
                     $message  = Display::return_message($message, 'confirmation');
664 664
                 }
665 665
                 break;
666
-			case 'show_message' :
666
+            case 'show_message' :
667 667
                 if (!empty($_GET['warn'])) {
668 668
                     // to prevent too long messages
669 669
                     if ($_GET['warn'] == 'session_message') {
@@ -681,46 +681,46 @@  discard block
 block discarded – undo
681 681
                     $message .= Display::return_message(stripslashes($_GET['message']), 'confirmation');
682 682
                 }
683 683
 
684
-				break;
685
-			case 'delete_user' :
686
-				if (api_is_platform_admin()) {
684
+                break;
685
+            case 'delete_user' :
686
+                if (api_is_platform_admin()) {
687 687
                     $user_to_delete = $_GET['user_id'];
688 688
                     $current_user_id = api_get_user_id();
689 689
 
690
-					if ($deleteUserAvailable && api_global_admin_can_edit_admin($_GET['user_id'])) {
691
-						if ($user_to_delete != $current_user_id && UserManager :: delete_user($_GET['user_id'])) {
692
-							$message = Display :: return_message(get_lang('UserDeleted'), 'confirmation');
693
-						} else {
694
-							$message = Display :: return_message(get_lang('CannotDeleteUserBecauseOwnsCourse'), 'error');
695
-						}
696
-					} else {
697
-						$message = Display :: return_message(get_lang('CannotDeleteUser'),'error');
698
-					}
699
-				}
700
-				break;
690
+                    if ($deleteUserAvailable && api_global_admin_can_edit_admin($_GET['user_id'])) {
691
+                        if ($user_to_delete != $current_user_id && UserManager :: delete_user($_GET['user_id'])) {
692
+                            $message = Display :: return_message(get_lang('UserDeleted'), 'confirmation');
693
+                        } else {
694
+                            $message = Display :: return_message(get_lang('CannotDeleteUserBecauseOwnsCourse'), 'error');
695
+                        }
696
+                    } else {
697
+                        $message = Display :: return_message(get_lang('CannotDeleteUser'),'error');
698
+                    }
699
+                }
700
+                break;
701 701
             case 'delete' :
702
-				if (api_is_platform_admin()) {
703
-					$number_of_selected_users = count($_POST['id']);
704
-					$number_of_deleted_users = 0;
705
-					if (is_array($_POST['id'])) {
706
-						foreach ($_POST['id'] as $index => $user_id) {
707
-							if($user_id != $_user['user_id']) {
708
-								if(UserManager :: delete_user($user_id)) {
709
-									$number_of_deleted_users++;
710
-								}
711
-							}
712
-						}
713
-					}
714
-					if ($number_of_selected_users == $number_of_deleted_users) {
702
+                if (api_is_platform_admin()) {
703
+                    $number_of_selected_users = count($_POST['id']);
704
+                    $number_of_deleted_users = 0;
705
+                    if (is_array($_POST['id'])) {
706
+                        foreach ($_POST['id'] as $index => $user_id) {
707
+                            if($user_id != $_user['user_id']) {
708
+                                if(UserManager :: delete_user($user_id)) {
709
+                                    $number_of_deleted_users++;
710
+                                }
711
+                            }
712
+                        }
713
+                    }
714
+                    if ($number_of_selected_users == $number_of_deleted_users) {
715 715
                         $message = Display :: return_message(get_lang('SelectedUsersDeleted'), 'confirmation');
716
-					} else {
716
+                    } else {
717 717
                         $message = Display :: return_message(get_lang('SomeUsersNotDeleted'), 'error');
718
-					}
719
-				}
720
-				break;
721
-		}
722
-		Security::clear_token();
723
-	}
718
+                    }
719
+                }
720
+                break;
721
+        }
722
+        Security::clear_token();
723
+    }
724 724
 }
725 725
 
726 726
 // Create a search-box
@@ -740,24 +740,24 @@  discard block
 block discarded – undo
740 740
 
741 741
 $actions  = '';
742 742
 if (api_is_platform_admin()) {
743
-	$actions .= '<div style="float:right;">'.
744
-		 '<a href="'.api_get_path(WEB_CODE_PATH).'admin/user_add.php">'.
745
-         Display::return_icon('new_user.png',get_lang('AddUsers'),'',ICON_SIZE_MEDIUM).'</a>'.
746
-		 '</div>';
743
+    $actions .= '<div style="float:right;">'.
744
+            '<a href="'.api_get_path(WEB_CODE_PATH).'admin/user_add.php">'.
745
+            Display::return_icon('new_user.png',get_lang('AddUsers'),'',ICON_SIZE_MEDIUM).'</a>'.
746
+            '</div>';
747 747
 }
748 748
 $actions .= $form->return_form();
749 749
 
750 750
 if (isset ($_GET['keyword'])) {
751
-	$parameters = array ('keyword' => Security::remove_XSS($_GET['keyword']));
751
+    $parameters = array ('keyword' => Security::remove_XSS($_GET['keyword']));
752 752
 } elseif (isset ($_GET['keyword_firstname'])) {
753
-	$parameters['keyword_firstname'] 	= Security::remove_XSS($_GET['keyword_firstname']);
754
-	$parameters['keyword_lastname']	 	= Security::remove_XSS($_GET['keyword_lastname']);
755
-	$parameters['keyword_username']	 	= Security::remove_XSS($_GET['keyword_username']);
756
-	$parameters['keyword_email'] 	 	= Security::remove_XSS($_GET['keyword_email']);
757
-	$parameters['keyword_officialcode'] = Security::remove_XSS($_GET['keyword_officialcode']);
758
-	$parameters['keyword_status'] 		= Security::remove_XSS($_GET['keyword_status']);
759
-	$parameters['keyword_active'] 		= Security::remove_XSS($_GET['keyword_active']);
760
-	$parameters['keyword_inactive'] 	= Security::remove_XSS($_GET['keyword_inactive']);
753
+    $parameters['keyword_firstname'] 	= Security::remove_XSS($_GET['keyword_firstname']);
754
+    $parameters['keyword_lastname']	 	= Security::remove_XSS($_GET['keyword_lastname']);
755
+    $parameters['keyword_username']	 	= Security::remove_XSS($_GET['keyword_username']);
756
+    $parameters['keyword_email'] 	 	= Security::remove_XSS($_GET['keyword_email']);
757
+    $parameters['keyword_officialcode'] = Security::remove_XSS($_GET['keyword_officialcode']);
758
+    $parameters['keyword_status'] 		= Security::remove_XSS($_GET['keyword_status']);
759
+    $parameters['keyword_active'] 		= Security::remove_XSS($_GET['keyword_active']);
760
+    $parameters['keyword_inactive'] 	= Security::remove_XSS($_GET['keyword_inactive']);
761 761
 }
762 762
 // Create a sortable table with user-data
763 763
 $parameters['sec_token'] = Security::get_token();
@@ -768,7 +768,7 @@  discard block
 block discarded – undo
768 768
 $res_admin = Database::query($sql_admin);
769 769
 $_admins_list = array();
770 770
 while ($row_admin = Database::fetch_row($res_admin)) {
771
-	$_admins_list[] = $row_admin[0];
771
+    $_admins_list[] = $row_admin[0];
772 772
 }
773 773
 
774 774
 // Display Advanced search form.
@@ -824,11 +824,11 @@  discard block
 block discarded – undo
824 824
 $table->set_header(2, get_lang('OfficialCode'));
825 825
 
826 826
 if (api_is_western_name_order()) {
827
-	$table->set_header(3, get_lang('FirstName'));
828
-	$table->set_header(4, get_lang('LastName'));
827
+    $table->set_header(3, get_lang('FirstName'));
828
+    $table->set_header(4, get_lang('LastName'));
829 829
 } else {
830
-	$table->set_header(3, get_lang('LastName'));
831
-	$table->set_header(4, get_lang('FirstName'));
830
+    $table->set_header(3, get_lang('LastName'));
831
+    $table->set_header(4, get_lang('FirstName'));
832 832
 }
833 833
 $table->set_header(5, get_lang('LoginName'));
834 834
 $table->set_header(6, get_lang('Email'));
Please login to merge, or discard this patch.
main/admin/user_update_import.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -128,7 +128,7 @@
 block discarded – undo
128 128
 /**
129 129
  * Update users from the imported data
130 130
  * @param   array   $users List of users
131
- * @return  void
131
+ * @return  false|null
132 132
  * @uses global variable $inserted_in_course, which returns the list of courses the user was inserted in
133 133
  */
134 134
 
Please login to merge, or discard this patch.
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /* For licensing terms, see /license.txt */
3 3
 /**
4
- * This tool allows platform admins to add users by uploading a CSV or XML file
5
- * @package chamilo.admin
6
- */
4
+     * This tool allows platform admins to add users by uploading a CSV or XML file
5
+     * @package chamilo.admin
6
+     */
7 7
 
8 8
 /**
9 9
  * Validate the imported data.
@@ -60,8 +60,8 @@  discard block
 block discarded – undo
60 60
                     $user['error'] = get_lang('UserNameNotAvailable');
61 61
                     $errors[] = $user;
62 62
                 }
63
-             }
64
-          }
63
+                }
64
+            }
65 65
 
66 66
         // 3. Check status.
67 67
         if (isset($user['Status']) && !api_status_exists($user['Status'])) {
@@ -242,10 +242,10 @@  discard block
 block discarded – undo
242 242
     return $users;
243 243
 }
244 244
 /**
245
- * XML-parser: handle start of element
246
- * @param   string  $parser Deprecated?
247
- * @param   string  $data The data to be parsed
248
- */
245
+     * XML-parser: handle start of element
246
+     * @param   string  $parser Deprecated?
247
+     * @param   string  $data The data to be parsed
248
+     */
249 249
 function element_start($parser, $data)
250 250
 {
251 251
     $data = api_utf8_decode($data);
Please login to merge, or discard this patch.
main/attendance/attendance_controller.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -206,7 +206,7 @@
 block discarded – undo
206 206
 
207 207
     /**
208 208
      * Restores an attendance entry and fallback to attendances rendering
209
-     * @param int	$attendanceId
209
+     * @param int	$attendance_id
210 210
      */
211 211
     public function attendance_restore($attendance_id)
212 212
     {
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -636,11 +636,11 @@
 block discarded – undo
636 636
             }
637 637
             $formToDisplay = $form->returnForm();
638 638
         } else {
639
-           if (!empty($sessionId)) {
640
-               $sessionInfo = api_get_session_info($sessionId);
641
-               $startDate = $sessionInfo['access_start_date'];
642
-               $endDate = $sessionInfo['access_end_date'];
643
-           }
639
+            if (!empty($sessionId)) {
640
+                $sessionInfo = api_get_session_info($sessionId);
641
+                $startDate = $sessionInfo['access_start_date'];
642
+                $endDate = $sessionInfo['access_end_date'];
643
+            }
644 644
         }
645 645
 
646 646
         $attendance = new Attendance();
Please login to merge, or discard this patch.
main/auth/cas/authcas.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
 require_once api_get_path(SYS_PATH).'main/auth/external_login/functions.inc.php';
11 11
 
12 12
 /**
13
-* @return true if cas is configured
13
+* @return boolean if cas is configured
14 14
 *
15 15
 **/
16 16
 function cas_configured() {
Please login to merge, or discard this patch.
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 *
15 15
 **/
16 16
 function cas_configured() {
17
-	global $cas_auth_ver, $cas_auth_server, $cas_auth_port, $cas_auth_uri;
17
+    global $cas_auth_ver, $cas_auth_server, $cas_auth_port, $cas_auth_uri;
18 18
     $res = false;
19 19
     if (!empty($cas_auth_ver) && !empty($cas_auth_server) && !empty($cas_auth_port)) {
20 20
         $res = true;
@@ -32,23 +32,23 @@  discard block
 block discarded – undo
32 32
 
33 33
 function cas_is_authenticated()
34 34
 {
35
-	global $cas_auth_ver, $cas_auth_server, $cas_auth_port, $cas_auth_uri;
36
-	global $PHPCAS_CLIENT;
37
-	global $logout;
35
+    global $cas_auth_ver, $cas_auth_server, $cas_auth_port, $cas_auth_uri;
36
+    global $PHPCAS_CLIENT;
37
+    global $logout;
38 38
 
39 39
     if (!cas_configured()) {
40 40
         return;
41 41
     }
42 42
 
43
-	if (!is_object($PHPCAS_CLIENT)) {
44
-		phpCAS::client($cas_auth_ver,$cas_auth_server,$cas_auth_port,$cas_auth_uri);
45
-		phpCAS::setNoCasServerValidation();
46
-	}
47
-	$auth = phpCAS::checkAuthentication();
43
+    if (!is_object($PHPCAS_CLIENT)) {
44
+        phpCAS::client($cas_auth_ver,$cas_auth_server,$cas_auth_port,$cas_auth_uri);
45
+        phpCAS::setNoCasServerValidation();
46
+    }
47
+    $auth = phpCAS::checkAuthentication();
48 48
 
49
-	if ($auth) {
50
-		$login= trim(phpCAS::getUser());
51
-		/*
49
+    if ($auth) {
50
+        $login= trim(phpCAS::getUser());
51
+        /*
52 52
 		   Get user  attributes. Here are the attributes for crdp platform
53 53
 		   sn => name
54 54
 		   ENTPersonMailInterne => mail
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 		   ENTPersonProfils => profil
57 57
 		   givenName => first name
58 58
 		 */
59
-		/*$user=phpCAS::getAttributes();
59
+        /*$user=phpCAS::getAttributes();
60 60
 		$firstName = trim($user['givenName']);
61 61
 		$lastName = trim($user['sn']);
62 62
 		$login = trim($user['ENTPersonAlias']);
@@ -79,54 +79,54 @@  discard block
 block discarded – undo
79 79
 			default:
80 80
 				$status=5; // Student
81 81
 		}*/
82
-		if (!$logout){
83
-		    // get user info from username
84
-		    $tab_user_info = api_get_user_info($login);
85
-
86
-		    // user found in the chamilo database
87
-		    if (is_array($tab_user_info)) {
88
-		        // if option is on we update user automatically from ldap server
89
-		        if (api_get_setting("update_user_info_cas_with_ldap") == "true") {
82
+        if (!$logout){
83
+            // get user info from username
84
+            $tab_user_info = api_get_user_info($login);
85
+
86
+            // user found in the chamilo database
87
+            if (is_array($tab_user_info)) {
88
+                // if option is on we update user automatically from ldap server
89
+                if (api_get_setting("update_user_info_cas_with_ldap") == "true") {
90 90
                     $ldapuser = extldap_authenticate($login, 'nopass', true);
91 91
                     if ($ldapuser !== false) {
92 92
                         $chamilo_user = extldap_get_chamilo_user($ldapuser);
93 93
                         $chamilo_user['user_id'] = $tab_user_info['user_id'];
94 94
                         $chamilo_user['status'] = $tab_user_info['status'];
95
-        				UserManager::update_user ($chamilo_user["user_id"], $chamilo_user["firstname"], $chamilo_user["lastname"], $login, null, null, $chamilo_user["email"], $chamilo_user["status"], '', '', '', '', 1, null, 0, null,'') ;
96
-		            }
97
-		        }
98
-		        return $login;
99
-		    }
100
-		    // user not found
101
-		    else {
102
-		        // if option is on we can ADD user automatically from ldap server or by modify own profil
103
-		        $user_added = false;
104
-		        switch (api_get_setting("cas_add_user_activate")) {
105
-		            case PLATFORM_AUTH_SOURCE :
106
-		                // user will have to modify firstname, lastname, email in chamilo profil edit
107
-		                $userdata = get_lang("EditInProfil");
108
-          				UserManager::create_user($userdata, $userdata, '5', $userdata, $login, 'casplaceholder', '','','','',CAS_AUTH_SOURCE);
109
-          				$user_added = $login;
110
-		                break;
111
-		            case LDAP_AUTH_SOURCE :
112
-		                // user info are read from ldap connexion
113
-	                    // get user info from ldap server
114
-	                    // user has already been authenticated by CAS
115
-	                    // If user not found in LDAP, user not created
116
-	                    $ldapuser = extldap_authenticate($login, 'nopass', true);
117
-	                    if ($ldapuser !== false) {
118
-	                        $chamilo_user = extldap_get_chamilo_user($ldapuser);
95
+                        UserManager::update_user ($chamilo_user["user_id"], $chamilo_user["firstname"], $chamilo_user["lastname"], $login, null, null, $chamilo_user["email"], $chamilo_user["status"], '', '', '', '', 1, null, 0, null,'') ;
96
+                    }
97
+                }
98
+                return $login;
99
+            }
100
+            // user not found
101
+            else {
102
+                // if option is on we can ADD user automatically from ldap server or by modify own profil
103
+                $user_added = false;
104
+                switch (api_get_setting("cas_add_user_activate")) {
105
+                    case PLATFORM_AUTH_SOURCE :
106
+                        // user will have to modify firstname, lastname, email in chamilo profil edit
107
+                        $userdata = get_lang("EditInProfil");
108
+                            UserManager::create_user($userdata, $userdata, '5', $userdata, $login, 'casplaceholder', '','','','',CAS_AUTH_SOURCE);
109
+                            $user_added = $login;
110
+                        break;
111
+                    case LDAP_AUTH_SOURCE :
112
+                        // user info are read from ldap connexion
113
+                        // get user info from ldap server
114
+                        // user has already been authenticated by CAS
115
+                        // If user not found in LDAP, user not created
116
+                        $ldapuser = extldap_authenticate($login, 'nopass', true);
117
+                        if ($ldapuser !== false) {
118
+                            $chamilo_user = extldap_get_chamilo_user($ldapuser);
119 119
                             $chamilo_user['username'] = $login;
120 120
                             $chamilo_user['auth_source'] = CAS_AUTH_SOURCE;
121 121
                             $chamilo_uid = external_add_user($chamilo_user);
122
-          				    $user_added = $login;
123
-          				}
124
-		                break;
125
-		            default : break;
126
-		        }
127
-		        return $user_added;
128
-		    }
129
-		}
122
+                                $user_added = $login;
123
+                            }
124
+                        break;
125
+                    default : break;
126
+                }
127
+                return $user_added;
128
+            }
129
+        }
130 130
 //		//If the user is in the dokeos database and we are ,not in a logout request, we upgrade his infomration by ldap
131 131
 //		if (! $logout){
132 132
 //			$user_table = Database::get_main_table(TABLE_MAIN_USER);
@@ -148,10 +148,10 @@  discard block
 block discarded – undo
148 148
 //
149 149
 //			}
150 150
 //		}
151
-		return $login;
151
+        return $login;
152 152
     } else {
153
-		return false;
154
-	}
153
+        return false;
154
+    }
155 155
 }
156 156
 
157 157
 /**
Please login to merge, or discard this patch.
main/auth/cas/lib/CAS.php 2 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
 	/**
517 517
 	 * Logs a string in debug mode.
518 518
 	 *
519
-	 * @param $str the string to write
519
+	 * @param string $str the string to write
520 520
 	 *
521 521
 	 * @private
522 522
 	 */
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
 	 * This method is used by interface methods to print an error and where the function
538 538
 	 * was originally called from.
539 539
 	 *
540
-	 * @param $msg the message to print
540
+	 * @param string $msg the message to print
541 541
 	 *
542 542
 	 * @private
543 543
 	 */
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
 	/**
665 665
 	 * This method returns the phpCAS version.
666 666
 	 *
667
-	 * @return the phpCAS version.
667
+	 * @return string phpCAS version.
668 668
 	 */
669 669
 	function getVersion() {
670 670
 		return PHPCAS_VERSION;
@@ -1070,7 +1070,7 @@  discard block
 block discarded – undo
1070 1070
 	 * @warning should not be called only after phpCAS::forceAuthentication()
1071 1071
 	 * or phpCAS::checkAuthentication().
1072 1072
 	 *
1073
-	 * @return the login name of the authenticated user
1073
+	 * @return string login name of the authenticated user
1074 1074
 	 */
1075 1075
 	function getUser() {
1076 1076
 		global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL;
Please login to merge, or discard this patch.
Indentation   +1139 added lines, -1139 removed lines patch added patch discarded remove patch
@@ -33,14 +33,14 @@  discard block
 block discarded – undo
33 33
 // hack by Vangelis Haniotakis to handle the absence of $_SERVER['REQUEST_URI'] in IIS
34 34
 //
35 35
 if (!$_SERVER['REQUEST_URI']) {
36
-	$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . '?' . $_SERVER['QUERY_STRING'];
36
+    $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . '?' . $_SERVER['QUERY_STRING'];
37 37
 }
38 38
 
39 39
 //
40 40
 // another one by Vangelis Haniotakis also to make phpCAS work with PHP5
41 41
 //
42 42
 if (version_compare(PHP_VERSION, '5', '>=')) {
43
-	require_once (dirname(__FILE__) . '/CAS/domxml-php4-to-php5.php');
43
+    require_once (dirname(__FILE__) . '/CAS/domxml-php4-to-php5.php');
44 44
 }
45 45
 
46 46
 /**
@@ -282,10 +282,10 @@  discard block
 block discarded – undo
282 282
  * @hideinitializer
283 283
  */
284 284
 $GLOBALS['PHPCAS_INIT_CALL'] = array (
285
-	'done' => FALSE,
286
-	'file' => '?',
287
-	'line' => -1,
288
-	'method' => '?'
285
+    'done' => FALSE,
286
+    'file' => '?',
287
+    'line' => -1,
288
+    'method' => '?'
289 289
 );
290 290
 
291 291
 /**
@@ -295,11 +295,11 @@  discard block
 block discarded – undo
295 295
  * @hideinitializer
296 296
  */
297 297
 $GLOBALS['PHPCAS_AUTH_CHECK_CALL'] = array (
298
-	'done' => FALSE,
299
-	'file' => '?',
300
-	'line' => -1,
301
-	'method' => '?',
302
-	'result' => FALSE
298
+    'done' => FALSE,
299
+    'file' => '?',
300
+    'line' => -1,
301
+    'method' => '?',
302
+    'result' => FALSE
303 303
 );
304 304
 
305 305
 /**
@@ -308,9 +308,9 @@  discard block
 block discarded – undo
308 308
  * @hideinitializer
309 309
  */
310 310
 $GLOBALS['PHPCAS_DEBUG'] = array (
311
-	'filename' => '/tmp/cas.log',
312
-	'indent' => 0,
313
-	'unique_id' => ''
311
+    'filename' => '/tmp/cas.log',
312
+    'indent' => 0,
313
+    'unique_id' => ''
314 314
 );
315 315
 
316 316
 /** @} */
@@ -340,1141 +340,1141 @@  discard block
 block discarded – undo
340 340
 
341 341
 class phpCAS {
342 342
 
343
-	// ########################################################################
344
-	//  INITIALIZATION
345
-	// ########################################################################
346
-
347
-	/**
348
-	 * @addtogroup publicInit
349
-	 * @{
350
-	 */
351
-
352
-	/**
353
-	 * phpCAS client initializer.
354
-	 * @note Only one of the phpCAS::client() and phpCAS::proxy functions should be
355
-	 * called, only once, and before all other methods (except phpCAS::getVersion()
356
-	 * and phpCAS::setDebug()).
357
-	 *
358
-	 * @param $server_version the version of the CAS server
359
-	 * @param $server_hostname the hostname of the CAS server
360
-	 * @param $server_port the port the CAS server is running on
361
-	 * @param $server_uri the URI the CAS server is responding on
362
-	 * @param $start_session Have phpCAS start PHP sessions (default true)
363
-	 *
364
-	 * @return a newly created CASClient object
365
-	 */
366
-	function client($server_version, $server_hostname, $server_port, $server_uri, $start_session = true) {
367
-		global $PHPCAS_CLIENT, $PHPCAS_INIT_CALL;
368
-
369
-		phpCAS :: traceBegin();
370
-		if (is_object($PHPCAS_CLIENT)) {
371
-			phpCAS :: error($PHPCAS_INIT_CALL['method'] . '() has already been called (at ' . $PHPCAS_INIT_CALL['file'] . ':' . $PHPCAS_INIT_CALL['line'] . ')');
372
-		}
373
-		if (gettype($server_version) != 'string') {
374
-			phpCAS :: error('type mismatched for parameter $server_version (should be `string\')');
375
-		}
376
-		if (gettype($server_hostname) != 'string') {
377
-			phpCAS :: error('type mismatched for parameter $server_hostname (should be `string\')');
378
-		}
379
-		if (gettype($server_port) != 'integer') {
380
-			phpCAS :: error('type mismatched for parameter $server_port (should be `integer\')');
381
-		}
382
-		if (gettype($server_uri) != 'string') {
383
-			phpCAS :: error('type mismatched for parameter $server_uri (should be `string\')');
384
-		}
385
-
386
-		// store where the initializer is called from
387
-		$dbg = phpCAS :: backtrace();
388
-		$PHPCAS_INIT_CALL = array (
389
-			'done' => TRUE,
390
-			'file' => $dbg[0]['file'],
391
-			'line' => $dbg[0]['line'],
392
-			'method' => __CLASS__ . '::' . __FUNCTION__
393
-		);
394
-
395
-		// initialize the global object $PHPCAS_CLIENT
396
-		$PHPCAS_CLIENT = new CASClient($server_version, FALSE /*proxy*/
397
-		, $server_hostname, $server_port, $server_uri, $start_session);
398
-		phpCAS :: traceEnd();
399
-	}
400
-
401
-	/**
402
-	 * phpCAS proxy initializer.
403
-	 * @note Only one of the phpCAS::client() and phpCAS::proxy functions should be
404
-	 * called, only once, and before all other methods (except phpCAS::getVersion()
405
-	 * and phpCAS::setDebug()).
406
-	 *
407
-	 * @param $server_version the version of the CAS server
408
-	 * @param $server_hostname the hostname of the CAS server
409
-	 * @param $server_port the port the CAS server is running on
410
-	 * @param $server_uri the URI the CAS server is responding on
411
-	 * @param $start_session Have phpCAS start PHP sessions (default true)
412
-	 *
413
-	 * @return a newly created CASClient object
414
-	 */
415
-	function proxy($server_version, $server_hostname, $server_port, $server_uri, $start_session = true) {
416
-		global $PHPCAS_CLIENT, $PHPCAS_INIT_CALL;
417
-
418
-		phpCAS :: traceBegin();
419
-		if (is_object($PHPCAS_CLIENT)) {
420
-			phpCAS :: error($PHPCAS_INIT_CALL['method'] . '() has already been called (at ' . $PHPCAS_INIT_CALL['file'] . ':' . $PHPCAS_INIT_CALL['line'] . ')');
421
-		}
422
-		if (gettype($server_version) != 'string') {
423
-			phpCAS :: error('type mismatched for parameter $server_version (should be `string\')');
424
-		}
425
-		if (gettype($server_hostname) != 'string') {
426
-			phpCAS :: error('type mismatched for parameter $server_hostname (should be `string\')');
427
-		}
428
-		if (gettype($server_port) != 'integer') {
429
-			phpCAS :: error('type mismatched for parameter $server_port (should be `integer\')');
430
-		}
431
-		if (gettype($server_uri) != 'string') {
432
-			phpCAS :: error('type mismatched for parameter $server_uri (should be `string\')');
433
-		}
434
-
435
-		// store where the initialzer is called from
436
-		$dbg = phpCAS :: backtrace();
437
-		$PHPCAS_INIT_CALL = array (
438
-			'done' => TRUE,
439
-			'file' => $dbg[0]['file'],
440
-			'line' => $dbg[0]['line'],
441
-			'method' => __CLASS__ . '::' . __FUNCTION__
442
-		);
443
-
444
-		// initialize the global object $PHPCAS_CLIENT
445
-		$PHPCAS_CLIENT = new CASClient($server_version, TRUE /*proxy*/
446
-		, $server_hostname, $server_port, $server_uri, $start_session);
447
-		phpCAS :: traceEnd();
448
-	}
449
-
450
-	/** @} */
451
-	// ########################################################################
452
-	//  DEBUGGING
453
-	// ########################################################################
454
-
455
-	/**
456
-	 * @addtogroup publicDebug
457
-	 * @{
458
-	 */
459
-
460
-	/**
461
-	 * Set/unset debug mode
462
-	 *
463
-	 * @param $filename the name of the file used for logging, or FALSE to stop debugging.
464
-	 */
465
-	function setDebug($filename = '') {
466
-		global $PHPCAS_DEBUG;
467
-
468
-		if ($filename != FALSE && gettype($filename) != 'string') {
469
-			phpCAS :: error('type mismatched for parameter $dbg (should be FALSE or the name of the log file)');
470
-		}
471
-
472
-		if (empty ($filename)) {
473
-			if (preg_match('/^Win.*/', getenv('OS'))) {
474
-				if (isset ($_ENV['TMP'])) {
475
-					$debugDir = $_ENV['TMP'] . '/';
476
-				} else
477
-					if (isset ($_ENV['TEMP'])) {
478
-						$debugDir = $_ENV['TEMP'] . '/';
479
-					} else {
480
-						$debugDir = '';
481
-					}
482
-			} else {
483
-				$debugDir = DEFAULT_DEBUG_DIR;
484
-			}
485
-			$filename = $debugDir . 'phpCAS.log';
486
-		}
487
-
488
-		if (empty ($PHPCAS_DEBUG['unique_id'])) {
489
-			$PHPCAS_DEBUG['unique_id'] = substr(strtoupper(md5(uniqid(''))), 0, 4);
490
-		}
491
-
492
-		$PHPCAS_DEBUG['filename'] = $filename;
493
-
494
-		phpCAS :: trace('START ******************');
495
-	}
496
-
497
-	/** @} */
498
-	/**
499
-	 * @addtogroup internalDebug
500
-	 * @{
501
-	 */
502
-
503
-	/**
504
-	 * This method is a wrapper for debug_backtrace() that is not available 
505
-	 * in all PHP versions (>= 4.3.0 only)
506
-	 */
507
-	function backtrace() {
508
-		if (function_exists('debug_backtrace')) {
509
-			return debug_backtrace();
510
-		} else {
511
-			// poor man's hack ... but it does work ...
512
-			return array ();
513
-		}
514
-	}
515
-
516
-	/**
517
-	 * Logs a string in debug mode.
518
-	 *
519
-	 * @param $str the string to write
520
-	 *
521
-	 * @private
522
-	 */
523
-	function log($str) {
524
-		$indent_str = ".";
525
-		global $PHPCAS_DEBUG;
526
-
527
-		if ($PHPCAS_DEBUG['filename']) {
528
-			for ($i = 0; $i < $PHPCAS_DEBUG['indent']; $i++) {
529
-				$indent_str .= '|    ';
530
-			}
531
-			error_log($PHPCAS_DEBUG['unique_id'] . ' ' . $indent_str . $str . "\n", 3, $PHPCAS_DEBUG['filename']);
532
-		}
533
-
534
-	}
535
-
536
-	/**
537
-	 * This method is used by interface methods to print an error and where the function
538
-	 * was originally called from.
539
-	 *
540
-	 * @param $msg the message to print
541
-	 *
542
-	 * @private
543
-	 */
544
-	function error($msg) {
545
-		$dbg = phpCAS :: backtrace();
546
-		$function = '?';
547
-		$file = '?';
548
-		$line = '?';
549
-		if (is_array($dbg)) {
550
-			for ($i = 1; $i < sizeof($dbg); $i++) {
551
-				if (is_array($dbg[$i])) {
552
-					if ($dbg[$i]['class'] == __CLASS__) {
553
-						$function = $dbg[$i]['function'];
554
-						$file = $dbg[$i]['file'];
555
-						$line = $dbg[$i]['line'];
556
-					}
557
-				}
558
-			}
559
-		}
560
-		echo "<br />\n<b>phpCAS error</b>: <font color=\"FF0000\"><b>" . __CLASS__ . "::" . $function . '(): ' . htmlentities($msg) . "</b></font> in <b>" . $file . "</b> on line <b>" . $line . "</b><br />\n";
561
-		phpCAS :: trace($msg);
562
-		phpCAS :: traceExit();
563
-		exit ();
564
-	}
565
-
566
-	/**
567
-	 * This method is used to log something in debug mode.
568
-	 */
569
-	function trace($str) {
570
-		$dbg = phpCAS :: backtrace();
571
-		phpCAS :: log($str . ' [' . basename($dbg[1]['file']) . ':' . $dbg[1]['line'] . ']');
572
-	}
573
-
574
-	/**
575
-	 * This method is used to indicate the start of the execution of a function in debug mode.
576
-	 */
577
-	function traceBegin() {
578
-		global $PHPCAS_DEBUG;
579
-
580
-		$dbg = phpCAS :: backtrace();
581
-		$str = '=> ';
582
-		if (!empty ($dbg[2]['class'])) {
583
-			$str .= $dbg[2]['class'] . '::';
584
-		}
585
-		$str .= $dbg[2]['function'] . '(';
586
-		if (is_array($dbg[2]['args'])) {
587
-			foreach ($dbg[2]['args'] as $index => $arg) {
588
-				if ($index != 0) {
589
-					$str .= ', ';
590
-				}
591
-				$str .= str_replace("\n", "", var_export($arg, TRUE));
592
-			}
593
-		}
594
-		$str .= ') [' . basename($dbg[2]['file']) . ':' . $dbg[2]['line'] . ']';
595
-		phpCAS :: log($str);
596
-		$PHPCAS_DEBUG['indent']++;
597
-	}
598
-
599
-	/**
600
-	 * This method is used to indicate the end of the execution of a function in debug mode.
601
-	 *
602
-	 * @param $res the result of the function
603
-	 */
604
-	function traceEnd($res = '') {
605
-		global $PHPCAS_DEBUG;
606
-
607
-		$PHPCAS_DEBUG['indent']--;
608
-		$dbg = phpCAS :: backtrace();
609
-		$str = '';
610
-		$str .= '<= ' . str_replace("\n", "", var_export($res, TRUE));
611
-		phpCAS :: log($str);
612
-	}
613
-
614
-	/**
615
-	 * This method is used to indicate the end of the execution of the program
616
-	 */
617
-	function traceExit() {
618
-		global $PHPCAS_DEBUG;
619
-
620
-		phpCAS :: log('exit()');
621
-		while ($PHPCAS_DEBUG['indent'] > 0) {
622
-			phpCAS :: log('-');
623
-			$PHPCAS_DEBUG['indent']--;
624
-		}
625
-	}
626
-
627
-	/** @} */
628
-	// ########################################################################
629
-	//  INTERNATIONALIZATION
630
-	// ########################################################################
631
-	/**
632
-	 * @addtogroup publicLang
633
-	 * @{
634
-	 */
635
-
636
-	/**
637
-	 * This method is used to set the language used by phpCAS. 
638
-	 * @note Can be called only once.
639
-	 *
640
-	 * @param $lang a string representing the language.
641
-	 *
642
-	 * @sa PHPCAS_LANG_FRENCH, PHPCAS_LANG_ENGLISH
643
-	 */
644
-	function setLang($lang) {
645
-		global $PHPCAS_CLIENT;
646
-		if (!is_object($PHPCAS_CLIENT)) {
647
-			phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()');
648
-		}
649
-		if (gettype($lang) != 'string') {
650
-			phpCAS :: error('type mismatched for parameter $lang (should be `string\')');
651
-		}
652
-		$PHPCAS_CLIENT->setLang($lang);
653
-	}
654
-
655
-	/** @} */
656
-	// ########################################################################
657
-	//  VERSION
658
-	// ########################################################################
659
-	/**
660
-	 * @addtogroup public
661
-	 * @{
662
-	 */
663
-
664
-	/**
665
-	 * This method returns the phpCAS version.
666
-	 *
667
-	 * @return the phpCAS version.
668
-	 */
669
-	function getVersion() {
670
-		return PHPCAS_VERSION;
671
-	}
672
-
673
-	/** @} */
674
-	// ########################################################################
675
-	//  HTML OUTPUT
676
-	// ########################################################################
677
-	/**
678
-	 * @addtogroup publicOutput
679
-	 * @{
680
-	 */
681
-
682
-	/**
683
-	 * This method sets the HTML header used for all outputs.
684
-	 *
685
-	 * @param $header the HTML header.
686
-	 */
687
-	function setHTMLHeader($header) {
688
-		global $PHPCAS_CLIENT;
689
-		if (!is_object($PHPCAS_CLIENT)) {
690
-			phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()');
691
-		}
692
-		if (gettype($header) != 'string') {
693
-			phpCAS :: error('type mismatched for parameter $header (should be `string\')');
694
-		}
695
-		$PHPCAS_CLIENT->setHTMLHeader($header);
696
-	}
697
-
698
-	/**
699
-	 * This method sets the HTML footer used for all outputs.
700
-	 *
701
-	 * @param $footer the HTML footer.
702
-	 */
703
-	function setHTMLFooter($footer) {
704
-		global $PHPCAS_CLIENT;
705
-		if (!is_object($PHPCAS_CLIENT)) {
706
-			phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()');
707
-		}
708
-		if (gettype($footer) != 'string') {
709
-			phpCAS :: error('type mismatched for parameter $footer (should be `string\')');
710
-		}
711
-		$PHPCAS_CLIENT->setHTMLFooter($footer);
712
-	}
713
-
714
-	/** @} */
715
-	// ########################################################################
716
-	//  PGT STORAGE
717
-	// ########################################################################
718
-	/**
719
-	 * @addtogroup publicPGTStorage
720
-	 * @{
721
-	 */
722
-
723
-	/**
724
-	 * This method is used to tell phpCAS to store the response of the
725
-	 * CAS server to PGT requests onto the filesystem. 
726
-	 *
727
-	 * @param $format the format used to store the PGT's (`plain' and `xml' allowed)
728
-	 * @param $path the path where the PGT's should be stored
729
-	 */
730
-	function setPGTStorageFile($format = '', $path = '') {
731
-		global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL;
732
-
733
-		phpCAS :: traceBegin();
734
-		if (!is_object($PHPCAS_CLIENT)) {
735
-			phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()');
736
-		}
737
-		if (!$PHPCAS_CLIENT->isProxy()) {
738
-			phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()');
739
-		}
740
-		if ($PHPCAS_AUTH_CHECK_CALL['done']) {
741
-			phpCAS :: error('this method should only be called before ' . $PHPCAS_AUTH_CHECK_CALL['method'] . '() (called at ' . $PHPCAS_AUTH_CHECK_CALL['file'] . ':' . $PHPCAS_AUTH_CHECK_CALL['line'] . ')');
742
-		}
743
-		if (gettype($format) != 'string') {
744
-			phpCAS :: error('type mismatched for parameter $format (should be `string\')');
745
-		}
746
-		if (gettype($path) != 'string') {
747
-			phpCAS :: error('type mismatched for parameter $format (should be `string\')');
748
-		}
749
-		$PHPCAS_CLIENT->setPGTStorageFile($format, $path);
750
-		phpCAS :: traceEnd();
751
-	}
752
-
753
-	/**
754
-	 * This method is used to tell phpCAS to store the response of the
755
-	 * CAS server to PGT requests into a database. 
756
-	 * @note The connection to the database is done only when needed. 
757
-	 * As a consequence, bad parameters are detected only when 
758
-	 * initializing PGT storage, except in debug mode.
759
-	 *
760
-	 * @param $user the user to access the data with
761
-	 * @param $password the user's password
762
-	 * @param $database_type the type of the database hosting the data
763
-	 * @param $hostname the server hosting the database
764
-	 * @param $port the port the server is listening on
765
-	 * @param $database the name of the database
766
-	 * @param $table the name of the table storing the data
767
-	 */
768
-	function setPGTStorageDB($user, $password, $database_type = '', $hostname = '', $port = 0, $database = '', $table = '') {
769
-		global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL;
770
-
771
-		phpCAS :: traceBegin();
772
-		if (!is_object($PHPCAS_CLIENT)) {
773
-			phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()');
774
-		}
775
-		if (!$PHPCAS_CLIENT->isProxy()) {
776
-			phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()');
777
-		}
778
-		if ($PHPCAS_AUTH_CHECK_CALL['done']) {
779
-			phpCAS :: error('this method should only be called before ' . $PHPCAS_AUTH_CHECK_CALL['method'] . '() (called at ' . $PHPCAS_AUTH_CHECK_CALL['file'] . ':' . $PHPCAS_AUTH_CHECK_CALL['line'] . ')');
780
-		}
781
-		if (gettype($user) != 'string') {
782
-			phpCAS :: error('type mismatched for parameter $user (should be `string\')');
783
-		}
784
-		if (gettype($password) != 'string') {
785
-			phpCAS :: error('type mismatched for parameter $password (should be `string\')');
786
-		}
787
-		if (gettype($database_type) != 'string') {
788
-			phpCAS :: error('type mismatched for parameter $database_type (should be `string\')');
789
-		}
790
-		if (gettype($hostname) != 'string') {
791
-			phpCAS :: error('type mismatched for parameter $hostname (should be `string\')');
792
-		}
793
-		if (gettype($port) != 'integer') {
794
-			phpCAS :: error('type mismatched for parameter $port (should be `integer\')');
795
-		}
796
-		if (gettype($database) != 'string') {
797
-			phpCAS :: error('type mismatched for parameter $database (should be `string\')');
798
-		}
799
-		if (gettype($table) != 'string') {
800
-			phpCAS :: error('type mismatched for parameter $table (should be `string\')');
801
-		}
802
-		$PHPCAS_CLIENT->setPGTStorageDB($user, $password, $database_type, $hostname, $port, $database, $table);
803
-		phpCAS :: traceEnd();
804
-	}
805
-
806
-	/** @} */
807
-	// ########################################################################
808
-	// ACCESS TO EXTERNAL SERVICES
809
-	// ########################################################################
810
-	/**
811
-	 * @addtogroup publicServices
812
-	 * @{
813
-	 */
814
-
815
-	/**
816
-	 * This method is used to access an HTTP[S] service.
817
-	 * 
818
-	 * @param $url the service to access.
819
-	 * @param $err_code an error code Possible values are PHPCAS_SERVICE_OK (on
820
-	 * success), PHPCAS_SERVICE_PT_NO_SERVER_RESPONSE, PHPCAS_SERVICE_PT_BAD_SERVER_RESPONSE,
821
-	 * PHPCAS_SERVICE_PT_FAILURE, PHPCAS_SERVICE_NOT AVAILABLE.
822
-	 * @param $output the output of the service (also used to give an error
823
-	 * message on failure).
824
-	 *
825
-	 * @return TRUE on success, FALSE otherwise (in this later case, $err_code
826
-	 * gives the reason why it failed and $output contains an error message).
827
-	 */
828
-	function serviceWeb($url, & $err_code, & $output) {
829
-		global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL;
830
-
831
-		phpCAS :: traceBegin();
832
-		if (!is_object($PHPCAS_CLIENT)) {
833
-			phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()');
834
-		}
835
-		if (!$PHPCAS_CLIENT->isProxy()) {
836
-			phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()');
837
-		}
838
-		if (!$PHPCAS_AUTH_CHECK_CALL['done']) {
839
-			phpCAS :: error('this method should only be called after the programmer is sure the user has been authenticated (by calling ' . __CLASS__ . '::checkAuthentication() or ' . __CLASS__ . '::forceAuthentication()');
840
-		}
841
-		if (!$PHPCAS_AUTH_CHECK_CALL['result']) {
842
-			phpCAS :: error('authentication was checked (by ' . $PHPCAS_AUTH_CHECK_CALL['method'] . '() at ' . $PHPCAS_AUTH_CHECK_CALL['file'] . ':' . $PHPCAS_AUTH_CHECK_CALL['line'] . ') but the method returned FALSE');
843
-		}
844
-		if (gettype($url) != 'string') {
845
-			phpCAS :: error('type mismatched for parameter $url (should be `string\')');
846
-		}
847
-
848
-		$res = $PHPCAS_CLIENT->serviceWeb($url, $err_code, $output);
849
-
850
-		phpCAS :: traceEnd($res);
851
-		return $res;
852
-	}
853
-
854
-	/**
855
-	 * This method is used to access an IMAP/POP3/NNTP service.
856
-	 * 
857
-	 * @param $url a string giving the URL of the service, including the mailing box
858
-	 * for IMAP URLs, as accepted by imap_open().
859
-	 * @param $service a string giving for CAS retrieve Proxy ticket
860
-	 * @param $flags options given to imap_open().
861
-	 * @param $err_code an error code Possible values are PHPCAS_SERVICE_OK (on
862
-	 * success), PHPCAS_SERVICE_PT_NO_SERVER_RESPONSE, PHPCAS_SERVICE_PT_BAD_SERVER_RESPONSE,
863
-	 * PHPCAS_SERVICE_PT_FAILURE, PHPCAS_SERVICE_NOT AVAILABLE.
864
-	 * @param $err_msg an error message on failure
865
-	 * @param $pt the Proxy Ticket (PT) retrieved from the CAS server to access the URL
866
-	 * on success, FALSE on error).
867
-	 *
868
-	 * @return an IMAP stream on success, FALSE otherwise (in this later case, $err_code
869
-	 * gives the reason why it failed and $err_msg contains an error message).
870
-	 */
871
-	function serviceMail($url, $service, $flags, & $err_code, & $err_msg, & $pt) {
872
-		global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL;
873
-
874
-		phpCAS :: traceBegin();
875
-		if (!is_object($PHPCAS_CLIENT)) {
876
-			phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()');
877
-		}
878
-		if (!$PHPCAS_CLIENT->isProxy()) {
879
-			phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()');
880
-		}
881
-		if (!$PHPCAS_AUTH_CHECK_CALL['done']) {
882
-			phpCAS :: error('this method should only be called after the programmer is sure the user has been authenticated (by calling ' . __CLASS__ . '::checkAuthentication() or ' . __CLASS__ . '::forceAuthentication()');
883
-		}
884
-		if (!$PHPCAS_AUTH_CHECK_CALL['result']) {
885
-			phpCAS :: error('authentication was checked (by ' . $PHPCAS_AUTH_CHECK_CALL['method'] . '() at ' . $PHPCAS_AUTH_CHECK_CALL['file'] . ':' . $PHPCAS_AUTH_CHECK_CALL['line'] . ') but the method returned FALSE');
886
-		}
887
-		if (gettype($url) != 'string') {
888
-			phpCAS :: error('type mismatched for parameter $url (should be `string\')');
889
-		}
890
-
891
-		if (gettype($flags) != 'integer') {
892
-			phpCAS :: error('type mismatched for parameter $flags (should be `integer\')');
893
-		}
894
-
895
-		$res = $PHPCAS_CLIENT->serviceMail($url, $service, $flags, $err_code, $err_msg, $pt);
896
-
897
-		phpCAS :: traceEnd($res);
898
-		return $res;
899
-	}
900
-
901
-	/** @} */
902
-	// ########################################################################
903
-	//  AUTHENTICATION
904
-	// ########################################################################
905
-	/**
906
-	 * @addtogroup publicAuth
907
-	 * @{
908
-	 */
909
-
910
-	/**
911
-	 * Set the times authentication will be cached before really accessing the CAS server in gateway mode: 
912
-	 * - -1: check only once, and then never again (until you pree login)
913
-	 * - 0: always check
914
-	 * - n: check every "n" time
915
-	 *
916
-	 * @param $n an integer.
917
-	 */
918
-	function setCacheTimesForAuthRecheck($n) {
919
-		global $PHPCAS_CLIENT;
920
-		if (!is_object($PHPCAS_CLIENT)) {
921
-			phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()');
922
-		}
923
-		if (gettype($n) != 'integer') {
924
-			phpCAS :: error('type mismatched for parameter $header (should be `string\')');
925
-		}
926
-		$PHPCAS_CLIENT->setCacheTimesForAuthRecheck($n);
927
-	}
928
-
929
-	/**
930
-	 * This method is called to check if the user is authenticated (use the gateway feature).
931
-	 * @return TRUE when the user is authenticated; otherwise FALSE.
932
-	 */
933
-	function checkAuthentication() {
934
-		global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL;
935
-
936
-		phpCAS :: traceBegin();
937
-		if (!is_object($PHPCAS_CLIENT)) {
938
-			phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()');
939
-		}
940
-
941
-		$auth = $PHPCAS_CLIENT->checkAuthentication();
942
-
943
-		// store where the authentication has been checked and the result
944
-		$dbg = phpCAS :: backtrace();
945
-		$PHPCAS_AUTH_CHECK_CALL = array (
946
-			'done' => TRUE,
947
-			'file' => $dbg[0]['file'],
948
-			'line' => $dbg[0]['line'],
949
-			'method' => __CLASS__ . '::' . __FUNCTION__,
950
-			'result' => $auth
951
-		);
952
-		phpCAS :: traceEnd($auth);
953
-		return $auth;
954
-	}
955
-
956
-	/**
957
-	 * This method is called to force authentication if the user was not already 
958
-	 * authenticated. If the user is not authenticated, halt by redirecting to 
959
-	 * the CAS server.
960
-	 */
961
-	function forceAuthentication() {
962
-		global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL;
963
-
964
-		phpCAS :: traceBegin();
965
-		if (!is_object($PHPCAS_CLIENT)) {
966
-			phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()');
967
-		}
968
-
969
-		$auth = $PHPCAS_CLIENT->forceAuthentication();
970
-
971
-		// store where the authentication has been checked and the result
972
-		$dbg = phpCAS :: backtrace();
973
-		$PHPCAS_AUTH_CHECK_CALL = array (
974
-			'done' => TRUE,
975
-			'file' => $dbg[0]['file'],
976
-			'line' => $dbg[0]['line'],
977
-			'method' => __CLASS__ . '::' . __FUNCTION__,
978
-			'result' => $auth
979
-		);
980
-
981
-		if (!$auth) {
982
-			phpCAS :: trace('user is not authenticated, redirecting to the CAS server');
983
-			$PHPCAS_CLIENT->forceAuthentication();
984
-		} else {
985
-			phpCAS :: trace('no need to authenticate (user `' . phpCAS :: getUser() . '\' is already authenticated)');
986
-		}
987
-
988
-		phpCAS :: traceEnd();
989
-		return $auth;
990
-	}
991
-
992
-	/**
993
-	 * This method is called to renew the authentication.
994
-	 **/
995
-	function renewAuthentication() {
996
-		global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL;
997
-
998
-		phpCAS :: traceBegin();
999
-		if (!is_object($PHPCAS_CLIENT)) {
1000
-			phpCAS :: error('this method should not be called before' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()');
1001
-		}
1002
-
1003
-		// store where the authentication has been checked and the result
1004
-		$dbg = phpCAS :: backtrace();
1005
-		$PHPCAS_AUTH_CHECK_CALL = array (
1006
-			'done' => TRUE,
1007
-			'file' => $dbg[0]['file'],
1008
-			'line' => $dbg[0]['line'],
1009
-			'method' => __CLASS__ . '::' . __FUNCTION__,
1010
-			'result' => $auth
1011
-		);
1012
-
1013
-		$PHPCAS_CLIENT->renewAuthentication();
1014
-		phpCAS :: traceEnd();
1015
-	}
1016
-
1017
-	/**
1018
-	 * This method has been left from version 0.4.1 for compatibility reasons.
1019
-	 */
1020
-	function authenticate() {
1021
-		phpCAS :: error('this method is deprecated. You should use ' . __CLASS__ . '::forceAuthentication() instead');
1022
-	}
1023
-
1024
-	/**
1025
-	 * This method is called to check if the user is authenticated (previously or by
1026
-	 * tickets given in the URL).
1027
-	 *
1028
-	 * @return TRUE when the user is authenticated.
1029
-	 */
1030
-	function isAuthenticated() {
1031
-		global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL;
1032
-
1033
-		phpCAS :: traceBegin();
1034
-		if (!is_object($PHPCAS_CLIENT)) {
1035
-			phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()');
1036
-		}
1037
-
1038
-		// call the isAuthenticated method of the global $PHPCAS_CLIENT object
1039
-		$auth = $PHPCAS_CLIENT->isAuthenticated();
1040
-
1041
-		// store where the authentication has been checked and the result
1042
-		$dbg = phpCAS :: backtrace();
1043
-		$PHPCAS_AUTH_CHECK_CALL = array (
1044
-			'done' => TRUE,
1045
-			'file' => $dbg[0]['file'],
1046
-			'line' => $dbg[0]['line'],
1047
-			'method' => __CLASS__ . '::' . __FUNCTION__,
1048
-			'result' => $auth
1049
-		);
1050
-		phpCAS :: traceEnd($auth);
1051
-		return $auth;
1052
-	}
1053
-
1054
-	/**
1055
-	 * Checks whether authenticated based on $_SESSION. Useful to avoid
1056
-	 * server calls.
1057
-	 * @return true if authenticated, false otherwise.
1058
-	 * @since 0.4.22 by Brendan Arnold
1059
-	 */
1060
-	function isSessionAuthenticated() {
1061
-		global $PHPCAS_CLIENT;
1062
-		if (!is_object($PHPCAS_CLIENT)) {
1063
-			phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()');
1064
-		}
1065
-		return ($PHPCAS_CLIENT->isSessionAuthenticated());
1066
-	}
1067
-
1068
-	/**
1069
-	 * This method returns the CAS user's login name.
1070
-	 * @warning should not be called only after phpCAS::forceAuthentication()
1071
-	 * or phpCAS::checkAuthentication().
1072
-	 *
1073
-	 * @return the login name of the authenticated user
1074
-	 */
1075
-	function getUser() {
1076
-		global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL;
1077
-		if (!is_object($PHPCAS_CLIENT)) {
1078
-			phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()');
1079
-		}
1080
-		if (!$PHPCAS_AUTH_CHECK_CALL['done']) {
1081
-			phpCAS :: error('this method should only be called after ' . __CLASS__ . '::forceAuthentication() or ' . __CLASS__ . '::isAuthenticated()');
1082
-		}
1083
-		if (!$PHPCAS_AUTH_CHECK_CALL['result']) {
1084
-			phpCAS :: error('authentication was checked (by ' . $PHPCAS_AUTH_CHECK_CALL['method'] . '() at ' . $PHPCAS_AUTH_CHECK_CALL['file'] . ':' . $PHPCAS_AUTH_CHECK_CALL['line'] . ') but the method returned FALSE');
1085
-		}
1086
-		return $PHPCAS_CLIENT->getUser();
1087
-	}
1088
-
1089
-	/**
1090
-	 * This method returns the CAS user's login name.
1091
-	 * @warning should not be called only after phpCAS::forceAuthentication()
1092
-	 * or phpCAS::checkAuthentication().
1093
-	 *
1094
-	 * @return the login name of the authenticated user
1095
-	 */
1096
-	function getAttributes() {
1097
-		global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL;
1098
-		if (!is_object($PHPCAS_CLIENT)) {
1099
-			phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()');
1100
-		}
1101
-		if (!$PHPCAS_AUTH_CHECK_CALL['done']) {
1102
-			phpCAS :: error('this method should only be called after ' . __CLASS__ . '::forceAuthentication() or ' . __CLASS__ . '::isAuthenticated()');
1103
-		}
1104
-		if (!$PHPCAS_AUTH_CHECK_CALL['result']) {
1105
-			phpCAS :: error('authentication was checked (by ' . $PHPCAS_AUTH_CHECK_CALL['method'] . '() at ' . $PHPCAS_AUTH_CHECK_CALL['file'] . ':' . $PHPCAS_AUTH_CHECK_CALL['line'] . ') but the method returned FALSE');
1106
-		}
1107
-		return $PHPCAS_CLIENT->getAttributes();
1108
-	}
1109
-	/**
1110
-	 * Handle logout requests.
1111
-	 */
1112
-	function handleLogoutRequests($check_client = true, $allowed_clients = false) {
1113
-		global $PHPCAS_CLIENT;
1114
-		if (!is_object($PHPCAS_CLIENT)) {
1115
-			phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()');
1116
-		}
1117
-		return ($PHPCAS_CLIENT->handleLogoutRequests($check_client, $allowed_clients));
1118
-	}
1119
-
1120
-	/**
1121
-	 * This method returns the URL to be used to login.
1122
-	 * or phpCAS::isAuthenticated().
1123
-	 *
1124
-	 * @return the login name of the authenticated user
1125
-	 */
1126
-	function getServerLoginURL() {
1127
-		global $PHPCAS_CLIENT;
1128
-		if (!is_object($PHPCAS_CLIENT)) {
1129
-			phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()');
1130
-		}
1131
-		return $PHPCAS_CLIENT->getServerLoginURL();
1132
-	}
1133
-
1134
-	/**
1135
-	 * Set the login URL of the CAS server.
1136
-	 * @param $url the login URL
1137
-	 * @since 0.4.21 by Wyman Chan
1138
-	 */
1139
-	function setServerLoginURL($url = '') {
1140
-		global $PHPCAS_CLIENT;
1141
-		phpCAS :: traceBegin();
1142
-		if (!is_object($PHPCAS_CLIENT)) {
1143
-			phpCAS :: error('this method should only be called after
343
+    // ########################################################################
344
+    //  INITIALIZATION
345
+    // ########################################################################
346
+
347
+    /**
348
+     * @addtogroup publicInit
349
+     * @{
350
+     */
351
+
352
+    /**
353
+     * phpCAS client initializer.
354
+     * @note Only one of the phpCAS::client() and phpCAS::proxy functions should be
355
+     * called, only once, and before all other methods (except phpCAS::getVersion()
356
+     * and phpCAS::setDebug()).
357
+     *
358
+     * @param $server_version the version of the CAS server
359
+     * @param $server_hostname the hostname of the CAS server
360
+     * @param $server_port the port the CAS server is running on
361
+     * @param $server_uri the URI the CAS server is responding on
362
+     * @param $start_session Have phpCAS start PHP sessions (default true)
363
+     *
364
+     * @return a newly created CASClient object
365
+     */
366
+    function client($server_version, $server_hostname, $server_port, $server_uri, $start_session = true) {
367
+        global $PHPCAS_CLIENT, $PHPCAS_INIT_CALL;
368
+
369
+        phpCAS :: traceBegin();
370
+        if (is_object($PHPCAS_CLIENT)) {
371
+            phpCAS :: error($PHPCAS_INIT_CALL['method'] . '() has already been called (at ' . $PHPCAS_INIT_CALL['file'] . ':' . $PHPCAS_INIT_CALL['line'] . ')');
372
+        }
373
+        if (gettype($server_version) != 'string') {
374
+            phpCAS :: error('type mismatched for parameter $server_version (should be `string\')');
375
+        }
376
+        if (gettype($server_hostname) != 'string') {
377
+            phpCAS :: error('type mismatched for parameter $server_hostname (should be `string\')');
378
+        }
379
+        if (gettype($server_port) != 'integer') {
380
+            phpCAS :: error('type mismatched for parameter $server_port (should be `integer\')');
381
+        }
382
+        if (gettype($server_uri) != 'string') {
383
+            phpCAS :: error('type mismatched for parameter $server_uri (should be `string\')');
384
+        }
385
+
386
+        // store where the initializer is called from
387
+        $dbg = phpCAS :: backtrace();
388
+        $PHPCAS_INIT_CALL = array (
389
+            'done' => TRUE,
390
+            'file' => $dbg[0]['file'],
391
+            'line' => $dbg[0]['line'],
392
+            'method' => __CLASS__ . '::' . __FUNCTION__
393
+        );
394
+
395
+        // initialize the global object $PHPCAS_CLIENT
396
+        $PHPCAS_CLIENT = new CASClient($server_version, FALSE /*proxy*/
397
+        , $server_hostname, $server_port, $server_uri, $start_session);
398
+        phpCAS :: traceEnd();
399
+    }
400
+
401
+    /**
402
+     * phpCAS proxy initializer.
403
+     * @note Only one of the phpCAS::client() and phpCAS::proxy functions should be
404
+     * called, only once, and before all other methods (except phpCAS::getVersion()
405
+     * and phpCAS::setDebug()).
406
+     *
407
+     * @param $server_version the version of the CAS server
408
+     * @param $server_hostname the hostname of the CAS server
409
+     * @param $server_port the port the CAS server is running on
410
+     * @param $server_uri the URI the CAS server is responding on
411
+     * @param $start_session Have phpCAS start PHP sessions (default true)
412
+     *
413
+     * @return a newly created CASClient object
414
+     */
415
+    function proxy($server_version, $server_hostname, $server_port, $server_uri, $start_session = true) {
416
+        global $PHPCAS_CLIENT, $PHPCAS_INIT_CALL;
417
+
418
+        phpCAS :: traceBegin();
419
+        if (is_object($PHPCAS_CLIENT)) {
420
+            phpCAS :: error($PHPCAS_INIT_CALL['method'] . '() has already been called (at ' . $PHPCAS_INIT_CALL['file'] . ':' . $PHPCAS_INIT_CALL['line'] . ')');
421
+        }
422
+        if (gettype($server_version) != 'string') {
423
+            phpCAS :: error('type mismatched for parameter $server_version (should be `string\')');
424
+        }
425
+        if (gettype($server_hostname) != 'string') {
426
+            phpCAS :: error('type mismatched for parameter $server_hostname (should be `string\')');
427
+        }
428
+        if (gettype($server_port) != 'integer') {
429
+            phpCAS :: error('type mismatched for parameter $server_port (should be `integer\')');
430
+        }
431
+        if (gettype($server_uri) != 'string') {
432
+            phpCAS :: error('type mismatched for parameter $server_uri (should be `string\')');
433
+        }
434
+
435
+        // store where the initialzer is called from
436
+        $dbg = phpCAS :: backtrace();
437
+        $PHPCAS_INIT_CALL = array (
438
+            'done' => TRUE,
439
+            'file' => $dbg[0]['file'],
440
+            'line' => $dbg[0]['line'],
441
+            'method' => __CLASS__ . '::' . __FUNCTION__
442
+        );
443
+
444
+        // initialize the global object $PHPCAS_CLIENT
445
+        $PHPCAS_CLIENT = new CASClient($server_version, TRUE /*proxy*/
446
+        , $server_hostname, $server_port, $server_uri, $start_session);
447
+        phpCAS :: traceEnd();
448
+    }
449
+
450
+    /** @} */
451
+    // ########################################################################
452
+    //  DEBUGGING
453
+    // ########################################################################
454
+
455
+    /**
456
+     * @addtogroup publicDebug
457
+     * @{
458
+     */
459
+
460
+    /**
461
+     * Set/unset debug mode
462
+     *
463
+     * @param $filename the name of the file used for logging, or FALSE to stop debugging.
464
+     */
465
+    function setDebug($filename = '') {
466
+        global $PHPCAS_DEBUG;
467
+
468
+        if ($filename != FALSE && gettype($filename) != 'string') {
469
+            phpCAS :: error('type mismatched for parameter $dbg (should be FALSE or the name of the log file)');
470
+        }
471
+
472
+        if (empty ($filename)) {
473
+            if (preg_match('/^Win.*/', getenv('OS'))) {
474
+                if (isset ($_ENV['TMP'])) {
475
+                    $debugDir = $_ENV['TMP'] . '/';
476
+                } else
477
+                    if (isset ($_ENV['TEMP'])) {
478
+                        $debugDir = $_ENV['TEMP'] . '/';
479
+                    } else {
480
+                        $debugDir = '';
481
+                    }
482
+            } else {
483
+                $debugDir = DEFAULT_DEBUG_DIR;
484
+            }
485
+            $filename = $debugDir . 'phpCAS.log';
486
+        }
487
+
488
+        if (empty ($PHPCAS_DEBUG['unique_id'])) {
489
+            $PHPCAS_DEBUG['unique_id'] = substr(strtoupper(md5(uniqid(''))), 0, 4);
490
+        }
491
+
492
+        $PHPCAS_DEBUG['filename'] = $filename;
493
+
494
+        phpCAS :: trace('START ******************');
495
+    }
496
+
497
+    /** @} */
498
+    /**
499
+     * @addtogroup internalDebug
500
+     * @{
501
+     */
502
+
503
+    /**
504
+     * This method is a wrapper for debug_backtrace() that is not available 
505
+     * in all PHP versions (>= 4.3.0 only)
506
+     */
507
+    function backtrace() {
508
+        if (function_exists('debug_backtrace')) {
509
+            return debug_backtrace();
510
+        } else {
511
+            // poor man's hack ... but it does work ...
512
+            return array ();
513
+        }
514
+    }
515
+
516
+    /**
517
+     * Logs a string in debug mode.
518
+     *
519
+     * @param $str the string to write
520
+     *
521
+     * @private
522
+     */
523
+    function log($str) {
524
+        $indent_str = ".";
525
+        global $PHPCAS_DEBUG;
526
+
527
+        if ($PHPCAS_DEBUG['filename']) {
528
+            for ($i = 0; $i < $PHPCAS_DEBUG['indent']; $i++) {
529
+                $indent_str .= '|    ';
530
+            }
531
+            error_log($PHPCAS_DEBUG['unique_id'] . ' ' . $indent_str . $str . "\n", 3, $PHPCAS_DEBUG['filename']);
532
+        }
533
+
534
+    }
535
+
536
+    /**
537
+     * This method is used by interface methods to print an error and where the function
538
+     * was originally called from.
539
+     *
540
+     * @param $msg the message to print
541
+     *
542
+     * @private
543
+     */
544
+    function error($msg) {
545
+        $dbg = phpCAS :: backtrace();
546
+        $function = '?';
547
+        $file = '?';
548
+        $line = '?';
549
+        if (is_array($dbg)) {
550
+            for ($i = 1; $i < sizeof($dbg); $i++) {
551
+                if (is_array($dbg[$i])) {
552
+                    if ($dbg[$i]['class'] == __CLASS__) {
553
+                        $function = $dbg[$i]['function'];
554
+                        $file = $dbg[$i]['file'];
555
+                        $line = $dbg[$i]['line'];
556
+                    }
557
+                }
558
+            }
559
+        }
560
+        echo "<br />\n<b>phpCAS error</b>: <font color=\"FF0000\"><b>" . __CLASS__ . "::" . $function . '(): ' . htmlentities($msg) . "</b></font> in <b>" . $file . "</b> on line <b>" . $line . "</b><br />\n";
561
+        phpCAS :: trace($msg);
562
+        phpCAS :: traceExit();
563
+        exit ();
564
+    }
565
+
566
+    /**
567
+     * This method is used to log something in debug mode.
568
+     */
569
+    function trace($str) {
570
+        $dbg = phpCAS :: backtrace();
571
+        phpCAS :: log($str . ' [' . basename($dbg[1]['file']) . ':' . $dbg[1]['line'] . ']');
572
+    }
573
+
574
+    /**
575
+     * This method is used to indicate the start of the execution of a function in debug mode.
576
+     */
577
+    function traceBegin() {
578
+        global $PHPCAS_DEBUG;
579
+
580
+        $dbg = phpCAS :: backtrace();
581
+        $str = '=> ';
582
+        if (!empty ($dbg[2]['class'])) {
583
+            $str .= $dbg[2]['class'] . '::';
584
+        }
585
+        $str .= $dbg[2]['function'] . '(';
586
+        if (is_array($dbg[2]['args'])) {
587
+            foreach ($dbg[2]['args'] as $index => $arg) {
588
+                if ($index != 0) {
589
+                    $str .= ', ';
590
+                }
591
+                $str .= str_replace("\n", "", var_export($arg, TRUE));
592
+            }
593
+        }
594
+        $str .= ') [' . basename($dbg[2]['file']) . ':' . $dbg[2]['line'] . ']';
595
+        phpCAS :: log($str);
596
+        $PHPCAS_DEBUG['indent']++;
597
+    }
598
+
599
+    /**
600
+     * This method is used to indicate the end of the execution of a function in debug mode.
601
+     *
602
+     * @param $res the result of the function
603
+     */
604
+    function traceEnd($res = '') {
605
+        global $PHPCAS_DEBUG;
606
+
607
+        $PHPCAS_DEBUG['indent']--;
608
+        $dbg = phpCAS :: backtrace();
609
+        $str = '';
610
+        $str .= '<= ' . str_replace("\n", "", var_export($res, TRUE));
611
+        phpCAS :: log($str);
612
+    }
613
+
614
+    /**
615
+     * This method is used to indicate the end of the execution of the program
616
+     */
617
+    function traceExit() {
618
+        global $PHPCAS_DEBUG;
619
+
620
+        phpCAS :: log('exit()');
621
+        while ($PHPCAS_DEBUG['indent'] > 0) {
622
+            phpCAS :: log('-');
623
+            $PHPCAS_DEBUG['indent']--;
624
+        }
625
+    }
626
+
627
+    /** @} */
628
+    // ########################################################################
629
+    //  INTERNATIONALIZATION
630
+    // ########################################################################
631
+    /**
632
+     * @addtogroup publicLang
633
+     * @{
634
+     */
635
+
636
+    /**
637
+     * This method is used to set the language used by phpCAS. 
638
+     * @note Can be called only once.
639
+     *
640
+     * @param $lang a string representing the language.
641
+     *
642
+     * @sa PHPCAS_LANG_FRENCH, PHPCAS_LANG_ENGLISH
643
+     */
644
+    function setLang($lang) {
645
+        global $PHPCAS_CLIENT;
646
+        if (!is_object($PHPCAS_CLIENT)) {
647
+            phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()');
648
+        }
649
+        if (gettype($lang) != 'string') {
650
+            phpCAS :: error('type mismatched for parameter $lang (should be `string\')');
651
+        }
652
+        $PHPCAS_CLIENT->setLang($lang);
653
+    }
654
+
655
+    /** @} */
656
+    // ########################################################################
657
+    //  VERSION
658
+    // ########################################################################
659
+    /**
660
+     * @addtogroup public
661
+     * @{
662
+     */
663
+
664
+    /**
665
+     * This method returns the phpCAS version.
666
+     *
667
+     * @return the phpCAS version.
668
+     */
669
+    function getVersion() {
670
+        return PHPCAS_VERSION;
671
+    }
672
+
673
+    /** @} */
674
+    // ########################################################################
675
+    //  HTML OUTPUT
676
+    // ########################################################################
677
+    /**
678
+     * @addtogroup publicOutput
679
+     * @{
680
+     */
681
+
682
+    /**
683
+     * This method sets the HTML header used for all outputs.
684
+     *
685
+     * @param $header the HTML header.
686
+     */
687
+    function setHTMLHeader($header) {
688
+        global $PHPCAS_CLIENT;
689
+        if (!is_object($PHPCAS_CLIENT)) {
690
+            phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()');
691
+        }
692
+        if (gettype($header) != 'string') {
693
+            phpCAS :: error('type mismatched for parameter $header (should be `string\')');
694
+        }
695
+        $PHPCAS_CLIENT->setHTMLHeader($header);
696
+    }
697
+
698
+    /**
699
+     * This method sets the HTML footer used for all outputs.
700
+     *
701
+     * @param $footer the HTML footer.
702
+     */
703
+    function setHTMLFooter($footer) {
704
+        global $PHPCAS_CLIENT;
705
+        if (!is_object($PHPCAS_CLIENT)) {
706
+            phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()');
707
+        }
708
+        if (gettype($footer) != 'string') {
709
+            phpCAS :: error('type mismatched for parameter $footer (should be `string\')');
710
+        }
711
+        $PHPCAS_CLIENT->setHTMLFooter($footer);
712
+    }
713
+
714
+    /** @} */
715
+    // ########################################################################
716
+    //  PGT STORAGE
717
+    // ########################################################################
718
+    /**
719
+     * @addtogroup publicPGTStorage
720
+     * @{
721
+     */
722
+
723
+    /**
724
+     * This method is used to tell phpCAS to store the response of the
725
+     * CAS server to PGT requests onto the filesystem. 
726
+     *
727
+     * @param $format the format used to store the PGT's (`plain' and `xml' allowed)
728
+     * @param $path the path where the PGT's should be stored
729
+     */
730
+    function setPGTStorageFile($format = '', $path = '') {
731
+        global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL;
732
+
733
+        phpCAS :: traceBegin();
734
+        if (!is_object($PHPCAS_CLIENT)) {
735
+            phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()');
736
+        }
737
+        if (!$PHPCAS_CLIENT->isProxy()) {
738
+            phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()');
739
+        }
740
+        if ($PHPCAS_AUTH_CHECK_CALL['done']) {
741
+            phpCAS :: error('this method should only be called before ' . $PHPCAS_AUTH_CHECK_CALL['method'] . '() (called at ' . $PHPCAS_AUTH_CHECK_CALL['file'] . ':' . $PHPCAS_AUTH_CHECK_CALL['line'] . ')');
742
+        }
743
+        if (gettype($format) != 'string') {
744
+            phpCAS :: error('type mismatched for parameter $format (should be `string\')');
745
+        }
746
+        if (gettype($path) != 'string') {
747
+            phpCAS :: error('type mismatched for parameter $format (should be `string\')');
748
+        }
749
+        $PHPCAS_CLIENT->setPGTStorageFile($format, $path);
750
+        phpCAS :: traceEnd();
751
+    }
752
+
753
+    /**
754
+     * This method is used to tell phpCAS to store the response of the
755
+     * CAS server to PGT requests into a database. 
756
+     * @note The connection to the database is done only when needed. 
757
+     * As a consequence, bad parameters are detected only when 
758
+     * initializing PGT storage, except in debug mode.
759
+     *
760
+     * @param $user the user to access the data with
761
+     * @param $password the user's password
762
+     * @param $database_type the type of the database hosting the data
763
+     * @param $hostname the server hosting the database
764
+     * @param $port the port the server is listening on
765
+     * @param $database the name of the database
766
+     * @param $table the name of the table storing the data
767
+     */
768
+    function setPGTStorageDB($user, $password, $database_type = '', $hostname = '', $port = 0, $database = '', $table = '') {
769
+        global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL;
770
+
771
+        phpCAS :: traceBegin();
772
+        if (!is_object($PHPCAS_CLIENT)) {
773
+            phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()');
774
+        }
775
+        if (!$PHPCAS_CLIENT->isProxy()) {
776
+            phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()');
777
+        }
778
+        if ($PHPCAS_AUTH_CHECK_CALL['done']) {
779
+            phpCAS :: error('this method should only be called before ' . $PHPCAS_AUTH_CHECK_CALL['method'] . '() (called at ' . $PHPCAS_AUTH_CHECK_CALL['file'] . ':' . $PHPCAS_AUTH_CHECK_CALL['line'] . ')');
780
+        }
781
+        if (gettype($user) != 'string') {
782
+            phpCAS :: error('type mismatched for parameter $user (should be `string\')');
783
+        }
784
+        if (gettype($password) != 'string') {
785
+            phpCAS :: error('type mismatched for parameter $password (should be `string\')');
786
+        }
787
+        if (gettype($database_type) != 'string') {
788
+            phpCAS :: error('type mismatched for parameter $database_type (should be `string\')');
789
+        }
790
+        if (gettype($hostname) != 'string') {
791
+            phpCAS :: error('type mismatched for parameter $hostname (should be `string\')');
792
+        }
793
+        if (gettype($port) != 'integer') {
794
+            phpCAS :: error('type mismatched for parameter $port (should be `integer\')');
795
+        }
796
+        if (gettype($database) != 'string') {
797
+            phpCAS :: error('type mismatched for parameter $database (should be `string\')');
798
+        }
799
+        if (gettype($table) != 'string') {
800
+            phpCAS :: error('type mismatched for parameter $table (should be `string\')');
801
+        }
802
+        $PHPCAS_CLIENT->setPGTStorageDB($user, $password, $database_type, $hostname, $port, $database, $table);
803
+        phpCAS :: traceEnd();
804
+    }
805
+
806
+    /** @} */
807
+    // ########################################################################
808
+    // ACCESS TO EXTERNAL SERVICES
809
+    // ########################################################################
810
+    /**
811
+     * @addtogroup publicServices
812
+     * @{
813
+     */
814
+
815
+    /**
816
+     * This method is used to access an HTTP[S] service.
817
+     * 
818
+     * @param $url the service to access.
819
+     * @param $err_code an error code Possible values are PHPCAS_SERVICE_OK (on
820
+     * success), PHPCAS_SERVICE_PT_NO_SERVER_RESPONSE, PHPCAS_SERVICE_PT_BAD_SERVER_RESPONSE,
821
+     * PHPCAS_SERVICE_PT_FAILURE, PHPCAS_SERVICE_NOT AVAILABLE.
822
+     * @param $output the output of the service (also used to give an error
823
+     * message on failure).
824
+     *
825
+     * @return TRUE on success, FALSE otherwise (in this later case, $err_code
826
+     * gives the reason why it failed and $output contains an error message).
827
+     */
828
+    function serviceWeb($url, & $err_code, & $output) {
829
+        global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL;
830
+
831
+        phpCAS :: traceBegin();
832
+        if (!is_object($PHPCAS_CLIENT)) {
833
+            phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()');
834
+        }
835
+        if (!$PHPCAS_CLIENT->isProxy()) {
836
+            phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()');
837
+        }
838
+        if (!$PHPCAS_AUTH_CHECK_CALL['done']) {
839
+            phpCAS :: error('this method should only be called after the programmer is sure the user has been authenticated (by calling ' . __CLASS__ . '::checkAuthentication() or ' . __CLASS__ . '::forceAuthentication()');
840
+        }
841
+        if (!$PHPCAS_AUTH_CHECK_CALL['result']) {
842
+            phpCAS :: error('authentication was checked (by ' . $PHPCAS_AUTH_CHECK_CALL['method'] . '() at ' . $PHPCAS_AUTH_CHECK_CALL['file'] . ':' . $PHPCAS_AUTH_CHECK_CALL['line'] . ') but the method returned FALSE');
843
+        }
844
+        if (gettype($url) != 'string') {
845
+            phpCAS :: error('type mismatched for parameter $url (should be `string\')');
846
+        }
847
+
848
+        $res = $PHPCAS_CLIENT->serviceWeb($url, $err_code, $output);
849
+
850
+        phpCAS :: traceEnd($res);
851
+        return $res;
852
+    }
853
+
854
+    /**
855
+     * This method is used to access an IMAP/POP3/NNTP service.
856
+     * 
857
+     * @param $url a string giving the URL of the service, including the mailing box
858
+     * for IMAP URLs, as accepted by imap_open().
859
+     * @param $service a string giving for CAS retrieve Proxy ticket
860
+     * @param $flags options given to imap_open().
861
+     * @param $err_code an error code Possible values are PHPCAS_SERVICE_OK (on
862
+     * success), PHPCAS_SERVICE_PT_NO_SERVER_RESPONSE, PHPCAS_SERVICE_PT_BAD_SERVER_RESPONSE,
863
+     * PHPCAS_SERVICE_PT_FAILURE, PHPCAS_SERVICE_NOT AVAILABLE.
864
+     * @param $err_msg an error message on failure
865
+     * @param $pt the Proxy Ticket (PT) retrieved from the CAS server to access the URL
866
+     * on success, FALSE on error).
867
+     *
868
+     * @return an IMAP stream on success, FALSE otherwise (in this later case, $err_code
869
+     * gives the reason why it failed and $err_msg contains an error message).
870
+     */
871
+    function serviceMail($url, $service, $flags, & $err_code, & $err_msg, & $pt) {
872
+        global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL;
873
+
874
+        phpCAS :: traceBegin();
875
+        if (!is_object($PHPCAS_CLIENT)) {
876
+            phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()');
877
+        }
878
+        if (!$PHPCAS_CLIENT->isProxy()) {
879
+            phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()');
880
+        }
881
+        if (!$PHPCAS_AUTH_CHECK_CALL['done']) {
882
+            phpCAS :: error('this method should only be called after the programmer is sure the user has been authenticated (by calling ' . __CLASS__ . '::checkAuthentication() or ' . __CLASS__ . '::forceAuthentication()');
883
+        }
884
+        if (!$PHPCAS_AUTH_CHECK_CALL['result']) {
885
+            phpCAS :: error('authentication was checked (by ' . $PHPCAS_AUTH_CHECK_CALL['method'] . '() at ' . $PHPCAS_AUTH_CHECK_CALL['file'] . ':' . $PHPCAS_AUTH_CHECK_CALL['line'] . ') but the method returned FALSE');
886
+        }
887
+        if (gettype($url) != 'string') {
888
+            phpCAS :: error('type mismatched for parameter $url (should be `string\')');
889
+        }
890
+
891
+        if (gettype($flags) != 'integer') {
892
+            phpCAS :: error('type mismatched for parameter $flags (should be `integer\')');
893
+        }
894
+
895
+        $res = $PHPCAS_CLIENT->serviceMail($url, $service, $flags, $err_code, $err_msg, $pt);
896
+
897
+        phpCAS :: traceEnd($res);
898
+        return $res;
899
+    }
900
+
901
+    /** @} */
902
+    // ########################################################################
903
+    //  AUTHENTICATION
904
+    // ########################################################################
905
+    /**
906
+     * @addtogroup publicAuth
907
+     * @{
908
+     */
909
+
910
+    /**
911
+     * Set the times authentication will be cached before really accessing the CAS server in gateway mode: 
912
+     * - -1: check only once, and then never again (until you pree login)
913
+     * - 0: always check
914
+     * - n: check every "n" time
915
+     *
916
+     * @param $n an integer.
917
+     */
918
+    function setCacheTimesForAuthRecheck($n) {
919
+        global $PHPCAS_CLIENT;
920
+        if (!is_object($PHPCAS_CLIENT)) {
921
+            phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()');
922
+        }
923
+        if (gettype($n) != 'integer') {
924
+            phpCAS :: error('type mismatched for parameter $header (should be `string\')');
925
+        }
926
+        $PHPCAS_CLIENT->setCacheTimesForAuthRecheck($n);
927
+    }
928
+
929
+    /**
930
+     * This method is called to check if the user is authenticated (use the gateway feature).
931
+     * @return TRUE when the user is authenticated; otherwise FALSE.
932
+     */
933
+    function checkAuthentication() {
934
+        global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL;
935
+
936
+        phpCAS :: traceBegin();
937
+        if (!is_object($PHPCAS_CLIENT)) {
938
+            phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()');
939
+        }
940
+
941
+        $auth = $PHPCAS_CLIENT->checkAuthentication();
942
+
943
+        // store where the authentication has been checked and the result
944
+        $dbg = phpCAS :: backtrace();
945
+        $PHPCAS_AUTH_CHECK_CALL = array (
946
+            'done' => TRUE,
947
+            'file' => $dbg[0]['file'],
948
+            'line' => $dbg[0]['line'],
949
+            'method' => __CLASS__ . '::' . __FUNCTION__,
950
+            'result' => $auth
951
+        );
952
+        phpCAS :: traceEnd($auth);
953
+        return $auth;
954
+    }
955
+
956
+    /**
957
+     * This method is called to force authentication if the user was not already 
958
+     * authenticated. If the user is not authenticated, halt by redirecting to 
959
+     * the CAS server.
960
+     */
961
+    function forceAuthentication() {
962
+        global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL;
963
+
964
+        phpCAS :: traceBegin();
965
+        if (!is_object($PHPCAS_CLIENT)) {
966
+            phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()');
967
+        }
968
+
969
+        $auth = $PHPCAS_CLIENT->forceAuthentication();
970
+
971
+        // store where the authentication has been checked and the result
972
+        $dbg = phpCAS :: backtrace();
973
+        $PHPCAS_AUTH_CHECK_CALL = array (
974
+            'done' => TRUE,
975
+            'file' => $dbg[0]['file'],
976
+            'line' => $dbg[0]['line'],
977
+            'method' => __CLASS__ . '::' . __FUNCTION__,
978
+            'result' => $auth
979
+        );
980
+
981
+        if (!$auth) {
982
+            phpCAS :: trace('user is not authenticated, redirecting to the CAS server');
983
+            $PHPCAS_CLIENT->forceAuthentication();
984
+        } else {
985
+            phpCAS :: trace('no need to authenticate (user `' . phpCAS :: getUser() . '\' is already authenticated)');
986
+        }
987
+
988
+        phpCAS :: traceEnd();
989
+        return $auth;
990
+    }
991
+
992
+    /**
993
+     * This method is called to renew the authentication.
994
+     **/
995
+    function renewAuthentication() {
996
+        global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL;
997
+
998
+        phpCAS :: traceBegin();
999
+        if (!is_object($PHPCAS_CLIENT)) {
1000
+            phpCAS :: error('this method should not be called before' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()');
1001
+        }
1002
+
1003
+        // store where the authentication has been checked and the result
1004
+        $dbg = phpCAS :: backtrace();
1005
+        $PHPCAS_AUTH_CHECK_CALL = array (
1006
+            'done' => TRUE,
1007
+            'file' => $dbg[0]['file'],
1008
+            'line' => $dbg[0]['line'],
1009
+            'method' => __CLASS__ . '::' . __FUNCTION__,
1010
+            'result' => $auth
1011
+        );
1012
+
1013
+        $PHPCAS_CLIENT->renewAuthentication();
1014
+        phpCAS :: traceEnd();
1015
+    }
1016
+
1017
+    /**
1018
+     * This method has been left from version 0.4.1 for compatibility reasons.
1019
+     */
1020
+    function authenticate() {
1021
+        phpCAS :: error('this method is deprecated. You should use ' . __CLASS__ . '::forceAuthentication() instead');
1022
+    }
1023
+
1024
+    /**
1025
+     * This method is called to check if the user is authenticated (previously or by
1026
+     * tickets given in the URL).
1027
+     *
1028
+     * @return TRUE when the user is authenticated.
1029
+     */
1030
+    function isAuthenticated() {
1031
+        global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL;
1032
+
1033
+        phpCAS :: traceBegin();
1034
+        if (!is_object($PHPCAS_CLIENT)) {
1035
+            phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()');
1036
+        }
1037
+
1038
+        // call the isAuthenticated method of the global $PHPCAS_CLIENT object
1039
+        $auth = $PHPCAS_CLIENT->isAuthenticated();
1040
+
1041
+        // store where the authentication has been checked and the result
1042
+        $dbg = phpCAS :: backtrace();
1043
+        $PHPCAS_AUTH_CHECK_CALL = array (
1044
+            'done' => TRUE,
1045
+            'file' => $dbg[0]['file'],
1046
+            'line' => $dbg[0]['line'],
1047
+            'method' => __CLASS__ . '::' . __FUNCTION__,
1048
+            'result' => $auth
1049
+        );
1050
+        phpCAS :: traceEnd($auth);
1051
+        return $auth;
1052
+    }
1053
+
1054
+    /**
1055
+     * Checks whether authenticated based on $_SESSION. Useful to avoid
1056
+     * server calls.
1057
+     * @return true if authenticated, false otherwise.
1058
+     * @since 0.4.22 by Brendan Arnold
1059
+     */
1060
+    function isSessionAuthenticated() {
1061
+        global $PHPCAS_CLIENT;
1062
+        if (!is_object($PHPCAS_CLIENT)) {
1063
+            phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()');
1064
+        }
1065
+        return ($PHPCAS_CLIENT->isSessionAuthenticated());
1066
+    }
1067
+
1068
+    /**
1069
+     * This method returns the CAS user's login name.
1070
+     * @warning should not be called only after phpCAS::forceAuthentication()
1071
+     * or phpCAS::checkAuthentication().
1072
+     *
1073
+     * @return the login name of the authenticated user
1074
+     */
1075
+    function getUser() {
1076
+        global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL;
1077
+        if (!is_object($PHPCAS_CLIENT)) {
1078
+            phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()');
1079
+        }
1080
+        if (!$PHPCAS_AUTH_CHECK_CALL['done']) {
1081
+            phpCAS :: error('this method should only be called after ' . __CLASS__ . '::forceAuthentication() or ' . __CLASS__ . '::isAuthenticated()');
1082
+        }
1083
+        if (!$PHPCAS_AUTH_CHECK_CALL['result']) {
1084
+            phpCAS :: error('authentication was checked (by ' . $PHPCAS_AUTH_CHECK_CALL['method'] . '() at ' . $PHPCAS_AUTH_CHECK_CALL['file'] . ':' . $PHPCAS_AUTH_CHECK_CALL['line'] . ') but the method returned FALSE');
1085
+        }
1086
+        return $PHPCAS_CLIENT->getUser();
1087
+    }
1088
+
1089
+    /**
1090
+     * This method returns the CAS user's login name.
1091
+     * @warning should not be called only after phpCAS::forceAuthentication()
1092
+     * or phpCAS::checkAuthentication().
1093
+     *
1094
+     * @return the login name of the authenticated user
1095
+     */
1096
+    function getAttributes() {
1097
+        global $PHPCAS_CLIENT, $PHPCAS_AUTH_CHECK_CALL;
1098
+        if (!is_object($PHPCAS_CLIENT)) {
1099
+            phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()');
1100
+        }
1101
+        if (!$PHPCAS_AUTH_CHECK_CALL['done']) {
1102
+            phpCAS :: error('this method should only be called after ' . __CLASS__ . '::forceAuthentication() or ' . __CLASS__ . '::isAuthenticated()');
1103
+        }
1104
+        if (!$PHPCAS_AUTH_CHECK_CALL['result']) {
1105
+            phpCAS :: error('authentication was checked (by ' . $PHPCAS_AUTH_CHECK_CALL['method'] . '() at ' . $PHPCAS_AUTH_CHECK_CALL['file'] . ':' . $PHPCAS_AUTH_CHECK_CALL['line'] . ') but the method returned FALSE');
1106
+        }
1107
+        return $PHPCAS_CLIENT->getAttributes();
1108
+    }
1109
+    /**
1110
+     * Handle logout requests.
1111
+     */
1112
+    function handleLogoutRequests($check_client = true, $allowed_clients = false) {
1113
+        global $PHPCAS_CLIENT;
1114
+        if (!is_object($PHPCAS_CLIENT)) {
1115
+            phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()');
1116
+        }
1117
+        return ($PHPCAS_CLIENT->handleLogoutRequests($check_client, $allowed_clients));
1118
+    }
1119
+
1120
+    /**
1121
+     * This method returns the URL to be used to login.
1122
+     * or phpCAS::isAuthenticated().
1123
+     *
1124
+     * @return the login name of the authenticated user
1125
+     */
1126
+    function getServerLoginURL() {
1127
+        global $PHPCAS_CLIENT;
1128
+        if (!is_object($PHPCAS_CLIENT)) {
1129
+            phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()');
1130
+        }
1131
+        return $PHPCAS_CLIENT->getServerLoginURL();
1132
+    }
1133
+
1134
+    /**
1135
+     * Set the login URL of the CAS server.
1136
+     * @param $url the login URL
1137
+     * @since 0.4.21 by Wyman Chan
1138
+     */
1139
+    function setServerLoginURL($url = '') {
1140
+        global $PHPCAS_CLIENT;
1141
+        phpCAS :: traceBegin();
1142
+        if (!is_object($PHPCAS_CLIENT)) {
1143
+            phpCAS :: error('this method should only be called after
1144 1144
 							' . __CLASS__ . '::client()');
1145
-		}
1146
-		if (gettype($url) != 'string') {
1147
-			phpCAS :: error('type mismatched for parameter $url (should be
1145
+        }
1146
+        if (gettype($url) != 'string') {
1147
+            phpCAS :: error('type mismatched for parameter $url (should be
1148 1148
 						`string\')');
1149
-		}
1150
-		$PHPCAS_CLIENT->setServerLoginURL($url);
1151
-		phpCAS :: traceEnd();
1152
-	}
1153
-
1154
-	/**
1155
-	 * Set the serviceValidate URL of the CAS server.
1156
-	 * Used only in CAS 1.0 validations
1157
-	 * @param $url the serviceValidate URL
1158
-	 * @since 1.1.0 by Joachim Fritschi
1159
-	 */
1160
-	function setServerServiceValidateURL($url = '') {
1161
-		global $PHPCAS_CLIENT;
1162
-		phpCAS :: traceBegin();
1163
-		if (!is_object($PHPCAS_CLIENT)) {
1164
-			phpCAS :: error('this method should only be called after
1149
+        }
1150
+        $PHPCAS_CLIENT->setServerLoginURL($url);
1151
+        phpCAS :: traceEnd();
1152
+    }
1153
+
1154
+    /**
1155
+     * Set the serviceValidate URL of the CAS server.
1156
+     * Used only in CAS 1.0 validations
1157
+     * @param $url the serviceValidate URL
1158
+     * @since 1.1.0 by Joachim Fritschi
1159
+     */
1160
+    function setServerServiceValidateURL($url = '') {
1161
+        global $PHPCAS_CLIENT;
1162
+        phpCAS :: traceBegin();
1163
+        if (!is_object($PHPCAS_CLIENT)) {
1164
+            phpCAS :: error('this method should only be called after
1165 1165
 							' . __CLASS__ . '::client()');
1166
-		}
1167
-		if (gettype($url) != 'string') {
1168
-			phpCAS :: error('type mismatched for parameter $url (should be
1166
+        }
1167
+        if (gettype($url) != 'string') {
1168
+            phpCAS :: error('type mismatched for parameter $url (should be
1169 1169
 						`string\')');
1170
-		}
1171
-		$PHPCAS_CLIENT->setServerServiceValidateURL($url);
1172
-		phpCAS :: traceEnd();
1173
-	}
1174
-
1175
-	/**
1176
-	 * Set the proxyValidate URL of the CAS server.
1177
-	 * Used for all CAS 2.0 validations
1178
-	 * @param $url the proxyValidate URL
1179
-	 * @since 1.1.0 by Joachim Fritschi
1180
-	 */
1181
-	function setServerProxyValidateURL($url = '') {
1182
-		global $PHPCAS_CLIENT;
1183
-		phpCAS :: traceBegin();
1184
-		if (!is_object($PHPCAS_CLIENT)) {
1185
-			phpCAS :: error('this method should only be called after
1170
+        }
1171
+        $PHPCAS_CLIENT->setServerServiceValidateURL($url);
1172
+        phpCAS :: traceEnd();
1173
+    }
1174
+
1175
+    /**
1176
+     * Set the proxyValidate URL of the CAS server.
1177
+     * Used for all CAS 2.0 validations
1178
+     * @param $url the proxyValidate URL
1179
+     * @since 1.1.0 by Joachim Fritschi
1180
+     */
1181
+    function setServerProxyValidateURL($url = '') {
1182
+        global $PHPCAS_CLIENT;
1183
+        phpCAS :: traceBegin();
1184
+        if (!is_object($PHPCAS_CLIENT)) {
1185
+            phpCAS :: error('this method should only be called after
1186 1186
 							' . __CLASS__ . '::client()');
1187
-		}
1188
-		if (gettype($url) != 'string') {
1189
-			phpCAS :: error('type mismatched for parameter $url (should be
1187
+        }
1188
+        if (gettype($url) != 'string') {
1189
+            phpCAS :: error('type mismatched for parameter $url (should be
1190 1190
 						`string\')');
1191
-		}
1192
-		$PHPCAS_CLIENT->setServerProxyValidateURL($url);
1193
-		phpCAS :: traceEnd();
1194
-	}
1195
-
1196
-	/**
1197
-	 * Set the samlValidate URL of the CAS server.
1198
-	 * @param $url the samlValidate URL
1199
-	 * @since 1.1.0 by Joachim Fritschi
1200
-	 */
1201
-	function setServerSamlValidateURL($url = '') {
1202
-		global $PHPCAS_CLIENT;
1203
-		phpCAS :: traceBegin();
1204
-		if (!is_object($PHPCAS_CLIENT)) {
1205
-			phpCAS :: error('this method should only be called after
1191
+        }
1192
+        $PHPCAS_CLIENT->setServerProxyValidateURL($url);
1193
+        phpCAS :: traceEnd();
1194
+    }
1195
+
1196
+    /**
1197
+     * Set the samlValidate URL of the CAS server.
1198
+     * @param $url the samlValidate URL
1199
+     * @since 1.1.0 by Joachim Fritschi
1200
+     */
1201
+    function setServerSamlValidateURL($url = '') {
1202
+        global $PHPCAS_CLIENT;
1203
+        phpCAS :: traceBegin();
1204
+        if (!is_object($PHPCAS_CLIENT)) {
1205
+            phpCAS :: error('this method should only be called after
1206 1206
 							' . __CLASS__ . '::client()');
1207
-		}
1208
-		if (gettype($url) != 'string') {
1209
-			phpCAS :: error('type mismatched for parameter $url (should be
1207
+        }
1208
+        if (gettype($url) != 'string') {
1209
+            phpCAS :: error('type mismatched for parameter $url (should be
1210 1210
 						`string\')');
1211
-		}
1212
-		$PHPCAS_CLIENT->setServerSamlValidateURL($url);
1213
-		phpCAS :: traceEnd();
1214
-	}
1215
-
1216
-	/**
1217
-	 * This method returns the URL to be used to login.
1218
-	 * or phpCAS::isAuthenticated().
1219
-	 *
1220
-	 * @return the login name of the authenticated user
1221
-	 */
1222
-	function getServerLogoutURL() {
1223
-		global $PHPCAS_CLIENT;
1224
-		if (!is_object($PHPCAS_CLIENT)) {
1225
-			phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()');
1226
-		}
1227
-		return $PHPCAS_CLIENT->getServerLogoutURL();
1228
-	}
1229
-
1230
-	/**
1231
-	 * Set the logout URL of the CAS server.
1232
-	 * @param $url the logout URL
1233
-	 * @since 0.4.21 by Wyman Chan
1234
-	 */
1235
-	function setServerLogoutURL($url = '') {
1236
-		global $PHPCAS_CLIENT;
1237
-		phpCAS :: traceBegin();
1238
-		if (!is_object($PHPCAS_CLIENT)) {
1239
-			phpCAS :: error('this method should only be called after
1211
+        }
1212
+        $PHPCAS_CLIENT->setServerSamlValidateURL($url);
1213
+        phpCAS :: traceEnd();
1214
+    }
1215
+
1216
+    /**
1217
+     * This method returns the URL to be used to login.
1218
+     * or phpCAS::isAuthenticated().
1219
+     *
1220
+     * @return the login name of the authenticated user
1221
+     */
1222
+    function getServerLogoutURL() {
1223
+        global $PHPCAS_CLIENT;
1224
+        if (!is_object($PHPCAS_CLIENT)) {
1225
+            phpCAS :: error('this method should not be called before ' . __CLASS__ . '::client() or ' . __CLASS__ . '::proxy()');
1226
+        }
1227
+        return $PHPCAS_CLIENT->getServerLogoutURL();
1228
+    }
1229
+
1230
+    /**
1231
+     * Set the logout URL of the CAS server.
1232
+     * @param $url the logout URL
1233
+     * @since 0.4.21 by Wyman Chan
1234
+     */
1235
+    function setServerLogoutURL($url = '') {
1236
+        global $PHPCAS_CLIENT;
1237
+        phpCAS :: traceBegin();
1238
+        if (!is_object($PHPCAS_CLIENT)) {
1239
+            phpCAS :: error('this method should only be called after
1240 1240
 							' . __CLASS__ . '::client()');
1241
-		}
1242
-		if (gettype($url) != 'string') {
1243
-			phpCAS :: error('type mismatched for parameter $url (should be
1241
+        }
1242
+        if (gettype($url) != 'string') {
1243
+            phpCAS :: error('type mismatched for parameter $url (should be
1244 1244
 						`string\')');
1245
-		}
1246
-		$PHPCAS_CLIENT->setServerLogoutURL($url);
1247
-		phpCAS :: traceEnd();
1248
-	}
1249
-
1250
-	/**
1251
-	 * This method is used to logout from CAS.
1252
-	 * @params $params an array that contains the optional url and service parameters that will be passed to the CAS server
1253
-	 * @public
1254
-	 */
1255
-	function logout($params = "") {
1256
-		global $PHPCAS_CLIENT;
1257
-		phpCAS :: traceBegin();
1258
-		if (!is_object($PHPCAS_CLIENT)) {
1259
-			phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()');
1260
-		}
1261
-		$parsedParams = array ();
1262
-		if ($params != "") {
1263
-			if (is_string($params)) {
1264
-				phpCAS :: error('method `phpCAS::logout($url)\' is now deprecated, use `phpCAS::logoutWithUrl($url)\' instead');
1265
-			}
1266
-			if (!is_array($params)) {
1267
-				phpCAS :: error('type mismatched for parameter $params (should be `array\')');
1268
-			}
1269
-			foreach ($params as $key => $value) {
1270
-				if ($key != "service" && $key != "url") {
1271
-					phpCAS :: error('only `url\' and `service\' parameters are allowed for method `phpCAS::logout($params)\'');
1272
-				}
1273
-				$parsedParams[$key] = $value;
1274
-			}
1275
-		}
1276
-		$PHPCAS_CLIENT->logout($parsedParams);
1277
-		// never reached
1278
-		phpCAS :: traceEnd();
1279
-	}
1280
-
1281
-	/**
1282
-	 * This method is used to logout from CAS. Halts by redirecting to the CAS server.
1283
-	 * @param $service a URL that will be transmitted to the CAS server
1284
-	 */
1285
-	function logoutWithRedirectService($service) {
1286
-		global $PHPCAS_CLIENT;
1287
-		phpCAS :: traceBegin();
1288
-		if (!is_object($PHPCAS_CLIENT)) {
1289
-			phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()');
1290
-		}
1291
-		if (!is_string($service)) {
1292
-			phpCAS :: error('type mismatched for parameter $service (should be `string\')');
1293
-		}
1294
-		$PHPCAS_CLIENT->logout(array (
1295
-			"service" => $service
1296
-		));
1297
-		// never reached
1298
-		phpCAS :: traceEnd();
1299
-	}
1300
-
1301
-	/**
1302
-	 * This method is used to logout from CAS. Halts by redirecting to the CAS server.
1303
-	 * @param $url a URL that will be transmitted to the CAS server
1304
-	 */
1305
-	function logoutWithUrl($url) {
1306
-		global $PHPCAS_CLIENT;
1307
-		phpCAS :: traceBegin();
1308
-		if (!is_object($PHPCAS_CLIENT)) {
1309
-			phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()');
1310
-		}
1311
-		if (!is_string($url)) {
1312
-			phpCAS :: error('type mismatched for parameter $url (should be `string\')');
1313
-		}
1314
-		$PHPCAS_CLIENT->logout(array (
1315
-			"url" => $url
1316
-		));
1317
-		// never reached
1318
-		phpCAS :: traceEnd();
1319
-	}
1320
-
1321
-	/**
1322
-	 * This method is used to logout from CAS. Halts by redirecting to the CAS server.
1323
-	 * @param $service a URL that will be transmitted to the CAS server
1324
-	 * @param $url a URL that will be transmitted to the CAS server
1325
-	 */
1326
-	function logoutWithRedirectServiceAndUrl($service, $url) {
1327
-		global $PHPCAS_CLIENT;
1328
-		phpCAS :: traceBegin();
1329
-		if (!is_object($PHPCAS_CLIENT)) {
1330
-			phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()');
1331
-		}
1332
-		if (!is_string($service)) {
1333
-			phpCAS :: error('type mismatched for parameter $service (should be `string\')');
1334
-		}
1335
-		if (!is_string($url)) {
1336
-			phpCAS :: error('type mismatched for parameter $url (should be `string\')');
1337
-		}
1338
-		$PHPCAS_CLIENT->logout(array (
1339
-			"service" => $service,
1340
-			"url" => $url
1341
-		));
1342
-		// never reached
1343
-		phpCAS :: traceEnd();
1344
-	}
1345
-
1346
-	/**
1347
-	 * Set the fixed URL that will be used by the CAS server to transmit the PGT.
1348
-	 * When this method is not called, a phpCAS script uses its own URL for the callback.
1349
-	 *
1350
-	 * @param $url the URL
1351
-	 */
1352
-	function setFixedCallbackURL($url = '') {
1353
-		global $PHPCAS_CLIENT;
1354
-		phpCAS :: traceBegin();
1355
-		if (!is_object($PHPCAS_CLIENT)) {
1356
-			phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()');
1357
-		}
1358
-		if (!$PHPCAS_CLIENT->isProxy()) {
1359
-			phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()');
1360
-		}
1361
-		if (gettype($url) != 'string') {
1362
-			phpCAS :: error('type mismatched for parameter $url (should be `string\')');
1363
-		}
1364
-		$PHPCAS_CLIENT->setCallbackURL($url);
1365
-		phpCAS :: traceEnd();
1366
-	}
1367
-
1368
-	/**
1369
-	 * Set the fixed URL that will be set as the CAS service parameter. When this
1370
-	 * method is not called, a phpCAS script uses its own URL.
1371
-	 *
1372
-	 * @param $url the URL
1373
-	 */
1374
-	function setFixedServiceURL($url) {
1375
-		global $PHPCAS_CLIENT;
1376
-		phpCAS :: traceBegin();
1377
-		if (!is_object($PHPCAS_CLIENT)) {
1378
-			phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()');
1379
-		}
1380
-		if (gettype($url) != 'string') {
1381
-			phpCAS :: error('type mismatched for parameter $url (should be `string\')');
1382
-		}
1383
-		$PHPCAS_CLIENT->setURL($url);
1384
-		phpCAS :: traceEnd();
1385
-	}
1386
-
1387
-	/**
1388
-	 * Get the URL that is set as the CAS service parameter.
1389
-	 */
1390
-	function getServiceURL() {
1391
-		global $PHPCAS_CLIENT;
1392
-		if (!is_object($PHPCAS_CLIENT)) {
1393
-			phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()');
1394
-		}
1395
-		return ($PHPCAS_CLIENT->getURL());
1396
-	}
1397
-
1398
-	/**
1399
-	 * Retrieve a Proxy Ticket from the CAS server.
1400
-	 */
1401
-	function retrievePT($target_service, & $err_code, & $err_msg) {
1402
-		global $PHPCAS_CLIENT;
1403
-		if (!is_object($PHPCAS_CLIENT)) {
1404
-			phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()');
1405
-		}
1406
-		if (gettype($target_service) != 'string') {
1407
-			phpCAS :: error('type mismatched for parameter $target_service(should be `string\')');
1408
-		}
1409
-		return ($PHPCAS_CLIENT->retrievePT($target_service, $err_code, $err_msg));
1410
-	}
1411
-
1412
-	/**
1413
-	 * Set the certificate of the CAS server.
1414
-	 *
1415
-	 * @param $cert the PEM certificate
1416
-	 */
1417
-	function setCasServerCert($cert) {
1418
-		global $PHPCAS_CLIENT;
1419
-		phpCAS :: traceBegin();
1420
-		if (!is_object($PHPCAS_CLIENT)) {
1421
-			phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()');
1422
-		}
1423
-		if (gettype($cert) != 'string') {
1424
-			phpCAS :: error('type mismatched for parameter $cert (should be `string\')');
1425
-		}
1426
-		$PHPCAS_CLIENT->setCasServerCert($cert);
1427
-		phpCAS :: traceEnd();
1428
-	}
1429
-
1430
-	/**
1431
-	 * Set the certificate of the CAS server CA.
1432
-	 *
1433
-	 * @param $cert the CA certificate
1434
-	 */
1435
-	function setCasServerCACert($cert) {
1436
-		global $PHPCAS_CLIENT;
1437
-		phpCAS :: traceBegin();
1438
-		if (!is_object($PHPCAS_CLIENT)) {
1439
-			phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()');
1440
-		}
1441
-		if (gettype($cert) != 'string') {
1442
-			phpCAS :: error('type mismatched for parameter $cert (should be `string\')');
1443
-		}
1444
-		$PHPCAS_CLIENT->setCasServerCACert($cert);
1445
-		phpCAS :: traceEnd();
1446
-	}
1447
-
1448
-	/**
1449
-	 * Set no SSL validation for the CAS server.
1450
-	 */
1451
-	function setNoCasServerValidation() {
1452
-		global $PHPCAS_CLIENT;
1453
-		phpCAS :: traceBegin();
1454
-		if (!is_object($PHPCAS_CLIENT)) {
1455
-			phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()');
1456
-		}
1457
-		$PHPCAS_CLIENT->setNoCasServerValidation();
1458
-		phpCAS :: traceEnd();
1459
-	}
1460
-
1461
-	/** @} */
1462
-
1463
-	/**
1464
-	 * Change CURL options.
1465
-	 * CURL is used to connect through HTTPS to CAS server
1466
-	 * @param $key the option key
1467
-	 * @param $value the value to set
1468
-	 */
1469
-	function setExtraCurlOption($key, $value) {
1470
-		global $PHPCAS_CLIENT;
1471
-		phpCAS :: traceBegin();
1472
-		if (!is_object($PHPCAS_CLIENT)) {
1473
-			phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()');
1474
-		}
1475
-		$PHPCAS_CLIENT->setExtraCurlOption($key, $value);
1476
-		phpCAS :: traceEnd();
1477
-	}
1245
+        }
1246
+        $PHPCAS_CLIENT->setServerLogoutURL($url);
1247
+        phpCAS :: traceEnd();
1248
+    }
1249
+
1250
+    /**
1251
+     * This method is used to logout from CAS.
1252
+     * @params $params an array that contains the optional url and service parameters that will be passed to the CAS server
1253
+     * @public
1254
+     */
1255
+    function logout($params = "") {
1256
+        global $PHPCAS_CLIENT;
1257
+        phpCAS :: traceBegin();
1258
+        if (!is_object($PHPCAS_CLIENT)) {
1259
+            phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()');
1260
+        }
1261
+        $parsedParams = array ();
1262
+        if ($params != "") {
1263
+            if (is_string($params)) {
1264
+                phpCAS :: error('method `phpCAS::logout($url)\' is now deprecated, use `phpCAS::logoutWithUrl($url)\' instead');
1265
+            }
1266
+            if (!is_array($params)) {
1267
+                phpCAS :: error('type mismatched for parameter $params (should be `array\')');
1268
+            }
1269
+            foreach ($params as $key => $value) {
1270
+                if ($key != "service" && $key != "url") {
1271
+                    phpCAS :: error('only `url\' and `service\' parameters are allowed for method `phpCAS::logout($params)\'');
1272
+                }
1273
+                $parsedParams[$key] = $value;
1274
+            }
1275
+        }
1276
+        $PHPCAS_CLIENT->logout($parsedParams);
1277
+        // never reached
1278
+        phpCAS :: traceEnd();
1279
+    }
1280
+
1281
+    /**
1282
+     * This method is used to logout from CAS. Halts by redirecting to the CAS server.
1283
+     * @param $service a URL that will be transmitted to the CAS server
1284
+     */
1285
+    function logoutWithRedirectService($service) {
1286
+        global $PHPCAS_CLIENT;
1287
+        phpCAS :: traceBegin();
1288
+        if (!is_object($PHPCAS_CLIENT)) {
1289
+            phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()');
1290
+        }
1291
+        if (!is_string($service)) {
1292
+            phpCAS :: error('type mismatched for parameter $service (should be `string\')');
1293
+        }
1294
+        $PHPCAS_CLIENT->logout(array (
1295
+            "service" => $service
1296
+        ));
1297
+        // never reached
1298
+        phpCAS :: traceEnd();
1299
+    }
1300
+
1301
+    /**
1302
+     * This method is used to logout from CAS. Halts by redirecting to the CAS server.
1303
+     * @param $url a URL that will be transmitted to the CAS server
1304
+     */
1305
+    function logoutWithUrl($url) {
1306
+        global $PHPCAS_CLIENT;
1307
+        phpCAS :: traceBegin();
1308
+        if (!is_object($PHPCAS_CLIENT)) {
1309
+            phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()');
1310
+        }
1311
+        if (!is_string($url)) {
1312
+            phpCAS :: error('type mismatched for parameter $url (should be `string\')');
1313
+        }
1314
+        $PHPCAS_CLIENT->logout(array (
1315
+            "url" => $url
1316
+        ));
1317
+        // never reached
1318
+        phpCAS :: traceEnd();
1319
+    }
1320
+
1321
+    /**
1322
+     * This method is used to logout from CAS. Halts by redirecting to the CAS server.
1323
+     * @param $service a URL that will be transmitted to the CAS server
1324
+     * @param $url a URL that will be transmitted to the CAS server
1325
+     */
1326
+    function logoutWithRedirectServiceAndUrl($service, $url) {
1327
+        global $PHPCAS_CLIENT;
1328
+        phpCAS :: traceBegin();
1329
+        if (!is_object($PHPCAS_CLIENT)) {
1330
+            phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()');
1331
+        }
1332
+        if (!is_string($service)) {
1333
+            phpCAS :: error('type mismatched for parameter $service (should be `string\')');
1334
+        }
1335
+        if (!is_string($url)) {
1336
+            phpCAS :: error('type mismatched for parameter $url (should be `string\')');
1337
+        }
1338
+        $PHPCAS_CLIENT->logout(array (
1339
+            "service" => $service,
1340
+            "url" => $url
1341
+        ));
1342
+        // never reached
1343
+        phpCAS :: traceEnd();
1344
+    }
1345
+
1346
+    /**
1347
+     * Set the fixed URL that will be used by the CAS server to transmit the PGT.
1348
+     * When this method is not called, a phpCAS script uses its own URL for the callback.
1349
+     *
1350
+     * @param $url the URL
1351
+     */
1352
+    function setFixedCallbackURL($url = '') {
1353
+        global $PHPCAS_CLIENT;
1354
+        phpCAS :: traceBegin();
1355
+        if (!is_object($PHPCAS_CLIENT)) {
1356
+            phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()');
1357
+        }
1358
+        if (!$PHPCAS_CLIENT->isProxy()) {
1359
+            phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()');
1360
+        }
1361
+        if (gettype($url) != 'string') {
1362
+            phpCAS :: error('type mismatched for parameter $url (should be `string\')');
1363
+        }
1364
+        $PHPCAS_CLIENT->setCallbackURL($url);
1365
+        phpCAS :: traceEnd();
1366
+    }
1367
+
1368
+    /**
1369
+     * Set the fixed URL that will be set as the CAS service parameter. When this
1370
+     * method is not called, a phpCAS script uses its own URL.
1371
+     *
1372
+     * @param $url the URL
1373
+     */
1374
+    function setFixedServiceURL($url) {
1375
+        global $PHPCAS_CLIENT;
1376
+        phpCAS :: traceBegin();
1377
+        if (!is_object($PHPCAS_CLIENT)) {
1378
+            phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()');
1379
+        }
1380
+        if (gettype($url) != 'string') {
1381
+            phpCAS :: error('type mismatched for parameter $url (should be `string\')');
1382
+        }
1383
+        $PHPCAS_CLIENT->setURL($url);
1384
+        phpCAS :: traceEnd();
1385
+    }
1386
+
1387
+    /**
1388
+     * Get the URL that is set as the CAS service parameter.
1389
+     */
1390
+    function getServiceURL() {
1391
+        global $PHPCAS_CLIENT;
1392
+        if (!is_object($PHPCAS_CLIENT)) {
1393
+            phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()');
1394
+        }
1395
+        return ($PHPCAS_CLIENT->getURL());
1396
+    }
1397
+
1398
+    /**
1399
+     * Retrieve a Proxy Ticket from the CAS server.
1400
+     */
1401
+    function retrievePT($target_service, & $err_code, & $err_msg) {
1402
+        global $PHPCAS_CLIENT;
1403
+        if (!is_object($PHPCAS_CLIENT)) {
1404
+            phpCAS :: error('this method should only be called after ' . __CLASS__ . '::proxy()');
1405
+        }
1406
+        if (gettype($target_service) != 'string') {
1407
+            phpCAS :: error('type mismatched for parameter $target_service(should be `string\')');
1408
+        }
1409
+        return ($PHPCAS_CLIENT->retrievePT($target_service, $err_code, $err_msg));
1410
+    }
1411
+
1412
+    /**
1413
+     * Set the certificate of the CAS server.
1414
+     *
1415
+     * @param $cert the PEM certificate
1416
+     */
1417
+    function setCasServerCert($cert) {
1418
+        global $PHPCAS_CLIENT;
1419
+        phpCAS :: traceBegin();
1420
+        if (!is_object($PHPCAS_CLIENT)) {
1421
+            phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()');
1422
+        }
1423
+        if (gettype($cert) != 'string') {
1424
+            phpCAS :: error('type mismatched for parameter $cert (should be `string\')');
1425
+        }
1426
+        $PHPCAS_CLIENT->setCasServerCert($cert);
1427
+        phpCAS :: traceEnd();
1428
+    }
1429
+
1430
+    /**
1431
+     * Set the certificate of the CAS server CA.
1432
+     *
1433
+     * @param $cert the CA certificate
1434
+     */
1435
+    function setCasServerCACert($cert) {
1436
+        global $PHPCAS_CLIENT;
1437
+        phpCAS :: traceBegin();
1438
+        if (!is_object($PHPCAS_CLIENT)) {
1439
+            phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()');
1440
+        }
1441
+        if (gettype($cert) != 'string') {
1442
+            phpCAS :: error('type mismatched for parameter $cert (should be `string\')');
1443
+        }
1444
+        $PHPCAS_CLIENT->setCasServerCACert($cert);
1445
+        phpCAS :: traceEnd();
1446
+    }
1447
+
1448
+    /**
1449
+     * Set no SSL validation for the CAS server.
1450
+     */
1451
+    function setNoCasServerValidation() {
1452
+        global $PHPCAS_CLIENT;
1453
+        phpCAS :: traceBegin();
1454
+        if (!is_object($PHPCAS_CLIENT)) {
1455
+            phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()');
1456
+        }
1457
+        $PHPCAS_CLIENT->setNoCasServerValidation();
1458
+        phpCAS :: traceEnd();
1459
+    }
1460
+
1461
+    /** @} */
1462
+
1463
+    /**
1464
+     * Change CURL options.
1465
+     * CURL is used to connect through HTTPS to CAS server
1466
+     * @param $key the option key
1467
+     * @param $value the value to set
1468
+     */
1469
+    function setExtraCurlOption($key, $value) {
1470
+        global $PHPCAS_CLIENT;
1471
+        phpCAS :: traceBegin();
1472
+        if (!is_object($PHPCAS_CLIENT)) {
1473
+            phpCAS :: error('this method should only be called after ' . __CLASS__ . '::client() or' . __CLASS__ . '::proxy()');
1474
+        }
1475
+        $PHPCAS_CLIENT->setExtraCurlOption($key, $value);
1476
+        phpCAS :: traceEnd();
1477
+    }
1478 1478
 
1479 1479
 }
1480 1480
 
Please login to merge, or discard this patch.