@@ -66,30 +66,30 @@ discard block |
||
66 | 66 | $sublanguage_folder_error = false; |
67 | 67 | |
68 | 68 | if (isset($_GET['id']) && $_GET['id']==strval(intval($_GET['id']))) { |
69 | - $language_name = SubLanguageManager::get_name_of_language_by_id ($_GET['id']); |
|
70 | - $sub_language_name = SubLanguageManager::get_name_of_language_by_id ($_GET['sub_language_id']); |
|
71 | - $all_data_of_language = SubLanguageManager::get_all_information_of_language($_GET['id']); |
|
72 | - $all_data_of_sublanguage = SubLanguageManager::get_all_information_of_language($_GET['sub_language_id']); |
|
73 | - $sub_language_file = api_get_path(SYS_LANG_PATH).$all_data_of_sublanguage['dokeos_folder']; |
|
69 | + $language_name = SubLanguageManager::get_name_of_language_by_id ($_GET['id']); |
|
70 | + $sub_language_name = SubLanguageManager::get_name_of_language_by_id ($_GET['sub_language_id']); |
|
71 | + $all_data_of_language = SubLanguageManager::get_all_information_of_language($_GET['id']); |
|
72 | + $all_data_of_sublanguage = SubLanguageManager::get_all_information_of_language($_GET['sub_language_id']); |
|
73 | + $sub_language_file = api_get_path(SYS_LANG_PATH).$all_data_of_sublanguage['dokeos_folder']; |
|
74 | 74 | |
75 | - if (!file_exists($sub_language_file) || !is_writable($sub_language_file)) { |
|
76 | - $sublanguage_folder_error = $sub_language_file.' '.get_lang('IsNotWritable'); |
|
77 | - } |
|
78 | - if (SubLanguageManager::check_if_exist_language_by_id($_GET['id'])===true) { |
|
79 | - $language_id_exist = true; |
|
80 | - } else { |
|
81 | - $language_id_exist = false; |
|
82 | - } |
|
75 | + if (!file_exists($sub_language_file) || !is_writable($sub_language_file)) { |
|
76 | + $sublanguage_folder_error = $sub_language_file.' '.get_lang('IsNotWritable'); |
|
77 | + } |
|
78 | + if (SubLanguageManager::check_if_exist_language_by_id($_GET['id'])===true) { |
|
79 | + $language_id_exist = true; |
|
80 | + } else { |
|
81 | + $language_id_exist = false; |
|
82 | + } |
|
83 | 83 | } else { |
84 | - $language_name=''; |
|
85 | - $language_id_exist=false; |
|
84 | + $language_name=''; |
|
85 | + $language_id_exist=false; |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | $intro = sprintf(get_lang('RegisterTermsOfSubLanguageForX'), strtolower($sub_language_name)); |
89 | 89 | $path_folder = api_get_path(SYS_LANG_PATH).$all_data_of_language['dokeos_folder']; |
90 | 90 | |
91 | 91 | if (!is_dir($path_folder) || strlen($all_data_of_language['dokeos_folder'])==0) { |
92 | - api_not_allowed(true); |
|
92 | + api_not_allowed(true); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | Display :: display_header($language_name); |
@@ -101,10 +101,10 @@ discard block |
||
101 | 101 | echo '</div>'; |
102 | 102 | |
103 | 103 | if (!empty($_SESSION['msg'])) { |
104 | - echo $_SESSION['msg']; |
|
105 | - unset($_SESSION['msg']); |
|
104 | + echo $_SESSION['msg']; |
|
105 | + unset($_SESSION['msg']); |
|
106 | 106 | } else { |
107 | - echo '<br />'; |
|
107 | + echo '<br />'; |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | echo $html; |
123 | 123 | echo '<br /><br /><br />'; |
124 | 124 | if (!empty($sublanguage_folder_error)) { |
125 | - Display::display_warning_message($sublanguage_folder_error); |
|
125 | + Display::display_warning_message($sublanguage_folder_error); |
|
126 | 126 | } |
127 | 127 | echo '<div id="div_message_information_id"> </div>'; |
128 | 128 | |
@@ -136,186 +136,186 @@ discard block |
||
136 | 136 | * @return array |
137 | 137 | */ |
138 | 138 | function search_language_term( |
139 | - $term, |
|
140 | - $search_in_variable = true, |
|
141 | - $search_in_english = true, |
|
142 | - $search_in_parent = true, |
|
143 | - $search_in_sub_language = true |
|
139 | + $term, |
|
140 | + $search_in_variable = true, |
|
141 | + $search_in_english = true, |
|
142 | + $search_in_parent = true, |
|
143 | + $search_in_sub_language = true |
|
144 | 144 | ) { |
145 | - //These the $_REQUEST['id'] and the $_REQUEST['sub_language_id'] variables are process in global.inc.php (LOAD LANGUAGE FILES SECTION) |
|
146 | - /* |
|
145 | + //These the $_REQUEST['id'] and the $_REQUEST['sub_language_id'] variables are process in global.inc.php (LOAD LANGUAGE FILES SECTION) |
|
146 | + /* |
|
147 | 147 | These 4 arrays are set in global.inc.php with the condition that will be load from sub_language.php or sub_language_ajax.inc.php |
148 | 148 | $english_language_array |
149 | 149 | $parent_language_array |
150 | 150 | $sub_language_array |
151 | 151 | $language_files_to_load |
152 | 152 | */ |
153 | - global $language_files_to_load, $sub_language_array, $english_language_array, $parent_language_array; |
|
154 | - $language_files_to_load_keys = array_flip($language_files_to_load); |
|
155 | - $array_to_search = $parent_language_array; |
|
156 | - $list_info = array(); |
|
157 | - $term='/'.Security::remove_XSS(trim($_REQUEST['txt_search_word'])).'/i'; |
|
158 | - //@todo optimize this foreach |
|
159 | - foreach ($language_files_to_load as $lang_file) { |
|
160 | - //searching in parent language of the sub language |
|
161 | - if ($search_in_parent) { |
|
162 | - $variables = $parent_language_array[$lang_file]; |
|
163 | - foreach ($variables as $parent_name_variable =>$parent_variable_value) { |
|
164 | - //arrays are avoided |
|
165 | - if (is_array($parent_variable_value)) { |
|
166 | - continue; |
|
167 | - } |
|
168 | - $founded = false; |
|
169 | - // searching the item in the parent tool |
|
170 | - if (preg_match($term,$parent_variable_value)!==0) { |
|
171 | - $founded = true; |
|
172 | - } |
|
173 | - if ($founded) { |
|
174 | - //loading variable from the english array |
|
175 | - $sub_language_name_variable = $sub_language_array[$lang_file][$parent_name_variable]; |
|
176 | - //loading variable from the english array |
|
177 | - $english_name_variable = $english_language_array[$lang_file][$parent_name_variable]; |
|
153 | + global $language_files_to_load, $sub_language_array, $english_language_array, $parent_language_array; |
|
154 | + $language_files_to_load_keys = array_flip($language_files_to_load); |
|
155 | + $array_to_search = $parent_language_array; |
|
156 | + $list_info = array(); |
|
157 | + $term='/'.Security::remove_XSS(trim($_REQUEST['txt_search_word'])).'/i'; |
|
158 | + //@todo optimize this foreach |
|
159 | + foreach ($language_files_to_load as $lang_file) { |
|
160 | + //searching in parent language of the sub language |
|
161 | + if ($search_in_parent) { |
|
162 | + $variables = $parent_language_array[$lang_file]; |
|
163 | + foreach ($variables as $parent_name_variable =>$parent_variable_value) { |
|
164 | + //arrays are avoided |
|
165 | + if (is_array($parent_variable_value)) { |
|
166 | + continue; |
|
167 | + } |
|
168 | + $founded = false; |
|
169 | + // searching the item in the parent tool |
|
170 | + if (preg_match($term,$parent_variable_value)!==0) { |
|
171 | + $founded = true; |
|
172 | + } |
|
173 | + if ($founded) { |
|
174 | + //loading variable from the english array |
|
175 | + $sub_language_name_variable = $sub_language_array[$lang_file][$parent_name_variable]; |
|
176 | + //loading variable from the english array |
|
177 | + $english_name_variable = $english_language_array[$lang_file][$parent_name_variable]; |
|
178 | 178 | |
179 | - //config buttons |
|
180 | - /*if (strlen($english_name_variable)>1500) { |
|
179 | + //config buttons |
|
180 | + /*if (strlen($english_name_variable)>1500) { |
|
181 | 181 | $size =20; |
182 | 182 | } else { |
183 | 183 | $size =4; |
184 | 184 | }*/ |
185 | 185 | |
186 | - $obj_text='<textarea rows="10" cols="40" name="txt|'.$parent_name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="txtid_'.$language_files_to_load_keys[$lang_file].'_'.$parent_name_variable.'" >'.$sub_language_name_variable.'</textarea>'; |
|
187 | - $obj_button='<button class="save" type="button" name="btn|'.$parent_name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="btnid_'.$parent_name_variable.'" />'.get_lang('Save').'</button>'; |
|
186 | + $obj_text='<textarea rows="10" cols="40" name="txt|'.$parent_name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="txtid_'.$language_files_to_load_keys[$lang_file].'_'.$parent_name_variable.'" >'.$sub_language_name_variable.'</textarea>'; |
|
187 | + $obj_button='<button class="save" type="button" name="btn|'.$parent_name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="btnid_'.$parent_name_variable.'" />'.get_lang('Save').'</button>'; |
|
188 | 188 | |
189 | - $list_info[] = array( |
|
190 | - $lang_file . '.inc.php', |
|
191 | - $parent_name_variable, |
|
192 | - $english_name_variable, |
|
193 | - $parent_variable_value, |
|
194 | - $obj_text, |
|
195 | - $obj_button |
|
196 | - ); |
|
197 | - } |
|
198 | - } |
|
199 | - } |
|
189 | + $list_info[] = array( |
|
190 | + $lang_file . '.inc.php', |
|
191 | + $parent_name_variable, |
|
192 | + $english_name_variable, |
|
193 | + $parent_variable_value, |
|
194 | + $obj_text, |
|
195 | + $obj_button |
|
196 | + ); |
|
197 | + } |
|
198 | + } |
|
199 | + } |
|
200 | 200 | |
201 | - //search in english |
|
202 | - if ($search_in_english || $search_in_variable) { |
|
203 | - $variables = $english_language_array[$lang_file]; |
|
204 | - foreach ($variables as $name_variable =>$variable_value) { |
|
205 | - if (is_array($variable_value)) { |
|
206 | - continue; |
|
207 | - } |
|
201 | + //search in english |
|
202 | + if ($search_in_english || $search_in_variable) { |
|
203 | + $variables = $english_language_array[$lang_file]; |
|
204 | + foreach ($variables as $name_variable =>$variable_value) { |
|
205 | + if (is_array($variable_value)) { |
|
206 | + continue; |
|
207 | + } |
|
208 | 208 | |
209 | - if (is_array($variable_value)) |
|
210 | - echo $lang_file; |
|
211 | - $founded = false; |
|
212 | - if ($search_in_english && $search_in_variable) { |
|
213 | - // searching the item in the parent tool |
|
214 | - if (preg_match($term,$variable_value)!==0 || preg_match($term,$name_variable)!==0 ) { |
|
215 | - $founded = true; |
|
216 | - } |
|
217 | - } else { |
|
218 | - if ($search_in_english) { |
|
219 | - if (preg_match($term,$variable_value)!==0) { |
|
220 | - $founded = true; |
|
221 | - } |
|
222 | - } else { |
|
223 | - if (preg_match($term,$name_variable)!==0) { |
|
224 | - $founded = true; |
|
225 | - } |
|
226 | - } |
|
227 | - } |
|
209 | + if (is_array($variable_value)) |
|
210 | + echo $lang_file; |
|
211 | + $founded = false; |
|
212 | + if ($search_in_english && $search_in_variable) { |
|
213 | + // searching the item in the parent tool |
|
214 | + if (preg_match($term,$variable_value)!==0 || preg_match($term,$name_variable)!==0 ) { |
|
215 | + $founded = true; |
|
216 | + } |
|
217 | + } else { |
|
218 | + if ($search_in_english) { |
|
219 | + if (preg_match($term,$variable_value)!==0) { |
|
220 | + $founded = true; |
|
221 | + } |
|
222 | + } else { |
|
223 | + if (preg_match($term,$name_variable)!==0) { |
|
224 | + $founded = true; |
|
225 | + } |
|
226 | + } |
|
227 | + } |
|
228 | 228 | |
229 | - if ($founded) { |
|
230 | - //loading variable from the english array |
|
231 | - $sub_language_name_variable = null; |
|
232 | - if (isset($sub_language_array[$lang_file][$name_variable])) { |
|
233 | - $sub_language_name_variable = $sub_language_array[$lang_file][$name_variable]; |
|
234 | - } |
|
235 | - $parent_variable_value = null; |
|
236 | - if (isset($parent_language_array[$lang_file][$name_variable])) { |
|
237 | - $parent_variable_value = $parent_language_array[$lang_file][$name_variable]; |
|
238 | - } |
|
239 | - //config buttons |
|
240 | - $obj_text='<textarea rows="10" cols="40" name="txt|'.$name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="txtid_'.$language_files_to_load_keys[$lang_file].'_'.$name_variable.'" >'. |
|
241 | - $sub_language_name_variable.' |
|
229 | + if ($founded) { |
|
230 | + //loading variable from the english array |
|
231 | + $sub_language_name_variable = null; |
|
232 | + if (isset($sub_language_array[$lang_file][$name_variable])) { |
|
233 | + $sub_language_name_variable = $sub_language_array[$lang_file][$name_variable]; |
|
234 | + } |
|
235 | + $parent_variable_value = null; |
|
236 | + if (isset($parent_language_array[$lang_file][$name_variable])) { |
|
237 | + $parent_variable_value = $parent_language_array[$lang_file][$name_variable]; |
|
238 | + } |
|
239 | + //config buttons |
|
240 | + $obj_text='<textarea rows="10" cols="40" name="txt|'.$name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="txtid_'.$language_files_to_load_keys[$lang_file].'_'.$name_variable.'" >'. |
|
241 | + $sub_language_name_variable.' |
|
242 | 242 | </textarea>'; |
243 | - $obj_button='<button class="save" type="button" name="btn|'.$name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="btnid_'.$name_variable.'" />'.get_lang('Save').'</button>'; |
|
243 | + $obj_button='<button class="save" type="button" name="btn|'.$name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="btnid_'.$name_variable.'" />'.get_lang('Save').'</button>'; |
|
244 | 244 | |
245 | - //loading variable from the english array |
|
246 | - $english_name_variable = $english_language_array[$lang_file][$name_variable]; |
|
245 | + //loading variable from the english array |
|
246 | + $english_name_variable = $english_language_array[$lang_file][$name_variable]; |
|
247 | 247 | |
248 | - $list_info[] = array( |
|
249 | - $lang_file . '.inc.php', |
|
250 | - $name_variable, |
|
251 | - $english_name_variable, |
|
252 | - $parent_variable_value, |
|
253 | - $obj_text, |
|
254 | - $obj_button |
|
255 | - ); |
|
256 | - } |
|
257 | - } |
|
258 | - } |
|
248 | + $list_info[] = array( |
|
249 | + $lang_file . '.inc.php', |
|
250 | + $name_variable, |
|
251 | + $english_name_variable, |
|
252 | + $parent_variable_value, |
|
253 | + $obj_text, |
|
254 | + $obj_button |
|
255 | + ); |
|
256 | + } |
|
257 | + } |
|
258 | + } |
|
259 | 259 | |
260 | - // Search in sub language |
|
261 | - if ($search_in_sub_language) { |
|
262 | - $variables = $sub_language_array[$lang_file]; |
|
263 | - foreach ($variables as $name_variable =>$variable_value) { |
|
264 | - if (is_array($parent_variable_value)) { |
|
265 | - continue; |
|
266 | - } |
|
260 | + // Search in sub language |
|
261 | + if ($search_in_sub_language) { |
|
262 | + $variables = $sub_language_array[$lang_file]; |
|
263 | + foreach ($variables as $name_variable =>$variable_value) { |
|
264 | + if (is_array($parent_variable_value)) { |
|
265 | + continue; |
|
266 | + } |
|
267 | 267 | |
268 | - if (is_array($variable_value)) { |
|
269 | - continue; |
|
270 | - } |
|
268 | + if (is_array($variable_value)) { |
|
269 | + continue; |
|
270 | + } |
|
271 | 271 | |
272 | - $founded = false; |
|
273 | - // searching the item in the parent tool |
|
274 | - if (preg_match($term,$variable_value)!==0) { |
|
275 | - $founded = true; |
|
276 | - } |
|
277 | - if ($founded) { |
|
278 | - //loading variable from the english array |
|
279 | - $sub_language_name_variable = $sub_language_array[$lang_file][$name_variable]; |
|
280 | - $parent_variable_value = $parent_language_array[$lang_file][$name_variable]; |
|
281 | - //config buttons |
|
282 | - $obj_text='<textarea rows="10" cols="40" name="txt|'.$name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="txtid_'.$language_files_to_load_keys[$lang_file].'_'.$name_variable.'" >'.$sub_language_name_variable.'</textarea>'; |
|
283 | - $obj_button='<button class="save" type="button" name="btn|'.$name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="btnid_'.$name_variable.'" />'.get_lang('Save').'</button>'; |
|
272 | + $founded = false; |
|
273 | + // searching the item in the parent tool |
|
274 | + if (preg_match($term,$variable_value)!==0) { |
|
275 | + $founded = true; |
|
276 | + } |
|
277 | + if ($founded) { |
|
278 | + //loading variable from the english array |
|
279 | + $sub_language_name_variable = $sub_language_array[$lang_file][$name_variable]; |
|
280 | + $parent_variable_value = $parent_language_array[$lang_file][$name_variable]; |
|
281 | + //config buttons |
|
282 | + $obj_text='<textarea rows="10" cols="40" name="txt|'.$name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="txtid_'.$language_files_to_load_keys[$lang_file].'_'.$name_variable.'" >'.$sub_language_name_variable.'</textarea>'; |
|
283 | + $obj_button='<button class="save" type="button" name="btn|'.$name_variable.'|'.$language_files_to_load_keys[$lang_file].'" id="btnid_'.$name_variable.'" />'.get_lang('Save').'</button>'; |
|
284 | 284 | |
285 | - //loading variable from the english array |
|
286 | - $english_name_variable = $english_language_array[$lang_file][$name_variable]; |
|
287 | - $list_info[]=array($lang_file.'.inc.php', |
|
288 | - $name_variable, |
|
289 | - $english_name_variable, |
|
290 | - $parent_variable_value,$obj_text,$obj_button); |
|
291 | - } |
|
292 | - } |
|
293 | - } |
|
294 | - } |
|
285 | + //loading variable from the english array |
|
286 | + $english_name_variable = $english_language_array[$lang_file][$name_variable]; |
|
287 | + $list_info[]=array($lang_file.'.inc.php', |
|
288 | + $name_variable, |
|
289 | + $english_name_variable, |
|
290 | + $parent_variable_value,$obj_text,$obj_button); |
|
291 | + } |
|
292 | + } |
|
293 | + } |
|
294 | + } |
|
295 | 295 | |
296 | - $list_info = array_unique_dimensional($list_info); |
|
297 | - return $list_info; |
|
296 | + $list_info = array_unique_dimensional($list_info); |
|
297 | + return $list_info; |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | // Allow see data in sort table |
301 | 301 | $list_info = array(); |
302 | 302 | if (isset($_REQUEST['txt_search_word'])) { |
303 | - //@todo fix to accept a char with 1 char |
|
304 | - if (strlen(trim($_REQUEST['txt_search_word']))>2) { |
|
305 | - $list_info = search_language_term( |
|
306 | - $_REQUEST['txt_search_word'], |
|
307 | - true, |
|
308 | - true, |
|
309 | - true, |
|
310 | - true |
|
311 | - ); |
|
312 | - } |
|
303 | + //@todo fix to accept a char with 1 char |
|
304 | + if (strlen(trim($_REQUEST['txt_search_word']))>2) { |
|
305 | + $list_info = search_language_term( |
|
306 | + $_REQUEST['txt_search_word'], |
|
307 | + true, |
|
308 | + true, |
|
309 | + true, |
|
310 | + true |
|
311 | + ); |
|
312 | + } |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | $parameters = array( |
316 | - 'id' => intval($_GET['id']), |
|
317 | - 'sub_language_id' => intval($_GET['sub_language_id']), |
|
318 | - 'txt_search_word' => $txt_search_word |
|
316 | + 'id' => intval($_GET['id']), |
|
317 | + 'sub_language_id' => intval($_GET['sub_language_id']), |
|
318 | + 'txt_search_word' => $txt_search_word |
|
319 | 319 | ); |
320 | 320 | $table = new SortableTableFromArrayConfig($list_info, 1,20,'data_info'); |
321 | 321 | $table->set_additional_parameters($parameters); |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | $sessionId = api_get_session_id(); |
66 | 66 | |
67 | 67 | if (api_is_in_group()) { |
68 | - $group_properties = GroupManager::get_group_properties($group_id); |
|
68 | + $group_properties = GroupManager::get_group_properties($group_id); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | $dir = '/'; |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | $_GET['id'], |
78 | 78 | api_get_course_id(), |
79 | 79 | true, |
80 | - 0 |
|
80 | + 0 |
|
81 | 81 | ); |
82 | 82 | |
83 | 83 | if (!empty($sessionId) && empty($document_data)) { |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | ); |
90 | 90 | } |
91 | 91 | |
92 | - $document_id = $document_data['id']; |
|
93 | - $file = $document_data['path']; |
|
94 | - $parent_id = DocumentManager::get_document_id($course_info, dirname($file)); |
|
95 | - $dir = dirname($document_data['path']); |
|
96 | - $dir_original = $dir; |
|
97 | - $doc = basename($file); |
|
98 | - $readonly = $document_data['readonly']; |
|
92 | + $document_id = $document_data['id']; |
|
93 | + $file = $document_data['path']; |
|
94 | + $parent_id = DocumentManager::get_document_id($course_info, dirname($file)); |
|
95 | + $dir = dirname($document_data['path']); |
|
96 | + $dir_original = $dir; |
|
97 | + $doc = basename($file); |
|
98 | + $readonly = $document_data['readonly']; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | if (empty($document_data)) { |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | |
118 | 118 | // Level correction for group documents. |
119 | 119 | if (!empty($group_properties['directory'])) { |
120 | - $count_dir = $count_dir > 0 ? $count_dir - 1 : 0; |
|
120 | + $count_dir = $count_dir > 0 ? $count_dir - 1 : 0; |
|
121 | 121 | } |
122 | 122 | $relative_url = ''; |
123 | 123 | for ($i = 0; $i < ($count_dir); $i++) { |
@@ -139,13 +139,13 @@ discard block |
||
139 | 139 | ); |
140 | 140 | |
141 | 141 | if ($is_certificate_mode) { |
142 | - $editorConfig['CreateDocumentDir'] = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/'; |
|
143 | - $editorConfig['CreateDocumentWebDir'] = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/'; |
|
144 | - $editorConfig['BaseHref'] = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$dir; |
|
142 | + $editorConfig['CreateDocumentDir'] = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/'; |
|
143 | + $editorConfig['CreateDocumentWebDir'] = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/'; |
|
144 | + $editorConfig['BaseHref'] = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$dir; |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | $is_allowed_to_edit = api_is_allowed_to_edit(null, true) || $_SESSION['group_member_with_upload_rights']|| |
148 | - DocumentManager::is_my_shared_folder(api_get_user_id(), $dir, $sessionId); |
|
148 | + DocumentManager::is_my_shared_folder(api_get_user_id(), $dir, $sessionId); |
|
149 | 149 | $noPHP_SELF = true; |
150 | 150 | |
151 | 151 | /* Other initialization code */ |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | 'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(), |
159 | 159 | 'name' => get_lang('GroupSpace'), |
160 | 160 | ); |
161 | - $group_document = true; |
|
162 | - $noPHP_SELF = true; |
|
161 | + $group_document = true; |
|
162 | + $noPHP_SELF = true; |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | if (!$is_certificate_mode) { |
@@ -193,9 +193,9 @@ discard block |
||
193 | 193 | |
194 | 194 | //TODO:check the below code and his funcionality |
195 | 195 | if (!api_is_allowed_to_edit()) { |
196 | - if (DocumentManager::check_readonly($course_info, $user_id, $file)) { |
|
197 | - api_not_allowed(); |
|
198 | - } |
|
196 | + if (DocumentManager::check_readonly($course_info, $user_id, $file)) { |
|
197 | + api_not_allowed(); |
|
198 | + } |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /* MAIN TOOL CODE */ |
@@ -203,18 +203,18 @@ discard block |
||
203 | 203 | /* Code to change the comment */ |
204 | 204 | |
205 | 205 | if (isset($_POST['comment'])) { |
206 | - // Fixing the path if it is wrong |
|
207 | - $comment = trim($_POST['comment']); |
|
208 | - $title = trim($_POST['title']); |
|
206 | + // Fixing the path if it is wrong |
|
207 | + $comment = trim($_POST['comment']); |
|
208 | + $title = trim($_POST['title']); |
|
209 | 209 | |
210 | 210 | // Just in case see BT#3525 |
211 | 211 | if (empty($title)) { |
212 | - $title = $document_data['title']; |
|
213 | - } |
|
212 | + $title = $document_data['title']; |
|
213 | + } |
|
214 | 214 | |
215 | - if (empty($title)) { |
|
216 | - $title = get_document_title($_POST['filename']); |
|
217 | - } |
|
215 | + if (empty($title)) { |
|
216 | + $title = get_document_title($_POST['filename']); |
|
217 | + } |
|
218 | 218 | |
219 | 219 | if (!empty($document_id)) { |
220 | 220 | $params = [ |
@@ -226,43 +226,43 @@ discard block |
||
226 | 226 | $params, |
227 | 227 | ['c_id = ? AND id = ?' => [$course_id, $document_id]] |
228 | 228 | ); |
229 | - Display::addFlash(Display::return_message(get_lang('fileModified'))); |
|
229 | + Display::addFlash(Display::return_message(get_lang('fileModified'))); |
|
230 | 230 | } |
231 | 231 | } |
232 | 232 | |
233 | 233 | /* WYSIWYG HTML EDITOR - Program Logic */ |
234 | 234 | if ($is_allowed_to_edit) { |
235 | - if (isset($_POST['formSent']) && $_POST['formSent'] == 1) { |
|
235 | + if (isset($_POST['formSent']) && $_POST['formSent'] == 1) { |
|
236 | 236 | |
237 | - $filename = stripslashes($_POST['filename']); |
|
237 | + $filename = stripslashes($_POST['filename']); |
|
238 | 238 | $extension = $_POST['extension']; |
239 | - $content = isset($_POST['content']) ? trim(str_replace(array("\r", "\n"), '', stripslashes($_POST['content']))) : null; |
|
240 | - $content = Security::remove_XSS($content, COURSEMANAGERLOWSECURITY); |
|
239 | + $content = isset($_POST['content']) ? trim(str_replace(array("\r", "\n"), '', stripslashes($_POST['content']))) : null; |
|
240 | + $content = Security::remove_XSS($content, COURSEMANAGERLOWSECURITY); |
|
241 | 241 | |
242 | 242 | if ($dir == '/') { |
243 | 243 | $dir = ''; |
244 | 244 | } |
245 | 245 | |
246 | - $file = $dir.'/'.$filename.'.'.$extension; |
|
247 | - $read_only_flag = isset($_POST['readonly']) ? $_POST['readonly'] : null; |
|
248 | - $read_only_flag = empty($read_only_flag) ? 0 : 1; |
|
246 | + $file = $dir.'/'.$filename.'.'.$extension; |
|
247 | + $read_only_flag = isset($_POST['readonly']) ? $_POST['readonly'] : null; |
|
248 | + $read_only_flag = empty($read_only_flag) ? 0 : 1; |
|
249 | 249 | |
250 | - if (empty($filename)) { |
|
250 | + if (empty($filename)) { |
|
251 | 251 | Display::addFlash(Display::return_message(get_lang('NoFileName'), 'warning')); |
252 | - } else { |
|
252 | + } else { |
|
253 | 253 | |
254 | - $file_size = filesize($document_data['absolute_path']); |
|
254 | + $file_size = filesize($document_data['absolute_path']); |
|
255 | 255 | |
256 | - if ($read_only_flag == 0) { |
|
257 | - if (!empty($content)) { |
|
258 | - if ($fp = @fopen($document_data['absolute_path'], 'w')) { |
|
259 | - // For flv player, change absolute path temporarily to prevent from erasing it in the following lines |
|
260 | - $content = str_replace(array('flv=h', 'flv=/'), array('flv=h|', 'flv=/|'), $content); |
|
261 | - fputs($fp, $content); |
|
262 | - fclose($fp); |
|
256 | + if ($read_only_flag == 0) { |
|
257 | + if (!empty($content)) { |
|
258 | + if ($fp = @fopen($document_data['absolute_path'], 'w')) { |
|
259 | + // For flv player, change absolute path temporarily to prevent from erasing it in the following lines |
|
260 | + $content = str_replace(array('flv=h', 'flv=/'), array('flv=h|', 'flv=/|'), $content); |
|
261 | + fputs($fp, $content); |
|
262 | + fclose($fp); |
|
263 | 263 | |
264 | 264 | $filepath = $document_data['absolute_parent_path']; |
265 | - /* |
|
265 | + /* |
|
266 | 266 | if (!is_dir($filepath.'css')) { |
267 | 267 | mkdir($filepath.'css', api_get_permissions_for_new_directories()); |
268 | 268 | $doc_id = add_document($_course, $dir.'css', 'folder', 0, 'css'); |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | ); |
293 | 293 | }*/ |
294 | 294 | |
295 | - /*if (!is_file($filepath.'css/frames.css')) { |
|
295 | + /*if (!is_file($filepath.'css/frames.css')) { |
|
296 | 296 | $platform_theme = api_get_setting('stylesheets'); |
297 | 297 | if (file_exists(api_get_path(SYS_CODE_PATH).'css/'.$platform_theme.'/frames.css')) { |
298 | 298 | copy(api_get_path(SYS_CODE_PATH).'css/'.$platform_theme.'/frames.css', $filepath.'css/frames.css'); |
@@ -330,54 +330,54 @@ discard block |
||
330 | 330 | } |
331 | 331 | }*/ |
332 | 332 | |
333 | - // "WHAT'S NEW" notification: update table item_property |
|
334 | - $document_id = DocumentManager::get_document_id($_course, $file); |
|
335 | - |
|
336 | - if ($document_id) { |
|
337 | - update_existing_document( |
|
338 | - $_course, |
|
339 | - $document_id, |
|
340 | - $file_size, |
|
341 | - $read_only_flag |
|
342 | - ); |
|
343 | - api_item_property_update( |
|
344 | - $_course, |
|
345 | - TOOL_DOCUMENT, |
|
346 | - $document_id, |
|
347 | - 'DocumentUpdated', |
|
348 | - api_get_user_id(), |
|
349 | - null, |
|
350 | - null, |
|
351 | - null, |
|
352 | - null, |
|
353 | - $sessionId |
|
354 | - ); |
|
355 | - // Update parent folders |
|
356 | - item_property_update_on_folder( |
|
357 | - $_course, |
|
358 | - $dir, |
|
359 | - api_get_user_id() |
|
360 | - ); |
|
361 | - header('Location: document.php?id=' . $document_data['parent_id'] . '&' . api_get_cidreq() . ($is_certificate_mode?'&curdirpath=/certificates&selectcat=1':'')); |
|
362 | - exit; |
|
363 | - } else { |
|
333 | + // "WHAT'S NEW" notification: update table item_property |
|
334 | + $document_id = DocumentManager::get_document_id($_course, $file); |
|
335 | + |
|
336 | + if ($document_id) { |
|
337 | + update_existing_document( |
|
338 | + $_course, |
|
339 | + $document_id, |
|
340 | + $file_size, |
|
341 | + $read_only_flag |
|
342 | + ); |
|
343 | + api_item_property_update( |
|
344 | + $_course, |
|
345 | + TOOL_DOCUMENT, |
|
346 | + $document_id, |
|
347 | + 'DocumentUpdated', |
|
348 | + api_get_user_id(), |
|
349 | + null, |
|
350 | + null, |
|
351 | + null, |
|
352 | + null, |
|
353 | + $sessionId |
|
354 | + ); |
|
355 | + // Update parent folders |
|
356 | + item_property_update_on_folder( |
|
357 | + $_course, |
|
358 | + $dir, |
|
359 | + api_get_user_id() |
|
360 | + ); |
|
361 | + header('Location: document.php?id=' . $document_data['parent_id'] . '&' . api_get_cidreq() . ($is_certificate_mode?'&curdirpath=/certificates&selectcat=1':'')); |
|
362 | + exit; |
|
363 | + } else { |
|
364 | 364 | Display::addFlash(Display::return_message(get_lang('Impossible'), 'warning')); |
365 | - } |
|
366 | - } else { |
|
365 | + } |
|
366 | + } else { |
|
367 | 367 | Display::addFlash(Display::return_message(get_lang('Impossible'), 'warning')); |
368 | - } |
|
369 | - } else { |
|
370 | - if ($document_id) { |
|
368 | + } |
|
369 | + } else { |
|
370 | + if ($document_id) { |
|
371 | 371 | update_existing_document($_course, $document_id, $file_size, $read_only_flag); |
372 | - } |
|
373 | - } |
|
374 | - } else { |
|
372 | + } |
|
373 | + } |
|
374 | + } else { |
|
375 | 375 | if ($document_id) { |
376 | 376 | update_existing_document($_course, $document_id, $file_size, $read_only_flag); |
377 | 377 | } |
378 | - } |
|
379 | - } |
|
380 | - } |
|
378 | + } |
|
379 | + } |
|
380 | + } |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | // Replace relative paths by absolute web paths (e.g. './' => 'http://www.chamilo.org/courses/ABC/document/') |
@@ -431,35 +431,35 @@ discard block |
||
431 | 431 | api_get_group_id() |
432 | 432 | ) |
433 | 433 | ) { |
434 | - $action = api_get_self().'?id='.$document_data['id'].'&'.api_get_cidreq(); |
|
434 | + $action = api_get_self().'?id='.$document_data['id'].'&'.api_get_cidreq(); |
|
435 | 435 | if ($is_certificate_mode) { |
436 | 436 | $action .= '&curdirpath=/certificates&selectcat=1'; |
437 | 437 | } |
438 | - $form = new FormValidator('formEdit', 'post', $action, null, array('class' => 'form-vertical')); |
|
439 | - |
|
440 | - // Form title |
|
441 | - $form->addElement('header', $nameTools); |
|
442 | - $form->addElement('hidden', 'filename'); |
|
443 | - $form->addElement('hidden', 'extension'); |
|
444 | - $form->addElement('hidden', 'file_path'); |
|
445 | - $form->addElement('hidden', 'commentPath'); |
|
446 | - $form->addElement('hidden', 'showedit'); |
|
447 | - $form->addElement('hidden', 'origin'); |
|
448 | - $form->addElement('hidden', 'origin_opt'); |
|
438 | + $form = new FormValidator('formEdit', 'post', $action, null, array('class' => 'form-vertical')); |
|
439 | + |
|
440 | + // Form title |
|
441 | + $form->addElement('header', $nameTools); |
|
442 | + $form->addElement('hidden', 'filename'); |
|
443 | + $form->addElement('hidden', 'extension'); |
|
444 | + $form->addElement('hidden', 'file_path'); |
|
445 | + $form->addElement('hidden', 'commentPath'); |
|
446 | + $form->addElement('hidden', 'showedit'); |
|
447 | + $form->addElement('hidden', 'origin'); |
|
448 | + $form->addElement('hidden', 'origin_opt'); |
|
449 | 449 | $form->addText('title', get_lang('Title'), true, array('cols-size' => [2, 10, 0], 'autofocus')); |
450 | 450 | |
451 | - $defaults['title'] = $document_data['title']; |
|
451 | + $defaults['title'] = $document_data['title']; |
|
452 | 452 | |
453 | - $form->addElement('hidden', 'formSent'); |
|
454 | - $defaults['formSent'] = 1; |
|
453 | + $form->addElement('hidden', 'formSent'); |
|
454 | + $defaults['formSent'] = 1; |
|
455 | 455 | |
456 | - $read_only_flag = isset($_POST['readonly']) ? $_POST['readonly'] : null; |
|
456 | + $read_only_flag = isset($_POST['readonly']) ? $_POST['readonly'] : null; |
|
457 | 457 | |
458 | - // Desactivation of IE proprietary commenting tags inside the text before loading it on the online editor. |
|
459 | - // This fix has been proposed by Hubert Borderiou, see Bug #573, http://support.chamilo.org/issues/573 |
|
460 | - $defaults['content'] = str_replace('<!--[', '<!-- [', $content); |
|
458 | + // Desactivation of IE proprietary commenting tags inside the text before loading it on the online editor. |
|
459 | + // This fix has been proposed by Hubert Borderiou, see Bug #573, http://support.chamilo.org/issues/573 |
|
460 | + $defaults['content'] = str_replace('<!--[', '<!-- [', $content); |
|
461 | 461 | |
462 | - // HotPotatoes tests are html files, but they should not be edited in order their functionality to be preserved. |
|
462 | + // HotPotatoes tests are html files, but they should not be edited in order their functionality to be preserved. |
|
463 | 463 | |
464 | 464 | $showSystemFolders = api_get_course_setting('show_system_folders'); |
465 | 465 | $condition = stripos($dir, '/HotPotatoes_files') === false; |
@@ -467,44 +467,44 @@ discard block |
||
467 | 467 | $condition = true; |
468 | 468 | } |
469 | 469 | |
470 | - if (($extension == 'htm' || $extension == 'html') && $condition) { |
|
471 | - if (empty($readonly) && $readonly == 0) { |
|
470 | + if (($extension == 'htm' || $extension == 'html') && $condition) { |
|
471 | + if (empty($readonly) && $readonly == 0) { |
|
472 | 472 | $form->addHtmlEditor('content', '', true, true, $editorConfig); |
473 | - } |
|
474 | - } |
|
473 | + } |
|
474 | + } |
|
475 | 475 | |
476 | - if (!$group_document && !DocumentManager::is_my_shared_folder(api_get_user_id(), $currentDirPath, $sessionId)) { |
|
477 | - // Updated on field |
|
476 | + if (!$group_document && !DocumentManager::is_my_shared_folder(api_get_user_id(), $currentDirPath, $sessionId)) { |
|
477 | + // Updated on field |
|
478 | 478 | $display_date = date_to_str_ago($last_edit_date). |
479 | - ' <span class="dropbox_date">'.api_format_date(api_get_local_time($last_edit_date)).'</span>'; |
|
480 | - $form->addElement('static', null, get_lang('UpdatedOn'), $display_date); |
|
481 | - } |
|
479 | + ' <span class="dropbox_date">'.api_format_date(api_get_local_time($last_edit_date)).'</span>'; |
|
480 | + $form->addElement('static', null, get_lang('UpdatedOn'), $display_date); |
|
481 | + } |
|
482 | 482 | |
483 | - $form->addElement('textarea', 'comment', get_lang('Comment'), ['cols-size' => [2, 10, 0]]); |
|
483 | + $form->addElement('textarea', 'comment', get_lang('Comment'), ['cols-size' => [2, 10, 0]]); |
|
484 | 484 | |
485 | - if ($owner_id == api_get_user_id() || api_is_platform_admin()) { |
|
486 | - $checked =& $form->addElement('checkbox', 'readonly', null, get_lang('ReadOnly')); |
|
487 | - if ($readonly == 1) { |
|
488 | - $checked->setChecked(true); |
|
489 | - } |
|
490 | - } |
|
485 | + if ($owner_id == api_get_user_id() || api_is_platform_admin()) { |
|
486 | + $checked =& $form->addElement('checkbox', 'readonly', null, get_lang('ReadOnly')); |
|
487 | + if ($readonly == 1) { |
|
488 | + $checked->setChecked(true); |
|
489 | + } |
|
490 | + } |
|
491 | 491 | |
492 | - if ($is_certificate_mode) { |
|
493 | - $form->addButtonUpdate(get_lang('SaveCertificate')); |
|
492 | + if ($is_certificate_mode) { |
|
493 | + $form->addButtonUpdate(get_lang('SaveCertificate')); |
|
494 | 494 | } else { |
495 | - $form->addButtonUpdate(get_lang('SaveDocument')); |
|
495 | + $form->addButtonUpdate(get_lang('SaveDocument')); |
|
496 | 496 | } |
497 | 497 | |
498 | - $defaults['filename'] = $filename; |
|
499 | - $defaults['extension'] = $extension; |
|
500 | - $defaults['file_path'] = isset($_GET['file']) ? Security::remove_XSS($_GET['file']) : null; |
|
501 | - $defaults['commentPath'] = $file; |
|
502 | - $defaults['renameTo'] = $file_name; |
|
503 | - $defaults['comment'] = $document_data['comment']; |
|
504 | - $defaults['origin'] = isset($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : null; |
|
505 | - $defaults['origin_opt'] = isset($_GET['origin_opt']) ? Security::remove_XSS($_GET['origin_opt']) : null; |
|
498 | + $defaults['filename'] = $filename; |
|
499 | + $defaults['extension'] = $extension; |
|
500 | + $defaults['file_path'] = isset($_GET['file']) ? Security::remove_XSS($_GET['file']) : null; |
|
501 | + $defaults['commentPath'] = $file; |
|
502 | + $defaults['renameTo'] = $file_name; |
|
503 | + $defaults['comment'] = $document_data['comment']; |
|
504 | + $defaults['origin'] = isset($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : null; |
|
505 | + $defaults['origin_opt'] = isset($_GET['origin_opt']) ? Security::remove_XSS($_GET['origin_opt']) : null; |
|
506 | 506 | |
507 | - $form->setDefaults($defaults); |
|
507 | + $form->setDefaults($defaults); |
|
508 | 508 | |
509 | 509 | show_return( |
510 | 510 | $parent_id, |
@@ -514,25 +514,25 @@ discard block |
||
514 | 514 | $is_certificate_mode |
515 | 515 | ); |
516 | 516 | |
517 | - if ($is_certificate_mode) { |
|
518 | - $all_information_by_create_certificate = DocumentManager::get_all_info_to_certificate( |
|
519 | - api_get_user_id(), |
|
520 | - api_get_course_id() |
|
521 | - ); |
|
522 | - $str_info = ''; |
|
523 | - foreach ($all_information_by_create_certificate[0] as $info_value) { |
|
524 | - $str_info .= $info_value.'<br/>'; |
|
525 | - } |
|
526 | - $create_certificate=get_lang('CreateCertificateWithTags'); |
|
527 | - Display::display_normal_message( |
|
528 | - $create_certificate.': <br /><br />'.$str_info, |
|
529 | - false |
|
530 | - ); |
|
531 | - } |
|
532 | - |
|
533 | - if ($extension=='svg' && !api_browser_support('svg') && api_get_setting('enabled_support_svg') == 'true'){ |
|
534 | - Display::display_warning_message(get_lang('BrowserDontSupportsSVG')); |
|
535 | - } |
|
517 | + if ($is_certificate_mode) { |
|
518 | + $all_information_by_create_certificate = DocumentManager::get_all_info_to_certificate( |
|
519 | + api_get_user_id(), |
|
520 | + api_get_course_id() |
|
521 | + ); |
|
522 | + $str_info = ''; |
|
523 | + foreach ($all_information_by_create_certificate[0] as $info_value) { |
|
524 | + $str_info .= $info_value.'<br/>'; |
|
525 | + } |
|
526 | + $create_certificate=get_lang('CreateCertificateWithTags'); |
|
527 | + Display::display_normal_message( |
|
528 | + $create_certificate.': <br /><br />'.$str_info, |
|
529 | + false |
|
530 | + ); |
|
531 | + } |
|
532 | + |
|
533 | + if ($extension=='svg' && !api_browser_support('svg') && api_get_setting('enabled_support_svg') == 'true'){ |
|
534 | + Display::display_warning_message(get_lang('BrowserDontSupportsSVG')); |
|
535 | + } |
|
536 | 536 | echo '<div class="row" style="overflow:hidden"> |
537 | 537 | <div id="template_col" class="col-md-2"> |
538 | 538 | <div class="panel panel-default"> |
@@ -560,58 +560,58 @@ discard block |
||
560 | 560 | */ |
561 | 561 | function change_name($base_work_dir, $source_file, $rename_to, $dir, $doc) |
562 | 562 | { |
563 | - $file_name_for_change = $base_work_dir.$dir.$source_file; |
|
563 | + $file_name_for_change = $base_work_dir.$dir.$source_file; |
|
564 | 564 | $rename_to = disable_dangerous_file($rename_to); // Avoid renaming to .htaccess file |
565 | - $rename_to = my_rename($file_name_for_change, stripslashes($rename_to)); // fileManage API |
|
566 | - |
|
567 | - if ($rename_to) { |
|
568 | - if (isset($dir) && $dir != '') { |
|
569 | - $source_file = $dir.$source_file; |
|
570 | - $new_full_file_name = dirname($source_file).'/'.$rename_to; |
|
571 | - } else { |
|
572 | - $source_file = '/'.$source_file; |
|
573 | - $new_full_file_name = '/'.$rename_to; |
|
574 | - } |
|
575 | - |
|
576 | - update_db_info('update', $source_file, $new_full_file_name); // fileManage API |
|
565 | + $rename_to = my_rename($file_name_for_change, stripslashes($rename_to)); // fileManage API |
|
566 | + |
|
567 | + if ($rename_to) { |
|
568 | + if (isset($dir) && $dir != '') { |
|
569 | + $source_file = $dir.$source_file; |
|
570 | + $new_full_file_name = dirname($source_file).'/'.$rename_to; |
|
571 | + } else { |
|
572 | + $source_file = '/'.$source_file; |
|
573 | + $new_full_file_name = '/'.$rename_to; |
|
574 | + } |
|
575 | + |
|
576 | + update_db_info('update', $source_file, $new_full_file_name); // fileManage API |
|
577 | 577 | Display::addFlash(Display::return_message(get_lang('fileModified'))); |
578 | 578 | |
579 | - return true; |
|
580 | - } else { |
|
579 | + return true; |
|
580 | + } else { |
|
581 | 581 | Display::addFlash(Display::return_message(get_lang('FileExists'))); |
582 | - } |
|
582 | + } |
|
583 | 583 | } |
584 | 584 | |
585 | 585 | //return button back to |
586 | 586 | function show_return($document_id, $path, $call_from_tool='', $slide_id=0, $is_certificate_mode=false) |
587 | 587 | { |
588 | 588 | global $parent_id; |
589 | - echo '<div class="actions">'; |
|
589 | + echo '<div class="actions">'; |
|
590 | 590 | |
591 | 591 | $url = api_get_path(WEB_CODE_PATH).'document/document.php?'.api_get_cidreq().'&id='.$parent_id; |
592 | 592 | |
593 | - if ($is_certificate_mode) { |
|
594 | - $selectedCategory = (isset($_GET['curdirpath']) ? Security::remove_XSS($_GET['curdirpath']) : ''); |
|
595 | - echo '<a href="document.php?curdirpath='. $selectedCategory .'&selectcat=' . $selectedCategory .'">'. |
|
593 | + if ($is_certificate_mode) { |
|
594 | + $selectedCategory = (isset($_GET['curdirpath']) ? Security::remove_XSS($_GET['curdirpath']) : ''); |
|
595 | + echo '<a href="document.php?curdirpath='. $selectedCategory .'&selectcat=' . $selectedCategory .'">'. |
|
596 | 596 | Display::return_icon('back.png',get_lang('Back').' '.get_lang('To').' '.get_lang('CertificateOverview'),'',ICON_SIZE_MEDIUM).'</a>'; |
597 | - } elseif($call_from_tool=='slideshow') { |
|
598 | - echo '<a href="'.api_get_path(WEB_PATH).'main/document/slideshow.php?slide_id='.$slide_id.'&curdirpath='.Security::remove_XSS(urlencode($_GET['curdirpath'])).'">'. |
|
597 | + } elseif($call_from_tool=='slideshow') { |
|
598 | + echo '<a href="'.api_get_path(WEB_PATH).'main/document/slideshow.php?slide_id='.$slide_id.'&curdirpath='.Security::remove_XSS(urlencode($_GET['curdirpath'])).'">'. |
|
599 | 599 | Display::return_icon('slideshow.png', get_lang('BackTo').' '.get_lang('ViewSlideshow'),'',ICON_SIZE_MEDIUM).'</a>'; |
600 | - } elseif($call_from_tool=='editdraw') { |
|
601 | - echo '<a href="'.$url.'">'. |
|
600 | + } elseif($call_from_tool=='editdraw') { |
|
601 | + echo '<a href="'.$url.'">'. |
|
602 | 602 | Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'),'',ICON_SIZE_MEDIUM).'</a>'; |
603 | - echo '<a href="javascript:history.back(1)">'.Display::return_icon('draw.png', get_lang('BackTo').' '.get_lang('Draw'), array(), 32).'</a>'; |
|
604 | - } elseif($call_from_tool=='editodf') { |
|
603 | + echo '<a href="javascript:history.back(1)">'.Display::return_icon('draw.png', get_lang('BackTo').' '.get_lang('Draw'), array(), 32).'</a>'; |
|
604 | + } elseif($call_from_tool=='editodf') { |
|
605 | 605 | echo '<a href="'.$url.'">'. |
606 | 606 | Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'),'',ICON_SIZE_MEDIUM).'</a>'; |
607 | 607 | echo '<a href="javascript:history.back(1)">'.Display::return_icon('draw.png', get_lang('BackTo').' '.get_lang('Write'), array(), 32).'</a>'; |
608 | 608 | } elseif($call_from_tool=='editpaint'){ |
609 | - echo '<a href="'.$url.'">'. |
|
609 | + echo '<a href="'.$url.'">'. |
|
610 | 610 | Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'), array(), ICON_SIZE_MEDIUM).'</a>'; |
611 | - echo '<a href="javascript:history.back(1)">'.Display::return_icon('paint.png', get_lang('BackTo').' '.get_lang('Paint'), array(), 32).'</a>'; |
|
612 | - } else { |
|
613 | - echo '<a href="'.$url.'">'. |
|
611 | + echo '<a href="javascript:history.back(1)">'.Display::return_icon('paint.png', get_lang('BackTo').' '.get_lang('Paint'), array(), 32).'</a>'; |
|
612 | + } else { |
|
613 | + echo '<a href="'.$url.'">'. |
|
614 | 614 | Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'),'',ICON_SIZE_MEDIUM).'</a>'; |
615 | - } |
|
616 | - echo '</div>'; |
|
615 | + } |
|
616 | + echo '</div>'; |
|
617 | 617 | } |
@@ -15,15 +15,15 @@ discard block |
||
15 | 15 | { |
16 | 16 | } |
17 | 17 | |
18 | - /** |
|
19 | - * Add a new Term and Condition |
|
20 | - * @param int $language language id |
|
21 | - * @param string $content content |
|
22 | - * @param int $type term and condition type (0 or 1) |
|
23 | - * @param string $changes explain changes |
|
24 | - * @return boolean success |
|
25 | - */ |
|
26 | - public static function add($language, $content, $type, $changes) |
|
18 | + /** |
|
19 | + * Add a new Term and Condition |
|
20 | + * @param int $language language id |
|
21 | + * @param string $content content |
|
22 | + * @param int $type term and condition type (0 or 1) |
|
23 | + * @param string $changes explain changes |
|
24 | + * @return boolean success |
|
25 | + */ |
|
26 | + public static function add($language, $content, $type, $changes) |
|
27 | 27 | { |
28 | 28 | $legal_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
29 | 29 | $last = self::get_last_condition($language); |
@@ -64,59 +64,59 @@ discard block |
||
64 | 64 | /** |
65 | 65 | * @param int $id |
66 | 66 | */ |
67 | - public static function delete($id) |
|
67 | + public static function delete($id) |
|
68 | 68 | { |
69 | - /* |
|
69 | + /* |
|
70 | 70 | $legal_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
71 | 71 | $id = intval($id); |
72 | 72 | $sql = "DELETE FROM $legal_table WHERE id = '".$id."'"; |
73 | 73 | */ |
74 | - } |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * Gets the last version of a Term and condition by language |
|
78 | - * @param int $language language id |
|
79 | - * @return array all the info of a Term and condition |
|
80 | - */ |
|
81 | - public static function get_last_condition_version($language) |
|
76 | + /** |
|
77 | + * Gets the last version of a Term and condition by language |
|
78 | + * @param int $language language id |
|
79 | + * @return array all the info of a Term and condition |
|
80 | + */ |
|
81 | + public static function get_last_condition_version($language) |
|
82 | 82 | { |
83 | - $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
|
84 | - $language= Database::escape_string($language); |
|
85 | - $sql = "SELECT version FROM $legal_conditions_table |
|
83 | + $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
|
84 | + $language= Database::escape_string($language); |
|
85 | + $sql = "SELECT version FROM $legal_conditions_table |
|
86 | 86 | WHERE language_id = '".$language."' |
87 | 87 | ORDER BY id DESC LIMIT 1 "; |
88 | - $result = Database::query($sql); |
|
89 | - $row = Database::fetch_array($result); |
|
88 | + $result = Database::query($sql); |
|
89 | + $row = Database::fetch_array($result); |
|
90 | 90 | if (Database::num_rows($result) > 0) { |
91 | 91 | |
92 | - return $row['version']; |
|
93 | - } else { |
|
92 | + return $row['version']; |
|
93 | + } else { |
|
94 | 94 | |
95 | - return 0; |
|
96 | - } |
|
97 | - } |
|
95 | + return 0; |
|
96 | + } |
|
97 | + } |
|
98 | 98 | |
99 | - /** |
|
100 | - * Gets the data of a Term and condition by language |
|
101 | - * @param int $language language id |
|
102 | - * @return array all the info of a Term and condition |
|
103 | - */ |
|
104 | - public static function get_last_condition($language) |
|
99 | + /** |
|
100 | + * Gets the data of a Term and condition by language |
|
101 | + * @param int $language language id |
|
102 | + * @return array all the info of a Term and condition |
|
103 | + */ |
|
104 | + public static function get_last_condition($language) |
|
105 | 105 | { |
106 | - $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
|
107 | - $language= Database::escape_string($language); |
|
108 | - $sql = "SELECT * FROM $legal_conditions_table |
|
106 | + $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
|
107 | + $language= Database::escape_string($language); |
|
108 | + $sql = "SELECT * FROM $legal_conditions_table |
|
109 | 109 | WHERE language_id = '".$language."' |
110 | 110 | ORDER BY version DESC |
111 | 111 | LIMIT 1 "; |
112 | - $result = Database::query($sql); |
|
113 | - $result = Database::fetch_array($result, 'ASSOC'); |
|
112 | + $result = Database::query($sql); |
|
113 | + $result = Database::fetch_array($result, 'ASSOC'); |
|
114 | 114 | |
115 | 115 | if (isset($result['content'])) { |
116 | 116 | $result['content'] = self::replaceTags($result['content']); |
117 | 117 | } |
118 | 118 | return $result; |
119 | - } |
|
119 | + } |
|
120 | 120 | |
121 | 121 | /** |
122 | 122 | * @param string $content |
@@ -141,12 +141,12 @@ discard block |
||
141 | 141 | return $content; |
142 | 142 | } |
143 | 143 | |
144 | - /** |
|
145 | - * Gets the last version of a Term and condition by language |
|
146 | - * @param int $language language id |
|
147 | - * @return boolean | int the version or false if does not exist |
|
148 | - */ |
|
149 | - public static function get_last_version($language) |
|
144 | + /** |
|
145 | + * Gets the last version of a Term and condition by language |
|
146 | + * @param int $language language id |
|
147 | + * @return boolean | int the version or false if does not exist |
|
148 | + */ |
|
149 | + public static function get_last_version($language) |
|
150 | 150 | { |
151 | 151 | $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
152 | 152 | $language = intval($language); |
@@ -164,15 +164,15 @@ discard block |
||
164 | 164 | |
165 | 165 | return false; |
166 | 166 | } |
167 | - } |
|
167 | + } |
|
168 | 168 | |
169 | - /** |
|
170 | - * Show the last condition |
|
171 | - * @param array $term_preview with type and content i.e array('type'=>'1', 'content'=>'hola'); |
|
169 | + /** |
|
170 | + * Show the last condition |
|
171 | + * @param array $term_preview with type and content i.e array('type'=>'1', 'content'=>'hola'); |
|
172 | 172 | * |
173 | - * @return string html preview |
|
174 | - */ |
|
175 | - public static function show_last_condition($term_preview) |
|
173 | + * @return string html preview |
|
174 | + */ |
|
175 | + public static function show_last_condition($term_preview) |
|
176 | 176 | { |
177 | 177 | $preview = ''; |
178 | 178 | switch ($term_preview['type']) { |
@@ -201,37 +201,37 @@ discard block |
||
201 | 201 | default: |
202 | 202 | break; |
203 | 203 | } |
204 | - return $preview; |
|
205 | - } |
|
204 | + return $preview; |
|
205 | + } |
|
206 | 206 | |
207 | - /** |
|
208 | - * Get the terms and condition table (only for maintenance) |
|
209 | - * @param int $from |
|
210 | - * @param int $number_of_items |
|
211 | - * @param int $column |
|
212 | - * @return array |
|
213 | - */ |
|
214 | - public static function get_legal_data($from, $number_of_items, $column) |
|
207 | + /** |
|
208 | + * Get the terms and condition table (only for maintenance) |
|
209 | + * @param int $from |
|
210 | + * @param int $number_of_items |
|
211 | + * @param int $column |
|
212 | + * @return array |
|
213 | + */ |
|
214 | + public static function get_legal_data($from, $number_of_items, $column) |
|
215 | 215 | { |
216 | - $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
|
217 | - $lang_table = Database::get_main_table(TABLE_MAIN_LANGUAGE); |
|
218 | - $from = intval($from); |
|
219 | - $number_of_items = intval($number_of_items); |
|
220 | - $column = intval($column); |
|
216 | + $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
|
217 | + $lang_table = Database::get_main_table(TABLE_MAIN_LANGUAGE); |
|
218 | + $from = intval($from); |
|
219 | + $number_of_items = intval($number_of_items); |
|
220 | + $column = intval($column); |
|
221 | 221 | |
222 | - $sql = "SELECT version, original_name as language, content, changes, type, FROM_UNIXTIME(date) |
|
222 | + $sql = "SELECT version, original_name as language, content, changes, type, FROM_UNIXTIME(date) |
|
223 | 223 | FROM $legal_conditions_table inner join $lang_table l on(language_id = l.id) "; |
224 | - $sql .= "ORDER BY language, version ASC "; |
|
225 | - $sql .= "LIMIT $from, $number_of_items "; |
|
224 | + $sql .= "ORDER BY language, version ASC "; |
|
225 | + $sql .= "LIMIT $from, $number_of_items "; |
|
226 | 226 | |
227 | - $result = Database::query($sql); |
|
228 | - $legals = array(); |
|
229 | - $versions = array(); |
|
230 | - while ($legal = Database::fetch_array($result)) { |
|
231 | - // max 2000 chars |
|
232 | - //echo strlen($legal[1]); echo '<br>'; |
|
233 | - $versions[] = $legal[0]; |
|
234 | - $languages[] = $legal[1]; |
|
227 | + $result = Database::query($sql); |
|
228 | + $legals = array(); |
|
229 | + $versions = array(); |
|
230 | + while ($legal = Database::fetch_array($result)) { |
|
231 | + // max 2000 chars |
|
232 | + //echo strlen($legal[1]); echo '<br>'; |
|
233 | + $versions[] = $legal[0]; |
|
234 | + $languages[] = $legal[1]; |
|
235 | 235 | if (strlen($legal[2]) > 2000) { |
236 | 236 | $legal[2] = substr($legal[2], 0, 2000).' ... '; |
237 | 237 | } |
@@ -240,50 +240,50 @@ discard block |
||
240 | 240 | } elseif ($legal[4] == 1) { |
241 | 241 | $legal[4] = get_lang('PageLink'); |
242 | 242 | } |
243 | - $legals[] = $legal; |
|
244 | - } |
|
245 | - return $legals; |
|
246 | - } |
|
243 | + $legals[] = $legal; |
|
244 | + } |
|
245 | + return $legals; |
|
246 | + } |
|
247 | 247 | |
248 | - /** |
|
249 | - * Gets the number of terms and conditions available |
|
250 | - * @return int |
|
251 | - */ |
|
252 | - public static function count() |
|
248 | + /** |
|
249 | + * Gets the number of terms and conditions available |
|
250 | + * @return int |
|
251 | + */ |
|
252 | + public static function count() |
|
253 | 253 | { |
254 | - $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
|
255 | - $sql = "SELECT count(*) as count_result |
|
254 | + $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
|
255 | + $sql = "SELECT count(*) as count_result |
|
256 | 256 | FROM $legal_conditions_table |
257 | 257 | ORDER BY id DESC "; |
258 | - $result = Database::query($sql); |
|
259 | - $url = Database::fetch_array($result,'ASSOC'); |
|
260 | - $result = $url['count_result']; |
|
258 | + $result = Database::query($sql); |
|
259 | + $url = Database::fetch_array($result,'ASSOC'); |
|
260 | + $result = $url['count_result']; |
|
261 | 261 | |
262 | - return $result; |
|
263 | - } |
|
262 | + return $result; |
|
263 | + } |
|
264 | 264 | |
265 | - /** |
|
266 | - * Get type of terms and conditions |
|
267 | - * @param int $legal_id |
|
268 | - * @param int $language_id |
|
269 | - * @return int The current type of terms and conditions |
|
270 | - */ |
|
271 | - public static function get_type_of_terms_and_conditions($legal_id, $language_id) |
|
265 | + /** |
|
266 | + * Get type of terms and conditions |
|
267 | + * @param int $legal_id |
|
268 | + * @param int $language_id |
|
269 | + * @return int The current type of terms and conditions |
|
270 | + */ |
|
271 | + public static function get_type_of_terms_and_conditions($legal_id, $language_id) |
|
272 | 272 | { |
273 | - $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
|
274 | - $legal_id = intval($legal_id); |
|
275 | - $language_id = intval($language_id); |
|
276 | - $sql = 'SELECT type FROM '.$legal_conditions_table.' |
|
273 | + $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
|
274 | + $legal_id = intval($legal_id); |
|
275 | + $language_id = intval($language_id); |
|
276 | + $sql = 'SELECT type FROM '.$legal_conditions_table.' |
|
277 | 277 | WHERE id = "'.$legal_id.'" AND language_id="'.$language_id.'"'; |
278 | - $rs = Database::query($sql); |
|
278 | + $rs = Database::query($sql); |
|
279 | 279 | |
280 | - return Database::result($rs,0,'type'); |
|
281 | - } |
|
280 | + return Database::result($rs,0,'type'); |
|
281 | + } |
|
282 | 282 | |
283 | 283 | /** |
284 | 284 | * @param int $userId |
285 | 285 | */ |
286 | - public static function sendLegal($userId) |
|
286 | + public static function sendLegal($userId) |
|
287 | 287 | { |
288 | 288 | $subject = get_lang('SendTermsSubject'); |
289 | 289 | $content = sprintf( |
@@ -304,9 +304,9 @@ discard block |
||
304 | 304 | */ |
305 | 305 | public static function remove_XSS($var, $user_status = null, $filter_terms = false) |
306 | 306 | { |
307 | - if ($filter_terms) { |
|
308 | - $var = self::filter_terms($var); |
|
309 | - } |
|
307 | + if ($filter_terms) { |
|
308 | + $var = self::filter_terms($var); |
|
309 | + } |
|
310 | 310 | |
311 | 311 | if (empty($user_status)) { |
312 | 312 | if (api_is_anonymous()) { |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | */ |
402 | 402 | public static function filter_terms($text) |
403 | 403 | { |
404 | - static $bad_terms = array(); |
|
404 | + static $bad_terms = array(); |
|
405 | 405 | |
406 | 406 | if (empty($bad_terms)) { |
407 | 407 | $list = api_get_setting('filter_terms'); |
@@ -422,14 +422,14 @@ discard block |
||
422 | 422 | } |
423 | 423 | } |
424 | 424 | |
425 | - $replace = '***'; |
|
426 | - if (!empty($bad_terms)) { |
|
427 | - // Fast way |
|
428 | - $new_text = str_ireplace($bad_terms, $replace, $text, $count); |
|
429 | - $text = $new_text; |
|
430 | - } |
|
425 | + $replace = '***'; |
|
426 | + if (!empty($bad_terms)) { |
|
427 | + // Fast way |
|
428 | + $new_text = str_ireplace($bad_terms, $replace, $text, $count); |
|
429 | + $text = $new_text; |
|
430 | + } |
|
431 | 431 | |
432 | - return $text; |
|
432 | + return $text; |
|
433 | 433 | } |
434 | 434 | |
435 | 435 |
@@ -165,10 +165,10 @@ discard block |
||
165 | 165 | */ |
166 | 166 | function LoginDelete($user_id) |
167 | 167 | { |
168 | - $online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
|
168 | + $online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
|
169 | 169 | $user_id = intval($user_id); |
170 | - $query = "DELETE FROM " . $online_table . " WHERE login_user_id = $user_id"; |
|
171 | - Database::query($query); |
|
170 | + $query = "DELETE FROM " . $online_table . " WHERE login_user_id = $user_id"; |
|
171 | + Database::query($query); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | /** |
@@ -177,17 +177,17 @@ discard block |
||
177 | 177 | */ |
178 | 178 | function user_is_online($user_id) |
179 | 179 | { |
180 | - $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
|
181 | - $table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
180 | + $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
|
181 | + $table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
182 | 182 | |
183 | - $access_url_id = api_get_current_access_url_id(); |
|
184 | - $time_limit = api_get_setting('time_limit_whosonline'); |
|
183 | + $access_url_id = api_get_current_access_url_id(); |
|
184 | + $time_limit = api_get_setting('time_limit_whosonline'); |
|
185 | 185 | |
186 | 186 | $online_time = time() - $time_limit*60; |
187 | 187 | $limit_date = api_get_utc_datetime($online_time); |
188 | 188 | $user_id = intval($user_id); |
189 | 189 | |
190 | - $query = " SELECT login_user_id,login_date |
|
190 | + $query = " SELECT login_user_id,login_date |
|
191 | 191 | FROM $track_online_table track |
192 | 192 | INNER JOIN $table_user u ON (u.id=track.login_user_id) |
193 | 193 | WHERE |
@@ -196,13 +196,13 @@ discard block |
||
196 | 196 | u.id = $user_id |
197 | 197 | LIMIT 1 "; |
198 | 198 | |
199 | - $result = Database::query($query); |
|
200 | - if (Database::num_rows($result)) { |
|
199 | + $result = Database::query($query); |
|
200 | + if (Database::num_rows($result)) { |
|
201 | 201 | |
202 | - return true; |
|
203 | - } |
|
202 | + return true; |
|
203 | + } |
|
204 | 204 | |
205 | - return false; |
|
205 | + return false; |
|
206 | 206 | |
207 | 207 | } |
208 | 208 | /** |
@@ -238,13 +238,13 @@ discard block |
||
238 | 238 | |
239 | 239 | $online_time = time() - $time_limit * 60; |
240 | 240 | $current_date = api_get_utc_datetime($online_time); |
241 | - $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
|
242 | - $friend_user_table = Database::get_main_table(TABLE_MAIN_USER_REL_USER); |
|
243 | - $table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
241 | + $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
|
242 | + $friend_user_table = Database::get_main_table(TABLE_MAIN_USER_REL_USER); |
|
243 | + $table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
244 | 244 | |
245 | - if ($friends) { |
|
246 | - // who friends from social network is online |
|
247 | - $query = "SELECT DISTINCT login_user_id, login_date |
|
245 | + if ($friends) { |
|
246 | + // who friends from social network is online |
|
247 | + $query = "SELECT DISTINCT login_user_id, login_date |
|
248 | 248 | FROM $track_online_table INNER JOIN $friend_user_table |
249 | 249 | ON (friend_user_id = login_user_id) |
250 | 250 | WHERE |
@@ -254,21 +254,21 @@ discard block |
||
254 | 254 | user_id = '".api_get_user_id()."' |
255 | 255 | ORDER BY $column $direction |
256 | 256 | LIMIT $from, $number_of_items"; |
257 | - } else { |
|
258 | - $query = "SELECT DISTINCT login_user_id, login_date |
|
257 | + } else { |
|
258 | + $query = "SELECT DISTINCT login_user_id, login_date |
|
259 | 259 | FROM ".$track_online_table ." e |
260 | 260 | INNER JOIN ".$table_user ." u ON (u.id = e.login_user_id) |
261 | 261 | WHERE u.status != ".ANONYMOUS." AND login_date >= '".$current_date."' |
262 | 262 | ORDER BY $column $direction |
263 | 263 | LIMIT $from, $number_of_items"; |
264 | - } |
|
265 | - |
|
266 | - if (api_get_multiple_access_url()) { |
|
267 | - $access_url_id = api_get_current_access_url_id(); |
|
268 | - if ($access_url_id != -1) { |
|
269 | - if ($friends) { |
|
270 | - // friends from social network is online |
|
271 | - $query = "SELECT distinct login_user_id, login_date |
|
264 | + } |
|
265 | + |
|
266 | + if (api_get_multiple_access_url()) { |
|
267 | + $access_url_id = api_get_current_access_url_id(); |
|
268 | + if ($access_url_id != -1) { |
|
269 | + if ($friends) { |
|
270 | + // friends from social network is online |
|
271 | + $query = "SELECT distinct login_user_id, login_date |
|
272 | 272 | FROM $track_online_table track INNER JOIN $friend_user_table |
273 | 273 | ON (friend_user_id = login_user_id) |
274 | 274 | WHERE track.access_url_id = $access_url_id AND |
@@ -277,9 +277,9 @@ discard block |
||
277 | 277 | relation_type='".USER_RELATION_TYPE_FRIEND."' |
278 | 278 | ORDER BY $column $direction |
279 | 279 | LIMIT $from, $number_of_items"; |
280 | - } else { |
|
281 | - // all users online |
|
282 | - $query = "SELECT login_user_id, login_date |
|
280 | + } else { |
|
281 | + // all users online |
|
282 | + $query = "SELECT login_user_id, login_date |
|
283 | 283 | FROM ".$track_online_table ." track |
284 | 284 | INNER JOIN ".$table_user ." u |
285 | 285 | ON (u.id=track.login_user_id) |
@@ -287,26 +287,26 @@ discard block |
||
287 | 287 | login_date >= '".$current_date."' |
288 | 288 | ORDER BY $column $direction |
289 | 289 | LIMIT $from, $number_of_items"; |
290 | - } |
|
291 | - } |
|
292 | - } |
|
290 | + } |
|
291 | + } |
|
292 | + } |
|
293 | 293 | |
294 | - //This query will show all registered users. Only for dev purposes. |
|
295 | - /*$query = "SELECT DISTINCT u.id as login_user_id, login_date FROM ".$track_online_table ." e , $table_user u |
|
294 | + //This query will show all registered users. Only for dev purposes. |
|
295 | + /*$query = "SELECT DISTINCT u.id as login_user_id, login_date FROM ".$track_online_table ." e , $table_user u |
|
296 | 296 | GROUP by u.id |
297 | 297 | ORDER BY $column $direction |
298 | 298 | LIMIT $from, $number_of_items";*/ |
299 | 299 | |
300 | - $result = Database::query($query); |
|
301 | - if ($result) { |
|
302 | - $users_online = array(); |
|
303 | - while (list($login_user_id, $login_date) = Database::fetch_row($result)) { |
|
300 | + $result = Database::query($query); |
|
301 | + if ($result) { |
|
302 | + $users_online = array(); |
|
303 | + while (list($login_user_id, $login_date) = Database::fetch_row($result)) { |
|
304 | 304 | $users_online[] = $login_user_id; |
305 | - } |
|
306 | - return $users_online; |
|
307 | - } else { |
|
308 | - return false; |
|
309 | - } |
|
305 | + } |
|
306 | + return $users_online; |
|
307 | + } else { |
|
308 | + return false; |
|
309 | + } |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | function who_is_online_count($time_limit = null, $friends = false) |
@@ -316,15 +316,15 @@ discard block |
||
316 | 316 | } else { |
317 | 317 | $time_limit = intval($time_limit); |
318 | 318 | } |
319 | - $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
|
320 | - $friend_user_table = Database::get_main_table(TABLE_MAIN_USER_REL_USER); |
|
321 | - $table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
322 | - $online_time = time() - $time_limit * 60; |
|
323 | - $current_date = api_get_utc_datetime($online_time); |
|
324 | - |
|
325 | - if ($friends) { |
|
326 | - // who friends from social network is online |
|
327 | - $query = "SELECT DISTINCT count(login_user_id) as count |
|
319 | + $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
|
320 | + $friend_user_table = Database::get_main_table(TABLE_MAIN_USER_REL_USER); |
|
321 | + $table_user = Database::get_main_table(TABLE_MAIN_USER); |
|
322 | + $online_time = time() - $time_limit * 60; |
|
323 | + $current_date = api_get_utc_datetime($online_time); |
|
324 | + |
|
325 | + if ($friends) { |
|
326 | + // who friends from social network is online |
|
327 | + $query = "SELECT DISTINCT count(login_user_id) as count |
|
328 | 328 | FROM $track_online_table INNER JOIN $friend_user_table |
329 | 329 | ON (friend_user_id = login_user_id) |
330 | 330 | WHERE |
@@ -332,20 +332,20 @@ discard block |
||
332 | 332 | friend_user_id <> '".api_get_user_id()."' AND |
333 | 333 | relation_type='".USER_RELATION_TYPE_FRIEND."' AND |
334 | 334 | user_id = '".api_get_user_id()."' "; |
335 | - } else { |
|
336 | - // All users online |
|
337 | - $query = "SELECT count(login_id) as count |
|
335 | + } else { |
|
336 | + // All users online |
|
337 | + $query = "SELECT count(login_id) as count |
|
338 | 338 | FROM $track_online_table track INNER JOIN $table_user u |
339 | 339 | ON (u.id=track.login_user_id) |
340 | 340 | WHERE u.status != ".ANONYMOUS." AND login_date >= '$current_date' "; |
341 | - } |
|
342 | - |
|
343 | - if (api_get_multiple_access_url()) { |
|
344 | - $access_url_id = api_get_current_access_url_id(); |
|
345 | - if ($access_url_id != -1) { |
|
346 | - if ($friends) { |
|
347 | - // friends from social network is online |
|
348 | - $query = "SELECT DISTINCT count(login_user_id) as count |
|
341 | + } |
|
342 | + |
|
343 | + if (api_get_multiple_access_url()) { |
|
344 | + $access_url_id = api_get_current_access_url_id(); |
|
345 | + if ($access_url_id != -1) { |
|
346 | + if ($friends) { |
|
347 | + // friends from social network is online |
|
348 | + $query = "SELECT DISTINCT count(login_user_id) as count |
|
349 | 349 | FROM $track_online_table track |
350 | 350 | INNER JOIN $friend_user_table ON (friend_user_id = login_user_id) |
351 | 351 | WHERE |
@@ -353,29 +353,29 @@ discard block |
||
353 | 353 | login_date >= '".$current_date."' AND |
354 | 354 | friend_user_id <> '".api_get_user_id()."' AND |
355 | 355 | relation_type='".USER_RELATION_TYPE_FRIEND."' "; |
356 | - } else { |
|
357 | - // all users online |
|
358 | - $query = "SELECT count(login_id) as count FROM $track_online_table track |
|
356 | + } else { |
|
357 | + // all users online |
|
358 | + $query = "SELECT count(login_id) as count FROM $track_online_table track |
|
359 | 359 | INNER JOIN $table_user u ON (u.id=track.login_user_id) |
360 | 360 | WHERE |
361 | 361 | u.status != ".ANONYMOUS." AND |
362 | 362 | track.access_url_id = $access_url_id AND |
363 | 363 | login_date >= '$current_date' "; |
364 | - } |
|
365 | - } |
|
366 | - } |
|
364 | + } |
|
365 | + } |
|
366 | + } |
|
367 | 367 | |
368 | 368 | // Dev purposes show all users online |
369 | 369 | /*$table_user = Database::get_main_table(TABLE_MAIN_USER); |
370 | 370 | $query = "SELECT count(*) as count FROM ".$table_user;*/ |
371 | 371 | |
372 | - $result = Database::query($query); |
|
373 | - if (Database::num_rows($result) > 0) { |
|
374 | - $row = Database::fetch_array($result); |
|
375 | - return $row['count']; |
|
376 | - } else { |
|
377 | - return false; |
|
378 | - } |
|
372 | + $result = Database::query($query); |
|
373 | + if (Database::num_rows($result) > 0) { |
|
374 | + $row = Database::fetch_array($result); |
|
375 | + return $row['count']; |
|
376 | + } else { |
|
377 | + return false; |
|
378 | + } |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | */ |
389 | 389 | function who_is_online_in_this_course($from, $number_of_items, $uid, $time_limit, $course_code) |
390 | 390 | { |
391 | - if (empty($course_code)) return false; |
|
391 | + if (empty($course_code)) return false; |
|
392 | 392 | |
393 | 393 | if (empty($time_limit)) { |
394 | 394 | $time_limit = api_get_setting('time_limit_whosonline'); |
@@ -401,55 +401,55 @@ discard block |
||
401 | 401 | $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
402 | 402 | $course_code = Database::escape_string($course_code); |
403 | 403 | $courseInfo = api_get_course_info($course_code); |
404 | - $courseId = $courseInfo['real_id']; |
|
404 | + $courseId = $courseInfo['real_id']; |
|
405 | 405 | |
406 | 406 | $from = intval($from); |
407 | 407 | $number_of_items = intval($number_of_items); |
408 | 408 | |
409 | - $query = "SELECT login_user_id, login_date FROM $track_online_table |
|
409 | + $query = "SELECT login_user_id, login_date FROM $track_online_table |
|
410 | 410 | WHERE login_user_id <> 2 AND c_id = $courseId AND login_date >= '$current_date' |
411 | 411 | LIMIT $from, $number_of_items "; |
412 | 412 | |
413 | - $result = Database::query($query); |
|
414 | - if ($result) { |
|
415 | - $users_online = array(); |
|
413 | + $result = Database::query($query); |
|
414 | + if ($result) { |
|
415 | + $users_online = array(); |
|
416 | 416 | |
417 | - while(list($login_user_id, $login_date) = Database::fetch_row($result)) { |
|
417 | + while(list($login_user_id, $login_date) = Database::fetch_row($result)) { |
|
418 | 418 | $users_online[] = $login_user_id; |
419 | - } |
|
420 | - return $users_online; |
|
421 | - } else { |
|
422 | - return false; |
|
423 | - } |
|
419 | + } |
|
420 | + return $users_online; |
|
421 | + } else { |
|
422 | + return false; |
|
423 | + } |
|
424 | 424 | } |
425 | 425 | |
426 | 426 | function who_is_online_in_this_course_count($uid, $time_limit, $coursecode=null) |
427 | 427 | { |
428 | - if (empty($coursecode)) { |
|
429 | - return false; |
|
430 | - } |
|
431 | - $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
|
432 | - $coursecode = Database::escape_string($coursecode); |
|
433 | - $time_limit = Database::escape_string($time_limit); |
|
428 | + if (empty($coursecode)) { |
|
429 | + return false; |
|
430 | + } |
|
431 | + $track_online_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ONLINE); |
|
432 | + $coursecode = Database::escape_string($coursecode); |
|
433 | + $time_limit = Database::escape_string($time_limit); |
|
434 | 434 | |
435 | 435 | $online_time = time() - $time_limit * 60; |
436 | 436 | $current_date = api_get_utc_datetime($online_time); |
437 | - $courseId = api_get_course_int_id($coursecode); |
|
437 | + $courseId = api_get_course_int_id($coursecode); |
|
438 | 438 | |
439 | - if (empty($courseId)) { |
|
440 | - return false; |
|
441 | - } |
|
439 | + if (empty($courseId)) { |
|
440 | + return false; |
|
441 | + } |
|
442 | 442 | |
443 | - $query = "SELECT count(login_user_id) as count |
|
443 | + $query = "SELECT count(login_user_id) as count |
|
444 | 444 | FROM $track_online_table |
445 | 445 | WHERE login_user_id <> 2 AND c_id = $courseId AND login_date >= '$current_date' "; |
446 | - $result = Database::query($query); |
|
447 | - if (Database::num_rows($result) > 0) { |
|
448 | - $row = Database::fetch_array($result); |
|
449 | - return $row['count']; |
|
450 | - } else { |
|
451 | - return false; |
|
452 | - } |
|
446 | + $result = Database::query($query); |
|
447 | + if (Database::num_rows($result) > 0) { |
|
448 | + $row = Database::fetch_array($result); |
|
449 | + return $row['count']; |
|
450 | + } else { |
|
451 | + return false; |
|
452 | + } |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | /** |
@@ -459,15 +459,15 @@ discard block |
||
459 | 459 | * @deprecated user api_get_user_info($user_id) |
460 | 460 | */ |
461 | 461 | function GetFullUserName($uid) { |
462 | - $uid = (int) $uid; |
|
463 | - $uid = intval($uid); |
|
464 | - $user_table = Database::get_main_table(TABLE_MAIN_USER); |
|
465 | - $query = "SELECT firstname, lastname FROM ".$user_table." WHERE id=$uid"; |
|
466 | - $result = @Database::query($query); |
|
467 | - if (count($result)>0) { |
|
468 | - while(list($firstname,$lastname)= Database::fetch_array($result)) { |
|
469 | - $str = str_replace(' ', ' ', api_get_person_name($firstname, $lastname)); |
|
470 | - return $str; |
|
471 | - } |
|
472 | - } |
|
462 | + $uid = (int) $uid; |
|
463 | + $uid = intval($uid); |
|
464 | + $user_table = Database::get_main_table(TABLE_MAIN_USER); |
|
465 | + $query = "SELECT firstname, lastname FROM ".$user_table." WHERE id=$uid"; |
|
466 | + $result = @Database::query($query); |
|
467 | + if (count($result)>0) { |
|
468 | + while(list($firstname,$lastname)= Database::fetch_array($result)) { |
|
469 | + $str = str_replace(' ', ' ', api_get_person_name($firstname, $lastname)); |
|
470 | + return $str; |
|
471 | + } |
|
472 | + } |
|
473 | 473 | } |
@@ -95,13 +95,13 @@ discard block |
||
95 | 95 | if (isset($_configuration['language_measure_frequency']) && |
96 | 96 | $_configuration['language_measure_frequency'] == 1 |
97 | 97 | ) { |
98 | - require_once api_get_path(SYS_CODE_PATH).'/cron/lang/langstats.class.php'; |
|
99 | - global $langstats; |
|
100 | - $langstats->add_use($variable,''); |
|
98 | + require_once api_get_path(SYS_CODE_PATH).'/cron/lang/langstats.class.php'; |
|
99 | + global $langstats; |
|
100 | + $langstats->add_use($variable,''); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | if (!isset($used_lang_vars)) { |
104 | - $used_lang_vars = array(); |
|
104 | + $used_lang_vars = array(); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | // Caching results from some API functions, for speed. |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | static $text_direction = array(); |
292 | 292 | |
293 | 293 | if (empty($language)) { |
294 | - $language = api_get_interface_language(); |
|
294 | + $language = api_get_interface_language(); |
|
295 | 295 | } |
296 | 296 | if (!isset($text_direction[$language])) { |
297 | 297 | $text_direction[$language] = in_array(api_purify_language_id($language), |
@@ -528,24 +528,24 @@ discard block |
||
528 | 528 | case DATE_FORMAT_ONLY_DAYNAME: |
529 | 529 | $date_format = get_lang('dateFormatOnlyDayName', '', $language); |
530 | 530 | if (INTL_INSTALLED) { |
531 | - $datetype = IntlDateFormatter::SHORT; |
|
532 | - $timetype = IntlDateFormatter::NONE; |
|
533 | - } |
|
531 | + $datetype = IntlDateFormatter::SHORT; |
|
532 | + $timetype = IntlDateFormatter::NONE; |
|
533 | + } |
|
534 | 534 | break; |
535 | 535 | case DATE_FORMAT_NUMBER_NO_YEAR: |
536 | 536 | $date_format = get_lang('dateFormatShortNumberNoYear', '', $language); |
537 | - if (INTL_INSTALLED) { |
|
538 | - $datetype = IntlDateFormatter::SHORT; |
|
539 | - $timetype = IntlDateFormatter::NONE; |
|
540 | - } |
|
537 | + if (INTL_INSTALLED) { |
|
538 | + $datetype = IntlDateFormatter::SHORT; |
|
539 | + $timetype = IntlDateFormatter::NONE; |
|
540 | + } |
|
541 | + break; |
|
542 | + case DATE_FORMAT_NUMBER: |
|
543 | + $date_format = get_lang('dateFormatShortNumber', '', $language); |
|
544 | + if (INTL_INSTALLED) { |
|
545 | + $datetype = IntlDateFormatter::SHORT; |
|
546 | + $timetype = IntlDateFormatter::NONE; |
|
547 | + } |
|
541 | 548 | break; |
542 | - case DATE_FORMAT_NUMBER: |
|
543 | - $date_format = get_lang('dateFormatShortNumber', '', $language); |
|
544 | - if (INTL_INSTALLED) { |
|
545 | - $datetype = IntlDateFormatter::SHORT; |
|
546 | - $timetype = IntlDateFormatter::NONE; |
|
547 | - } |
|
548 | - break; |
|
549 | 549 | case TIME_NO_SEC_FORMAT: |
550 | 550 | $date_format = get_lang('timeNoSecFormat', '', $language); |
551 | 551 | if (INTL_INSTALLED) { |
@@ -581,14 +581,14 @@ discard block |
||
581 | 581 | $timetype = IntlDateFormatter::SHORT; |
582 | 582 | } |
583 | 583 | break; |
584 | - case DATE_TIME_FORMAT_SHORT: |
|
584 | + case DATE_TIME_FORMAT_SHORT: |
|
585 | 585 | $date_format = get_lang('dateTimeFormatShort', '', $language); |
586 | 586 | if (INTL_INSTALLED) { |
587 | 587 | $datetype = IntlDateFormatter::FULL; |
588 | 588 | $timetype = IntlDateFormatter::SHORT; |
589 | 589 | } |
590 | 590 | break; |
591 | - case DATE_TIME_FORMAT_SHORT_TIME_FIRST: |
|
591 | + case DATE_TIME_FORMAT_SHORT_TIME_FIRST: |
|
592 | 592 | $date_format = get_lang('dateTimeFormatShortTimeFirst', '', $language); |
593 | 593 | if (INTL_INSTALLED) { |
594 | 594 | $datetype = IntlDateFormatter::FULL; |
@@ -1700,7 +1700,6 @@ discard block |
||
1700 | 1700 | |
1701 | 1701 | /** |
1702 | 1702 | * Return true a date is valid |
1703 | - |
|
1704 | 1703 | * @param string $date example: 2014-06-30 13:05:05 |
1705 | 1704 | * @param string $format example: "Y-m-d H:i:s" |
1706 | 1705 | * |
@@ -1969,15 +1968,15 @@ discard block |
||
1969 | 1968 | function apiGetHumanDateTime($date, $showTime = true, $humanForm = false) { |
1970 | 1969 | if ($showTime) { |
1971 | 1970 | if ($humanForm) { |
1972 | - return $date->format('j M Y H:i:s'); |
|
1971 | + return $date->format('j M Y H:i:s'); |
|
1973 | 1972 | } else { |
1974 | - return $date->format('Y-m-d H:i:s'); |
|
1973 | + return $date->format('Y-m-d H:i:s'); |
|
1975 | 1974 | } |
1976 | 1975 | } else { |
1977 | 1976 | if ($humanForm) { |
1978 | - return $date->format('j M Y'); |
|
1977 | + return $date->format('j M Y'); |
|
1979 | 1978 | } else { |
1980 | - return $date->format('Y-m-d'); |
|
1979 | + return $date->format('Y-m-d'); |
|
1981 | 1980 | } |
1982 | 1981 | } |
1983 | 1982 | } |
@@ -139,7 +139,7 @@ |
||
139 | 139 | api_get_local_time($glossary_data['update_date']) |
140 | 140 | ); |
141 | 141 | } else { |
142 | - $glossary_data['update_date'] = ''; |
|
142 | + $glossary_data['update_date'] = ''; |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | $form->addLabel(get_lang('CreationDate'), $glossary_data['insert_date']); |
@@ -251,12 +251,12 @@ discard block |
||
251 | 251 | } |
252 | 252 | |
253 | 253 | /** |
254 | - * update user info about certificate |
|
255 | - * @param int $cat_id category id |
|
256 | - * @param int $user_id user id |
|
257 | - * @param string $path_certificate the path name of the certificate |
|
258 | - * @return void |
|
259 | - */ |
|
254 | + * update user info about certificate |
|
255 | + * @param int $cat_id category id |
|
256 | + * @param int $user_id user id |
|
257 | + * @param string $path_certificate the path name of the certificate |
|
258 | + * @return void |
|
259 | + */ |
|
260 | 260 | public function update_user_info_about_certificate( |
261 | 261 | $cat_id, |
262 | 262 | $user_id, |
@@ -359,13 +359,13 @@ discard block |
||
359 | 359 | } |
360 | 360 | |
361 | 361 | /** |
362 | - * Shows the student's certificate (HTML file). If the global setting |
|
363 | - * allow_public_certificates is set to 'false', no certificate can be printed. |
|
364 | - * If the global allow_public_certificates is set to 'true' and the course |
|
365 | - * setting allow_public_certificates is set to 0, no certificate *in this |
|
366 | - * course* can be printed (for anonymous users). Connected users can always |
|
367 | - * print them. |
|
368 | - */ |
|
362 | + * Shows the student's certificate (HTML file). If the global setting |
|
363 | + * allow_public_certificates is set to 'false', no certificate can be printed. |
|
364 | + * If the global allow_public_certificates is set to 'true' and the course |
|
365 | + * setting allow_public_certificates is set to 0, no certificate *in this |
|
366 | + * course* can be printed (for anonymous users). Connected users can always |
|
367 | + * print them. |
|
368 | + */ |
|
369 | 369 | public function show() |
370 | 370 | { |
371 | 371 | // Special rules for anonymous users |
@@ -373,13 +373,13 @@ discard block |
||
373 | 373 | $firstname = $userInfo['firstname']; |
374 | 374 | $lastname = $userInfo['lastname']; |
375 | 375 | |
376 | - if (api_is_western_name_order()) { |
|
377 | - $message = sprintf(get_lang('AttemptingToLoginAs'),$firstname, $lastname, $userId); |
|
378 | - } else { |
|
379 | - $message = sprintf(get_lang('AttemptingToLoginAs'), $lastname, $firstname, $userId); |
|
380 | - } |
|
376 | + if (api_is_western_name_order()) { |
|
377 | + $message = sprintf(get_lang('AttemptingToLoginAs'),$firstname, $lastname, $userId); |
|
378 | + } else { |
|
379 | + $message = sprintf(get_lang('AttemptingToLoginAs'), $lastname, $firstname, $userId); |
|
380 | + } |
|
381 | 381 | |
382 | - if ($userId) { |
|
382 | + if ($userId) { |
|
383 | 383 | |
384 | 384 | // Logout the current user |
385 | 385 | LoginDelete(api_get_user_id()); |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | }*/ |
455 | 455 | |
456 | 456 | if (!in_array($direction, array('ASC','DESC'))) { |
457 | - $direction = 'ASC'; |
|
457 | + $direction = 'ASC'; |
|
458 | 458 | } |
459 | 459 | $column = intval($column); |
460 | 460 | $from = intval($from); |
@@ -465,23 +465,23 @@ discard block |
||
465 | 465 | $sql .= " WHERE u.creator_id = ".api_get_user_id(); |
466 | 466 | } |
467 | 467 | |
468 | - $sql .= " ORDER BY col$column $direction "; |
|
469 | - $sql .= " LIMIT $from,$number_of_items"; |
|
468 | + $sql .= " ORDER BY col$column $direction "; |
|
469 | + $sql .= " LIMIT $from,$number_of_items"; |
|
470 | 470 | |
471 | - $res = Database::query($sql); |
|
471 | + $res = Database::query($sql); |
|
472 | 472 | |
473 | - $users = array (); |
|
473 | + $users = array (); |
|
474 | 474 | $t = time(); |
475 | - while ($user = Database::fetch_row($res)) { |
|
476 | - $userPicture = UserManager::getUserPicture($user[0], USER_IMAGE_SIZE_SMALL); |
|
477 | - $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]).'" />'; |
|
475 | + while ($user = Database::fetch_row($res)) { |
|
476 | + $userPicture = UserManager::getUserPicture($user[0], USER_IMAGE_SIZE_SMALL); |
|
477 | + $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]).'" />'; |
|
478 | 478 | |
479 | 479 | if ($user[7] == 1 && !empty($user[10])) { |
480 | 480 | // check expiration date |
481 | 481 | $expiration_time = convert_sql_date($user[10]); |
482 | 482 | // if expiration date is passed, store a special value for active field |
483 | 483 | if ($expiration_time < $t) { |
484 | - $user[7] = '-1'; |
|
484 | + $user[7] = '-1'; |
|
485 | 485 | } |
486 | 486 | } |
487 | 487 | |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | */ |
512 | 512 | function email_filter($email) |
513 | 513 | { |
514 | - return Display :: encrypted_mailto_link($email, $email); |
|
514 | + return Display :: encrypted_mailto_link($email, $email); |
|
515 | 515 | } |
516 | 516 | |
517 | 517 | /** |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | */ |
522 | 522 | function user_filter($name, $params, $row) |
523 | 523 | { |
524 | - return '<a href="'.api_get_path(WEB_PATH).'whoisonline.php?origin=user_list&id='.$row[0].'">'.$name.'</a>'; |
|
524 | + return '<a href="'.api_get_path(WEB_PATH).'whoisonline.php?origin=user_list&id='.$row[0].'">'.$name.'</a>'; |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | /** |
@@ -533,32 +533,32 @@ discard block |
||
533 | 533 | */ |
534 | 534 | function modify_filter($user_id, $url_params, $row) |
535 | 535 | { |
536 | - global $charset, $_admins_list; |
|
536 | + global $charset, $_admins_list; |
|
537 | 537 | $is_admin = in_array($user_id, $_admins_list); |
538 | 538 | $statusname = api_get_status_langvars(); |
539 | 539 | $user_is_anonymous = false; |
540 | 540 | $current_user_status_label = $row['7']; |
541 | 541 | |
542 | - if ($current_user_status_label == $statusname[ANONYMOUS]) { |
|
543 | - $user_is_anonymous =true; |
|
544 | - } |
|
545 | - $result = ''; |
|
546 | - if (!$user_is_anonymous) { |
|
547 | - $icon = Display::return_icon('course.png', get_lang('Courses'), array('onmouseout' => 'clear_course_list (\'div_'.$user_id.'\')')); |
|
548 | - $result .= '<a href="javascript:void(0)" onclick="load_course_list(\'div_'.$user_id.'\','.$user_id.')" > |
|
542 | + if ($current_user_status_label == $statusname[ANONYMOUS]) { |
|
543 | + $user_is_anonymous =true; |
|
544 | + } |
|
545 | + $result = ''; |
|
546 | + if (!$user_is_anonymous) { |
|
547 | + $icon = Display::return_icon('course.png', get_lang('Courses'), array('onmouseout' => 'clear_course_list (\'div_'.$user_id.'\')')); |
|
548 | + $result .= '<a href="javascript:void(0)" onclick="load_course_list(\'div_'.$user_id.'\','.$user_id.')" > |
|
549 | 549 | '.$icon.' |
550 | 550 | <div class="blackboard_hide" id="div_'.$user_id.'"> </div> |
551 | 551 | </a>'; |
552 | 552 | |
553 | 553 | $icon = Display::return_icon('session.png', get_lang('Sessions'), array('onmouseout' => 'clear_session_list (\'div_s_'.$user_id.'\')')); |
554 | - $result .= '<a href="javascript:void(0)" onclick="load_session_list(\'div_s_'.$user_id.'\','.$user_id.')" > |
|
554 | + $result .= '<a href="javascript:void(0)" onclick="load_session_list(\'div_s_'.$user_id.'\','.$user_id.')" > |
|
555 | 555 | '.$icon.' |
556 | 556 | <div class="blackboard_hide" id="div_s_'.$user_id.'"> </div> |
557 | 557 | </a>'; |
558 | - } else { |
|
559 | - $result .= Display::return_icon('course_na.png',get_lang('Courses')).' '; |
|
560 | - $result .= Display::return_icon('course_na.png',get_lang('Sessions')).' '; |
|
561 | - } |
|
558 | + } else { |
|
559 | + $result .= Display::return_icon('course_na.png',get_lang('Courses')).' '; |
|
560 | + $result .= Display::return_icon('course_na.png',get_lang('Sessions')).' '; |
|
561 | + } |
|
562 | 562 | |
563 | 563 | if (api_is_platform_admin()) { |
564 | 564 | if (!$user_is_anonymous) { |
@@ -607,14 +607,14 @@ discard block |
||
607 | 607 | ); |
608 | 608 | } |
609 | 609 | |
610 | - if ($is_admin) { |
|
611 | - $result .= Display::return_icon('admin_star.png', get_lang('IsAdministrator'),array('width'=> ICON_SIZE_SMALL, 'heigth'=> ICON_SIZE_SMALL)); |
|
612 | - } else { |
|
613 | - $result .= Display::return_icon('admin_star_na.png', get_lang('IsNotAdministrator')); |
|
614 | - } |
|
610 | + if ($is_admin) { |
|
611 | + $result .= Display::return_icon('admin_star.png', get_lang('IsAdministrator'),array('width'=> ICON_SIZE_SMALL, 'heigth'=> ICON_SIZE_SMALL)); |
|
612 | + } else { |
|
613 | + $result .= Display::return_icon('admin_star_na.png', get_lang('IsNotAdministrator')); |
|
614 | + } |
|
615 | 615 | |
616 | - // actions for assigning sessions, courses or users |
|
617 | - if (!api_is_session_admin()) { |
|
616 | + // actions for assigning sessions, courses or users |
|
617 | + if (!api_is_session_admin()) { |
|
618 | 618 | if ($current_user_status_label == $statusname[SESSIONADMIN]) { |
619 | 619 | $result .= Display::url( |
620 | 620 | Display::return_icon('view_more_stats.gif', get_lang('AssignSessions')), |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | ); |
645 | 645 | } |
646 | 646 | } |
647 | - } |
|
647 | + } |
|
648 | 648 | |
649 | 649 | if (api_is_platform_admin()) { |
650 | 650 | $result .= ' <a data-title="'.get_lang('FreeBusyCalendar').'" 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">'. |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | } |
663 | 663 | } |
664 | 664 | } |
665 | - return $result; |
|
665 | + return $result; |
|
666 | 666 | } |
667 | 667 | |
668 | 668 | /** |
@@ -694,11 +694,11 @@ discard block |
||
694 | 694 | if ($action === 'edit') { |
695 | 695 | $result = Display::return_icon($image.'.png', get_lang('AccountExpired'), array(), 16); |
696 | 696 | } elseif ($row['0'] <> $_user['user_id']) { |
697 | - // 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. |
|
698 | - $result = Display::return_icon($image.'.png', get_lang(ucfirst($action)), array('onclick'=>'active_user(this);', 'id'=>'img_'.$row['0']), 16).'</a>'; |
|
699 | - } |
|
697 | + // 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. |
|
698 | + $result = Display::return_icon($image.'.png', get_lang(ucfirst($action)), array('onclick'=>'active_user(this);', 'id'=>'img_'.$row['0']), 16).'</a>'; |
|
699 | + } |
|
700 | 700 | |
701 | - return $result; |
|
701 | + return $result; |
|
702 | 702 | } |
703 | 703 | |
704 | 704 | /** |
@@ -711,8 +711,8 @@ discard block |
||
711 | 711 | * @author Patrick Cool <[email protected]>, Ghent University, Belgium |
712 | 712 | */ |
713 | 713 | function status_filter($status) { |
714 | - $statusname = api_get_status_langvars(); |
|
715 | - return $statusname[$status]; |
|
714 | + $statusname = api_get_status_langvars(); |
|
715 | + return $statusname[$status]; |
|
716 | 716 | } |
717 | 717 | |
718 | 718 | if (isset($_GET['keyword']) || isset($_GET['keyword_firstname'])) { |
@@ -728,8 +728,8 @@ discard block |
||
728 | 728 | |
729 | 729 | if (!empty($action)) { |
730 | 730 | $check = Security::check_token('get'); |
731 | - if ($check) { |
|
732 | - switch ($action) { |
|
731 | + if ($check) { |
|
732 | + switch ($action) { |
|
733 | 733 | case 'add_user_to_my_url': |
734 | 734 | $user_id = $_REQUEST["user_id"]; |
735 | 735 | $result = UrlManager::add_user_to_url($user_id, $current_access_url_id); |
@@ -739,45 +739,45 @@ discard block |
||
739 | 739 | $message = Display::return_message($message, 'confirmation'); |
740 | 740 | } |
741 | 741 | break; |
742 | - case 'delete_user': |
|
743 | - if (api_is_platform_admin()) { |
|
742 | + case 'delete_user': |
|
743 | + if (api_is_platform_admin()) { |
|
744 | 744 | $user_to_delete = $_GET['user_id']; |
745 | 745 | $current_user_id = api_get_user_id(); |
746 | 746 | |
747 | - if ($deleteUserAvailable && api_global_admin_can_edit_admin($_GET['user_id'])) { |
|
748 | - if ($user_to_delete != $current_user_id && UserManager :: delete_user($_GET['user_id'])) { |
|
749 | - $message = Display :: return_message(get_lang('UserDeleted'), 'confirmation'); |
|
750 | - } else { |
|
751 | - $message = Display :: return_message(get_lang('CannotDeleteUserBecauseOwnsCourse'), 'error'); |
|
752 | - } |
|
753 | - } else { |
|
754 | - $message = Display :: return_message(get_lang('CannotDeleteUser'),'error'); |
|
755 | - } |
|
756 | - } |
|
757 | - break; |
|
747 | + if ($deleteUserAvailable && api_global_admin_can_edit_admin($_GET['user_id'])) { |
|
748 | + if ($user_to_delete != $current_user_id && UserManager :: delete_user($_GET['user_id'])) { |
|
749 | + $message = Display :: return_message(get_lang('UserDeleted'), 'confirmation'); |
|
750 | + } else { |
|
751 | + $message = Display :: return_message(get_lang('CannotDeleteUserBecauseOwnsCourse'), 'error'); |
|
752 | + } |
|
753 | + } else { |
|
754 | + $message = Display :: return_message(get_lang('CannotDeleteUser'),'error'); |
|
755 | + } |
|
756 | + } |
|
757 | + break; |
|
758 | 758 | case 'delete': |
759 | - if (api_is_platform_admin()) { |
|
760 | - $number_of_selected_users = count($_POST['id']); |
|
761 | - $number_of_deleted_users = 0; |
|
762 | - if (is_array($_POST['id'])) { |
|
763 | - foreach ($_POST['id'] as $index => $user_id) { |
|
764 | - if ($user_id != $_user['user_id']) { |
|
765 | - if (UserManager::delete_user($user_id)) { |
|
766 | - $number_of_deleted_users++; |
|
767 | - } |
|
768 | - } |
|
769 | - } |
|
770 | - } |
|
771 | - if ($number_of_selected_users == $number_of_deleted_users) { |
|
759 | + if (api_is_platform_admin()) { |
|
760 | + $number_of_selected_users = count($_POST['id']); |
|
761 | + $number_of_deleted_users = 0; |
|
762 | + if (is_array($_POST['id'])) { |
|
763 | + foreach ($_POST['id'] as $index => $user_id) { |
|
764 | + if ($user_id != $_user['user_id']) { |
|
765 | + if (UserManager::delete_user($user_id)) { |
|
766 | + $number_of_deleted_users++; |
|
767 | + } |
|
768 | + } |
|
769 | + } |
|
770 | + } |
|
771 | + if ($number_of_selected_users == $number_of_deleted_users) { |
|
772 | 772 | $message = Display :: return_message(get_lang('SelectedUsersDeleted'), 'confirmation'); |
773 | - } else { |
|
773 | + } else { |
|
774 | 774 | $message = Display :: return_message(get_lang('SomeUsersNotDeleted'), 'error'); |
775 | - } |
|
776 | - } |
|
777 | - break; |
|
778 | - } |
|
779 | - Security::clear_token(); |
|
780 | - } |
|
775 | + } |
|
776 | + } |
|
777 | + break; |
|
778 | + } |
|
779 | + Security::clear_token(); |
|
780 | + } |
|
781 | 781 | } |
782 | 782 | |
783 | 783 | // Create a search-box |
@@ -794,15 +794,15 @@ discard block |
||
794 | 794 | $actionsCenter = ''; |
795 | 795 | $actionsRight = ''; |
796 | 796 | if (api_is_platform_admin()) { |
797 | - $actionsRight .= '<a class="pull-right" href="'.api_get_path(WEB_CODE_PATH).'admin/user_add.php">'. |
|
798 | - Display::return_icon('new_user.png',get_lang('AddUsers'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
797 | + $actionsRight .= '<a class="pull-right" href="'.api_get_path(WEB_CODE_PATH).'admin/user_add.php">'. |
|
798 | + Display::return_icon('new_user.png',get_lang('AddUsers'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
799 | 799 | } |
800 | 800 | |
801 | 801 | $actionsLeft .= $form->returnForm(); |
802 | 802 | $actionsCenter .= $searchAdvanced; |
803 | 803 | |
804 | 804 | if (isset($_GET['keyword'])) { |
805 | - $parameters = array('keyword' => Security::remove_XSS($_GET['keyword'])); |
|
805 | + $parameters = array('keyword' => Security::remove_XSS($_GET['keyword'])); |
|
806 | 806 | } elseif (isset ($_GET['keyword_firstname'])) { |
807 | 807 | $parameters['keyword_firstname'] = Security::remove_XSS($_GET['keyword_firstname']); |
808 | 808 | $parameters['keyword_lastname'] = Security::remove_XSS($_GET['keyword_lastname']); |
@@ -878,11 +878,11 @@ discard block |
||
878 | 878 | $table->set_header(2, get_lang('OfficialCode')); |
879 | 879 | |
880 | 880 | if (api_is_western_name_order()) { |
881 | - $table->set_header(3, get_lang('FirstName')); |
|
882 | - $table->set_header(4, get_lang('LastName')); |
|
881 | + $table->set_header(3, get_lang('FirstName')); |
|
882 | + $table->set_header(4, get_lang('LastName')); |
|
883 | 883 | } else { |
884 | - $table->set_header(3, get_lang('LastName')); |
|
885 | - $table->set_header(4, get_lang('FirstName')); |
|
884 | + $table->set_header(3, get_lang('LastName')); |
|
885 | + $table->set_header(4, get_lang('FirstName')); |
|
886 | 886 | } |
887 | 887 | $table->set_header(5, get_lang('LoginName')); |
888 | 888 | $table->set_header(6, get_lang('Email')); |