@@ -291,16 +291,16 @@ |
||
291 | 291 | Duis bibendum elementum justo. Duis posuere. Fusce nulla odio, posuere eget, condimentum nec, venenatis eu, elit. In hac habitasse platea dictumst. Aenean ac sem in enim imperdiet feugiat. Integer tincidunt lectus at elit. Integer magna lacus, vehicula quis, eleifend eget, suscipit vitae, leo. Nunc porta augue nec enim. Curabitur vehicula volutpat enim. Aliquam consequat. Vestibulum rhoncus tellus vitae erat. Integer est. Quisque fermentum leo nec odio. Suspendisse lobortis sollicitudin augue. Nullam urna mi, suscipit eu, sagittis laoreet, ultrices ac, sem. Aliquam enim tortor, hendrerit non, cursus a, tristique sit amet, sapien. Suspendisse potenti. Aenean semper placerat neque.'; |
292 | 292 | switch($type) |
293 | 293 | { |
294 | - case 'description': |
|
294 | + case 'description': |
|
295 | 295 | $descriptions = explode(".",$dummy_text); |
296 | 296 | return $descriptions[rand(0,count($descriptions)-1)]; |
297 | 297 | break; |
298 | - case 'title': |
|
298 | + case 'title': |
|
299 | 299 | $dummy_text = str_replace(array("\n",'.',',',"\t"),array(' ','','',' '),$dummy_text); |
300 | 300 | $titles = explode(" ",$dummy_text); |
301 | 301 | return trim($titles[rand(0,count($titles)-1)]); |
302 | 302 | break; |
303 | - case 'text': |
|
303 | + case 'text': |
|
304 | 304 | $texts = explode("\n",$dummy_text); |
305 | 305 | return $texts[rand(0,count($texts)-1)]; |
306 | 306 | break; |
@@ -20,16 +20,16 @@ discard block |
||
20 | 20 | */ |
21 | 21 | class CourseRestorer |
22 | 22 | { |
23 | - /** |
|
24 | - * The course-object |
|
25 | - */ |
|
23 | + /** |
|
24 | + * The course-object |
|
25 | + */ |
|
26 | 26 | public $course; |
27 | 27 | public $destination_course_info; |
28 | 28 | |
29 | - /** |
|
30 | - * What to do with files with same name (FILE_SKIP, FILE_RENAME or |
|
31 | - * FILE_OVERWRITE) |
|
32 | - */ |
|
29 | + /** |
|
30 | + * What to do with files with same name (FILE_SKIP, FILE_RENAME or |
|
31 | + * FILE_OVERWRITE) |
|
32 | + */ |
|
33 | 33 | public $file_option; |
34 | 34 | public $set_tools_invisible_by_default; |
35 | 35 | public $skip_content; |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | 'events', |
42 | 42 | 'forum_category', |
43 | 43 | 'forums', |
44 | - // 'forum_topics', |
|
44 | + // 'forum_topics', |
|
45 | 45 | 'glossary', |
46 | 46 | 'quizzes', |
47 | 47 | 'test_category', |
@@ -109,15 +109,15 @@ discard block |
||
109 | 109 | $this->tool_copy_settings = $array; |
110 | 110 | } |
111 | 111 | |
112 | - /** |
|
113 | - * Restore a course. |
|
112 | + /** |
|
113 | + * Restore a course. |
|
114 | 114 | * |
115 | - * @param string $destination_course_code code of the Chamilo-course in |
|
116 | - * @param int $session_id |
|
117 | - * @param bool $update_course_settings Course settings are going to be restore? |
|
115 | + * @param string $destination_course_code code of the Chamilo-course in |
|
116 | + * @param int $session_id |
|
117 | + * @param bool $update_course_settings Course settings are going to be restore? |
|
118 | 118 | * @param bool $respect_base_content |
119 | 119 | * @return false|null |
120 | - */ |
|
120 | + */ |
|
121 | 121 | public function restore( |
122 | 122 | $destination_course_code = '', |
123 | 123 | $session_id = 0, |
@@ -260,17 +260,17 @@ discard block |
||
260 | 260 | } |
261 | 261 | } |
262 | 262 | |
263 | - /** |
|
264 | - * Restore only harmless course settings: |
|
263 | + /** |
|
264 | + * Restore only harmless course settings: |
|
265 | 265 | * course_language, visibility, department_name,department_url, |
266 | 266 | * subscribe, unsubscribe ,category_code |
267 | - * |
|
268 | - * @param string $destination_course_code |
|
269 | - */ |
|
267 | + * |
|
268 | + * @param string $destination_course_code |
|
269 | + */ |
|
270 | 270 | public function restore_course_settings($destination_course_code) |
271 | 271 | { |
272 | - $origin_course_info = api_get_course_info($destination_course_code); |
|
273 | - $course_info = $this->course->info; |
|
272 | + $origin_course_info = api_get_course_info($destination_course_code); |
|
273 | + $course_info = $this->course->info; |
|
274 | 274 | $params['course_language'] = $course_info['language']; |
275 | 275 | $params['visibility'] = $course_info['visibility']; |
276 | 276 | $params['department_name'] = $course_info['department_name']; |
@@ -279,8 +279,8 @@ discard block |
||
279 | 279 | $params['category_code'] = $course_info['categoryCode']; |
280 | 280 | $params['subscribe'] = $course_info['subscribe_allowed']; |
281 | 281 | $params['unsubscribe'] = $course_info['unsubscribe']; |
282 | - CourseManager::update_attributes($origin_course_info['real_id'], $params); |
|
283 | - } |
|
282 | + CourseManager::update_attributes($origin_course_info['real_id'], $params); |
|
283 | + } |
|
284 | 284 | |
285 | 285 | /** |
286 | 286 | * Restore documents |
@@ -294,11 +294,11 @@ discard block |
||
294 | 294 | $course_info = api_get_course_info($destination_course_code); |
295 | 295 | |
296 | 296 | if ($this->course->has_resources(RESOURCE_DOCUMENT)) { |
297 | - $table = Database :: get_course_table(TABLE_DOCUMENT); |
|
298 | - $resources = $this->course->resources; |
|
297 | + $table = Database :: get_course_table(TABLE_DOCUMENT); |
|
298 | + $resources = $this->course->resources; |
|
299 | 299 | $path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/'; |
300 | 300 | |
301 | - foreach ($resources[RESOURCE_DOCUMENT] as $id => $document) { |
|
301 | + foreach ($resources[RESOURCE_DOCUMENT] as $id => $document) { |
|
302 | 302 | |
303 | 303 | if (empty($document->item_properties[0]['id_session'])) { |
304 | 304 | $my_session_id = 0; |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | } |
369 | 369 | } |
370 | 370 | } |
371 | - } elseif ($document->file_type == DOCUMENT) { |
|
371 | + } elseif ($document->file_type == DOCUMENT) { |
|
372 | 372 | //Checking if folder exists in the database otherwise we created it |
373 | 373 | $dir_to_create = dirname($document->path); |
374 | 374 | |
@@ -424,19 +424,19 @@ discard block |
||
424 | 424 | } |
425 | 425 | } |
426 | 426 | |
427 | - if (file_exists($path.$document->path)) { |
|
428 | - switch ($this->file_option) { |
|
429 | - case FILE_OVERWRITE: |
|
427 | + if (file_exists($path.$document->path)) { |
|
428 | + switch ($this->file_option) { |
|
429 | + case FILE_OVERWRITE: |
|
430 | 430 | $origin_path = $this->course->backup_path.'/'.$document->path; |
431 | 431 | |
432 | - if (file_exists($origin_path)) { |
|
433 | - copy($origin_path, $path.$document->path); |
|
432 | + if (file_exists($origin_path)) { |
|
433 | + copy($origin_path, $path.$document->path); |
|
434 | 434 | $sql = "SELECT id FROM $table |
435 | 435 | WHERE |
436 | 436 | c_id = ".$this->destination_course_id." AND |
437 | 437 | path = '/".self::DBUTF8escapestring(substr($document->path, 9))."'"; |
438 | 438 | |
439 | - $res = Database::query($sql); |
|
439 | + $res = Database::query($sql); |
|
440 | 440 | $count = Database::num_rows($res); |
441 | 441 | |
442 | 442 | if ($count == 0) { |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | 'readonly' => 0 |
452 | 452 | ]; |
453 | 453 | |
454 | - $document_id = Database::insert($table, $params); |
|
454 | + $document_id = Database::insert($table, $params); |
|
455 | 455 | |
456 | 456 | if ($document_id) { |
457 | 457 | $sql = "UPDATE $table SET id = iid WHERE iid = $document_id"; |
@@ -559,83 +559,83 @@ discard block |
||
559 | 559 | ], |
560 | 560 | ] |
561 | 561 | ); |
562 | - } |
|
562 | + } |
|
563 | 563 | |
564 | - break; |
|
565 | - case FILE_SKIP: |
|
566 | - $sql = "SELECT id FROM $table |
|
564 | + break; |
|
565 | + case FILE_SKIP: |
|
566 | + $sql = "SELECT id FROM $table |
|
567 | 567 | WHERE |
568 | 568 | c_id = ".$this->destination_course_id." AND |
569 | 569 | path='/".self::DBUTF8escapestring(substr($document->path, 9))."'"; |
570 | - $res = Database::query($sql); |
|
571 | - $obj = Database::fetch_object($res); |
|
572 | - $this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = $obj->id; |
|
573 | - break; |
|
574 | - case FILE_RENAME: |
|
575 | - $i = 1; |
|
576 | - $ext = explode('.', basename($document->path)); |
|
577 | - if (count($ext) > 1) { |
|
578 | - $ext = array_pop($ext); |
|
579 | - $file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1)); |
|
580 | - $ext = '.'.$ext; |
|
581 | - } else { |
|
582 | - $ext = ''; |
|
583 | - $file_name_no_ext = $document->path; |
|
584 | - } |
|
585 | - $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
586 | - $file_exists = file_exists($path.$new_file_name); |
|
587 | - while ($file_exists) { |
|
588 | - $i ++; |
|
589 | - $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
590 | - $file_exists = file_exists($path.$new_file_name); |
|
591 | - } |
|
592 | - |
|
593 | - if (!empty($session_id)) { |
|
594 | - |
|
595 | - $document_path = explode('/',$document->path,3); |
|
596 | - $course_path = $path; |
|
597 | - $orig_base_folder = $document_path[1]; |
|
598 | - $orig_base_path = $course_path.$document_path[0].'/'.$document_path[1]; |
|
599 | - |
|
600 | - if (is_dir($orig_base_path)) { |
|
601 | - |
|
602 | - $new_base_foldername = $orig_base_folder; |
|
603 | - $new_base_path = $orig_base_path; |
|
604 | - |
|
605 | - if ($_SESSION['orig_base_foldername'] != $new_base_foldername) { |
|
606 | - unset($_SESSION['new_base_foldername']); |
|
607 | - unset($_SESSION['orig_base_foldername']); |
|
608 | - unset($_SESSION['new_base_path']); |
|
609 | - } |
|
610 | - |
|
611 | - $folder_exists = file_exists($new_base_path); |
|
612 | - if ($folder_exists) { |
|
613 | - $_SESSION['orig_base_foldername'] = $new_base_foldername; // e.g: carpeta1 in session |
|
614 | - $x = ''; |
|
615 | - while ($folder_exists) { |
|
616 | - $x = $x + 1; |
|
617 | - $new_base_foldername = $document_path[1].'_'.$x; |
|
618 | - $new_base_path = $orig_base_path.'_'.$x; |
|
570 | + $res = Database::query($sql); |
|
571 | + $obj = Database::fetch_object($res); |
|
572 | + $this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = $obj->id; |
|
573 | + break; |
|
574 | + case FILE_RENAME: |
|
575 | + $i = 1; |
|
576 | + $ext = explode('.', basename($document->path)); |
|
577 | + if (count($ext) > 1) { |
|
578 | + $ext = array_pop($ext); |
|
579 | + $file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1)); |
|
580 | + $ext = '.'.$ext; |
|
581 | + } else { |
|
582 | + $ext = ''; |
|
583 | + $file_name_no_ext = $document->path; |
|
584 | + } |
|
585 | + $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
586 | + $file_exists = file_exists($path.$new_file_name); |
|
587 | + while ($file_exists) { |
|
588 | + $i ++; |
|
589 | + $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
590 | + $file_exists = file_exists($path.$new_file_name); |
|
591 | + } |
|
592 | + |
|
593 | + if (!empty($session_id)) { |
|
594 | + |
|
595 | + $document_path = explode('/',$document->path,3); |
|
596 | + $course_path = $path; |
|
597 | + $orig_base_folder = $document_path[1]; |
|
598 | + $orig_base_path = $course_path.$document_path[0].'/'.$document_path[1]; |
|
599 | + |
|
600 | + if (is_dir($orig_base_path)) { |
|
601 | + |
|
602 | + $new_base_foldername = $orig_base_folder; |
|
603 | + $new_base_path = $orig_base_path; |
|
604 | + |
|
605 | + if ($_SESSION['orig_base_foldername'] != $new_base_foldername) { |
|
606 | + unset($_SESSION['new_base_foldername']); |
|
607 | + unset($_SESSION['orig_base_foldername']); |
|
608 | + unset($_SESSION['new_base_path']); |
|
609 | + } |
|
610 | + |
|
611 | + $folder_exists = file_exists($new_base_path); |
|
612 | + if ($folder_exists) { |
|
613 | + $_SESSION['orig_base_foldername'] = $new_base_foldername; // e.g: carpeta1 in session |
|
614 | + $x = ''; |
|
615 | + while ($folder_exists) { |
|
616 | + $x = $x + 1; |
|
617 | + $new_base_foldername = $document_path[1].'_'.$x; |
|
618 | + $new_base_path = $orig_base_path.'_'.$x; |
|
619 | 619 | if ($_SESSION['new_base_foldername'] == $new_base_foldername) { |
620 | 620 | break; |
621 | 621 | } |
622 | - $folder_exists = file_exists($new_base_path); |
|
623 | - } |
|
624 | - $_SESSION['new_base_foldername'] = $new_base_foldername; |
|
625 | - $_SESSION['new_base_path'] = $new_base_path; |
|
626 | - } |
|
627 | - |
|
628 | - if (isset($_SESSION['new_base_foldername']) && isset($_SESSION['new_base_path'])) { |
|
629 | - $new_base_foldername = $_SESSION['new_base_foldername']; |
|
630 | - $new_base_path = $_SESSION['new_base_path']; |
|
631 | - } |
|
632 | - |
|
633 | - $dest_document_path = $new_base_path.'/'.$document_path[2]; // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1/collaborative.png" |
|
634 | - $basedir_dest_path = dirname($dest_document_path); // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1" |
|
635 | - $base_path_document = $course_path.$document_path[0]; // e.g: "/var/www/wiener/courses/CURSO4/document" |
|
636 | - $path_title = '/'.$new_base_foldername.'/'.$document_path[2]; |
|
637 | - |
|
638 | - copy_folder_course_session( |
|
622 | + $folder_exists = file_exists($new_base_path); |
|
623 | + } |
|
624 | + $_SESSION['new_base_foldername'] = $new_base_foldername; |
|
625 | + $_SESSION['new_base_path'] = $new_base_path; |
|
626 | + } |
|
627 | + |
|
628 | + if (isset($_SESSION['new_base_foldername']) && isset($_SESSION['new_base_path'])) { |
|
629 | + $new_base_foldername = $_SESSION['new_base_foldername']; |
|
630 | + $new_base_path = $_SESSION['new_base_path']; |
|
631 | + } |
|
632 | + |
|
633 | + $dest_document_path = $new_base_path.'/'.$document_path[2]; // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1/collaborative.png" |
|
634 | + $basedir_dest_path = dirname($dest_document_path); // e.g: "/var/www/wiener/courses/CURSO4/document/carpeta1_1/subcarpeta1" |
|
635 | + $base_path_document = $course_path.$document_path[0]; // e.g: "/var/www/wiener/courses/CURSO4/document" |
|
636 | + $path_title = '/'.$new_base_foldername.'/'.$document_path[2]; |
|
637 | + |
|
638 | + copy_folder_course_session( |
|
639 | 639 | $basedir_dest_path, |
640 | 640 | $base_path_document, |
641 | 641 | $session_id, |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | 'session_id' => $my_session_id, |
678 | 678 | ]; |
679 | 679 | |
680 | - $document_id = Database::insert($table, $params); |
|
680 | + $document_id = Database::insert($table, $params); |
|
681 | 681 | |
682 | 682 | if ($document_id) { |
683 | 683 | $sql = "UPDATE $table SET id = iid WHERE iid = $document_id"; |
@@ -706,10 +706,10 @@ discard block |
||
706 | 706 | null, |
707 | 707 | $my_session_id |
708 | 708 | ); |
709 | - } else { |
|
710 | - if (file_exists($path.$document->path)) { |
|
709 | + } else { |
|
710 | + if (file_exists($path.$document->path)) { |
|
711 | 711 | copy($path.$document->path, $path.$new_file_name); |
712 | - } |
|
712 | + } |
|
713 | 713 | //Replace old course code with the new destination code see BT#1985 |
714 | 714 | if (file_exists($path.$new_file_name)) { |
715 | 715 | $file_info = pathinfo($path.$new_file_name); |
@@ -768,10 +768,10 @@ discard block |
||
768 | 768 | $my_session_id |
769 | 769 | ); |
770 | 770 | } |
771 | - } |
|
772 | - } else { |
|
771 | + } |
|
772 | + } else { |
|
773 | 773 | |
774 | - copy($this->course->backup_path.'/'.$document->path, $path.$new_file_name); |
|
774 | + copy($this->course->backup_path.'/'.$document->path, $path.$new_file_name); |
|
775 | 775 | |
776 | 776 | //Replace old course code with the new destination code see BT#1985 |
777 | 777 | if (file_exists($path.$new_file_name)) { |
@@ -831,20 +831,20 @@ discard block |
||
831 | 831 | null, |
832 | 832 | $my_session_id |
833 | 833 | ); |
834 | - } |
|
835 | - break; |
|
836 | - |
|
837 | - } // end switch |
|
838 | - } else { |
|
839 | - // end if file exists |
|
840 | - //make sure the source file actually exists |
|
841 | - if (is_file($this->course->backup_path.'/'.$document->path) && |
|
834 | + } |
|
835 | + break; |
|
836 | + |
|
837 | + } // end switch |
|
838 | + } else { |
|
839 | + // end if file exists |
|
840 | + //make sure the source file actually exists |
|
841 | + if (is_file($this->course->backup_path.'/'.$document->path) && |
|
842 | 842 | is_readable($this->course->backup_path.'/'.$document->path) && |
843 | 843 | is_dir(dirname($path.$document->path)) && |
844 | 844 | is_writeable(dirname($path.$document->path)) |
845 | 845 | ) { |
846 | - //echo 'Copying'; |
|
847 | - copy($this->course->backup_path.'/'.$document->path, $path.$document->path); |
|
846 | + //echo 'Copying'; |
|
847 | + copy($this->course->backup_path.'/'.$document->path, $path.$document->path); |
|
848 | 848 | |
849 | 849 | //Replace old course code with the new destination code see BT#1985 |
850 | 850 | if (file_exists($path.$document->path)) { |
@@ -883,7 +883,7 @@ discard block |
||
883 | 883 | Database::query($sql); |
884 | 884 | } |
885 | 885 | |
886 | - $this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = $document_id; |
|
886 | + $this->course->resources[RESOURCE_DOCUMENT][$id]->destination_id = $document_id; |
|
887 | 887 | |
888 | 888 | $itemProperty = isset($document->item_properties[0]) ? $document->item_properties[0] : ''; |
889 | 889 | $insertUserId = isset($itemProperty['insert_user_id']) ? $itemProperty['insert_user_id'] : api_get_user_id(); |
@@ -905,78 +905,78 @@ discard block |
||
905 | 905 | null, |
906 | 906 | $my_session_id |
907 | 907 | ); |
908 | - } else { |
|
909 | - if (is_file($this->course->backup_path.'/'.$document->path) && |
|
908 | + } else { |
|
909 | + if (is_file($this->course->backup_path.'/'.$document->path) && |
|
910 | 910 | is_readable($this->course->backup_path.'/'.$document->path) |
911 | 911 | ) { |
912 | - error_log('Course copy generated an ignoreable error while trying to copy '.$this->course->backup_path.'/'.$document->path.': file not found'); |
|
913 | - } |
|
914 | - if (!is_dir(dirname($path.$document->path))) { |
|
915 | - error_log('Course copy generated an ignoreable error while trying to copy to '.dirname($path.$document->path).': directory not found'); |
|
916 | - } |
|
917 | - if (!is_writeable(dirname($path.$document->path))) { |
|
918 | - error_log('Course copy generated an ignoreable error while trying to copy to '.dirname($path.$document->path).': directory not writeable'); |
|
919 | - } |
|
920 | - } |
|
921 | - } // end file doesn't exist |
|
922 | - } |
|
923 | - } // end for each |
|
924 | - |
|
925 | - // Delete sessions for the copy the new folder in session |
|
926 | - unset($_SESSION['new_base_foldername']); |
|
927 | - unset($_SESSION['orig_base_foldername']); |
|
928 | - unset($_SESSION['new_base_path']); |
|
929 | - } |
|
930 | - } |
|
931 | - |
|
932 | - /** |
|
933 | - * Restore scorm documents |
|
934 | - * TODO @TODO check that the restore function with renaming doesn't break the scorm structure! |
|
912 | + error_log('Course copy generated an ignoreable error while trying to copy '.$this->course->backup_path.'/'.$document->path.': file not found'); |
|
913 | + } |
|
914 | + if (!is_dir(dirname($path.$document->path))) { |
|
915 | + error_log('Course copy generated an ignoreable error while trying to copy to '.dirname($path.$document->path).': directory not found'); |
|
916 | + } |
|
917 | + if (!is_writeable(dirname($path.$document->path))) { |
|
918 | + error_log('Course copy generated an ignoreable error while trying to copy to '.dirname($path.$document->path).': directory not writeable'); |
|
919 | + } |
|
920 | + } |
|
921 | + } // end file doesn't exist |
|
922 | + } |
|
923 | + } // end for each |
|
924 | + |
|
925 | + // Delete sessions for the copy the new folder in session |
|
926 | + unset($_SESSION['new_base_foldername']); |
|
927 | + unset($_SESSION['orig_base_foldername']); |
|
928 | + unset($_SESSION['new_base_path']); |
|
929 | + } |
|
930 | + } |
|
931 | + |
|
932 | + /** |
|
933 | + * Restore scorm documents |
|
934 | + * TODO @TODO check that the restore function with renaming doesn't break the scorm structure! |
|
935 | 935 | * see #7029 |
936 | - */ |
|
937 | - public function restore_scorm_documents() |
|
936 | + */ |
|
937 | + public function restore_scorm_documents() |
|
938 | 938 | { |
939 | - $perm = api_get_permissions_for_new_directories(); |
|
939 | + $perm = api_get_permissions_for_new_directories(); |
|
940 | 940 | |
941 | - if ($this->course->has_resources(RESOURCE_SCORM)) { |
|
942 | - $resources = $this->course->resources; |
|
941 | + if ($this->course->has_resources(RESOURCE_SCORM)) { |
|
942 | + $resources = $this->course->resources; |
|
943 | 943 | |
944 | - foreach ($resources[RESOURCE_SCORM] as $document) { |
|
945 | - $path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/'; |
|
946 | - @mkdir(dirname($path.$document->path), $perm, true); |
|
944 | + foreach ($resources[RESOURCE_SCORM] as $document) { |
|
945 | + $path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/'; |
|
946 | + @mkdir(dirname($path.$document->path), $perm, true); |
|
947 | 947 | |
948 | - if (file_exists($path.$document->path)) { |
|
949 | - switch ($this->file_option) { |
|
950 | - case FILE_OVERWRITE: |
|
951 | - rmdirr($path.$document->path); |
|
948 | + if (file_exists($path.$document->path)) { |
|
949 | + switch ($this->file_option) { |
|
950 | + case FILE_OVERWRITE: |
|
951 | + rmdirr($path.$document->path); |
|
952 | 952 | copyDirTo( |
953 | 953 | $this->course->backup_path . '/' . $document->path, |
954 | 954 | $path . dirname($document->path), |
955 | 955 | false |
956 | 956 | ); |
957 | - break; |
|
958 | - case FILE_SKIP: |
|
959 | - break; |
|
957 | + break; |
|
958 | + case FILE_SKIP: |
|
959 | + break; |
|
960 | 960 | case FILE_RENAME: |
961 | - $i = 1; |
|
962 | - $ext = explode('.', basename($document->path)); |
|
963 | - if (count($ext) > 1) { |
|
964 | - $ext = array_pop($ext); |
|
965 | - $file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1)); |
|
966 | - $ext = '.'.$ext; |
|
967 | - } else { |
|
968 | - $ext = ''; |
|
969 | - $file_name_no_ext = $document->path; |
|
970 | - } |
|
971 | - |
|
972 | - $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
973 | - $file_exists = file_exists($path.$new_file_name); |
|
974 | - |
|
975 | - while ($file_exists) { |
|
976 | - $i ++; |
|
977 | - $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
978 | - $file_exists = file_exists($path.$new_file_name); |
|
979 | - } |
|
961 | + $i = 1; |
|
962 | + $ext = explode('.', basename($document->path)); |
|
963 | + if (count($ext) > 1) { |
|
964 | + $ext = array_pop($ext); |
|
965 | + $file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1)); |
|
966 | + $ext = '.'.$ext; |
|
967 | + } else { |
|
968 | + $ext = ''; |
|
969 | + $file_name_no_ext = $document->path; |
|
970 | + } |
|
971 | + |
|
972 | + $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
973 | + $file_exists = file_exists($path.$new_file_name); |
|
974 | + |
|
975 | + while ($file_exists) { |
|
976 | + $i ++; |
|
977 | + $new_file_name = $file_name_no_ext.'_'.$i.$ext; |
|
978 | + $file_exists = file_exists($path.$new_file_name); |
|
979 | + } |
|
980 | 980 | |
981 | 981 | rename( |
982 | 982 | $this->course->backup_path . '/' . $document->path, |
@@ -992,30 +992,30 @@ discard block |
||
992 | 992 | $this->course->backup_path . '/' . $document->path |
993 | 993 | ); |
994 | 994 | |
995 | - break; |
|
996 | - } // end switch |
|
997 | - } else { |
|
995 | + break; |
|
996 | + } // end switch |
|
997 | + } else { |
|
998 | 998 | // end if file exists |
999 | 999 | copyDirTo( |
1000 | 1000 | $this->course->backup_path . '/' . $document->path, |
1001 | 1001 | $path . dirname($document->path), |
1002 | 1002 | false |
1003 | 1003 | ); |
1004 | - } |
|
1005 | - } // end for each |
|
1006 | - } |
|
1007 | - } |
|
1008 | - |
|
1009 | - /** |
|
1010 | - * Restore forums |
|
1011 | - */ |
|
1012 | - public function restore_forums($sessionId = 0) |
|
1004 | + } |
|
1005 | + } // end for each |
|
1006 | + } |
|
1007 | + } |
|
1008 | + |
|
1009 | + /** |
|
1010 | + * Restore forums |
|
1011 | + */ |
|
1012 | + public function restore_forums($sessionId = 0) |
|
1013 | 1013 | { |
1014 | - if ($this->course->has_resources(RESOURCE_FORUM)) { |
|
1014 | + if ($this->course->has_resources(RESOURCE_FORUM)) { |
|
1015 | 1015 | $sessionId = intval($sessionId); |
1016 | - $table_forum = Database::get_course_table(TABLE_FORUM); |
|
1017 | - $resources = $this->course->resources; |
|
1018 | - foreach ($resources[RESOURCE_FORUM] as $id => $forum) { |
|
1016 | + $table_forum = Database::get_course_table(TABLE_FORUM); |
|
1017 | + $resources = $this->course->resources; |
|
1018 | + foreach ($resources[RESOURCE_FORUM] as $id => $forum) { |
|
1019 | 1019 | $params = (array)$forum->obj; |
1020 | 1020 | $cat_id = ''; |
1021 | 1021 | if (isset($this->course->resources[RESOURCE_FORUMCATEGORY]) && |
@@ -1063,33 +1063,33 @@ discard block |
||
1063 | 1063 | Database::query($sql); |
1064 | 1064 | } |
1065 | 1065 | |
1066 | - $this->course->resources[RESOURCE_FORUM][$id]->destination_id = $new_id; |
|
1067 | - |
|
1068 | - $forum_topics = 0; |
|
1069 | - if (is_array($this->course->resources[RESOURCE_FORUMTOPIC])) { |
|
1070 | - foreach ($this->course->resources[RESOURCE_FORUMTOPIC] as $topic_id => $topic) { |
|
1071 | - if ($topic->obj->forum_id == $id) { |
|
1072 | - $this->restore_topic($topic_id, $new_id, $sessionId); |
|
1073 | - $forum_topics ++; |
|
1074 | - } |
|
1075 | - } |
|
1076 | - } |
|
1077 | - if ($forum_topics > 0) { |
|
1078 | - $sql = "UPDATE ".$table_forum." SET forum_threads = ".$forum_topics." |
|
1066 | + $this->course->resources[RESOURCE_FORUM][$id]->destination_id = $new_id; |
|
1067 | + |
|
1068 | + $forum_topics = 0; |
|
1069 | + if (is_array($this->course->resources[RESOURCE_FORUMTOPIC])) { |
|
1070 | + foreach ($this->course->resources[RESOURCE_FORUMTOPIC] as $topic_id => $topic) { |
|
1071 | + if ($topic->obj->forum_id == $id) { |
|
1072 | + $this->restore_topic($topic_id, $new_id, $sessionId); |
|
1073 | + $forum_topics ++; |
|
1074 | + } |
|
1075 | + } |
|
1076 | + } |
|
1077 | + if ($forum_topics > 0) { |
|
1078 | + $sql = "UPDATE ".$table_forum." SET forum_threads = ".$forum_topics." |
|
1079 | 1079 | WHERE c_id = {$this->destination_course_id} AND forum_id = ".(int)$new_id; |
1080 | - Database::query($sql); |
|
1081 | - } |
|
1082 | - } |
|
1083 | - } |
|
1084 | - } |
|
1085 | - |
|
1086 | - /** |
|
1087 | - * Restore forum-categories |
|
1088 | - */ |
|
1080 | + Database::query($sql); |
|
1081 | + } |
|
1082 | + } |
|
1083 | + } |
|
1084 | + } |
|
1085 | + |
|
1086 | + /** |
|
1087 | + * Restore forum-categories |
|
1088 | + */ |
|
1089 | 1089 | public function restore_forum_category($my_id = null, $sessionId = 0) |
1090 | 1090 | { |
1091 | - $forum_cat_table = Database :: get_course_table(TABLE_FORUM_CATEGORY); |
|
1092 | - $resources = $this->course->resources; |
|
1091 | + $forum_cat_table = Database :: get_course_table(TABLE_FORUM_CATEGORY); |
|
1092 | + $resources = $this->course->resources; |
|
1093 | 1093 | if (!empty($resources[RESOURCE_FORUMCATEGORY])) { |
1094 | 1094 | foreach ($resources[RESOURCE_FORUMCATEGORY] as $id => $forum_cat) { |
1095 | 1095 | if (!empty($my_id)) { |
@@ -1135,16 +1135,16 @@ discard block |
||
1135 | 1135 | } |
1136 | 1136 | } |
1137 | 1137 | } |
1138 | - } |
|
1138 | + } |
|
1139 | 1139 | |
1140 | - /** |
|
1141 | - * Restore a forum-topic |
|
1142 | - * @param false|string $forum_id |
|
1143 | - */ |
|
1140 | + /** |
|
1141 | + * Restore a forum-topic |
|
1142 | + * @param false|string $forum_id |
|
1143 | + */ |
|
1144 | 1144 | public function restore_topic($thread_id, $forum_id, $sessionId = 0) |
1145 | 1145 | { |
1146 | - $table = Database :: get_course_table(TABLE_FORUM_THREAD); |
|
1147 | - $topic = $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]; |
|
1146 | + $table = Database :: get_course_table(TABLE_FORUM_THREAD); |
|
1147 | + $topic = $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]; |
|
1148 | 1148 | |
1149 | 1149 | $params = (array)$topic->obj; |
1150 | 1150 | $params = self::DBUTF8_array($params); |
@@ -1181,27 +1181,27 @@ discard block |
||
1181 | 1181 | $sessionId |
1182 | 1182 | ); |
1183 | 1183 | |
1184 | - $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]->destination_id = $new_id; |
|
1185 | - $topic_replies = -1; |
|
1186 | - |
|
1187 | - foreach ($this->course->resources[RESOURCE_FORUMPOST] as $post_id => $post) { |
|
1188 | - if ($post->obj->thread_id == $thread_id) { |
|
1189 | - $topic_replies++; |
|
1190 | - $this->restore_post($post_id, $new_id, $forum_id, $sessionId); |
|
1191 | - } |
|
1192 | - } |
|
1193 | - return $new_id; |
|
1194 | - } |
|
1195 | - |
|
1196 | - /** |
|
1197 | - * Restore a forum-post |
|
1198 | - * @TODO Restore tree-structure of posts. For example: attachments to posts. |
|
1199 | - * @param false|string $topic_id |
|
1200 | - */ |
|
1184 | + $this->course->resources[RESOURCE_FORUMTOPIC][$thread_id]->destination_id = $new_id; |
|
1185 | + $topic_replies = -1; |
|
1186 | + |
|
1187 | + foreach ($this->course->resources[RESOURCE_FORUMPOST] as $post_id => $post) { |
|
1188 | + if ($post->obj->thread_id == $thread_id) { |
|
1189 | + $topic_replies++; |
|
1190 | + $this->restore_post($post_id, $new_id, $forum_id, $sessionId); |
|
1191 | + } |
|
1192 | + } |
|
1193 | + return $new_id; |
|
1194 | + } |
|
1195 | + |
|
1196 | + /** |
|
1197 | + * Restore a forum-post |
|
1198 | + * @TODO Restore tree-structure of posts. For example: attachments to posts. |
|
1199 | + * @param false|string $topic_id |
|
1200 | + */ |
|
1201 | 1201 | public function restore_post($id, $topic_id, $forum_id, $sessionId = 0) |
1202 | 1202 | { |
1203 | - $table_post = Database :: get_course_table(TABLE_FORUM_POST); |
|
1204 | - $post = $this->course->resources[RESOURCE_FORUMPOST][$id]; |
|
1203 | + $table_post = Database :: get_course_table(TABLE_FORUM_POST); |
|
1204 | + $post = $this->course->resources[RESOURCE_FORUMPOST][$id]; |
|
1205 | 1205 | $params = (array) $post->obj; |
1206 | 1206 | $params['c_id'] = $this->destination_course_id; |
1207 | 1207 | $params['forum_id'] = $forum_id; |
@@ -1236,37 +1236,37 @@ discard block |
||
1236 | 1236 | null, |
1237 | 1237 | $sessionId |
1238 | 1238 | ); |
1239 | - $this->course->resources[RESOURCE_FORUMPOST][$id]->destination_id = $new_id; |
|
1239 | + $this->course->resources[RESOURCE_FORUMPOST][$id]->destination_id = $new_id; |
|
1240 | 1240 | |
1241 | - return $new_id; |
|
1242 | - } |
|
1241 | + return $new_id; |
|
1242 | + } |
|
1243 | 1243 | |
1244 | - /** |
|
1245 | - * Restore links |
|
1246 | - */ |
|
1244 | + /** |
|
1245 | + * Restore links |
|
1246 | + */ |
|
1247 | 1247 | public function restore_links($session_id = 0) |
1248 | 1248 | { |
1249 | - if ($this->course->has_resources(RESOURCE_LINK)) { |
|
1250 | - $link_table = Database :: get_course_table(TABLE_LINK); |
|
1251 | - $resources = $this->course->resources; |
|
1249 | + if ($this->course->has_resources(RESOURCE_LINK)) { |
|
1250 | + $link_table = Database :: get_course_table(TABLE_LINK); |
|
1251 | + $resources = $this->course->resources; |
|
1252 | 1252 | |
1253 | - foreach ($resources[RESOURCE_LINK] as $id => $link) { |
|
1253 | + foreach ($resources[RESOURCE_LINK] as $id => $link) { |
|
1254 | 1254 | $cat_id = $this->restore_link_category( |
1255 | 1255 | $link->category_id, |
1256 | 1256 | $session_id |
1257 | 1257 | ); |
1258 | - $sql = "SELECT MAX(display_order) |
|
1258 | + $sql = "SELECT MAX(display_order) |
|
1259 | 1259 | FROM $link_table |
1260 | 1260 | WHERE |
1261 | 1261 | c_id = ".$this->destination_course_id." AND |
1262 | 1262 | category_id='" . intval($cat_id). "'"; |
1263 | - $result = Database::query($sql); |
|
1264 | - list($max_order) = Database::fetch_array($result); |
|
1263 | + $result = Database::query($sql); |
|
1264 | + list($max_order) = Database::fetch_array($result); |
|
1265 | 1265 | |
1266 | 1266 | $params = []; |
1267 | - if (!empty($session_id)) { |
|
1267 | + if (!empty($session_id)) { |
|
1268 | 1268 | $params['session_id'] = $session_id; |
1269 | - } |
|
1269 | + } |
|
1270 | 1270 | |
1271 | 1271 | $params['c_id'] = $this->destination_course_id; |
1272 | 1272 | $params['url'] = self::DBUTF8($link->url); |
@@ -1295,9 +1295,9 @@ discard block |
||
1295 | 1295 | } |
1296 | 1296 | $this->course->resources[RESOURCE_LINK][$id]->destination_id = $id; |
1297 | 1297 | } |
1298 | - } |
|
1299 | - } |
|
1300 | - } |
|
1298 | + } |
|
1299 | + } |
|
1300 | + } |
|
1301 | 1301 | |
1302 | 1302 | /** |
1303 | 1303 | * Restore a link-category |
@@ -1341,21 +1341,21 @@ discard block |
||
1341 | 1341 | return $this->course->resources[RESOURCE_LINKCATEGORY][$id]->destination_id; |
1342 | 1342 | } |
1343 | 1343 | |
1344 | - /** |
|
1345 | - * Restore tool intro |
|
1346 | - */ |
|
1344 | + /** |
|
1345 | + * Restore tool intro |
|
1346 | + */ |
|
1347 | 1347 | public function restore_tool_intro($sessionId = 0) |
1348 | 1348 | { |
1349 | - if ($this->course->has_resources(RESOURCE_TOOL_INTRO)) { |
|
1349 | + if ($this->course->has_resources(RESOURCE_TOOL_INTRO)) { |
|
1350 | 1350 | $sessionId = intval($sessionId); |
1351 | - $tool_intro_table = Database :: get_course_table(TABLE_TOOL_INTRO); |
|
1352 | - $resources = $this->course->resources; |
|
1353 | - foreach ($resources[RESOURCE_TOOL_INTRO] as $id => $tool_intro) { |
|
1354 | - $sql = "DELETE FROM ".$tool_intro_table." |
|
1351 | + $tool_intro_table = Database :: get_course_table(TABLE_TOOL_INTRO); |
|
1352 | + $resources = $this->course->resources; |
|
1353 | + foreach ($resources[RESOURCE_TOOL_INTRO] as $id => $tool_intro) { |
|
1354 | + $sql = "DELETE FROM ".$tool_intro_table." |
|
1355 | 1355 | WHERE |
1356 | 1356 | c_id = ".$this->destination_course_id." AND |
1357 | 1357 | id='".self::DBUTF8escapestring($tool_intro->id)."'"; |
1358 | - Database::query($sql); |
|
1358 | + Database::query($sql); |
|
1359 | 1359 | |
1360 | 1360 | $tool_intro->intro_text = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
1361 | 1361 | $tool_intro->intro_text, |
@@ -1383,21 +1383,21 @@ discard block |
||
1383 | 1383 | |
1384 | 1384 | $this->course->resources[RESOURCE_TOOL_INTRO][$id]->destination_id = $id; |
1385 | 1385 | } |
1386 | - } |
|
1387 | - } |
|
1388 | - } |
|
1386 | + } |
|
1387 | + } |
|
1388 | + } |
|
1389 | 1389 | |
1390 | - /** |
|
1391 | - * Restore events |
|
1392 | - */ |
|
1390 | + /** |
|
1391 | + * Restore events |
|
1392 | + */ |
|
1393 | 1393 | public function restore_events($sessionId = 0) |
1394 | 1394 | { |
1395 | - if ($this->course->has_resources(RESOURCE_EVENT)) { |
|
1395 | + if ($this->course->has_resources(RESOURCE_EVENT)) { |
|
1396 | 1396 | $sessionId = intval($sessionId); |
1397 | - $table = Database :: get_course_table(TABLE_AGENDA); |
|
1398 | - $resources = $this->course->resources; |
|
1399 | - foreach ($resources[RESOURCE_EVENT] as $id => $event) { |
|
1400 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1397 | + $table = Database :: get_course_table(TABLE_AGENDA); |
|
1398 | + $resources = $this->course->resources; |
|
1399 | + foreach ($resources[RESOURCE_EVENT] as $id => $event) { |
|
1400 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1401 | 1401 | $event->content = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
1402 | 1402 | $event->content, |
1403 | 1403 | $this->course->code, |
@@ -1415,7 +1415,7 @@ discard block |
||
1415 | 1415 | 'end_date' => $event->end_date, |
1416 | 1416 | 'session_id' => $sessionId, |
1417 | 1417 | ]; |
1418 | - $new_event_id = Database::insert($table, $params); |
|
1418 | + $new_event_id = Database::insert($table, $params); |
|
1419 | 1419 | |
1420 | 1420 | if ($new_event_id) { |
1421 | 1421 | $sql = "UPDATE $table SET id = iid WHERE iid = $new_event_id"; |
@@ -1428,30 +1428,30 @@ discard block |
||
1428 | 1428 | $this->course->resources[RESOURCE_EVENT][$id]->destination_id = $new_event_id; |
1429 | 1429 | } |
1430 | 1430 | |
1431 | - // Copy event attachment |
|
1431 | + // Copy event attachment |
|
1432 | 1432 | |
1433 | - $origin_path = $this->course->backup_path.'/upload/calendar/'; |
|
1434 | - $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/calendar/'; |
|
1433 | + $origin_path = $this->course->backup_path.'/upload/calendar/'; |
|
1434 | + $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/calendar/'; |
|
1435 | 1435 | |
1436 | - if (!empty($this->course->orig)) { |
|
1436 | + if (!empty($this->course->orig)) { |
|
1437 | 1437 | |
1438 | - $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
1439 | - $sql = 'SELECT path, comment, size, filename |
|
1438 | + $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
1439 | + $sql = 'SELECT path, comment, size, filename |
|
1440 | 1440 | FROM '.$table_attachment.' |
1441 | 1441 | WHERE c_id = '.$this->destination_course_id.' AND agenda_id = '.$id; |
1442 | - $attachment_event = Database::query($sql); |
|
1443 | - $attachment_event = Database::fetch_object($attachment_event); |
|
1442 | + $attachment_event = Database::query($sql); |
|
1443 | + $attachment_event = Database::fetch_object($attachment_event); |
|
1444 | 1444 | |
1445 | - if (file_exists($origin_path.$attachment_event->path) && |
|
1445 | + if (file_exists($origin_path.$attachment_event->path) && |
|
1446 | 1446 | !is_dir($origin_path.$attachment_event->path) |
1447 | 1447 | ) { |
1448 | - $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1449 | - $copy_result = copy($origin_path.$attachment_event->path, $destination_path.$new_filename); |
|
1450 | - //$copy_result = true; |
|
1451 | - if ($copy_result) { |
|
1452 | - $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
1448 | + $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1449 | + $copy_result = copy($origin_path.$attachment_event->path, $destination_path.$new_filename); |
|
1450 | + //$copy_result = true; |
|
1451 | + if ($copy_result) { |
|
1452 | + $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
1453 | 1453 | |
1454 | - $params = [ |
|
1454 | + $params = [ |
|
1455 | 1455 | 'c_id' => $this->destination_course_id, |
1456 | 1456 | 'path' => self::DBUTF8($new_filename), |
1457 | 1457 | 'comment' => self::DBUTF8($attachment_event->comment), |
@@ -1465,17 +1465,17 @@ discard block |
||
1465 | 1465 | Database::query($sql); |
1466 | 1466 | } |
1467 | 1467 | } |
1468 | - } |
|
1469 | - } else { |
|
1470 | - // get the info of the file |
|
1471 | - if (!empty($event->attachment_path) && |
|
1468 | + } |
|
1469 | + } else { |
|
1470 | + // get the info of the file |
|
1471 | + if (!empty($event->attachment_path) && |
|
1472 | 1472 | is_file($origin_path.$event->attachment_path) && |
1473 | 1473 | is_readable($origin_path.$event->attachment_path) |
1474 | 1474 | ) { |
1475 | - $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1476 | - $copy_result = copy($origin_path.$event->attachment_path, $destination_path.$new_filename); |
|
1477 | - if ($copy_result) { |
|
1478 | - $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
1475 | + $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1476 | + $copy_result = copy($origin_path.$event->attachment_path, $destination_path.$new_filename); |
|
1477 | + if ($copy_result) { |
|
1478 | + $table_attachment = Database :: get_course_table(TABLE_AGENDA_ATTACHMENT); |
|
1479 | 1479 | |
1480 | 1480 | $params = [ |
1481 | 1481 | 'c_id' => $this->destination_course_id, |
@@ -1491,29 +1491,29 @@ discard block |
||
1491 | 1491 | $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $id"; |
1492 | 1492 | Database::query($sql); |
1493 | 1493 | } |
1494 | - } |
|
1495 | - } |
|
1496 | - } |
|
1497 | - } |
|
1498 | - } |
|
1499 | - } |
|
1500 | - |
|
1501 | - /** |
|
1502 | - * Restore course-description |
|
1503 | - */ |
|
1494 | + } |
|
1495 | + } |
|
1496 | + } |
|
1497 | + } |
|
1498 | + } |
|
1499 | + } |
|
1500 | + |
|
1501 | + /** |
|
1502 | + * Restore course-description |
|
1503 | + */ |
|
1504 | 1504 | public function restore_course_descriptions($session_id = 0) |
1505 | 1505 | { |
1506 | - if ($this->course->has_resources(RESOURCE_COURSEDESCRIPTION)) { |
|
1507 | - $table = Database :: get_course_table(TABLE_COURSE_DESCRIPTION); |
|
1508 | - $resources = $this->course->resources; |
|
1509 | - foreach ($resources[RESOURCE_COURSEDESCRIPTION] as $id => $cd) { |
|
1506 | + if ($this->course->has_resources(RESOURCE_COURSEDESCRIPTION)) { |
|
1507 | + $table = Database :: get_course_table(TABLE_COURSE_DESCRIPTION); |
|
1508 | + $resources = $this->course->resources; |
|
1509 | + foreach ($resources[RESOURCE_COURSEDESCRIPTION] as $id => $cd) { |
|
1510 | 1510 | $courseDescription = (array) $cd; |
1511 | 1511 | |
1512 | 1512 | $content = isset($courseDescription['content']) ? $courseDescription['content'] : ''; |
1513 | 1513 | $descriptionType = isset($courseDescription['description_type']) ? $courseDescription['description_type'] : ''; |
1514 | 1514 | $title = isset($courseDescription['title']) ? $courseDescription['title'] : ''; |
1515 | 1515 | |
1516 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1516 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1517 | 1517 | $description_content = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
1518 | 1518 | $content, |
1519 | 1519 | $this->course->code, |
@@ -1542,22 +1542,22 @@ discard block |
||
1542 | 1542 | } |
1543 | 1543 | $this->course->resources[RESOURCE_COURSEDESCRIPTION][$id]->destination_id = $id; |
1544 | 1544 | } |
1545 | - } |
|
1546 | - } |
|
1547 | - } |
|
1545 | + } |
|
1546 | + } |
|
1547 | + } |
|
1548 | 1548 | |
1549 | - /** |
|
1550 | - * Restore announcements |
|
1551 | - */ |
|
1549 | + /** |
|
1550 | + * Restore announcements |
|
1551 | + */ |
|
1552 | 1552 | public function restore_announcements($sessionId = 0) |
1553 | 1553 | { |
1554 | - if ($this->course->has_resources(RESOURCE_ANNOUNCEMENT)) { |
|
1554 | + if ($this->course->has_resources(RESOURCE_ANNOUNCEMENT)) { |
|
1555 | 1555 | $sessionId = intval($sessionId); |
1556 | - $table = Database :: get_course_table(TABLE_ANNOUNCEMENT); |
|
1557 | - $resources = $this->course->resources; |
|
1558 | - foreach ($resources[RESOURCE_ANNOUNCEMENT] as $id => $announcement) { |
|
1556 | + $table = Database :: get_course_table(TABLE_ANNOUNCEMENT); |
|
1557 | + $resources = $this->course->resources; |
|
1558 | + foreach ($resources[RESOURCE_ANNOUNCEMENT] as $id => $announcement) { |
|
1559 | 1559 | |
1560 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1560 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1561 | 1561 | $announcement->content = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
1562 | 1562 | $announcement->content, |
1563 | 1563 | $this->course->code, |
@@ -1576,7 +1576,7 @@ discard block |
||
1576 | 1576 | 'session_id' => $sessionId, |
1577 | 1577 | ]; |
1578 | 1578 | |
1579 | - $new_announcement_id = Database::insert($table, $params); |
|
1579 | + $new_announcement_id = Database::insert($table, $params); |
|
1580 | 1580 | |
1581 | 1581 | if ($new_announcement_id) { |
1582 | 1582 | $sql = "UPDATE $table SET id = iid WHERE iid = $new_announcement_id"; |
@@ -1588,32 +1588,32 @@ discard block |
||
1588 | 1588 | $this->course->resources[RESOURCE_ANNOUNCEMENT][$id]->destination_id = $new_announcement_id; |
1589 | 1589 | } |
1590 | 1590 | |
1591 | - $origin_path = $this->course->backup_path.'/upload/announcements/'; |
|
1592 | - $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/announcements/'; |
|
1591 | + $origin_path = $this->course->backup_path.'/upload/announcements/'; |
|
1592 | + $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/announcements/'; |
|
1593 | 1593 | |
1594 | - // Copy announcement attachment file |
|
1595 | - if (!empty($this->course->orig)) { |
|
1594 | + // Copy announcement attachment file |
|
1595 | + if (!empty($this->course->orig)) { |
|
1596 | 1596 | |
1597 | - $table_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
1598 | - $sql = 'SELECT path, comment, size, filename |
|
1597 | + $table_attachment = Database::get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
1598 | + $sql = 'SELECT path, comment, size, filename |
|
1599 | 1599 | FROM '.$table_attachment.' |
1600 | 1600 | WHERE |
1601 | 1601 | c_id = '.$this->destination_course_id.' AND |
1602 | 1602 | announcement_id = '.$id; |
1603 | - $attachment_event = Database::query($sql); |
|
1604 | - $attachment_event = Database::fetch_object($attachment_event); |
|
1603 | + $attachment_event = Database::query($sql); |
|
1604 | + $attachment_event = Database::fetch_object($attachment_event); |
|
1605 | 1605 | |
1606 | - if (file_exists($origin_path.$attachment_event->path) && |
|
1606 | + if (file_exists($origin_path.$attachment_event->path) && |
|
1607 | 1607 | !is_dir($origin_path.$attachment_event->path) |
1608 | 1608 | ) { |
1609 | - $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1609 | + $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1610 | 1610 | $copy_result = copy( |
1611 | 1611 | $origin_path.$attachment_event->path, |
1612 | 1612 | $destination_path.$new_filename |
1613 | 1613 | ); |
1614 | 1614 | |
1615 | - if ($copy_result) { |
|
1616 | - $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
1615 | + if ($copy_result) { |
|
1616 | + $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
1617 | 1617 | |
1618 | 1618 | $params = [ |
1619 | 1619 | 'c_id' => $this->destination_course_id, |
@@ -1630,20 +1630,20 @@ discard block |
||
1630 | 1630 | $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $attachmentId"; |
1631 | 1631 | Database::query($sql); |
1632 | 1632 | } |
1633 | - } |
|
1634 | - } |
|
1635 | - } else { |
|
1636 | - // get the info of the file |
|
1637 | - if (!empty($announcement->attachment_path) && |
|
1633 | + } |
|
1634 | + } |
|
1635 | + } else { |
|
1636 | + // get the info of the file |
|
1637 | + if (!empty($announcement->attachment_path) && |
|
1638 | 1638 | is_file($origin_path.$announcement->attachment_path) && |
1639 | 1639 | is_readable($origin_path.$announcement->attachment_path) |
1640 | 1640 | ) { |
1641 | - $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1642 | - $copy_result = copy($origin_path.$announcement->attachment_path, $destination_path.$new_filename); |
|
1641 | + $new_filename = uniqid(''); //ass seen in the add_agenda_attachment_file() function in agenda.inc.php |
|
1642 | + $copy_result = copy($origin_path.$announcement->attachment_path, $destination_path.$new_filename); |
|
1643 | 1643 | |
1644 | - if ($copy_result) { |
|
1645 | - $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
1646 | - /*$sql = "INSERT INTO ".$table_attachment." SET |
|
1644 | + if ($copy_result) { |
|
1645 | + $table_attachment = Database :: get_course_table(TABLE_ANNOUNCEMENT_ATTACHMENT); |
|
1646 | + /*$sql = "INSERT INTO ".$table_attachment." SET |
|
1647 | 1647 | c_id = ".$this->destination_course_id." , |
1648 | 1648 | path = '".self::DBUTF8escapestring($new_filename)."', |
1649 | 1649 | comment = '".self::DBUTF8escapestring($announcement->attachment_comment)."', |
@@ -1666,12 +1666,12 @@ discard block |
||
1666 | 1666 | $sql = "UPDATE $table_attachment SET id = iid WHERE iid = $attachmentId"; |
1667 | 1667 | Database::query($sql); |
1668 | 1668 | } |
1669 | - } |
|
1670 | - } |
|
1671 | - } |
|
1672 | - } |
|
1673 | - } |
|
1674 | - } |
|
1669 | + } |
|
1670 | + } |
|
1671 | + } |
|
1672 | + } |
|
1673 | + } |
|
1674 | + } |
|
1675 | 1675 | |
1676 | 1676 | /** |
1677 | 1677 | * Restore Quiz |
@@ -1682,13 +1682,13 @@ discard block |
||
1682 | 1682 | $session_id = 0, |
1683 | 1683 | $respect_base_content = false |
1684 | 1684 | ) { |
1685 | - if ($this->course->has_resources(RESOURCE_QUIZ)) { |
|
1686 | - $table_qui = Database :: get_course_table(TABLE_QUIZ_TEST); |
|
1687 | - $table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION); |
|
1688 | - $table_doc = Database :: get_course_table(TABLE_DOCUMENT); |
|
1689 | - $resources = $this->course->resources; |
|
1685 | + if ($this->course->has_resources(RESOURCE_QUIZ)) { |
|
1686 | + $table_qui = Database :: get_course_table(TABLE_QUIZ_TEST); |
|
1687 | + $table_rel = Database :: get_course_table(TABLE_QUIZ_TEST_QUESTION); |
|
1688 | + $table_doc = Database :: get_course_table(TABLE_DOCUMENT); |
|
1689 | + $resources = $this->course->resources; |
|
1690 | 1690 | |
1691 | - foreach ($resources[RESOURCE_QUIZ] as $id => $quiz) { |
|
1691 | + foreach ($resources[RESOURCE_QUIZ] as $id => $quiz) { |
|
1692 | 1692 | |
1693 | 1693 | if (isset($quiz->obj)) { |
1694 | 1694 | //For new imports |
@@ -1698,7 +1698,7 @@ discard block |
||
1698 | 1698 | $quiz->obj = $quiz; |
1699 | 1699 | } |
1700 | 1700 | |
1701 | - $doc = ''; |
|
1701 | + $doc = ''; |
|
1702 | 1702 | if (!empty($quiz->sound)) { |
1703 | 1703 | if (isset($this->course->resources[RESOURCE_DOCUMENT][$quiz->sound]) && |
1704 | 1704 | $this->course->resources[RESOURCE_DOCUMENT][$quiz->sound]->is_restored()) { |
@@ -1706,14 +1706,14 @@ discard block |
||
1706 | 1706 | WHERE |
1707 | 1707 | c_id = " . $this->destination_course_id . " AND |
1708 | 1708 | id = " . $resources[RESOURCE_DOCUMENT][$quiz->sound]->destination_id; |
1709 | - $doc = Database::query($sql); |
|
1710 | - $doc = Database::fetch_object($doc); |
|
1711 | - $doc = str_replace('/audio/', '', $doc->path); |
|
1712 | - } |
|
1713 | - } |
|
1714 | - |
|
1715 | - if ($id != -1) { |
|
1716 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1709 | + $doc = Database::query($sql); |
|
1710 | + $doc = Database::fetch_object($doc); |
|
1711 | + $doc = str_replace('/audio/', '', $doc->path); |
|
1712 | + } |
|
1713 | + } |
|
1714 | + |
|
1715 | + if ($id != -1) { |
|
1716 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1717 | 1717 | $quiz->description = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
1718 | 1718 | $quiz->description, |
1719 | 1719 | $this->course->code, |
@@ -1725,13 +1725,13 @@ discard block |
||
1725 | 1725 | $quiz->start_time = $quiz->start_time == '0000-00-00 00:00:00' ? null : $quiz->start_time; |
1726 | 1726 | $quiz->end_time = $quiz->end_time == '0000-00-00 00:00:00' ? null : $quiz->end_time; |
1727 | 1727 | |
1728 | - global $_custom; |
|
1729 | - if (isset($_custom['exercises_clean_dates_when_restoring']) && |
|
1728 | + global $_custom; |
|
1729 | + if (isset($_custom['exercises_clean_dates_when_restoring']) && |
|
1730 | 1730 | $_custom['exercises_clean_dates_when_restoring'] |
1731 | 1731 | ) { |
1732 | - $quiz->start_time = null; |
|
1733 | - $quiz->end_time = null; |
|
1734 | - } |
|
1732 | + $quiz->start_time = null; |
|
1733 | + $quiz->end_time = null; |
|
1734 | + } |
|
1735 | 1735 | |
1736 | 1736 | $params = array( |
1737 | 1737 | 'c_id' => $this->destination_course_id, |
@@ -1765,10 +1765,10 @@ discard block |
||
1765 | 1765 | } |
1766 | 1766 | $params['session_id'] = $my_session_id; |
1767 | 1767 | } else { |
1768 | - if (!empty($session_id)) { |
|
1769 | - $session_id = intval($session_id); |
|
1768 | + if (!empty($session_id)) { |
|
1769 | + $session_id = intval($session_id); |
|
1770 | 1770 | $params['session_id'] = $session_id; |
1771 | - } |
|
1771 | + } |
|
1772 | 1772 | } |
1773 | 1773 | $new_id = Database::insert($table_qui, $params); |
1774 | 1774 | |
@@ -1777,15 +1777,15 @@ discard block |
||
1777 | 1777 | Database::query($sql); |
1778 | 1778 | } |
1779 | 1779 | |
1780 | - } else { |
|
1781 | - // $id = -1 identifies the fictionary test for collecting |
|
1782 | - // orphan questions. We do not store it in the database. |
|
1783 | - $new_id = -1; |
|
1784 | - } |
|
1780 | + } else { |
|
1781 | + // $id = -1 identifies the fictionary test for collecting |
|
1782 | + // orphan questions. We do not store it in the database. |
|
1783 | + $new_id = -1; |
|
1784 | + } |
|
1785 | 1785 | |
1786 | - $this->course->resources[RESOURCE_QUIZ][$id]->destination_id = $new_id; |
|
1786 | + $this->course->resources[RESOURCE_QUIZ][$id]->destination_id = $new_id; |
|
1787 | 1787 | |
1788 | - $order = 0; |
|
1788 | + $order = 0; |
|
1789 | 1789 | if (!empty($quiz->question_ids)) { |
1790 | 1790 | foreach ($quiz->question_ids as $index => $question_id) { |
1791 | 1791 | $qid = $this->restore_quiz_question($question_id); |
@@ -1798,30 +1798,30 @@ discard block |
||
1798 | 1798 | Database::query($sql); |
1799 | 1799 | } |
1800 | 1800 | } |
1801 | - } |
|
1802 | - } |
|
1803 | - } |
|
1801 | + } |
|
1802 | + } |
|
1803 | + } |
|
1804 | 1804 | |
1805 | - /** |
|
1806 | - * Restore quiz-questions |
|
1805 | + /** |
|
1806 | + * Restore quiz-questions |
|
1807 | 1807 | * @params int question id |
1808 | - */ |
|
1808 | + */ |
|
1809 | 1809 | public function restore_quiz_question($id) |
1810 | 1810 | { |
1811 | - $resources = $this->course->resources; |
|
1811 | + $resources = $this->course->resources; |
|
1812 | 1812 | $question = isset($resources[RESOURCE_QUIZQUESTION][$id]) ? $resources[RESOURCE_QUIZQUESTION][$id] : null; |
1813 | 1813 | |
1814 | - $new_id = 0; |
|
1814 | + $new_id = 0; |
|
1815 | 1815 | |
1816 | - if (is_object($question)) { |
|
1817 | - if ($question->is_restored()) { |
|
1818 | - return $question->destination_id; |
|
1819 | - } |
|
1820 | - $table_que = Database::get_course_table(TABLE_QUIZ_QUESTION); |
|
1821 | - $table_ans = Database::get_course_table(TABLE_QUIZ_ANSWER); |
|
1816 | + if (is_object($question)) { |
|
1817 | + if ($question->is_restored()) { |
|
1818 | + return $question->destination_id; |
|
1819 | + } |
|
1820 | + $table_que = Database::get_course_table(TABLE_QUIZ_QUESTION); |
|
1821 | + $table_ans = Database::get_course_table(TABLE_QUIZ_ANSWER); |
|
1822 | 1822 | $table_options = Database::get_course_table(TABLE_QUIZ_QUESTION_OPTION); |
1823 | 1823 | |
1824 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1824 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1825 | 1825 | $question->description = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
1826 | 1826 | $question->description, |
1827 | 1827 | $this->course->code, |
@@ -1842,7 +1842,7 @@ discard block |
||
1842 | 1842 | 'extra' => self::DBUTF8($question->extra), |
1843 | 1843 | ]; |
1844 | 1844 | |
1845 | - $new_id = Database::insert($table_que, $params); |
|
1845 | + $new_id = Database::insert($table_que, $params); |
|
1846 | 1846 | |
1847 | 1847 | if ($new_id) { |
1848 | 1848 | |
@@ -1883,7 +1883,7 @@ discard block |
||
1883 | 1883 | |
1884 | 1884 | foreach ($temp as $index => $answer) { |
1885 | 1885 | //id = '".$index."', |
1886 | - $params = [ |
|
1886 | + $params = [ |
|
1887 | 1887 | 'c_id' => $this->destination_course_id, |
1888 | 1888 | 'question_id' => $new_id, |
1889 | 1889 | 'answer' => self::DBUTF8($answer['answer']), |
@@ -1902,12 +1902,12 @@ discard block |
||
1902 | 1902 | $sql = "UPDATE $table_ans SET id = iid, id_auto = iid WHERE iid = $answerId"; |
1903 | 1903 | Database::query($sql); |
1904 | 1904 | } |
1905 | - } |
|
1906 | - } else { |
|
1905 | + } |
|
1906 | + } else { |
|
1907 | 1907 | $correct_answers = array(); |
1908 | - foreach ($question->answers as $index => $answer) { |
|
1908 | + foreach ($question->answers as $index => $answer) { |
|
1909 | 1909 | |
1910 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1910 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
1911 | 1911 | $answer['answer'] = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
1912 | 1912 | $answer['answer'], |
1913 | 1913 | $this->course->code, |
@@ -1948,8 +1948,8 @@ discard block |
||
1948 | 1948 | } |
1949 | 1949 | |
1950 | 1950 | $correct_answers[$answerId] = $answer['correct']; |
1951 | - } |
|
1952 | - } |
|
1951 | + } |
|
1952 | + } |
|
1953 | 1953 | |
1954 | 1954 | //Current course id |
1955 | 1955 | $course_id = api_get_course_int_id(); |
@@ -2046,12 +2046,12 @@ discard block |
||
2046 | 2046 | } |
2047 | 2047 | } |
2048 | 2048 | } |
2049 | - $this->course->resources[RESOURCE_QUIZQUESTION][$id]->destination_id = $new_id; |
|
2050 | - } |
|
2051 | - return $new_id; |
|
2052 | - } |
|
2049 | + $this->course->resources[RESOURCE_QUIZQUESTION][$id]->destination_id = $new_id; |
|
2050 | + } |
|
2051 | + return $new_id; |
|
2052 | + } |
|
2053 | 2053 | |
2054 | - /** |
|
2054 | + /** |
|
2055 | 2055 | * @todo : add session id when used for session |
2056 | 2056 | */ |
2057 | 2057 | public function restore_test_category($session_id, $respect_base_content, $destination_course_code) |
@@ -2131,21 +2131,21 @@ discard block |
||
2131 | 2131 | $sessionId = intval($sessionId); |
2132 | 2132 | |
2133 | 2133 | if ($this->course->has_resources(RESOURCE_SURVEY)) { |
2134 | - $table_sur = Database :: get_course_table(TABLE_SURVEY); |
|
2135 | - $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION); |
|
2136 | - $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); |
|
2137 | - $resources = $this->course->resources; |
|
2138 | - foreach ($resources[RESOURCE_SURVEY] as $id => $survey) { |
|
2134 | + $table_sur = Database :: get_course_table(TABLE_SURVEY); |
|
2135 | + $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION); |
|
2136 | + $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); |
|
2137 | + $resources = $this->course->resources; |
|
2138 | + foreach ($resources[RESOURCE_SURVEY] as $id => $survey) { |
|
2139 | 2139 | |
2140 | - $sql = 'SELECT survey_id FROM '.$table_sur.' |
|
2140 | + $sql = 'SELECT survey_id FROM '.$table_sur.' |
|
2141 | 2141 | WHERE |
2142 | 2142 | c_id = '.$this->destination_course_id.' AND |
2143 | 2143 | code = "'.self::DBUTF8escapestring($survey->code).'" AND |
2144 | 2144 | lang = "'.self::DBUTF8escapestring($survey->lang).'" '; |
2145 | 2145 | |
2146 | - $result_check = Database::query($sql); |
|
2146 | + $result_check = Database::query($sql); |
|
2147 | 2147 | |
2148 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2148 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2149 | 2149 | $survey->title = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
2150 | 2150 | $survey->title, |
2151 | 2151 | $this->course->code, |
@@ -2199,20 +2199,20 @@ discard block |
||
2199 | 2199 | 'session_id' => $sessionId, |
2200 | 2200 | ]; |
2201 | 2201 | |
2202 | - //An existing survey exists with the same code and the same language |
|
2203 | - if (Database::num_rows($result_check) == 1) { |
|
2204 | - switch ($this->file_option) { |
|
2205 | - case FILE_SKIP: |
|
2206 | - //Do nothing |
|
2207 | - break; |
|
2208 | - case FILE_RENAME: |
|
2209 | - $survey_code = $survey->code.'_'; |
|
2210 | - $i=1; |
|
2211 | - $temp_survey_code = $survey_code.$i; |
|
2212 | - while (!$this->is_survey_code_available($temp_survey_code)) { |
|
2213 | - $temp_survey_code = $survey_code.++$i; |
|
2214 | - } |
|
2215 | - $survey_code = $temp_survey_code; |
|
2202 | + //An existing survey exists with the same code and the same language |
|
2203 | + if (Database::num_rows($result_check) == 1) { |
|
2204 | + switch ($this->file_option) { |
|
2205 | + case FILE_SKIP: |
|
2206 | + //Do nothing |
|
2207 | + break; |
|
2208 | + case FILE_RENAME: |
|
2209 | + $survey_code = $survey->code.'_'; |
|
2210 | + $i=1; |
|
2211 | + $temp_survey_code = $survey_code.$i; |
|
2212 | + while (!$this->is_survey_code_available($temp_survey_code)) { |
|
2213 | + $temp_survey_code = $survey_code.++$i; |
|
2214 | + } |
|
2215 | + $survey_code = $temp_survey_code; |
|
2216 | 2216 | |
2217 | 2217 | $params['code'] = $survey_code; |
2218 | 2218 | $new_id = Database::insert($table_sur, $params); |
@@ -2231,25 +2231,25 @@ discard block |
||
2231 | 2231 | Database::query($sql); |
2232 | 2232 | } |
2233 | 2233 | } |
2234 | - break; |
|
2235 | - case FILE_OVERWRITE: |
|
2236 | - // Delete the existing survey with the same code and language and import the one of the source course |
|
2237 | - // getting the information of the survey (used for when the survey is shared) |
|
2234 | + break; |
|
2235 | + case FILE_OVERWRITE: |
|
2236 | + // Delete the existing survey with the same code and language and import the one of the source course |
|
2237 | + // getting the information of the survey (used for when the survey is shared) |
|
2238 | 2238 | |
2239 | - $sql = "SELECT * FROM $table_sur |
|
2239 | + $sql = "SELECT * FROM $table_sur |
|
2240 | 2240 | WHERE |
2241 | 2241 | c_id = ".$this->destination_course_id." AND |
2242 | 2242 | survey_id='".self::DBUTF8escapestring(Database::result($result_check,0,0))."'"; |
2243 | - $result = Database::query($sql); |
|
2244 | - $survey_data = Database::fetch_array($result,'ASSOC'); |
|
2243 | + $result = Database::query($sql); |
|
2244 | + $survey_data = Database::fetch_array($result,'ASSOC'); |
|
2245 | 2245 | |
2246 | - // if the survey is shared => also delete the shared content |
|
2247 | - if (isset($survey_data['survey_share']) && is_numeric($survey_data['survey_share'])) { |
|
2246 | + // if the survey is shared => also delete the shared content |
|
2247 | + if (isset($survey_data['survey_share']) && is_numeric($survey_data['survey_share'])) { |
|
2248 | 2248 | SurveyManager::delete_survey($survey_data['survey_share'], true,$this->destination_course_id); |
2249 | - } |
|
2250 | - SurveyManager :: delete_survey($survey_data['survey_id'],false,$this->destination_course_id); |
|
2249 | + } |
|
2250 | + SurveyManager :: delete_survey($survey_data['survey_id'],false,$this->destination_course_id); |
|
2251 | 2251 | |
2252 | - // Insert the new source survey |
|
2252 | + // Insert the new source survey |
|
2253 | 2253 | $new_id = Database::insert($table_sur, $params); |
2254 | 2254 | |
2255 | 2255 | if ($new_id) { |
@@ -2270,11 +2270,11 @@ discard block |
||
2270 | 2270 | Database::query($sql); |
2271 | 2271 | } |
2272 | 2272 | } |
2273 | - break; |
|
2274 | - default: |
|
2275 | - break; |
|
2276 | - } |
|
2277 | - } else { |
|
2273 | + break; |
|
2274 | + default: |
|
2275 | + break; |
|
2276 | + } |
|
2277 | + } else { |
|
2278 | 2278 | // No existing survey with the same language and the same code, we just copy the survey |
2279 | 2279 | $new_id = Database::insert($table_sur, $params); |
2280 | 2280 | |
@@ -2296,49 +2296,49 @@ discard block |
||
2296 | 2296 | Database::query($sql); |
2297 | 2297 | } |
2298 | 2298 | } |
2299 | - } |
|
2300 | - } |
|
2301 | - } |
|
2302 | - } |
|
2303 | - |
|
2304 | - /** |
|
2305 | - * Check availability of a survey code |
|
2306 | - * @param string $survey_code |
|
2307 | - */ |
|
2299 | + } |
|
2300 | + } |
|
2301 | + } |
|
2302 | + } |
|
2303 | + |
|
2304 | + /** |
|
2305 | + * Check availability of a survey code |
|
2306 | + * @param string $survey_code |
|
2307 | + */ |
|
2308 | 2308 | public function is_survey_code_available($survey_code) |
2309 | 2309 | { |
2310 | - $table_sur = Database :: get_course_table(TABLE_SURVEY); |
|
2311 | - $sql = "SELECT * FROM $table_sur |
|
2310 | + $table_sur = Database :: get_course_table(TABLE_SURVEY); |
|
2311 | + $sql = "SELECT * FROM $table_sur |
|
2312 | 2312 | WHERE |
2313 | 2313 | c_id = ".$this->destination_course_id." AND |
2314 | 2314 | code='".self::DBUTF8escapestring($survey_code)."'"; |
2315 | - $result = Database::query($sql); |
|
2315 | + $result = Database::query($sql); |
|
2316 | 2316 | if (Database::num_rows($result) > 0) { |
2317 | 2317 | return false; |
2318 | 2318 | } else { |
2319 | 2319 | return true; |
2320 | 2320 | } |
2321 | - } |
|
2321 | + } |
|
2322 | 2322 | |
2323 | - /** |
|
2324 | - * Restore survey-questions |
|
2325 | - * @param string $survey_id |
|
2326 | - */ |
|
2323 | + /** |
|
2324 | + * Restore survey-questions |
|
2325 | + * @param string $survey_id |
|
2326 | + */ |
|
2327 | 2327 | public function restore_survey_question($id, $survey_id) |
2328 | 2328 | { |
2329 | - $resources = $this->course->resources; |
|
2330 | - $question = $resources[RESOURCE_SURVEYQUESTION][$id]; |
|
2329 | + $resources = $this->course->resources; |
|
2330 | + $question = $resources[RESOURCE_SURVEYQUESTION][$id]; |
|
2331 | 2331 | |
2332 | - $new_id=0; |
|
2332 | + $new_id=0; |
|
2333 | 2333 | |
2334 | - if (is_object($question)) { |
|
2335 | - if ($question->is_restored()) { |
|
2336 | - return $question->destination_id; |
|
2337 | - } |
|
2338 | - $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION); |
|
2339 | - $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); |
|
2334 | + if (is_object($question)) { |
|
2335 | + if ($question->is_restored()) { |
|
2336 | + return $question->destination_id; |
|
2337 | + } |
|
2338 | + $table_que = Database :: get_course_table(TABLE_SURVEY_QUESTION); |
|
2339 | + $table_ans = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION); |
|
2340 | 2340 | |
2341 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2341 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2342 | 2342 | $question->survey_question = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
2343 | 2343 | $question->survey_question, |
2344 | 2344 | $this->course->code, |
@@ -2392,10 +2392,10 @@ discard block |
||
2392 | 2392 | } |
2393 | 2393 | $this->course->resources[RESOURCE_SURVEYQUESTION][$id]->destination_id = $new_id; |
2394 | 2394 | } |
2395 | - } |
|
2395 | + } |
|
2396 | 2396 | |
2397 | - return $new_id; |
|
2398 | - } |
|
2397 | + return $new_id; |
|
2398 | + } |
|
2399 | 2399 | |
2400 | 2400 | /** |
2401 | 2401 | * Restoring learning paths |
@@ -2406,19 +2406,19 @@ discard block |
||
2406 | 2406 | { |
2407 | 2407 | $session_id = intval($session_id); |
2408 | 2408 | |
2409 | - if ($this->course->has_resources(RESOURCE_LEARNPATH)) { |
|
2409 | + if ($this->course->has_resources(RESOURCE_LEARNPATH)) { |
|
2410 | 2410 | $table_main = Database::get_course_table(TABLE_LP_MAIN); |
2411 | 2411 | $table_item = Database::get_course_table(TABLE_LP_ITEM); |
2412 | 2412 | $table_tool = Database::get_course_table(TABLE_TOOL_LIST); |
2413 | 2413 | |
2414 | - $resources = $this->course->resources; |
|
2414 | + $resources = $this->course->resources; |
|
2415 | 2415 | |
2416 | - $origin_path = $this->course->backup_path.'/upload/learning_path/images/'; |
|
2417 | - $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/learning_path/images/'; |
|
2416 | + $origin_path = $this->course->backup_path.'/upload/learning_path/images/'; |
|
2417 | + $destination_path = api_get_path(SYS_COURSE_PATH).$this->course->destination_path.'/upload/learning_path/images/'; |
|
2418 | 2418 | |
2419 | - foreach ($resources[RESOURCE_LEARNPATH] as $id => $lp) { |
|
2420 | - $condition_session = ''; |
|
2421 | - if (!empty($session_id)) { |
|
2419 | + foreach ($resources[RESOURCE_LEARNPATH] as $id => $lp) { |
|
2420 | + $condition_session = ''; |
|
2421 | + if (!empty($session_id)) { |
|
2422 | 2422 | if ($respect_base_content) { |
2423 | 2423 | $my_session_id = $lp->session_id; |
2424 | 2424 | if (!empty($lp->session_id)) { |
@@ -2429,20 +2429,20 @@ discard block |
||
2429 | 2429 | $session_id = intval($session_id); |
2430 | 2430 | $condition_session = $session_id; |
2431 | 2431 | } |
2432 | - } |
|
2433 | - |
|
2434 | - // Adding the author's image |
|
2435 | - if (!empty($lp->preview_image)) { |
|
2436 | - $new_filename = uniqid('').substr($lp->preview_image,strlen($lp->preview_image)-7, strlen($lp->preview_image)); |
|
2437 | - if (file_exists($origin_path.$lp->preview_image) && !is_dir($origin_path.$lp->preview_image)) { |
|
2438 | - $copy_result = copy($origin_path.$lp->preview_image, $destination_path.$new_filename); |
|
2439 | - if ($copy_result) { |
|
2440 | - $lp->preview_image = $new_filename; |
|
2441 | - } else { |
|
2442 | - $lp->preview_image =''; |
|
2443 | - } |
|
2444 | - } |
|
2445 | - } |
|
2432 | + } |
|
2433 | + |
|
2434 | + // Adding the author's image |
|
2435 | + if (!empty($lp->preview_image)) { |
|
2436 | + $new_filename = uniqid('').substr($lp->preview_image,strlen($lp->preview_image)-7, strlen($lp->preview_image)); |
|
2437 | + if (file_exists($origin_path.$lp->preview_image) && !is_dir($origin_path.$lp->preview_image)) { |
|
2438 | + $copy_result = copy($origin_path.$lp->preview_image, $destination_path.$new_filename); |
|
2439 | + if ($copy_result) { |
|
2440 | + $lp->preview_image = $new_filename; |
|
2441 | + } else { |
|
2442 | + $lp->preview_image =''; |
|
2443 | + } |
|
2444 | + } |
|
2445 | + } |
|
2446 | 2446 | |
2447 | 2447 | if ($this->add_text_in_items) { |
2448 | 2448 | $lp->name = $lp->name.' '.get_lang('CopyLabelSuffix'); |
@@ -2500,7 +2500,7 @@ discard block |
||
2500 | 2500 | $params['session_id'] = $condition_session; |
2501 | 2501 | } |
2502 | 2502 | |
2503 | - $new_lp_id = Database::insert($table_main, $params); |
|
2503 | + $new_lp_id = Database::insert($table_main, $params); |
|
2504 | 2504 | |
2505 | 2505 | if ($new_lp_id) { |
2506 | 2506 | |
@@ -2561,13 +2561,13 @@ discard block |
||
2561 | 2561 | $old_refs = array(); |
2562 | 2562 | $prerequisite_ids = array(); |
2563 | 2563 | |
2564 | - foreach ($lp->get_items() as $index => $item) { |
|
2565 | - // we set the ref code here and then we update in a for loop |
|
2566 | - $ref = $item['ref']; |
|
2564 | + foreach ($lp->get_items() as $index => $item) { |
|
2565 | + // we set the ref code here and then we update in a for loop |
|
2566 | + $ref = $item['ref']; |
|
2567 | 2567 | |
2568 | - // Dealing with path the same way as ref as some data has |
|
2568 | + // Dealing with path the same way as ref as some data has |
|
2569 | 2569 | // been put into path when it's a local resource |
2570 | - // Only fix the path for no scos |
|
2570 | + // Only fix the path for no scos |
|
2571 | 2571 | if ($item['item_type'] == 'sco') { |
2572 | 2572 | $path = $item['path']; |
2573 | 2573 | } else { |
@@ -2596,128 +2596,128 @@ discard block |
||
2596 | 2596 | 'launch_data' => self::DBUTF8($item['launch_data']), |
2597 | 2597 | ]; |
2598 | 2598 | |
2599 | - $new_item_id = Database::insert($table_item, $params); |
|
2599 | + $new_item_id = Database::insert($table_item, $params); |
|
2600 | 2600 | |
2601 | 2601 | $sql = "UPDATE $table_item SET id = iid WHERE iid = $new_item_id"; |
2602 | 2602 | Database::query($sql); |
2603 | 2603 | |
2604 | - //save a link between old and new item IDs |
|
2605 | - $new_item_ids[$item['id']] = $new_item_id; |
|
2606 | - //save a reference of items that need a parent_item_id refresh |
|
2607 | - $parent_item_ids[$new_item_id] = $item['parent_item_id']; |
|
2608 | - //save a reference of items that need a previous_item_id refresh |
|
2609 | - $previous_item_ids[$new_item_id] = $item['previous_item_id']; |
|
2610 | - //save a reference of items that need a next_item_id refresh |
|
2611 | - $next_item_ids[$new_item_id] = $item['next_item_id']; |
|
2612 | - |
|
2613 | - if (!empty($item['prerequisite'])) { |
|
2614 | - if ($lp->lp_type =='2') { |
|
2615 | - // if is an sco |
|
2616 | - $old_prerequisite[$new_item_id]= $item['prerequisite']; |
|
2617 | - } else { |
|
2618 | - $old_prerequisite[$new_item_id]= $new_item_ids[$item['prerequisite']]; |
|
2619 | - } |
|
2620 | - } |
|
2621 | - |
|
2622 | - if (!empty($ref)) { |
|
2623 | - if ($lp->lp_type =='2') { |
|
2624 | - // if is an sco |
|
2625 | - $old_refs[$new_item_id]= $ref; |
|
2626 | - } else { |
|
2604 | + //save a link between old and new item IDs |
|
2605 | + $new_item_ids[$item['id']] = $new_item_id; |
|
2606 | + //save a reference of items that need a parent_item_id refresh |
|
2607 | + $parent_item_ids[$new_item_id] = $item['parent_item_id']; |
|
2608 | + //save a reference of items that need a previous_item_id refresh |
|
2609 | + $previous_item_ids[$new_item_id] = $item['previous_item_id']; |
|
2610 | + //save a reference of items that need a next_item_id refresh |
|
2611 | + $next_item_ids[$new_item_id] = $item['next_item_id']; |
|
2612 | + |
|
2613 | + if (!empty($item['prerequisite'])) { |
|
2614 | + if ($lp->lp_type =='2') { |
|
2615 | + // if is an sco |
|
2616 | + $old_prerequisite[$new_item_id]= $item['prerequisite']; |
|
2617 | + } else { |
|
2618 | + $old_prerequisite[$new_item_id]= $new_item_ids[$item['prerequisite']]; |
|
2619 | + } |
|
2620 | + } |
|
2621 | + |
|
2622 | + if (!empty($ref)) { |
|
2623 | + if ($lp->lp_type =='2') { |
|
2624 | + // if is an sco |
|
2625 | + $old_refs[$new_item_id]= $ref; |
|
2626 | + } else { |
|
2627 | 2627 | $old_refs[$new_item_id]= $new_item_ids[$ref]; |
2628 | - } |
|
2629 | - } |
|
2628 | + } |
|
2629 | + } |
|
2630 | 2630 | |
2631 | - $prerequisite_ids[$new_item_id] = $item['prerequisite']; |
|
2632 | - } |
|
2631 | + $prerequisite_ids[$new_item_id] = $item['prerequisite']; |
|
2632 | + } |
|
2633 | 2633 | |
2634 | - // Updating prerequisites |
|
2635 | - foreach ($old_prerequisite as $key=>$my_old_prerequisite) { |
|
2636 | - if ($my_old_prerequisite != ''){ |
|
2637 | - $sql = "UPDATE ".$table_item." SET prerequisite = '".$my_old_prerequisite."' |
|
2634 | + // Updating prerequisites |
|
2635 | + foreach ($old_prerequisite as $key=>$my_old_prerequisite) { |
|
2636 | + if ($my_old_prerequisite != ''){ |
|
2637 | + $sql = "UPDATE ".$table_item." SET prerequisite = '".$my_old_prerequisite."' |
|
2638 | 2638 | WHERE c_id = ".$this->destination_course_id." AND id = '".$key."' "; |
2639 | - Database::query($sql); |
|
2640 | - } |
|
2641 | - } |
|
2642 | - |
|
2643 | - // Updating refs |
|
2644 | - foreach ($old_refs as $key=>$my_old_ref) { |
|
2645 | - if ($my_old_ref != '') { |
|
2646 | - $sql = "UPDATE ".$table_item." SET ref = '".$my_old_ref."' |
|
2639 | + Database::query($sql); |
|
2640 | + } |
|
2641 | + } |
|
2642 | + |
|
2643 | + // Updating refs |
|
2644 | + foreach ($old_refs as $key=>$my_old_ref) { |
|
2645 | + if ($my_old_ref != '') { |
|
2646 | + $sql = "UPDATE ".$table_item." SET ref = '".$my_old_ref."' |
|
2647 | 2647 | WHERE c_id = ".$this->destination_course_id." AND id = '".$key."' "; |
2648 | - Database::query($sql); |
|
2649 | - } |
|
2650 | - } |
|
2651 | - |
|
2652 | - foreach ($parent_item_ids as $new_item_id => $parent_item_old_id) { |
|
2653 | - $parent_new_id = 0; |
|
2654 | - if($parent_item_old_id != 0){ |
|
2655 | - $parent_new_id = $new_item_ids[$parent_item_old_id]; |
|
2656 | - } |
|
2657 | - $sql = "UPDATE ".$table_item." SET parent_item_id = '".$parent_new_id."' |
|
2648 | + Database::query($sql); |
|
2649 | + } |
|
2650 | + } |
|
2651 | + |
|
2652 | + foreach ($parent_item_ids as $new_item_id => $parent_item_old_id) { |
|
2653 | + $parent_new_id = 0; |
|
2654 | + if($parent_item_old_id != 0){ |
|
2655 | + $parent_new_id = $new_item_ids[$parent_item_old_id]; |
|
2656 | + } |
|
2657 | + $sql = "UPDATE ".$table_item." SET parent_item_id = '".$parent_new_id."' |
|
2658 | 2658 | WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'"; |
2659 | - Database::query($sql); |
|
2660 | - } |
|
2661 | - foreach ($previous_item_ids as $new_item_id => $previous_item_old_id) { |
|
2662 | - $previous_new_id = 0; |
|
2663 | - if ($previous_item_old_id != 0){ |
|
2664 | - $previous_new_id = $new_item_ids[$previous_item_old_id]; |
|
2665 | - } |
|
2666 | - $sql = "UPDATE ".$table_item." SET previous_item_id = '".$previous_new_id."' |
|
2659 | + Database::query($sql); |
|
2660 | + } |
|
2661 | + foreach ($previous_item_ids as $new_item_id => $previous_item_old_id) { |
|
2662 | + $previous_new_id = 0; |
|
2663 | + if ($previous_item_old_id != 0){ |
|
2664 | + $previous_new_id = $new_item_ids[$previous_item_old_id]; |
|
2665 | + } |
|
2666 | + $sql = "UPDATE ".$table_item." SET previous_item_id = '".$previous_new_id."' |
|
2667 | 2667 | WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'"; |
2668 | - Database::query($sql); |
|
2669 | - } |
|
2670 | - |
|
2671 | - foreach ($next_item_ids as $new_item_id => $next_item_old_id) { |
|
2672 | - $next_new_id = 0; |
|
2673 | - if ($next_item_old_id != 0){ |
|
2674 | - $next_new_id = $new_item_ids[$next_item_old_id]; |
|
2675 | - } |
|
2676 | - $sql = "UPDATE ".$table_item." SET next_item_id = '".$next_new_id."' |
|
2668 | + Database::query($sql); |
|
2669 | + } |
|
2670 | + |
|
2671 | + foreach ($next_item_ids as $new_item_id => $next_item_old_id) { |
|
2672 | + $next_new_id = 0; |
|
2673 | + if ($next_item_old_id != 0){ |
|
2674 | + $next_new_id = $new_item_ids[$next_item_old_id]; |
|
2675 | + } |
|
2676 | + $sql = "UPDATE ".$table_item." SET next_item_id = '".$next_new_id."' |
|
2677 | 2677 | WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'"; |
2678 | - Database::query($sql); |
|
2679 | - } |
|
2680 | - |
|
2681 | - foreach ($prerequisite_ids as $new_item_id => $prerequisite_old_id) { |
|
2682 | - $prerequisite_new_id = 0; |
|
2683 | - if ($prerequisite_old_id != 0){ |
|
2684 | - $prerequisite_new_id = $new_item_ids[$prerequisite_old_id]; |
|
2685 | - } |
|
2686 | - $sql = "UPDATE ".$table_item." SET prerequisite = '".$prerequisite_new_id."' |
|
2678 | + Database::query($sql); |
|
2679 | + } |
|
2680 | + |
|
2681 | + foreach ($prerequisite_ids as $new_item_id => $prerequisite_old_id) { |
|
2682 | + $prerequisite_new_id = 0; |
|
2683 | + if ($prerequisite_old_id != 0){ |
|
2684 | + $prerequisite_new_id = $new_item_ids[$prerequisite_old_id]; |
|
2685 | + } |
|
2686 | + $sql = "UPDATE ".$table_item." SET prerequisite = '".$prerequisite_new_id."' |
|
2687 | 2687 | WHERE c_id = ".$this->destination_course_id." AND id = '".$new_item_id."'"; |
2688 | - Database::query($sql); |
|
2689 | - } |
|
2690 | - $this->course->resources[RESOURCE_LEARNPATH][$id]->destination_id = $new_lp_id; |
|
2691 | - } |
|
2692 | - } |
|
2693 | - } |
|
2694 | - |
|
2695 | - /** |
|
2696 | - * Restore works |
|
2688 | + Database::query($sql); |
|
2689 | + } |
|
2690 | + $this->course->resources[RESOURCE_LEARNPATH][$id]->destination_id = $new_lp_id; |
|
2691 | + } |
|
2692 | + } |
|
2693 | + } |
|
2694 | + |
|
2695 | + /** |
|
2696 | + * Restore works |
|
2697 | 2697 | * @deprecated use restore_works |
2698 | 2698 | * |
2699 | - */ |
|
2700 | - public function restore_student_publication($sessionId = 0) |
|
2699 | + */ |
|
2700 | + public function restore_student_publication($sessionId = 0) |
|
2701 | 2701 | { |
2702 | 2702 | $sessionId = intval($sessionId); |
2703 | 2703 | $work_assignment_table = Database:: get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT); |
2704 | 2704 | $work_table = Database:: get_course_table(TABLE_STUDENT_PUBLICATION); |
2705 | 2705 | $item_property_table = Database:: get_course_table(TABLE_ITEM_PROPERTY); |
2706 | 2706 | |
2707 | - // Query in student publication |
|
2708 | - $sql = 'SELECT * FROM '.$work_table.' |
|
2707 | + // Query in student publication |
|
2708 | + $sql = 'SELECT * FROM '.$work_table.' |
|
2709 | 2709 | WHERE c_id = '.$this->course_origin_id.' AND filetype = "folder" AND active IN (0, 1) '; |
2710 | 2710 | |
2711 | - $result = Database::query($sql); |
|
2712 | - $folders = Database::store_result($result, 'ASSOC'); |
|
2711 | + $result = Database::query($sql); |
|
2712 | + $folders = Database::store_result($result, 'ASSOC'); |
|
2713 | 2713 | |
2714 | - foreach ($folders as $folder) { |
|
2715 | - $old_id = $folder['id']; |
|
2714 | + foreach ($folders as $folder) { |
|
2715 | + $old_id = $folder['id']; |
|
2716 | 2716 | unset($folder['id']); |
2717 | - $folder['c_id'] = $this->destination_course_id; |
|
2717 | + $folder['c_id'] = $this->destination_course_id; |
|
2718 | 2718 | $folder['parent_id'] = 0; |
2719 | 2719 | $folder['session_id'] = $sessionId; |
2720 | - $new_id = Database::insert($work_table, $folder); |
|
2720 | + $new_id = Database::insert($work_table, $folder); |
|
2721 | 2721 | |
2722 | 2722 | if ($new_id) { |
2723 | 2723 | // query in item property |
@@ -2776,23 +2776,23 @@ discard block |
||
2776 | 2776 | } |
2777 | 2777 | } |
2778 | 2778 | } |
2779 | - } |
|
2779 | + } |
|
2780 | 2780 | |
2781 | 2781 | $destination = '../..'.api_get_path(REL_COURSE_PATH).$this->course->destination_path.'/work/'; |
2782 | 2782 | $origin = '../..'.api_get_path(REL_COURSE_PATH).$this->course->info['path'].'/work/'; |
2783 | 2783 | self::allow_create_all_directory($origin, $destination, false); |
2784 | - } |
|
2784 | + } |
|
2785 | 2785 | |
2786 | 2786 | /** |
2787 | - * copy all directory and sub directory |
|
2788 | - * @param string The path origin |
|
2789 | - * @param string The path destination |
|
2790 | - * @param boolean Option Overwrite |
|
2791 | - * @param string $source |
|
2792 | - * @param string $dest |
|
2793 | - * @return void() |
|
2794 | - * @deprecated |
|
2795 | - */ |
|
2787 | + * copy all directory and sub directory |
|
2788 | + * @param string The path origin |
|
2789 | + * @param string The path destination |
|
2790 | + * @param boolean Option Overwrite |
|
2791 | + * @param string $source |
|
2792 | + * @param string $dest |
|
2793 | + * @return void() |
|
2794 | + * @deprecated |
|
2795 | + */ |
|
2796 | 2796 | public function allow_create_all_directory($source, $dest, $overwrite = false) |
2797 | 2797 | { |
2798 | 2798 | if (!is_dir($dest)) { |
@@ -2803,7 +2803,7 @@ discard block |
||
2803 | 2803 | if ($file != '.' && $file != '..') { |
2804 | 2804 | $path = $source . '/' . $file; |
2805 | 2805 | if (is_file($path)) { |
2806 | - /* if (!is_file($dest . '/' . $file) || $overwrite) |
|
2806 | + /* if (!is_file($dest . '/' . $file) || $overwrite) |
|
2807 | 2807 | if (!@copy($path, $dest . '/' . $file)) { |
2808 | 2808 | echo '<font color="red">File ('.$path.') '.get_lang('NotHavePermission').'</font>'; |
2809 | 2809 | }*/ |
@@ -2818,12 +2818,12 @@ discard block |
||
2818 | 2818 | } |
2819 | 2819 | } |
2820 | 2820 | |
2821 | - /** |
|
2822 | - * Gets the new ID of one specific tool item from the tool name and the old ID |
|
2823 | - * @param string Tool name |
|
2824 | - * @param integer Old ID |
|
2825 | - * @return integer New ID |
|
2826 | - */ |
|
2821 | + /** |
|
2822 | + * Gets the new ID of one specific tool item from the tool name and the old ID |
|
2823 | + * @param string Tool name |
|
2824 | + * @param integer Old ID |
|
2825 | + * @return integer New ID |
|
2826 | + */ |
|
2827 | 2827 | public function get_new_id($tool, $ref) |
2828 | 2828 | { |
2829 | 2829 | // Check if the value exist in the current array. |
@@ -2845,25 +2845,25 @@ discard block |
||
2845 | 2845 | } |
2846 | 2846 | |
2847 | 2847 | return ''; |
2848 | - } |
|
2848 | + } |
|
2849 | 2849 | |
2850 | - /** |
|
2851 | - * Restore glossary |
|
2852 | - */ |
|
2850 | + /** |
|
2851 | + * Restore glossary |
|
2852 | + */ |
|
2853 | 2853 | public function restore_glossary($session_id = 0) |
2854 | 2854 | { |
2855 | - if ($this->course->has_resources(RESOURCE_GLOSSARY)) { |
|
2856 | - $table_glossary = Database :: get_course_table(TABLE_GLOSSARY); |
|
2857 | - $resources = $this->course->resources; |
|
2858 | - foreach ($resources[RESOURCE_GLOSSARY] as $id => $glossary) { |
|
2855 | + if ($this->course->has_resources(RESOURCE_GLOSSARY)) { |
|
2856 | + $table_glossary = Database :: get_course_table(TABLE_GLOSSARY); |
|
2857 | + $resources = $this->course->resources; |
|
2858 | + foreach ($resources[RESOURCE_GLOSSARY] as $id => $glossary) { |
|
2859 | 2859 | |
2860 | 2860 | $params = []; |
2861 | - if (!empty($session_id)) { |
|
2862 | - $session_id = intval($session_id); |
|
2861 | + if (!empty($session_id)) { |
|
2862 | + $session_id = intval($session_id); |
|
2863 | 2863 | $params['session_id'] = $session_id; |
2864 | - } |
|
2864 | + } |
|
2865 | 2865 | |
2866 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2866 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2867 | 2867 | $glossary->description = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
2868 | 2868 | $glossary->description, |
2869 | 2869 | $this->course->code, |
@@ -2897,27 +2897,27 @@ discard block |
||
2897 | 2897 | |
2898 | 2898 | $this->course->resources[RESOURCE_GLOSSARY][$id]->destination_id = $my_id; |
2899 | 2899 | } |
2900 | - } |
|
2901 | - } |
|
2902 | - } |
|
2900 | + } |
|
2901 | + } |
|
2902 | + } |
|
2903 | 2903 | |
2904 | 2904 | /** |
2905 | 2905 | * @param int $session_id |
2906 | 2906 | */ |
2907 | 2907 | public function restore_wiki($session_id = 0) |
2908 | 2908 | { |
2909 | - if ($this->course->has_resources(RESOURCE_WIKI)) { |
|
2910 | - // wiki table of the target course |
|
2911 | - $table_wiki = Database :: get_course_table(TABLE_WIKI); |
|
2912 | - $table_wiki_conf = Database :: get_course_table(TABLE_WIKI_CONF); |
|
2909 | + if ($this->course->has_resources(RESOURCE_WIKI)) { |
|
2910 | + // wiki table of the target course |
|
2911 | + $table_wiki = Database :: get_course_table(TABLE_WIKI); |
|
2912 | + $table_wiki_conf = Database :: get_course_table(TABLE_WIKI_CONF); |
|
2913 | 2913 | |
2914 | - // storing all the resources that have to be copied in an array |
|
2915 | - $resources = $this->course->resources; |
|
2914 | + // storing all the resources that have to be copied in an array |
|
2915 | + $resources = $this->course->resources; |
|
2916 | 2916 | |
2917 | - foreach ($resources[RESOURCE_WIKI] as $id => $wiki) { |
|
2918 | - // the sql statement to insert the groups from the old course to the new course |
|
2917 | + foreach ($resources[RESOURCE_WIKI] as $id => $wiki) { |
|
2918 | + // the sql statement to insert the groups from the old course to the new course |
|
2919 | 2919 | |
2920 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2920 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
2921 | 2921 | $wiki->content = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
2922 | 2922 | $wiki->content, |
2923 | 2923 | $this->course->code, |
@@ -2952,7 +2952,7 @@ discard block |
||
2952 | 2952 | 'user_ip' => '' |
2953 | 2953 | ]; |
2954 | 2954 | |
2955 | - $new_id = Database::insert($table_wiki, $params); |
|
2955 | + $new_id = Database::insert($table_wiki, $params); |
|
2956 | 2956 | |
2957 | 2957 | if ($new_id) { |
2958 | 2958 | $sql = "UPDATE $table_wiki SET page_id = '$new_id', id = iid |
@@ -2982,9 +2982,9 @@ discard block |
||
2982 | 2982 | |
2983 | 2983 | Database::insert($table_wiki_conf, $params); |
2984 | 2984 | } |
2985 | - } |
|
2986 | - } |
|
2987 | - } |
|
2985 | + } |
|
2986 | + } |
|
2987 | + } |
|
2988 | 2988 | |
2989 | 2989 | /** |
2990 | 2990 | * Restore Thematics |
@@ -2992,15 +2992,15 @@ discard block |
||
2992 | 2992 | */ |
2993 | 2993 | public function restore_thematic($session_id = 0) |
2994 | 2994 | { |
2995 | - if ($this->course->has_resources(RESOURCE_THEMATIC)) { |
|
2995 | + if ($this->course->has_resources(RESOURCE_THEMATIC)) { |
|
2996 | 2996 | $table_thematic = Database::get_course_table(TABLE_THEMATIC); |
2997 | 2997 | $table_thematic_advance = Database::get_course_table(TABLE_THEMATIC_ADVANCE); |
2998 | 2998 | $table_thematic_plan = Database::get_course_table(TABLE_THEMATIC_PLAN); |
2999 | 2999 | |
3000 | - $resources = $this->course->resources; |
|
3001 | - foreach ($resources[RESOURCE_THEMATIC] as $id => $thematic) { |
|
3000 | + $resources = $this->course->resources; |
|
3001 | + foreach ($resources[RESOURCE_THEMATIC] as $id => $thematic) { |
|
3002 | 3002 | |
3003 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
3003 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
3004 | 3004 | $thematic->params['content'] = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
3005 | 3005 | $thematic->params['content'], |
3006 | 3006 | $this->course->code, |
@@ -3008,13 +3008,13 @@ discard block |
||
3008 | 3008 | $this->course->backup_path, |
3009 | 3009 | $this->course->info['path'] |
3010 | 3010 | ); |
3011 | - $thematic->params['c_id'] = $this->destination_course_id; |
|
3012 | - unset($thematic->params['id']); |
|
3011 | + $thematic->params['c_id'] = $this->destination_course_id; |
|
3012 | + unset($thematic->params['id']); |
|
3013 | 3013 | unset($thematic->params['iid']); |
3014 | 3014 | |
3015 | - $last_id = Database::insert($table_thematic, $thematic->params, false); |
|
3015 | + $last_id = Database::insert($table_thematic, $thematic->params, false); |
|
3016 | 3016 | |
3017 | - if ($last_id) { |
|
3017 | + if ($last_id) { |
|
3018 | 3018 | |
3019 | 3019 | $sql = "UPDATE $table_thematic SET id = iid WHERE iid = $last_id"; |
3020 | 3020 | Database::query($sql); |
@@ -3027,12 +3027,12 @@ discard block |
||
3027 | 3027 | api_get_user_id() |
3028 | 3028 | ); |
3029 | 3029 | |
3030 | - foreach ($thematic->thematic_advance_list as $thematic_advance) { |
|
3031 | - unset($thematic_advance['id']); |
|
3030 | + foreach ($thematic->thematic_advance_list as $thematic_advance) { |
|
3031 | + unset($thematic_advance['id']); |
|
3032 | 3032 | unset($thematic_advance['iid']); |
3033 | - $thematic_advance['attendance_id'] = 0; |
|
3034 | - $thematic_advance['thematic_id'] = $last_id; |
|
3035 | - $thematic_advance['c_id'] = $this->destination_course_id; |
|
3033 | + $thematic_advance['attendance_id'] = 0; |
|
3034 | + $thematic_advance['thematic_id'] = $last_id; |
|
3035 | + $thematic_advance['c_id'] = $this->destination_course_id; |
|
3036 | 3036 | |
3037 | 3037 | $my_id = Database::insert( |
3038 | 3038 | $table_thematic_advance, |
@@ -3040,7 +3040,7 @@ discard block |
||
3040 | 3040 | false |
3041 | 3041 | ); |
3042 | 3042 | |
3043 | - if ($my_id) { |
|
3043 | + if ($my_id) { |
|
3044 | 3044 | |
3045 | 3045 | $sql = "UPDATE $table_thematic_advance SET id = iid WHERE iid = $my_id"; |
3046 | 3046 | Database::query($sql); |
@@ -3052,17 +3052,17 @@ discard block |
||
3052 | 3052 | 'ThematicAdvanceAdded', |
3053 | 3053 | api_get_user_id() |
3054 | 3054 | ); |
3055 | - } |
|
3056 | - } |
|
3055 | + } |
|
3056 | + } |
|
3057 | 3057 | |
3058 | - foreach($thematic->thematic_plan_list as $thematic_plan) { |
|
3059 | - unset($thematic_plan['id']); |
|
3058 | + foreach($thematic->thematic_plan_list as $thematic_plan) { |
|
3059 | + unset($thematic_plan['id']); |
|
3060 | 3060 | unset($thematic_plan['iid']); |
3061 | - $thematic_plan['thematic_id'] = $last_id; |
|
3062 | - $thematic_plan['c_id'] = $this->destination_course_id; |
|
3063 | - $my_id = Database::insert($table_thematic_plan, $thematic_plan, false); |
|
3061 | + $thematic_plan['thematic_id'] = $last_id; |
|
3062 | + $thematic_plan['c_id'] = $this->destination_course_id; |
|
3063 | + $my_id = Database::insert($table_thematic_plan, $thematic_plan, false); |
|
3064 | 3064 | |
3065 | - if ($my_id) { |
|
3065 | + if ($my_id) { |
|
3066 | 3066 | |
3067 | 3067 | $sql = "UPDATE $table_thematic_plan SET id = iid WHERE iid = $my_id"; |
3068 | 3068 | Database::query($sql); |
@@ -3074,12 +3074,12 @@ discard block |
||
3074 | 3074 | 'ThematicPlanAdded', |
3075 | 3075 | api_get_user_id() |
3076 | 3076 | ); |
3077 | - } |
|
3078 | - } |
|
3079 | - } |
|
3080 | - } |
|
3081 | - } |
|
3082 | - } |
|
3077 | + } |
|
3078 | + } |
|
3079 | + } |
|
3080 | + } |
|
3081 | + } |
|
3082 | + } |
|
3083 | 3083 | |
3084 | 3084 | /** |
3085 | 3085 | * Restore Attendance |
@@ -3087,14 +3087,14 @@ discard block |
||
3087 | 3087 | */ |
3088 | 3088 | public function restore_attendance($session_id = 0) |
3089 | 3089 | { |
3090 | - if ($this->course->has_resources(RESOURCE_ATTENDANCE)) { |
|
3091 | - $table_attendance = Database :: get_course_table(TABLE_ATTENDANCE); |
|
3092 | - $table_attendance_calendar = Database :: get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
3090 | + if ($this->course->has_resources(RESOURCE_ATTENDANCE)) { |
|
3091 | + $table_attendance = Database :: get_course_table(TABLE_ATTENDANCE); |
|
3092 | + $table_attendance_calendar = Database :: get_course_table(TABLE_ATTENDANCE_CALENDAR); |
|
3093 | 3093 | |
3094 | - $resources = $this->course->resources; |
|
3095 | - foreach ($resources[RESOURCE_ATTENDANCE] as $id => $obj) { |
|
3094 | + $resources = $this->course->resources; |
|
3095 | + foreach ($resources[RESOURCE_ATTENDANCE] as $id => $obj) { |
|
3096 | 3096 | |
3097 | - // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
3097 | + // check resources inside html from ckeditor tool and copy correct urls into recipient course |
|
3098 | 3098 | $obj->params['description'] = DocumentManager::replace_urls_inside_content_html_from_copy_course( |
3099 | 3099 | $obj->params['description'], |
3100 | 3100 | $this->course->code, |
@@ -3106,11 +3106,11 @@ discard block |
||
3106 | 3106 | unset($obj->params['id']); |
3107 | 3107 | unset($obj->params['iid']); |
3108 | 3108 | |
3109 | - $obj->params['c_id'] = $this->destination_course_id; |
|
3109 | + $obj->params['c_id'] = $this->destination_course_id; |
|
3110 | 3110 | |
3111 | - $last_id = Database::insert($table_attendance, $obj->params); |
|
3111 | + $last_id = Database::insert($table_attendance, $obj->params); |
|
3112 | 3112 | |
3113 | - if (is_numeric($last_id)) { |
|
3113 | + if (is_numeric($last_id)) { |
|
3114 | 3114 | |
3115 | 3115 | $sql = "UPDATE $table_attendance SET id = iid WHERE iid = $last_id"; |
3116 | 3116 | Database::query($sql); |
@@ -3124,11 +3124,11 @@ discard block |
||
3124 | 3124 | ); |
3125 | 3125 | |
3126 | 3126 | foreach ($obj->attendance_calendar as $attendance_calendar) { |
3127 | - unset($attendance_calendar['id']); |
|
3127 | + unset($attendance_calendar['id']); |
|
3128 | 3128 | unset($attendance_calendar['iid']); |
3129 | 3129 | |
3130 | - $attendance_calendar['attendance_id'] = $last_id; |
|
3131 | - $attendance_calendar['c_id'] = $this->destination_course_id; |
|
3130 | + $attendance_calendar['attendance_id'] = $last_id; |
|
3131 | + $attendance_calendar['c_id'] = $this->destination_course_id; |
|
3132 | 3132 | $attendanceCalendarId = Database::insert( |
3133 | 3133 | $table_attendance_calendar, |
3134 | 3134 | $attendance_calendar |
@@ -3136,11 +3136,11 @@ discard block |
||
3136 | 3136 | |
3137 | 3137 | $sql = "UPDATE $table_attendance_calendar SET id = iid WHERE iid = $attendanceCalendarId"; |
3138 | 3138 | Database::query($sql); |
3139 | - } |
|
3140 | - } |
|
3141 | - } |
|
3142 | - } |
|
3143 | - } |
|
3139 | + } |
|
3140 | + } |
|
3141 | + } |
|
3142 | + } |
|
3143 | + } |
|
3144 | 3144 | |
3145 | 3145 | /** |
3146 | 3146 | * Restore Works |
@@ -3281,11 +3281,11 @@ discard block |
||
3281 | 3281 | */ |
3282 | 3282 | public function DBUTF8($str) |
3283 | 3283 | { |
3284 | - if (UTF8_CONVERT) { |
|
3284 | + if (UTF8_CONVERT) { |
|
3285 | 3285 | $str = utf8_encode($str); |
3286 | 3286 | } |
3287 | - return $str; |
|
3288 | - } |
|
3287 | + return $str; |
|
3288 | + } |
|
3289 | 3289 | |
3290 | 3290 | /** |
3291 | 3291 | * @param string $str |
@@ -3296,8 +3296,8 @@ discard block |
||
3296 | 3296 | if (UTF8_CONVERT) { |
3297 | 3297 | $str = utf8_encode($str); |
3298 | 3298 | } |
3299 | - return Database::escape_string($str); |
|
3300 | - } |
|
3299 | + return Database::escape_string($str); |
|
3300 | + } |
|
3301 | 3301 | |
3302 | 3302 | /** |
3303 | 3303 | * @param array $array |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | 'changeable', |
20 | 20 | 'filter', |
21 | 21 | 'extra_field_type', |
22 | - /* Enable this when field_loggeable is introduced as a table field (2.0) |
|
22 | + /* Enable this when field_loggeable is introduced as a table field (2.0) |
|
23 | 23 | 'field_loggeable', |
24 | 24 | */ |
25 | 25 | 'created_at' |
@@ -556,7 +556,7 @@ discard block |
||
556 | 556 | * France:Paris;Bretagne;Marseille;Lyon|Belgique:Bruxelles;Namur;Liège;Bruges|Peru:Lima;Piura; |
557 | 557 | * into |
558 | 558 | * array( |
559 | - * 'France' => |
|
559 | + * 'France' => |
|
560 | 560 | * array('Paris', 'Bregtane', 'Marseille'), |
561 | 561 | * 'Belgique' => |
562 | 562 | * array('Namur', 'Liège') |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | foreach ($orderFields as $order) { |
762 | 762 | foreach ($extra as $field_details) { |
763 | 763 | if ($order == $field_details['variable']) { |
764 | - $newOrder[] = $field_details; |
|
764 | + $newOrder[] = $field_details; |
|
765 | 765 | } |
766 | 766 | } |
767 | 767 | } |
@@ -6,112 +6,111 @@ discard block |
||
6 | 6 | * |
7 | 7 | * Contains several functions dealing with displaying, |
8 | 8 | * editing,... of a blog |
9 | - |
|
10 | 9 | * @package chamilo.blogs |
11 | 10 | * @author Toon Keppens <[email protected]> |
12 | 11 | * @author Julio Montoya - Cleaning code |
13 | 12 | */ |
14 | 13 | class Blog |
15 | 14 | { |
16 | - /** |
|
17 | - * Get the title of a blog |
|
18 | - * @author Toon Keppens |
|
19 | - * |
|
20 | - * @param int $blog_id |
|
21 | - * |
|
22 | - * @return String Blog Title |
|
23 | - */ |
|
24 | - public static function get_blog_title ($blog_id) |
|
25 | - { |
|
26 | - $course_id = api_get_course_int_id(); |
|
27 | - |
|
28 | - if (is_numeric($blog_id)) { |
|
29 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
30 | - |
|
31 | - $sql = "SELECT blog_name |
|
15 | + /** |
|
16 | + * Get the title of a blog |
|
17 | + * @author Toon Keppens |
|
18 | + * |
|
19 | + * @param int $blog_id |
|
20 | + * |
|
21 | + * @return String Blog Title |
|
22 | + */ |
|
23 | + public static function get_blog_title ($blog_id) |
|
24 | + { |
|
25 | + $course_id = api_get_course_int_id(); |
|
26 | + |
|
27 | + if (is_numeric($blog_id)) { |
|
28 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
29 | + |
|
30 | + $sql = "SELECT blog_name |
|
32 | 31 | FROM " . $tbl_blogs . " |
33 | 32 | WHERE c_id = $course_id AND blog_id = " . intval($blog_id); |
34 | 33 | |
35 | - $result = Database::query($sql); |
|
36 | - $blog = Database::fetch_array($result); |
|
37 | - |
|
38 | - return stripslashes($blog['blog_name']); |
|
39 | - } |
|
40 | - } |
|
41 | - |
|
42 | - |
|
43 | - /** |
|
44 | - * Get the description of a blog |
|
45 | - * @author Toon Keppens |
|
46 | - * |
|
47 | - * @param Integer $blog_id |
|
48 | - * |
|
49 | - * @return String Blog description |
|
50 | - */ |
|
51 | - public static function get_blog_subtitle($blog_id) |
|
52 | - { |
|
53 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
54 | - $course_id = api_get_course_int_id(); |
|
55 | - $sql = "SELECT blog_subtitle FROM $tbl_blogs |
|
34 | + $result = Database::query($sql); |
|
35 | + $blog = Database::fetch_array($result); |
|
36 | + |
|
37 | + return stripslashes($blog['blog_name']); |
|
38 | + } |
|
39 | + } |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * Get the description of a blog |
|
44 | + * @author Toon Keppens |
|
45 | + * |
|
46 | + * @param Integer $blog_id |
|
47 | + * |
|
48 | + * @return String Blog description |
|
49 | + */ |
|
50 | + public static function get_blog_subtitle($blog_id) |
|
51 | + { |
|
52 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
53 | + $course_id = api_get_course_int_id(); |
|
54 | + $sql = "SELECT blog_subtitle FROM $tbl_blogs |
|
56 | 55 | WHERE c_id = $course_id AND blog_id ='".intval($blog_id)."'"; |
57 | - $result = Database::query($sql); |
|
58 | - $blog = Database::fetch_array($result); |
|
59 | - |
|
60 | - return stripslashes($blog['blog_subtitle']); |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * Get the users of a blog |
|
65 | - * @author Toon Keppens |
|
66 | - * |
|
67 | - * @param Integer $blog_id |
|
68 | - * |
|
69 | - * @return Array Returns an array with [userid]=>[username] |
|
70 | - */ |
|
71 | - public static function get_blog_users($blog_id) |
|
72 | - { |
|
73 | - // Database table definitions |
|
74 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
75 | - $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
76 | - |
|
77 | - $course_id = api_get_course_int_id(); |
|
78 | - |
|
79 | - // Get blog members |
|
80 | - $sql = "SELECT user.user_id, user.firstname, user.lastname |
|
56 | + $result = Database::query($sql); |
|
57 | + $blog = Database::fetch_array($result); |
|
58 | + |
|
59 | + return stripslashes($blog['blog_subtitle']); |
|
60 | + } |
|
61 | + |
|
62 | + /** |
|
63 | + * Get the users of a blog |
|
64 | + * @author Toon Keppens |
|
65 | + * |
|
66 | + * @param Integer $blog_id |
|
67 | + * |
|
68 | + * @return Array Returns an array with [userid]=>[username] |
|
69 | + */ |
|
70 | + public static function get_blog_users($blog_id) |
|
71 | + { |
|
72 | + // Database table definitions |
|
73 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
74 | + $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
75 | + |
|
76 | + $course_id = api_get_course_int_id(); |
|
77 | + |
|
78 | + // Get blog members |
|
79 | + $sql = "SELECT user.user_id, user.firstname, user.lastname |
|
81 | 80 | FROM " . $tbl_blogs_rel_user . " blogs_rel_user |
82 | 81 | INNER JOIN " . $tbl_users . " user |
83 | 82 | ON blogs_rel_user.user_id = user.user_id |
84 | 83 | WHERE |
85 | 84 | blogs_rel_user.c_id = $course_id AND |
86 | 85 | blogs_rel_user.blog_id = '" . (int)$blog_id."'"; |
87 | - $result = Database::query($sql); |
|
88 | - $blog_members = array (); |
|
89 | - while($user = Database::fetch_array($result)) { |
|
90 | - $blog_members[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']); |
|
91 | - } |
|
92 | - |
|
93 | - return $blog_members; |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * Creates a new blog in the given course |
|
98 | - * @author Toon Keppens |
|
99 | - * @param string $title |
|
100 | - */ |
|
101 | - public static function create_blog($title, $subtitle) |
|
102 | - { |
|
103 | - $_user = api_get_user_info(); |
|
86 | + $result = Database::query($sql); |
|
87 | + $blog_members = array (); |
|
88 | + while($user = Database::fetch_array($result)) { |
|
89 | + $blog_members[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']); |
|
90 | + } |
|
91 | + |
|
92 | + return $blog_members; |
|
93 | + } |
|
94 | + |
|
95 | + /** |
|
96 | + * Creates a new blog in the given course |
|
97 | + * @author Toon Keppens |
|
98 | + * @param string $title |
|
99 | + */ |
|
100 | + public static function create_blog($title, $subtitle) |
|
101 | + { |
|
102 | + $_user = api_get_user_info(); |
|
104 | 103 | $course_id = api_get_course_int_id(); |
105 | 104 | |
106 | - $current_date=date('Y-m-d H:i:s',time()); |
|
107 | - $session_id = api_get_session_id(); |
|
108 | - // Tabel definitions |
|
105 | + $current_date=date('Y-m-d H:i:s',time()); |
|
106 | + $session_id = api_get_session_id(); |
|
107 | + // Tabel definitions |
|
109 | 108 | $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
110 | 109 | $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST); |
111 | 110 | $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
112 | 111 | |
113 | - //verified if exist blog |
|
114 | - $sql = 'SELECT COUNT(*) as count FROM '.$tbl_blogs.' |
|
112 | + //verified if exist blog |
|
113 | + $sql = 'SELECT COUNT(*) as count FROM '.$tbl_blogs.' |
|
115 | 114 | WHERE |
116 | 115 | c_id = '.$course_id.' AND |
117 | 116 | blog_name="'.Database::escape_string($title).'" AND |
@@ -120,9 +119,9 @@ discard block |
||
120 | 119 | $info_count = Database::result($res, 0, 0); |
121 | 120 | |
122 | 121 | if ($info_count == 0) { |
123 | - // Create the blog |
|
122 | + // Create the blog |
|
124 | 123 | $params = [ |
125 | - 'blog_id' => 0, |
|
124 | + 'blog_id' => 0, |
|
126 | 125 | 'c_id' => $course_id, |
127 | 126 | 'blog_name' => $title, |
128 | 127 | 'blog_subtitle' => $subtitle, |
@@ -130,14 +129,14 @@ discard block |
||
130 | 129 | 'visibility' => 1 , |
131 | 130 | 'session_id' => $session_id, |
132 | 131 | ]; |
133 | - $this_blog_id = Database::insert($tbl_blogs, $params); |
|
132 | + $this_blog_id = Database::insert($tbl_blogs, $params); |
|
134 | 133 | |
135 | - if ($this_blog_id > 0) { |
|
134 | + if ($this_blog_id > 0) { |
|
136 | 135 | |
137 | 136 | $sql = "UPDATE $tbl_blogs SET blog_id = iid WHERE iid = $this_blog_id"; |
138 | 137 | Database::query($sql); |
139 | 138 | |
140 | - // insert into item_property |
|
139 | + // insert into item_property |
|
141 | 140 | api_item_property_update( |
142 | 141 | api_get_course_info(), |
143 | 142 | TOOL_BLOGS, |
@@ -145,12 +144,12 @@ discard block |
||
145 | 144 | 'BlogAdded', |
146 | 145 | api_get_user_id() |
147 | 146 | ); |
148 | - } |
|
147 | + } |
|
149 | 148 | |
150 | - // Make first post. :) |
|
149 | + // Make first post. :) |
|
151 | 150 | |
152 | 151 | $params = [ |
153 | - 'post_id' => 0, |
|
152 | + 'post_id' => 0, |
|
154 | 153 | 'c_id' => $course_id, |
155 | 154 | 'title' => get_lang("Welcome"), |
156 | 155 | 'full_text' => get_lang('FirstPostText'), |
@@ -164,10 +163,10 @@ discard block |
||
164 | 163 | Database::query($sql); |
165 | 164 | } |
166 | 165 | |
167 | - // Put it on course homepage |
|
168 | - $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, session_id, target) |
|
166 | + // Put it on course homepage |
|
167 | + $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, session_id, target) |
|
169 | 168 | VALUES ($course_id, '".Database::escape_string($title)."','blog/blog.php?blog_id=".(int)$this_blog_id."','blog.gif','1','0','pastillegris.gif',0,'$session_id', '')"; |
170 | - Database::query($sql); |
|
169 | + Database::query($sql); |
|
171 | 170 | |
172 | 171 | $toolId = Database::insert_id(); |
173 | 172 | if ($toolId) { |
@@ -175,35 +174,35 @@ discard block |
||
175 | 174 | Database::query($sql); |
176 | 175 | } |
177 | 176 | |
178 | - // Subscribe the teacher to this blog |
|
179 | - Blog::set_user_subscribed($this_blog_id, $_user['user_id']); |
|
180 | - } |
|
181 | - } |
|
182 | - |
|
183 | - /** |
|
184 | - * Update title and subtitle of a blog in the given course |
|
185 | - * @author Toon Keppens |
|
186 | - * @param string $title |
|
187 | - */ |
|
188 | - public static function edit_blog($blog_id, $title, $subtitle) |
|
189 | - { |
|
190 | - // Table definitions |
|
191 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
192 | - $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST); |
|
177 | + // Subscribe the teacher to this blog |
|
178 | + Blog::set_user_subscribed($this_blog_id, $_user['user_id']); |
|
179 | + } |
|
180 | + } |
|
181 | + |
|
182 | + /** |
|
183 | + * Update title and subtitle of a blog in the given course |
|
184 | + * @author Toon Keppens |
|
185 | + * @param string $title |
|
186 | + */ |
|
187 | + public static function edit_blog($blog_id, $title, $subtitle) |
|
188 | + { |
|
189 | + // Table definitions |
|
190 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
191 | + $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST); |
|
193 | 192 | |
194 | 193 | $course_id = api_get_course_int_id(); |
195 | 194 | |
196 | - // Update the blog |
|
197 | - $sql = "UPDATE $tbl_blogs SET |
|
195 | + // Update the blog |
|
196 | + $sql = "UPDATE $tbl_blogs SET |
|
198 | 197 | blog_name = '".Database::escape_string($title)."', |
199 | 198 | blog_subtitle = '".Database::escape_string($subtitle)."' |
200 | 199 | WHERE |
201 | 200 | c_id = $course_id AND |
202 | 201 | blog_id ='".Database::escape_string((int)$blog_id)."' |
203 | 202 | LIMIT 1"; |
204 | - Database::query($sql); |
|
203 | + Database::query($sql); |
|
205 | 204 | |
206 | - //update item_property (update) |
|
205 | + //update item_property (update) |
|
207 | 206 | api_item_property_update( |
208 | 207 | api_get_course_info(), |
209 | 208 | TOOL_BLOGS, |
@@ -212,21 +211,21 @@ discard block |
||
212 | 211 | api_get_user_id() |
213 | 212 | ); |
214 | 213 | |
215 | - // Update course homepage link |
|
216 | - $sql = "UPDATE $tbl_tool SET |
|
214 | + // Update course homepage link |
|
215 | + $sql = "UPDATE $tbl_tool SET |
|
217 | 216 | name = '".Database::escape_string($title)."' |
218 | 217 | WHERE c_id = $course_id AND link = 'blog/blog.php?blog_id=".(int)$blog_id."' LIMIT 1"; |
219 | - Database::query($sql); |
|
220 | - } |
|
221 | - |
|
222 | - /** |
|
223 | - * Deletes a blog and it's posts from the course database |
|
224 | - * @author Toon Keppens |
|
225 | - * @param Integer $blog_id |
|
226 | - */ |
|
227 | - public static function delete_blog($blog_id) |
|
228 | - { |
|
229 | - // Init |
|
218 | + Database::query($sql); |
|
219 | + } |
|
220 | + |
|
221 | + /** |
|
222 | + * Deletes a blog and it's posts from the course database |
|
223 | + * @author Toon Keppens |
|
224 | + * @param Integer $blog_id |
|
225 | + */ |
|
226 | + public static function delete_blog($blog_id) |
|
227 | + { |
|
228 | + // Init |
|
230 | 229 | $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
231 | 230 | $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
232 | 231 | $tbl_blogs_comment = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
@@ -237,34 +236,34 @@ discard block |
||
237 | 236 | $course_id = api_get_course_int_id(); |
238 | 237 | $blog_id = intval($blog_id); |
239 | 238 | |
240 | - // Delete posts from DB and the attachments |
|
241 | - delete_all_blog_attachment($blog_id); |
|
239 | + // Delete posts from DB and the attachments |
|
240 | + delete_all_blog_attachment($blog_id); |
|
242 | 241 | |
243 | - //Delete comments |
|
244 | - $sql = "DELETE FROM $tbl_blogs_comment WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
245 | - Database::query($sql); |
|
242 | + //Delete comments |
|
243 | + $sql = "DELETE FROM $tbl_blogs_comment WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
244 | + Database::query($sql); |
|
246 | 245 | |
247 | - // Delete posts |
|
248 | - $sql = "DELETE FROM $tbl_blogs_posts WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
249 | - Database::query($sql); |
|
246 | + // Delete posts |
|
247 | + $sql = "DELETE FROM $tbl_blogs_posts WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
248 | + Database::query($sql); |
|
250 | 249 | |
251 | - // Delete tasks |
|
252 | - $sql = "DELETE FROM $tbl_blogs_tasks WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
253 | - Database::query($sql); |
|
250 | + // Delete tasks |
|
251 | + $sql = "DELETE FROM $tbl_blogs_tasks WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
252 | + Database::query($sql); |
|
254 | 253 | |
255 | - // Delete ratings |
|
256 | - $sql = "DELETE FROM $tbl_blogs_rating WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
257 | - Database::query($sql); |
|
254 | + // Delete ratings |
|
255 | + $sql = "DELETE FROM $tbl_blogs_rating WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
256 | + Database::query($sql); |
|
258 | 257 | |
259 | - // Delete blog |
|
260 | - $sql ="DELETE FROM $tbl_blogs WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
261 | - Database::query($sql); |
|
258 | + // Delete blog |
|
259 | + $sql ="DELETE FROM $tbl_blogs WHERE c_id = $course_id AND blog_id ='".$blog_id."'"; |
|
260 | + Database::query($sql); |
|
262 | 261 | |
263 | - // Delete from course homepage |
|
264 | - $sql = "DELETE FROM $tbl_tool WHERE c_id = $course_id AND link = 'blog/blog.php?blog_id=".$blog_id."'"; |
|
265 | - Database::query($sql); |
|
262 | + // Delete from course homepage |
|
263 | + $sql = "DELETE FROM $tbl_tool WHERE c_id = $course_id AND link = 'blog/blog.php?blog_id=".$blog_id."'"; |
|
264 | + Database::query($sql); |
|
266 | 265 | |
267 | - //update item_property (delete) |
|
266 | + //update item_property (delete) |
|
268 | 267 | api_item_property_update( |
269 | 268 | api_get_course_info(), |
270 | 269 | TOOL_BLOGS, |
@@ -272,152 +271,152 @@ discard block |
||
272 | 271 | 'delete', |
273 | 272 | api_get_user_id() |
274 | 273 | ); |
275 | - } |
|
276 | - |
|
277 | - /** |
|
278 | - * Creates a new post in a given blog |
|
279 | - * @author Toon Keppens |
|
280 | - * @param String $title |
|
281 | - * @param String $full_text |
|
282 | - * @param Integer $blog_id |
|
283 | - */ |
|
284 | - public static function create_post($title, $full_text, $file_comment, $blog_id) |
|
285 | - { |
|
286 | - $_user = api_get_user_info(); |
|
287 | - $_course = api_get_course_info(); |
|
288 | - $course_id = $_course['real_id']; |
|
289 | - |
|
290 | - $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
291 | - $upload_ok=true; |
|
292 | - $has_attachment=false; |
|
293 | - $current_date = api_get_utc_datetime(); |
|
294 | - |
|
295 | - if (!empty($_FILES['user_upload']['name'])) { |
|
296 | - $upload_ok = process_uploaded_file($_FILES['user_upload']); |
|
297 | - $has_attachment=true; |
|
298 | - } |
|
299 | - |
|
300 | - if ($upload_ok) { |
|
301 | - // Table Definitions |
|
302 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
303 | - |
|
304 | - // Create the post |
|
305 | - $sql = "INSERT INTO $tbl_blogs_posts (c_id, title, full_text, date_creation, blog_id, author_id ) |
|
274 | + } |
|
275 | + |
|
276 | + /** |
|
277 | + * Creates a new post in a given blog |
|
278 | + * @author Toon Keppens |
|
279 | + * @param String $title |
|
280 | + * @param String $full_text |
|
281 | + * @param Integer $blog_id |
|
282 | + */ |
|
283 | + public static function create_post($title, $full_text, $file_comment, $blog_id) |
|
284 | + { |
|
285 | + $_user = api_get_user_info(); |
|
286 | + $_course = api_get_course_info(); |
|
287 | + $course_id = $_course['real_id']; |
|
288 | + |
|
289 | + $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
290 | + $upload_ok=true; |
|
291 | + $has_attachment=false; |
|
292 | + $current_date = api_get_utc_datetime(); |
|
293 | + |
|
294 | + if (!empty($_FILES['user_upload']['name'])) { |
|
295 | + $upload_ok = process_uploaded_file($_FILES['user_upload']); |
|
296 | + $has_attachment=true; |
|
297 | + } |
|
298 | + |
|
299 | + if ($upload_ok) { |
|
300 | + // Table Definitions |
|
301 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
302 | + |
|
303 | + // Create the post |
|
304 | + $sql = "INSERT INTO $tbl_blogs_posts (c_id, title, full_text, date_creation, blog_id, author_id ) |
|
306 | 305 | VALUES ($course_id, '".Database::escape_string($title)."', '".Database::escape_string($full_text)."','".$current_date."', '".(int)$blog_id."', '".(int)$_user['user_id']."');"; |
307 | 306 | |
308 | - Database::query($sql); |
|
309 | - $last_post_id = Database::insert_id(); |
|
307 | + Database::query($sql); |
|
308 | + $last_post_id = Database::insert_id(); |
|
310 | 309 | |
311 | 310 | if ($last_post_id) { |
312 | 311 | $sql = "UPDATE $tbl_blogs_posts SET post_id = iid WHERE iid = $last_post_id"; |
313 | 312 | Database::query($sql); |
314 | 313 | } |
315 | 314 | |
316 | - if ($has_attachment) { |
|
317 | - $courseDir = $_course['path'].'/upload/blog'; |
|
318 | - $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
319 | - $updir = $sys_course_path.$courseDir; |
|
320 | - |
|
321 | - // Try to add an extension to the file if it hasn't one |
|
322 | - $new_file_name = add_ext_on_mime(stripslashes($_FILES['user_upload']['name']), $_FILES['user_upload']['type']); |
|
323 | - |
|
324 | - // user's file name |
|
325 | - $file_name = $_FILES['user_upload']['name']; |
|
326 | - |
|
327 | - if (!filter_extension($new_file_name)) { |
|
328 | - Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); |
|
329 | - } else { |
|
330 | - $new_file_name = uniqid(''); |
|
331 | - $new_path = $updir.'/'.$new_file_name; |
|
332 | - $result = @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path); |
|
333 | - $comment = Database::escape_string($file_comment); |
|
334 | - |
|
335 | - // Storing the attachments if any |
|
336 | - if ($result) { |
|
337 | - $sql = 'INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size, blog_id,comment_id) '. |
|
338 | - "VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$last_post_id."', '".intval($_FILES['user_upload']['size'])."', '".$blog_id."', '0' )"; |
|
339 | - Database::query($sql); |
|
315 | + if ($has_attachment) { |
|
316 | + $courseDir = $_course['path'].'/upload/blog'; |
|
317 | + $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
318 | + $updir = $sys_course_path.$courseDir; |
|
319 | + |
|
320 | + // Try to add an extension to the file if it hasn't one |
|
321 | + $new_file_name = add_ext_on_mime(stripslashes($_FILES['user_upload']['name']), $_FILES['user_upload']['type']); |
|
322 | + |
|
323 | + // user's file name |
|
324 | + $file_name = $_FILES['user_upload']['name']; |
|
325 | + |
|
326 | + if (!filter_extension($new_file_name)) { |
|
327 | + Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); |
|
328 | + } else { |
|
329 | + $new_file_name = uniqid(''); |
|
330 | + $new_path = $updir.'/'.$new_file_name; |
|
331 | + $result = @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path); |
|
332 | + $comment = Database::escape_string($file_comment); |
|
333 | + |
|
334 | + // Storing the attachments if any |
|
335 | + if ($result) { |
|
336 | + $sql = 'INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size, blog_id,comment_id) '. |
|
337 | + "VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$last_post_id."', '".intval($_FILES['user_upload']['size'])."', '".$blog_id."', '0' )"; |
|
338 | + Database::query($sql); |
|
340 | 339 | $id = Database::insert_id(); |
341 | 340 | if ($id) { |
342 | 341 | $sql = "UPDATE $blog_table_attachment SET id = iid WHERE iid = $id"; |
343 | 342 | Database::query($sql); |
344 | 343 | } |
345 | - } |
|
346 | - } |
|
347 | - } |
|
348 | - } else { |
|
349 | - Display::display_error_message(get_lang('UplNoFileUploaded')); |
|
350 | - } |
|
351 | - } |
|
352 | - |
|
353 | - /** |
|
354 | - * Edits a post in a given blog |
|
355 | - * @author Toon Keppens |
|
356 | - * @param Integer $blog_id |
|
357 | - * @param String $title |
|
358 | - * @param String $full_text |
|
359 | - * @param Integer $blog_id |
|
360 | - */ |
|
361 | - public static function edit_post($post_id, $title, $full_text, $blog_id) |
|
362 | - { |
|
363 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
344 | + } |
|
345 | + } |
|
346 | + } |
|
347 | + } else { |
|
348 | + Display::display_error_message(get_lang('UplNoFileUploaded')); |
|
349 | + } |
|
350 | + } |
|
351 | + |
|
352 | + /** |
|
353 | + * Edits a post in a given blog |
|
354 | + * @author Toon Keppens |
|
355 | + * @param Integer $blog_id |
|
356 | + * @param String $title |
|
357 | + * @param String $full_text |
|
358 | + * @param Integer $blog_id |
|
359 | + */ |
|
360 | + public static function edit_post($post_id, $title, $full_text, $blog_id) |
|
361 | + { |
|
362 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
364 | 363 | $course_id = api_get_course_int_id(); |
365 | 364 | |
366 | - // Create the post |
|
367 | - $sql = "UPDATE $tbl_blogs_posts SET |
|
365 | + // Create the post |
|
366 | + $sql = "UPDATE $tbl_blogs_posts SET |
|
368 | 367 | title = '" . Database::escape_string($title)."', |
369 | 368 | full_text = '" . Database::escape_string($full_text)."' |
370 | 369 | WHERE c_id = $course_id AND post_id ='".(int)$post_id."' AND blog_id ='".(int)$blog_id."' |
371 | 370 | LIMIT 1 "; |
372 | - Database::query($sql); |
|
373 | - } |
|
374 | - |
|
375 | - /** |
|
376 | - * Deletes an article and it's comments |
|
377 | - * @author Toon Keppens |
|
378 | - * @param int $blog_id |
|
379 | - * @param int $post_id |
|
380 | - */ |
|
381 | - public static function delete_post($blog_id, $post_id) |
|
382 | - { |
|
383 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
384 | - $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
385 | - $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
371 | + Database::query($sql); |
|
372 | + } |
|
373 | + |
|
374 | + /** |
|
375 | + * Deletes an article and it's comments |
|
376 | + * @author Toon Keppens |
|
377 | + * @param int $blog_id |
|
378 | + * @param int $post_id |
|
379 | + */ |
|
380 | + public static function delete_post($blog_id, $post_id) |
|
381 | + { |
|
382 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
383 | + $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
384 | + $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
386 | 385 | |
387 | 386 | $course_id = api_get_course_int_id(); |
388 | 387 | |
389 | - // Delete ratings on this comment |
|
390 | - $sql = "DELETE FROM $tbl_blogs_rating |
|
388 | + // Delete ratings on this comment |
|
389 | + $sql = "DELETE FROM $tbl_blogs_rating |
|
391 | 390 | WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND item_id = '".(int)$post_id."' AND rating_type = 'post'"; |
392 | - Database::query($sql); |
|
391 | + Database::query($sql); |
|
393 | 392 | |
394 | - // Delete the post |
|
395 | - $sql = "DELETE FROM $tbl_blogs_posts |
|
393 | + // Delete the post |
|
394 | + $sql = "DELETE FROM $tbl_blogs_posts |
|
396 | 395 | WHERE c_id = $course_id AND post_id = '".(int)$post_id."'"; |
397 | - Database::query($sql); |
|
396 | + Database::query($sql); |
|
398 | 397 | |
399 | - // Delete the comments |
|
400 | - $sql = "DELETE FROM $tbl_blogs_comments |
|
398 | + // Delete the comments |
|
399 | + $sql = "DELETE FROM $tbl_blogs_comments |
|
401 | 400 | WHERE c_id = $course_id AND post_id = '".(int)$post_id."' AND blog_id = '".(int)$blog_id."'"; |
402 | - Database::query($sql); |
|
403 | - |
|
404 | - // Delete posts and attachments |
|
405 | - delete_all_blog_attachment($blog_id,$post_id); |
|
406 | - } |
|
407 | - |
|
408 | - /** |
|
409 | - * Creates a comment on a post in a given blog |
|
410 | - * @author Toon Keppens |
|
411 | - * @param String $title |
|
412 | - * @param String $full_text |
|
413 | - * @param Integer $blog_id |
|
414 | - * @param Integer $post_id |
|
415 | - * @param Integer $parent_id |
|
416 | - */ |
|
417 | - public static function create_comment($title, $full_text, $file_comment, $blog_id, $post_id, $parent_id, $task_id = 'NULL') |
|
418 | - { |
|
419 | - $_user = api_get_user_info(); |
|
420 | - $_course = api_get_course_info(); |
|
401 | + Database::query($sql); |
|
402 | + |
|
403 | + // Delete posts and attachments |
|
404 | + delete_all_blog_attachment($blog_id,$post_id); |
|
405 | + } |
|
406 | + |
|
407 | + /** |
|
408 | + * Creates a comment on a post in a given blog |
|
409 | + * @author Toon Keppens |
|
410 | + * @param String $title |
|
411 | + * @param String $full_text |
|
412 | + * @param Integer $blog_id |
|
413 | + * @param Integer $post_id |
|
414 | + * @param Integer $parent_id |
|
415 | + */ |
|
416 | + public static function create_comment($title, $full_text, $file_comment, $blog_id, $post_id, $parent_id, $task_id = 'NULL') |
|
417 | + { |
|
418 | + $_user = api_get_user_info(); |
|
419 | + $_course = api_get_course_info(); |
|
421 | 420 | $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
422 | 421 | |
423 | 422 | $upload_ok = true; |
@@ -425,55 +424,55 @@ discard block |
||
425 | 424 | $current_date = api_get_utc_datetime(); |
426 | 425 | $course_id = api_get_course_int_id(); |
427 | 426 | |
428 | - if (!empty($_FILES['user_upload']['name'])) { |
|
429 | - $upload_ok = process_uploaded_file($_FILES['user_upload']); |
|
430 | - $has_attachment=true; |
|
431 | - } |
|
427 | + if (!empty($_FILES['user_upload']['name'])) { |
|
428 | + $upload_ok = process_uploaded_file($_FILES['user_upload']); |
|
429 | + $has_attachment=true; |
|
430 | + } |
|
432 | 431 | |
433 | - if ($upload_ok) { |
|
434 | - // Table Definition |
|
435 | - $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
432 | + if ($upload_ok) { |
|
433 | + // Table Definition |
|
434 | + $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
436 | 435 | |
437 | - // Create the comment |
|
438 | - $sql = "INSERT INTO $tbl_blogs_comments (c_id, title, comment, author_id, date_creation, blog_id, post_id, parent_comment_id, task_id ) |
|
436 | + // Create the comment |
|
437 | + $sql = "INSERT INTO $tbl_blogs_comments (c_id, title, comment, author_id, date_creation, blog_id, post_id, parent_comment_id, task_id ) |
|
439 | 438 | VALUES ($course_id, '".Database::escape_string($title)."', '".Database::escape_string($full_text)."', '".(int)$_user['user_id']."','".$current_date."', '".(int)$blog_id."', '".(int)$post_id."', '".(int)$parent_id."', '".(int)$task_id."')"; |
440 | - Database::query($sql); |
|
439 | + Database::query($sql); |
|
441 | 440 | |
442 | - // Empty post values, or they are shown on the page again |
|
443 | - $last_id = Database::insert_id(); |
|
441 | + // Empty post values, or they are shown on the page again |
|
442 | + $last_id = Database::insert_id(); |
|
444 | 443 | |
445 | 444 | if ($last_id) { |
446 | 445 | $sql = "UPDATE $tbl_blogs_comments SET comment_id = iid WHERE iid = $last_id"; |
447 | 446 | Database::query($sql); |
448 | 447 | } |
449 | 448 | |
450 | - if ($has_attachment) { |
|
451 | - $courseDir = $_course['path'].'/upload/blog'; |
|
452 | - $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
453 | - $updir = $sys_course_path.$courseDir; |
|
454 | - |
|
455 | - // Try to add an extension to the file if it hasn't one |
|
456 | - $new_file_name = add_ext_on_mime( |
|
457 | - stripslashes($_FILES['user_upload']['name']), |
|
458 | - $_FILES['user_upload']['type'] |
|
459 | - ); |
|
460 | - |
|
461 | - // user's file name |
|
462 | - $file_name =$_FILES['user_upload']['name']; |
|
463 | - |
|
464 | - if (!filter_extension($new_file_name)) { |
|
465 | - Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); |
|
466 | - } else { |
|
467 | - $new_file_name = uniqid(''); |
|
468 | - $new_path=$updir.'/'.$new_file_name; |
|
469 | - $result= @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path); |
|
470 | - $comment = Database::escape_string($file_comment); |
|
471 | - |
|
472 | - // Storing the attachments if any |
|
473 | - if ($result) { |
|
474 | - $sql='INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size,blog_id,comment_id) '. |
|
475 | - "VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$post_id."', '".$_FILES['user_upload']['size']."', '".$blog_id."', '".$last_id."' )"; |
|
476 | - Database::query($sql); |
|
449 | + if ($has_attachment) { |
|
450 | + $courseDir = $_course['path'].'/upload/blog'; |
|
451 | + $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
452 | + $updir = $sys_course_path.$courseDir; |
|
453 | + |
|
454 | + // Try to add an extension to the file if it hasn't one |
|
455 | + $new_file_name = add_ext_on_mime( |
|
456 | + stripslashes($_FILES['user_upload']['name']), |
|
457 | + $_FILES['user_upload']['type'] |
|
458 | + ); |
|
459 | + |
|
460 | + // user's file name |
|
461 | + $file_name =$_FILES['user_upload']['name']; |
|
462 | + |
|
463 | + if (!filter_extension($new_file_name)) { |
|
464 | + Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); |
|
465 | + } else { |
|
466 | + $new_file_name = uniqid(''); |
|
467 | + $new_path=$updir.'/'.$new_file_name; |
|
468 | + $result= @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path); |
|
469 | + $comment = Database::escape_string($file_comment); |
|
470 | + |
|
471 | + // Storing the attachments if any |
|
472 | + if ($result) { |
|
473 | + $sql='INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size,blog_id,comment_id) '. |
|
474 | + "VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$post_id."', '".$_FILES['user_upload']['size']."', '".$blog_id."', '".$last_id."' )"; |
|
475 | + Database::query($sql); |
|
477 | 476 | |
478 | 477 | $id = Database::insert_id(); |
479 | 478 | |
@@ -481,91 +480,91 @@ discard block |
||
481 | 480 | $sql = "UPDATE $blog_table_attachment SET id = iid WHERE iid = $id"; |
482 | 481 | Database::query($sql); |
483 | 482 | } |
484 | - } |
|
485 | - } |
|
486 | - } |
|
487 | - } |
|
488 | - } |
|
489 | - |
|
490 | - /** |
|
491 | - * Deletes a comment from a blogpost |
|
492 | - * @author Toon Keppens |
|
493 | - * @param int $blog_id |
|
494 | - * @param int $comment_id |
|
495 | - */ |
|
496 | - public static function delete_comment($blog_id, $post_id, $comment_id) |
|
497 | - { |
|
498 | - $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
499 | - $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
500 | - $blog_id = intval($blog_id); |
|
501 | - $post_id = intval($post_id); |
|
502 | - $comment_id = intval($comment_id); |
|
483 | + } |
|
484 | + } |
|
485 | + } |
|
486 | + } |
|
487 | + } |
|
488 | + |
|
489 | + /** |
|
490 | + * Deletes a comment from a blogpost |
|
491 | + * @author Toon Keppens |
|
492 | + * @param int $blog_id |
|
493 | + * @param int $comment_id |
|
494 | + */ |
|
495 | + public static function delete_comment($blog_id, $post_id, $comment_id) |
|
496 | + { |
|
497 | + $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
498 | + $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
499 | + $blog_id = intval($blog_id); |
|
500 | + $post_id = intval($post_id); |
|
501 | + $comment_id = intval($comment_id); |
|
503 | 502 | $course_id = api_get_course_int_id(); |
504 | 503 | |
505 | - delete_all_blog_attachment($blog_id, $post_id, $comment_id); |
|
504 | + delete_all_blog_attachment($blog_id, $post_id, $comment_id); |
|
506 | 505 | |
507 | - // Delete ratings on this comment |
|
508 | - $sql = "DELETE FROM $tbl_blogs_rating |
|
506 | + // Delete ratings on this comment |
|
507 | + $sql = "DELETE FROM $tbl_blogs_rating |
|
509 | 508 | WHERE |
510 | 509 | c_id = $course_id AND |
511 | 510 | blog_id = '".$blog_id."' AND |
512 | 511 | item_id = '".$comment_id."' AND |
513 | 512 | rating_type = 'comment'"; |
514 | - Database::query($sql); |
|
513 | + Database::query($sql); |
|
515 | 514 | |
516 | - // select comments that have the selected comment as their parent |
|
517 | - $sql = "SELECT comment_id FROM $tbl_blogs_comments |
|
515 | + // select comments that have the selected comment as their parent |
|
516 | + $sql = "SELECT comment_id FROM $tbl_blogs_comments |
|
518 | 517 | WHERE c_id = $course_id AND parent_comment_id = '".$comment_id."'"; |
519 | - $result = Database::query($sql); |
|
518 | + $result = Database::query($sql); |
|
520 | 519 | |
521 | - // Delete them recursively |
|
522 | - while ($comment = Database::fetch_array($result)) { |
|
523 | - Blog::delete_comment($blog_id,$post_id,$comment['comment_id']); |
|
524 | - } |
|
520 | + // Delete them recursively |
|
521 | + while ($comment = Database::fetch_array($result)) { |
|
522 | + Blog::delete_comment($blog_id,$post_id,$comment['comment_id']); |
|
523 | + } |
|
525 | 524 | |
526 | - // Finally, delete the selected comment to |
|
527 | - $sql = "DELETE FROM $tbl_blogs_comments |
|
525 | + // Finally, delete the selected comment to |
|
526 | + $sql = "DELETE FROM $tbl_blogs_comments |
|
528 | 527 | WHERE c_id = $course_id AND comment_id = '".$comment_id."'"; |
529 | - Database::query($sql); |
|
530 | - } |
|
531 | - |
|
532 | - /** |
|
533 | - * Creates a new task in a blog |
|
534 | - * @author Toon Keppens |
|
535 | - * @param Integer $blog_id |
|
536 | - * @param String $title |
|
537 | - * @param String $description |
|
538 | - * @param String $color |
|
539 | - */ |
|
540 | - public static function create_task($blog_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color) |
|
541 | - { |
|
542 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
543 | - $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
544 | - |
|
545 | - $course_id = api_get_course_int_id(); |
|
546 | - |
|
547 | - // Create the task |
|
548 | - $sql = "INSERT INTO $tbl_blogs_tasks (c_id, blog_id, title, description, color, system_task) |
|
528 | + Database::query($sql); |
|
529 | + } |
|
530 | + |
|
531 | + /** |
|
532 | + * Creates a new task in a blog |
|
533 | + * @author Toon Keppens |
|
534 | + * @param Integer $blog_id |
|
535 | + * @param String $title |
|
536 | + * @param String $description |
|
537 | + * @param String $color |
|
538 | + */ |
|
539 | + public static function create_task($blog_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color) |
|
540 | + { |
|
541 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
542 | + $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
543 | + |
|
544 | + $course_id = api_get_course_int_id(); |
|
545 | + |
|
546 | + // Create the task |
|
547 | + $sql = "INSERT INTO $tbl_blogs_tasks (c_id, blog_id, title, description, color, system_task) |
|
549 | 548 | VALUES ($course_id , '".(int)$blog_id."', '" . Database::escape_string($title)."', '" . Database::escape_string($description)."', '" . Database::escape_string($color)."', '0');"; |
550 | - Database::query($sql); |
|
549 | + Database::query($sql); |
|
551 | 550 | |
552 | - $task_id = Database::insert_id(); |
|
551 | + $task_id = Database::insert_id(); |
|
553 | 552 | |
554 | 553 | if ($task_id) { |
555 | 554 | $sql = "UPDATE $tbl_blogs_tasks SET task_id = iid WHERE iid = $task_id"; |
556 | 555 | Database::query($sql); |
557 | 556 | } |
558 | 557 | |
559 | - $tool = 'BLOG_' . $blog_id; |
|
558 | + $tool = 'BLOG_' . $blog_id; |
|
560 | 559 | |
561 | - if ($articleDelete == 'on') { |
|
562 | - $sql = " INSERT INTO " . $tbl_tasks_permissions . " ( c_id, task_id, tool, action) VALUES ( |
|
560 | + if ($articleDelete == 'on') { |
|
561 | + $sql = " INSERT INTO " . $tbl_tasks_permissions . " ( c_id, task_id, tool, action) VALUES ( |
|
563 | 562 | '" . (int)$course_id . "', |
564 | 563 | '" . (int)$task_id . "', |
565 | 564 | '" . Database::escape_string($tool) . "', |
566 | 565 | 'article_delete' |
567 | 566 | )"; |
568 | - Database::query($sql); |
|
567 | + Database::query($sql); |
|
569 | 568 | |
570 | 569 | $id = Database::insert_id(); |
571 | 570 | |
@@ -575,171 +574,171 @@ discard block |
||
575 | 574 | } |
576 | 575 | } |
577 | 576 | |
578 | - if ($articleEdit == 'on') { |
|
579 | - $sql = " |
|
577 | + if ($articleEdit == 'on') { |
|
578 | + $sql = " |
|
580 | 579 | INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action ) VALUES ( |
581 | 580 | '" . (int)$course_id . "', |
582 | 581 | '" . (int)$task_id . "', |
583 | 582 | '" . Database::escape_string($tool) . "', |
584 | 583 | 'article_edit' |
585 | 584 | )"; |
586 | - Database::query($sql); |
|
585 | + Database::query($sql); |
|
587 | 586 | $id = Database::insert_id(); |
588 | 587 | |
589 | 588 | if ($id) { |
590 | 589 | $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id"; |
591 | 590 | Database::query($sql); |
592 | 591 | } |
593 | - } |
|
592 | + } |
|
594 | 593 | |
595 | - if ($commentsDelete == 'on') { |
|
596 | - $sql = " |
|
594 | + if ($commentsDelete == 'on') { |
|
595 | + $sql = " |
|
597 | 596 | INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action ) VALUES ( |
598 | 597 | '" . (int)$course_id . "', |
599 | 598 | '" . (int)$task_id . "', |
600 | 599 | '" . Database::escape_string($tool) . "', |
601 | 600 | 'article_comments_delete' |
602 | 601 | )"; |
603 | - Database::query($sql); |
|
602 | + Database::query($sql); |
|
604 | 603 | $id = Database::insert_id(); |
605 | 604 | |
606 | 605 | if ($id) { |
607 | 606 | $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id"; |
608 | 607 | Database::query($sql); |
609 | 608 | } |
610 | - } |
|
611 | - } |
|
612 | - |
|
613 | - /** |
|
614 | - * Edit a task in a blog |
|
615 | - * @author Toon Keppens |
|
616 | - * @param Integer $task_id |
|
617 | - * @param String $title |
|
618 | - * @param String $description |
|
619 | - * @param String $color |
|
620 | - */ |
|
621 | - public static function edit_task($blog_id, $task_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color) |
|
622 | - { |
|
623 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
624 | - $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
609 | + } |
|
610 | + } |
|
611 | + |
|
612 | + /** |
|
613 | + * Edit a task in a blog |
|
614 | + * @author Toon Keppens |
|
615 | + * @param Integer $task_id |
|
616 | + * @param String $title |
|
617 | + * @param String $description |
|
618 | + * @param String $color |
|
619 | + */ |
|
620 | + public static function edit_task($blog_id, $task_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color) |
|
621 | + { |
|
622 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
623 | + $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
625 | 624 | |
626 | 625 | $course_id = api_get_course_int_id(); |
627 | 626 | |
628 | - // Create the task |
|
629 | - $sql = "UPDATE $tbl_blogs_tasks SET |
|
627 | + // Create the task |
|
628 | + $sql = "UPDATE $tbl_blogs_tasks SET |
|
630 | 629 | title = '".Database::escape_string($title)."', |
631 | 630 | description = '".Database::escape_string($description)."', |
632 | 631 | color = '".Database::escape_string($color)."' |
633 | 632 | WHERE c_id = $course_id AND task_id ='".(int)$task_id."' LIMIT 1"; |
634 | - Database::query($sql); |
|
633 | + Database::query($sql); |
|
635 | 634 | |
636 | - $tool = 'BLOG_' . $blog_id; |
|
635 | + $tool = 'BLOG_' . $blog_id; |
|
637 | 636 | |
638 | - $sql = "DELETE FROM " . $tbl_tasks_permissions . " |
|
637 | + $sql = "DELETE FROM " . $tbl_tasks_permissions . " |
|
639 | 638 | WHERE c_id = $course_id AND task_id = '" . (int)$task_id."'"; |
640 | - Database::query($sql); |
|
639 | + Database::query($sql); |
|
641 | 640 | |
642 | - if ($articleDelete == 'on') { |
|
643 | - $sql = "INSERT INTO " . $tbl_tasks_permissions . " ( c_id, task_id, tool, action) VALUES ( |
|
641 | + if ($articleDelete == 'on') { |
|
642 | + $sql = "INSERT INTO " . $tbl_tasks_permissions . " ( c_id, task_id, tool, action) VALUES ( |
|
644 | 643 | '" . (int)$course_id . "', |
645 | 644 | '" . (int)$task_id . "', |
646 | 645 | '" . Database::escape_string($tool) . "', |
647 | 646 | 'article_delete' |
648 | 647 | )"; |
649 | - Database::query($sql); |
|
648 | + Database::query($sql); |
|
650 | 649 | $id = Database::insert_id(); |
651 | 650 | |
652 | 651 | if ($id) { |
653 | 652 | $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id"; |
654 | 653 | Database::query($sql); |
655 | 654 | } |
656 | - } |
|
655 | + } |
|
657 | 656 | |
658 | - if ($articleEdit == 'on') { |
|
659 | - $sql = "INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES ( |
|
657 | + if ($articleEdit == 'on') { |
|
658 | + $sql = "INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES ( |
|
660 | 659 | '" . (int)$course_id . "', |
661 | 660 | '" . (int)$task_id . "', |
662 | 661 | '" . Database::escape_string($tool) . "', |
663 | 662 | 'article_edit' |
664 | 663 | )"; |
665 | - Database::query($sql); |
|
664 | + Database::query($sql); |
|
666 | 665 | $id = Database::insert_id(); |
667 | 666 | |
668 | 667 | if ($id) { |
669 | 668 | $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id"; |
670 | 669 | Database::query($sql); |
671 | 670 | } |
672 | - } |
|
671 | + } |
|
673 | 672 | |
674 | - if ($commentsDelete == 'on') { |
|
675 | - $sql = " INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES ( |
|
673 | + if ($commentsDelete == 'on') { |
|
674 | + $sql = " INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES ( |
|
676 | 675 | '" . (int)$course_id . "', |
677 | 676 | '" . (int)$task_id . "', |
678 | 677 | '" . Database::escape_string($tool) . "', |
679 | 678 | 'article_comments_delete' |
680 | 679 | )"; |
681 | - Database::query($sql); |
|
680 | + Database::query($sql); |
|
682 | 681 | $id = Database::insert_id(); |
683 | 682 | |
684 | 683 | if ($id) { |
685 | 684 | $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id"; |
686 | 685 | Database::query($sql); |
687 | 686 | } |
688 | - } |
|
689 | - } |
|
690 | - |
|
691 | - /** |
|
692 | - * Deletes a task from a blog |
|
693 | - * @param Integer $blog_id |
|
694 | - * @param Integer $task_id |
|
695 | - */ |
|
696 | - public static function delete_task($blog_id, $task_id) |
|
697 | - { |
|
698 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
699 | - $course_id = api_get_course_int_id(); |
|
700 | - |
|
701 | - // Delete posts |
|
702 | - $sql = "DELETE FROM $tbl_blogs_tasks |
|
687 | + } |
|
688 | + } |
|
689 | + |
|
690 | + /** |
|
691 | + * Deletes a task from a blog |
|
692 | + * @param Integer $blog_id |
|
693 | + * @param Integer $task_id |
|
694 | + */ |
|
695 | + public static function delete_task($blog_id, $task_id) |
|
696 | + { |
|
697 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
698 | + $course_id = api_get_course_int_id(); |
|
699 | + |
|
700 | + // Delete posts |
|
701 | + $sql = "DELETE FROM $tbl_blogs_tasks |
|
703 | 702 | WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND task_id = '".(int)$task_id."'"; |
704 | - Database::query($sql); |
|
705 | - } |
|
706 | - |
|
707 | - /** |
|
708 | - * Deletes an assigned task from a blog |
|
709 | - * @param Integer $blog_id |
|
710 | - */ |
|
711 | - public static function delete_assigned_task($blog_id, $task_id, $user_id) |
|
712 | - { |
|
713 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
703 | + Database::query($sql); |
|
704 | + } |
|
705 | + |
|
706 | + /** |
|
707 | + * Deletes an assigned task from a blog |
|
708 | + * @param Integer $blog_id |
|
709 | + */ |
|
710 | + public static function delete_assigned_task($blog_id, $task_id, $user_id) |
|
711 | + { |
|
712 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
714 | 713 | $course_id = api_get_course_int_id(); |
715 | 714 | |
716 | - // Delete posts |
|
717 | - $sql = "DELETE FROM $tbl_blogs_tasks_rel_user |
|
715 | + // Delete posts |
|
716 | + $sql = "DELETE FROM $tbl_blogs_tasks_rel_user |
|
718 | 717 | WHERE |
719 | 718 | c_id = $course_id AND |
720 | 719 | blog_id = '".(int)$blog_id."' AND |
721 | 720 | task_id = '".(int)$task_id."' AND |
722 | 721 | user_id = '".(int)$user_id."'"; |
723 | - Database::query($sql); |
|
724 | - } |
|
725 | - |
|
726 | - /** |
|
727 | - * Get personal task list |
|
728 | - * @author Toon Keppens |
|
729 | - * @return Returns an unsorted list (<ul></ul>) with the users' tasks |
|
730 | - */ |
|
731 | - public static function get_personal_task_list() |
|
732 | - { |
|
733 | - $_user = api_get_user_info(); |
|
734 | - |
|
735 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
736 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
737 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
738 | - |
|
739 | - $course_id = api_get_course_int_id(); |
|
740 | - |
|
741 | - if ($_user['user_id']) { |
|
742 | - $sql = "SELECT task_rel_user.*, task.title, blog.blog_name |
|
722 | + Database::query($sql); |
|
723 | + } |
|
724 | + |
|
725 | + /** |
|
726 | + * Get personal task list |
|
727 | + * @author Toon Keppens |
|
728 | + * @return Returns an unsorted list (<ul></ul>) with the users' tasks |
|
729 | + */ |
|
730 | + public static function get_personal_task_list() |
|
731 | + { |
|
732 | + $_user = api_get_user_info(); |
|
733 | + |
|
734 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
735 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
736 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
737 | + |
|
738 | + $course_id = api_get_course_int_id(); |
|
739 | + |
|
740 | + if ($_user['user_id']) { |
|
741 | + $sql = "SELECT task_rel_user.*, task.title, blog.blog_name |
|
743 | 742 | FROM $tbl_blogs_tasks_rel_user task_rel_user |
744 | 743 | INNER JOIN $tbl_blogs_tasks task |
745 | 744 | ON task_rel_user.task_id = task.task_id |
@@ -753,85 +752,85 @@ discard block |
||
753 | 752 | task_rel_user.user_id = ".(int)$_user['user_id']." |
754 | 753 | ORDER BY target_date ASC"; |
755 | 754 | |
756 | - $result = Database::query($sql); |
|
757 | - |
|
758 | - if (Database::num_rows($result) > 0) { |
|
759 | - echo '<ul>'; |
|
760 | - while ($mytask = Database::fetch_array($result)) { |
|
761 | - echo '<li><a href="blog.php?action=execute_task&blog_id=' . $mytask['blog_id'] . '&task_id='.stripslashes($mytask['task_id']) . '" title="[Blog: '.stripslashes($mytask['blog_name']) . '] ' . get_lang('ExecuteThisTask') . '">'.stripslashes($mytask['title']) . '</a></li>'; |
|
762 | - } |
|
763 | - echo '<ul>'; |
|
764 | - } else { |
|
765 | - echo get_lang('NoTasks'); |
|
766 | - } |
|
767 | - } else { |
|
768 | - echo get_lang('NoTasks'); |
|
769 | - } |
|
770 | - } |
|
771 | - |
|
772 | - /** |
|
773 | - * Changes the visibility of a blog |
|
774 | - * @author Toon Keppens |
|
775 | - * @param Integer $blog_id |
|
776 | - */ |
|
777 | - public static function change_blog_visibility($blog_id) |
|
778 | - { |
|
779 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
780 | - $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST); |
|
781 | - $course_id = api_get_course_int_id(); |
|
782 | - |
|
783 | - // Get blog properties |
|
784 | - $sql = "SELECT blog_name, visibility FROM $tbl_blogs |
|
755 | + $result = Database::query($sql); |
|
756 | + |
|
757 | + if (Database::num_rows($result) > 0) { |
|
758 | + echo '<ul>'; |
|
759 | + while ($mytask = Database::fetch_array($result)) { |
|
760 | + echo '<li><a href="blog.php?action=execute_task&blog_id=' . $mytask['blog_id'] . '&task_id='.stripslashes($mytask['task_id']) . '" title="[Blog: '.stripslashes($mytask['blog_name']) . '] ' . get_lang('ExecuteThisTask') . '">'.stripslashes($mytask['title']) . '</a></li>'; |
|
761 | + } |
|
762 | + echo '<ul>'; |
|
763 | + } else { |
|
764 | + echo get_lang('NoTasks'); |
|
765 | + } |
|
766 | + } else { |
|
767 | + echo get_lang('NoTasks'); |
|
768 | + } |
|
769 | + } |
|
770 | + |
|
771 | + /** |
|
772 | + * Changes the visibility of a blog |
|
773 | + * @author Toon Keppens |
|
774 | + * @param Integer $blog_id |
|
775 | + */ |
|
776 | + public static function change_blog_visibility($blog_id) |
|
777 | + { |
|
778 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
779 | + $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST); |
|
780 | + $course_id = api_get_course_int_id(); |
|
781 | + |
|
782 | + // Get blog properties |
|
783 | + $sql = "SELECT blog_name, visibility FROM $tbl_blogs |
|
785 | 784 | WHERE c_id = $course_id AND blog_id='".(int)$blog_id."'"; |
786 | - $result = Database::query($sql); |
|
787 | - $blog = Database::fetch_array($result); |
|
788 | - $visibility = $blog['visibility']; |
|
789 | - $title = $blog['blog_name']; |
|
790 | - |
|
791 | - if ($visibility == 1) { |
|
792 | - // Change visibility state, remove from course home. |
|
793 | - $sql = "UPDATE $tbl_blogs SET visibility = '0' |
|
785 | + $result = Database::query($sql); |
|
786 | + $blog = Database::fetch_array($result); |
|
787 | + $visibility = $blog['visibility']; |
|
788 | + $title = $blog['blog_name']; |
|
789 | + |
|
790 | + if ($visibility == 1) { |
|
791 | + // Change visibility state, remove from course home. |
|
792 | + $sql = "UPDATE $tbl_blogs SET visibility = '0' |
|
794 | 793 | WHERE c_id = $course_id AND blog_id ='".(int)$blog_id."' LIMIT 1"; |
795 | - Database::query($sql); |
|
794 | + Database::query($sql); |
|
796 | 795 | |
797 | - $sql = "DELETE FROM $tbl_tool |
|
796 | + $sql = "DELETE FROM $tbl_tool |
|
798 | 797 | WHERE c_id = $course_id AND name = '".Database::escape_string($title)."' LIMIT 1"; |
799 | - Database::query($sql); |
|
800 | - } else { |
|
801 | - // Change visibility state, add to course home. |
|
802 | - $sql = "UPDATE $tbl_blogs SET visibility = '1' |
|
798 | + Database::query($sql); |
|
799 | + } else { |
|
800 | + // Change visibility state, add to course home. |
|
801 | + $sql = "UPDATE $tbl_blogs SET visibility = '1' |
|
803 | 802 | WHERE c_id = $course_id AND blog_id ='".(int)$blog_id."' LIMIT 1"; |
804 | - Database::query($sql); |
|
803 | + Database::query($sql); |
|
805 | 804 | |
806 | - $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, target ) |
|
805 | + $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, target ) |
|
807 | 806 | VALUES ($course_id, '".Database::escape_string($title)."', 'blog/blog.php?blog_id=".(int)$blog_id."', 'blog.gif', '1', '0', 'pastillegris.gif', '0', '_self')"; |
808 | - Database::query($sql); |
|
807 | + Database::query($sql); |
|
809 | 808 | $id = Database::insert_id(); |
810 | 809 | |
811 | 810 | if ($id) { |
812 | 811 | $sql = "UPDATE $tbl_tool SET id = iid WHERE iid = $id"; |
813 | 812 | Database::query($sql); |
814 | 813 | } |
815 | - } |
|
816 | - } |
|
817 | - |
|
818 | - /** |
|
819 | - * Shows the posts of a blog |
|
820 | - * @author Toon Keppens |
|
821 | - * |
|
822 | - * @param Integer $blog_id |
|
823 | - */ |
|
824 | - public static function display_blog_posts($blog_id, $filter = '1=1', $max_number_of_posts = 20) |
|
814 | + } |
|
815 | + } |
|
816 | + |
|
817 | + /** |
|
818 | + * Shows the posts of a blog |
|
819 | + * @author Toon Keppens |
|
820 | + * |
|
821 | + * @param Integer $blog_id |
|
822 | + */ |
|
823 | + public static function display_blog_posts($blog_id, $filter = '1=1', $max_number_of_posts = 20) |
|
825 | 824 | { |
826 | - // Init |
|
827 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
828 | - $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
829 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
825 | + // Init |
|
826 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
827 | + $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
828 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
830 | 829 | |
831 | - $course_id = api_get_course_int_id(); |
|
830 | + $course_id = api_get_course_int_id(); |
|
832 | 831 | |
833 | - // Get posts and authors |
|
834 | - $sql = "SELECT post.*, user.lastname, user.firstname, user.username |
|
832 | + // Get posts and authors |
|
833 | + $sql = "SELECT post.*, user.lastname, user.firstname, user.username |
|
835 | 834 | FROM $tbl_blogs_posts post |
836 | 835 | INNER JOIN $tbl_users user |
837 | 836 | ON post.author_id = user.user_id |
@@ -839,131 +838,131 @@ discard block |
||
839 | 838 | post.c_id = $course_id AND |
840 | 839 | $filter |
841 | 840 | ORDER BY post_id DESC LIMIT 0,".(int)$max_number_of_posts; |
842 | - $result = Database::query($sql); |
|
843 | - |
|
844 | - // Display |
|
845 | - if(Database::num_rows($result) > 0) { |
|
846 | - $limit = 200; |
|
847 | - while ($blog_post = Database::fetch_array($result)) { |
|
848 | - // Get number of comments |
|
849 | - $sql = "SELECT COUNT(1) as number_of_comments |
|
841 | + $result = Database::query($sql); |
|
842 | + |
|
843 | + // Display |
|
844 | + if(Database::num_rows($result) > 0) { |
|
845 | + $limit = 200; |
|
846 | + while ($blog_post = Database::fetch_array($result)) { |
|
847 | + // Get number of comments |
|
848 | + $sql = "SELECT COUNT(1) as number_of_comments |
|
850 | 849 | FROM $tbl_blogs_comments |
851 | 850 | WHERE |
852 | 851 | c_id = $course_id AND |
853 | 852 | blog_id = '".(int)$blog_id."' AND |
854 | 853 | post_id = '" . (int)$blog_post['post_id']."'"; |
855 | - $tmp = Database::query($sql); |
|
856 | - $blog_post_comments = Database::fetch_array($tmp); |
|
857 | - |
|
858 | - // Prepare data |
|
859 | - $blog_post_id = $blog_post['post_id']; |
|
860 | - $blog_post_text = make_clickable(stripslashes($blog_post['full_text'])); |
|
861 | - $blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get()); |
|
862 | - |
|
863 | - // Create an introduction text (but keep FULL sentences) |
|
864 | - $words = 0; |
|
865 | - $blog_post_text_cut = cut($blog_post_text, $limit) ; |
|
866 | - $words = strlen($blog_post_text); |
|
867 | - |
|
868 | - if ($words >= $limit) { |
|
869 | - $readMoreLink = ' <div class="link" onclick="document.getElementById(\'blogpost_text_' . $blog_post_id . '\').style.display=\'block\'; document.getElementById(\'blogpost_introduction_' . $blog_post_id . '\').style.display=\'none\'">' . get_lang('ReadMore') . '</div>'; |
|
870 | - $introduction_text = $blog_post_text_cut; |
|
871 | - } else { |
|
872 | - $introduction_text = $blog_post_text; |
|
873 | - $readMoreLink = ''; |
|
874 | - } |
|
875 | - |
|
876 | - $introduction_text = stripslashes($introduction_text); |
|
877 | - |
|
878 | - echo '<div class="blogpost">'; |
|
879 | - echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >'.stripslashes($blog_post['title']) . '</a></span>'; |
|
880 | - echo '<span class="blogpost_date"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . $blog_post_date . '</a></span>'; |
|
881 | - echo '<div class="blogpost_introduction" id="blogpost_introduction_'.$blog_post_id.'">' . $introduction_text.$readMoreLink.'</div>'; |
|
882 | - echo '<div class="blogpost_text" id="blogpost_text_' . $blog_post_id . '" style="display: none">' . $blog_post_text . '</div>'; |
|
883 | - |
|
884 | - $file_name_array = get_blog_attachment($blog_id,$blog_post_id,0); |
|
885 | - |
|
886 | - if (!empty($file_name_array)) { |
|
887 | - echo '<br /><br />'; |
|
888 | - echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
889 | - echo '<a href="download.php?file='; |
|
890 | - echo $file_name_array['path']; |
|
891 | - echo ' "> '.$file_name_array['filename'].' </a><br />'; |
|
892 | - echo '</span>'; |
|
893 | - } |
|
894 | - $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES); |
|
895 | - echo '<span class="blogpost_info">' . get_lang('Author') . ': ' . Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)) .' - <a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . get_lang('Comments') . ': ' . $blog_post_comments['number_of_comments'] . '</a></span>'; |
|
896 | - echo '</div>'; |
|
897 | - } |
|
898 | - } else { |
|
899 | - if($filter == '1=1') { |
|
900 | - echo get_lang('NoArticles'); |
|
901 | - } else { |
|
902 | - echo get_lang('NoArticleMatches'); |
|
903 | - } |
|
904 | - } |
|
854 | + $tmp = Database::query($sql); |
|
855 | + $blog_post_comments = Database::fetch_array($tmp); |
|
856 | + |
|
857 | + // Prepare data |
|
858 | + $blog_post_id = $blog_post['post_id']; |
|
859 | + $blog_post_text = make_clickable(stripslashes($blog_post['full_text'])); |
|
860 | + $blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get()); |
|
861 | + |
|
862 | + // Create an introduction text (but keep FULL sentences) |
|
863 | + $words = 0; |
|
864 | + $blog_post_text_cut = cut($blog_post_text, $limit) ; |
|
865 | + $words = strlen($blog_post_text); |
|
866 | + |
|
867 | + if ($words >= $limit) { |
|
868 | + $readMoreLink = ' <div class="link" onclick="document.getElementById(\'blogpost_text_' . $blog_post_id . '\').style.display=\'block\'; document.getElementById(\'blogpost_introduction_' . $blog_post_id . '\').style.display=\'none\'">' . get_lang('ReadMore') . '</div>'; |
|
869 | + $introduction_text = $blog_post_text_cut; |
|
870 | + } else { |
|
871 | + $introduction_text = $blog_post_text; |
|
872 | + $readMoreLink = ''; |
|
873 | + } |
|
874 | + |
|
875 | + $introduction_text = stripslashes($introduction_text); |
|
876 | + |
|
877 | + echo '<div class="blogpost">'; |
|
878 | + echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >'.stripslashes($blog_post['title']) . '</a></span>'; |
|
879 | + echo '<span class="blogpost_date"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . $blog_post_date . '</a></span>'; |
|
880 | + echo '<div class="blogpost_introduction" id="blogpost_introduction_'.$blog_post_id.'">' . $introduction_text.$readMoreLink.'</div>'; |
|
881 | + echo '<div class="blogpost_text" id="blogpost_text_' . $blog_post_id . '" style="display: none">' . $blog_post_text . '</div>'; |
|
882 | + |
|
883 | + $file_name_array = get_blog_attachment($blog_id,$blog_post_id,0); |
|
884 | + |
|
885 | + if (!empty($file_name_array)) { |
|
886 | + echo '<br /><br />'; |
|
887 | + echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
888 | + echo '<a href="download.php?file='; |
|
889 | + echo $file_name_array['path']; |
|
890 | + echo ' "> '.$file_name_array['filename'].' </a><br />'; |
|
891 | + echo '</span>'; |
|
892 | + } |
|
893 | + $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES); |
|
894 | + echo '<span class="blogpost_info">' . get_lang('Author') . ': ' . Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)) .' - <a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . get_lang('Comments') . ': ' . $blog_post_comments['number_of_comments'] . '</a></span>'; |
|
895 | + echo '</div>'; |
|
896 | + } |
|
897 | + } else { |
|
898 | + if($filter == '1=1') { |
|
899 | + echo get_lang('NoArticles'); |
|
900 | + } else { |
|
901 | + echo get_lang('NoArticleMatches'); |
|
902 | + } |
|
903 | + } |
|
905 | 904 | } |
906 | 905 | |
907 | - /** |
|
908 | - * Display the search results |
|
909 | - * |
|
910 | - * @param Integer $blog_id |
|
911 | - * @param String $query_string |
|
912 | - */ |
|
913 | - public static function display_search_results ($blog_id, $query_string) |
|
914 | - { |
|
915 | - // Init |
|
916 | - $query_string = Database::escape_string($query_string); |
|
917 | - $query_string_parts = explode(' ',$query_string); |
|
918 | - $query_string = array(); |
|
919 | - foreach ($query_string_parts as $query_part) { |
|
920 | - $query_string[] = " full_text LIKE '%" . $query_part."%' OR title LIKE '%" . $query_part."%' "; |
|
921 | - } |
|
922 | - $query_string = '('.implode('OR',$query_string) . ')'; |
|
923 | - |
|
924 | - // Display the posts |
|
925 | - echo '<span class="blogpost_title">' . get_lang('SearchResults') . '</span>'; |
|
926 | - Blog::display_blog_posts($blog_id, $query_string); |
|
927 | - } |
|
928 | - |
|
929 | - /** |
|
930 | - * Display posts from a certain date |
|
931 | - * |
|
932 | - * @param Integer $blog_id |
|
933 | - * @param String $query_string |
|
934 | - */ |
|
935 | - public static function display_day_results($blog_id, $query_string) |
|
936 | - { |
|
937 | - $date_output = $query_string; |
|
938 | - $date = explode('-',$query_string); |
|
939 | - $query_string = ' DAYOFMONTH(date_creation) =' . intval($date[2]) . ' AND MONTH(date_creation) =' . intval($date[1]) . ' AND YEAR(date_creation) =' . intval($date[0]); |
|
940 | - |
|
941 | - // Put date in correct output format |
|
942 | - $date_output = api_format_date($date_output, DATE_FORMAT_LONG); |
|
943 | - |
|
944 | - // Display the posts |
|
945 | - echo '<span class="blogpost_title">' . get_lang('PostsOf') . ': ' . $date_output . '</span>'; |
|
946 | - Blog::display_blog_posts($blog_id, $query_string); |
|
947 | - } |
|
948 | - |
|
949 | - /** |
|
950 | - * Displays a post and his comments |
|
951 | - * |
|
952 | - * @param Integer $blog_id |
|
953 | - * @param Integer $post_id |
|
954 | - */ |
|
955 | - public static function display_post($blog_id, $post_id) |
|
956 | - { |
|
957 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
958 | - $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
959 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
960 | - |
|
961 | - global $charset, $dateFormatLong; |
|
962 | - |
|
963 | - $course_id = api_get_course_int_id(); |
|
964 | - |
|
965 | - // Get posts and author |
|
966 | - $sql = "SELECT post.*, user.lastname, user.firstname, user.username |
|
906 | + /** |
|
907 | + * Display the search results |
|
908 | + * |
|
909 | + * @param Integer $blog_id |
|
910 | + * @param String $query_string |
|
911 | + */ |
|
912 | + public static function display_search_results ($blog_id, $query_string) |
|
913 | + { |
|
914 | + // Init |
|
915 | + $query_string = Database::escape_string($query_string); |
|
916 | + $query_string_parts = explode(' ',$query_string); |
|
917 | + $query_string = array(); |
|
918 | + foreach ($query_string_parts as $query_part) { |
|
919 | + $query_string[] = " full_text LIKE '%" . $query_part."%' OR title LIKE '%" . $query_part."%' "; |
|
920 | + } |
|
921 | + $query_string = '('.implode('OR',$query_string) . ')'; |
|
922 | + |
|
923 | + // Display the posts |
|
924 | + echo '<span class="blogpost_title">' . get_lang('SearchResults') . '</span>'; |
|
925 | + Blog::display_blog_posts($blog_id, $query_string); |
|
926 | + } |
|
927 | + |
|
928 | + /** |
|
929 | + * Display posts from a certain date |
|
930 | + * |
|
931 | + * @param Integer $blog_id |
|
932 | + * @param String $query_string |
|
933 | + */ |
|
934 | + public static function display_day_results($blog_id, $query_string) |
|
935 | + { |
|
936 | + $date_output = $query_string; |
|
937 | + $date = explode('-',$query_string); |
|
938 | + $query_string = ' DAYOFMONTH(date_creation) =' . intval($date[2]) . ' AND MONTH(date_creation) =' . intval($date[1]) . ' AND YEAR(date_creation) =' . intval($date[0]); |
|
939 | + |
|
940 | + // Put date in correct output format |
|
941 | + $date_output = api_format_date($date_output, DATE_FORMAT_LONG); |
|
942 | + |
|
943 | + // Display the posts |
|
944 | + echo '<span class="blogpost_title">' . get_lang('PostsOf') . ': ' . $date_output . '</span>'; |
|
945 | + Blog::display_blog_posts($blog_id, $query_string); |
|
946 | + } |
|
947 | + |
|
948 | + /** |
|
949 | + * Displays a post and his comments |
|
950 | + * |
|
951 | + * @param Integer $blog_id |
|
952 | + * @param Integer $post_id |
|
953 | + */ |
|
954 | + public static function display_post($blog_id, $post_id) |
|
955 | + { |
|
956 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
957 | + $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
958 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
959 | + |
|
960 | + global $charset, $dateFormatLong; |
|
961 | + |
|
962 | + $course_id = api_get_course_int_id(); |
|
963 | + |
|
964 | + // Get posts and author |
|
965 | + $sql = "SELECT post.*, user.lastname, user.firstname, user.username |
|
967 | 966 | FROM $tbl_blogs_posts post |
968 | 967 | INNER JOIN $tbl_users user |
969 | 968 | ON post.author_id = user.user_id |
@@ -972,113 +971,113 @@ discard block |
||
972 | 971 | post.blog_id = '".(int)$blog_id."' AND |
973 | 972 | post.post_id = '".(int)$post_id."' |
974 | 973 | ORDER BY post_id DESC"; |
975 | - $result = Database::query($sql); |
|
976 | - $blog_post = Database::fetch_array($result); |
|
974 | + $result = Database::query($sql); |
|
975 | + $blog_post = Database::fetch_array($result); |
|
977 | 976 | |
978 | - // Get number of comments |
|
979 | - $sql = "SELECT COUNT(1) as number_of_comments |
|
977 | + // Get number of comments |
|
978 | + $sql = "SELECT COUNT(1) as number_of_comments |
|
980 | 979 | FROM $tbl_blogs_comments |
981 | 980 | WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND post_id = '".(int)$post_id."'"; |
982 | - $result = Database::query($sql); |
|
983 | - $blog_post_comments = Database::fetch_array($result); |
|
981 | + $result = Database::query($sql); |
|
982 | + $blog_post_comments = Database::fetch_array($result); |
|
984 | 983 | |
985 | - // Prepare data |
|
986 | - $blog_post_text = make_clickable(stripslashes($blog_post['full_text'])); |
|
987 | - $blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get()); |
|
988 | - $blog_post_actions = ""; |
|
984 | + // Prepare data |
|
985 | + $blog_post_text = make_clickable(stripslashes($blog_post['full_text'])); |
|
986 | + $blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get()); |
|
987 | + $blog_post_actions = ""; |
|
989 | 988 | |
990 | - $task_id = (isset($_GET['task_id']) && is_numeric($_GET['task_id'])) ? intval($_GET['task_id']) : 0; |
|
989 | + $task_id = (isset($_GET['task_id']) && is_numeric($_GET['task_id'])) ? intval($_GET['task_id']) : 0; |
|
991 | 990 | |
992 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_edit', $task_id)) { |
|
993 | - $blog_post_actions .= '<a href="blog.php?action=edit_post&blog_id=' . $blog_id . '&post_id=' . $post_id . '&article_id=' . $blog_post['post_id'] . '&task_id=' . $task_id . '" title="' . get_lang('EditThisPost') . '">'; |
|
994 | - $blog_post_actions .= Display::return_icon('edit.png'); |
|
995 | - $blog_post_actions .= '</a>'; |
|
991 | + if (api_is_allowed('BLOG_' . $blog_id, 'article_edit', $task_id)) { |
|
992 | + $blog_post_actions .= '<a href="blog.php?action=edit_post&blog_id=' . $blog_id . '&post_id=' . $post_id . '&article_id=' . $blog_post['post_id'] . '&task_id=' . $task_id . '" title="' . get_lang('EditThisPost') . '">'; |
|
993 | + $blog_post_actions .= Display::return_icon('edit.png'); |
|
994 | + $blog_post_actions .= '</a>'; |
|
996 | 995 | } |
997 | 996 | |
998 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_delete', $task_id)) { |
|
999 | - $blog_post_actions .= '<a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $post_id . '&do=delete_article&article_id=' . $blog_post['post_id'] . '&task_id=' . $task_id . '" title="' . get_lang('DeleteThisArticle') . '" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;">'; |
|
997 | + if (api_is_allowed('BLOG_' . $blog_id, 'article_delete', $task_id)) { |
|
998 | + $blog_post_actions .= '<a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $post_id . '&do=delete_article&article_id=' . $blog_post['post_id'] . '&task_id=' . $task_id . '" title="' . get_lang('DeleteThisArticle') . '" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;">'; |
|
1000 | 999 | $blog_post_actions .= Display::return_icon('delete.png'); |
1001 | 1000 | $blog_post_actions .= '</a>'; |
1002 | 1001 | } |
1003 | 1002 | |
1004 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_rate')) |
|
1005 | - $rating_select = Blog::display_rating_form('post',$blog_id,$post_id); |
|
1003 | + if (api_is_allowed('BLOG_' . $blog_id, 'article_rate')) |
|
1004 | + $rating_select = Blog::display_rating_form('post',$blog_id,$post_id); |
|
1006 | 1005 | |
1007 | - $blog_post_text=stripslashes($blog_post_text); |
|
1006 | + $blog_post_text=stripslashes($blog_post_text); |
|
1008 | 1007 | |
1009 | - // Display post |
|
1010 | - echo '<div class="blogpost">'; |
|
1011 | - echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '" title="' . get_lang('ReadPost') . '" >'.stripslashes($blog_post['title']) . '</a></span>'; |
|
1012 | - echo '<span class="blogpost_date">' . $blog_post_date . '</span>'; |
|
1013 | - echo '<span class="blogpost_text">' . $blog_post_text . '</span><br />'; |
|
1008 | + // Display post |
|
1009 | + echo '<div class="blogpost">'; |
|
1010 | + echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '" title="' . get_lang('ReadPost') . '" >'.stripslashes($blog_post['title']) . '</a></span>'; |
|
1011 | + echo '<span class="blogpost_date">' . $blog_post_date . '</span>'; |
|
1012 | + echo '<span class="blogpost_text">' . $blog_post_text . '</span><br />'; |
|
1014 | 1013 | |
1015 | - $file_name_array = get_blog_attachment($blog_id, $post_id); |
|
1014 | + $file_name_array = get_blog_attachment($blog_id, $post_id); |
|
1016 | 1015 | |
1017 | 1016 | if (!empty($file_name_array)) { |
1018 | - echo ' <br />'; |
|
1019 | - echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
1020 | - echo '<a href="download.php?file='; |
|
1021 | - echo $file_name_array['path']; |
|
1022 | - echo ' "> '.$file_name_array['filename'].' </a>'; |
|
1023 | - echo '</span>'; |
|
1024 | - echo '<span class="attachment_comment">'; |
|
1025 | - echo $file_name_array['comment']; |
|
1026 | - echo '</span>'; |
|
1027 | - echo '<br />'; |
|
1028 | - } |
|
1017 | + echo ' <br />'; |
|
1018 | + echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
1019 | + echo '<a href="download.php?file='; |
|
1020 | + echo $file_name_array['path']; |
|
1021 | + echo ' "> '.$file_name_array['filename'].' </a>'; |
|
1022 | + echo '</span>'; |
|
1023 | + echo '<span class="attachment_comment">'; |
|
1024 | + echo $file_name_array['comment']; |
|
1025 | + echo '</span>'; |
|
1026 | + echo '<br />'; |
|
1027 | + } |
|
1029 | 1028 | $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES); |
1030 | - echo '<span class="blogpost_info">'.get_lang('Author').': ' .Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)).' - '.get_lang('Comments').': '.$blog_post_comments['number_of_comments'].' - '.get_lang('Rating').': '.Blog::display_rating('post',$blog_id,$post_id).$rating_select.'</span>'; |
|
1031 | - echo '<span class="blogpost_actions">' . $blog_post_actions . '</span>'; |
|
1032 | - echo '</div>'; |
|
1033 | - |
|
1034 | - // Display comments if there are any |
|
1035 | - if($blog_post_comments['number_of_comments'] > 0) { |
|
1036 | - echo '<div class="comments">'; |
|
1037 | - echo '<span class="blogpost_title">' . get_lang('Comments') . '</span><br />'; |
|
1038 | - Blog::get_threaded_comments(0, 0, $blog_id, $post_id, $task_id); |
|
1039 | - echo '</div>'; |
|
1040 | - } |
|
1041 | - |
|
1042 | - // Display comment form |
|
1043 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_comments_add')) { |
|
1044 | - Blog::display_new_comment_form($blog_id, $post_id, $blog_post['title']); |
|
1045 | - } |
|
1046 | - } |
|
1047 | - |
|
1048 | - /** |
|
1049 | - * Adds rating to a certain post or comment |
|
1050 | - * @author Toon Keppens |
|
1051 | - * |
|
1052 | - * @param String $type |
|
1053 | - * @param Integer $blog_id |
|
1054 | - * @param Integer $item_id |
|
1055 | - * @param Integer $rating |
|
1056 | - * |
|
1057 | - * @return Boolean success |
|
1058 | - */ |
|
1059 | - public static function add_rating($type, $blog_id, $item_id, $rating) |
|
1060 | - { |
|
1061 | - $_user = api_get_user_info(); |
|
1062 | - |
|
1063 | - // Init |
|
1064 | - $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
1065 | - $course_id = api_get_course_int_id(); |
|
1066 | - |
|
1067 | - // Check if the user has already rated this post/comment |
|
1068 | - $sql = "SELECT rating_id FROM $tbl_blogs_rating |
|
1029 | + echo '<span class="blogpost_info">'.get_lang('Author').': ' .Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)).' - '.get_lang('Comments').': '.$blog_post_comments['number_of_comments'].' - '.get_lang('Rating').': '.Blog::display_rating('post',$blog_id,$post_id).$rating_select.'</span>'; |
|
1030 | + echo '<span class="blogpost_actions">' . $blog_post_actions . '</span>'; |
|
1031 | + echo '</div>'; |
|
1032 | + |
|
1033 | + // Display comments if there are any |
|
1034 | + if($blog_post_comments['number_of_comments'] > 0) { |
|
1035 | + echo '<div class="comments">'; |
|
1036 | + echo '<span class="blogpost_title">' . get_lang('Comments') . '</span><br />'; |
|
1037 | + Blog::get_threaded_comments(0, 0, $blog_id, $post_id, $task_id); |
|
1038 | + echo '</div>'; |
|
1039 | + } |
|
1040 | + |
|
1041 | + // Display comment form |
|
1042 | + if (api_is_allowed('BLOG_' . $blog_id, 'article_comments_add')) { |
|
1043 | + Blog::display_new_comment_form($blog_id, $post_id, $blog_post['title']); |
|
1044 | + } |
|
1045 | + } |
|
1046 | + |
|
1047 | + /** |
|
1048 | + * Adds rating to a certain post or comment |
|
1049 | + * @author Toon Keppens |
|
1050 | + * |
|
1051 | + * @param String $type |
|
1052 | + * @param Integer $blog_id |
|
1053 | + * @param Integer $item_id |
|
1054 | + * @param Integer $rating |
|
1055 | + * |
|
1056 | + * @return Boolean success |
|
1057 | + */ |
|
1058 | + public static function add_rating($type, $blog_id, $item_id, $rating) |
|
1059 | + { |
|
1060 | + $_user = api_get_user_info(); |
|
1061 | + |
|
1062 | + // Init |
|
1063 | + $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
1064 | + $course_id = api_get_course_int_id(); |
|
1065 | + |
|
1066 | + // Check if the user has already rated this post/comment |
|
1067 | + $sql = "SELECT rating_id FROM $tbl_blogs_rating |
|
1069 | 1068 | WHERE |
1070 | 1069 | c_id = $course_id AND |
1071 | 1070 | blog_id = '".(int)$blog_id."' AND |
1072 | 1071 | item_id = '".(int)$item_id."' AND |
1073 | 1072 | rating_type = '".Database::escape_string($type)."' AND |
1074 | 1073 | user_id = '".(int)$_user['user_id']."'"; |
1075 | - $result = Database::query($sql); |
|
1074 | + $result = Database::query($sql); |
|
1076 | 1075 | |
1077 | 1076 | // Add rating |
1078 | - if (Database::num_rows($result) == 0) { |
|
1079 | - $sql = "INSERT INTO $tbl_blogs_rating (c_id, blog_id, rating_type, item_id, user_id, rating ) |
|
1077 | + if (Database::num_rows($result) == 0) { |
|
1078 | + $sql = "INSERT INTO $tbl_blogs_rating (c_id, blog_id, rating_type, item_id, user_id, rating ) |
|
1080 | 1079 | VALUES ($course_id, '".(int)$blog_id."', '".Database::escape_string($type)."', '".(int)$item_id."', '".(int)$_user['user_id']."', '".Database::escape_string($rating)."')"; |
1081 | - Database::query($sql); |
|
1080 | + Database::query($sql); |
|
1082 | 1081 | |
1083 | 1082 | $id = Database::insert_id(); |
1084 | 1083 | if ($id) { |
@@ -1086,103 +1085,103 @@ discard block |
||
1086 | 1085 | Database::query($sql); |
1087 | 1086 | } |
1088 | 1087 | |
1089 | - return true; |
|
1088 | + return true; |
|
1090 | 1089 | } else { |
1091 | - return false; |
|
1092 | - } |
|
1093 | - } |
|
1094 | - |
|
1095 | - /** |
|
1096 | - * Shows the rating of user |
|
1097 | - * @param String $type |
|
1098 | - * @param Integer $blog_id |
|
1099 | - * @param Integer $item_id |
|
1100 | - * @return array |
|
1101 | - */ |
|
1102 | - public static function display_rating($type, $blog_id, $item_id) |
|
1103 | - { |
|
1104 | - $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
1105 | - $course_id = api_get_course_int_id(); |
|
1106 | - |
|
1107 | - // Calculate rating |
|
1108 | - $sql = "SELECT AVG(rating) as rating FROM $tbl_blogs_rating |
|
1090 | + return false; |
|
1091 | + } |
|
1092 | + } |
|
1093 | + |
|
1094 | + /** |
|
1095 | + * Shows the rating of user |
|
1096 | + * @param String $type |
|
1097 | + * @param Integer $blog_id |
|
1098 | + * @param Integer $item_id |
|
1099 | + * @return array |
|
1100 | + */ |
|
1101 | + public static function display_rating($type, $blog_id, $item_id) |
|
1102 | + { |
|
1103 | + $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
1104 | + $course_id = api_get_course_int_id(); |
|
1105 | + |
|
1106 | + // Calculate rating |
|
1107 | + $sql = "SELECT AVG(rating) as rating FROM $tbl_blogs_rating |
|
1109 | 1108 | WHERE |
1110 | 1109 | c_id = $course_id AND |
1111 | 1110 | blog_id = '".(int)$blog_id."' AND |
1112 | 1111 | item_id = '".(int)$item_id."' AND |
1113 | 1112 | rating_type = '".Database::escape_string($type)."' "; |
1114 | - $result = Database::query($sql); |
|
1115 | - $result = Database::fetch_array($result); |
|
1116 | - return round($result['rating'], 2); |
|
1117 | - } |
|
1118 | - |
|
1119 | - /** |
|
1120 | - * Shows the rating form if not already rated by that user |
|
1121 | - * @author Toon Keppens |
|
1122 | - * |
|
1123 | - * @param String $type |
|
1124 | - * @param Integer $blog_id |
|
1125 | - * @param integer $post_id |
|
1126 | - */ |
|
1127 | - public static function display_rating_form ($type, $blog_id, $post_id, $comment_id = NULL) |
|
1128 | - { |
|
1129 | - $_user = api_get_user_info(); |
|
1130 | - $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
1113 | + $result = Database::query($sql); |
|
1114 | + $result = Database::fetch_array($result); |
|
1115 | + return round($result['rating'], 2); |
|
1116 | + } |
|
1117 | + |
|
1118 | + /** |
|
1119 | + * Shows the rating form if not already rated by that user |
|
1120 | + * @author Toon Keppens |
|
1121 | + * |
|
1122 | + * @param String $type |
|
1123 | + * @param Integer $blog_id |
|
1124 | + * @param integer $post_id |
|
1125 | + */ |
|
1126 | + public static function display_rating_form ($type, $blog_id, $post_id, $comment_id = NULL) |
|
1127 | + { |
|
1128 | + $_user = api_get_user_info(); |
|
1129 | + $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING); |
|
1131 | 1130 | $course_id = api_get_course_int_id(); |
1132 | 1131 | |
1133 | 1132 | if ($type == 'post') { |
1134 | - // Check if the user has already rated this post |
|
1135 | - $sql = "SELECT rating_id FROM $tbl_blogs_rating |
|
1133 | + // Check if the user has already rated this post |
|
1134 | + $sql = "SELECT rating_id FROM $tbl_blogs_rating |
|
1136 | 1135 | WHERE c_id = $course_id AND |
1137 | 1136 | blog_id = '".(int)$blog_id."' |
1138 | 1137 | AND item_id = '".(int)$post_id."' |
1139 | 1138 | AND rating_type = '".Database::escape_string($type)."' |
1140 | 1139 | AND user_id = '".(int)$_user['user_id']."'"; |
1141 | - $result = Database::query($sql); |
|
1140 | + $result = Database::query($sql); |
|
1142 | 1141 | // Add rating |
1143 | 1142 | if (Database::num_rows($result) == 0) { |
1144 | - return ' - ' . get_lang('RateThis') . ': <form method="get" action="blog.php" style="display: inline" id="frm_rating_' . $type . '_' . $post_id . '" name="frm_rating_' . $type . '_' . $post_id . '"><select name="rating" onchange="document.forms[\'frm_rating_' . $type . '_' . $post_id . '\'].submit()"><option value="">-</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option></select><input type="hidden" name="action" value="view_post" /><input type="hidden" name="type" value="' . $type . '" /><input type="hidden" name="do" value="rate" /><input type="hidden" name="blog_id" value="' . $blog_id . '" /><input type="hidden" name="post_id" value="' . $post_id . '" /></form>'; |
|
1143 | + return ' - ' . get_lang('RateThis') . ': <form method="get" action="blog.php" style="display: inline" id="frm_rating_' . $type . '_' . $post_id . '" name="frm_rating_' . $type . '_' . $post_id . '"><select name="rating" onchange="document.forms[\'frm_rating_' . $type . '_' . $post_id . '\'].submit()"><option value="">-</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option></select><input type="hidden" name="action" value="view_post" /><input type="hidden" name="type" value="' . $type . '" /><input type="hidden" name="do" value="rate" /><input type="hidden" name="blog_id" value="' . $blog_id . '" /><input type="hidden" name="post_id" value="' . $post_id . '" /></form>'; |
|
1145 | 1144 | } else { |
1146 | - return ''; |
|
1147 | - } |
|
1148 | - } |
|
1145 | + return ''; |
|
1146 | + } |
|
1147 | + } |
|
1149 | 1148 | |
1150 | 1149 | if ($type = 'comment') { |
1151 | - // Check if the user has already rated this comment |
|
1152 | - $sql = "SELECT rating_id FROM $tbl_blogs_rating |
|
1150 | + // Check if the user has already rated this comment |
|
1151 | + $sql = "SELECT rating_id FROM $tbl_blogs_rating |
|
1153 | 1152 | WHERE c_id = $course_id AND blog_id = '".(int)$blog_id ."' |
1154 | 1153 | AND item_id = '".(int)$comment_id."' |
1155 | 1154 | AND rating_type = '".Database::escape_string($type)."' |
1156 | 1155 | AND user_id = '".(int)$_user['user_id']."'"; |
1157 | - $result = Database::query($sql); |
|
1156 | + $result = Database::query($sql); |
|
1158 | 1157 | |
1159 | 1158 | if (Database::num_rows($result) == 0) { |
1160 | - return ' - ' . get_lang('RateThis') . ': <form method="get" action="blog.php" style="display: inline" id="frm_rating_' . $type . '_' . $comment_id . '" name="frm_rating_' . $type . '_' . $comment_id . '"><select name="rating" onchange="document.forms[\'frm_rating_' . $type . '_' . $comment_id . '\'].submit()"><option value="">-</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option></select><input type="hidden" name="action" value="view_post" /><input type="hidden" name="type" value="' . $type . '" /><input type="hidden" name="do" value="rate" /><input type="hidden" name="blog_id" value="' . $blog_id . '" /><input type="hidden" name="post_id" value="' . $post_id . '" /><input type="hidden" name="comment_id" value="' . $comment_id . '" /></form>'; |
|
1159 | + return ' - ' . get_lang('RateThis') . ': <form method="get" action="blog.php" style="display: inline" id="frm_rating_' . $type . '_' . $comment_id . '" name="frm_rating_' . $type . '_' . $comment_id . '"><select name="rating" onchange="document.forms[\'frm_rating_' . $type . '_' . $comment_id . '\'].submit()"><option value="">-</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option></select><input type="hidden" name="action" value="view_post" /><input type="hidden" name="type" value="' . $type . '" /><input type="hidden" name="do" value="rate" /><input type="hidden" name="blog_id" value="' . $blog_id . '" /><input type="hidden" name="post_id" value="' . $post_id . '" /><input type="hidden" name="comment_id" value="' . $comment_id . '" /></form>'; |
|
1161 | 1160 | } else { |
1162 | - return ''; |
|
1163 | - } |
|
1164 | - } |
|
1165 | - } |
|
1166 | - |
|
1167 | - /** |
|
1168 | - * This functions gets all replys to a post, threaded. |
|
1169 | - * |
|
1170 | - * @param Integer $current |
|
1171 | - * @param Integer $current_level |
|
1172 | - * @param Integer $blog_id |
|
1173 | - * @param Integer $post_id |
|
1174 | - */ |
|
1175 | - public static function get_threaded_comments($current = 0, $current_level = 0, $blog_id, $post_id, $task_id = 0) |
|
1176 | - { |
|
1177 | - $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
1178 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
1179 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1180 | - global $charset; |
|
1181 | - |
|
1182 | - $course_id = api_get_course_int_id(); |
|
1183 | - |
|
1184 | - // Select top level comments |
|
1185 | - $next_level = $current_level + 1; |
|
1161 | + return ''; |
|
1162 | + } |
|
1163 | + } |
|
1164 | + } |
|
1165 | + |
|
1166 | + /** |
|
1167 | + * This functions gets all replys to a post, threaded. |
|
1168 | + * |
|
1169 | + * @param Integer $current |
|
1170 | + * @param Integer $current_level |
|
1171 | + * @param Integer $blog_id |
|
1172 | + * @param Integer $post_id |
|
1173 | + */ |
|
1174 | + public static function get_threaded_comments($current = 0, $current_level = 0, $blog_id, $post_id, $task_id = 0) |
|
1175 | + { |
|
1176 | + $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); |
|
1177 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
1178 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1179 | + global $charset; |
|
1180 | + |
|
1181 | + $course_id = api_get_course_int_id(); |
|
1182 | + |
|
1183 | + // Select top level comments |
|
1184 | + $next_level = $current_level + 1; |
|
1186 | 1185 | $sql = "SELECT comments.*, user.lastname, user.firstname, user.username, task.color |
1187 | 1186 | FROM $tbl_blogs_comments comments |
1188 | 1187 | INNER JOIN $tbl_users user |
@@ -1194,11 +1193,11 @@ discard block |
||
1194 | 1193 | parent_comment_id = $current AND |
1195 | 1194 | comments.blog_id = '".(int)$blog_id."' AND |
1196 | 1195 | comments.post_id = '".(int)$post_id."'"; |
1197 | - $result = Database::query($sql); |
|
1196 | + $result = Database::query($sql); |
|
1198 | 1197 | |
1199 | - while($comment = Database::fetch_array($result)) { |
|
1200 | - // Select the children recursivly |
|
1201 | - $tmp = "SELECT comments.*, user.lastname, user.firstname, user.username |
|
1198 | + while($comment = Database::fetch_array($result)) { |
|
1199 | + // Select the children recursivly |
|
1200 | + $tmp = "SELECT comments.*, user.lastname, user.firstname, user.username |
|
1202 | 1201 | FROM $tbl_blogs_comments comments |
1203 | 1202 | INNER JOIN $tbl_users user |
1204 | 1203 | ON comments.author_id = user.user_id |
@@ -1207,15 +1206,15 @@ discard block |
||
1207 | 1206 | comment_id = $current |
1208 | 1207 | AND blog_id = '".(int)$blog_id."' |
1209 | 1208 | AND post_id = '".(int)$post_id."'"; |
1210 | - $tmp = Database::query($tmp); |
|
1211 | - $tmp = Database::fetch_array($tmp); |
|
1212 | - $parent_cat = $tmp['parent_comment_id']; |
|
1213 | - $border_color = ''; |
|
1214 | - |
|
1215 | - // Prepare data |
|
1216 | - $comment_text = make_clickable(stripslashes($comment['comment'])); |
|
1217 | - $blog_comment_date = api_convert_and_format_date($comment['date_creation'], null, date_default_timezone_get()); |
|
1218 | - $blog_comment_actions = ""; |
|
1209 | + $tmp = Database::query($tmp); |
|
1210 | + $tmp = Database::fetch_array($tmp); |
|
1211 | + $parent_cat = $tmp['parent_comment_id']; |
|
1212 | + $border_color = ''; |
|
1213 | + |
|
1214 | + // Prepare data |
|
1215 | + $comment_text = make_clickable(stripslashes($comment['comment'])); |
|
1216 | + $blog_comment_date = api_convert_and_format_date($comment['date_creation'], null, date_default_timezone_get()); |
|
1217 | + $blog_comment_actions = ""; |
|
1219 | 1218 | if (api_is_allowed('BLOG_'.$blog_id, 'article_comments_delete', $task_id)) { |
1220 | 1219 | $blog_comment_actions .= '<a href="blog.php?action=view_post&blog_id='.$blog_id.'&post_id='.$post_id.'&do=delete_comment&comment_id='.$comment['comment_id'].'&task_id='.$task_id.'" title="'.get_lang( |
1221 | 1220 | 'DeleteThisComment' |
@@ -1230,167 +1229,167 @@ discard block |
||
1230 | 1229 | $rating_select = Blog::display_rating_form('comment', $blog_id, $post_id, $comment['comment_id']); |
1231 | 1230 | } |
1232 | 1231 | |
1233 | - if (!is_null($comment['task_id'])) { |
|
1234 | - $border_color = ' border-left: 3px solid #' . $comment['color']; |
|
1235 | - } |
|
1236 | - |
|
1237 | - $comment_text = stripslashes($comment_text); |
|
1238 | - |
|
1239 | - // Output... |
|
1240 | - $margin = $current_level * 30; |
|
1241 | - echo '<div class="blogpost_comment" style="margin-left: ' . $margin . 'px;' . $border_color . '">'; |
|
1242 | - echo '<span class="blogpost_comment_title"><a href="#add_comment" onclick="document.getElementById(\'comment_parent_id\').value=\'' . $comment['comment_id'] . '\'; document.getElementById(\'comment_title\').value=\'Re: '.addslashes($comment['title']) . '\'" title="' . get_lang('ReplyToThisComment') . '" >'.stripslashes($comment['title']) . '</a></span>'; |
|
1243 | - echo '<span class="blogpost_comment_date">' . $blog_comment_date . '</span>'; |
|
1244 | - echo '<span class="blogpost_text">' . $comment_text . '</span>'; |
|
1245 | - |
|
1246 | - $file_name_array = get_blog_attachment($blog_id,$post_id, $comment['comment_id']); |
|
1247 | - if (!empty($file_name_array)) { |
|
1248 | - echo '<br /><br />'; |
|
1249 | - echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
1250 | - echo '<a href="download.php?file='; |
|
1251 | - echo $file_name_array['path']; |
|
1252 | - echo ' "> '.$file_name_array['filename'].' </a>'; |
|
1253 | - echo '<span class="attachment_comment">'; |
|
1254 | - echo $file_name_array['comment']; |
|
1255 | - echo '</span><br />'; |
|
1256 | - } |
|
1257 | - $username = api_htmlentities(sprintf(get_lang('LoginX'), $comment['username']), ENT_QUOTES); |
|
1258 | - echo '<span class="blogpost_comment_info">'.get_lang('Author').': '.Display::tag('span', api_get_person_name($comment['firstname'], $comment['lastname']), array('title'=>$username)).' - '.get_lang('Rating').': '.Blog::display_rating('comment', $blog_id, $comment['comment_id']).$rating_select.'</span>'; |
|
1259 | - echo '<span class="blogpost_actions">' . $blog_comment_actions . '</span>'; |
|
1260 | - echo '</div>'; |
|
1261 | - |
|
1262 | - // Go further down the tree. |
|
1263 | - Blog::get_threaded_comments($comment['comment_id'], $next_level, $blog_id, $post_id); |
|
1264 | - } |
|
1265 | - } |
|
1266 | - |
|
1267 | - /** |
|
1268 | - * Displays the form to create a new post |
|
1269 | - * @author Toon Keppens |
|
1270 | - * |
|
1271 | - * @param Integer $blog_id |
|
1272 | - */ |
|
1273 | - public static function display_form_new_post($blog_id) |
|
1274 | - { |
|
1275 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) { |
|
1276 | - $form = new FormValidator( |
|
1277 | - 'add_post', |
|
1278 | - 'post', |
|
1279 | - api_get_path(WEB_CODE_PATH)."blog/blog.php?action=new_post&blog_id=" . $blog_id . "&" . api_get_cidreq(), |
|
1280 | - null, |
|
1281 | - array('enctype' => 'multipart/form-data') |
|
1282 | - ); |
|
1283 | - $form->addHidden('post_title_edited', 'false'); |
|
1284 | - $form->addHeader(get_lang('NewPost')); |
|
1285 | - $form->addText('title', get_lang('Title')); |
|
1286 | - $config = array(); |
|
1287 | - if (!api_is_allowed_to_edit()) { |
|
1288 | - $config['ToolbarSet'] = 'ProjectStudent'; |
|
1289 | - } else { |
|
1290 | - $config['ToolbarSet'] = 'Project'; |
|
1291 | - } |
|
1292 | - $form->addHtmlEditor('full_text', get_lang('Content'), false, false, $config); |
|
1293 | - $form->addFile('user_upload', get_lang('AddAnAttachment')); |
|
1294 | - $form->addTextarea('post_file_comment', get_lang('FileComment')); |
|
1295 | - $form->addHidden('new_post_submit', 'true'); |
|
1296 | - $form->addButton('save', get_lang('Save')); |
|
1297 | - |
|
1298 | - $form->display(); |
|
1299 | - } else { |
|
1300 | - api_not_allowed(); |
|
1301 | - } |
|
1302 | - } |
|
1303 | - |
|
1304 | - /** |
|
1305 | - * Displays the form to edit a post |
|
1306 | - * @author Toon Keppens |
|
1307 | - * |
|
1308 | - * @param Integer $blog_id |
|
1309 | - */ |
|
1310 | - public static function display_form_edit_post($blog_id, $post_id) |
|
1311 | - { |
|
1312 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
1313 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
1314 | - |
|
1315 | - $course_id = api_get_course_int_id(); |
|
1316 | - |
|
1317 | - // Get posts and author |
|
1318 | - $sql = "SELECT post.*, user.lastname, user.firstname |
|
1319 | - FROM $tbl_blogs_posts post |
|
1320 | - INNER JOIN $tbl_users user ON post.author_id = user.user_id |
|
1321 | - WHERE |
|
1322 | - post.c_id = $course_id AND |
|
1323 | - post.blog_id = '".(int)$blog_id ."' |
|
1324 | - AND post.post_id = '".(int)$post_id."' |
|
1325 | - ORDER BY post_id DESC"; |
|
1326 | - $result = Database::query($sql); |
|
1327 | - $blog_post = Database::fetch_array($result); |
|
1328 | - |
|
1329 | - // Form |
|
1330 | - $form = new FormValidator( |
|
1331 | - 'edit_post', |
|
1332 | - 'post', |
|
1333 | - api_get_path(WEB_CODE_PATH).'blog/blog.php?action=edit_post&post_id=' . intval($_GET['post_id']) . '&blog_id=' . intval($blog_id) . '&article_id='.intval($_GET['article_id']).'&task_id='.intval($_GET['task_id']) |
|
1334 | - ); |
|
1335 | - |
|
1336 | - $form->addHeader(get_lang('EditPost')); |
|
1337 | - $form->addText('title', get_lang('Title')); |
|
1338 | - |
|
1339 | - if (!api_is_allowed_to_edit()) { |
|
1340 | - $config['ToolbarSet'] = 'ProjectStudent'; |
|
1341 | - } else { |
|
1342 | - $config['ToolbarSet'] = 'Project'; |
|
1343 | - } |
|
1344 | - $form->addHtmlEditor('full_text', get_lang('Content'), false, false, $config); |
|
1345 | - |
|
1346 | - $form->addHidden('action', ''); |
|
1347 | - $form->addHidden('edit_post_submit', 'true'); |
|
1348 | - $form->addHidden('post_id', intval($_GET['post_id'])); |
|
1349 | - $form->addButton('save', get_lang('Save')); |
|
1350 | - $form->setDefaults($blog_post); |
|
1351 | - $form->display(); |
|
1352 | - } |
|
1353 | - |
|
1354 | - /** |
|
1355 | - * Displays a list of tasks in this blog |
|
1356 | - * @author Toon Keppens |
|
1357 | - * |
|
1358 | - * @param Integer $blog_id |
|
1359 | - */ |
|
1360 | - public static function display_task_list($blog_id) |
|
1232 | + if (!is_null($comment['task_id'])) { |
|
1233 | + $border_color = ' border-left: 3px solid #' . $comment['color']; |
|
1234 | + } |
|
1235 | + |
|
1236 | + $comment_text = stripslashes($comment_text); |
|
1237 | + |
|
1238 | + // Output... |
|
1239 | + $margin = $current_level * 30; |
|
1240 | + echo '<div class="blogpost_comment" style="margin-left: ' . $margin . 'px;' . $border_color . '">'; |
|
1241 | + echo '<span class="blogpost_comment_title"><a href="#add_comment" onclick="document.getElementById(\'comment_parent_id\').value=\'' . $comment['comment_id'] . '\'; document.getElementById(\'comment_title\').value=\'Re: '.addslashes($comment['title']) . '\'" title="' . get_lang('ReplyToThisComment') . '" >'.stripslashes($comment['title']) . '</a></span>'; |
|
1242 | + echo '<span class="blogpost_comment_date">' . $blog_comment_date . '</span>'; |
|
1243 | + echo '<span class="blogpost_text">' . $comment_text . '</span>'; |
|
1244 | + |
|
1245 | + $file_name_array = get_blog_attachment($blog_id,$post_id, $comment['comment_id']); |
|
1246 | + if (!empty($file_name_array)) { |
|
1247 | + echo '<br /><br />'; |
|
1248 | + echo Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
1249 | + echo '<a href="download.php?file='; |
|
1250 | + echo $file_name_array['path']; |
|
1251 | + echo ' "> '.$file_name_array['filename'].' </a>'; |
|
1252 | + echo '<span class="attachment_comment">'; |
|
1253 | + echo $file_name_array['comment']; |
|
1254 | + echo '</span><br />'; |
|
1255 | + } |
|
1256 | + $username = api_htmlentities(sprintf(get_lang('LoginX'), $comment['username']), ENT_QUOTES); |
|
1257 | + echo '<span class="blogpost_comment_info">'.get_lang('Author').': '.Display::tag('span', api_get_person_name($comment['firstname'], $comment['lastname']), array('title'=>$username)).' - '.get_lang('Rating').': '.Blog::display_rating('comment', $blog_id, $comment['comment_id']).$rating_select.'</span>'; |
|
1258 | + echo '<span class="blogpost_actions">' . $blog_comment_actions . '</span>'; |
|
1259 | + echo '</div>'; |
|
1260 | + |
|
1261 | + // Go further down the tree. |
|
1262 | + Blog::get_threaded_comments($comment['comment_id'], $next_level, $blog_id, $post_id); |
|
1263 | + } |
|
1264 | + } |
|
1265 | + |
|
1266 | + /** |
|
1267 | + * Displays the form to create a new post |
|
1268 | + * @author Toon Keppens |
|
1269 | + * |
|
1270 | + * @param Integer $blog_id |
|
1271 | + */ |
|
1272 | + public static function display_form_new_post($blog_id) |
|
1273 | + { |
|
1274 | + if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) { |
|
1275 | + $form = new FormValidator( |
|
1276 | + 'add_post', |
|
1277 | + 'post', |
|
1278 | + api_get_path(WEB_CODE_PATH)."blog/blog.php?action=new_post&blog_id=" . $blog_id . "&" . api_get_cidreq(), |
|
1279 | + null, |
|
1280 | + array('enctype' => 'multipart/form-data') |
|
1281 | + ); |
|
1282 | + $form->addHidden('post_title_edited', 'false'); |
|
1283 | + $form->addHeader(get_lang('NewPost')); |
|
1284 | + $form->addText('title', get_lang('Title')); |
|
1285 | + $config = array(); |
|
1286 | + if (!api_is_allowed_to_edit()) { |
|
1287 | + $config['ToolbarSet'] = 'ProjectStudent'; |
|
1288 | + } else { |
|
1289 | + $config['ToolbarSet'] = 'Project'; |
|
1290 | + } |
|
1291 | + $form->addHtmlEditor('full_text', get_lang('Content'), false, false, $config); |
|
1292 | + $form->addFile('user_upload', get_lang('AddAnAttachment')); |
|
1293 | + $form->addTextarea('post_file_comment', get_lang('FileComment')); |
|
1294 | + $form->addHidden('new_post_submit', 'true'); |
|
1295 | + $form->addButton('save', get_lang('Save')); |
|
1296 | + |
|
1297 | + $form->display(); |
|
1298 | + } else { |
|
1299 | + api_not_allowed(); |
|
1300 | + } |
|
1301 | + } |
|
1302 | + |
|
1303 | + /** |
|
1304 | + * Displays the form to edit a post |
|
1305 | + * @author Toon Keppens |
|
1306 | + * |
|
1307 | + * @param Integer $blog_id |
|
1308 | + */ |
|
1309 | + public static function display_form_edit_post($blog_id, $post_id) |
|
1310 | + { |
|
1311 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
1312 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
1313 | + |
|
1314 | + $course_id = api_get_course_int_id(); |
|
1315 | + |
|
1316 | + // Get posts and author |
|
1317 | + $sql = "SELECT post.*, user.lastname, user.firstname |
|
1318 | + FROM $tbl_blogs_posts post |
|
1319 | + INNER JOIN $tbl_users user ON post.author_id = user.user_id |
|
1320 | + WHERE |
|
1321 | + post.c_id = $course_id AND |
|
1322 | + post.blog_id = '".(int)$blog_id ."' |
|
1323 | + AND post.post_id = '".(int)$post_id."' |
|
1324 | + ORDER BY post_id DESC"; |
|
1325 | + $result = Database::query($sql); |
|
1326 | + $blog_post = Database::fetch_array($result); |
|
1327 | + |
|
1328 | + // Form |
|
1329 | + $form = new FormValidator( |
|
1330 | + 'edit_post', |
|
1331 | + 'post', |
|
1332 | + api_get_path(WEB_CODE_PATH).'blog/blog.php?action=edit_post&post_id=' . intval($_GET['post_id']) . '&blog_id=' . intval($blog_id) . '&article_id='.intval($_GET['article_id']).'&task_id='.intval($_GET['task_id']) |
|
1333 | + ); |
|
1334 | + |
|
1335 | + $form->addHeader(get_lang('EditPost')); |
|
1336 | + $form->addText('title', get_lang('Title')); |
|
1337 | + |
|
1338 | + if (!api_is_allowed_to_edit()) { |
|
1339 | + $config['ToolbarSet'] = 'ProjectStudent'; |
|
1340 | + } else { |
|
1341 | + $config['ToolbarSet'] = 'Project'; |
|
1342 | + } |
|
1343 | + $form->addHtmlEditor('full_text', get_lang('Content'), false, false, $config); |
|
1344 | + |
|
1345 | + $form->addHidden('action', ''); |
|
1346 | + $form->addHidden('edit_post_submit', 'true'); |
|
1347 | + $form->addHidden('post_id', intval($_GET['post_id'])); |
|
1348 | + $form->addButton('save', get_lang('Save')); |
|
1349 | + $form->setDefaults($blog_post); |
|
1350 | + $form->display(); |
|
1351 | + } |
|
1352 | + |
|
1353 | + /** |
|
1354 | + * Displays a list of tasks in this blog |
|
1355 | + * @author Toon Keppens |
|
1356 | + * |
|
1357 | + * @param Integer $blog_id |
|
1358 | + */ |
|
1359 | + public static function display_task_list($blog_id) |
|
1361 | 1360 | { |
1362 | - global $charset; |
|
1361 | + global $charset; |
|
1363 | 1362 | $course_id = api_get_course_int_id(); |
1364 | 1363 | |
1365 | - if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) { |
|
1366 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1367 | - $counter = 0; |
|
1368 | - global $color2; |
|
1364 | + if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) { |
|
1365 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1366 | + $counter = 0; |
|
1367 | + global $color2; |
|
1369 | 1368 | |
1370 | - echo '<div class="actions">'; |
|
1371 | - echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=add">'; |
|
1369 | + echo '<div class="actions">'; |
|
1370 | + echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=add">'; |
|
1372 | 1371 | echo Display::return_icon('blog_newtasks.gif', get_lang('AddTasks')); |
1373 | 1372 | echo get_lang('AddTasks') . '</a> '; |
1374 | - echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=assign">'; |
|
1373 | + echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=assign">'; |
|
1375 | 1374 | echo Display::return_icon('blog_task.gif', get_lang('AssignTasks')); |
1376 | 1375 | echo get_lang('AssignTasks') . '</a>'; |
1377 | - ?> |
|
1376 | + ?> |
|
1378 | 1377 | <a href="<?php echo api_get_self(); ?>?action=manage_rights&blog_id=<?php echo $blog_id ?>" title="<?php echo get_lang('ManageRights') ?>"> |
1379 | 1378 | <?php echo Display::return_icon('blog_admin_users.png', get_lang('RightsManager'),'',ICON_SIZE_SMALL). get_lang('RightsManager') ?></a> |
1380 | 1379 | <?php |
1381 | - echo '</div>'; |
|
1380 | + echo '</div>'; |
|
1382 | 1381 | |
1383 | - echo '<span class="blogpost_title">' . get_lang('TaskList') . '</span><br />'; |
|
1384 | - echo "<table class=\"data_table\">"; |
|
1385 | - echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">", |
|
1386 | - "<th width='240'><b>",get_lang('Title'),"</b></th>", |
|
1387 | - "<th><b>",get_lang('Description'),"</b></th>", |
|
1388 | - "<th><b>",get_lang('Color'),"</b></th>", |
|
1389 | - "<th width='50'><b>",get_lang('Modify'),"</b></th>", |
|
1390 | - "</tr>"; |
|
1382 | + echo '<span class="blogpost_title">' . get_lang('TaskList') . '</span><br />'; |
|
1383 | + echo "<table class=\"data_table\">"; |
|
1384 | + echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">", |
|
1385 | + "<th width='240'><b>",get_lang('Title'),"</b></th>", |
|
1386 | + "<th><b>",get_lang('Description'),"</b></th>", |
|
1387 | + "<th><b>",get_lang('Color'),"</b></th>", |
|
1388 | + "<th width='50'><b>",get_lang('Modify'),"</b></th>", |
|
1389 | + "</tr>"; |
|
1391 | 1390 | |
1392 | 1391 | |
1393 | - $sql = " SELECT |
|
1392 | + $sql = " SELECT |
|
1394 | 1393 | blog_id, |
1395 | 1394 | task_id, |
1396 | 1395 | blog_id, |
@@ -1401,64 +1400,64 @@ discard block |
||
1401 | 1400 | FROM " . $tbl_blogs_tasks . " |
1402 | 1401 | WHERE c_id = $course_id AND blog_id = " . (int)$blog_id . " |
1403 | 1402 | ORDER BY system_task, title"; |
1404 | - $result = Database::query($sql); |
|
1403 | + $result = Database::query($sql); |
|
1405 | 1404 | |
1406 | - while ($task = Database::fetch_array($result)) { |
|
1407 | - $counter++; |
|
1408 | - $css_class = (($counter % 2) == 0) ? "row_odd" : "row_even"; |
|
1409 | - $delete_icon = ($task['system_task'] == '1') ? "delete_na.png" : "delete.png"; |
|
1410 | - $delete_title = ($task['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask'); |
|
1411 | - $delete_link = ($task['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=delete&task_id=' . $task['task_id']; |
|
1412 | - $delete_confirm = ($task['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"'; |
|
1405 | + while ($task = Database::fetch_array($result)) { |
|
1406 | + $counter++; |
|
1407 | + $css_class = (($counter % 2) == 0) ? "row_odd" : "row_even"; |
|
1408 | + $delete_icon = ($task['system_task'] == '1') ? "delete_na.png" : "delete.png"; |
|
1409 | + $delete_title = ($task['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask'); |
|
1410 | + $delete_link = ($task['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=delete&task_id=' . $task['task_id']; |
|
1411 | + $delete_confirm = ($task['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"'; |
|
1413 | 1412 | |
1414 | - echo '<tr class="' . $css_class . '" valign="top">'; |
|
1413 | + echo '<tr class="' . $css_class . '" valign="top">'; |
|
1415 | 1414 | echo '<td width="240">'.Security::remove_XSS($task['title']).'</td>'; |
1416 | 1415 | echo '<td>'.Security::remove_XSS($task['description']).'</td>'; |
1417 | 1416 | echo '<td><span style="background-color: #'.$task['color'].'"> </span></td>'; |
1418 | 1417 | echo '<td width="50">'; |
1419 | 1418 | echo '<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$task['blog_id'].'&do=edit&task_id='.$task['task_id'].'">'; |
1420 | 1419 | echo Display::return_icon('edit.png', get_lang('EditTask')); |
1421 | - echo "</a>"; |
|
1422 | - echo '<a href="'.$delete_link.'"'; |
|
1423 | - echo $delete_confirm; |
|
1424 | - echo '>'; |
|
1420 | + echo "</a>"; |
|
1421 | + echo '<a href="'.$delete_link.'"'; |
|
1422 | + echo $delete_confirm; |
|
1423 | + echo '>'; |
|
1425 | 1424 | echo Display::return_icon($delete_icon, $delete_title); |
1426 | - echo "</a>"; |
|
1427 | - echo '</td>'; |
|
1428 | - echo '</tr>'; |
|
1429 | - } |
|
1430 | - echo "</table>"; |
|
1431 | - } |
|
1432 | - } |
|
1433 | - |
|
1434 | - /** |
|
1435 | - * Displays a list of tasks assigned to a user in this blog |
|
1436 | - * @author Toon Keppens |
|
1437 | - * |
|
1438 | - * @param Integer $blog_id |
|
1439 | - */ |
|
1440 | - public static function display_assigned_task_list ($blog_id) |
|
1425 | + echo "</a>"; |
|
1426 | + echo '</td>'; |
|
1427 | + echo '</tr>'; |
|
1428 | + } |
|
1429 | + echo "</table>"; |
|
1430 | + } |
|
1431 | + } |
|
1432 | + |
|
1433 | + /** |
|
1434 | + * Displays a list of tasks assigned to a user in this blog |
|
1435 | + * @author Toon Keppens |
|
1436 | + * |
|
1437 | + * @param Integer $blog_id |
|
1438 | + */ |
|
1439 | + public static function display_assigned_task_list ($blog_id) |
|
1441 | 1440 | { |
1442 | - // Init |
|
1443 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
1444 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1445 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
1446 | - $counter = 0; |
|
1447 | - global $charset,$color2; |
|
1448 | - |
|
1449 | - echo '<span class="blogpost_title">' . get_lang('AssignedTasks') . '</span><br />'; |
|
1450 | - echo "<table class=\"data_table\">"; |
|
1451 | - echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">", |
|
1452 | - "<th width='240'><b>",get_lang('Member'),"</b></th>", |
|
1453 | - "<th><b>",get_lang('Task'),"</b></th>", |
|
1454 | - "<th><b>",get_lang('Description'),"</b></th>", |
|
1455 | - "<th><b>",get_lang('TargetDate'),"</b></th>", |
|
1456 | - "<th width='50'><b>",get_lang('Modify'),"</b></th>", |
|
1457 | - "</tr>"; |
|
1458 | - |
|
1459 | - $course_id = api_get_course_int_id(); |
|
1460 | - |
|
1461 | - $sql = "SELECT task_rel_user.*, task.title, user.firstname, user.lastname, user.username, task.description, task.system_task, task.blog_id, task.task_id |
|
1441 | + // Init |
|
1442 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
1443 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1444 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
1445 | + $counter = 0; |
|
1446 | + global $charset,$color2; |
|
1447 | + |
|
1448 | + echo '<span class="blogpost_title">' . get_lang('AssignedTasks') . '</span><br />'; |
|
1449 | + echo "<table class=\"data_table\">"; |
|
1450 | + echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">", |
|
1451 | + "<th width='240'><b>",get_lang('Member'),"</b></th>", |
|
1452 | + "<th><b>",get_lang('Task'),"</b></th>", |
|
1453 | + "<th><b>",get_lang('Description'),"</b></th>", |
|
1454 | + "<th><b>",get_lang('TargetDate'),"</b></th>", |
|
1455 | + "<th width='50'><b>",get_lang('Modify'),"</b></th>", |
|
1456 | + "</tr>"; |
|
1457 | + |
|
1458 | + $course_id = api_get_course_int_id(); |
|
1459 | + |
|
1460 | + $sql = "SELECT task_rel_user.*, task.title, user.firstname, user.lastname, user.username, task.description, task.system_task, task.blog_id, task.task_id |
|
1462 | 1461 | FROM $tbl_blogs_tasks_rel_user task_rel_user |
1463 | 1462 | INNER JOIN $tbl_blogs_tasks task ON task_rel_user.task_id = task.task_id |
1464 | 1463 | INNER JOIN $tbl_users user ON task_rel_user.user_id = user.user_id |
@@ -1467,15 +1466,15 @@ discard block |
||
1467 | 1466 | task.c_id = $course_id AND |
1468 | 1467 | task_rel_user.blog_id = '".(int)$blog_id."' |
1469 | 1468 | ORDER BY target_date ASC"; |
1470 | - $result = Database::query($sql); |
|
1469 | + $result = Database::query($sql); |
|
1471 | 1470 | |
1472 | - while ($assignment = Database::fetch_array($result)) { |
|
1473 | - $counter++; |
|
1474 | - $css_class = (($counter % 2)==0) ? "row_odd" : "row_even"; |
|
1475 | - $delete_icon = ($assignment['system_task'] == '1') ? "delete_na.png" : "delete.png"; |
|
1476 | - $delete_title = ($assignment['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask'); |
|
1477 | - $delete_link = ($assignment['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete&task_id=' . $assignment['task_id']; |
|
1478 | - $delete_confirm = ($assignment['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"'; |
|
1471 | + while ($assignment = Database::fetch_array($result)) { |
|
1472 | + $counter++; |
|
1473 | + $css_class = (($counter % 2)==0) ? "row_odd" : "row_even"; |
|
1474 | + $delete_icon = ($assignment['system_task'] == '1') ? "delete_na.png" : "delete.png"; |
|
1475 | + $delete_title = ($assignment['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask'); |
|
1476 | + $delete_link = ($assignment['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete&task_id=' . $assignment['task_id']; |
|
1477 | + $delete_confirm = ($assignment['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"'; |
|
1479 | 1478 | |
1480 | 1479 | $username = api_htmlentities(sprintf(get_lang('LoginX'), $assignment['username']), ENT_QUOTES); |
1481 | 1480 | |
@@ -1490,26 +1489,26 @@ discard block |
||
1490 | 1489 | echo '<td>'.$assignment['target_date'].'</td>'; |
1491 | 1490 | echo '<td width="50">'; |
1492 | 1491 | echo '<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$assignment['blog_id'].'&do=edit_assignment&task_id='.$assignment['task_id'].'&user_id='.$assignment['user_id'].'">'; |
1493 | - echo Display::return_icon('edit.png', get_lang('EditTask')); |
|
1494 | - echo "</a>"; |
|
1495 | - echo '<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$assignment['blog_id'].'&do=delete_assignment&task_id='.$assignment['task_id'].'&user_id='.$assignment['user_id'].'" '; |
|
1496 | - echo 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)).'\')) return false;"'; |
|
1492 | + echo Display::return_icon('edit.png', get_lang('EditTask')); |
|
1493 | + echo "</a>"; |
|
1494 | + echo '<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$assignment['blog_id'].'&do=delete_assignment&task_id='.$assignment['task_id'].'&user_id='.$assignment['user_id'].'" '; |
|
1495 | + echo 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)).'\')) return false;"'; |
|
1497 | 1496 | echo Display::return_icon($delete_icon, $delete_title); |
1498 | - echo "</a>"; |
|
1499 | - echo '</td>'; |
|
1500 | - echo '</tr>'; |
|
1501 | - } |
|
1502 | - echo "</table>"; |
|
1503 | - } |
|
1504 | - |
|
1505 | - /** |
|
1506 | - * Displays new task form |
|
1507 | - * @author Toon Keppens |
|
1508 | - * |
|
1509 | - */ |
|
1510 | - public static function display_new_task_form ($blog_id) |
|
1511 | - { |
|
1512 | - // Init |
|
1497 | + echo "</a>"; |
|
1498 | + echo '</td>'; |
|
1499 | + echo '</tr>'; |
|
1500 | + } |
|
1501 | + echo "</table>"; |
|
1502 | + } |
|
1503 | + |
|
1504 | + /** |
|
1505 | + * Displays new task form |
|
1506 | + * @author Toon Keppens |
|
1507 | + * |
|
1508 | + */ |
|
1509 | + public static function display_new_task_form ($blog_id) |
|
1510 | + { |
|
1511 | + // Init |
|
1513 | 1512 | $colors = array( |
1514 | 1513 | 'FFFFFF', |
1515 | 1514 | 'FFFF99', |
@@ -1528,14 +1527,14 @@ discard block |
||
1528 | 1527 | '000000' |
1529 | 1528 | ); |
1530 | 1529 | |
1531 | - // form |
|
1532 | - echo '<form name="add_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '">'; |
|
1530 | + // form |
|
1531 | + echo '<form name="add_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '">'; |
|
1533 | 1532 | |
1534 | - // form title |
|
1535 | - echo '<legend>'.get_lang('AddTask').'</legend>'; |
|
1533 | + // form title |
|
1534 | + echo '<legend>'.get_lang('AddTask').'</legend>'; |
|
1536 | 1535 | |
1537 | - // task title |
|
1538 | - echo ' <div class="control-group"> |
|
1536 | + // task title |
|
1537 | + echo ' <div class="control-group"> |
|
1539 | 1538 | <label class="control-label"> |
1540 | 1539 | <span class="form_required">*</span>' . get_lang('Title') . ' |
1541 | 1540 | </label> |
@@ -1544,8 +1543,8 @@ discard block |
||
1544 | 1543 | </div> |
1545 | 1544 | </div>'; |
1546 | 1545 | |
1547 | - // task comment |
|
1548 | - echo ' <div class="control-group"> |
|
1546 | + // task comment |
|
1547 | + echo ' <div class="control-group"> |
|
1549 | 1548 | <label class="control-label"> |
1550 | 1549 | ' . get_lang('Description') . ' |
1551 | 1550 | </label> |
@@ -1554,8 +1553,8 @@ discard block |
||
1554 | 1553 | </div> |
1555 | 1554 | </div>'; |
1556 | 1555 | |
1557 | - // task management |
|
1558 | - echo ' <div class="control-group"> |
|
1556 | + // task management |
|
1557 | + echo ' <div class="control-group"> |
|
1559 | 1558 | <label class="control-label"> |
1560 | 1559 | ' . get_lang('TaskManager') . ' |
1561 | 1560 | </label> |
@@ -1576,12 +1575,12 @@ discard block |
||
1576 | 1575 | echo '<td style="border:1px dotted #808080; text-align:center;"><input id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>'; |
1577 | 1576 | echo '</tr>'; |
1578 | 1577 | echo '</table>'; |
1579 | - echo ' </div> |
|
1578 | + echo ' </div> |
|
1580 | 1579 | </div>'; |
1581 | 1580 | |
1582 | 1581 | |
1583 | - // task color |
|
1584 | - echo ' <div class="control-group"> |
|
1582 | + // task color |
|
1583 | + echo ' <div class="control-group"> |
|
1585 | 1584 | <label class="control-label"> |
1586 | 1585 | ' . get_lang('Color') . ' |
1587 | 1586 | </label> |
@@ -1592,40 +1591,40 @@ discard block |
||
1592 | 1591 | echo '<option value="' . $color . '" ' . $style . '> </option>'; |
1593 | 1592 | } |
1594 | 1593 | echo '</select>'; |
1595 | - echo ' </div> |
|
1594 | + echo ' </div> |
|
1596 | 1595 | </div>'; |
1597 | 1596 | |
1598 | - // submit |
|
1599 | - echo ' <div class="control-group"> |
|
1597 | + // submit |
|
1598 | + echo ' <div class="control-group"> |
|
1600 | 1599 | <div class="controls"> |
1601 | 1600 | <input type="hidden" name="action" value="" /> |
1602 | 1601 | <input type="hidden" name="new_task_submit" value="true" /> |
1603 | 1602 | <button class="save" type="submit" name="Submit">' . get_lang('Save') . '</button> |
1604 | 1603 | </div> |
1605 | 1604 | </div>'; |
1606 | - echo '</form>'; |
|
1605 | + echo '</form>'; |
|
1607 | 1606 | |
1608 | - echo '<div style="clear:both; margin-bottom: 10px;"></div>'; |
|
1609 | - } |
|
1607 | + echo '<div style="clear:both; margin-bottom: 10px;"></div>'; |
|
1608 | + } |
|
1610 | 1609 | |
1611 | 1610 | |
1612 | - /** |
|
1613 | - * Displays edit task form |
|
1614 | - * @author Toon Keppens |
|
1615 | - * |
|
1616 | - */ |
|
1617 | - public static function display_edit_task_form ($blog_id, $task_id) { |
|
1618 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1611 | + /** |
|
1612 | + * Displays edit task form |
|
1613 | + * @author Toon Keppens |
|
1614 | + * |
|
1615 | + */ |
|
1616 | + public static function display_edit_task_form ($blog_id, $task_id) { |
|
1617 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1619 | 1618 | $course_id = api_get_course_int_id(); |
1620 | 1619 | |
1621 | - $colors = array('FFFFFF','FFFF99','FFCC99','FF9933','FF6699','CCFF99','CC9966','66FF00', '9966FF', 'CF3F3F', '990033','669933','0033FF','003366','000000'); |
|
1620 | + $colors = array('FFFFFF','FFFF99','FFCC99','FF9933','FF6699','CCFF99','CC9966','66FF00', '9966FF', 'CF3F3F', '990033','669933','0033FF','003366','000000'); |
|
1622 | 1621 | |
1623 | - $sql = "SELECT blog_id, task_id, title, description, color FROM $tbl_blogs_tasks WHERE c_id = $course_id AND task_id = '".(int)$task_id."'"; |
|
1624 | - $result = Database::query($sql); |
|
1625 | - $task = Database::fetch_array($result); |
|
1622 | + $sql = "SELECT blog_id, task_id, title, description, color FROM $tbl_blogs_tasks WHERE c_id = $course_id AND task_id = '".(int)$task_id."'"; |
|
1623 | + $result = Database::query($sql); |
|
1624 | + $task = Database::fetch_array($result); |
|
1626 | 1625 | |
1627 | - // Display |
|
1628 | - echo '<form name="edit_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '"> |
|
1626 | + // Display |
|
1627 | + echo '<form name="edit_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '"> |
|
1629 | 1628 | <legend>' . get_lang('EditTask') . '</legend> |
1630 | 1629 | <table width="100%" border="0" cellspacing="2"> |
1631 | 1630 | <tr> |
@@ -1637,42 +1636,42 @@ discard block |
||
1637 | 1636 | <td><textarea name="task_description" cols="45">'.Security::remove_XSS($task['description']).'</textarea></td> |
1638 | 1637 | </tr>'; |
1639 | 1638 | |
1640 | - /* edit by Kevin Van Den Haute ([email protected]) */ |
|
1641 | - $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
1639 | + /* edit by Kevin Van Den Haute ([email protected]) */ |
|
1640 | + $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
|
1642 | 1641 | |
1643 | - $sql = " SELECT id, action FROM " . $tbl_tasks_permissions . " |
|
1642 | + $sql = " SELECT id, action FROM " . $tbl_tasks_permissions . " |
|
1644 | 1643 | WHERE c_id = $course_id AND task_id = '" . (int)$task_id."'"; |
1645 | - $result = Database::query($sql); |
|
1646 | - |
|
1647 | - $arrPermissions = array(); |
|
1648 | - |
|
1649 | - while ($row = Database::fetch_array($result)) |
|
1650 | - $arrPermissions[] = $row['action']; |
|
1651 | - |
|
1652 | - echo '<tr>'; |
|
1653 | - echo '<td style="text-align:right; vertical-align:top;">' . get_lang('TaskManager') . ': </td>'; |
|
1654 | - echo '<td>'; |
|
1655 | - echo '<table class="data_table" cellspacing="0" style="border-collapse:collapse; width:446px;">'; |
|
1656 | - echo '<tr>'; |
|
1657 | - echo '<th colspan="2" style="width:223px;">' . get_lang('ArticleManager') . '</th>'; |
|
1658 | - echo '<th width:223px;>' . get_lang('CommentManager') . '</th>'; |
|
1659 | - echo '</tr>'; |
|
1660 | - echo '<tr>'; |
|
1661 | - echo '<th style="width:111px;"><label for="articleDelete">' . get_lang('Delete') . '</label></th>'; |
|
1662 | - echo '<th style="width:112px;"><label for="articleEdit">' . get_lang('Edit') . '</label></th>'; |
|
1663 | - echo '<th style="width:223px;"><label for="commentsDelete">' . get_lang('Delete') . '</label></th>'; |
|
1664 | - echo '</tr>'; |
|
1665 | - echo '<tr>'; |
|
1666 | - echo '<td style="text-align:center;"><input ' . ((in_array('article_delete', $arrPermissions)) ? 'checked ' : '') . 'id="articleDelete" name="chkArticleDelete" type="checkbox" /></td>'; |
|
1667 | - echo '<td style="text-align:center;"><input ' . ((in_array('article_edit', $arrPermissions)) ? 'checked ' : '') . 'id="articleEdit" name="chkArticleEdit" type="checkbox" /></td>'; |
|
1668 | - echo '<td style="text-align:center;"><input ' . ((in_array('article_comments_delete', $arrPermissions)) ? 'checked ' : '') . 'id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>'; |
|
1669 | - echo '</tr>'; |
|
1670 | - echo '</table>'; |
|
1671 | - echo '</td>'; |
|
1672 | - echo '</tr>'; |
|
1673 | - /* end of edit */ |
|
1674 | - |
|
1675 | - echo '<tr> |
|
1644 | + $result = Database::query($sql); |
|
1645 | + |
|
1646 | + $arrPermissions = array(); |
|
1647 | + |
|
1648 | + while ($row = Database::fetch_array($result)) |
|
1649 | + $arrPermissions[] = $row['action']; |
|
1650 | + |
|
1651 | + echo '<tr>'; |
|
1652 | + echo '<td style="text-align:right; vertical-align:top;">' . get_lang('TaskManager') . ': </td>'; |
|
1653 | + echo '<td>'; |
|
1654 | + echo '<table class="data_table" cellspacing="0" style="border-collapse:collapse; width:446px;">'; |
|
1655 | + echo '<tr>'; |
|
1656 | + echo '<th colspan="2" style="width:223px;">' . get_lang('ArticleManager') . '</th>'; |
|
1657 | + echo '<th width:223px;>' . get_lang('CommentManager') . '</th>'; |
|
1658 | + echo '</tr>'; |
|
1659 | + echo '<tr>'; |
|
1660 | + echo '<th style="width:111px;"><label for="articleDelete">' . get_lang('Delete') . '</label></th>'; |
|
1661 | + echo '<th style="width:112px;"><label for="articleEdit">' . get_lang('Edit') . '</label></th>'; |
|
1662 | + echo '<th style="width:223px;"><label for="commentsDelete">' . get_lang('Delete') . '</label></th>'; |
|
1663 | + echo '</tr>'; |
|
1664 | + echo '<tr>'; |
|
1665 | + echo '<td style="text-align:center;"><input ' . ((in_array('article_delete', $arrPermissions)) ? 'checked ' : '') . 'id="articleDelete" name="chkArticleDelete" type="checkbox" /></td>'; |
|
1666 | + echo '<td style="text-align:center;"><input ' . ((in_array('article_edit', $arrPermissions)) ? 'checked ' : '') . 'id="articleEdit" name="chkArticleEdit" type="checkbox" /></td>'; |
|
1667 | + echo '<td style="text-align:center;"><input ' . ((in_array('article_comments_delete', $arrPermissions)) ? 'checked ' : '') . 'id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>'; |
|
1668 | + echo '</tr>'; |
|
1669 | + echo '</table>'; |
|
1670 | + echo '</td>'; |
|
1671 | + echo '</tr>'; |
|
1672 | + /* end of edit */ |
|
1673 | + |
|
1674 | + echo '<tr> |
|
1676 | 1675 | <td align="right">' . get_lang('Color') . ': </td> |
1677 | 1676 | <td> |
1678 | 1677 | <select name="task_color" id="color" style="width: 150px; background-color: #' . $task['color'] . '" onchange="document.getElementById(\'color\').style.backgroundColor=\'#\'+document.getElementById(\'color\').value" onkeypress="document.getElementById(\'color\').style.backgroundColor=\'#\'+document.getElementById(\'color\').value">'; |
@@ -1681,7 +1680,7 @@ discard block |
||
1681 | 1680 | $style = 'style="background-color: #' . $color . '"'; |
1682 | 1681 | echo '<option value="' . $color . '" ' . $style . ' ' . $selected . ' > </option>'; |
1683 | 1682 | } |
1684 | - echo ' </select> |
|
1683 | + echo ' </select> |
|
1685 | 1684 | </td> |
1686 | 1685 | </tr> |
1687 | 1686 | <tr> |
@@ -1694,34 +1693,34 @@ discard block |
||
1694 | 1693 | </tr> |
1695 | 1694 | </table> |
1696 | 1695 | </form>'; |
1697 | - } |
|
1698 | - |
|
1699 | - /** |
|
1700 | - * @param $blog_id |
|
1701 | - * @return FormValidator |
|
1702 | - */ |
|
1703 | - public static function getTaskForm($blog_id) |
|
1704 | - { |
|
1705 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
1706 | - $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
1707 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1708 | - $course_id = api_get_course_int_id(); |
|
1709 | - |
|
1710 | - // Get users in this blog / make select list of it |
|
1711 | - $sql = "SELECT user.user_id, user.firstname, user.lastname, user.username |
|
1696 | + } |
|
1697 | + |
|
1698 | + /** |
|
1699 | + * @param $blog_id |
|
1700 | + * @return FormValidator |
|
1701 | + */ |
|
1702 | + public static function getTaskForm($blog_id) |
|
1703 | + { |
|
1704 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
1705 | + $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
1706 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1707 | + $course_id = api_get_course_int_id(); |
|
1708 | + |
|
1709 | + // Get users in this blog / make select list of it |
|
1710 | + $sql = "SELECT user.user_id, user.firstname, user.lastname, user.username |
|
1712 | 1711 | FROM $tbl_users user |
1713 | 1712 | INNER JOIN $tbl_blogs_rel_user blogs_rel_user |
1714 | 1713 | ON user.user_id = blogs_rel_user.user_id |
1715 | 1714 | WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".(int)$blog_id."'"; |
1716 | - $result = Database::query($sql); |
|
1715 | + $result = Database::query($sql); |
|
1717 | 1716 | |
1718 | - $options = array(); |
|
1719 | - while ($user = Database::fetch_array($result)) { |
|
1720 | - $options[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']); |
|
1721 | - } |
|
1717 | + $options = array(); |
|
1718 | + while ($user = Database::fetch_array($result)) { |
|
1719 | + $options[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']); |
|
1720 | + } |
|
1722 | 1721 | |
1723 | - // Get tasks in this blog / make select list of it |
|
1724 | - $sql = " |
|
1722 | + // Get tasks in this blog / make select list of it |
|
1723 | + $sql = " |
|
1725 | 1724 | SELECT |
1726 | 1725 | blog_id, |
1727 | 1726 | task_id, |
@@ -1733,97 +1732,97 @@ discard block |
||
1733 | 1732 | FROM $tbl_blogs_tasks |
1734 | 1733 | WHERE c_id = $course_id AND blog_id = " . (int)$blog_id . " |
1735 | 1734 | ORDER BY system_task, title"; |
1736 | - $result = Database::query($sql); |
|
1737 | - |
|
1738 | - $taskOptions = array(); |
|
1739 | - while ($task = Database::fetch_array($result)) { |
|
1740 | - $taskOptions[$task['task_id']] = stripslashes($task['title']); |
|
1741 | - } |
|
1742 | - |
|
1743 | - $form = new FormValidator( |
|
1744 | - 'assign_task', |
|
1745 | - 'post', |
|
1746 | - api_get_path( |
|
1747 | - WEB_CODE_PATH |
|
1748 | - ).'blog/blog.php?action=manage_tasks&blog_id='.$blog_id |
|
1749 | - ); |
|
1750 | - |
|
1751 | - $form->addHeader(get_lang('AssignTask')); |
|
1752 | - $form->addSelect('task_user_id', get_lang('SelectUser'), $options); |
|
1753 | - $form->addSelect('task_task_id', get_lang('SelectTask'), $taskOptions); |
|
1754 | - $form->addDatePicker('task_day', get_lang('SelectTargetDate')); |
|
1755 | - |
|
1756 | - $form->addHidden('action', ''); |
|
1757 | - $form->addButtonSave(get_lang('Ok')); |
|
1758 | - |
|
1759 | - return $form; |
|
1760 | - } |
|
1761 | - |
|
1762 | - /** |
|
1763 | - * Displays assign task form |
|
1764 | - * @author Toon Keppens |
|
1765 | - * |
|
1766 | - */ |
|
1767 | - public static function display_assign_task_form($blog_id) |
|
1768 | - { |
|
1769 | - $form = self::getTaskForm($blog_id); |
|
1770 | - $form->addHidden('assign_task_submit', 'true'); |
|
1771 | - $form->display(); |
|
1772 | - echo '<div style="clear: both; margin-bottom:10px;"></div>'; |
|
1773 | - } |
|
1774 | - |
|
1775 | - /** |
|
1776 | - * Displays assign task form |
|
1777 | - * @author Toon Keppens |
|
1778 | - * |
|
1779 | - */ |
|
1780 | - public static function display_edit_assigned_task_form($blog_id, $task_id, $user_id) |
|
1781 | - { |
|
1782 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
1783 | - |
|
1784 | - $course_id = api_get_course_int_id(); |
|
1785 | - |
|
1786 | - // Get assignd date; |
|
1787 | - $sql = " |
|
1735 | + $result = Database::query($sql); |
|
1736 | + |
|
1737 | + $taskOptions = array(); |
|
1738 | + while ($task = Database::fetch_array($result)) { |
|
1739 | + $taskOptions[$task['task_id']] = stripslashes($task['title']); |
|
1740 | + } |
|
1741 | + |
|
1742 | + $form = new FormValidator( |
|
1743 | + 'assign_task', |
|
1744 | + 'post', |
|
1745 | + api_get_path( |
|
1746 | + WEB_CODE_PATH |
|
1747 | + ).'blog/blog.php?action=manage_tasks&blog_id='.$blog_id |
|
1748 | + ); |
|
1749 | + |
|
1750 | + $form->addHeader(get_lang('AssignTask')); |
|
1751 | + $form->addSelect('task_user_id', get_lang('SelectUser'), $options); |
|
1752 | + $form->addSelect('task_task_id', get_lang('SelectTask'), $taskOptions); |
|
1753 | + $form->addDatePicker('task_day', get_lang('SelectTargetDate')); |
|
1754 | + |
|
1755 | + $form->addHidden('action', ''); |
|
1756 | + $form->addButtonSave(get_lang('Ok')); |
|
1757 | + |
|
1758 | + return $form; |
|
1759 | + } |
|
1760 | + |
|
1761 | + /** |
|
1762 | + * Displays assign task form |
|
1763 | + * @author Toon Keppens |
|
1764 | + * |
|
1765 | + */ |
|
1766 | + public static function display_assign_task_form($blog_id) |
|
1767 | + { |
|
1768 | + $form = self::getTaskForm($blog_id); |
|
1769 | + $form->addHidden('assign_task_submit', 'true'); |
|
1770 | + $form->display(); |
|
1771 | + echo '<div style="clear: both; margin-bottom:10px;"></div>'; |
|
1772 | + } |
|
1773 | + |
|
1774 | + /** |
|
1775 | + * Displays assign task form |
|
1776 | + * @author Toon Keppens |
|
1777 | + * |
|
1778 | + */ |
|
1779 | + public static function display_edit_assigned_task_form($blog_id, $task_id, $user_id) |
|
1780 | + { |
|
1781 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
1782 | + |
|
1783 | + $course_id = api_get_course_int_id(); |
|
1784 | + |
|
1785 | + // Get assignd date; |
|
1786 | + $sql = " |
|
1788 | 1787 | SELECT target_date |
1789 | 1788 | FROM $tbl_blogs_tasks_rel_user |
1790 | 1789 | WHERE c_id = $course_id AND |
1791 | 1790 | blog_id = '".(int)$blog_id."' AND |
1792 | 1791 | user_id = '".(int)$user_id."' AND |
1793 | 1792 | task_id = '".(int)$task_id."'"; |
1794 | - $result = Database::query($sql); |
|
1795 | - $row = Database::fetch_assoc($result); |
|
1796 | - |
|
1797 | - $date = $row['target_date']; |
|
1798 | - |
|
1799 | - $defaults = [ |
|
1800 | - 'task_user_id' => $user_id, |
|
1801 | - 'task_task_id' => $task_id, |
|
1802 | - 'task_day' => $date |
|
1803 | - ]; |
|
1804 | - $form = self::getTaskForm($blog_id); |
|
1805 | - $form->addHidden('old_task_id', $task_id); |
|
1806 | - $form->addHidden('old_user_id', $user_id); |
|
1807 | - $form->addHidden('old_target_date', $date); |
|
1808 | - $form->addHidden('assign_task_edit_submit', 'true'); |
|
1809 | - $form->setDefaults($defaults); |
|
1810 | - $form->display(); |
|
1811 | - } |
|
1812 | - |
|
1813 | - /** |
|
1814 | - * Assigns a task to a user in a blog |
|
1815 | - * |
|
1816 | - * @param Integer $blog_id |
|
1817 | - * @param Integer $user_id |
|
1818 | - * @param Integer $task_id |
|
1819 | - * @param Date $target_date |
|
1820 | - */ |
|
1821 | - public static function assign_task($blog_id, $user_id, $task_id, $target_date) |
|
1822 | - { |
|
1823 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
1824 | - $course_id = api_get_course_int_id(); |
|
1825 | - |
|
1826 | - $sql = " |
|
1793 | + $result = Database::query($sql); |
|
1794 | + $row = Database::fetch_assoc($result); |
|
1795 | + |
|
1796 | + $date = $row['target_date']; |
|
1797 | + |
|
1798 | + $defaults = [ |
|
1799 | + 'task_user_id' => $user_id, |
|
1800 | + 'task_task_id' => $task_id, |
|
1801 | + 'task_day' => $date |
|
1802 | + ]; |
|
1803 | + $form = self::getTaskForm($blog_id); |
|
1804 | + $form->addHidden('old_task_id', $task_id); |
|
1805 | + $form->addHidden('old_user_id', $user_id); |
|
1806 | + $form->addHidden('old_target_date', $date); |
|
1807 | + $form->addHidden('assign_task_edit_submit', 'true'); |
|
1808 | + $form->setDefaults($defaults); |
|
1809 | + $form->display(); |
|
1810 | + } |
|
1811 | + |
|
1812 | + /** |
|
1813 | + * Assigns a task to a user in a blog |
|
1814 | + * |
|
1815 | + * @param Integer $blog_id |
|
1816 | + * @param Integer $user_id |
|
1817 | + * @param Integer $task_id |
|
1818 | + * @param Date $target_date |
|
1819 | + */ |
|
1820 | + public static function assign_task($blog_id, $user_id, $task_id, $target_date) |
|
1821 | + { |
|
1822 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
1823 | + $course_id = api_get_course_int_id(); |
|
1824 | + |
|
1825 | + $sql = " |
|
1827 | 1826 | SELECT COUNT(*) as 'number' |
1828 | 1827 | FROM " . $tbl_blogs_tasks_rel_user . " |
1829 | 1828 | WHERE c_id = $course_id AND |
@@ -1832,11 +1831,11 @@ discard block |
||
1832 | 1831 | AND task_id = " . (int)$task_id . " |
1833 | 1832 | "; |
1834 | 1833 | |
1835 | - $result = Database::query($sql); |
|
1836 | - $row = Database::fetch_assoc($result); |
|
1834 | + $result = Database::query($sql); |
|
1835 | + $row = Database::fetch_assoc($result); |
|
1837 | 1836 | |
1838 | - if ($row['number'] == 0) { |
|
1839 | - $sql = " |
|
1837 | + if ($row['number'] == 0) { |
|
1838 | + $sql = " |
|
1840 | 1839 | INSERT INTO " . $tbl_blogs_tasks_rel_user . " ( |
1841 | 1840 | c_id, |
1842 | 1841 | blog_id, |
@@ -1851,9 +1850,9 @@ discard block |
||
1851 | 1850 | '" . Database::escape_string($target_date) . "' |
1852 | 1851 | )"; |
1853 | 1852 | |
1854 | - Database::query($sql); |
|
1855 | - } |
|
1856 | - } |
|
1853 | + Database::query($sql); |
|
1854 | + } |
|
1855 | + } |
|
1857 | 1856 | |
1858 | 1857 | /** |
1859 | 1858 | * @param $blog_id |
@@ -1873,11 +1872,11 @@ discard block |
||
1873 | 1872 | $old_task_id, |
1874 | 1873 | $old_target_date |
1875 | 1874 | ) { |
1876 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
1875 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
1877 | 1876 | |
1878 | - $course_id = api_get_course_int_id(); |
|
1877 | + $course_id = api_get_course_int_id(); |
|
1879 | 1878 | |
1880 | - $sql = "SELECT COUNT(*) as 'number' |
|
1879 | + $sql = "SELECT COUNT(*) as 'number' |
|
1881 | 1880 | FROM " . $tbl_blogs_tasks_rel_user . " |
1882 | 1881 | WHERE |
1883 | 1882 | c_id = $course_id AND |
@@ -1886,11 +1885,11 @@ discard block |
||
1886 | 1885 | task_id = " . (int)$task_id . " |
1887 | 1886 | "; |
1888 | 1887 | |
1889 | - $result = Database::query($sql); |
|
1890 | - $row = Database::fetch_assoc($result); |
|
1888 | + $result = Database::query($sql); |
|
1889 | + $row = Database::fetch_assoc($result); |
|
1891 | 1890 | |
1892 | - if ($row['number'] == 0 || ($row['number'] != 0 && $task_id == $old_task_id && $user_id == $old_user_id)) { |
|
1893 | - $sql = " |
|
1891 | + if ($row['number'] == 0 || ($row['number'] != 0 && $task_id == $old_task_id && $user_id == $old_user_id)) { |
|
1892 | + $sql = " |
|
1894 | 1893 | UPDATE " . $tbl_blogs_tasks_rel_user . " |
1895 | 1894 | SET |
1896 | 1895 | user_id = " . (int)$user_id . ", |
@@ -1903,76 +1902,76 @@ discard block |
||
1903 | 1902 | task_id = " . (int)$old_task_id . " AND |
1904 | 1903 | target_date = '" . Database::escape_string($old_target_date) . "' |
1905 | 1904 | "; |
1906 | - Database::query($sql); |
|
1907 | - } |
|
1908 | - } |
|
1909 | - |
|
1910 | - /** |
|
1911 | - * Displays a list with posts a user can select to execute his task. |
|
1912 | - * |
|
1913 | - * @param Integer $blog_id |
|
1914 | - * @param unknown_type $task_id |
|
1915 | - */ |
|
1916 | - public static function display_select_task_post($blog_id, $task_id) |
|
1905 | + Database::query($sql); |
|
1906 | + } |
|
1907 | + } |
|
1908 | + |
|
1909 | + /** |
|
1910 | + * Displays a list with posts a user can select to execute his task. |
|
1911 | + * |
|
1912 | + * @param Integer $blog_id |
|
1913 | + * @param unknown_type $task_id |
|
1914 | + */ |
|
1915 | + public static function display_select_task_post($blog_id, $task_id) |
|
1917 | 1916 | { |
1918 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1919 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
1920 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
1921 | - $course_id = api_get_course_int_id(); |
|
1917 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
1918 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
1919 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
1920 | + $course_id = api_get_course_int_id(); |
|
1922 | 1921 | |
1923 | 1922 | |
1924 | - $sql = "SELECT title, description FROM $tbl_blogs_tasks |
|
1923 | + $sql = "SELECT title, description FROM $tbl_blogs_tasks |
|
1925 | 1924 | WHERE task_id = '".(int)$task_id."' |
1926 | 1925 | AND c_id = $course_id"; |
1927 | - $result = Database::query($sql); |
|
1928 | - $row = Database::fetch_assoc($result); |
|
1929 | - // Get posts and authors |
|
1930 | - $sql = "SELECT post.*, user.lastname, user.firstname, user.username |
|
1926 | + $result = Database::query($sql); |
|
1927 | + $row = Database::fetch_assoc($result); |
|
1928 | + // Get posts and authors |
|
1929 | + $sql = "SELECT post.*, user.lastname, user.firstname, user.username |
|
1931 | 1930 | FROM $tbl_blogs_posts post |
1932 | 1931 | INNER JOIN $tbl_users user ON post.author_id = user.user_id |
1933 | 1932 | WHERE post.blog_id = '".(int)$blog_id."' AND post.c_id = $course_id |
1934 | 1933 | ORDER BY post_id DESC |
1935 | 1934 | LIMIT 0, 100"; |
1936 | - $result = Database::query($sql); |
|
1935 | + $result = Database::query($sql); |
|
1937 | 1936 | |
1938 | - // Display |
|
1939 | - echo '<span class="blogpost_title">' . get_lang('SelectTaskArticle') . ' "' . stripslashes($row['title']) . '"</span>'; |
|
1940 | - echo '<span style="font-style: italic;"">'.stripslashes($row['description']) . '</span><br><br>'; |
|
1937 | + // Display |
|
1938 | + echo '<span class="blogpost_title">' . get_lang('SelectTaskArticle') . ' "' . stripslashes($row['title']) . '"</span>'; |
|
1939 | + echo '<span style="font-style: italic;"">'.stripslashes($row['description']) . '</span><br><br>'; |
|
1941 | 1940 | |
1942 | - if (Database::num_rows($result) > 0) { |
|
1943 | - while($blog_post = Database::fetch_array($result)) { |
|
1944 | - $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES); |
|
1945 | - echo '<a href="blog.php?action=execute_task&blog_id=' . $blog_id . '&task_id=' . $task_id . '&post_id=' . $blog_post['post_id'] . '#add_comment">'.stripslashes($blog_post['title']) . '</a>, ' . get_lang('WrittenBy') . ' ' . stripslashes(Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username))) . '<br />'; |
|
1946 | - } |
|
1941 | + if (Database::num_rows($result) > 0) { |
|
1942 | + while($blog_post = Database::fetch_array($result)) { |
|
1943 | + $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES); |
|
1944 | + echo '<a href="blog.php?action=execute_task&blog_id=' . $blog_id . '&task_id=' . $task_id . '&post_id=' . $blog_post['post_id'] . '#add_comment">'.stripslashes($blog_post['title']) . '</a>, ' . get_lang('WrittenBy') . ' ' . stripslashes(Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username))) . '<br />'; |
|
1945 | + } |
|
1947 | 1946 | } else { |
1948 | 1947 | echo get_lang('NoArticles'); |
1949 | 1948 | } |
1950 | - } |
|
1951 | - |
|
1952 | - /** |
|
1953 | - * Subscribes a user to a given blog |
|
1954 | - * @author Toon Keppens |
|
1955 | - * |
|
1956 | - * @param Integer $blog_id |
|
1957 | - * @param Integer $user_id |
|
1958 | - */ |
|
1959 | - public static function set_user_subscribed($blog_id, $user_id) |
|
1949 | + } |
|
1950 | + |
|
1951 | + /** |
|
1952 | + * Subscribes a user to a given blog |
|
1953 | + * @author Toon Keppens |
|
1954 | + * |
|
1955 | + * @param Integer $blog_id |
|
1956 | + * @param Integer $user_id |
|
1957 | + */ |
|
1958 | + public static function set_user_subscribed($blog_id, $user_id) |
|
1960 | 1959 | { |
1961 | - // Init |
|
1962 | - $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
1963 | - $tbl_user_permissions = Database::get_course_table(TABLE_PERMISSION_USER); |
|
1960 | + // Init |
|
1961 | + $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
1962 | + $tbl_user_permissions = Database::get_course_table(TABLE_PERMISSION_USER); |
|
1964 | 1963 | |
1965 | - $course_id = api_get_course_int_id(); |
|
1964 | + $course_id = api_get_course_int_id(); |
|
1966 | 1965 | |
1967 | - // Subscribe the user |
|
1968 | - $sql = "INSERT INTO $tbl_blogs_rel_user (c_id, blog_id, user_id ) |
|
1966 | + // Subscribe the user |
|
1967 | + $sql = "INSERT INTO $tbl_blogs_rel_user (c_id, blog_id, user_id ) |
|
1969 | 1968 | VALUES ($course_id, '".(int)$blog_id."', '".(int)$user_id."');"; |
1970 | - Database::query($sql); |
|
1969 | + Database::query($sql); |
|
1971 | 1970 | |
1972 | - // Give this user basic rights |
|
1973 | - $sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action) |
|
1971 | + // Give this user basic rights |
|
1972 | + $sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action) |
|
1974 | 1973 | VALUES ($course_id, '".(int)$user_id."','BLOG_" . (int)$blog_id."','article_add')"; |
1975 | - Database::query($sql); |
|
1974 | + Database::query($sql); |
|
1976 | 1975 | |
1977 | 1976 | $id = Database::insert_id(); |
1978 | 1977 | if ($id) { |
@@ -1980,9 +1979,9 @@ discard block |
||
1980 | 1979 | Database::query($sql); |
1981 | 1980 | } |
1982 | 1981 | |
1983 | - $sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action) |
|
1982 | + $sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action) |
|
1984 | 1983 | VALUES ($course_id, '".(int)$user_id."','BLOG_" . (int)$blog_id."','article_comments_add')"; |
1985 | - Database::query($sql); |
|
1984 | + Database::query($sql); |
|
1986 | 1985 | |
1987 | 1986 | $id = Database::insert_id(); |
1988 | 1987 | if ($id) { |
@@ -1990,197 +1989,197 @@ discard block |
||
1990 | 1989 | Database::query($sql); |
1991 | 1990 | } |
1992 | 1991 | |
1993 | - } |
|
1992 | + } |
|
1994 | 1993 | |
1995 | - /** |
|
1996 | - * Unsubscribe a user from a given blog |
|
1997 | - * @author Toon Keppens |
|
1998 | - * |
|
1999 | - * @param Integer $blog_id |
|
2000 | - * @param Integer $user_id |
|
2001 | - */ |
|
2002 | - public static function set_user_unsubscribed($blog_id, $user_id) |
|
1994 | + /** |
|
1995 | + * Unsubscribe a user from a given blog |
|
1996 | + * @author Toon Keppens |
|
1997 | + * |
|
1998 | + * @param Integer $blog_id |
|
1999 | + * @param Integer $user_id |
|
2000 | + */ |
|
2001 | + public static function set_user_unsubscribed($blog_id, $user_id) |
|
2003 | 2002 | { |
2004 | - // Init |
|
2003 | + // Init |
|
2005 | 2004 | $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
2006 | 2005 | $tbl_user_permissions = Database::get_course_table(TABLE_PERMISSION_USER); |
2007 | 2006 | |
2008 | - // Unsubscribe the user |
|
2009 | - $sql = "DELETE FROM $tbl_blogs_rel_user |
|
2007 | + // Unsubscribe the user |
|
2008 | + $sql = "DELETE FROM $tbl_blogs_rel_user |
|
2010 | 2009 | WHERE blog_id = '".(int)$blog_id."' AND user_id = '".(int)$user_id."'"; |
2011 | - Database::query($sql); |
|
2010 | + Database::query($sql); |
|
2012 | 2011 | |
2013 | - // Remove this user's permissions. |
|
2014 | - $sql = "DELETE FROM $tbl_user_permissions |
|
2012 | + // Remove this user's permissions. |
|
2013 | + $sql = "DELETE FROM $tbl_user_permissions |
|
2015 | 2014 | WHERE user_id = '".(int)$user_id."'"; |
2016 | - Database::query($sql); |
|
2017 | - } |
|
2018 | - |
|
2019 | - /** |
|
2020 | - * Displays the form to register users in a blog (in a course) |
|
2021 | - * The listed users are users subcribed in the course. |
|
2022 | - * @author Toon Keppens |
|
2023 | - * |
|
2024 | - * @param Integer $blog_id |
|
2025 | - * |
|
2026 | - * @return Html Form with sortable table with users to subcribe in a blog, in a course. |
|
2027 | - */ |
|
2028 | - public static function display_form_user_subscribe($blog_id) |
|
2029 | - { |
|
2030 | - $_course = api_get_course_info(); |
|
2031 | - $is_western_name_order = api_is_western_name_order(); |
|
2032 | - $session_id = api_get_session_id(); |
|
2033 | - $course_id = $_course['real_id']; |
|
2034 | - |
|
2035 | - $currentCourse = $_course['code']; |
|
2036 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
2037 | - $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
2038 | - |
|
2039 | - echo '<legend>'.get_lang('SubscribeMembers').'</legend>'; |
|
2040 | - |
|
2041 | - $properties["width"] = "100%"; |
|
2042 | - |
|
2043 | - // Get blog members' id. |
|
2044 | - $sql = "SELECT user.user_id FROM $tbl_users user |
|
2015 | + Database::query($sql); |
|
2016 | + } |
|
2017 | + |
|
2018 | + /** |
|
2019 | + * Displays the form to register users in a blog (in a course) |
|
2020 | + * The listed users are users subcribed in the course. |
|
2021 | + * @author Toon Keppens |
|
2022 | + * |
|
2023 | + * @param Integer $blog_id |
|
2024 | + * |
|
2025 | + * @return Html Form with sortable table with users to subcribe in a blog, in a course. |
|
2026 | + */ |
|
2027 | + public static function display_form_user_subscribe($blog_id) |
|
2028 | + { |
|
2029 | + $_course = api_get_course_info(); |
|
2030 | + $is_western_name_order = api_is_western_name_order(); |
|
2031 | + $session_id = api_get_session_id(); |
|
2032 | + $course_id = $_course['real_id']; |
|
2033 | + |
|
2034 | + $currentCourse = $_course['code']; |
|
2035 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
2036 | + $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
2037 | + |
|
2038 | + echo '<legend>'.get_lang('SubscribeMembers').'</legend>'; |
|
2039 | + |
|
2040 | + $properties["width"] = "100%"; |
|
2041 | + |
|
2042 | + // Get blog members' id. |
|
2043 | + $sql = "SELECT user.user_id FROM $tbl_users user |
|
2045 | 2044 | INNER JOIN $tbl_blogs_rel_user blogs_rel_user |
2046 | 2045 | ON user.user_id = blogs_rel_user.user_id |
2047 | 2046 | WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".intval($blog_id)."'"; |
2048 | - $result = Database::query($sql); |
|
2049 | - |
|
2050 | - $blog_member_ids = array(); |
|
2051 | - while($user = Database::fetch_array($result)) { |
|
2052 | - $blog_member_ids[] = $user['user_id']; |
|
2053 | - } |
|
2054 | - |
|
2055 | - // Set table headers |
|
2056 | - $column_header[] = array ('', false, ''); |
|
2057 | - if ($is_western_name_order) { |
|
2058 | - $column_header[] = array(get_lang('FirstName'), true, ''); |
|
2059 | - $column_header[] = array(get_lang('LastName'), true, ''); |
|
2060 | - } else { |
|
2061 | - $column_header[] = array(get_lang('LastName'), true, ''); |
|
2062 | - $column_header[] = array(get_lang('FirstName'), true, ''); |
|
2063 | - } |
|
2064 | - $column_header[] = array(get_lang('Email'), false, ''); |
|
2065 | - $column_header[] = array(get_lang('Register'), false, ''); |
|
2047 | + $result = Database::query($sql); |
|
2048 | + |
|
2049 | + $blog_member_ids = array(); |
|
2050 | + while($user = Database::fetch_array($result)) { |
|
2051 | + $blog_member_ids[] = $user['user_id']; |
|
2052 | + } |
|
2053 | + |
|
2054 | + // Set table headers |
|
2055 | + $column_header[] = array ('', false, ''); |
|
2056 | + if ($is_western_name_order) { |
|
2057 | + $column_header[] = array(get_lang('FirstName'), true, ''); |
|
2058 | + $column_header[] = array(get_lang('LastName'), true, ''); |
|
2059 | + } else { |
|
2060 | + $column_header[] = array(get_lang('LastName'), true, ''); |
|
2061 | + $column_header[] = array(get_lang('FirstName'), true, ''); |
|
2062 | + } |
|
2063 | + $column_header[] = array(get_lang('Email'), false, ''); |
|
2064 | + $column_header[] = array(get_lang('Register'), false, ''); |
|
2066 | 2065 | |
2067 | 2066 | $student_list = CourseManager:: get_student_list_from_course_code( |
2068 | 2067 | $currentCourse, |
2069 | 2068 | false, |
2070 | 2069 | $session_id |
2071 | 2070 | ); |
2072 | - $user_data = array(); |
|
2073 | - |
|
2074 | - // Add users that are not in this blog to the list. |
|
2075 | - foreach ($student_list as $key=>$user) { |
|
2076 | - if(isset($user['id_user'])) { |
|
2077 | - $user['user_id'] = $user['id_user']; |
|
2078 | - } |
|
2079 | - if(!in_array($user['user_id'],$blog_member_ids)) { |
|
2080 | - $a_infosUser = api_get_user_info($user['user_id']); |
|
2081 | - $row = array (); |
|
2082 | - $row[] = '<input type="checkbox" name="user[]" value="' . $a_infosUser['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "subscribe") ? ' checked="checked" ' : '') . '/>'; |
|
2083 | - $username = api_htmlentities(sprintf(get_lang('LoginX'), $a_infosUser["username"]), ENT_QUOTES); |
|
2084 | - if ($is_western_name_order) { |
|
2085 | - $row[] = $a_infosUser["firstname"]; |
|
2086 | - $row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username)); |
|
2087 | - } else { |
|
2088 | - $row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username)); |
|
2089 | - $row[] = $a_infosUser["firstname"]; |
|
2090 | - } |
|
2091 | - $row[] = Display::icon_mailto_link($a_infosUser["email"]); |
|
2092 | - |
|
2093 | - //Link to register users |
|
2094 | - if ($a_infosUser["user_id"] != $_SESSION['_user']['user_id']){ |
|
2095 | - $row[] = "<a class=\"btn btn-primary \" href=\"" .api_get_self()."?action=manage_members&blog_id=$blog_id®ister=yes&user_id=" . $a_infosUser["user_id"]."\">" . get_lang('Register')."</a>"; |
|
2096 | - } else { |
|
2097 | - $row[] = ''; |
|
2098 | - } |
|
2099 | - $user_data[] = $row; |
|
2100 | - } |
|
2101 | - } |
|
2102 | - |
|
2103 | - // Display |
|
2104 | - $query_vars['action'] = 'manage_members'; |
|
2105 | - $query_vars['blog_id'] = $blog_id; |
|
2106 | - echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">'; |
|
2107 | - Display::display_sortable_table($column_header, $user_data,null,null,$query_vars); |
|
2108 | - $link = ''; |
|
2109 | - $link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']) . '&' : ''; |
|
2110 | - $link .= "blog_id=$blog_id&"; |
|
2111 | - |
|
2112 | - echo '<a href="blog.php?' . $link . 'selectall=subscribe">' . get_lang('SelectAll') . '</a> - '; |
|
2113 | - echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> '; |
|
2114 | - echo get_lang('WithSelected') . ' : '; |
|
2115 | - echo '<select name="action">'; |
|
2116 | - echo '<option value="select_subscribe">' . get_lang('Register') . '</option>'; |
|
2117 | - echo '</select>'; |
|
2118 | - echo '<input type="hidden" name="register" value="true" />'; |
|
2119 | - echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>'; |
|
2120 | - echo '</form>'; |
|
2121 | - } |
|
2122 | - |
|
2123 | - /** |
|
2124 | - * Displays the form to register users in a blog (in a course) |
|
2125 | - * The listed users are users subcribed in the course. |
|
2126 | - * @author Toon Keppens |
|
2127 | - * |
|
2128 | - * @param Integer $blog_id |
|
2129 | - * |
|
2130 | - * @return false|null Form with sortable table with users to unsubcribe from a blog. |
|
2131 | - */ |
|
2132 | - public static function display_form_user_unsubscribe ($blog_id) |
|
2133 | - { |
|
2134 | - $_user = api_get_user_info(); |
|
2135 | - $is_western_name_order = api_is_western_name_order(); |
|
2136 | - |
|
2137 | - // Init |
|
2138 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
2139 | - $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
2140 | - |
|
2141 | - echo '<legend>'.get_lang('UnsubscribeMembers').'</legend>'; |
|
2142 | - |
|
2143 | - $properties["width"] = "100%"; |
|
2144 | - //table column titles |
|
2145 | - $column_header[] = array ('', false, ''); |
|
2146 | - if ($is_western_name_order) { |
|
2147 | - $column_header[] = array (get_lang('FirstName'), true, ''); |
|
2148 | - $column_header[] = array (get_lang('LastName'), true, ''); |
|
2149 | - } else { |
|
2150 | - $column_header[] = array (get_lang('LastName'), true, ''); |
|
2151 | - $column_header[] = array (get_lang('FirstName'), true, ''); |
|
2152 | - } |
|
2153 | - $column_header[] = array (get_lang('Email'), false, ''); |
|
2154 | - $column_header[] = array (get_lang('TaskManager'), true, ''); |
|
2155 | - $column_header[] = array (get_lang('UnRegister'), false, ''); |
|
2156 | - |
|
2157 | - $course_id = api_get_course_int_id(); |
|
2158 | - |
|
2159 | - $sql = "SELECT user.user_id, user.lastname, user.firstname, user.email, user.username |
|
2071 | + $user_data = array(); |
|
2072 | + |
|
2073 | + // Add users that are not in this blog to the list. |
|
2074 | + foreach ($student_list as $key=>$user) { |
|
2075 | + if(isset($user['id_user'])) { |
|
2076 | + $user['user_id'] = $user['id_user']; |
|
2077 | + } |
|
2078 | + if(!in_array($user['user_id'],$blog_member_ids)) { |
|
2079 | + $a_infosUser = api_get_user_info($user['user_id']); |
|
2080 | + $row = array (); |
|
2081 | + $row[] = '<input type="checkbox" name="user[]" value="' . $a_infosUser['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "subscribe") ? ' checked="checked" ' : '') . '/>'; |
|
2082 | + $username = api_htmlentities(sprintf(get_lang('LoginX'), $a_infosUser["username"]), ENT_QUOTES); |
|
2083 | + if ($is_western_name_order) { |
|
2084 | + $row[] = $a_infosUser["firstname"]; |
|
2085 | + $row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username)); |
|
2086 | + } else { |
|
2087 | + $row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username)); |
|
2088 | + $row[] = $a_infosUser["firstname"]; |
|
2089 | + } |
|
2090 | + $row[] = Display::icon_mailto_link($a_infosUser["email"]); |
|
2091 | + |
|
2092 | + //Link to register users |
|
2093 | + if ($a_infosUser["user_id"] != $_SESSION['_user']['user_id']){ |
|
2094 | + $row[] = "<a class=\"btn btn-primary \" href=\"" .api_get_self()."?action=manage_members&blog_id=$blog_id®ister=yes&user_id=" . $a_infosUser["user_id"]."\">" . get_lang('Register')."</a>"; |
|
2095 | + } else { |
|
2096 | + $row[] = ''; |
|
2097 | + } |
|
2098 | + $user_data[] = $row; |
|
2099 | + } |
|
2100 | + } |
|
2101 | + |
|
2102 | + // Display |
|
2103 | + $query_vars['action'] = 'manage_members'; |
|
2104 | + $query_vars['blog_id'] = $blog_id; |
|
2105 | + echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">'; |
|
2106 | + Display::display_sortable_table($column_header, $user_data,null,null,$query_vars); |
|
2107 | + $link = ''; |
|
2108 | + $link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']) . '&' : ''; |
|
2109 | + $link .= "blog_id=$blog_id&"; |
|
2110 | + |
|
2111 | + echo '<a href="blog.php?' . $link . 'selectall=subscribe">' . get_lang('SelectAll') . '</a> - '; |
|
2112 | + echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> '; |
|
2113 | + echo get_lang('WithSelected') . ' : '; |
|
2114 | + echo '<select name="action">'; |
|
2115 | + echo '<option value="select_subscribe">' . get_lang('Register') . '</option>'; |
|
2116 | + echo '</select>'; |
|
2117 | + echo '<input type="hidden" name="register" value="true" />'; |
|
2118 | + echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>'; |
|
2119 | + echo '</form>'; |
|
2120 | + } |
|
2121 | + |
|
2122 | + /** |
|
2123 | + * Displays the form to register users in a blog (in a course) |
|
2124 | + * The listed users are users subcribed in the course. |
|
2125 | + * @author Toon Keppens |
|
2126 | + * |
|
2127 | + * @param Integer $blog_id |
|
2128 | + * |
|
2129 | + * @return false|null Form with sortable table with users to unsubcribe from a blog. |
|
2130 | + */ |
|
2131 | + public static function display_form_user_unsubscribe ($blog_id) |
|
2132 | + { |
|
2133 | + $_user = api_get_user_info(); |
|
2134 | + $is_western_name_order = api_is_western_name_order(); |
|
2135 | + |
|
2136 | + // Init |
|
2137 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
2138 | + $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); |
|
2139 | + |
|
2140 | + echo '<legend>'.get_lang('UnsubscribeMembers').'</legend>'; |
|
2141 | + |
|
2142 | + $properties["width"] = "100%"; |
|
2143 | + //table column titles |
|
2144 | + $column_header[] = array ('', false, ''); |
|
2145 | + if ($is_western_name_order) { |
|
2146 | + $column_header[] = array (get_lang('FirstName'), true, ''); |
|
2147 | + $column_header[] = array (get_lang('LastName'), true, ''); |
|
2148 | + } else { |
|
2149 | + $column_header[] = array (get_lang('LastName'), true, ''); |
|
2150 | + $column_header[] = array (get_lang('FirstName'), true, ''); |
|
2151 | + } |
|
2152 | + $column_header[] = array (get_lang('Email'), false, ''); |
|
2153 | + $column_header[] = array (get_lang('TaskManager'), true, ''); |
|
2154 | + $column_header[] = array (get_lang('UnRegister'), false, ''); |
|
2155 | + |
|
2156 | + $course_id = api_get_course_int_id(); |
|
2157 | + |
|
2158 | + $sql = "SELECT user.user_id, user.lastname, user.firstname, user.email, user.username |
|
2160 | 2159 | FROM $tbl_users user INNER JOIN $tbl_blogs_rel_user blogs_rel_user |
2161 | 2160 | ON user.user_id = blogs_rel_user.user_id |
2162 | 2161 | WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".(int)$blog_id."'"; |
2163 | 2162 | |
2164 | - if (!($sql_result = Database::query($sql))) { |
|
2165 | - return false; |
|
2166 | - } |
|
2167 | - |
|
2168 | - $user_data = array (); |
|
2169 | - |
|
2170 | - while ($myrow = Database::fetch_array($sql_result)) { |
|
2171 | - $row = array (); |
|
2172 | - $row[] = '<input type="checkbox" name="user[]" value="' . $myrow['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "unsubscribe") ? ' checked="checked" ' : '') . '/>'; |
|
2173 | - $username = api_htmlentities(sprintf(get_lang('LoginX'), $myrow["username"]), ENT_QUOTES); |
|
2174 | - if ($is_western_name_order) { |
|
2175 | - $row[] = $myrow["firstname"]; |
|
2176 | - $row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username)); |
|
2177 | - } else { |
|
2178 | - $row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username)); |
|
2179 | - $row[] = $myrow["firstname"]; |
|
2180 | - } |
|
2181 | - $row[] = Display::icon_mailto_link($myrow["email"]); |
|
2182 | - |
|
2183 | - $sql = "SELECT bt.title task |
|
2163 | + if (!($sql_result = Database::query($sql))) { |
|
2164 | + return false; |
|
2165 | + } |
|
2166 | + |
|
2167 | + $user_data = array (); |
|
2168 | + |
|
2169 | + while ($myrow = Database::fetch_array($sql_result)) { |
|
2170 | + $row = array (); |
|
2171 | + $row[] = '<input type="checkbox" name="user[]" value="' . $myrow['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "unsubscribe") ? ' checked="checked" ' : '') . '/>'; |
|
2172 | + $username = api_htmlentities(sprintf(get_lang('LoginX'), $myrow["username"]), ENT_QUOTES); |
|
2173 | + if ($is_western_name_order) { |
|
2174 | + $row[] = $myrow["firstname"]; |
|
2175 | + $row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username)); |
|
2176 | + } else { |
|
2177 | + $row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username)); |
|
2178 | + $row[] = $myrow["firstname"]; |
|
2179 | + } |
|
2180 | + $row[] = Display::icon_mailto_link($myrow["email"]); |
|
2181 | + |
|
2182 | + $sql = "SELECT bt.title task |
|
2184 | 2183 | FROM " . Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER) . " btu |
2185 | 2184 | INNER JOIN " . Database::get_course_table(TABLE_BLOGS_TASKS) . " bt |
2186 | 2185 | ON btu.task_id = bt.task_id |
@@ -2188,157 +2187,157 @@ discard block |
||
2188 | 2187 | bt.c_id = $course_id AND |
2189 | 2188 | btu.blog_id = $blog_id AND |
2190 | 2189 | btu.user_id = " . $myrow['user_id']; |
2191 | - $sql_res = Database::query($sql); |
|
2192 | - |
|
2193 | - $task = ''; |
|
2194 | - |
|
2195 | - while($r = Database::fetch_array($sql_res)) { |
|
2196 | - $task .= stripslashes($r['task']) . ', '; |
|
2197 | - } |
|
2198 | - //echo $task; |
|
2199 | - $task = (api_strlen(trim($task)) != 0) ? api_substr($task, 0, api_strlen($task) - 2) : get_lang('Reader'); |
|
2200 | - $row[] = $task; |
|
2201 | - //Link to register users |
|
2202 | - |
|
2203 | - if ($myrow["user_id"] != $_user['user_id']) { |
|
2204 | - $row[] = "<a class=\"btn btn-primary\" href=\"" .api_get_self()."?action=manage_members&blog_id=$blog_id&unregister=yes&user_id=" . $myrow['user_id']."\">" . get_lang('UnRegister')."</a>"; |
|
2205 | - } else { |
|
2206 | - $row[] = ''; |
|
2207 | - } |
|
2208 | - |
|
2209 | - $user_data[] = $row; |
|
2210 | - } |
|
2211 | - |
|
2212 | - $query_vars['action'] = 'manage_members'; |
|
2213 | - $query_vars['blog_id'] = $blog_id; |
|
2214 | - echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">'; |
|
2215 | - Display::display_sortable_table($column_header, $user_data,null,null,$query_vars); |
|
2216 | - $link = ''; |
|
2217 | - $link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']). '&' : ''; |
|
2218 | - $link .= "blog_id=$blog_id&"; |
|
2219 | - |
|
2220 | - echo '<a href="blog.php?' . $link . 'selectall=unsubscribe">' . get_lang('SelectAll') . '</a> - '; |
|
2221 | - echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> '; |
|
2222 | - echo get_lang('WithSelected') . ' : '; |
|
2223 | - echo '<select name="action">'; |
|
2224 | - echo '<option value="select_unsubscribe">' . get_lang('UnRegister') . '</option>'; |
|
2225 | - echo '</select>'; |
|
2226 | - echo '<input type="hidden" name="unregister" value="true" />'; |
|
2227 | - echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>'; |
|
2228 | - echo '</form>'; |
|
2229 | - } |
|
2230 | - |
|
2231 | - /** |
|
2232 | - * Displays a matrix with selectboxes. On the left: users, on top: possible rights. |
|
2233 | - * The blog admin can thus select what a certain user can do in the current blog |
|
2234 | - * |
|
2235 | - * @param Integer $blog_id |
|
2236 | - */ |
|
2237 | - public static function display_form_user_rights ($blog_id) |
|
2190 | + $sql_res = Database::query($sql); |
|
2191 | + |
|
2192 | + $task = ''; |
|
2193 | + |
|
2194 | + while($r = Database::fetch_array($sql_res)) { |
|
2195 | + $task .= stripslashes($r['task']) . ', '; |
|
2196 | + } |
|
2197 | + //echo $task; |
|
2198 | + $task = (api_strlen(trim($task)) != 0) ? api_substr($task, 0, api_strlen($task) - 2) : get_lang('Reader'); |
|
2199 | + $row[] = $task; |
|
2200 | + //Link to register users |
|
2201 | + |
|
2202 | + if ($myrow["user_id"] != $_user['user_id']) { |
|
2203 | + $row[] = "<a class=\"btn btn-primary\" href=\"" .api_get_self()."?action=manage_members&blog_id=$blog_id&unregister=yes&user_id=" . $myrow['user_id']."\">" . get_lang('UnRegister')."</a>"; |
|
2204 | + } else { |
|
2205 | + $row[] = ''; |
|
2206 | + } |
|
2207 | + |
|
2208 | + $user_data[] = $row; |
|
2209 | + } |
|
2210 | + |
|
2211 | + $query_vars['action'] = 'manage_members'; |
|
2212 | + $query_vars['blog_id'] = $blog_id; |
|
2213 | + echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">'; |
|
2214 | + Display::display_sortable_table($column_header, $user_data,null,null,$query_vars); |
|
2215 | + $link = ''; |
|
2216 | + $link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']). '&' : ''; |
|
2217 | + $link .= "blog_id=$blog_id&"; |
|
2218 | + |
|
2219 | + echo '<a href="blog.php?' . $link . 'selectall=unsubscribe">' . get_lang('SelectAll') . '</a> - '; |
|
2220 | + echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> '; |
|
2221 | + echo get_lang('WithSelected') . ' : '; |
|
2222 | + echo '<select name="action">'; |
|
2223 | + echo '<option value="select_unsubscribe">' . get_lang('UnRegister') . '</option>'; |
|
2224 | + echo '</select>'; |
|
2225 | + echo '<input type="hidden" name="unregister" value="true" />'; |
|
2226 | + echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>'; |
|
2227 | + echo '</form>'; |
|
2228 | + } |
|
2229 | + |
|
2230 | + /** |
|
2231 | + * Displays a matrix with selectboxes. On the left: users, on top: possible rights. |
|
2232 | + * The blog admin can thus select what a certain user can do in the current blog |
|
2233 | + * |
|
2234 | + * @param Integer $blog_id |
|
2235 | + */ |
|
2236 | + public static function display_form_user_rights ($blog_id) |
|
2237 | + { |
|
2238 | + echo '<legend>'.get_lang('RightsManager').'</legend>'; |
|
2239 | + echo '<br />'; |
|
2240 | + |
|
2241 | + // Integration of patricks permissions system. |
|
2242 | + require_once api_get_path(SYS_CODE_PATH).'permissions/blog_permissions.inc.php'; |
|
2243 | + } |
|
2244 | + |
|
2245 | + /** |
|
2246 | + * Displays the form to create a new post |
|
2247 | + * @author Toon Keppens |
|
2248 | + * |
|
2249 | + * @param Integer $blog_id |
|
2250 | + * @param integer $post_id |
|
2251 | + */ |
|
2252 | + public static function display_new_comment_form($blog_id, $post_id, $title) |
|
2238 | 2253 | { |
2239 | - echo '<legend>'.get_lang('RightsManager').'</legend>'; |
|
2240 | - echo '<br />'; |
|
2241 | - |
|
2242 | - // Integration of patricks permissions system. |
|
2243 | - require_once api_get_path(SYS_CODE_PATH).'permissions/blog_permissions.inc.php'; |
|
2244 | - } |
|
2245 | - |
|
2246 | - /** |
|
2247 | - * Displays the form to create a new post |
|
2248 | - * @author Toon Keppens |
|
2249 | - * |
|
2250 | - * @param Integer $blog_id |
|
2251 | - * @param integer $post_id |
|
2252 | - */ |
|
2253 | - public static function display_new_comment_form($blog_id, $post_id, $title) |
|
2254 | - { |
|
2255 | - $form = new FormValidator( |
|
2256 | - 'add_post', |
|
2257 | - 'post', |
|
2258 | - api_get_path(WEB_CODE_PATH)."blog/blog.php?action=view_post&blog_id=" . intval($blog_id) . "&post_id=".intval($post_id)."&".api_get_cidreq(), |
|
2259 | - null, |
|
2260 | - array('enctype' => 'multipart/form-data') |
|
2261 | - ); |
|
2262 | - |
|
2263 | - $header = get_lang('AddNewComment'); |
|
2264 | - if (isset($_GET['task_id'])) { |
|
2265 | - $header = get_lang('ExecuteThisTask'); |
|
2266 | - } |
|
2267 | - $form->addHeader($header); |
|
2268 | - $form->addText('title', get_lang('Title')); |
|
2269 | - |
|
2270 | - $config = array(); |
|
2271 | - if (!api_is_allowed_to_edit()) { |
|
2272 | - $config['ToolbarSet'] = 'ProjectComment'; |
|
2273 | - } else { |
|
2274 | - $config['ToolbarSet'] = 'ProjectCommentStudent'; |
|
2275 | - } |
|
2276 | - $form->addHtmlEditor('comment', get_lang('Comment'), false, false, $config); |
|
2277 | - $form->addFile('user_upload', get_lang('AddAnAttachment')); |
|
2278 | - |
|
2279 | - $form->addTextarea('post_file_comment', get_lang('FileComment')); |
|
2280 | - |
|
2281 | - $form->addHidden('action', null); |
|
2282 | - $form->addHidden('comment_parent_id', 0); |
|
2283 | - |
|
2284 | - if (isset($_GET['task_id'])) { |
|
2285 | - $form->addHidden('new_task_execution_submit', 'true'); |
|
2286 | - $form->addHidden('task_id', intval($_GET['task_id'])); |
|
2287 | - } else { |
|
2288 | - $form->addHidden('new_comment_submit', 'true'); |
|
2289 | - } |
|
2290 | - $form->addButton('save', get_lang('Save')); |
|
2291 | - $form->display(); |
|
2292 | - } |
|
2293 | - |
|
2294 | - |
|
2295 | - /** |
|
2296 | - * show the calender of the given month |
|
2297 | - * @author Patrick Cool |
|
2298 | - * @author Toon Keppens |
|
2299 | - * |
|
2300 | - * @param Integer $month: the integer value of the month we are viewing |
|
2301 | - * @param Integer $year: the 4-digit year indication e.g. 2005 |
|
2302 | - * |
|
2303 | - * @return html code |
|
2304 | - */ |
|
2305 | - public static function display_minimonthcalendar($month, $year, $blog_id) |
|
2306 | - { |
|
2307 | - // Init |
|
2308 | - $_user = api_get_user_info(); |
|
2309 | - global $DaysShort; |
|
2310 | - global $MonthsLong; |
|
2311 | - |
|
2312 | - $posts = array(); |
|
2313 | - $tasks = array(); |
|
2314 | - |
|
2315 | - $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
2316 | - $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
2317 | - $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
2318 | - $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
2319 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
2320 | - |
|
2321 | - $course_id = api_get_course_int_id(); |
|
2322 | - |
|
2323 | - //Handle leap year |
|
2324 | - $numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); |
|
2325 | - |
|
2326 | - if(($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0)) |
|
2327 | - $numberofdays[2] = 29; |
|
2328 | - |
|
2329 | - //Get the first day of the month |
|
2330 | - $dayone = getdate(mktime(0, 0, 0, $month, 1, $year)); |
|
2331 | - $monthName = $MonthsLong[$month-1]; |
|
2332 | - |
|
2333 | - //Start the week on monday |
|
2334 | - $startdayofweek = $dayone['wday'] <> 0 ? ($dayone['wday'] - 1) : 6; |
|
2335 | - $blogId = isset($_GET['blog_id']) ? intval($_GET['blog_id']) : null; |
|
2336 | - $filter = isset($_GET['filter']) ? Security::remove_XSS($_GET['filter']) : null; |
|
2337 | - $backwardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 1 ? 12 : $month -1)."&year=". ($month == 1 ? $year -1 : $year); |
|
2338 | - $forewardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 12 ? 1 : $month +1)."&year=". ($month == 12 ? $year +1 : $year); |
|
2339 | - |
|
2340 | - // Get posts for this month |
|
2341 | - $sql = "SELECT post.*, DAYOFMONTH(date_creation) as post_day, user.lastname, user.firstname |
|
2254 | + $form = new FormValidator( |
|
2255 | + 'add_post', |
|
2256 | + 'post', |
|
2257 | + api_get_path(WEB_CODE_PATH)."blog/blog.php?action=view_post&blog_id=" . intval($blog_id) . "&post_id=".intval($post_id)."&".api_get_cidreq(), |
|
2258 | + null, |
|
2259 | + array('enctype' => 'multipart/form-data') |
|
2260 | + ); |
|
2261 | + |
|
2262 | + $header = get_lang('AddNewComment'); |
|
2263 | + if (isset($_GET['task_id'])) { |
|
2264 | + $header = get_lang('ExecuteThisTask'); |
|
2265 | + } |
|
2266 | + $form->addHeader($header); |
|
2267 | + $form->addText('title', get_lang('Title')); |
|
2268 | + |
|
2269 | + $config = array(); |
|
2270 | + if (!api_is_allowed_to_edit()) { |
|
2271 | + $config['ToolbarSet'] = 'ProjectComment'; |
|
2272 | + } else { |
|
2273 | + $config['ToolbarSet'] = 'ProjectCommentStudent'; |
|
2274 | + } |
|
2275 | + $form->addHtmlEditor('comment', get_lang('Comment'), false, false, $config); |
|
2276 | + $form->addFile('user_upload', get_lang('AddAnAttachment')); |
|
2277 | + |
|
2278 | + $form->addTextarea('post_file_comment', get_lang('FileComment')); |
|
2279 | + |
|
2280 | + $form->addHidden('action', null); |
|
2281 | + $form->addHidden('comment_parent_id', 0); |
|
2282 | + |
|
2283 | + if (isset($_GET['task_id'])) { |
|
2284 | + $form->addHidden('new_task_execution_submit', 'true'); |
|
2285 | + $form->addHidden('task_id', intval($_GET['task_id'])); |
|
2286 | + } else { |
|
2287 | + $form->addHidden('new_comment_submit', 'true'); |
|
2288 | + } |
|
2289 | + $form->addButton('save', get_lang('Save')); |
|
2290 | + $form->display(); |
|
2291 | + } |
|
2292 | + |
|
2293 | + |
|
2294 | + /** |
|
2295 | + * show the calender of the given month |
|
2296 | + * @author Patrick Cool |
|
2297 | + * @author Toon Keppens |
|
2298 | + * |
|
2299 | + * @param Integer $month: the integer value of the month we are viewing |
|
2300 | + * @param Integer $year: the 4-digit year indication e.g. 2005 |
|
2301 | + * |
|
2302 | + * @return html code |
|
2303 | + */ |
|
2304 | + public static function display_minimonthcalendar($month, $year, $blog_id) |
|
2305 | + { |
|
2306 | + // Init |
|
2307 | + $_user = api_get_user_info(); |
|
2308 | + global $DaysShort; |
|
2309 | + global $MonthsLong; |
|
2310 | + |
|
2311 | + $posts = array(); |
|
2312 | + $tasks = array(); |
|
2313 | + |
|
2314 | + $tbl_users = Database::get_main_table(TABLE_MAIN_USER); |
|
2315 | + $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
2316 | + $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
|
2317 | + $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
2318 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
2319 | + |
|
2320 | + $course_id = api_get_course_int_id(); |
|
2321 | + |
|
2322 | + //Handle leap year |
|
2323 | + $numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); |
|
2324 | + |
|
2325 | + if(($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0)) |
|
2326 | + $numberofdays[2] = 29; |
|
2327 | + |
|
2328 | + //Get the first day of the month |
|
2329 | + $dayone = getdate(mktime(0, 0, 0, $month, 1, $year)); |
|
2330 | + $monthName = $MonthsLong[$month-1]; |
|
2331 | + |
|
2332 | + //Start the week on monday |
|
2333 | + $startdayofweek = $dayone['wday'] <> 0 ? ($dayone['wday'] - 1) : 6; |
|
2334 | + $blogId = isset($_GET['blog_id']) ? intval($_GET['blog_id']) : null; |
|
2335 | + $filter = isset($_GET['filter']) ? Security::remove_XSS($_GET['filter']) : null; |
|
2336 | + $backwardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 1 ? 12 : $month -1)."&year=". ($month == 1 ? $year -1 : $year); |
|
2337 | + $forewardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 12 ? 1 : $month +1)."&year=". ($month == 12 ? $year +1 : $year); |
|
2338 | + |
|
2339 | + // Get posts for this month |
|
2340 | + $sql = "SELECT post.*, DAYOFMONTH(date_creation) as post_day, user.lastname, user.firstname |
|
2342 | 2341 | FROM $tbl_blogs_posts post |
2343 | 2342 | INNER JOIN $tbl_users user |
2344 | 2343 | ON post.author_id = user.user_id |
@@ -2348,20 +2347,20 @@ discard block |
||
2348 | 2347 | MONTH(date_creation) = '".(int)$month."' AND |
2349 | 2348 | YEAR(date_creation) = '".(int)$year."' |
2350 | 2349 | ORDER BY date_creation"; |
2351 | - $result = Database::query($sql); |
|
2352 | - |
|
2353 | - // We will create an array of days on which there are posts. |
|
2354 | - if( Database::num_rows($result) > 0) { |
|
2355 | - while($blog_post = Database::fetch_array($result)) { |
|
2356 | - // If the day of this post is not yet in the array, add it. |
|
2357 | - if (!in_array($blog_post['post_day'], $posts)) |
|
2358 | - $posts[] = $blog_post['post_day']; |
|
2359 | - } |
|
2360 | - } |
|
2361 | - |
|
2362 | - // Get tasks for this month |
|
2363 | - if ($_user['user_id']) { |
|
2364 | - $sql = " SELECT task_rel_user.*, DAYOFMONTH(target_date) as task_day, task.title, blog.blog_name |
|
2350 | + $result = Database::query($sql); |
|
2351 | + |
|
2352 | + // We will create an array of days on which there are posts. |
|
2353 | + if( Database::num_rows($result) > 0) { |
|
2354 | + while($blog_post = Database::fetch_array($result)) { |
|
2355 | + // If the day of this post is not yet in the array, add it. |
|
2356 | + if (!in_array($blog_post['post_day'], $posts)) |
|
2357 | + $posts[] = $blog_post['post_day']; |
|
2358 | + } |
|
2359 | + } |
|
2360 | + |
|
2361 | + // Get tasks for this month |
|
2362 | + if ($_user['user_id']) { |
|
2363 | + $sql = " SELECT task_rel_user.*, DAYOFMONTH(target_date) as task_day, task.title, blog.blog_name |
|
2365 | 2364 | FROM $tbl_blogs_tasks_rel_user task_rel_user |
2366 | 2365 | INNER JOIN $tbl_blogs_tasks task ON task_rel_user.task_id = task.task_id |
2367 | 2366 | INNER JOIN $tbl_blogs blog ON task_rel_user.blog_id = blog.blog_id |
@@ -2373,85 +2372,85 @@ discard block |
||
2373 | 2372 | MONTH(target_date) = '".(int)$month."' AND |
2374 | 2373 | YEAR(target_date) = '".(int)$year."' |
2375 | 2374 | ORDER BY target_date ASC"; |
2376 | - $result = Database::query($sql); |
|
2377 | - |
|
2378 | - if (Database::num_rows($result) > 0) { |
|
2379 | - while ($mytask = Database::fetch_array($result)) { |
|
2380 | - $tasks[$mytask['task_day']][$mytask['task_id']]['task_id'] = $mytask['task_id']; |
|
2381 | - $tasks[$mytask['task_day']][$mytask['task_id']]['title'] = $mytask['title']; |
|
2382 | - $tasks[$mytask['task_day']][$mytask['task_id']]['blog_id'] = $mytask['blog_id']; |
|
2383 | - $tasks[$mytask['task_day']][$mytask['task_id']]['blog_name'] = $mytask['blog_name']; |
|
2384 | - $tasks[$mytask['task_day']][$mytask['task_id']]['day'] = $mytask['task_day']; |
|
2385 | - } |
|
2386 | - } |
|
2387 | - } |
|
2388 | - |
|
2389 | - echo '<table id="smallcalendar" class="table table-responsive">', |
|
2390 | - "<tr id=\"title\">", |
|
2391 | - "<th width=\"10%\"><a href=\"", $backwardsURL, "\">«</a></th>", |
|
2392 | - "<th align=\"center\" width=\"80%\" colspan=\"5\">", $monthName, " ", $year, "</th>", |
|
2393 | - "<th width=\"10%\" align=\"right\"><a href=\"", $forewardsURL, "\">»</a></th>", "</tr>"; |
|
2394 | - |
|
2395 | - echo "<tr>"; |
|
2396 | - |
|
2397 | - for($ii = 1; $ii < 8; $ii ++) |
|
2398 | - echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>"; |
|
2399 | - |
|
2400 | - echo "</tr>"; |
|
2401 | - |
|
2402 | - $curday = -1; |
|
2403 | - $today = getdate(); |
|
2404 | - |
|
2405 | - while ($curday <= $numberofdays[$month]) { |
|
2406 | - echo "<tr>"; |
|
2407 | - for ($ii = 0; $ii < 7; $ii ++) { |
|
2408 | - if (($curday == -1) && ($ii == $startdayofweek)) |
|
2409 | - $curday = 1; |
|
2410 | - |
|
2411 | - if (($curday > 0) && ($curday <= $numberofdays[$month])) { |
|
2412 | - $bgcolor = $ii < 5 ? $class="class=\"days_week\"" : $class="class=\"days_weekend\""; |
|
2413 | - $dayheader = "$curday"; |
|
2414 | - |
|
2415 | - if(($curday == $today['mday']) && ($year == $today['year']) && ($month == $today['mon'])) { |
|
2416 | - $dayheader = "$curday"; |
|
2417 | - $class = "class=\"days_today\""; |
|
2418 | - } |
|
2419 | - |
|
2420 | - echo "<td " . $class.">"; |
|
2421 | - |
|
2422 | - // If there are posts on this day, create a filter link. |
|
2423 | - if(in_array($curday, $posts)) |
|
2424 | - echo '<a href="blog.php?blog_id=' . $blog_id . '&filter=' . $year . '-' . $month . '-' . $curday . '&month=' . $month . '&year=' . $year . '" title="' . get_lang('ViewPostsOfThisDay') . '">' . $curday . '</a>'; |
|
2425 | - else |
|
2426 | - echo $dayheader; |
|
2427 | - |
|
2428 | - if (count($tasks) > 0) { |
|
2429 | - if (isset($tasks[$curday]) && is_array($tasks[$curday])) { |
|
2430 | - // Add tasks to calendar |
|
2431 | - foreach ($tasks[$curday] as $task) { |
|
2432 | - echo '<a href="blog.php?action=execute_task&blog_id=' . $task['blog_id'] . '&task_id='.stripslashes($task['task_id']) . '" title="' . $task['title'] . ' : ' . get_lang('InBlog') . ' : ' . $task['blog_name'] . ' - ' . get_lang('ExecuteThisTask') . '">'; |
|
2433 | - echo Display::return_icon('blog_task.gif', get_lang('ExecuteThisTask')); |
|
2375 | + $result = Database::query($sql); |
|
2376 | + |
|
2377 | + if (Database::num_rows($result) > 0) { |
|
2378 | + while ($mytask = Database::fetch_array($result)) { |
|
2379 | + $tasks[$mytask['task_day']][$mytask['task_id']]['task_id'] = $mytask['task_id']; |
|
2380 | + $tasks[$mytask['task_day']][$mytask['task_id']]['title'] = $mytask['title']; |
|
2381 | + $tasks[$mytask['task_day']][$mytask['task_id']]['blog_id'] = $mytask['blog_id']; |
|
2382 | + $tasks[$mytask['task_day']][$mytask['task_id']]['blog_name'] = $mytask['blog_name']; |
|
2383 | + $tasks[$mytask['task_day']][$mytask['task_id']]['day'] = $mytask['task_day']; |
|
2384 | + } |
|
2385 | + } |
|
2386 | + } |
|
2387 | + |
|
2388 | + echo '<table id="smallcalendar" class="table table-responsive">', |
|
2389 | + "<tr id=\"title\">", |
|
2390 | + "<th width=\"10%\"><a href=\"", $backwardsURL, "\">«</a></th>", |
|
2391 | + "<th align=\"center\" width=\"80%\" colspan=\"5\">", $monthName, " ", $year, "</th>", |
|
2392 | + "<th width=\"10%\" align=\"right\"><a href=\"", $forewardsURL, "\">»</a></th>", "</tr>"; |
|
2393 | + |
|
2394 | + echo "<tr>"; |
|
2395 | + |
|
2396 | + for($ii = 1; $ii < 8; $ii ++) |
|
2397 | + echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>"; |
|
2398 | + |
|
2399 | + echo "</tr>"; |
|
2400 | + |
|
2401 | + $curday = -1; |
|
2402 | + $today = getdate(); |
|
2403 | + |
|
2404 | + while ($curday <= $numberofdays[$month]) { |
|
2405 | + echo "<tr>"; |
|
2406 | + for ($ii = 0; $ii < 7; $ii ++) { |
|
2407 | + if (($curday == -1) && ($ii == $startdayofweek)) |
|
2408 | + $curday = 1; |
|
2409 | + |
|
2410 | + if (($curday > 0) && ($curday <= $numberofdays[$month])) { |
|
2411 | + $bgcolor = $ii < 5 ? $class="class=\"days_week\"" : $class="class=\"days_weekend\""; |
|
2412 | + $dayheader = "$curday"; |
|
2413 | + |
|
2414 | + if(($curday == $today['mday']) && ($year == $today['year']) && ($month == $today['mon'])) { |
|
2415 | + $dayheader = "$curday"; |
|
2416 | + $class = "class=\"days_today\""; |
|
2417 | + } |
|
2418 | + |
|
2419 | + echo "<td " . $class.">"; |
|
2420 | + |
|
2421 | + // If there are posts on this day, create a filter link. |
|
2422 | + if(in_array($curday, $posts)) |
|
2423 | + echo '<a href="blog.php?blog_id=' . $blog_id . '&filter=' . $year . '-' . $month . '-' . $curday . '&month=' . $month . '&year=' . $year . '" title="' . get_lang('ViewPostsOfThisDay') . '">' . $curday . '</a>'; |
|
2424 | + else |
|
2425 | + echo $dayheader; |
|
2426 | + |
|
2427 | + if (count($tasks) > 0) { |
|
2428 | + if (isset($tasks[$curday]) && is_array($tasks[$curday])) { |
|
2429 | + // Add tasks to calendar |
|
2430 | + foreach ($tasks[$curday] as $task) { |
|
2431 | + echo '<a href="blog.php?action=execute_task&blog_id=' . $task['blog_id'] . '&task_id='.stripslashes($task['task_id']) . '" title="' . $task['title'] . ' : ' . get_lang('InBlog') . ' : ' . $task['blog_name'] . ' - ' . get_lang('ExecuteThisTask') . '">'; |
|
2432 | + echo Display::return_icon('blog_task.gif', get_lang('ExecuteThisTask')); |
|
2434 | 2433 | echo '</a>'; |
2435 | - } |
|
2436 | - } |
|
2437 | - } |
|
2438 | - |
|
2439 | - echo "</td>"; |
|
2440 | - $curday ++; |
|
2441 | - } else |
|
2442 | - echo "<td> </td>"; |
|
2443 | - } |
|
2444 | - echo "</tr>"; |
|
2445 | - } |
|
2446 | - echo "</table>"; |
|
2447 | - } |
|
2448 | - |
|
2449 | - /** |
|
2450 | - * Blog admin | Display the form to add a new blog. |
|
2451 | - * |
|
2452 | - */ |
|
2453 | - public static function display_new_blog_form() |
|
2454 | - { |
|
2434 | + } |
|
2435 | + } |
|
2436 | + } |
|
2437 | + |
|
2438 | + echo "</td>"; |
|
2439 | + $curday ++; |
|
2440 | + } else |
|
2441 | + echo "<td> </td>"; |
|
2442 | + } |
|
2443 | + echo "</tr>"; |
|
2444 | + } |
|
2445 | + echo "</table>"; |
|
2446 | + } |
|
2447 | + |
|
2448 | + /** |
|
2449 | + * Blog admin | Display the form to add a new blog. |
|
2450 | + * |
|
2451 | + */ |
|
2452 | + public static function display_new_blog_form() |
|
2453 | + { |
|
2455 | 2454 | $form = new FormValidator('add_blog', 'post', 'blog_admin.php?action=add'); |
2456 | 2455 | $form->addElement('header', get_lang('AddBlog')); |
2457 | 2456 | $form->addElement('text', 'blog_name', get_lang('Title')); |
@@ -2461,34 +2460,34 @@ discard block |
||
2461 | 2460 | $form->addButtonSave(get_lang('SaveProject')); |
2462 | 2461 | |
2463 | 2462 | $defaults = array( |
2464 | - 'blog_name' => isset($_POST['blog_name']) ? Security::remove_XSS($_POST['blog_name']) : null, |
|
2465 | - 'blog_subtitle' => isset($_POST['blog_subtitle']) ? Security::remove_XSS($_POST['blog_subtitle']) : null |
|
2466 | - ); |
|
2463 | + 'blog_name' => isset($_POST['blog_name']) ? Security::remove_XSS($_POST['blog_name']) : null, |
|
2464 | + 'blog_subtitle' => isset($_POST['blog_subtitle']) ? Security::remove_XSS($_POST['blog_subtitle']) : null |
|
2465 | + ); |
|
2467 | 2466 | $form->setDefaults($defaults); |
2468 | 2467 | $form->display(); |
2469 | - } |
|
2470 | - |
|
2471 | - /** |
|
2472 | - * Blog admin | Display the form to edit a blog. |
|
2473 | - * |
|
2474 | - */ |
|
2475 | - public static function display_edit_blog_form($blog_id) |
|
2476 | - { |
|
2477 | - $course_id = api_get_course_int_id(); |
|
2478 | - $blog_id= intval($blog_id); |
|
2479 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
2480 | - |
|
2481 | - $sql = "SELECT blog_id, blog_name, blog_subtitle |
|
2468 | + } |
|
2469 | + |
|
2470 | + /** |
|
2471 | + * Blog admin | Display the form to edit a blog. |
|
2472 | + * |
|
2473 | + */ |
|
2474 | + public static function display_edit_blog_form($blog_id) |
|
2475 | + { |
|
2476 | + $course_id = api_get_course_int_id(); |
|
2477 | + $blog_id= intval($blog_id); |
|
2478 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
2479 | + |
|
2480 | + $sql = "SELECT blog_id, blog_name, blog_subtitle |
|
2482 | 2481 | FROM $tbl_blogs |
2483 | 2482 | WHERE c_id = $course_id AND blog_id = '".$blog_id."'"; |
2484 | - $result = Database::query($sql); |
|
2485 | - $blog = Database::fetch_array($result); |
|
2483 | + $result = Database::query($sql); |
|
2484 | + $blog = Database::fetch_array($result); |
|
2486 | 2485 | |
2487 | - // the form contained errors but we do not want to lose the changes the user already did |
|
2488 | - if ($_POST) { |
|
2489 | - $blog['blog_name'] = Security::remove_XSS($_POST['blog_name']); |
|
2490 | - $blog['blog_subtitle'] = Security::remove_XSS($_POST['blog_subtitle']); |
|
2491 | - } |
|
2486 | + // the form contained errors but we do not want to lose the changes the user already did |
|
2487 | + if ($_POST) { |
|
2488 | + $blog['blog_name'] = Security::remove_XSS($_POST['blog_name']); |
|
2489 | + $blog['blog_subtitle'] = Security::remove_XSS($_POST['blog_subtitle']); |
|
2490 | + } |
|
2492 | 2491 | |
2493 | 2492 | $form = new FormValidator('edit_blog', 'post','blog_admin.php?action=edit&blog_id='.intval($_GET['blog_id'])); |
2494 | 2493 | $form->addElement('header', get_lang('EditBlog')); |
@@ -2504,76 +2503,76 @@ discard block |
||
2504 | 2503 | $defaults['blog_subtitle'] = $blog['blog_subtitle']; |
2505 | 2504 | $form->setDefaults($defaults); |
2506 | 2505 | $form->display(); |
2507 | - } |
|
2506 | + } |
|
2508 | 2507 | |
2509 | - /** |
|
2510 | - * Blog admin | Returns table with blogs in this course |
|
2511 | - */ |
|
2512 | - public static function display_blog_list() |
|
2508 | + /** |
|
2509 | + * Blog admin | Returns table with blogs in this course |
|
2510 | + */ |
|
2511 | + public static function display_blog_list() |
|
2513 | 2512 | { |
2514 | - global $charset; |
|
2515 | - $_user = api_get_user_info(); |
|
2513 | + global $charset; |
|
2514 | + $_user = api_get_user_info(); |
|
2516 | 2515 | $course_id = api_get_course_int_id(); |
2517 | 2516 | |
2518 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
2517 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
2519 | 2518 | |
2520 | - //condition for the session |
|
2521 | - $session_id = api_get_session_id(); |
|
2519 | + //condition for the session |
|
2520 | + $session_id = api_get_session_id(); |
|
2522 | 2521 | |
2523 | - $sql = "SELECT blog_name, blog_subtitle, visibility, blog_id, session_id |
|
2522 | + $sql = "SELECT blog_name, blog_subtitle, visibility, blog_id, session_id |
|
2524 | 2523 | FROM $tbl_blogs WHERE c_id = $course_id |
2525 | 2524 | ORDER BY date_creation DESC"; |
2526 | - $result = Database::query($sql); |
|
2527 | - $list_info = array(); |
|
2528 | - if (Database::num_rows($result)) { |
|
2529 | - while ($row_project=Database::fetch_row($result)) { |
|
2530 | - $list_info[]=$row_project; |
|
2531 | - } |
|
2532 | - } |
|
2533 | - |
|
2534 | - $list_content_blog = array(); |
|
2535 | - $list_body_blog = array(); |
|
2536 | - |
|
2537 | - if (is_array($list_info)) { |
|
2538 | - foreach ($list_info as $key => $info_log) { |
|
2539 | - // Validation when belongs to a session |
|
2540 | - $session_img = api_get_session_image($info_log[4], $_user['status']); |
|
2541 | - |
|
2542 | - $url_start_blog = 'blog.php' ."?". "blog_id=".$info_log[3]. "&".api_get_cidreq(); |
|
2543 | - $title = $info_log[0]; |
|
2525 | + $result = Database::query($sql); |
|
2526 | + $list_info = array(); |
|
2527 | + if (Database::num_rows($result)) { |
|
2528 | + while ($row_project=Database::fetch_row($result)) { |
|
2529 | + $list_info[]=$row_project; |
|
2530 | + } |
|
2531 | + } |
|
2532 | + |
|
2533 | + $list_content_blog = array(); |
|
2534 | + $list_body_blog = array(); |
|
2535 | + |
|
2536 | + if (is_array($list_info)) { |
|
2537 | + foreach ($list_info as $key => $info_log) { |
|
2538 | + // Validation when belongs to a session |
|
2539 | + $session_img = api_get_session_image($info_log[4], $_user['status']); |
|
2540 | + |
|
2541 | + $url_start_blog = 'blog.php' ."?". "blog_id=".$info_log[3]. "&".api_get_cidreq(); |
|
2542 | + $title = $info_log[0]; |
|
2544 | 2543 | $image = Display::return_icon('blog.png', $title); |
2545 | - $list_name = '<div style="float: left; width: 35px; height: 22px;"><a href="'.$url_start_blog.'">' . $image . '</a></div><a href="'.$url_start_blog.'">' .$title. '</a>' . $session_img; |
|
2544 | + $list_name = '<div style="float: left; width: 35px; height: 22px;"><a href="'.$url_start_blog.'">' . $image . '</a></div><a href="'.$url_start_blog.'">' .$title. '</a>' . $session_img; |
|
2546 | 2545 | |
2547 | - $list_body_blog[] = $list_name; |
|
2548 | - $list_body_blog[] = $info_log[1]; |
|
2546 | + $list_body_blog[] = $list_name; |
|
2547 | + $list_body_blog[] = $info_log[1]; |
|
2549 | 2548 | |
2550 | - $visibility_icon=($info_log[2]==0) ? 'invisible' : 'visible'; |
|
2551 | - $visibility_info=($info_log[2]==0) ? 'Visible' : 'Invisible'; |
|
2552 | - $my_image = '<a href="' .api_get_self(). '?action=edit&blog_id=' . $info_log[3] . '">'; |
|
2549 | + $visibility_icon=($info_log[2]==0) ? 'invisible' : 'visible'; |
|
2550 | + $visibility_info=($info_log[2]==0) ? 'Visible' : 'Invisible'; |
|
2551 | + $my_image = '<a href="' .api_get_self(). '?action=edit&blog_id=' . $info_log[3] . '">'; |
|
2553 | 2552 | $my_image.= Display::return_icon('edit.png', get_lang('EditBlog')); |
2554 | 2553 | |
2555 | - $my_image.= "</a>"; |
|
2556 | - $my_image.= '<a href="' .api_get_self(). '?action=delete&blog_id=' . $info_log[3] . '" '; |
|
2557 | - $my_image.= 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;" >'; |
|
2554 | + $my_image.= "</a>"; |
|
2555 | + $my_image.= '<a href="' .api_get_self(). '?action=delete&blog_id=' . $info_log[3] . '" '; |
|
2556 | + $my_image.= 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;" >'; |
|
2558 | 2557 | $my_image.= Display::return_icon('delete.png', get_lang('DeleteBlog')); |
2559 | 2558 | |
2560 | - $my_image.= "</a>"; |
|
2561 | - $my_image.= '<a href="' .api_get_self(). '?action=visibility&blog_id=' . $info_log[3] . '">'; |
|
2559 | + $my_image.= "</a>"; |
|
2560 | + $my_image.= '<a href="' .api_get_self(). '?action=visibility&blog_id=' . $info_log[3] . '">'; |
|
2562 | 2561 | $my_image.= Display::return_icon($visibility_icon . '.gif', get_lang($visibility_info)); |
2563 | 2562 | |
2564 | - $my_image.= "</a>"; |
|
2565 | - $list_body_blog[]=$my_image; |
|
2566 | - $list_content_blog[]=$list_body_blog; |
|
2567 | - $list_body_blog = array(); |
|
2568 | - } |
|
2569 | - |
|
2570 | - $table = new SortableTableFromArrayConfig($list_content_blog, 1,20,'project'); |
|
2571 | - $table->set_header(0, get_lang('Title')); |
|
2572 | - $table->set_header(1, get_lang('SubTitle')); |
|
2573 | - $table->set_header(2, get_lang('Modify')); |
|
2574 | - $table->display(); |
|
2575 | - } |
|
2576 | - } |
|
2563 | + $my_image.= "</a>"; |
|
2564 | + $list_body_blog[]=$my_image; |
|
2565 | + $list_content_blog[]=$list_body_blog; |
|
2566 | + $list_body_blog = array(); |
|
2567 | + } |
|
2568 | + |
|
2569 | + $table = new SortableTableFromArrayConfig($list_content_blog, 1,20,'project'); |
|
2570 | + $table->set_header(0, get_lang('Title')); |
|
2571 | + $table->set_header(1, get_lang('SubTitle')); |
|
2572 | + $table->set_header(2, get_lang('Modify')); |
|
2573 | + $table->display(); |
|
2574 | + } |
|
2575 | + } |
|
2577 | 2576 | } |
2578 | 2577 | |
2579 | 2578 | /** |
@@ -2594,34 +2593,34 @@ discard block |
||
2594 | 2593 | */ |
2595 | 2594 | function get_blog_attachment($blog_id, $post_id=null,$comment_id=null) |
2596 | 2595 | { |
2597 | - $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
2598 | - |
|
2599 | - $blog_id = intval($blog_id); |
|
2600 | - $comment_id = intval($comment_id); |
|
2601 | - $post_id = intval($post_id); |
|
2602 | - $row=array(); |
|
2603 | - $where=''; |
|
2604 | - if (!empty ($post_id) && is_numeric($post_id)) { |
|
2605 | - $where.=' AND post_id ="'.$post_id.'" '; |
|
2606 | - } |
|
2607 | - |
|
2608 | - if (!empty ($comment_id) && is_numeric($comment_id)) { |
|
2609 | - if (!empty ($post_id)) { |
|
2610 | - $where.= ' AND '; |
|
2611 | - } |
|
2612 | - $where.=' comment_id ="'.$comment_id.'" '; |
|
2613 | - } |
|
2596 | + $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
2597 | + |
|
2598 | + $blog_id = intval($blog_id); |
|
2599 | + $comment_id = intval($comment_id); |
|
2600 | + $post_id = intval($post_id); |
|
2601 | + $row=array(); |
|
2602 | + $where=''; |
|
2603 | + if (!empty ($post_id) && is_numeric($post_id)) { |
|
2604 | + $where.=' AND post_id ="'.$post_id.'" '; |
|
2605 | + } |
|
2606 | + |
|
2607 | + if (!empty ($comment_id) && is_numeric($comment_id)) { |
|
2608 | + if (!empty ($post_id)) { |
|
2609 | + $where.= ' AND '; |
|
2610 | + } |
|
2611 | + $where.=' comment_id ="'.$comment_id.'" '; |
|
2612 | + } |
|
2614 | 2613 | |
2615 | 2614 | $course_id = api_get_course_int_id(); |
2616 | 2615 | |
2617 | - $sql = 'SELECT path, filename, comment FROM '. $blog_table_attachment.' |
|
2616 | + $sql = 'SELECT path, filename, comment FROM '. $blog_table_attachment.' |
|
2618 | 2617 | WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; |
2619 | 2618 | |
2620 | - $result=Database::query($sql); |
|
2621 | - if (Database::num_rows($result)!=0) { |
|
2622 | - $row=Database::fetch_array($result); |
|
2623 | - } |
|
2624 | - return $row; |
|
2619 | + $result=Database::query($sql); |
|
2620 | + if (Database::num_rows($result)!=0) { |
|
2621 | + $row=Database::fetch_array($result); |
|
2622 | + } |
|
2623 | + return $row; |
|
2625 | 2624 | } |
2626 | 2625 | |
2627 | 2626 | /** |
@@ -2638,16 +2637,16 @@ discard block |
||
2638 | 2637 | |
2639 | 2638 | function delete_all_blog_attachment($blog_id,$post_id=null,$comment_id=null) |
2640 | 2639 | { |
2641 | - $_course = api_get_course_info(); |
|
2642 | - $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
2643 | - $blog_id = intval($blog_id); |
|
2644 | - $comment_id = intval($comment_id); |
|
2645 | - $post_id = intval($post_id); |
|
2640 | + $_course = api_get_course_info(); |
|
2641 | + $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
2642 | + $blog_id = intval($blog_id); |
|
2643 | + $comment_id = intval($comment_id); |
|
2644 | + $post_id = intval($post_id); |
|
2646 | 2645 | |
2647 | 2646 | $course_id = api_get_course_int_id(); |
2648 | - $where = null; |
|
2647 | + $where = null; |
|
2649 | 2648 | |
2650 | - // delete files in DB |
|
2649 | + // delete files in DB |
|
2651 | 2650 | if (!empty ($post_id) && is_numeric($post_id)) { |
2652 | 2651 | $where .= ' AND post_id ="'.$post_id.'" '; |
2653 | 2652 | } |
@@ -2659,25 +2658,25 @@ discard block |
||
2659 | 2658 | $where .= ' comment_id ="'.$comment_id.'" '; |
2660 | 2659 | } |
2661 | 2660 | |
2662 | - // delete all files in directory |
|
2663 | - $courseDir = $_course['path'].'/upload/blog'; |
|
2664 | - $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
2665 | - $updir = $sys_course_path.$courseDir; |
|
2661 | + // delete all files in directory |
|
2662 | + $courseDir = $_course['path'].'/upload/blog'; |
|
2663 | + $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
2664 | + $updir = $sys_course_path.$courseDir; |
|
2666 | 2665 | |
2667 | - $sql = 'SELECT path FROM '.$blog_table_attachment.' |
|
2666 | + $sql = 'SELECT path FROM '.$blog_table_attachment.' |
|
2668 | 2667 | WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; |
2669 | - $result=Database::query($sql); |
|
2670 | - |
|
2671 | - while ($row=Database::fetch_row($result)) { |
|
2672 | - $file=$updir.'/'.$row[0]; |
|
2673 | - if (Security::check_abs_path($file,$updir) ) |
|
2674 | - { |
|
2675 | - @ unlink($file); |
|
2676 | - } |
|
2677 | - } |
|
2678 | - $sql = 'DELETE FROM '. $blog_table_attachment.' |
|
2668 | + $result=Database::query($sql); |
|
2669 | + |
|
2670 | + while ($row=Database::fetch_row($result)) { |
|
2671 | + $file=$updir.'/'.$row[0]; |
|
2672 | + if (Security::check_abs_path($file,$updir) ) |
|
2673 | + { |
|
2674 | + @ unlink($file); |
|
2675 | + } |
|
2676 | + } |
|
2677 | + $sql = 'DELETE FROM '. $blog_table_attachment.' |
|
2679 | 2678 | WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; |
2680 | - Database::query($sql); |
|
2679 | + Database::query($sql); |
|
2681 | 2680 | } |
2682 | 2681 | |
2683 | 2682 | /** |
@@ -2687,12 +2686,12 @@ discard block |
||
2687 | 2686 | */ |
2688 | 2687 | function get_blog_post_from_user($course_code, $user_id) |
2689 | 2688 | { |
2690 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
2691 | - $tbl_blog_post = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
2692 | - $course_info = api_get_course_info($course_code); |
|
2693 | - $course_id = $course_info['real_id']; |
|
2689 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
2690 | + $tbl_blog_post = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
2691 | + $course_info = api_get_course_info($course_code); |
|
2692 | + $course_id = $course_info['real_id']; |
|
2694 | 2693 | |
2695 | - $sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation |
|
2694 | + $sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation |
|
2696 | 2695 | FROM $tbl_blogs blog |
2697 | 2696 | INNER JOIN $tbl_blog_post post |
2698 | 2697 | ON (blog.blog_id = post.blog_id) |
@@ -2701,19 +2700,19 @@ discard block |
||
2701 | 2700 | post.c_id = $course_id AND |
2702 | 2701 | author_id = $user_id AND visibility = 1 |
2703 | 2702 | ORDER BY post.date_creation DESC "; |
2704 | - $result = Database::query($sql); |
|
2705 | - $return_data = ''; |
|
2706 | - |
|
2707 | - if (Database::num_rows($result)!=0) { |
|
2708 | - while ($row=Database::fetch_array($result)) { |
|
2709 | - $return_data.= '<div class="clear"></div><br />'; |
|
2710 | - $return_data.= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.Display::return_icon('blog_article.png',get_lang('BlogPosts')).' '.$row['title'].' <div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.$my_course_id.' " >'.get_lang('SeeBlog').'</a></div></div>'; |
|
2711 | - $return_data.= '<br / >'; |
|
2712 | - $return_data.= $row['full_text']; |
|
2713 | - $return_data.= '<br /><br />'; |
|
2714 | - } |
|
2715 | - } |
|
2716 | - return $return_data; |
|
2703 | + $result = Database::query($sql); |
|
2704 | + $return_data = ''; |
|
2705 | + |
|
2706 | + if (Database::num_rows($result)!=0) { |
|
2707 | + while ($row=Database::fetch_array($result)) { |
|
2708 | + $return_data.= '<div class="clear"></div><br />'; |
|
2709 | + $return_data.= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.Display::return_icon('blog_article.png',get_lang('BlogPosts')).' '.$row['title'].' <div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.$my_course_id.' " >'.get_lang('SeeBlog').'</a></div></div>'; |
|
2710 | + $return_data.= '<br / >'; |
|
2711 | + $return_data.= $row['full_text']; |
|
2712 | + $return_data.= '<br /><br />'; |
|
2713 | + } |
|
2714 | + } |
|
2715 | + return $return_data; |
|
2717 | 2716 | } |
2718 | 2717 | |
2719 | 2718 | /** |
@@ -2730,7 +2729,7 @@ discard block |
||
2730 | 2729 | $course_info = api_get_course_info($course_code); |
2731 | 2730 | $course_id = $course_info['real_id']; |
2732 | 2731 | |
2733 | - $sql = "SELECT DISTINCT blog.blog_id, comment_id, title, comment, comment.date_creation |
|
2732 | + $sql = "SELECT DISTINCT blog.blog_id, comment_id, title, comment, comment.date_creation |
|
2734 | 2733 | FROM $tbl_blogs blog INNER JOIN $tbl_blog_comment comment |
2735 | 2734 | ON (blog.blog_id = comment.blog_id) |
2736 | 2735 | WHERE blog.c_id = $course_id AND |
@@ -2738,18 +2737,18 @@ discard block |
||
2738 | 2737 | author_id = $user_id AND |
2739 | 2738 | visibility = 1 |
2740 | 2739 | ORDER BY blog_name"; |
2741 | - $result = Database::query($sql); |
|
2742 | - $return_data = ''; |
|
2743 | - if (Database::num_rows($result)!=0) { |
|
2744 | - while ($row=Database::fetch_array($result)) { |
|
2745 | - $return_data.= '<div class="clear"></div><br />'; |
|
2746 | - $return_data.= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.$row['title'].' <div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.Security::remove_XSS($course_code).' " >'.get_lang('SeeBlog').'</a></div></div>'; |
|
2747 | - $return_data.= '<br / >'; |
|
2748 | - //$return_data.= '<strong>'.$row['title'].'</strong>'; echo '<br>';*/ |
|
2749 | - $return_data.= $row['comment']; |
|
2750 | - $return_data.= '<br />'; |
|
2751 | - } |
|
2752 | - } |
|
2753 | - return $return_data; |
|
2740 | + $result = Database::query($sql); |
|
2741 | + $return_data = ''; |
|
2742 | + if (Database::num_rows($result)!=0) { |
|
2743 | + while ($row=Database::fetch_array($result)) { |
|
2744 | + $return_data.= '<div class="clear"></div><br />'; |
|
2745 | + $return_data.= '<div class="actions" style="margin-left:5px;margin-right:5px;">'.$row['title'].' <div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.Security::remove_XSS($course_code).' " >'.get_lang('SeeBlog').'</a></div></div>'; |
|
2746 | + $return_data.= '<br / >'; |
|
2747 | + //$return_data.= '<strong>'.$row['title'].'</strong>'; echo '<br>';*/ |
|
2748 | + $return_data.= $row['comment']; |
|
2749 | + $return_data.= '<br />'; |
|
2750 | + } |
|
2751 | + } |
|
2752 | + return $return_data; |
|
2754 | 2753 | } |
2755 | 2754 |
@@ -144,8 +144,8 @@ discard block |
||
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
147 | - * Generates an HTML Certificate and fills the path_certificate field in the DB |
|
148 | - **/ |
|
147 | + * Generates an HTML Certificate and fills the path_certificate field in the DB |
|
148 | + **/ |
|
149 | 149 | public function generate($params = array()) |
150 | 150 | { |
151 | 151 | // The user directory should be set |
@@ -261,12 +261,12 @@ discard block |
||
261 | 261 | } |
262 | 262 | |
263 | 263 | /** |
264 | - * update user info about certificate |
|
265 | - * @param int $cat_id category id |
|
266 | - * @param int $user_id user id |
|
267 | - * @param string $path_certificate the path name of the certificate |
|
268 | - * @return void |
|
269 | - */ |
|
264 | + * update user info about certificate |
|
265 | + * @param int $cat_id category id |
|
266 | + * @param int $user_id user id |
|
267 | + * @param string $path_certificate the path name of the certificate |
|
268 | + * @return void |
|
269 | + */ |
|
270 | 270 | public function update_user_info_about_certificate( |
271 | 271 | $cat_id, |
272 | 272 | $user_id, |
@@ -368,13 +368,13 @@ discard block |
||
368 | 368 | } |
369 | 369 | |
370 | 370 | /** |
371 | - * Shows the student's certificate (HTML file). If the global setting |
|
372 | - * allow_public_certificates is set to 'false', no certificate can be printed. |
|
373 | - * If the global allow_public_certificates is set to 'true' and the course |
|
374 | - * setting allow_public_certificates is set to 0, no certificate *in this |
|
375 | - * course* can be printed (for anonymous users). Connected users can always |
|
376 | - * print them. |
|
377 | - */ |
|
371 | + * Shows the student's certificate (HTML file). If the global setting |
|
372 | + * allow_public_certificates is set to 'false', no certificate can be printed. |
|
373 | + * If the global allow_public_certificates is set to 'true' and the course |
|
374 | + * setting allow_public_certificates is set to 0, no certificate *in this |
|
375 | + * course* can be printed (for anonymous users). Connected users can always |
|
376 | + * print them. |
|
377 | + */ |
|
378 | 378 | public function show() |
379 | 379 | { |
380 | 380 | // Special rules for anonymous users |
@@ -29,11 +29,11 @@ |
||
29 | 29 | krsort($langs, SORT_NUMERIC); |
30 | 30 | // Choosing the best match |
31 | 31 | foreach($langs as $weight => $codes) { |
32 | - foreach ($codes as $code) { |
|
33 | - if (in_array($code, $available_langs)) { |
|
34 | - return $code; |
|
35 | - } |
|
36 | - } |
|
32 | + foreach ($codes as $code) { |
|
33 | + if (in_array($code, $available_langs)) { |
|
34 | + return $code; |
|
35 | + } |
|
36 | + } |
|
37 | 37 | } |
38 | 38 | // No match |
39 | 39 | return null; |
@@ -24,15 +24,15 @@ |
||
24 | 24 | $lang_match = $chamilo_langs[get_preferred_language($available_langs)]; |
25 | 25 | // recover previous value ... |
26 | 26 | if (isset($_SESSION['user_language_choice'])) |
27 | - $lang_match = $_SESSION['user_language_choice']; |
|
27 | + $lang_match = $_SESSION['user_language_choice']; |
|
28 | 28 | |
29 | 29 | // Chamilo parameter, on logout |
30 | 30 | if (isset($_REQUEST['language']) && !empty($_REQUEST['language']) && in_array($_REQUEST['language'], $chamilo_langs)) { |
31 | - $lang_match = $_REQUEST['language']; |
|
31 | + $lang_match = $_REQUEST['language']; |
|
32 | 32 | } |
33 | 33 | // Incoming link parameter |
34 | 34 | if (isset($_REQUEST['lang']) && !empty($_REQUEST['lang']) && in_array($_REQUEST['lang'], $available_langs)) { |
35 | - $lang_match = $chamilo_langs[$_REQUEST['lang']]; |
|
35 | + $lang_match = $chamilo_langs[$_REQUEST['lang']]; |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | $detect = api_get_setting('auto_detect_language_custom_pages'); |
@@ -11,235 +11,235 @@ discard block |
||
11 | 11 | */ |
12 | 12 | class nusoap_parser extends nusoap_base |
13 | 13 | { |
14 | - var $xml = ''; |
|
15 | - var $xml_encoding = ''; |
|
16 | - var $method = ''; |
|
17 | - var $root_struct = ''; |
|
18 | - var $root_struct_name = ''; |
|
19 | - var $root_struct_namespace = ''; |
|
20 | - var $root_header = ''; |
|
14 | + var $xml = ''; |
|
15 | + var $xml_encoding = ''; |
|
16 | + var $method = ''; |
|
17 | + var $root_struct = ''; |
|
18 | + var $root_struct_name = ''; |
|
19 | + var $root_struct_namespace = ''; |
|
20 | + var $root_header = ''; |
|
21 | 21 | var $document = ''; // incoming SOAP body (text) |
22 | - // determines where in the message we are (envelope,header,body,method) |
|
23 | - var $status = ''; |
|
24 | - var $position = 0; |
|
25 | - var $depth = 0; |
|
26 | - var $default_namespace = ''; |
|
27 | - var $namespaces = array(); |
|
28 | - var $message = array(); |
|
22 | + // determines where in the message we are (envelope,header,body,method) |
|
23 | + var $status = ''; |
|
24 | + var $position = 0; |
|
25 | + var $depth = 0; |
|
26 | + var $default_namespace = ''; |
|
27 | + var $namespaces = array(); |
|
28 | + var $message = array(); |
|
29 | 29 | var $parent; |
30 | - var $fault = false; |
|
31 | - var $fault_code = ''; |
|
32 | - var $fault_str = ''; |
|
33 | - var $fault_detail = ''; |
|
34 | - var $depth_array = array(); |
|
35 | - var $debug_flag = true; |
|
36 | - var $soapresponse = NULL; // parsed SOAP Body |
|
37 | - var $soapheader = NULL; // parsed SOAP Header |
|
38 | - var $responseHeaders = ''; // incoming SOAP headers (text) |
|
39 | - var $body_position = 0; |
|
40 | - // for multiref parsing: |
|
41 | - // array of id => pos |
|
42 | - var $ids = array(); |
|
43 | - // array of id => hrefs => pos |
|
44 | - var $multirefs = array(); |
|
45 | - // toggle for auto-decoding element content |
|
46 | - var $decode_utf8 = true; |
|
30 | + var $fault = false; |
|
31 | + var $fault_code = ''; |
|
32 | + var $fault_str = ''; |
|
33 | + var $fault_detail = ''; |
|
34 | + var $depth_array = array(); |
|
35 | + var $debug_flag = true; |
|
36 | + var $soapresponse = NULL; // parsed SOAP Body |
|
37 | + var $soapheader = NULL; // parsed SOAP Header |
|
38 | + var $responseHeaders = ''; // incoming SOAP headers (text) |
|
39 | + var $body_position = 0; |
|
40 | + // for multiref parsing: |
|
41 | + // array of id => pos |
|
42 | + var $ids = array(); |
|
43 | + // array of id => hrefs => pos |
|
44 | + var $multirefs = array(); |
|
45 | + // toggle for auto-decoding element content |
|
46 | + var $decode_utf8 = true; |
|
47 | 47 | |
48 | - /** |
|
49 | - * constructor that actually does the parsing |
|
50 | - * |
|
51 | - * @param string $xml SOAP message |
|
52 | - * @param string $encoding character encoding scheme of message |
|
53 | - * @param string $method method for which XML is parsed (unused?) |
|
54 | - * @param bool $decode_utf8 whether to decode UTF-8 to ISO-8859-1 |
|
55 | - * @return void|bool |
|
56 | - * @access public |
|
57 | - */ |
|
58 | - function nusoap_parser($xml,$encoding='UTF-8',$method='',$decode_utf8=true){ |
|
59 | - parent::nusoap_base(); |
|
60 | - $this->xml = $xml; |
|
61 | - $this->xml_encoding = $encoding; |
|
62 | - $this->method = $method; |
|
63 | - $this->decode_utf8 = $decode_utf8; |
|
48 | + /** |
|
49 | + * constructor that actually does the parsing |
|
50 | + * |
|
51 | + * @param string $xml SOAP message |
|
52 | + * @param string $encoding character encoding scheme of message |
|
53 | + * @param string $method method for which XML is parsed (unused?) |
|
54 | + * @param bool $decode_utf8 whether to decode UTF-8 to ISO-8859-1 |
|
55 | + * @return void|bool |
|
56 | + * @access public |
|
57 | + */ |
|
58 | + function nusoap_parser($xml,$encoding='UTF-8',$method='',$decode_utf8=true){ |
|
59 | + parent::nusoap_base(); |
|
60 | + $this->xml = $xml; |
|
61 | + $this->xml_encoding = $encoding; |
|
62 | + $this->method = $method; |
|
63 | + $this->decode_utf8 = $decode_utf8; |
|
64 | 64 | |
65 | - // Check whether content has been read. |
|
66 | - if(!empty($this->xml)){ |
|
67 | - // Check XML encoding |
|
68 | - $pos_xml = strpos($xml, '<?xml'); |
|
69 | - if ($pos_xml !== FALSE) { |
|
70 | - $xml_decl = substr($xml, $pos_xml, strpos($xml, '?>', $pos_xml + 2) - $pos_xml + 1); |
|
71 | - if (preg_match("/encoding=[\"']([^\"']*)[\"']/", $xml_decl, $res)) { |
|
72 | - $xml_encoding = $res[1]; |
|
73 | - if (strtoupper($xml_encoding) != $encoding) { |
|
74 | - $err = "Charset from HTTP Content-Type '" . $encoding . "' does not match encoding from XML declaration '" . $xml_encoding . "'"; |
|
75 | - $this->debug($err); |
|
76 | - if ($encoding != 'ISO-8859-1' || strtoupper($xml_encoding) != 'UTF-8') { |
|
77 | - $this->setError($err); |
|
78 | - return false; |
|
79 | - } |
|
80 | - // when HTTP says ISO-8859-1 (the default) and XML says UTF-8 (the typical), assume the other endpoint is just sloppy and proceed |
|
81 | - } else { |
|
82 | - $this->debug('Charset from HTTP Content-Type matches encoding from XML declaration'); |
|
83 | - } |
|
84 | - } else { |
|
85 | - $this->debug('No encoding specified in XML declaration'); |
|
86 | - } |
|
87 | - } else { |
|
88 | - $this->debug('No XML declaration'); |
|
89 | - } |
|
90 | - $this->debug('Entering nusoap_parser(), length='.strlen($xml).', encoding='.$encoding); |
|
91 | - // Create an XML parser - why not xml_parser_create_ns? |
|
92 | - $this->parser = xml_parser_create($this->xml_encoding); |
|
93 | - // Set the options for parsing the XML data. |
|
94 | - //xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); |
|
95 | - xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); |
|
96 | - xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $this->xml_encoding); |
|
97 | - // Set the object for the parser. |
|
98 | - xml_set_object($this->parser, $this); |
|
99 | - // Set the element handlers for the parser. |
|
100 | - xml_set_element_handler($this->parser, 'start_element','end_element'); |
|
101 | - xml_set_character_data_handler($this->parser,'character_data'); |
|
65 | + // Check whether content has been read. |
|
66 | + if(!empty($this->xml)){ |
|
67 | + // Check XML encoding |
|
68 | + $pos_xml = strpos($xml, '<?xml'); |
|
69 | + if ($pos_xml !== FALSE) { |
|
70 | + $xml_decl = substr($xml, $pos_xml, strpos($xml, '?>', $pos_xml + 2) - $pos_xml + 1); |
|
71 | + if (preg_match("/encoding=[\"']([^\"']*)[\"']/", $xml_decl, $res)) { |
|
72 | + $xml_encoding = $res[1]; |
|
73 | + if (strtoupper($xml_encoding) != $encoding) { |
|
74 | + $err = "Charset from HTTP Content-Type '" . $encoding . "' does not match encoding from XML declaration '" . $xml_encoding . "'"; |
|
75 | + $this->debug($err); |
|
76 | + if ($encoding != 'ISO-8859-1' || strtoupper($xml_encoding) != 'UTF-8') { |
|
77 | + $this->setError($err); |
|
78 | + return false; |
|
79 | + } |
|
80 | + // when HTTP says ISO-8859-1 (the default) and XML says UTF-8 (the typical), assume the other endpoint is just sloppy and proceed |
|
81 | + } else { |
|
82 | + $this->debug('Charset from HTTP Content-Type matches encoding from XML declaration'); |
|
83 | + } |
|
84 | + } else { |
|
85 | + $this->debug('No encoding specified in XML declaration'); |
|
86 | + } |
|
87 | + } else { |
|
88 | + $this->debug('No XML declaration'); |
|
89 | + } |
|
90 | + $this->debug('Entering nusoap_parser(), length='.strlen($xml).', encoding='.$encoding); |
|
91 | + // Create an XML parser - why not xml_parser_create_ns? |
|
92 | + $this->parser = xml_parser_create($this->xml_encoding); |
|
93 | + // Set the options for parsing the XML data. |
|
94 | + //xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); |
|
95 | + xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); |
|
96 | + xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $this->xml_encoding); |
|
97 | + // Set the object for the parser. |
|
98 | + xml_set_object($this->parser, $this); |
|
99 | + // Set the element handlers for the parser. |
|
100 | + xml_set_element_handler($this->parser, 'start_element','end_element'); |
|
101 | + xml_set_character_data_handler($this->parser,'character_data'); |
|
102 | 102 | |
103 | - xml_parse($this->parser, $this->xml); |
|
103 | + xml_parse($this->parser, $this->xml); |
|
104 | 104 | |
105 | - // Parse the XML file. |
|
106 | - //if (!xml_parse($this->parser,$xml,true)){ |
|
107 | - if (false) { |
|
108 | - // Display an error message. |
|
109 | - $err = sprintf('XML error parsing SOAP payload on line %d: %s', |
|
110 | - xml_get_current_line_number($this->parser), |
|
111 | - xml_error_string(xml_get_error_code($this->parser))); |
|
112 | - $this->debug($err); |
|
113 | - $this->debug("XML payload:\n" . $xml); |
|
114 | - $this->setError($err); |
|
115 | - } else { |
|
116 | - $this->debug('in nusoap_parser ctor, message:'); |
|
117 | - $this->appendDebug($this->varDump($this->message)); |
|
118 | - $this->debug('parsed successfully, found root struct: '.$this->root_struct.' of name '.$this->root_struct_name); |
|
119 | - // get final value |
|
120 | - $this->soapresponse = $this->message[$this->root_struct]['result']; |
|
121 | - // get header value |
|
122 | - if($this->root_header != '' && isset($this->message[$this->root_header]['result'])){ |
|
123 | - $this->soapheader = $this->message[$this->root_header]['result']; |
|
124 | - } |
|
125 | - // resolve hrefs/ids |
|
126 | - if(sizeof($this->multirefs) > 0){ |
|
127 | - foreach($this->multirefs as $id => $hrefs){ |
|
128 | - $this->debug('resolving multirefs for id: '.$id); |
|
129 | - $idVal = $this->buildVal($this->ids[$id]); |
|
130 | - if (is_array($idVal) && isset($idVal['!id'])) { |
|
131 | - unset($idVal['!id']); |
|
132 | - } |
|
133 | - foreach($hrefs as $refPos => $ref){ |
|
134 | - $this->debug('resolving href at pos '.$refPos); |
|
135 | - $this->multirefs[$id][$refPos] = $idVal; |
|
136 | - } |
|
137 | - } |
|
138 | - } |
|
139 | - } |
|
140 | - xml_parser_free($this->parser); |
|
141 | - } else { |
|
142 | - $this->debug('xml was empty, didn\'t parse!'); |
|
143 | - $this->setError('xml was empty, didn\'t parse!'); |
|
144 | - } |
|
145 | - } |
|
105 | + // Parse the XML file. |
|
106 | + //if (!xml_parse($this->parser,$xml,true)){ |
|
107 | + if (false) { |
|
108 | + // Display an error message. |
|
109 | + $err = sprintf('XML error parsing SOAP payload on line %d: %s', |
|
110 | + xml_get_current_line_number($this->parser), |
|
111 | + xml_error_string(xml_get_error_code($this->parser))); |
|
112 | + $this->debug($err); |
|
113 | + $this->debug("XML payload:\n" . $xml); |
|
114 | + $this->setError($err); |
|
115 | + } else { |
|
116 | + $this->debug('in nusoap_parser ctor, message:'); |
|
117 | + $this->appendDebug($this->varDump($this->message)); |
|
118 | + $this->debug('parsed successfully, found root struct: '.$this->root_struct.' of name '.$this->root_struct_name); |
|
119 | + // get final value |
|
120 | + $this->soapresponse = $this->message[$this->root_struct]['result']; |
|
121 | + // get header value |
|
122 | + if($this->root_header != '' && isset($this->message[$this->root_header]['result'])){ |
|
123 | + $this->soapheader = $this->message[$this->root_header]['result']; |
|
124 | + } |
|
125 | + // resolve hrefs/ids |
|
126 | + if(sizeof($this->multirefs) > 0){ |
|
127 | + foreach($this->multirefs as $id => $hrefs){ |
|
128 | + $this->debug('resolving multirefs for id: '.$id); |
|
129 | + $idVal = $this->buildVal($this->ids[$id]); |
|
130 | + if (is_array($idVal) && isset($idVal['!id'])) { |
|
131 | + unset($idVal['!id']); |
|
132 | + } |
|
133 | + foreach($hrefs as $refPos => $ref){ |
|
134 | + $this->debug('resolving href at pos '.$refPos); |
|
135 | + $this->multirefs[$id][$refPos] = $idVal; |
|
136 | + } |
|
137 | + } |
|
138 | + } |
|
139 | + } |
|
140 | + xml_parser_free($this->parser); |
|
141 | + } else { |
|
142 | + $this->debug('xml was empty, didn\'t parse!'); |
|
143 | + $this->setError('xml was empty, didn\'t parse!'); |
|
144 | + } |
|
145 | + } |
|
146 | 146 | |
147 | - /** |
|
148 | - * start-element handler |
|
149 | - * |
|
150 | - * @param resource $parser XML parser object |
|
151 | - * @param string $name element name |
|
152 | - * @param array $attrs associative array of attributes |
|
153 | - * @access private |
|
154 | - */ |
|
155 | - function start_element($parser, $name, $attrs) { |
|
147 | + /** |
|
148 | + * start-element handler |
|
149 | + * |
|
150 | + * @param resource $parser XML parser object |
|
151 | + * @param string $name element name |
|
152 | + * @param array $attrs associative array of attributes |
|
153 | + * @access private |
|
154 | + */ |
|
155 | + function start_element($parser, $name, $attrs) { |
|
156 | 156 | |
157 | - // position in a total number of elements, starting from 0 |
|
158 | - // update class level pos |
|
159 | - $pos = $this->position++; |
|
160 | - // and set mine |
|
161 | - $this->message[$pos] = array('pos' => $pos,'children'=>'','cdata'=>''); |
|
162 | - // depth = how many levels removed from root? |
|
163 | - // set mine as current global depth and increment global depth value |
|
164 | - $this->message[$pos]['depth'] = $this->depth++; |
|
157 | + // position in a total number of elements, starting from 0 |
|
158 | + // update class level pos |
|
159 | + $pos = $this->position++; |
|
160 | + // and set mine |
|
161 | + $this->message[$pos] = array('pos' => $pos,'children'=>'','cdata'=>''); |
|
162 | + // depth = how many levels removed from root? |
|
163 | + // set mine as current global depth and increment global depth value |
|
164 | + $this->message[$pos]['depth'] = $this->depth++; |
|
165 | 165 | |
166 | - // else add self as child to whoever the current parent is |
|
167 | - if($pos != 0){ |
|
168 | - $this->message[$this->parent]['children'] .= '|'.$pos; |
|
169 | - } |
|
170 | - // set my parent |
|
171 | - $this->message[$pos]['parent'] = $this->parent; |
|
172 | - // set self as current parent |
|
173 | - $this->parent = $pos; |
|
174 | - // set self as current value for this depth |
|
175 | - $this->depth_array[$this->depth] = $pos; |
|
176 | - // get element prefix |
|
177 | - if(strpos($name,':')){ |
|
178 | - // get ns prefix |
|
179 | - $prefix = substr($name,0,strpos($name,':')); |
|
180 | - // get unqualified name |
|
181 | - $name = substr(strstr($name,':'),1); |
|
182 | - } |
|
183 | - // set status |
|
184 | - if ($name == 'Envelope' && $this->status == '') { |
|
185 | - $this->status = 'envelope'; |
|
186 | - } elseif ($name == 'Header' && $this->status == 'envelope') { |
|
187 | - $this->root_header = $pos; |
|
188 | - $this->status = 'header'; |
|
189 | - } elseif ($name == 'Body' && $this->status == 'envelope'){ |
|
190 | - $this->status = 'body'; |
|
191 | - $this->body_position = $pos; |
|
192 | - // set method |
|
193 | - } elseif($this->status == 'body' && $pos == ($this->body_position+1)) { |
|
194 | - $this->status = 'method'; |
|
195 | - $this->root_struct_name = $name; |
|
196 | - $this->root_struct = $pos; |
|
197 | - $this->message[$pos]['type'] = 'struct'; |
|
198 | - $this->debug("found root struct $this->root_struct_name, pos $this->root_struct"); |
|
199 | - } |
|
200 | - // set my status |
|
201 | - $this->message[$pos]['status'] = $this->status; |
|
202 | - // set name |
|
203 | - $this->message[$pos]['name'] = htmlspecialchars($name); |
|
204 | - // set attrs |
|
205 | - $this->message[$pos]['attrs'] = $attrs; |
|
166 | + // else add self as child to whoever the current parent is |
|
167 | + if($pos != 0){ |
|
168 | + $this->message[$this->parent]['children'] .= '|'.$pos; |
|
169 | + } |
|
170 | + // set my parent |
|
171 | + $this->message[$pos]['parent'] = $this->parent; |
|
172 | + // set self as current parent |
|
173 | + $this->parent = $pos; |
|
174 | + // set self as current value for this depth |
|
175 | + $this->depth_array[$this->depth] = $pos; |
|
176 | + // get element prefix |
|
177 | + if(strpos($name,':')){ |
|
178 | + // get ns prefix |
|
179 | + $prefix = substr($name,0,strpos($name,':')); |
|
180 | + // get unqualified name |
|
181 | + $name = substr(strstr($name,':'),1); |
|
182 | + } |
|
183 | + // set status |
|
184 | + if ($name == 'Envelope' && $this->status == '') { |
|
185 | + $this->status = 'envelope'; |
|
186 | + } elseif ($name == 'Header' && $this->status == 'envelope') { |
|
187 | + $this->root_header = $pos; |
|
188 | + $this->status = 'header'; |
|
189 | + } elseif ($name == 'Body' && $this->status == 'envelope'){ |
|
190 | + $this->status = 'body'; |
|
191 | + $this->body_position = $pos; |
|
192 | + // set method |
|
193 | + } elseif($this->status == 'body' && $pos == ($this->body_position+1)) { |
|
194 | + $this->status = 'method'; |
|
195 | + $this->root_struct_name = $name; |
|
196 | + $this->root_struct = $pos; |
|
197 | + $this->message[$pos]['type'] = 'struct'; |
|
198 | + $this->debug("found root struct $this->root_struct_name, pos $this->root_struct"); |
|
199 | + } |
|
200 | + // set my status |
|
201 | + $this->message[$pos]['status'] = $this->status; |
|
202 | + // set name |
|
203 | + $this->message[$pos]['name'] = htmlspecialchars($name); |
|
204 | + // set attrs |
|
205 | + $this->message[$pos]['attrs'] = $attrs; |
|
206 | 206 | |
207 | - // loop through atts, logging ns and type declarations |
|
207 | + // loop through atts, logging ns and type declarations |
|
208 | 208 | $attstr = ''; |
209 | - foreach($attrs as $key => $value){ |
|
210 | - $key_prefix = $this->getPrefix($key); |
|
211 | - $key_localpart = $this->getLocalPart($key); |
|
212 | - // if ns declarations, add to class level array of valid namespaces |
|
209 | + foreach($attrs as $key => $value){ |
|
210 | + $key_prefix = $this->getPrefix($key); |
|
211 | + $key_localpart = $this->getLocalPart($key); |
|
212 | + // if ns declarations, add to class level array of valid namespaces |
|
213 | 213 | if($key_prefix == 'xmlns'){ |
214 | - if(preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/',$value)){ |
|
215 | - $this->XMLSchemaVersion = $value; |
|
216 | - $this->namespaces['xsd'] = $this->XMLSchemaVersion; |
|
217 | - $this->namespaces['xsi'] = $this->XMLSchemaVersion.'-instance'; |
|
218 | - } |
|
214 | + if(preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/',$value)){ |
|
215 | + $this->XMLSchemaVersion = $value; |
|
216 | + $this->namespaces['xsd'] = $this->XMLSchemaVersion; |
|
217 | + $this->namespaces['xsi'] = $this->XMLSchemaVersion.'-instance'; |
|
218 | + } |
|
219 | 219 | $this->namespaces[$key_localpart] = $value; |
220 | - // set method namespace |
|
221 | - if($name == $this->root_struct_name){ |
|
222 | - $this->methodNamespace = $value; |
|
223 | - } |
|
224 | - // if it's a type declaration, set type |
|
220 | + // set method namespace |
|
221 | + if($name == $this->root_struct_name){ |
|
222 | + $this->methodNamespace = $value; |
|
223 | + } |
|
224 | + // if it's a type declaration, set type |
|
225 | 225 | } elseif($key_localpart == 'type'){ |
226 | - if (isset($this->message[$pos]['type']) && $this->message[$pos]['type'] == 'array') { |
|
227 | - // do nothing: already processed arrayType |
|
228 | - } else { |
|
229 | - $value_prefix = $this->getPrefix($value); |
|
230 | - $value_localpart = $this->getLocalPart($value); |
|
231 | - $this->message[$pos]['type'] = $value_localpart; |
|
232 | - $this->message[$pos]['typePrefix'] = $value_prefix; |
|
233 | - if(isset($this->namespaces[$value_prefix])){ |
|
234 | - $this->message[$pos]['type_namespace'] = $this->namespaces[$value_prefix]; |
|
235 | - } else if(isset($attrs['xmlns:'.$value_prefix])) { |
|
236 | - $this->message[$pos]['type_namespace'] = $attrs['xmlns:'.$value_prefix]; |
|
237 | - } |
|
238 | - // should do something here with the namespace of specified type? |
|
239 | - } |
|
240 | - } elseif($key_localpart == 'arrayType'){ |
|
241 | - $this->message[$pos]['type'] = 'array'; |
|
242 | - /* do arrayType ereg here |
|
226 | + if (isset($this->message[$pos]['type']) && $this->message[$pos]['type'] == 'array') { |
|
227 | + // do nothing: already processed arrayType |
|
228 | + } else { |
|
229 | + $value_prefix = $this->getPrefix($value); |
|
230 | + $value_localpart = $this->getLocalPart($value); |
|
231 | + $this->message[$pos]['type'] = $value_localpart; |
|
232 | + $this->message[$pos]['typePrefix'] = $value_prefix; |
|
233 | + if(isset($this->namespaces[$value_prefix])){ |
|
234 | + $this->message[$pos]['type_namespace'] = $this->namespaces[$value_prefix]; |
|
235 | + } else if(isset($attrs['xmlns:'.$value_prefix])) { |
|
236 | + $this->message[$pos]['type_namespace'] = $attrs['xmlns:'.$value_prefix]; |
|
237 | + } |
|
238 | + // should do something here with the namespace of specified type? |
|
239 | + } |
|
240 | + } elseif($key_localpart == 'arrayType'){ |
|
241 | + $this->message[$pos]['type'] = 'array'; |
|
242 | + /* do arrayType ereg here |
|
243 | 243 | [1] arrayTypeValue ::= atype asize |
244 | 244 | [2] atype ::= QName rank* |
245 | 245 | [3] rank ::= '[' (',')* ']' |
@@ -247,129 +247,129 @@ discard block |
||
247 | 247 | [5] length ::= nextDimension* Digit+ |
248 | 248 | [6] nextDimension ::= Digit+ ',' |
249 | 249 | */ |
250 | - $expr = '/([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]/'; |
|
251 | - if(preg_match($expr,$value,$regs)){ |
|
252 | - $this->message[$pos]['typePrefix'] = $regs[1]; |
|
253 | - $this->message[$pos]['arrayTypePrefix'] = $regs[1]; |
|
254 | - if (isset($this->namespaces[$regs[1]])) { |
|
255 | - $this->message[$pos]['arrayTypeNamespace'] = $this->namespaces[$regs[1]]; |
|
256 | - } else if (isset($attrs['xmlns:'.$regs[1]])) { |
|
257 | - $this->message[$pos]['arrayTypeNamespace'] = $attrs['xmlns:'.$regs[1]]; |
|
258 | - } |
|
259 | - $this->message[$pos]['arrayType'] = $regs[2]; |
|
260 | - $this->message[$pos]['arraySize'] = $regs[3]; |
|
261 | - $this->message[$pos]['arrayCols'] = $regs[4]; |
|
262 | - } |
|
263 | - // specifies nil value (or not) |
|
264 | - } elseif ($key_localpart == 'nil'){ |
|
265 | - $this->message[$pos]['nil'] = ($value == 'true' || $value == '1'); |
|
266 | - // some other attribute |
|
267 | - } elseif ($key != 'href' && $key != 'xmlns' && $key_localpart != 'encodingStyle' && $key_localpart != 'root') { |
|
268 | - $this->message[$pos]['xattrs']['!' . $key] = $value; |
|
269 | - } |
|
250 | + $expr = '/([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]/'; |
|
251 | + if(preg_match($expr,$value,$regs)){ |
|
252 | + $this->message[$pos]['typePrefix'] = $regs[1]; |
|
253 | + $this->message[$pos]['arrayTypePrefix'] = $regs[1]; |
|
254 | + if (isset($this->namespaces[$regs[1]])) { |
|
255 | + $this->message[$pos]['arrayTypeNamespace'] = $this->namespaces[$regs[1]]; |
|
256 | + } else if (isset($attrs['xmlns:'.$regs[1]])) { |
|
257 | + $this->message[$pos]['arrayTypeNamespace'] = $attrs['xmlns:'.$regs[1]]; |
|
258 | + } |
|
259 | + $this->message[$pos]['arrayType'] = $regs[2]; |
|
260 | + $this->message[$pos]['arraySize'] = $regs[3]; |
|
261 | + $this->message[$pos]['arrayCols'] = $regs[4]; |
|
262 | + } |
|
263 | + // specifies nil value (or not) |
|
264 | + } elseif ($key_localpart == 'nil'){ |
|
265 | + $this->message[$pos]['nil'] = ($value == 'true' || $value == '1'); |
|
266 | + // some other attribute |
|
267 | + } elseif ($key != 'href' && $key != 'xmlns' && $key_localpart != 'encodingStyle' && $key_localpart != 'root') { |
|
268 | + $this->message[$pos]['xattrs']['!' . $key] = $value; |
|
269 | + } |
|
270 | 270 | |
271 | - if ($key == 'xmlns') { |
|
272 | - $this->default_namespace = $value; |
|
273 | - } |
|
274 | - // log id |
|
275 | - if($key == 'id'){ |
|
276 | - $this->ids[$value] = $pos; |
|
277 | - } |
|
278 | - // root |
|
279 | - if($key_localpart == 'root' && $value == 1){ |
|
280 | - $this->status = 'method'; |
|
281 | - $this->root_struct_name = $name; |
|
282 | - $this->root_struct = $pos; |
|
283 | - $this->debug("found root struct $this->root_struct_name, pos $pos"); |
|
284 | - } |
|
271 | + if ($key == 'xmlns') { |
|
272 | + $this->default_namespace = $value; |
|
273 | + } |
|
274 | + // log id |
|
275 | + if($key == 'id'){ |
|
276 | + $this->ids[$value] = $pos; |
|
277 | + } |
|
278 | + // root |
|
279 | + if($key_localpart == 'root' && $value == 1){ |
|
280 | + $this->status = 'method'; |
|
281 | + $this->root_struct_name = $name; |
|
282 | + $this->root_struct = $pos; |
|
283 | + $this->debug("found root struct $this->root_struct_name, pos $pos"); |
|
284 | + } |
|
285 | 285 | // for doclit |
286 | 286 | $attstr .= " $key=\"$value\""; |
287 | - } |
|
287 | + } |
|
288 | 288 | // get namespace - must be done after namespace atts are processed |
289 | - if(isset($prefix)){ |
|
290 | - $this->message[$pos]['namespace'] = $this->namespaces[$prefix]; |
|
291 | - $this->default_namespace = $this->namespaces[$prefix]; |
|
292 | - } else { |
|
293 | - $this->message[$pos]['namespace'] = $this->default_namespace; |
|
294 | - } |
|
289 | + if(isset($prefix)){ |
|
290 | + $this->message[$pos]['namespace'] = $this->namespaces[$prefix]; |
|
291 | + $this->default_namespace = $this->namespaces[$prefix]; |
|
292 | + } else { |
|
293 | + $this->message[$pos]['namespace'] = $this->default_namespace; |
|
294 | + } |
|
295 | 295 | if($this->status == 'header'){ |
296 | - if ($this->root_header != $pos) { |
|
297 | - $this->responseHeaders .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>"; |
|
298 | - } |
|
296 | + if ($this->root_header != $pos) { |
|
297 | + $this->responseHeaders .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>"; |
|
298 | + } |
|
299 | 299 | } elseif($this->root_struct_name != ''){ |
300 | - $this->document .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>"; |
|
300 | + $this->document .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>"; |
|
301 | 301 | } |
302 | - } |
|
302 | + } |
|
303 | 303 | |
304 | - /** |
|
305 | - * end-element handler |
|
306 | - * |
|
307 | - * @param resource $parser XML parser object |
|
308 | - * @param string $name element name |
|
309 | - * @access private |
|
310 | - */ |
|
311 | - function end_element($parser, $name) { |
|
312 | - // position of current element is equal to the last value left in depth_array for my depth |
|
313 | - $pos = $this->depth_array[$this->depth--]; |
|
304 | + /** |
|
305 | + * end-element handler |
|
306 | + * |
|
307 | + * @param resource $parser XML parser object |
|
308 | + * @param string $name element name |
|
309 | + * @access private |
|
310 | + */ |
|
311 | + function end_element($parser, $name) { |
|
312 | + // position of current element is equal to the last value left in depth_array for my depth |
|
313 | + $pos = $this->depth_array[$this->depth--]; |
|
314 | 314 | |
315 | 315 | // get element prefix |
316 | - if(strpos($name,':')){ |
|
317 | - // get ns prefix |
|
318 | - $prefix = substr($name,0,strpos($name,':')); |
|
319 | - // get unqualified name |
|
320 | - $name = substr(strstr($name,':'),1); |
|
321 | - } |
|
316 | + if(strpos($name,':')){ |
|
317 | + // get ns prefix |
|
318 | + $prefix = substr($name,0,strpos($name,':')); |
|
319 | + // get unqualified name |
|
320 | + $name = substr(strstr($name,':'),1); |
|
321 | + } |
|
322 | 322 | |
323 | - // build to native type |
|
324 | - if(isset($this->body_position) && $pos > $this->body_position){ |
|
325 | - // deal w/ multirefs |
|
326 | - if(isset($this->message[$pos]['attrs']['href'])){ |
|
327 | - // get id |
|
328 | - $id = substr($this->message[$pos]['attrs']['href'],1); |
|
329 | - // add placeholder to href array |
|
330 | - $this->multirefs[$id][$pos] = 'placeholder'; |
|
331 | - // add set a reference to it as the result value |
|
332 | - $this->message[$pos]['result'] =& $this->multirefs[$id][$pos]; |
|
323 | + // build to native type |
|
324 | + if(isset($this->body_position) && $pos > $this->body_position){ |
|
325 | + // deal w/ multirefs |
|
326 | + if(isset($this->message[$pos]['attrs']['href'])){ |
|
327 | + // get id |
|
328 | + $id = substr($this->message[$pos]['attrs']['href'],1); |
|
329 | + // add placeholder to href array |
|
330 | + $this->multirefs[$id][$pos] = 'placeholder'; |
|
331 | + // add set a reference to it as the result value |
|
332 | + $this->message[$pos]['result'] =& $this->multirefs[$id][$pos]; |
|
333 | 333 | // build complexType values |
334 | - } elseif($this->message[$pos]['children'] != ''){ |
|
335 | - // if result has already been generated (struct/array) |
|
336 | - if(!isset($this->message[$pos]['result'])){ |
|
337 | - $this->message[$pos]['result'] = $this->buildVal($pos); |
|
338 | - } |
|
339 | - // build complexType values of attributes and possibly simpleContent |
|
340 | - } elseif (isset($this->message[$pos]['xattrs'])) { |
|
341 | - if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) { |
|
342 | - $this->message[$pos]['xattrs']['!'] = null; |
|
343 | - } elseif (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') { |
|
344 | - if (isset($this->message[$pos]['type'])) { |
|
345 | - $this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
346 | - } else { |
|
347 | - $parent = $this->message[$pos]['parent']; |
|
348 | - if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
349 | - $this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
350 | - } else { |
|
351 | - $this->message[$pos]['xattrs']['!'] = $this->message[$pos]['cdata']; |
|
352 | - } |
|
353 | - } |
|
354 | - } |
|
355 | - $this->message[$pos]['result'] = $this->message[$pos]['xattrs']; |
|
356 | - // set value of simpleType (or nil complexType) |
|
357 | - } else { |
|
358 | - //$this->debug('adding data for scalar value '.$this->message[$pos]['name'].' of value '.$this->message[$pos]['cdata']); |
|
359 | - if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) { |
|
360 | - $this->message[$pos]['xattrs']['!'] = null; |
|
361 | - } elseif (isset($this->message[$pos]['type'])) { |
|
362 | - $this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
363 | - } else { |
|
364 | - $parent = $this->message[$pos]['parent']; |
|
365 | - if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
366 | - $this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
367 | - } else { |
|
368 | - $this->message[$pos]['result'] = $this->message[$pos]['cdata']; |
|
369 | - } |
|
370 | - } |
|
334 | + } elseif($this->message[$pos]['children'] != ''){ |
|
335 | + // if result has already been generated (struct/array) |
|
336 | + if(!isset($this->message[$pos]['result'])){ |
|
337 | + $this->message[$pos]['result'] = $this->buildVal($pos); |
|
338 | + } |
|
339 | + // build complexType values of attributes and possibly simpleContent |
|
340 | + } elseif (isset($this->message[$pos]['xattrs'])) { |
|
341 | + if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) { |
|
342 | + $this->message[$pos]['xattrs']['!'] = null; |
|
343 | + } elseif (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') { |
|
344 | + if (isset($this->message[$pos]['type'])) { |
|
345 | + $this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
346 | + } else { |
|
347 | + $parent = $this->message[$pos]['parent']; |
|
348 | + if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
349 | + $this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
350 | + } else { |
|
351 | + $this->message[$pos]['xattrs']['!'] = $this->message[$pos]['cdata']; |
|
352 | + } |
|
353 | + } |
|
354 | + } |
|
355 | + $this->message[$pos]['result'] = $this->message[$pos]['xattrs']; |
|
356 | + // set value of simpleType (or nil complexType) |
|
357 | + } else { |
|
358 | + //$this->debug('adding data for scalar value '.$this->message[$pos]['name'].' of value '.$this->message[$pos]['cdata']); |
|
359 | + if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) { |
|
360 | + $this->message[$pos]['xattrs']['!'] = null; |
|
361 | + } elseif (isset($this->message[$pos]['type'])) { |
|
362 | + $this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
363 | + } else { |
|
364 | + $parent = $this->message[$pos]['parent']; |
|
365 | + if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
366 | + $this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
367 | + } else { |
|
368 | + $this->message[$pos]['result'] = $this->message[$pos]['cdata']; |
|
369 | + } |
|
370 | + } |
|
371 | 371 | |
372 | - /* add value to parent's result, if parent is struct/array |
|
372 | + /* add value to parent's result, if parent is struct/array |
|
373 | 373 | $parent = $this->message[$pos]['parent']; |
374 | 374 | if($this->message[$parent]['type'] != 'map'){ |
375 | 375 | if(strtolower($this->message[$parent]['type']) == 'array'){ |
@@ -379,261 +379,261 @@ discard block |
||
379 | 379 | } |
380 | 380 | } |
381 | 381 | */ |
382 | - } |
|
383 | - } |
|
382 | + } |
|
383 | + } |
|
384 | 384 | |
385 | 385 | // for doclit |
386 | 386 | if($this->status == 'header'){ |
387 | - if ($this->root_header != $pos) { |
|
388 | - $this->responseHeaders .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>"; |
|
389 | - } |
|
387 | + if ($this->root_header != $pos) { |
|
388 | + $this->responseHeaders .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>"; |
|
389 | + } |
|
390 | 390 | } elseif($pos >= $this->root_struct){ |
391 | - $this->document .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>"; |
|
391 | + $this->document .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>"; |
|
392 | 392 | } |
393 | - // switch status |
|
394 | - if ($pos == $this->root_struct){ |
|
395 | - $this->status = 'body'; |
|
396 | - $this->root_struct_namespace = $this->message[$pos]['namespace']; |
|
397 | - } elseif ($pos == $this->root_header) { |
|
398 | - $this->status = 'envelope'; |
|
399 | - } elseif ($name == 'Body' && $this->status == 'body') { |
|
400 | - $this->status = 'envelope'; |
|
401 | - } elseif ($name == 'Header' && $this->status == 'header') { // will never happen |
|
402 | - $this->status = 'envelope'; |
|
403 | - } elseif ($name == 'Envelope' && $this->status == 'envelope') { |
|
404 | - $this->status = ''; |
|
405 | - } |
|
406 | - // set parent back to my parent |
|
407 | - $this->parent = $this->message[$pos]['parent']; |
|
408 | - } |
|
393 | + // switch status |
|
394 | + if ($pos == $this->root_struct){ |
|
395 | + $this->status = 'body'; |
|
396 | + $this->root_struct_namespace = $this->message[$pos]['namespace']; |
|
397 | + } elseif ($pos == $this->root_header) { |
|
398 | + $this->status = 'envelope'; |
|
399 | + } elseif ($name == 'Body' && $this->status == 'body') { |
|
400 | + $this->status = 'envelope'; |
|
401 | + } elseif ($name == 'Header' && $this->status == 'header') { // will never happen |
|
402 | + $this->status = 'envelope'; |
|
403 | + } elseif ($name == 'Envelope' && $this->status == 'envelope') { |
|
404 | + $this->status = ''; |
|
405 | + } |
|
406 | + // set parent back to my parent |
|
407 | + $this->parent = $this->message[$pos]['parent']; |
|
408 | + } |
|
409 | 409 | |
410 | - /** |
|
411 | - * element content handler |
|
412 | - * |
|
413 | - * @param resource $parser XML parser object |
|
414 | - * @param string $data element content |
|
415 | - * @access private |
|
416 | - */ |
|
417 | - function character_data($parser, $data) |
|
410 | + /** |
|
411 | + * element content handler |
|
412 | + * |
|
413 | + * @param resource $parser XML parser object |
|
414 | + * @param string $data element content |
|
415 | + * @access private |
|
416 | + */ |
|
417 | + function character_data($parser, $data) |
|
418 | 418 | { |
419 | - $pos = $this->depth_array[$this->depth]; |
|
420 | - if ($this->xml_encoding == 'UTF-8'){ |
|
421 | - // TODO: add an option to disable this for folks who want |
|
422 | - // raw UTF-8 that, e.g., might not map to iso-8859-1 |
|
423 | - // TODO: this can also be handled with xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, "ISO-8859-1"); |
|
424 | - if($this->decode_utf8){ |
|
425 | - $data = utf8_decode($data); |
|
426 | - } |
|
427 | - } |
|
419 | + $pos = $this->depth_array[$this->depth]; |
|
420 | + if ($this->xml_encoding == 'UTF-8'){ |
|
421 | + // TODO: add an option to disable this for folks who want |
|
422 | + // raw UTF-8 that, e.g., might not map to iso-8859-1 |
|
423 | + // TODO: this can also be handled with xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, "ISO-8859-1"); |
|
424 | + if($this->decode_utf8){ |
|
425 | + $data = utf8_decode($data); |
|
426 | + } |
|
427 | + } |
|
428 | 428 | $this->message[$pos]['cdata'] .= $data; |
429 | 429 | // for doclit |
430 | 430 | if($this->status == 'header'){ |
431 | - $this->responseHeaders .= $data; |
|
431 | + $this->responseHeaders .= $data; |
|
432 | 432 | } else { |
433 | - $this->document .= $data; |
|
433 | + $this->document .= $data; |
|
434 | 434 | } |
435 | - } |
|
435 | + } |
|
436 | 436 | |
437 | - /** |
|
438 | - * get the parsed message (SOAP Body) |
|
439 | - * |
|
440 | - * @return mixed |
|
441 | - * @access public |
|
442 | - * @deprecated use get_soapbody instead |
|
443 | - */ |
|
444 | - function get_response(){ |
|
445 | - return $this->soapresponse; |
|
446 | - } |
|
437 | + /** |
|
438 | + * get the parsed message (SOAP Body) |
|
439 | + * |
|
440 | + * @return mixed |
|
441 | + * @access public |
|
442 | + * @deprecated use get_soapbody instead |
|
443 | + */ |
|
444 | + function get_response(){ |
|
445 | + return $this->soapresponse; |
|
446 | + } |
|
447 | 447 | |
448 | - /** |
|
449 | - * get the parsed SOAP Body (NULL if there was none) |
|
450 | - * |
|
451 | - * @return mixed |
|
452 | - * @access public |
|
453 | - */ |
|
454 | - function get_soapbody(){ |
|
455 | - return $this->soapresponse; |
|
456 | - } |
|
448 | + /** |
|
449 | + * get the parsed SOAP Body (NULL if there was none) |
|
450 | + * |
|
451 | + * @return mixed |
|
452 | + * @access public |
|
453 | + */ |
|
454 | + function get_soapbody(){ |
|
455 | + return $this->soapresponse; |
|
456 | + } |
|
457 | 457 | |
458 | - /** |
|
459 | - * get the parsed SOAP Header (NULL if there was none) |
|
460 | - * |
|
461 | - * @return mixed |
|
462 | - * @access public |
|
463 | - */ |
|
464 | - function get_soapheader(){ |
|
465 | - return $this->soapheader; |
|
466 | - } |
|
458 | + /** |
|
459 | + * get the parsed SOAP Header (NULL if there was none) |
|
460 | + * |
|
461 | + * @return mixed |
|
462 | + * @access public |
|
463 | + */ |
|
464 | + function get_soapheader(){ |
|
465 | + return $this->soapheader; |
|
466 | + } |
|
467 | 467 | |
468 | - /** |
|
469 | - * get the unparsed SOAP Header |
|
470 | - * |
|
471 | - * @return string XML or empty if no Header |
|
472 | - * @access public |
|
473 | - */ |
|
474 | - function getHeaders(){ |
|
475 | - return $this->responseHeaders; |
|
476 | - } |
|
468 | + /** |
|
469 | + * get the unparsed SOAP Header |
|
470 | + * |
|
471 | + * @return string XML or empty if no Header |
|
472 | + * @access public |
|
473 | + */ |
|
474 | + function getHeaders(){ |
|
475 | + return $this->responseHeaders; |
|
476 | + } |
|
477 | 477 | |
478 | - /** |
|
479 | - * decodes simple types into PHP variables |
|
480 | - * |
|
481 | - * @param string $value value to decode |
|
482 | - * @param string $type XML type to decode |
|
483 | - * @param string $typens XML type namespace to decode |
|
484 | - * @return mixed PHP value |
|
485 | - * @access private |
|
486 | - */ |
|
487 | - function decodeSimple($value, $type, $typens) { |
|
488 | - // TODO: use the namespace! |
|
489 | - if ((!isset($type)) || $type == 'string' || $type == 'long' || $type == 'unsignedLong') { |
|
490 | - return (string) $value; |
|
491 | - } |
|
492 | - if ($type == 'int' || $type == 'integer' || $type == 'short' || $type == 'byte') { |
|
493 | - return (int) $value; |
|
494 | - } |
|
495 | - if ($type == 'float' || $type == 'double' || $type == 'decimal') { |
|
496 | - return (double) $value; |
|
497 | - } |
|
498 | - if ($type == 'boolean') { |
|
499 | - if (strtolower($value) == 'false' || strtolower($value) == 'f') { |
|
500 | - return false; |
|
501 | - } |
|
502 | - return (boolean) $value; |
|
503 | - } |
|
504 | - if ($type == 'base64' || $type == 'base64Binary') { |
|
505 | - $this->debug('Decode base64 value'); |
|
506 | - return base64_decode($value); |
|
507 | - } |
|
508 | - // obscure numeric types |
|
509 | - if ($type == 'nonPositiveInteger' || $type == 'negativeInteger' |
|
510 | - || $type == 'nonNegativeInteger' || $type == 'positiveInteger' |
|
511 | - || $type == 'unsignedInt' |
|
512 | - || $type == 'unsignedShort' || $type == 'unsignedByte') { |
|
513 | - return (int) $value; |
|
514 | - } |
|
515 | - // bogus: parser treats array with no elements as a simple type |
|
516 | - if ($type == 'array') { |
|
517 | - return array(); |
|
518 | - } |
|
519 | - // everything else |
|
520 | - return (string) $value; |
|
521 | - } |
|
478 | + /** |
|
479 | + * decodes simple types into PHP variables |
|
480 | + * |
|
481 | + * @param string $value value to decode |
|
482 | + * @param string $type XML type to decode |
|
483 | + * @param string $typens XML type namespace to decode |
|
484 | + * @return mixed PHP value |
|
485 | + * @access private |
|
486 | + */ |
|
487 | + function decodeSimple($value, $type, $typens) { |
|
488 | + // TODO: use the namespace! |
|
489 | + if ((!isset($type)) || $type == 'string' || $type == 'long' || $type == 'unsignedLong') { |
|
490 | + return (string) $value; |
|
491 | + } |
|
492 | + if ($type == 'int' || $type == 'integer' || $type == 'short' || $type == 'byte') { |
|
493 | + return (int) $value; |
|
494 | + } |
|
495 | + if ($type == 'float' || $type == 'double' || $type == 'decimal') { |
|
496 | + return (double) $value; |
|
497 | + } |
|
498 | + if ($type == 'boolean') { |
|
499 | + if (strtolower($value) == 'false' || strtolower($value) == 'f') { |
|
500 | + return false; |
|
501 | + } |
|
502 | + return (boolean) $value; |
|
503 | + } |
|
504 | + if ($type == 'base64' || $type == 'base64Binary') { |
|
505 | + $this->debug('Decode base64 value'); |
|
506 | + return base64_decode($value); |
|
507 | + } |
|
508 | + // obscure numeric types |
|
509 | + if ($type == 'nonPositiveInteger' || $type == 'negativeInteger' |
|
510 | + || $type == 'nonNegativeInteger' || $type == 'positiveInteger' |
|
511 | + || $type == 'unsignedInt' |
|
512 | + || $type == 'unsignedShort' || $type == 'unsignedByte') { |
|
513 | + return (int) $value; |
|
514 | + } |
|
515 | + // bogus: parser treats array with no elements as a simple type |
|
516 | + if ($type == 'array') { |
|
517 | + return array(); |
|
518 | + } |
|
519 | + // everything else |
|
520 | + return (string) $value; |
|
521 | + } |
|
522 | 522 | |
523 | - /** |
|
524 | - * builds response structures for compound values (arrays/structs) |
|
525 | - * and scalars |
|
526 | - * |
|
527 | - * @param integer $pos position in node tree |
|
528 | - * @return mixed PHP value |
|
529 | - * @access private |
|
530 | - */ |
|
531 | - function buildVal($pos){ |
|
532 | - if(!isset($this->message[$pos]['type'])){ |
|
533 | - $this->message[$pos]['type'] = ''; |
|
534 | - } |
|
535 | - $this->debug('in buildVal() for '.$this->message[$pos]['name']."(pos $pos) of type ".$this->message[$pos]['type']); |
|
536 | - // if there are children... |
|
537 | - if($this->message[$pos]['children'] != ''){ |
|
538 | - $this->debug('in buildVal, there are children'); |
|
539 | - $children = explode('|',$this->message[$pos]['children']); |
|
540 | - array_shift($children); // knock off empty |
|
541 | - // md array |
|
542 | - if(isset($this->message[$pos]['arrayCols']) && $this->message[$pos]['arrayCols'] != ''){ |
|
543 | - $r=0; // rowcount |
|
544 | - $c=0; // colcount |
|
545 | - foreach($children as $child_pos){ |
|
546 | - $this->debug("in buildVal, got an MD array element: $r, $c"); |
|
547 | - $params[$r][] = $this->message[$child_pos]['result']; |
|
548 | - $c++; |
|
549 | - if($c == $this->message[$pos]['arrayCols']){ |
|
550 | - $c = 0; |
|
551 | - $r++; |
|
552 | - } |
|
523 | + /** |
|
524 | + * builds response structures for compound values (arrays/structs) |
|
525 | + * and scalars |
|
526 | + * |
|
527 | + * @param integer $pos position in node tree |
|
528 | + * @return mixed PHP value |
|
529 | + * @access private |
|
530 | + */ |
|
531 | + function buildVal($pos){ |
|
532 | + if(!isset($this->message[$pos]['type'])){ |
|
533 | + $this->message[$pos]['type'] = ''; |
|
534 | + } |
|
535 | + $this->debug('in buildVal() for '.$this->message[$pos]['name']."(pos $pos) of type ".$this->message[$pos]['type']); |
|
536 | + // if there are children... |
|
537 | + if($this->message[$pos]['children'] != ''){ |
|
538 | + $this->debug('in buildVal, there are children'); |
|
539 | + $children = explode('|',$this->message[$pos]['children']); |
|
540 | + array_shift($children); // knock off empty |
|
541 | + // md array |
|
542 | + if(isset($this->message[$pos]['arrayCols']) && $this->message[$pos]['arrayCols'] != ''){ |
|
543 | + $r=0; // rowcount |
|
544 | + $c=0; // colcount |
|
545 | + foreach($children as $child_pos){ |
|
546 | + $this->debug("in buildVal, got an MD array element: $r, $c"); |
|
547 | + $params[$r][] = $this->message[$child_pos]['result']; |
|
548 | + $c++; |
|
549 | + if($c == $this->message[$pos]['arrayCols']){ |
|
550 | + $c = 0; |
|
551 | + $r++; |
|
552 | + } |
|
553 | 553 | } |
554 | 554 | // array |
555 | - } elseif($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array'){ |
|
555 | + } elseif($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array'){ |
|
556 | 556 | $this->debug('in buildVal, adding array '.$this->message[$pos]['name']); |
557 | 557 | foreach($children as $child_pos){ |
558 | - $params[] = &$this->message[$child_pos]['result']; |
|
558 | + $params[] = &$this->message[$child_pos]['result']; |
|
559 | 559 | } |
560 | 560 | // apache Map type: java hashtable |
561 | 561 | } elseif($this->message[$pos]['type'] == 'Map' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap'){ |
562 | 562 | $this->debug('in buildVal, Java Map '.$this->message[$pos]['name']); |
563 | 563 | foreach($children as $child_pos){ |
564 | - $kv = explode("|",$this->message[$child_pos]['children']); |
|
565 | - $params[$this->message[$kv[1]]['result']] = &$this->message[$kv[2]]['result']; |
|
564 | + $kv = explode("|",$this->message[$child_pos]['children']); |
|
565 | + $params[$this->message[$kv[1]]['result']] = &$this->message[$kv[2]]['result']; |
|
566 | 566 | } |
567 | 567 | // generic compound type |
568 | 568 | //} elseif($this->message[$pos]['type'] == 'SOAPStruct' || $this->message[$pos]['type'] == 'struct') { |
569 | - } else { |
|
570 | - // Apache Vector type: treat as an array |
|
569 | + } else { |
|
570 | + // Apache Vector type: treat as an array |
|
571 | 571 | $this->debug('in buildVal, adding Java Vector or generic compound type '.$this->message[$pos]['name']); |
572 | - if ($this->message[$pos]['type'] == 'Vector' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap') { |
|
573 | - $notstruct = 1; |
|
574 | - } else { |
|
575 | - $notstruct = 0; |
|
576 | - } |
|
577 | - // |
|
578 | - foreach($children as $child_pos){ |
|
579 | - if($notstruct){ |
|
580 | - $params[] = &$this->message[$child_pos]['result']; |
|
581 | - } else { |
|
582 | - if (isset($params[$this->message[$child_pos]['name']])) { |
|
583 | - // de-serialize repeated element name into an array |
|
584 | - if ((!is_array($params[$this->message[$child_pos]['name']])) || (!isset($params[$this->message[$child_pos]['name']][0]))) { |
|
585 | - $params[$this->message[$child_pos]['name']] = array($params[$this->message[$child_pos]['name']]); |
|
586 | - } |
|
587 | - $params[$this->message[$child_pos]['name']][] = &$this->message[$child_pos]['result']; |
|
588 | - } else { |
|
589 | - $params[$this->message[$child_pos]['name']] = &$this->message[$child_pos]['result']; |
|
590 | - } |
|
591 | - } |
|
572 | + if ($this->message[$pos]['type'] == 'Vector' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap') { |
|
573 | + $notstruct = 1; |
|
574 | + } else { |
|
575 | + $notstruct = 0; |
|
592 | 576 | } |
593 | - } |
|
594 | - if (isset($this->message[$pos]['xattrs'])) { |
|
577 | + // |
|
578 | + foreach($children as $child_pos){ |
|
579 | + if($notstruct){ |
|
580 | + $params[] = &$this->message[$child_pos]['result']; |
|
581 | + } else { |
|
582 | + if (isset($params[$this->message[$child_pos]['name']])) { |
|
583 | + // de-serialize repeated element name into an array |
|
584 | + if ((!is_array($params[$this->message[$child_pos]['name']])) || (!isset($params[$this->message[$child_pos]['name']][0]))) { |
|
585 | + $params[$this->message[$child_pos]['name']] = array($params[$this->message[$child_pos]['name']]); |
|
586 | + } |
|
587 | + $params[$this->message[$child_pos]['name']][] = &$this->message[$child_pos]['result']; |
|
588 | + } else { |
|
589 | + $params[$this->message[$child_pos]['name']] = &$this->message[$child_pos]['result']; |
|
590 | + } |
|
591 | + } |
|
592 | + } |
|
593 | + } |
|
594 | + if (isset($this->message[$pos]['xattrs'])) { |
|
595 | 595 | $this->debug('in buildVal, handling attributes'); |
596 | - foreach ($this->message[$pos]['xattrs'] as $n => $v) { |
|
597 | - $params[$n] = $v; |
|
598 | - } |
|
599 | - } |
|
600 | - // handle simpleContent |
|
601 | - if (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') { |
|
596 | + foreach ($this->message[$pos]['xattrs'] as $n => $v) { |
|
597 | + $params[$n] = $v; |
|
598 | + } |
|
599 | + } |
|
600 | + // handle simpleContent |
|
601 | + if (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') { |
|
602 | 602 | $this->debug('in buildVal, handling simpleContent'); |
603 | - if (isset($this->message[$pos]['type'])) { |
|
604 | - $params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
605 | - } else { |
|
606 | - $parent = $this->message[$pos]['parent']; |
|
607 | - if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
608 | - $params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
609 | - } else { |
|
610 | - $params['!'] = $this->message[$pos]['cdata']; |
|
611 | - } |
|
612 | - } |
|
613 | - } |
|
614 | - $ret = is_array($params) ? $params : array(); |
|
615 | - $this->debug('in buildVal, return:'); |
|
616 | - //$this->appendDebug($this->varDump($ret)); |
|
617 | - return $ret; |
|
618 | - } else { |
|
619 | - $this->debug('in buildVal, no children, building scalar'); |
|
620 | - $cdata = isset($this->message[$pos]['cdata']) ? $this->message[$pos]['cdata'] : ''; |
|
621 | - if (isset($this->message[$pos]['type'])) { |
|
622 | - $ret = $this->decodeSimple($cdata, $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
623 | - $this->debug("in buildVal, return: $ret"); |
|
624 | - return $ret; |
|
625 | - } |
|
626 | - $parent = $this->message[$pos]['parent']; |
|
627 | - if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
628 | - $ret = $this->decodeSimple($cdata, $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
629 | - $this->debug("in buildVal, return: $ret"); |
|
630 | - return $ret; |
|
631 | - } |
|
632 | - $ret = $this->message[$pos]['cdata']; |
|
633 | - $this->debug("in buildVal, return: $ret"); |
|
634 | - return $ret; |
|
635 | - } |
|
636 | - } |
|
603 | + if (isset($this->message[$pos]['type'])) { |
|
604 | + $params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
605 | + } else { |
|
606 | + $parent = $this->message[$pos]['parent']; |
|
607 | + if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
608 | + $params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
609 | + } else { |
|
610 | + $params['!'] = $this->message[$pos]['cdata']; |
|
611 | + } |
|
612 | + } |
|
613 | + } |
|
614 | + $ret = is_array($params) ? $params : array(); |
|
615 | + $this->debug('in buildVal, return:'); |
|
616 | + //$this->appendDebug($this->varDump($ret)); |
|
617 | + return $ret; |
|
618 | + } else { |
|
619 | + $this->debug('in buildVal, no children, building scalar'); |
|
620 | + $cdata = isset($this->message[$pos]['cdata']) ? $this->message[$pos]['cdata'] : ''; |
|
621 | + if (isset($this->message[$pos]['type'])) { |
|
622 | + $ret = $this->decodeSimple($cdata, $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : ''); |
|
623 | + $this->debug("in buildVal, return: $ret"); |
|
624 | + return $ret; |
|
625 | + } |
|
626 | + $parent = $this->message[$pos]['parent']; |
|
627 | + if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) { |
|
628 | + $ret = $this->decodeSimple($cdata, $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : ''); |
|
629 | + $this->debug("in buildVal, return: $ret"); |
|
630 | + return $ret; |
|
631 | + } |
|
632 | + $ret = $this->message[$pos]['cdata']; |
|
633 | + $this->debug("in buildVal, return: $ret"); |
|
634 | + return $ret; |
|
635 | + } |
|
636 | + } |
|
637 | 637 | } |
638 | 638 | |
639 | 639 | /** |
@@ -320,13 +320,13 @@ discard block |
||
320 | 320 | $firstname = $userInfo['firstname']; |
321 | 321 | $lastname = $userInfo['lastname']; |
322 | 322 | |
323 | - if (api_is_western_name_order()) { |
|
324 | - $message = sprintf(get_lang('AttemptingToLoginAs'),$firstname, $lastname, $userId); |
|
325 | - } else { |
|
326 | - $message = sprintf(get_lang('AttemptingToLoginAs'), $lastname, $firstname, $userId); |
|
327 | - } |
|
323 | + if (api_is_western_name_order()) { |
|
324 | + $message = sprintf(get_lang('AttemptingToLoginAs'),$firstname, $lastname, $userId); |
|
325 | + } else { |
|
326 | + $message = sprintf(get_lang('AttemptingToLoginAs'), $lastname, $firstname, $userId); |
|
327 | + } |
|
328 | 328 | |
329 | - if ($userId) { |
|
329 | + if ($userId) { |
|
330 | 330 | |
331 | 331 | // Logout the current user |
332 | 332 | LoginDelete(api_get_user_id()); |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | Display :: display_footer(); |
362 | 362 | exit; |
363 | 363 | |
364 | - } |
|
364 | + } |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | /** |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | }*/ |
401 | 401 | |
402 | 402 | if (!in_array($direction, array('ASC','DESC'))) { |
403 | - $direction = 'ASC'; |
|
403 | + $direction = 'ASC'; |
|
404 | 404 | } |
405 | 405 | $column = intval($column); |
406 | 406 | $from = intval($from); |
@@ -411,23 +411,23 @@ discard block |
||
411 | 411 | $sql .= " WHERE u.creator_id = ".api_get_user_id(); |
412 | 412 | } |
413 | 413 | |
414 | - $sql .= " ORDER BY col$column $direction "; |
|
415 | - $sql .= " LIMIT $from,$number_of_items"; |
|
414 | + $sql .= " ORDER BY col$column $direction "; |
|
415 | + $sql .= " LIMIT $from,$number_of_items"; |
|
416 | 416 | |
417 | - $res = Database::query($sql); |
|
417 | + $res = Database::query($sql); |
|
418 | 418 | |
419 | - $users = array (); |
|
419 | + $users = array (); |
|
420 | 420 | $t = time(); |
421 | - while ($user = Database::fetch_row($res)) { |
|
422 | - $userPicture = UserManager::getUserPicture($user[0], USER_IMAGE_SIZE_SMALL); |
|
423 | - $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]).'" />'; |
|
421 | + while ($user = Database::fetch_row($res)) { |
|
422 | + $userPicture = UserManager::getUserPicture($user[0], USER_IMAGE_SIZE_SMALL); |
|
423 | + $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]).'" />'; |
|
424 | 424 | |
425 | 425 | if ($user[7] == 1 && !empty($user[10])) { |
426 | 426 | // check expiration date |
427 | 427 | $expiration_time = convert_sql_date($user[10]); |
428 | 428 | // if expiration date is passed, store a special value for active field |
429 | 429 | if ($expiration_time < $t) { |
430 | - $user[7] = '-1'; |
|
430 | + $user[7] = '-1'; |
|
431 | 431 | } |
432 | 432 | } |
433 | 433 | |
@@ -445,9 +445,9 @@ discard block |
||
445 | 445 | api_get_local_time($user[9]), |
446 | 446 | $user[0] |
447 | 447 | ); |
448 | - } |
|
448 | + } |
|
449 | 449 | |
450 | - return $users; |
|
450 | + return $users; |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | /** |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | * @return string HTML-code with a mailto-link |
457 | 457 | */ |
458 | 458 | function email_filter($email) { |
459 | - return Display :: encrypted_mailto_link($email, $email); |
|
459 | + return Display :: encrypted_mailto_link($email, $email); |
|
460 | 460 | } |
461 | 461 | |
462 | 462 | /** |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | * @return string HTML-code with a mailto-link |
466 | 466 | */ |
467 | 467 | function user_filter($name, $params, $row) { |
468 | - return '<a href="'.api_get_path(WEB_PATH).'whoisonline.php?origin=user_list&id='.$row[0].'">'.$name.'</a>'; |
|
468 | + return '<a href="'.api_get_path(WEB_PATH).'whoisonline.php?origin=user_list&id='.$row[0].'">'.$name.'</a>'; |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | /** |
@@ -476,71 +476,71 @@ discard block |
||
476 | 476 | * @return string Some HTML-code with modify-buttons |
477 | 477 | */ |
478 | 478 | function modify_filter($user_id, $url_params, $row) { |
479 | - global $charset, $_admins_list; |
|
480 | - $is_admin = in_array($user_id,$_admins_list); |
|
481 | - $statusname = api_get_status_langvars(); |
|
482 | - $user_is_anonymous = false; |
|
479 | + global $charset, $_admins_list; |
|
480 | + $is_admin = in_array($user_id,$_admins_list); |
|
481 | + $statusname = api_get_status_langvars(); |
|
482 | + $user_is_anonymous = false; |
|
483 | 483 | $current_user_status_label = $row['7']; |
484 | 484 | |
485 | - if ($current_user_status_label == $statusname[ANONYMOUS]) { |
|
486 | - $user_is_anonymous =true; |
|
487 | - } |
|
488 | - $result = ''; |
|
489 | - if (!$user_is_anonymous) { |
|
490 | - $icon = Display::return_icon('course.png', get_lang('Courses'), array('onmouseout' => 'clear_course_list (\'div_'.$user_id.'\')')); |
|
491 | - $result .= '<a href="javascript:void(0)" onclick="load_course_list(\'div_'.$user_id.'\','.$user_id.')" > |
|
485 | + if ($current_user_status_label == $statusname[ANONYMOUS]) { |
|
486 | + $user_is_anonymous =true; |
|
487 | + } |
|
488 | + $result = ''; |
|
489 | + if (!$user_is_anonymous) { |
|
490 | + $icon = Display::return_icon('course.png', get_lang('Courses'), array('onmouseout' => 'clear_course_list (\'div_'.$user_id.'\')')); |
|
491 | + $result .= '<a href="javascript:void(0)" onclick="load_course_list(\'div_'.$user_id.'\','.$user_id.')" > |
|
492 | 492 | '.$icon.' |
493 | 493 | <div class="blackboard_hide" id="div_'.$user_id.'"> </div> |
494 | 494 | </a>'; |
495 | 495 | |
496 | 496 | $icon = Display::return_icon('session.png', get_lang('Sessions'), array('onmouseout' => 'clear_session_list (\'div_s_'.$user_id.'\')')); |
497 | - $result .= '<a href="javascript:void(0)" onclick="load_session_list(\'div_s_'.$user_id.'\','.$user_id.')" > |
|
497 | + $result .= '<a href="javascript:void(0)" onclick="load_session_list(\'div_s_'.$user_id.'\','.$user_id.')" > |
|
498 | 498 | '.$icon.' |
499 | 499 | <div class="blackboard_hide" id="div_s_'.$user_id.'"> </div> |
500 | 500 | </a>'; |
501 | - } else { |
|
502 | - $result .= Display::return_icon('course_na.png',get_lang('Courses')).' '; |
|
503 | - $result .= Display::return_icon('course_na.png',get_lang('Sessions')).' '; |
|
504 | - } |
|
501 | + } else { |
|
502 | + $result .= Display::return_icon('course_na.png',get_lang('Courses')).' '; |
|
503 | + $result .= Display::return_icon('course_na.png',get_lang('Sessions')).' '; |
|
504 | + } |
|
505 | 505 | |
506 | - if (api_is_platform_admin()) { |
|
507 | - if (!$user_is_anonymous) { |
|
508 | - $result .= '<a href="user_information.php?user_id='.$user_id.'">'.Display::return_icon('synthese_view.gif', get_lang('Info')).'</a> '; |
|
509 | - } else { |
|
510 | - $result .= Display::return_icon('synthese_view_na.gif', get_lang('Info')).' '; |
|
511 | - } |
|
512 | - } |
|
506 | + if (api_is_platform_admin()) { |
|
507 | + if (!$user_is_anonymous) { |
|
508 | + $result .= '<a href="user_information.php?user_id='.$user_id.'">'.Display::return_icon('synthese_view.gif', get_lang('Info')).'</a> '; |
|
509 | + } else { |
|
510 | + $result .= Display::return_icon('synthese_view_na.gif', get_lang('Info')).' '; |
|
511 | + } |
|
512 | + } |
|
513 | 513 | |
514 | 514 | //only allow platform admins to login_as, or session admins only for students (not teachers nor other admins) |
515 | 515 | if (api_is_platform_admin() || (api_is_session_admin() && $current_user_status_label == $statusname[STUDENT])) { |
516 | - if (!$user_is_anonymous) { |
|
516 | + if (!$user_is_anonymous) { |
|
517 | 517 | if (api_global_admin_can_edit_admin($user_id)) { |
518 | 518 | $result .= '<a href="user_list.php?action=login_as&user_id='.$user_id.'&sec_token='.$_SESSION['sec_token'].'">'.Display::return_icon('login_as.png', get_lang('LoginAs')).'</a> '; |
519 | 519 | } else { |
520 | 520 | $result .= Display::return_icon('login_as_na.png', get_lang('LoginAs')).' '; |
521 | 521 | } |
522 | - } else { |
|
523 | - $result .= Display::return_icon('login_as_na.png', get_lang('LoginAs')).' '; |
|
524 | - } |
|
522 | + } else { |
|
523 | + $result .= Display::return_icon('login_as_na.png', get_lang('LoginAs')).' '; |
|
524 | + } |
|
525 | 525 | } else { |
526 | - $result .= Display::return_icon('login_as_na.png', get_lang('LoginAs')).' '; |
|
526 | + $result .= Display::return_icon('login_as_na.png', get_lang('LoginAs')).' '; |
|
527 | 527 | } |
528 | 528 | |
529 | - if ($current_user_status_label != $statusname[STUDENT]) { |
|
530 | - $result .= Display::return_icon('statistics_na.gif', get_lang('Reporting')).' '; |
|
531 | - } else { |
|
532 | - $result .= '<a href="../mySpace/myStudents.php?student='.$user_id.'">'.Display::return_icon('statistics.gif', get_lang('Reporting')).'</a> '; |
|
533 | - } |
|
529 | + if ($current_user_status_label != $statusname[STUDENT]) { |
|
530 | + $result .= Display::return_icon('statistics_na.gif', get_lang('Reporting')).' '; |
|
531 | + } else { |
|
532 | + $result .= '<a href="../mySpace/myStudents.php?student='.$user_id.'">'.Display::return_icon('statistics.gif', get_lang('Reporting')).'</a> '; |
|
533 | + } |
|
534 | 534 | |
535 | - if (api_is_platform_admin(true)) { |
|
535 | + if (api_is_platform_admin(true)) { |
|
536 | 536 | $editProfileUrl = Display::getProfileEditionLink($user_id, true); |
537 | 537 | |
538 | 538 | if (!$user_is_anonymous && api_global_admin_can_edit_admin($user_id, null, true)) { |
539 | 539 | $result .= '<a href="' . $editProfileUrl . '">'.Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a> '; |
540 | - } else { |
|
540 | + } else { |
|
541 | 541 | $result .= Display::return_icon('edit_na.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a> '; |
542 | - } |
|
543 | - } |
|
542 | + } |
|
543 | + } |
|
544 | 544 | |
545 | 545 | $allowAssignSkill = api_is_platform_admin(false, true); |
546 | 546 | |
@@ -551,14 +551,14 @@ discard block |
||
551 | 551 | ); |
552 | 552 | } |
553 | 553 | |
554 | - if ($is_admin) { |
|
555 | - $result .= Display::return_icon('admin_star.png', get_lang('IsAdministrator'),array('width'=> ICON_SIZE_SMALL, 'heigth'=> ICON_SIZE_SMALL)); |
|
556 | - } else { |
|
557 | - $result .= Display::return_icon('admin_star_na.png', get_lang('IsNotAdministrator')); |
|
558 | - } |
|
554 | + if ($is_admin) { |
|
555 | + $result .= Display::return_icon('admin_star.png', get_lang('IsAdministrator'),array('width'=> ICON_SIZE_SMALL, 'heigth'=> ICON_SIZE_SMALL)); |
|
556 | + } else { |
|
557 | + $result .= Display::return_icon('admin_star_na.png', get_lang('IsNotAdministrator')); |
|
558 | + } |
|
559 | 559 | |
560 | - // actions for assigning sessions, courses or users |
|
561 | - if (!api_is_session_admin()) { |
|
560 | + // actions for assigning sessions, courses or users |
|
561 | + if (!api_is_session_admin()) { |
|
562 | 562 | if ($current_user_status_label == $statusname[SESSIONADMIN]) { |
563 | 563 | $result .= Display::url( |
564 | 564 | Display::return_icon('view_more_stats.gif', get_lang('AssignSessions')), |
@@ -588,7 +588,7 @@ discard block |
||
588 | 588 | ); |
589 | 589 | } |
590 | 590 | } |
591 | - } |
|
591 | + } |
|
592 | 592 | |
593 | 593 | if (api_is_platform_admin()) { |
594 | 594 | $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">'. |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | } |
607 | 607 | } |
608 | 608 | } |
609 | - return $result; |
|
609 | + return $result; |
|
610 | 610 | } |
611 | 611 | |
612 | 612 | |
@@ -639,10 +639,10 @@ discard block |
||
639 | 639 | if ($action == 'edit') { |
640 | 640 | $result = Display::return_icon($image.'.png', get_lang('AccountExpired'), array(), 16); |
641 | 641 | } elseif ($row['0']<>$_user['user_id']) { |
642 | - // 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. |
|
643 | - $result = Display::return_icon($image.'.png', get_lang(ucfirst($action)), array('onclick'=>'active_user(this);', 'id'=>'img_'.$row['0']), 16).'</a>'; |
|
644 | - } |
|
645 | - return $result; |
|
642 | + // 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. |
|
643 | + $result = Display::return_icon($image.'.png', get_lang(ucfirst($action)), array('onclick'=>'active_user(this);', 'id'=>'img_'.$row['0']), 16).'</a>'; |
|
644 | + } |
|
645 | + return $result; |
|
646 | 646 | } |
647 | 647 | |
648 | 648 | /** |
@@ -655,8 +655,8 @@ discard block |
||
655 | 655 | * @author Patrick Cool <[email protected]>, Ghent University, Belgium |
656 | 656 | */ |
657 | 657 | function status_filter($status) { |
658 | - $statusname = api_get_status_langvars(); |
|
659 | - return $statusname[$status]; |
|
658 | + $statusname = api_get_status_langvars(); |
|
659 | + return $statusname[$status]; |
|
660 | 660 | } |
661 | 661 | |
662 | 662 | if (isset($_GET['keyword']) || isset($_GET['keyword_firstname'])) { |
@@ -672,8 +672,8 @@ discard block |
||
672 | 672 | |
673 | 673 | if (!empty($action)) { |
674 | 674 | $check = Security::check_token('get'); |
675 | - if ($check) { |
|
676 | - switch ($action) { |
|
675 | + if ($check) { |
|
676 | + switch ($action) { |
|
677 | 677 | case 'add_user_to_my_url': |
678 | 678 | $user_id = $_REQUEST["user_id"]; |
679 | 679 | $result = UrlManager::add_user_to_url($user_id, $current_access_url_id); |
@@ -683,45 +683,45 @@ discard block |
||
683 | 683 | $message = Display::return_message($message, 'confirmation'); |
684 | 684 | } |
685 | 685 | break; |
686 | - case 'delete_user': |
|
687 | - if (api_is_platform_admin()) { |
|
686 | + case 'delete_user': |
|
687 | + if (api_is_platform_admin()) { |
|
688 | 688 | $user_to_delete = $_GET['user_id']; |
689 | 689 | $current_user_id = api_get_user_id(); |
690 | 690 | |
691 | - if ($deleteUserAvailable && api_global_admin_can_edit_admin($_GET['user_id'])) { |
|
692 | - if ($user_to_delete != $current_user_id && UserManager :: delete_user($_GET['user_id'])) { |
|
693 | - $message = Display :: return_message(get_lang('UserDeleted'), 'confirmation'); |
|
694 | - } else { |
|
695 | - $message = Display :: return_message(get_lang('CannotDeleteUserBecauseOwnsCourse'), 'error'); |
|
696 | - } |
|
697 | - } else { |
|
698 | - $message = Display :: return_message(get_lang('CannotDeleteUser'),'error'); |
|
699 | - } |
|
700 | - } |
|
701 | - break; |
|
691 | + if ($deleteUserAvailable && api_global_admin_can_edit_admin($_GET['user_id'])) { |
|
692 | + if ($user_to_delete != $current_user_id && UserManager :: delete_user($_GET['user_id'])) { |
|
693 | + $message = Display :: return_message(get_lang('UserDeleted'), 'confirmation'); |
|
694 | + } else { |
|
695 | + $message = Display :: return_message(get_lang('CannotDeleteUserBecauseOwnsCourse'), 'error'); |
|
696 | + } |
|
697 | + } else { |
|
698 | + $message = Display :: return_message(get_lang('CannotDeleteUser'),'error'); |
|
699 | + } |
|
700 | + } |
|
701 | + break; |
|
702 | 702 | case 'delete': |
703 | - if (api_is_platform_admin()) { |
|
704 | - $number_of_selected_users = count($_POST['id']); |
|
705 | - $number_of_deleted_users = 0; |
|
706 | - if (is_array($_POST['id'])) { |
|
707 | - foreach ($_POST['id'] as $index => $user_id) { |
|
708 | - if ($user_id != $_user['user_id']) { |
|
709 | - if (UserManager::delete_user($user_id)) { |
|
710 | - $number_of_deleted_users++; |
|
711 | - } |
|
712 | - } |
|
713 | - } |
|
714 | - } |
|
715 | - if ($number_of_selected_users == $number_of_deleted_users) { |
|
703 | + if (api_is_platform_admin()) { |
|
704 | + $number_of_selected_users = count($_POST['id']); |
|
705 | + $number_of_deleted_users = 0; |
|
706 | + if (is_array($_POST['id'])) { |
|
707 | + foreach ($_POST['id'] as $index => $user_id) { |
|
708 | + if ($user_id != $_user['user_id']) { |
|
709 | + if (UserManager::delete_user($user_id)) { |
|
710 | + $number_of_deleted_users++; |
|
711 | + } |
|
712 | + } |
|
713 | + } |
|
714 | + } |
|
715 | + if ($number_of_selected_users == $number_of_deleted_users) { |
|
716 | 716 | $message = Display :: return_message(get_lang('SelectedUsersDeleted'), 'confirmation'); |
717 | - } else { |
|
717 | + } else { |
|
718 | 718 | $message = Display :: return_message(get_lang('SomeUsersNotDeleted'), 'error'); |
719 | - } |
|
720 | - } |
|
721 | - break; |
|
722 | - } |
|
723 | - Security::clear_token(); |
|
724 | - } |
|
719 | + } |
|
720 | + } |
|
721 | + break; |
|
722 | + } |
|
723 | + Security::clear_token(); |
|
724 | + } |
|
725 | 725 | } |
726 | 726 | |
727 | 727 | // Create a search-box |
@@ -737,24 +737,24 @@ discard block |
||
737 | 737 | $actionsCenter = ''; |
738 | 738 | $actionsRight = ''; |
739 | 739 | if (api_is_platform_admin()) { |
740 | - $actionsRight .= '<a class="pull-right" href="'.api_get_path(WEB_CODE_PATH).'admin/user_add.php">'. |
|
741 | - Display::return_icon('new_user.png',get_lang('AddUsers'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
740 | + $actionsRight .= '<a class="pull-right" href="'.api_get_path(WEB_CODE_PATH).'admin/user_add.php">'. |
|
741 | + Display::return_icon('new_user.png',get_lang('AddUsers'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
742 | 742 | } |
743 | 743 | |
744 | 744 | $actionsLeft .= $form->return_form(); |
745 | 745 | $actionsCenter .= $searchAdvanced; |
746 | 746 | |
747 | 747 | if (isset ($_GET['keyword'])) { |
748 | - $parameters = array ('keyword' => Security::remove_XSS($_GET['keyword'])); |
|
748 | + $parameters = array ('keyword' => Security::remove_XSS($_GET['keyword'])); |
|
749 | 749 | } elseif (isset ($_GET['keyword_firstname'])) { |
750 | - $parameters['keyword_firstname'] = Security::remove_XSS($_GET['keyword_firstname']); |
|
751 | - $parameters['keyword_lastname'] = Security::remove_XSS($_GET['keyword_lastname']); |
|
752 | - $parameters['keyword_username'] = Security::remove_XSS($_GET['keyword_username']); |
|
753 | - $parameters['keyword_email'] = Security::remove_XSS($_GET['keyword_email']); |
|
754 | - $parameters['keyword_officialcode'] = Security::remove_XSS($_GET['keyword_officialcode']); |
|
755 | - $parameters['keyword_status'] = Security::remove_XSS($_GET['keyword_status']); |
|
756 | - $parameters['keyword_active'] = Security::remove_XSS($_GET['keyword_active']); |
|
757 | - $parameters['keyword_inactive'] = Security::remove_XSS($_GET['keyword_inactive']); |
|
750 | + $parameters['keyword_firstname'] = Security::remove_XSS($_GET['keyword_firstname']); |
|
751 | + $parameters['keyword_lastname'] = Security::remove_XSS($_GET['keyword_lastname']); |
|
752 | + $parameters['keyword_username'] = Security::remove_XSS($_GET['keyword_username']); |
|
753 | + $parameters['keyword_email'] = Security::remove_XSS($_GET['keyword_email']); |
|
754 | + $parameters['keyword_officialcode'] = Security::remove_XSS($_GET['keyword_officialcode']); |
|
755 | + $parameters['keyword_status'] = Security::remove_XSS($_GET['keyword_status']); |
|
756 | + $parameters['keyword_active'] = Security::remove_XSS($_GET['keyword_active']); |
|
757 | + $parameters['keyword_inactive'] = Security::remove_XSS($_GET['keyword_inactive']); |
|
758 | 758 | } |
759 | 759 | // Create a sortable table with user-data |
760 | 760 | $parameters['sec_token'] = Security::get_token(); |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | $res_admin = Database::query($sql_admin); |
766 | 766 | $_admins_list = array(); |
767 | 767 | while ($row_admin = Database::fetch_row($res_admin)) { |
768 | - $_admins_list[] = $row_admin[0]; |
|
768 | + $_admins_list[] = $row_admin[0]; |
|
769 | 769 | } |
770 | 770 | |
771 | 771 | // Display Advanced search form. |
@@ -821,11 +821,11 @@ discard block |
||
821 | 821 | $table->set_header(2, get_lang('OfficialCode')); |
822 | 822 | |
823 | 823 | if (api_is_western_name_order()) { |
824 | - $table->set_header(3, get_lang('FirstName')); |
|
825 | - $table->set_header(4, get_lang('LastName')); |
|
824 | + $table->set_header(3, get_lang('FirstName')); |
|
825 | + $table->set_header(4, get_lang('LastName')); |
|
826 | 826 | } else { |
827 | - $table->set_header(3, get_lang('LastName')); |
|
828 | - $table->set_header(4, get_lang('FirstName')); |
|
827 | + $table->set_header(3, get_lang('LastName')); |
|
828 | + $table->set_header(4, get_lang('FirstName')); |
|
829 | 829 | } |
830 | 830 | $table->set_header(5, get_lang('LoginName')); |
831 | 831 | $table->set_header(6, get_lang('Email')); |