@@ -6,7 +6,6 @@ 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 |
@@ -335,7 +334,7 @@ discard block |
||
335 | 334 | // Storing the attachments if any |
336 | 335 | if ($result) { |
337 | 336 | $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' )"; |
|
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' )"; |
|
339 | 338 | Database::query($sql); |
340 | 339 | $id = Database::insert_id(); |
341 | 340 | if ($id) { |
@@ -479,7 +478,7 @@ discard block |
||
479 | 478 | // Storing the attachments if any |
480 | 479 | if ($result) { |
481 | 480 | $sql='INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size,blog_id,comment_id) '. |
482 | - "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."' )"; |
|
481 | + "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."' )"; |
|
483 | 482 | Database::query($sql); |
484 | 483 | |
485 | 484 | $id = Database::insert_id(); |
@@ -1398,10 +1397,10 @@ discard block |
||
1398 | 1397 | echo '<span class="blogpost_title">' . get_lang('TaskList') . '</span><br />'; |
1399 | 1398 | echo "<table class=\"data_table\">"; |
1400 | 1399 | echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">", |
1401 | - "<th width='240'><b>",get_lang('Title'),"</b></th>", |
|
1402 | - "<th><b>",get_lang('Description'),"</b></th>", |
|
1403 | - "<th><b>",get_lang('Color'),"</b></th>", |
|
1404 | - "<th width='50'><b>",get_lang('Modify'),"</b></th>", |
|
1400 | + "<th width='240'><b>",get_lang('Title'),"</b></th>", |
|
1401 | + "<th><b>",get_lang('Description'),"</b></th>", |
|
1402 | + "<th><b>",get_lang('Color'),"</b></th>", |
|
1403 | + "<th width='50'><b>",get_lang('Modify'),"</b></th>", |
|
1405 | 1404 | "</tr>"; |
1406 | 1405 | |
1407 | 1406 | |
@@ -1433,14 +1432,14 @@ discard block |
||
1433 | 1432 | echo '<td width="50">'; |
1434 | 1433 | echo '<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$task['blog_id'].'&do=edit&task_id='.$task['task_id'].'">'; |
1435 | 1434 | echo Display::return_icon('edit.png', get_lang('EditTask')); |
1436 | - echo "</a>"; |
|
1437 | - echo '<a href="'.$delete_link.'"'; |
|
1438 | - echo $delete_confirm; |
|
1439 | - echo '>'; |
|
1435 | + echo "</a>"; |
|
1436 | + echo '<a href="'.$delete_link.'"'; |
|
1437 | + echo $delete_confirm; |
|
1438 | + echo '>'; |
|
1440 | 1439 | echo Display::return_icon($delete_icon, $delete_title); |
1441 | - echo "</a>"; |
|
1442 | - echo '</td>'; |
|
1443 | - echo '</tr>'; |
|
1440 | + echo "</a>"; |
|
1441 | + echo '</td>'; |
|
1442 | + echo '</tr>'; |
|
1444 | 1443 | } |
1445 | 1444 | echo "</table>"; |
1446 | 1445 | } |
@@ -1464,11 +1463,11 @@ discard block |
||
1464 | 1463 | echo '<span class="blogpost_title">' . get_lang('AssignedTasks') . '</span><br />'; |
1465 | 1464 | echo "<table class=\"data_table\">"; |
1466 | 1465 | echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">", |
1467 | - "<th width='240'><b>",get_lang('Member'),"</b></th>", |
|
1468 | - "<th><b>",get_lang('Task'),"</b></th>", |
|
1469 | - "<th><b>",get_lang('Description'),"</b></th>", |
|
1470 | - "<th><b>",get_lang('TargetDate'),"</b></th>", |
|
1471 | - "<th width='50'><b>",get_lang('Modify'),"</b></th>", |
|
1466 | + "<th width='240'><b>",get_lang('Member'),"</b></th>", |
|
1467 | + "<th><b>",get_lang('Task'),"</b></th>", |
|
1468 | + "<th><b>",get_lang('Description'),"</b></th>", |
|
1469 | + "<th><b>",get_lang('TargetDate'),"</b></th>", |
|
1470 | + "<th width='50'><b>",get_lang('Modify'),"</b></th>", |
|
1472 | 1471 | "</tr>"; |
1473 | 1472 | |
1474 | 1473 | $course_id = api_get_course_int_id(); |
@@ -2316,7 +2315,7 @@ discard block |
||
2316 | 2315 | * @param Integer $year: the 4-digit year indication e.g. 2005 |
2317 | 2316 | * |
2318 | 2317 | * @return html code |
2319 | - */ |
|
2318 | + */ |
|
2320 | 2319 | public static function display_minimonthcalendar($month, $year, $blog_id) |
2321 | 2320 | { |
2322 | 2321 | // Init |
@@ -2609,34 +2608,34 @@ discard block |
||
2609 | 2608 | */ |
2610 | 2609 | function get_blog_attachment($blog_id, $post_id=null,$comment_id=null) |
2611 | 2610 | { |
2612 | - $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
2613 | - |
|
2614 | - $blog_id = intval($blog_id); |
|
2615 | - $comment_id = intval($comment_id); |
|
2616 | - $post_id = intval($post_id); |
|
2617 | - $row=array(); |
|
2618 | - $where=''; |
|
2619 | - if (!empty ($post_id) && is_numeric($post_id)) { |
|
2620 | - $where.=' AND post_id ="'.$post_id.'" '; |
|
2621 | - } |
|
2622 | - |
|
2623 | - if (!empty ($comment_id) && is_numeric($comment_id)) { |
|
2624 | - if (!empty ($post_id)) { |
|
2625 | - $where.= ' AND '; |
|
2626 | - } |
|
2627 | - $where.=' comment_id ="'.$comment_id.'" '; |
|
2628 | - } |
|
2611 | + $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
2612 | + |
|
2613 | + $blog_id = intval($blog_id); |
|
2614 | + $comment_id = intval($comment_id); |
|
2615 | + $post_id = intval($post_id); |
|
2616 | + $row=array(); |
|
2617 | + $where=''; |
|
2618 | + if (!empty ($post_id) && is_numeric($post_id)) { |
|
2619 | + $where.=' AND post_id ="'.$post_id.'" '; |
|
2620 | + } |
|
2621 | + |
|
2622 | + if (!empty ($comment_id) && is_numeric($comment_id)) { |
|
2623 | + if (!empty ($post_id)) { |
|
2624 | + $where.= ' AND '; |
|
2625 | + } |
|
2626 | + $where.=' comment_id ="'.$comment_id.'" '; |
|
2627 | + } |
|
2629 | 2628 | |
2630 | 2629 | $course_id = api_get_course_int_id(); |
2631 | 2630 | |
2632 | - $sql = 'SELECT path, filename, comment FROM '. $blog_table_attachment.' |
|
2631 | + $sql = 'SELECT path, filename, comment FROM '. $blog_table_attachment.' |
|
2633 | 2632 | WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; |
2634 | 2633 | |
2635 | - $result=Database::query($sql); |
|
2636 | - if (Database::num_rows($result)!=0) { |
|
2637 | - $row=Database::fetch_array($result); |
|
2638 | - } |
|
2639 | - return $row; |
|
2634 | + $result=Database::query($sql); |
|
2635 | + if (Database::num_rows($result)!=0) { |
|
2636 | + $row=Database::fetch_array($result); |
|
2637 | + } |
|
2638 | + return $row; |
|
2640 | 2639 | } |
2641 | 2640 | |
2642 | 2641 | /** |
@@ -2652,16 +2651,16 @@ discard block |
||
2652 | 2651 | $post_id = null, |
2653 | 2652 | $comment_id = null |
2654 | 2653 | ) { |
2655 | - $_course = api_get_course_info(); |
|
2656 | - $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
2657 | - $blog_id = intval($blog_id); |
|
2658 | - $comment_id = intval($comment_id); |
|
2659 | - $post_id = intval($post_id); |
|
2654 | + $_course = api_get_course_info(); |
|
2655 | + $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
2656 | + $blog_id = intval($blog_id); |
|
2657 | + $comment_id = intval($comment_id); |
|
2658 | + $post_id = intval($post_id); |
|
2660 | 2659 | |
2661 | 2660 | $course_id = api_get_course_int_id(); |
2662 | - $where = null; |
|
2661 | + $where = null; |
|
2663 | 2662 | |
2664 | - // delete files in DB |
|
2663 | + // delete files in DB |
|
2665 | 2664 | if (!empty ($post_id) && is_numeric($post_id)) { |
2666 | 2665 | $where .= ' AND post_id ="'.$post_id.'" '; |
2667 | 2666 | } |
@@ -2673,25 +2672,25 @@ discard block |
||
2673 | 2672 | $where .= ' comment_id ="'.$comment_id.'" '; |
2674 | 2673 | } |
2675 | 2674 | |
2676 | - // delete all files in directory |
|
2677 | - $courseDir = $_course['path'].'/upload/blog'; |
|
2678 | - $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
2679 | - $updir = $sys_course_path.$courseDir; |
|
2675 | + // delete all files in directory |
|
2676 | + $courseDir = $_course['path'].'/upload/blog'; |
|
2677 | + $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
2678 | + $updir = $sys_course_path.$courseDir; |
|
2680 | 2679 | |
2681 | - $sql = 'SELECT path FROM '.$blog_table_attachment.' |
|
2680 | + $sql = 'SELECT path FROM '.$blog_table_attachment.' |
|
2682 | 2681 | WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; |
2683 | - $result=Database::query($sql); |
|
2684 | - |
|
2685 | - while ($row=Database::fetch_row($result)) { |
|
2686 | - $file=$updir.'/'.$row[0]; |
|
2687 | - if (Security::check_abs_path($file,$updir) ) |
|
2688 | - { |
|
2689 | - @ unlink($file); |
|
2690 | - } |
|
2691 | - } |
|
2692 | - $sql = 'DELETE FROM '. $blog_table_attachment.' |
|
2682 | + $result=Database::query($sql); |
|
2683 | + |
|
2684 | + while ($row=Database::fetch_row($result)) { |
|
2685 | + $file=$updir.'/'.$row[0]; |
|
2686 | + if (Security::check_abs_path($file,$updir) ) |
|
2687 | + { |
|
2688 | + @ unlink($file); |
|
2689 | + } |
|
2690 | + } |
|
2691 | + $sql = 'DELETE FROM '. $blog_table_attachment.' |
|
2693 | 2692 | WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; |
2694 | - Database::query($sql); |
|
2693 | + Database::query($sql); |
|
2695 | 2694 | } |
2696 | 2695 | |
2697 | 2696 | /** |
@@ -2707,7 +2706,7 @@ discard block |
||
2707 | 2706 | $course_id = $course_info['real_id']; |
2708 | 2707 | $user_id = intval($user_id); |
2709 | 2708 | |
2710 | - $sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation |
|
2709 | + $sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation |
|
2711 | 2710 | FROM $tbl_blogs blog |
2712 | 2711 | INNER JOIN $tbl_blog_post post |
2713 | 2712 | ON (blog.blog_id = post.blog_id) |
@@ -2716,19 +2715,19 @@ discard block |
||
2716 | 2715 | post.c_id = $course_id AND |
2717 | 2716 | author_id = $user_id AND visibility = 1 |
2718 | 2717 | ORDER BY post.date_creation DESC "; |
2719 | - $result = Database::query($sql); |
|
2720 | - $return_data = ''; |
|
2721 | - |
|
2722 | - if (Database::num_rows($result)!=0) { |
|
2723 | - while ($row=Database::fetch_array($result)) { |
|
2724 | - $return_data.= '<div class="clear"></div><br />'; |
|
2725 | - $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>'; |
|
2726 | - $return_data.= '<br / >'; |
|
2727 | - $return_data.= $row['full_text']; |
|
2728 | - $return_data.= '<br /><br />'; |
|
2729 | - } |
|
2730 | - } |
|
2731 | - return $return_data; |
|
2718 | + $result = Database::query($sql); |
|
2719 | + $return_data = ''; |
|
2720 | + |
|
2721 | + if (Database::num_rows($result)!=0) { |
|
2722 | + while ($row=Database::fetch_array($result)) { |
|
2723 | + $return_data.= '<div class="clear"></div><br />'; |
|
2724 | + $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>'; |
|
2725 | + $return_data.= '<br / >'; |
|
2726 | + $return_data.= $row['full_text']; |
|
2727 | + $return_data.= '<br /><br />'; |
|
2728 | + } |
|
2729 | + } |
|
2730 | + return $return_data; |
|
2732 | 2731 | } |
2733 | 2732 | |
2734 | 2733 | /** |
@@ -2745,7 +2744,7 @@ discard block |
||
2745 | 2744 | $course_info = api_get_course_info($course_code); |
2746 | 2745 | $course_id = $course_info['real_id']; |
2747 | 2746 | |
2748 | - $sql = "SELECT DISTINCT blog.blog_id, comment_id, title, comment, comment.date_creation |
|
2747 | + $sql = "SELECT DISTINCT blog.blog_id, comment_id, title, comment, comment.date_creation |
|
2749 | 2748 | FROM $tbl_blogs blog INNER JOIN $tbl_blog_comment comment |
2750 | 2749 | ON (blog.blog_id = comment.blog_id) |
2751 | 2750 | WHERE blog.c_id = $course_id AND |
@@ -2753,17 +2752,17 @@ discard block |
||
2753 | 2752 | author_id = $user_id AND |
2754 | 2753 | visibility = 1 |
2755 | 2754 | ORDER BY blog_name"; |
2756 | - $result = Database::query($sql); |
|
2757 | - $return_data = ''; |
|
2758 | - if (Database::num_rows($result)!=0) { |
|
2759 | - while ($row=Database::fetch_array($result)) { |
|
2760 | - $return_data.= '<div class="clear"></div><br />'; |
|
2761 | - $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>'; |
|
2762 | - $return_data.= '<br / >'; |
|
2763 | - $return_data.= $row['comment']; |
|
2764 | - $return_data.= '<br />'; |
|
2765 | - } |
|
2766 | - } |
|
2767 | - return $return_data; |
|
2755 | + $result = Database::query($sql); |
|
2756 | + $return_data = ''; |
|
2757 | + if (Database::num_rows($result)!=0) { |
|
2758 | + while ($row=Database::fetch_array($result)) { |
|
2759 | + $return_data.= '<div class="clear"></div><br />'; |
|
2760 | + $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>'; |
|
2761 | + $return_data.= '<br / >'; |
|
2762 | + $return_data.= $row['comment']; |
|
2763 | + $return_data.= '<br />'; |
|
2764 | + } |
|
2765 | + } |
|
2766 | + return $return_data; |
|
2768 | 2767 | } |
2769 | 2768 |
@@ -480,8 +480,8 @@ discard block |
||
480 | 480 | ); |
481 | 481 | |
482 | 482 | if (($counter % $batchSize) === 0) { |
483 | - $em->flush(); |
|
484 | - $em->clear(); |
|
483 | + $em->flush(); |
|
484 | + $em->clear(); |
|
485 | 485 | } |
486 | 486 | $counter++; |
487 | 487 | } |
@@ -502,8 +502,8 @@ discard block |
||
502 | 502 | ); |
503 | 503 | |
504 | 504 | if (($counter % $batchSize) === 0) { |
505 | - $em->flush(); |
|
506 | - $em->clear(); |
|
505 | + $em->flush(); |
|
506 | + $em->clear(); |
|
507 | 507 | } |
508 | 508 | $counter++; |
509 | 509 | } |
@@ -1406,7 +1406,7 @@ discard block |
||
1406 | 1406 | ip.to_user_id = $user_id AND (ip.to_group_id IS NULL OR ip.to_group_id IN (0, ".implode(", ", $group_memberships).")) |
1407 | 1407 | ) "; |
1408 | 1408 | } else { |
1409 | - $cond_user_id = " AND ( |
|
1409 | + $cond_user_id = " AND ( |
|
1410 | 1410 | ip.to_user_id = $user_id AND (ip.to_group_id IS NULL OR ip.to_group_id IN (0, ".$group_id.")) |
1411 | 1411 | )"; |
1412 | 1412 | } |
@@ -372,13 +372,13 @@ discard block |
||
372 | 372 | $firstname = $userInfo['firstname']; |
373 | 373 | $lastname = $userInfo['lastname']; |
374 | 374 | |
375 | - if (api_is_western_name_order()) { |
|
376 | - $message = sprintf(get_lang('AttemptingToLoginAs'),$firstname, $lastname, $userId); |
|
377 | - } else { |
|
378 | - $message = sprintf(get_lang('AttemptingToLoginAs'), $lastname, $firstname, $userId); |
|
379 | - } |
|
375 | + if (api_is_western_name_order()) { |
|
376 | + $message = sprintf(get_lang('AttemptingToLoginAs'),$firstname, $lastname, $userId); |
|
377 | + } else { |
|
378 | + $message = sprintf(get_lang('AttemptingToLoginAs'), $lastname, $firstname, $userId); |
|
379 | + } |
|
380 | 380 | |
381 | - if ($userId) { |
|
381 | + if ($userId) { |
|
382 | 382 | |
383 | 383 | // Logout the current user |
384 | 384 | LoginDelete(api_get_user_id()); |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | { |
442 | 442 | $sql = prepare_user_sql_query(false); |
443 | 443 | if (!in_array($direction, array('ASC','DESC'))) { |
444 | - $direction = 'ASC'; |
|
444 | + $direction = 'ASC'; |
|
445 | 445 | } |
446 | 446 | $column = intval($column); |
447 | 447 | $from = intval($from); |
@@ -452,23 +452,23 @@ discard block |
||
452 | 452 | $sql .= " WHERE u.creator_id = ".api_get_user_id(); |
453 | 453 | } |
454 | 454 | |
455 | - $sql .= " ORDER BY col$column $direction "; |
|
456 | - $sql .= " LIMIT $from,$number_of_items"; |
|
455 | + $sql .= " ORDER BY col$column $direction "; |
|
456 | + $sql .= " LIMIT $from,$number_of_items"; |
|
457 | 457 | |
458 | - $res = Database::query($sql); |
|
458 | + $res = Database::query($sql); |
|
459 | 459 | |
460 | - $users = array (); |
|
460 | + $users = array (); |
|
461 | 461 | $t = time(); |
462 | - while ($user = Database::fetch_row($res)) { |
|
463 | - $userPicture = UserManager::getUserPicture($user[0], USER_IMAGE_SIZE_SMALL); |
|
464 | - $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]).'" />'; |
|
462 | + while ($user = Database::fetch_row($res)) { |
|
463 | + $userPicture = UserManager::getUserPicture($user[0], USER_IMAGE_SIZE_SMALL); |
|
464 | + $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]).'" />'; |
|
465 | 465 | |
466 | 466 | if ($user[7] == 1 && !empty($user[10])) { |
467 | 467 | // check expiration date |
468 | 468 | $expiration_time = convert_sql_date($user[10]); |
469 | 469 | // if expiration date is passed, store a special value for active field |
470 | 470 | if ($expiration_time < $t) { |
471 | - $user[7] = '-1'; |
|
471 | + $user[7] = '-1'; |
|
472 | 472 | } |
473 | 473 | } |
474 | 474 | |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | */ |
499 | 499 | function email_filter($email) |
500 | 500 | { |
501 | - return Display :: encrypted_mailto_link($email, $email); |
|
501 | + return Display :: encrypted_mailto_link($email, $email); |
|
502 | 502 | } |
503 | 503 | |
504 | 504 | /** |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | */ |
509 | 509 | function user_filter($name, $params, $row) |
510 | 510 | { |
511 | - return '<a href="'.api_get_path(WEB_PATH).'whoisonline.php?origin=user_list&id='.$row[0].'">'.$name.'</a>'; |
|
511 | + return '<a href="'.api_get_path(WEB_PATH).'whoisonline.php?origin=user_list&id='.$row[0].'">'.$name.'</a>'; |
|
512 | 512 | } |
513 | 513 | |
514 | 514 | /** |
@@ -526,17 +526,17 @@ discard block |
||
526 | 526 | $user_is_anonymous = false; |
527 | 527 | $current_user_status_label = $row['7']; |
528 | 528 | |
529 | - if ($current_user_status_label == $statusname[ANONYMOUS]) { |
|
530 | - $user_is_anonymous = true; |
|
531 | - } |
|
532 | - $result = ''; |
|
533 | - if (!$user_is_anonymous) { |
|
529 | + if ($current_user_status_label == $statusname[ANONYMOUS]) { |
|
530 | + $user_is_anonymous = true; |
|
531 | + } |
|
532 | + $result = ''; |
|
533 | + if (!$user_is_anonymous) { |
|
534 | 534 | $icon = Display::return_icon( |
535 | 535 | 'course.png', |
536 | 536 | get_lang('Courses'), |
537 | 537 | array('onmouseout' => 'clear_course_list (\'div_'.$user_id.'\')') |
538 | 538 | ); |
539 | - $result .= '<a href="javascript:void(0)" onclick="load_course_list(\'div_'.$user_id.'\','.$user_id.')" > |
|
539 | + $result .= '<a href="javascript:void(0)" onclick="load_course_list(\'div_'.$user_id.'\','.$user_id.')" > |
|
540 | 540 | '.$icon.' |
541 | 541 | <div class="blackboard_hide" id="div_'.$user_id.'"> </div> |
542 | 542 | </a>'; |
@@ -546,14 +546,14 @@ discard block |
||
546 | 546 | get_lang('Sessions'), |
547 | 547 | array('onmouseout' => 'clear_session_list (\'div_s_'.$user_id.'\')') |
548 | 548 | ); |
549 | - $result .= '<a href="javascript:void(0)" onclick="load_session_list(\'div_s_'.$user_id.'\','.$user_id.')" > |
|
549 | + $result .= '<a href="javascript:void(0)" onclick="load_session_list(\'div_s_'.$user_id.'\','.$user_id.')" > |
|
550 | 550 | '.$icon.' |
551 | 551 | <div class="blackboard_hide" id="div_s_'.$user_id.'"> </div> |
552 | 552 | </a>'; |
553 | - } else { |
|
554 | - $result .= Display::return_icon('course_na.png',get_lang('Courses')).' '; |
|
555 | - $result .= Display::return_icon('course_na.png',get_lang('Sessions')).' '; |
|
556 | - } |
|
553 | + } else { |
|
554 | + $result .= Display::return_icon('course_na.png',get_lang('Courses')).' '; |
|
555 | + $result .= Display::return_icon('course_na.png',get_lang('Sessions')).' '; |
|
556 | + } |
|
557 | 557 | |
558 | 558 | if (api_is_platform_admin()) { |
559 | 559 | if (!$user_is_anonymous) { |
@@ -602,18 +602,18 @@ discard block |
||
602 | 602 | ); |
603 | 603 | } |
604 | 604 | |
605 | - if ($is_admin) { |
|
605 | + if ($is_admin) { |
|
606 | 606 | $result .= Display::return_icon( |
607 | 607 | 'admin_star.png', |
608 | 608 | get_lang('IsAdministrator'), |
609 | 609 | array('width' => ICON_SIZE_SMALL, 'heigth' => ICON_SIZE_SMALL) |
610 | 610 | ); |
611 | - } else { |
|
612 | - $result .= Display::return_icon('admin_star_na.png', get_lang('IsNotAdministrator')); |
|
613 | - } |
|
611 | + } else { |
|
612 | + $result .= Display::return_icon('admin_star_na.png', get_lang('IsNotAdministrator')); |
|
613 | + } |
|
614 | 614 | |
615 | - // actions for assigning sessions, courses or users |
|
616 | - if (!api_is_session_admin()) { |
|
615 | + // actions for assigning sessions, courses or users |
|
616 | + if (!api_is_session_admin()) { |
|
617 | 617 | if ($current_user_status_label == $statusname[SESSIONADMIN]) { |
618 | 618 | $result .= Display::url( |
619 | 619 | Display::return_icon('view_more_stats.gif', get_lang('AssignSessions')), |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | ); |
644 | 644 | } |
645 | 645 | } |
646 | - } |
|
646 | + } |
|
647 | 647 | |
648 | 648 | if (api_is_platform_admin()) { |
649 | 649 | $result .= ' <a data-title="'.get_lang('FreeBusyCalendar').'" href="'.api_get_path(WEB_AJAX_PATH).'agenda.ajax.php?a=get_user_agenda&user_id='.$user_id.'&modal_size=lg" class="agenda_opener ajax">'. |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | } |
663 | 663 | } |
664 | 664 | |
665 | - return $result; |
|
665 | + return $result; |
|
666 | 666 | } |
667 | 667 | |
668 | 668 | /** |
@@ -694,16 +694,16 @@ discard block |
||
694 | 694 | if ($action === 'edit') { |
695 | 695 | $result = Display::return_icon($image.'.png', get_lang('AccountExpired'), array(), 16); |
696 | 696 | } elseif ($row['0'] <> $_user['user_id']) { |
697 | - // you cannot lock yourself out otherwise you could disable all the accounts including your own => everybody is locked out and nobody can change it anymore. |
|
697 | + // you cannot lock yourself out otherwise you could disable all the accounts including your own => everybody is locked out and nobody can change it anymore. |
|
698 | 698 | $result = Display::return_icon( |
699 | 699 | $image.'.png', |
700 | 700 | get_lang(ucfirst($action)), |
701 | 701 | array('onclick' => 'active_user(this);', 'id' => 'img_'.$row['0']), |
702 | 702 | 16 |
703 | 703 | ); |
704 | - } |
|
704 | + } |
|
705 | 705 | |
706 | - return $result; |
|
706 | + return $result; |
|
707 | 707 | } |
708 | 708 | |
709 | 709 | /** |
@@ -716,8 +716,8 @@ discard block |
||
716 | 716 | * @author Patrick Cool <[email protected]>, Ghent University, Belgium |
717 | 717 | */ |
718 | 718 | function status_filter($status) { |
719 | - $statusname = api_get_status_langvars(); |
|
720 | - return $statusname[$status]; |
|
719 | + $statusname = api_get_status_langvars(); |
|
720 | + return $statusname[$status]; |
|
721 | 721 | } |
722 | 722 | |
723 | 723 | if (isset($_GET['keyword']) || isset($_GET['keyword_firstname'])) { |
@@ -733,8 +733,8 @@ discard block |
||
733 | 733 | |
734 | 734 | if (!empty($action)) { |
735 | 735 | $check = Security::check_token('get'); |
736 | - if ($check) { |
|
737 | - switch ($action) { |
|
736 | + if ($check) { |
|
737 | + switch ($action) { |
|
738 | 738 | case 'add_user_to_my_url': |
739 | 739 | $user_id = $_REQUEST["user_id"]; |
740 | 740 | $result = UrlManager::add_user_to_url($user_id, $current_access_url_id); |
@@ -744,52 +744,52 @@ discard block |
||
744 | 744 | $message = Display::return_message($message, 'confirmation'); |
745 | 745 | } |
746 | 746 | break; |
747 | - case 'delete_user': |
|
748 | - if (api_is_platform_admin()) { |
|
747 | + case 'delete_user': |
|
748 | + if (api_is_platform_admin()) { |
|
749 | 749 | $user_to_delete = $_GET['user_id']; |
750 | 750 | $userToDeleteInfo = api_get_user_info($user_to_delete); |
751 | 751 | $current_user_id = api_get_user_id(); |
752 | 752 | |
753 | - if ($userToDeleteInfo && $deleteUserAvailable && api_global_admin_can_edit_admin($_GET['user_id'])) { |
|
754 | - if ($user_to_delete != $current_user_id && UserManager :: delete_user($_GET['user_id'])) { |
|
755 | - $message = Display :: return_message( |
|
756 | - get_lang('UserDeleted').': '.$userToDeleteInfo['complete_name_with_username'], |
|
753 | + if ($userToDeleteInfo && $deleteUserAvailable && api_global_admin_can_edit_admin($_GET['user_id'])) { |
|
754 | + if ($user_to_delete != $current_user_id && UserManager :: delete_user($_GET['user_id'])) { |
|
755 | + $message = Display :: return_message( |
|
756 | + get_lang('UserDeleted').': '.$userToDeleteInfo['complete_name_with_username'], |
|
757 | 757 | 'confirmation' |
758 | 758 | ); |
759 | - } else { |
|
760 | - $message = Display :: return_message(get_lang('CannotDeleteUserBecauseOwnsCourse'), 'error'); |
|
761 | - } |
|
762 | - } else { |
|
763 | - $message = Display :: return_message(get_lang('CannotDeleteUser'), 'error'); |
|
764 | - } |
|
765 | - Display::addFlash($message); |
|
766 | - header('Location: '.api_get_self()); |
|
759 | + } else { |
|
760 | + $message = Display :: return_message(get_lang('CannotDeleteUserBecauseOwnsCourse'), 'error'); |
|
761 | + } |
|
762 | + } else { |
|
763 | + $message = Display :: return_message(get_lang('CannotDeleteUser'), 'error'); |
|
764 | + } |
|
765 | + Display::addFlash($message); |
|
766 | + header('Location: '.api_get_self()); |
|
767 | 767 | exit; |
768 | - } |
|
769 | - break; |
|
768 | + } |
|
769 | + break; |
|
770 | 770 | case 'delete': |
771 | - if (api_is_platform_admin()) { |
|
772 | - $number_of_selected_users = count($_POST['id']); |
|
773 | - $number_of_deleted_users = 0; |
|
774 | - if (is_array($_POST['id'])) { |
|
775 | - foreach ($_POST['id'] as $index => $user_id) { |
|
776 | - if ($user_id != $_user['user_id']) { |
|
777 | - if (UserManager::delete_user($user_id)) { |
|
778 | - $number_of_deleted_users++; |
|
779 | - } |
|
780 | - } |
|
781 | - } |
|
782 | - } |
|
783 | - if ($number_of_selected_users == $number_of_deleted_users) { |
|
771 | + if (api_is_platform_admin()) { |
|
772 | + $number_of_selected_users = count($_POST['id']); |
|
773 | + $number_of_deleted_users = 0; |
|
774 | + if (is_array($_POST['id'])) { |
|
775 | + foreach ($_POST['id'] as $index => $user_id) { |
|
776 | + if ($user_id != $_user['user_id']) { |
|
777 | + if (UserManager::delete_user($user_id)) { |
|
778 | + $number_of_deleted_users++; |
|
779 | + } |
|
780 | + } |
|
781 | + } |
|
782 | + } |
|
783 | + if ($number_of_selected_users == $number_of_deleted_users) { |
|
784 | 784 | $message = Display :: return_message(get_lang('SelectedUsersDeleted'), 'confirmation'); |
785 | - } else { |
|
785 | + } else { |
|
786 | 786 | $message = Display :: return_message(get_lang('SomeUsersNotDeleted'), 'error'); |
787 | - } |
|
788 | - } |
|
789 | - break; |
|
790 | - } |
|
791 | - Security::clear_token(); |
|
792 | - } |
|
787 | + } |
|
788 | + } |
|
789 | + break; |
|
790 | + } |
|
791 | + Security::clear_token(); |
|
792 | + } |
|
793 | 793 | } |
794 | 794 | |
795 | 795 | // Create a search-box |
@@ -807,15 +807,15 @@ discard block |
||
807 | 807 | $actionsCenter = ''; |
808 | 808 | $actionsRight = ''; |
809 | 809 | if (api_is_platform_admin()) { |
810 | - $actionsRight .= '<a class="pull-right" href="'.api_get_path(WEB_CODE_PATH).'admin/user_add.php">'. |
|
811 | - Display::return_icon('new_user.png',get_lang('AddUsers'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
810 | + $actionsRight .= '<a class="pull-right" href="'.api_get_path(WEB_CODE_PATH).'admin/user_add.php">'. |
|
811 | + Display::return_icon('new_user.png',get_lang('AddUsers'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
812 | 812 | } |
813 | 813 | |
814 | 814 | $actionsLeft .= $form->returnForm(); |
815 | 815 | $actionsCenter .= $searchAdvanced; |
816 | 816 | |
817 | 817 | if (isset($_GET['keyword'])) { |
818 | - $parameters = array('keyword' => Security::remove_XSS($_GET['keyword'])); |
|
818 | + $parameters = array('keyword' => Security::remove_XSS($_GET['keyword'])); |
|
819 | 819 | } elseif (isset ($_GET['keyword_firstname'])) { |
820 | 820 | $parameters['keyword_firstname'] = Security::remove_XSS($_GET['keyword_firstname']); |
821 | 821 | $parameters['keyword_lastname'] = Security::remove_XSS($_GET['keyword_lastname']); |
@@ -889,11 +889,11 @@ discard block |
||
889 | 889 | $table->set_header(2, get_lang('OfficialCode')); |
890 | 890 | |
891 | 891 | if (api_is_western_name_order()) { |
892 | - $table->set_header(3, get_lang('FirstName')); |
|
893 | - $table->set_header(4, get_lang('LastName')); |
|
892 | + $table->set_header(3, get_lang('FirstName')); |
|
893 | + $table->set_header(4, get_lang('LastName')); |
|
894 | 894 | } else { |
895 | - $table->set_header(3, get_lang('LastName')); |
|
896 | - $table->set_header(4, get_lang('FirstName')); |
|
895 | + $table->set_header(3, get_lang('LastName')); |
|
896 | + $table->set_header(4, get_lang('FirstName')); |
|
897 | 897 | } |
898 | 898 | $table->set_header(5, get_lang('LoginName')); |
899 | 899 | $table->set_header(6, get_lang('Email')); |
@@ -132,38 +132,38 @@ discard block |
||
132 | 132 | */ |
133 | 133 | function my_rename($file_path, $new_file_name) { |
134 | 134 | |
135 | - $save_dir = getcwd(); |
|
136 | - $path = dirname($file_path); |
|
137 | - $old_file_name = basename($file_path); |
|
138 | - $new_file_name = api_replace_dangerous_char($new_file_name); |
|
135 | + $save_dir = getcwd(); |
|
136 | + $path = dirname($file_path); |
|
137 | + $old_file_name = basename($file_path); |
|
138 | + $new_file_name = api_replace_dangerous_char($new_file_name); |
|
139 | 139 | |
140 | - // If no extension, take the old one |
|
141 | - if ((strpos($new_file_name, '.') === false) && ($dotpos = strrpos($old_file_name, '.'))) { |
|
142 | - $new_file_name .= substr($old_file_name, $dotpos); |
|
143 | - } |
|
140 | + // If no extension, take the old one |
|
141 | + if ((strpos($new_file_name, '.') === false) && ($dotpos = strrpos($old_file_name, '.'))) { |
|
142 | + $new_file_name .= substr($old_file_name, $dotpos); |
|
143 | + } |
|
144 | 144 | |
145 | - // Note: still possible: 'xx.yy' -rename-> '.yy' -rename-> 'zz' |
|
146 | - // This is useful for folder names, where otherwise '.' would be sticky |
|
145 | + // Note: still possible: 'xx.yy' -rename-> '.yy' -rename-> 'zz' |
|
146 | + // This is useful for folder names, where otherwise '.' would be sticky |
|
147 | 147 | |
148 | - // Extension PHP is not allowed, change to PHPS |
|
149 | - $new_file_name = php2phps($new_file_name); |
|
148 | + // Extension PHP is not allowed, change to PHPS |
|
149 | + $new_file_name = php2phps($new_file_name); |
|
150 | 150 | |
151 | - if ($new_file_name == $old_file_name) { |
|
152 | - return $old_file_name; |
|
153 | - } |
|
151 | + if ($new_file_name == $old_file_name) { |
|
152 | + return $old_file_name; |
|
153 | + } |
|
154 | 154 | |
155 | - if (strtolower($new_file_name) != strtolower($old_file_name) && check_name_exist($path.'/'.$new_file_name)) { |
|
156 | - return false; |
|
157 | - } |
|
158 | - // On a Windows server, it would be better not to do the above check |
|
159 | - // because it succeeds for some new names resembling the old name. |
|
160 | - // But on Unix/Linux the check must be done because rename overwrites. |
|
155 | + if (strtolower($new_file_name) != strtolower($old_file_name) && check_name_exist($path.'/'.$new_file_name)) { |
|
156 | + return false; |
|
157 | + } |
|
158 | + // On a Windows server, it would be better not to do the above check |
|
159 | + // because it succeeds for some new names resembling the old name. |
|
160 | + // But on Unix/Linux the check must be done because rename overwrites. |
|
161 | 161 | |
162 | - chdir($path); |
|
163 | - $res = rename($old_file_name, $new_file_name) ? $new_file_name : false; |
|
164 | - chdir($save_dir); |
|
162 | + chdir($path); |
|
163 | + $res = rename($old_file_name, $new_file_name) ? $new_file_name : false; |
|
164 | + chdir($save_dir); |
|
165 | 165 | |
166 | - return $res; |
|
166 | + return $res; |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | $file_name = basename($source); |
186 | 186 | // move onto self illegal: mv a/b/c a/b/c or mv a/b/c a/b |
187 | 187 | if (strcasecmp($target, dirname($source)) === 0) { |
188 | - return false; |
|
188 | + return false; |
|
189 | 189 | } |
190 | 190 | $isWindowsOS = api_is_windows_os(); |
191 | 191 | $canExec = function_exists('exec'); |
@@ -265,8 +265,8 @@ discard block |
||
265 | 265 | */ |
266 | 266 | function getextension($filename) |
267 | 267 | { |
268 | - $bouts = explode('.', $filename); |
|
269 | - return array(array_pop($bouts), implode('.', $bouts)); |
|
268 | + $bouts = explode('.', $filename); |
|
269 | + return array(array_pop($bouts), implode('.', $bouts)); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | /** |
@@ -277,17 +277,17 @@ discard block |
||
277 | 277 | * @param boolean $recursive if true , include subdirectory in total |
278 | 278 | */ |
279 | 279 | function dirsize($root, $recursive = true) { |
280 | - $dir = @opendir($root); |
|
281 | - $size = 0; |
|
282 | - while ($file = @readdir($dir)) { |
|
283 | - if (!in_array($file, array('.', '..'))) { |
|
284 | - if (is_dir($root.'/'.$file)) { |
|
285 | - $size += $recursive ? dirsize($root.'/'.$file) : 0; |
|
286 | - } else { |
|
287 | - $size += @filesize($root.'/'.$file); |
|
288 | - } |
|
289 | - } |
|
290 | - } |
|
291 | - @closedir($dir); |
|
292 | - return $size; |
|
280 | + $dir = @opendir($root); |
|
281 | + $size = 0; |
|
282 | + while ($file = @readdir($dir)) { |
|
283 | + if (!in_array($file, array('.', '..'))) { |
|
284 | + if (is_dir($root.'/'.$file)) { |
|
285 | + $size += $recursive ? dirsize($root.'/'.$file) : 0; |
|
286 | + } else { |
|
287 | + $size += @filesize($root.'/'.$file); |
|
288 | + } |
|
289 | + } |
|
290 | + } |
|
291 | + @closedir($dir); |
|
292 | + return $size; |
|
293 | 293 | } |
@@ -1408,7 +1408,7 @@ discard block |
||
1408 | 1408 | $media .= '<div class="col-md-2 col-xs-2 social-post-answers">'; |
1409 | 1409 | $media .= '<div class="user-image pull-right">'; |
1410 | 1410 | $media .= '<a href="'.$url.'" ><img src="'. $users[$userIdLoop]['avatar'] . |
1411 | - '" alt="'.$users[$userIdLoop]['complete_name'].'" class="avatar-thumb"></a>'; |
|
1411 | + '" alt="'.$users[$userIdLoop]['complete_name'].'" class="avatar-thumb"></a>'; |
|
1412 | 1412 | $media .= '</div>'; |
1413 | 1413 | $media .= '</div>'; |
1414 | 1414 | $media .= '<div class="col-md-9 col-xs-9 social-post-answers">'; |
@@ -1623,10 +1623,10 @@ discard block |
||
1623 | 1623 | } |
1624 | 1624 | |
1625 | 1625 | /** |
1626 | - * Delete messages delete logic |
|
1627 | - * @param int $id id message to delete. |
|
1628 | - * @return bool status query |
|
1629 | - */ |
|
1626 | + * Delete messages delete logic |
|
1627 | + * @param int $id id message to delete. |
|
1628 | + * @return bool status query |
|
1629 | + */ |
|
1630 | 1630 | public static function deleteMessage($id) |
1631 | 1631 | { |
1632 | 1632 | $id = intval($id); |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | $geolocalization = $gMapsPlugin->get('enable_api') === 'true'; |
73 | 73 | |
74 | 74 | if ($geolocalization) { |
75 | - $gmapsApiKey = $gMapsPlugin->get('api_key'); |
|
76 | - $htmlHeadXtra[] = '<script type="text/javascript" src="//maps.googleapis.com/maps/api/js?sensor=true&key='. $gmapsApiKey . '" ></script>'; |
|
75 | + $gmapsApiKey = $gMapsPlugin->get('api_key'); |
|
76 | + $htmlHeadXtra[] = '<script type="text/javascript" src="//maps.googleapis.com/maps/api/js?sensor=true&key='. $gmapsApiKey . '" ></script>'; |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | $htmlHeadXtra[] = api_get_css_asset('cropper/dist/cropper.min.css'); |
@@ -117,27 +117,27 @@ discard block |
||
117 | 117 | $form->addElement('hidden', 'user_id', $user_id); |
118 | 118 | |
119 | 119 | if (api_is_western_name_order()) { |
120 | - // Firstname |
|
121 | - $form->addElement('text', 'firstname', get_lang('FirstName')); |
|
122 | - $form->applyFilter('firstname', 'html_filter'); |
|
123 | - $form->applyFilter('firstname', 'trim'); |
|
124 | - $form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required'); |
|
125 | - // Lastname |
|
126 | - $form->addElement('text', 'lastname', get_lang('LastName')); |
|
127 | - $form->applyFilter('lastname', 'html_filter'); |
|
128 | - $form->applyFilter('lastname', 'trim'); |
|
129 | - $form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required'); |
|
120 | + // Firstname |
|
121 | + $form->addElement('text', 'firstname', get_lang('FirstName')); |
|
122 | + $form->applyFilter('firstname', 'html_filter'); |
|
123 | + $form->applyFilter('firstname', 'trim'); |
|
124 | + $form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required'); |
|
125 | + // Lastname |
|
126 | + $form->addElement('text', 'lastname', get_lang('LastName')); |
|
127 | + $form->applyFilter('lastname', 'html_filter'); |
|
128 | + $form->applyFilter('lastname', 'trim'); |
|
129 | + $form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required'); |
|
130 | 130 | } else { |
131 | - // Lastname |
|
132 | - $form->addElement('text', 'lastname', get_lang('LastName')); |
|
133 | - $form->applyFilter('lastname', 'html_filter'); |
|
134 | - $form->applyFilter('lastname', 'trim'); |
|
135 | - $form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required'); |
|
136 | - // Firstname |
|
137 | - $form->addElement('text', 'firstname', get_lang('FirstName')); |
|
138 | - $form->applyFilter('firstname', 'html_filter'); |
|
139 | - $form->applyFilter('firstname', 'trim'); |
|
140 | - $form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required'); |
|
131 | + // Lastname |
|
132 | + $form->addElement('text', 'lastname', get_lang('LastName')); |
|
133 | + $form->applyFilter('lastname', 'html_filter'); |
|
134 | + $form->applyFilter('lastname', 'trim'); |
|
135 | + $form->addRule('lastname', get_lang('ThisFieldIsRequired'), 'required'); |
|
136 | + // Firstname |
|
137 | + $form->addElement('text', 'firstname', get_lang('FirstName')); |
|
138 | + $form->applyFilter('firstname', 'html_filter'); |
|
139 | + $form->applyFilter('firstname', 'trim'); |
|
140 | + $form->addRule('firstname', get_lang('ThisFieldIsRequired'), 'required'); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | // Official code |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | |
160 | 160 | // OpenID |
161 | 161 | if (api_get_setting('openid_authentication') == 'true') { |
162 | - $form->addElement('text', 'openid', get_lang('OpenIDURL')); |
|
162 | + $form->addElement('text', 'openid', get_lang('OpenIDURL')); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | // Phone |
@@ -174,18 +174,18 @@ discard block |
||
174 | 174 | $allowed_picture_types = api_get_supported_image_extensions(false); |
175 | 175 | |
176 | 176 | $form->addRule( |
177 | - 'picture', |
|
178 | - get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', |
|
179 | - 'filetype', |
|
180 | - $allowed_picture_types |
|
177 | + 'picture', |
|
178 | + get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', |
|
179 | + 'filetype', |
|
180 | + $allowed_picture_types |
|
181 | 181 | ); |
182 | 182 | if (strlen($user_data['picture_uri']) > 0) { |
183 | - $form->addElement('checkbox', 'delete_picture', '', get_lang('DelImage')); |
|
183 | + $form->addElement('checkbox', 'delete_picture', '', get_lang('DelImage')); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | // Username |
187 | 187 | if (api_get_setting('login_is_email') != 'true') { |
188 | - $form->addElement('text', 'username', get_lang('LoginName'), array('maxlength' => USERNAME_MAX_LENGTH)); |
|
188 | + $form->addElement('text', 'username', get_lang('LoginName'), array('maxlength' => USERNAME_MAX_LENGTH)); |
|
189 | 189 | $form->addRule('username', get_lang('ThisFieldIsRequired'), 'required'); |
190 | 190 | $form->addRule('username', sprintf(get_lang('UsernameMaxXCharacters'), (string)USERNAME_MAX_LENGTH), 'maxlength', USERNAME_MAX_LENGTH); |
191 | 191 | $form->addRule('username', get_lang('OnlyLettersAndNumbersAllowed'), 'username'); |
@@ -257,15 +257,15 @@ discard block |
||
257 | 257 | |
258 | 258 | // Platform admin |
259 | 259 | if (api_is_platform_admin()) { |
260 | - $group = array(); |
|
261 | - $group[] =$form->createElement('radio', 'platform_admin', null, get_lang('Yes'), 1); |
|
262 | - $group[] =$form->createElement('radio', 'platform_admin', null, get_lang('No'), 0); |
|
260 | + $group = array(); |
|
261 | + $group[] =$form->createElement('radio', 'platform_admin', null, get_lang('Yes'), 1); |
|
262 | + $group[] =$form->createElement('radio', 'platform_admin', null, get_lang('No'), 0); |
|
263 | 263 | |
264 | - $user_data['status'] == 1 ? $display = 'block':$display = 'none'; |
|
264 | + $user_data['status'] == 1 ? $display = 'block':$display = 'none'; |
|
265 | 265 | |
266 | - $form->addElement('html', '<div id="id_platform_admin" style="display:'.$display.'">'); |
|
267 | - $form->addGroup($group, 'admin', get_lang('PlatformAdmin'), null, false); |
|
268 | - $form->addElement('html', '</div>'); |
|
266 | + $form->addElement('html', '<div id="id_platform_admin" style="display:'.$display.'">'); |
|
267 | + $form->addGroup($group, 'admin', get_lang('PlatformAdmin'), null, false); |
|
268 | + $form->addElement('html', '</div>'); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | //Language |
@@ -283,16 +283,16 @@ discard block |
||
283 | 283 | $form->addElement('label', get_lang('RegistrationDate'), $date); |
284 | 284 | |
285 | 285 | if (!$user_data['platform_admin']) { |
286 | - // Expiration Date |
|
287 | - $form->addElement('radio', 'radio_expiration_date', get_lang('ExpirationDate'), get_lang('NeverExpires'), 0); |
|
288 | - $group = array (); |
|
289 | - $group[] = $form->createElement('radio', 'radio_expiration_date', null, get_lang('Enabled'), 1); |
|
290 | - $group[] = $form->createElement('DateTimePicker', 'expiration_date', null, array('onchange' => 'javascript: enable_expiration_date();')); |
|
291 | - $form->addGroup($group, 'max_member_group', null, null, false); |
|
292 | - |
|
293 | - // Active account or inactive account |
|
294 | - $form->addElement('radio', 'active', get_lang('ActiveAccount'), get_lang('Active'), 1); |
|
295 | - $form->addElement('radio', 'active', '', get_lang('Inactive'), 0); |
|
286 | + // Expiration Date |
|
287 | + $form->addElement('radio', 'radio_expiration_date', get_lang('ExpirationDate'), get_lang('NeverExpires'), 0); |
|
288 | + $group = array (); |
|
289 | + $group[] = $form->createElement('radio', 'radio_expiration_date', null, get_lang('Enabled'), 1); |
|
290 | + $group[] = $form->createElement('DateTimePicker', 'expiration_date', null, array('onchange' => 'javascript: enable_expiration_date();')); |
|
291 | + $form->addGroup($group, 'max_member_group', null, null, false); |
|
292 | + |
|
293 | + // Active account or inactive account |
|
294 | + $form->addElement('radio', 'active', get_lang('ActiveAccount'), get_lang('Active'), 1); |
|
295 | + $form->addElement('radio', 'active', '', get_lang('Inactive'), 0); |
|
296 | 296 | } |
297 | 297 | $studentBossList = UserManager::getStudentBossList($user_data['user_id']); |
298 | 298 | |
@@ -334,18 +334,18 @@ discard block |
||
334 | 334 | $expiration_date = $user_data['expiration_date']; |
335 | 335 | |
336 | 336 | if (empty($expiration_date)) { |
337 | - $user_data['radio_expiration_date'] = 0; |
|
338 | - $user_data['expiration_date'] = api_get_local_time(); |
|
337 | + $user_data['radio_expiration_date'] = 0; |
|
338 | + $user_data['expiration_date'] = api_get_local_time(); |
|
339 | 339 | } else { |
340 | - $user_data['radio_expiration_date'] = 1; |
|
341 | - $user_data['expiration_date'] = api_get_local_time($expiration_date); |
|
340 | + $user_data['radio_expiration_date'] = 1; |
|
341 | + $user_data['expiration_date'] = api_get_local_time($expiration_date); |
|
342 | 342 | } |
343 | 343 | $form->setDefaults($user_data); |
344 | 344 | |
345 | 345 | $error_drh = false; |
346 | 346 | // Validate form |
347 | 347 | if ($form->validate()) { |
348 | - $user = $form->getSubmitValues(1); |
|
348 | + $user = $form->getSubmitValues(1); |
|
349 | 349 | $reset_password = intval($user['reset_password']); |
350 | 350 | if ($reset_password == 2 && empty($user['password'])) { |
351 | 351 | Display::addFlash(Display::return_message(get_lang('PasswordIsTooShort'))); |
@@ -353,48 +353,48 @@ discard block |
||
353 | 353 | exit(); |
354 | 354 | } |
355 | 355 | |
356 | - $is_user_subscribed_in_course = CourseManager::is_user_subscribed_in_course($user['user_id']); |
|
356 | + $is_user_subscribed_in_course = CourseManager::is_user_subscribed_in_course($user['user_id']); |
|
357 | 357 | |
358 | - if ($user['status'] == DRH && $is_user_subscribed_in_course) { |
|
359 | - $error_drh = true; |
|
360 | - } else { |
|
361 | - $picture_element = $form->getElement('picture'); |
|
362 | - $picture = $picture_element->getValue(); |
|
358 | + if ($user['status'] == DRH && $is_user_subscribed_in_course) { |
|
359 | + $error_drh = true; |
|
360 | + } else { |
|
361 | + $picture_element = $form->getElement('picture'); |
|
362 | + $picture = $picture_element->getValue(); |
|
363 | 363 | |
364 | - $picture_uri = $user_data['picture_uri']; |
|
365 | - if (isset($user['delete_picture']) && $user['delete_picture']) { |
|
366 | - $picture_uri = UserManager::delete_user_picture($user_id); |
|
367 | - } elseif (!empty($picture['name'])) { |
|
364 | + $picture_uri = $user_data['picture_uri']; |
|
365 | + if (isset($user['delete_picture']) && $user['delete_picture']) { |
|
366 | + $picture_uri = UserManager::delete_user_picture($user_id); |
|
367 | + } elseif (!empty($picture['name'])) { |
|
368 | 368 | $picture_uri = UserManager::update_user_picture( |
369 | 369 | $user_id, |
370 | 370 | $_FILES['picture']['name'], |
371 | 371 | $_FILES['picture']['tmp_name'], |
372 | 372 | $user['picture_crop_result'] |
373 | 373 | ); |
374 | - } |
|
374 | + } |
|
375 | 375 | |
376 | - $lastname = $user['lastname']; |
|
377 | - $firstname = $user['firstname']; |
|
376 | + $lastname = $user['lastname']; |
|
377 | + $firstname = $user['firstname']; |
|
378 | 378 | $password = $user['password']; |
379 | 379 | $auth_source = isset($user['auth_source']) ? $user['auth_source'] : $userInfo['auth_source']; |
380 | - $official_code = $user['official_code']; |
|
381 | - $email = $user['email']; |
|
382 | - $phone = $user['phone']; |
|
383 | - $username = isset($user['username']) ? $user['username'] : $userInfo['username']; |
|
384 | - $status = intval($user['status']); |
|
385 | - $platform_admin = intval($user['platform_admin']); |
|
386 | - $send_mail = intval($user['send_mail']); |
|
387 | - $reset_password = intval($user['reset_password']); |
|
388 | - $hr_dept_id = isset($user['hr_dept_id']) ? intval($user['hr_dept_id']) : null; |
|
389 | - $language = $user['language']; |
|
390 | - |
|
391 | - if ($user['radio_expiration_date'] == '1' && !$user_data['platform_admin']) { |
|
380 | + $official_code = $user['official_code']; |
|
381 | + $email = $user['email']; |
|
382 | + $phone = $user['phone']; |
|
383 | + $username = isset($user['username']) ? $user['username'] : $userInfo['username']; |
|
384 | + $status = intval($user['status']); |
|
385 | + $platform_admin = intval($user['platform_admin']); |
|
386 | + $send_mail = intval($user['send_mail']); |
|
387 | + $reset_password = intval($user['reset_password']); |
|
388 | + $hr_dept_id = isset($user['hr_dept_id']) ? intval($user['hr_dept_id']) : null; |
|
389 | + $language = $user['language']; |
|
390 | + |
|
391 | + if ($user['radio_expiration_date'] == '1' && !$user_data['platform_admin']) { |
|
392 | 392 | $expiration_date = $user['expiration_date']; |
393 | - } else { |
|
394 | - $expiration_date = null; |
|
395 | - } |
|
393 | + } else { |
|
394 | + $expiration_date = null; |
|
395 | + } |
|
396 | 396 | |
397 | - $active = $user_data['platform_admin'] ? 1 : intval($user['active']); |
|
397 | + $active = $user_data['platform_admin'] ? 1 : intval($user['active']); |
|
398 | 398 | |
399 | 399 | //If the user is set to admin the status will be overwrite by COURSEMANAGER = 1 |
400 | 400 | if ($platform_admin == 1) { |
@@ -426,40 +426,40 @@ discard block |
||
426 | 426 | null, |
427 | 427 | $send_mail, |
428 | 428 | $reset_password, |
429 | - $user['address'] |
|
429 | + $user['address'] |
|
430 | 430 | ); |
431 | 431 | |
432 | 432 | if (isset($user['student_boss'])) { |
433 | 433 | UserManager::subscribeUserToBossList($user_id, $user['student_boss']); |
434 | 434 | } |
435 | 435 | |
436 | - if (api_get_setting('openid_authentication') == 'true' && !empty($user['openid'])) { |
|
437 | - $up = UserManager::update_openid($user_id, $user['openid']); |
|
438 | - } |
|
436 | + if (api_get_setting('openid_authentication') == 'true' && !empty($user['openid'])) { |
|
437 | + $up = UserManager::update_openid($user_id, $user['openid']); |
|
438 | + } |
|
439 | 439 | $currentUserId = api_get_user_id(); |
440 | 440 | |
441 | 441 | $userObj = api_get_user_entity($user_id); |
442 | 442 | |
443 | 443 | UserManager::add_user_as_admin($userObj); |
444 | 444 | |
445 | - if ($user_id != $currentUserId) { |
|
446 | - if ($platform_admin == 1) { |
|
447 | - $userObj = api_get_user_entity($user_id); |
|
445 | + if ($user_id != $currentUserId) { |
|
446 | + if ($platform_admin == 1) { |
|
447 | + $userObj = api_get_user_entity($user_id); |
|
448 | 448 | UserManager::add_user_as_admin($userObj); |
449 | - } else { |
|
449 | + } else { |
|
450 | 450 | UserManager::remove_user_admin($user_id); |
451 | - } |
|
452 | - } |
|
451 | + } |
|
452 | + } |
|
453 | 453 | |
454 | 454 | $extraFieldValue = new ExtraFieldValue('user'); |
455 | 455 | $extraFieldValue->saveFieldValues($user); |
456 | 456 | |
457 | - $tok = Security::get_token(); |
|
457 | + $tok = Security::get_token(); |
|
458 | 458 | |
459 | 459 | Display::addFlash(Display::return_message(get_lang('UserUpdated'))); |
460 | - header('Location: user_list.php?sec_token='.$tok); |
|
461 | - exit(); |
|
462 | - } |
|
460 | + header('Location: user_list.php?sec_token='.$tok); |
|
461 | + exit(); |
|
462 | + } |
|
463 | 463 | } |
464 | 464 | |
465 | 465 | if ($error_drh) { |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | |
59 | 59 | $gradebook = ''; |
60 | 60 | if (isset($_SESSION['gradebook'])) { |
61 | - $gradebook= $_SESSION['gradebook']; |
|
61 | + $gradebook= $_SESSION['gradebook']; |
|
62 | 62 | } |
63 | 63 | if (!empty($gradebook) && $gradebook=='view') { |
64 | 64 | $interbreadcrumb[] = array( |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | $htmlHeadXtra[] = '<link rel="stylesheet" href="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/css/hotspot.css">'; |
79 | 79 | |
80 | 80 | if ($origin != 'learnpath') { |
81 | - // So we are not in learnpath tool |
|
82 | - Display::display_header($nameTools, get_lang('Exercise')); |
|
81 | + // So we are not in learnpath tool |
|
82 | + Display::display_header($nameTools, get_lang('Exercise')); |
|
83 | 83 | } else { |
84 | 84 | $htmlHeadXtra[] = " |
85 | 85 | <style> |
@@ -93,19 +93,19 @@ discard block |
||
93 | 93 | |
94 | 94 | // I'm in a preview mode as course admin. Display the action menu. |
95 | 95 | if (api_is_course_admin() && $origin != 'learnpath') { |
96 | - echo '<div class="actions">'; |
|
97 | - echo '<a href="admin.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'">'. |
|
96 | + echo '<div class="actions">'; |
|
97 | + echo '<a href="admin.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'">'. |
|
98 | 98 | Display::return_icon('back.png', get_lang('GoBackToQuestionList'), array(), 32).'</a>'; |
99 | - echo '<a href="exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$objExercise->id.'">'. |
|
99 | + echo '<a href="exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$objExercise->id.'">'. |
|
100 | 100 | Display::return_icon('edit.png', get_lang('ModifyExercise'), array(), 32).'</a>'; |
101 | - echo '</div>'; |
|
101 | + echo '</div>'; |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | $feedback_type = $objExercise->feedback_type; |
105 | 105 | $exercise_stat_info = $objExercise->get_stat_track_exercise_info_by_exe_id($exe_id); |
106 | 106 | |
107 | 107 | if (!empty($exercise_stat_info['data_tracking'])) { |
108 | - $question_list = explode(',', $exercise_stat_info['data_tracking']); |
|
108 | + $question_list = explode(',', $exercise_stat_info['data_tracking']); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | $learnpath_id = $exercise_stat_info['orig_lp_id']; |
@@ -204,11 +204,11 @@ discard block |
||
204 | 204 | Session::erase('objExercise'); |
205 | 205 | Session::erase('exe_id'); |
206 | 206 | } |
207 | - Display::display_footer(); |
|
207 | + Display::display_footer(); |
|
208 | 208 | } else { |
209 | - $lp_mode = isset($_SESSION['lp_mode']) ? $_SESSION['lp_mode'] : null; |
|
210 | - $url = '../lp/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exercise_stat_info['exe_id'].'&fb_type='.$objExercise->feedback_type.'#atoc_'.$learnpath_item_id; |
|
211 | - $href = ($lp_mode == 'fullscreen')?' window.opener.location.href="'.$url.'" ':' top.location.href="'.$url.'"'; |
|
209 | + $lp_mode = isset($_SESSION['lp_mode']) ? $_SESSION['lp_mode'] : null; |
|
210 | + $url = '../lp/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exercise_stat_info['exe_id'].'&fb_type='.$objExercise->feedback_type.'#atoc_'.$learnpath_item_id; |
|
211 | + $href = ($lp_mode == 'fullscreen')?' window.opener.location.href="'.$url.'" ':' top.location.href="'.$url.'"'; |
|
212 | 212 | |
213 | 213 | if (api_is_allowed_to_session_edit()) { |
214 | 214 | Session::erase('objExercise'); |
@@ -217,8 +217,8 @@ discard block |
||
217 | 217 | |
218 | 218 | Session::write('attempt_remaining', $remainingMessage); |
219 | 219 | |
220 | - // Record the results in the learning path, using the SCORM interface (API) |
|
221 | - echo "<script>window.parent.API.void_save_asset('$total_score', '$max_score', 0, 'completed');</script>"; |
|
220 | + // Record the results in the learning path, using the SCORM interface (API) |
|
221 | + echo "<script>window.parent.API.void_save_asset('$total_score', '$max_score', 0, 'completed');</script>"; |
|
222 | 222 | echo '<script type="text/javascript">'.$href.'</script>'; |
223 | - echo '</body></html>'; |
|
223 | + echo '</body></html>'; |
|
224 | 224 | } |
@@ -41,13 +41,13 @@ discard block |
||
41 | 41 | $learnpath_id = 0; |
42 | 42 | |
43 | 43 | if (isset($_REQUEST['learnpath_id'])) { |
44 | - $learnpath_id = intval($_REQUEST['learnpath_id']); |
|
44 | + $learnpath_id = intval($_REQUEST['learnpath_id']); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | $learnpath_item_id = 0; |
48 | 48 | |
49 | 49 | if (isset($_REQUEST['learnpath_item_id'])) { |
50 | - $learnpath_item_id = intval($_REQUEST['learnpath_item_id']); |
|
50 | + $learnpath_item_id = intval($_REQUEST['learnpath_item_id']); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | $_SESSION['hotspot_coord']=array(); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | // Getting the options by js |
92 | 92 | if (empty($choice_value)) { |
93 | 93 | |
94 | - echo "<script> |
|
94 | + echo "<script> |
|
95 | 95 | // this works for only radio buttons |
96 | 96 | var f = self.parent.window.document.frm_exercise; |
97 | 97 | var choice_js=''; |
@@ -120,12 +120,12 @@ discard block |
||
120 | 120 | } |
121 | 121 | |
122 | 122 | "; |
123 | - // IMPORTANT |
|
124 | - //this is the real redirect function |
|
125 | - //echo 'window.location.href = "exercise_submit_modal.php?learnpath_id='.$learnpath_id.'&learnpath_item_id='.$learnpath_item_id.'&hotspotcoord="+ hotspotcoord + "&hotspot="+ hotspot + "&choice="+ choice_js + "&exerciseId='.$exerciseId.'&num='.$questionNum.'&exerciseType='.$exerciseType.'&origin='.$origin.'&gradebook='.$gradebook.'";'; |
|
123 | + // IMPORTANT |
|
124 | + //this is the real redirect function |
|
125 | + //echo 'window.location.href = "exercise_submit_modal.php?learnpath_id='.$learnpath_id.'&learnpath_item_id='.$learnpath_item_id.'&hotspotcoord="+ hotspotcoord + "&hotspot="+ hotspot + "&choice="+ choice_js + "&exerciseId='.$exerciseId.'&num='.$questionNum.'&exerciseType='.$exerciseType.'&origin='.$origin.'&gradebook='.$gradebook.'";'; |
|
126 | 126 | echo ' url = "exercise_submit_modal.php?learnpath_id='.$learnpath_id.'&learnpath_item_id='.$learnpath_item_id.'&hotspotcoord="+ hotspotcoord + "&hotspot="+ hotspot + "&choice="+ choice_js + "&exerciseId='.$exerciseId.'&num='.$questionNum.'&exerciseType='.$exerciseType.'&origin='.$origin.'&gradebook='.$gradebook.'";'; |
127 | 127 | echo "$('#global-modal .modal-body').load(url);"; |
128 | - echo '</script>'; |
|
128 | + echo '</script>'; |
|
129 | 129 | |
130 | 130 | exit; |
131 | 131 | } |
@@ -178,12 +178,12 @@ discard block |
||
178 | 178 | |
179 | 179 | // creates a temporary Question object |
180 | 180 | if (in_array($questionid, $questionList)) { |
181 | - $objQuestionTmp = Question :: read($questionid); |
|
182 | - $questionName =$objQuestionTmp->selectTitle(); |
|
183 | - $questionDescription=$objQuestionTmp->selectDescription(); |
|
184 | - $questionWeighting =$objQuestionTmp->selectWeighting(); |
|
185 | - $answerType =$objQuestionTmp->selectType(); |
|
186 | - $quesId =$objQuestionTmp->selectId(); //added by priya saini |
|
181 | + $objQuestionTmp = Question :: read($questionid); |
|
182 | + $questionName =$objQuestionTmp->selectTitle(); |
|
183 | + $questionDescription=$objQuestionTmp->selectDescription(); |
|
184 | + $questionWeighting =$objQuestionTmp->selectWeighting(); |
|
185 | + $answerType =$objQuestionTmp->selectType(); |
|
186 | + $quesId =$objQuestionTmp->selectId(); //added by priya saini |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | $objAnswerTmp=new Answer($questionid); |
@@ -206,43 +206,43 @@ discard block |
||
206 | 206 | $totalScore = 0; |
207 | 207 | |
208 | 208 | if (!empty($choice_value)) { |
209 | - for ($answerId=1;$answerId <= $nbrAnswers;$answerId++) { |
|
210 | - $answer = $objAnswerTmp->selectAnswer($answerId); |
|
211 | - $answerComment = $objAnswerTmp->selectComment($answerId); |
|
212 | - $answerDestination = $objAnswerTmp->selectDestination($answerId); |
|
213 | - |
|
214 | - $answerCorrect = $objAnswerTmp->isCorrect($answerId); |
|
215 | - $answerWeighting = $objAnswerTmp->selectWeighting($answerId); |
|
216 | - $numAnswer = $objAnswerTmp->selectAutoId($answerId); |
|
217 | - |
|
218 | - //delineation |
|
219 | - $delineation_cord = $objAnswerTmp->selectHotspotCoordinates(1); |
|
220 | - $answer_delineation_destination=$objAnswerTmp->selectDestination(1); |
|
209 | + for ($answerId=1;$answerId <= $nbrAnswers;$answerId++) { |
|
210 | + $answer = $objAnswerTmp->selectAnswer($answerId); |
|
211 | + $answerComment = $objAnswerTmp->selectComment($answerId); |
|
212 | + $answerDestination = $objAnswerTmp->selectDestination($answerId); |
|
213 | + |
|
214 | + $answerCorrect = $objAnswerTmp->isCorrect($answerId); |
|
215 | + $answerWeighting = $objAnswerTmp->selectWeighting($answerId); |
|
216 | + $numAnswer = $objAnswerTmp->selectAutoId($answerId); |
|
217 | + |
|
218 | + //delineation |
|
219 | + $delineation_cord = $objAnswerTmp->selectHotspotCoordinates(1); |
|
220 | + $answer_delineation_destination=$objAnswerTmp->selectDestination(1); |
|
221 | 221 | if ($dbg_local>0) { error_log(__LINE__.' answerId: '.$answerId.'('.$answerType.') - user delineation_cord: '.$delineation_cord.' - $answer_delineation_destination: '.$answer_delineation_destination,0);} |
222 | 222 | |
223 | - switch($answerType) { |
|
224 | - // for unique answer |
|
225 | - case UNIQUE_ANSWER : |
|
226 | - $studentChoice = ($choice_value == $numAnswer)?1:0; |
|
227 | - if ($studentChoice) { |
|
228 | - $questionScore +=$answerWeighting; |
|
229 | - $totalScore +=$answerWeighting; |
|
230 | - $newquestionList[]=$questionid; |
|
231 | - } |
|
232 | - break; |
|
233 | - case HOT_SPOT_DELINEATION : |
|
234 | - $studentChoice=$choice[$answerId]; |
|
235 | - if ($studentChoice) { |
|
236 | - $newquestionList[]=$questionid; |
|
237 | - } |
|
238 | - if ($answerId===1) { |
|
239 | - $questionScore +=$answerWeighting; |
|
240 | - $totalScore +=$answerWeighting; |
|
241 | - $_SESSION['hotspot_coord'][1] =$delineation_cord; |
|
242 | - $_SESSION['hotspot_dest'][1] =$answer_delineation_destination; |
|
243 | - } |
|
244 | - break; |
|
245 | - } |
|
223 | + switch($answerType) { |
|
224 | + // for unique answer |
|
225 | + case UNIQUE_ANSWER : |
|
226 | + $studentChoice = ($choice_value == $numAnswer)?1:0; |
|
227 | + if ($studentChoice) { |
|
228 | + $questionScore +=$answerWeighting; |
|
229 | + $totalScore +=$answerWeighting; |
|
230 | + $newquestionList[]=$questionid; |
|
231 | + } |
|
232 | + break; |
|
233 | + case HOT_SPOT_DELINEATION : |
|
234 | + $studentChoice=$choice[$answerId]; |
|
235 | + if ($studentChoice) { |
|
236 | + $newquestionList[]=$questionid; |
|
237 | + } |
|
238 | + if ($answerId===1) { |
|
239 | + $questionScore +=$answerWeighting; |
|
240 | + $totalScore +=$answerWeighting; |
|
241 | + $_SESSION['hotspot_coord'][1] =$delineation_cord; |
|
242 | + $_SESSION['hotspot_dest'][1] =$answer_delineation_destination; |
|
243 | + } |
|
244 | + break; |
|
245 | + } |
|
246 | 246 | |
247 | 247 | |
248 | 248 | if ($answerType == UNIQUE_ANSWER || $answerType == MULTIPLE_ANSWER) { |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | $lp_hotspot=$destination_items[2]; |
340 | 340 | $select_question_hotspot=$destination_items[3]; |
341 | 341 | $url_hotspot=$destination_items[4]; |
342 | - //echo 'show the feedback'; |
|
342 | + //echo 'show the feedback'; |
|
343 | 343 | } |
344 | 344 | } elseif($answerId>1) { |
345 | 345 | if ($objAnswerTmp->selectHotspotType($answerId) == 'noerror') { |
@@ -396,41 +396,41 @@ discard block |
||
396 | 396 | //we send the error |
397 | 397 | } |
398 | 398 | } |
399 | - } |
|
399 | + } |
|
400 | 400 | |
401 | - if ($overlap_color) { |
|
402 | - $overlap_color='green'; |
|
401 | + if ($overlap_color) { |
|
402 | + $overlap_color='green'; |
|
403 | 403 | } else { |
404 | - $overlap_color='red'; |
|
404 | + $overlap_color='red'; |
|
405 | 405 | } |
406 | - if ($missing_color) { |
|
407 | - $missing_color='green'; |
|
406 | + if ($missing_color) { |
|
407 | + $missing_color='green'; |
|
408 | 408 | } else { |
409 | - $missing_color='red'; |
|
409 | + $missing_color='red'; |
|
410 | 410 | } |
411 | - if ($excess_color) { |
|
412 | - $excess_color='green'; |
|
411 | + if ($excess_color) { |
|
412 | + $excess_color='green'; |
|
413 | 413 | } else { |
414 | - $excess_color='red'; |
|
414 | + $excess_color='red'; |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | if (!is_numeric($final_overlap)) { |
418 | - $final_overlap = 0; |
|
418 | + $final_overlap = 0; |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | if (!is_numeric($final_missing)) { |
422 | - $final_missing = 0; |
|
422 | + $final_missing = 0; |
|
423 | 423 | } |
424 | 424 | if (!is_numeric($final_excess)) { |
425 | - $final_excess = 0; |
|
425 | + $final_excess = 0; |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | if ($final_excess>100) { |
429 | - $final_excess = 100; |
|
429 | + $final_excess = 100; |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | |
433 | - $table_resume = '<table class="data_table" > |
|
433 | + $table_resume = '<table class="data_table" > |
|
434 | 434 | <tr class="row_odd" > |
435 | 435 | <td></td> |
436 | 436 | <td ><b>'.get_lang('Requirements').'</b></td> |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | <td><div style="color:'.$missing_color.'">'.(($final_missing < 0)?0:intval($final_missing)).'</div></td> |
456 | 456 | </tr> |
457 | 457 | </table>'; |
458 | - //var_dump($final_overlap, $threadhold1 , $final_missing, $threadhold2 , $final_excess, $threadhold3); |
|
458 | + //var_dump($final_overlap, $threadhold1 , $final_missing, $threadhold2 , $final_excess, $threadhold3); |
|
459 | 459 | } |
460 | 460 | $_SESSION['newquestionList'] = $newquestionList; |
461 | 461 | |
@@ -472,68 +472,68 @@ discard block |
||
472 | 472 | if ($answerType != HOT_SPOT_DELINEATION) { |
473 | 473 | if (!empty($destination)) { |
474 | 474 | $item_list = explode('@@',$destination); |
475 | - //print_R($item_list); |
|
476 | - $try = $item_list[0]; |
|
477 | - $lp = $item_list[1]; |
|
478 | - $destinationid= $item_list[2]; |
|
479 | - $url=$item_list[3]; |
|
475 | + //print_R($item_list); |
|
476 | + $try = $item_list[0]; |
|
477 | + $lp = $item_list[1]; |
|
478 | + $destinationid= $item_list[2]; |
|
479 | + $url=$item_list[3]; |
|
480 | 480 | } |
481 | - $table_resume=''; |
|
481 | + $table_resume=''; |
|
482 | 482 | } else { |
483 | - $try = $try_hotspot; |
|
484 | - $lp = $lp_hotspot; |
|
485 | - $destinationid= $select_question_hotspot; |
|
486 | - $url=$url_hotspot; |
|
487 | - if ($organs_at_risk_hit==0 && $wrong_results==false ) { |
|
488 | - // no error = no oar and no wrong result for delineation |
|
489 | - //show if no error |
|
490 | - //echo 'no error'; |
|
491 | - $comment= $answerComment = $objAnswerTmp->selectComment($nbrAnswers); |
|
492 | - $answerDestination = $objAnswerTmp->selectDestination($nbrAnswers); |
|
493 | - |
|
494 | - //we send the error |
|
495 | - $destination_items= explode('@@', $answerDestination); |
|
496 | - $try=$destination_items[1]; |
|
497 | - $lp=$destination_items[2]; |
|
498 | - $destinationid=$destination_items[3]; |
|
499 | - $url=$destination_items[4]; |
|
500 | - $exerciseResult[$questionid] = 1; |
|
501 | - } else { |
|
502 | - $exerciseResult[$questionid] = 0; |
|
503 | - } |
|
483 | + $try = $try_hotspot; |
|
484 | + $lp = $lp_hotspot; |
|
485 | + $destinationid= $select_question_hotspot; |
|
486 | + $url=$url_hotspot; |
|
487 | + if ($organs_at_risk_hit==0 && $wrong_results==false ) { |
|
488 | + // no error = no oar and no wrong result for delineation |
|
489 | + //show if no error |
|
490 | + //echo 'no error'; |
|
491 | + $comment= $answerComment = $objAnswerTmp->selectComment($nbrAnswers); |
|
492 | + $answerDestination = $objAnswerTmp->selectDestination($nbrAnswers); |
|
493 | + |
|
494 | + //we send the error |
|
495 | + $destination_items= explode('@@', $answerDestination); |
|
496 | + $try=$destination_items[1]; |
|
497 | + $lp=$destination_items[2]; |
|
498 | + $destinationid=$destination_items[3]; |
|
499 | + $url=$destination_items[4]; |
|
500 | + $exerciseResult[$questionid] = 1; |
|
501 | + } else { |
|
502 | + $exerciseResult[$questionid] = 0; |
|
503 | + } |
|
504 | 504 | } |
505 | 505 | |
506 | 506 | // the link to retry the question |
507 | 507 | if (isset($try) && $try==1) { |
508 | - $num_value_array= (array_keys($questionList, $questionid)); |
|
509 | - $links.= Display :: return_icon('reload.gif', '', array ('style' => 'padding-left:0px;padding-right:5px;')).'<a onclick="SendEx('.$num_value_array[0].');" href="#">'.get_lang('TryAgain').'</a><br /><br />'; |
|
508 | + $num_value_array= (array_keys($questionList, $questionid)); |
|
509 | + $links.= Display :: return_icon('reload.gif', '', array ('style' => 'padding-left:0px;padding-right:5px;')).'<a onclick="SendEx('.$num_value_array[0].');" href="#">'.get_lang('TryAgain').'</a><br /><br />'; |
|
510 | 510 | } |
511 | 511 | |
512 | 512 | // the link to theory (a learning path) |
513 | 513 | if (!empty($lp)) { |
514 | - $lp_url= api_get_path(WEB_CODE_PATH) . 'lp/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$lp; |
|
515 | - $list = new LearnpathList(api_get_user_id()); |
|
516 | - $flat_list = $list->get_flat_list(); |
|
517 | - $links.= Display :: return_icon('theory.gif', '', array ('style' => 'padding-left:0px;padding-right:5px;')).'<a target="_blank" href="'.$lp_url.'">'.get_lang('SeeTheory').'</a><br />'; |
|
514 | + $lp_url= api_get_path(WEB_CODE_PATH) . 'lp/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$lp; |
|
515 | + $list = new LearnpathList(api_get_user_id()); |
|
516 | + $flat_list = $list->get_flat_list(); |
|
517 | + $links.= Display :: return_icon('theory.gif', '', array ('style' => 'padding-left:0px;padding-right:5px;')).'<a target="_blank" href="'.$lp_url.'">'.get_lang('SeeTheory').'</a><br />'; |
|
518 | 518 | } |
519 | 519 | $links.='<br />'; |
520 | 520 | |
521 | 521 | // the link to an external website or link |
522 | 522 | if (!empty($url)) { |
523 | - $links.= Display :: return_icon('link.gif', '', array ('style' => 'padding-left:0px;padding-right:5px;')).'<a target="_blank" href="'.$url.'">'.get_lang('VisitUrl').'</a><br /><br />'; |
|
523 | + $links.= Display :: return_icon('link.gif', '', array ('style' => 'padding-left:0px;padding-right:5px;')).'<a target="_blank" href="'.$url.'">'.get_lang('VisitUrl').'</a><br /><br />'; |
|
524 | 524 | } |
525 | 525 | |
526 | 526 | // the link to finish the test |
527 | 527 | if ($destinationid==-1) { |
528 | - $links.= Display :: return_icon('finish.gif', '', array ('style' => 'width:22px; height:22px; padding-left:0px;padding-right:5px;')).'<a onclick="SendEx(-1);" href="#">'.get_lang('EndActivity').'</a><br /><br />'; |
|
528 | + $links.= Display :: return_icon('finish.gif', '', array ('style' => 'width:22px; height:22px; padding-left:0px;padding-right:5px;')).'<a onclick="SendEx(-1);" href="#">'.get_lang('EndActivity').'</a><br /><br />'; |
|
529 | 529 | } else { |
530 | - // the link to other question |
|
531 | - if (in_array($destinationid,$questionList)) { |
|
532 | - $objQuestionTmp = Question :: read($destinationid); |
|
533 | - $questionName=$objQuestionTmp->selectTitle(); |
|
534 | - $num_value_array= (array_keys($questionList, $destinationid)); |
|
535 | - $links.= Display :: return_icon('quiz.png', '', array ('style' => 'padding-left:0px;padding-right:5px;')).'<a onclick="SendEx('.$num_value_array[0].');" href="#">'.get_lang('GoToQuestion').' '.$num_value_array[0].'</a><br /><br />'; |
|
536 | - } |
|
530 | + // the link to other question |
|
531 | + if (in_array($destinationid,$questionList)) { |
|
532 | + $objQuestionTmp = Question :: read($destinationid); |
|
533 | + $questionName=$objQuestionTmp->selectTitle(); |
|
534 | + $num_value_array= (array_keys($questionList, $destinationid)); |
|
535 | + $links.= Display :: return_icon('quiz.png', '', array ('style' => 'padding-left:0px;padding-right:5px;')).'<a onclick="SendEx('.$num_value_array[0].');" href="#">'.get_lang('GoToQuestion').' '.$num_value_array[0].'</a><br /><br />'; |
|
536 | + } |
|
537 | 537 | } |
538 | 538 | |
539 | 539 | echo '<script> |
@@ -550,43 +550,43 @@ discard block |
||
550 | 550 | </script>'; |
551 | 551 | |
552 | 552 | if ($links!='') { |
553 | - /*echo '<div id="ModalContent" style="padding-bottom:30px;padding-top:10px;padding-left:20px;padding-right:20px;"> |
|
553 | + /*echo '<div id="ModalContent" style="padding-bottom:30px;padding-top:10px;padding-left:20px;padding-right:20px;"> |
|
554 | 554 | <a onclick="self.parent.tb_remove();" href="#" style="float:right; margin-top:-10px;">'.api_ucfirst(get_lang('Close')).'</a>';*/ |
555 | - echo '<h1><div style="color:#333;">'.get_lang('Feedback').'</div></h1>'; |
|
556 | - |
|
557 | - if ($answerType == HOT_SPOT_DELINEATION) { |
|
558 | - if ($organs_at_risk_hit > 0) { |
|
559 | - //$message='<p>'.get_lang('YourDelineation').'</p>'; |
|
560 | - //$message.=$table_resume; |
|
561 | - $message.='<br />'.get_lang('ResultIs').' <b>'.get_lang('Unacceptable').'</b><br />'; |
|
562 | - //if ($wrong_results) { } |
|
563 | - $message.='<p style="color:#DC0A0A;"><b>'.get_lang('OARHit').'</b></p>'; |
|
564 | - $message.='<p>'.$comment.'</p>'; |
|
565 | - } else { |
|
566 | - $message='<p>'.get_lang('YourDelineation').'</p>'; |
|
567 | - $message.=$table_resume; |
|
568 | - $message.='<br />'.get_lang('ResultIs').' <b>'.$result_comment.'</b><br />'; |
|
569 | - $message.='<p>'.$comment.'</p>'; |
|
570 | - } |
|
571 | - echo $message; |
|
572 | - } else { |
|
573 | - echo '<p>'.$comment.'</p>'; |
|
574 | - } |
|
575 | - echo '<h3>'.$links.'</h3>'; |
|
576 | - echo '</div>'; |
|
577 | - |
|
578 | - $_SESSION['hot_spot_result']=$message; |
|
579 | - $_SESSION['hotspot_delineation_result'][$exerciseId][$questionid] = array($message, $exerciseResult[$questionid]); |
|
580 | - //reseting the exerciseResult variable |
|
581 | - Session::write('exerciseResult',$exerciseResult); |
|
582 | - |
|
583 | - //save this variables just in case the exercise loads an LP with other exercise |
|
584 | - $_SESSION['objExerciseExtra'.$exerciseId] = $_SESSION['objExercise']; |
|
585 | - $_SESSION['exerciseResultExtra'.$exerciseId] = $_SESSION['exerciseResult']; |
|
586 | - $_SESSION['questionListExtra'.$exerciseId] = $_SESSION['questionList']; |
|
555 | + echo '<h1><div style="color:#333;">'.get_lang('Feedback').'</div></h1>'; |
|
556 | + |
|
557 | + if ($answerType == HOT_SPOT_DELINEATION) { |
|
558 | + if ($organs_at_risk_hit > 0) { |
|
559 | + //$message='<p>'.get_lang('YourDelineation').'</p>'; |
|
560 | + //$message.=$table_resume; |
|
561 | + $message.='<br />'.get_lang('ResultIs').' <b>'.get_lang('Unacceptable').'</b><br />'; |
|
562 | + //if ($wrong_results) { } |
|
563 | + $message.='<p style="color:#DC0A0A;"><b>'.get_lang('OARHit').'</b></p>'; |
|
564 | + $message.='<p>'.$comment.'</p>'; |
|
565 | + } else { |
|
566 | + $message='<p>'.get_lang('YourDelineation').'</p>'; |
|
567 | + $message.=$table_resume; |
|
568 | + $message.='<br />'.get_lang('ResultIs').' <b>'.$result_comment.'</b><br />'; |
|
569 | + $message.='<p>'.$comment.'</p>'; |
|
570 | + } |
|
571 | + echo $message; |
|
572 | + } else { |
|
573 | + echo '<p>'.$comment.'</p>'; |
|
574 | + } |
|
575 | + echo '<h3>'.$links.'</h3>'; |
|
576 | + echo '</div>'; |
|
577 | + |
|
578 | + $_SESSION['hot_spot_result']=$message; |
|
579 | + $_SESSION['hotspot_delineation_result'][$exerciseId][$questionid] = array($message, $exerciseResult[$questionid]); |
|
580 | + //reseting the exerciseResult variable |
|
581 | + Session::write('exerciseResult',$exerciseResult); |
|
582 | + |
|
583 | + //save this variables just in case the exercise loads an LP with other exercise |
|
584 | + $_SESSION['objExerciseExtra'.$exerciseId] = $_SESSION['objExercise']; |
|
585 | + $_SESSION['exerciseResultExtra'.$exerciseId] = $_SESSION['exerciseResult']; |
|
586 | + $_SESSION['questionListExtra'.$exerciseId] = $_SESSION['questionList']; |
|
587 | 587 | } else { |
588 | - $questionNum++; |
|
589 | - echo '<script> |
|
588 | + $questionNum++; |
|
589 | + echo '<script> |
|
590 | 590 | self.parent.window.location.href = "exercise_submit.php?exerciseId='.$exerciseId.'&num='.$questionNum.'&exerciseType='.$exerciseType.'&origin='.$origin.'"; |
591 | 591 | //self.parent.tb_remove(); |
592 | 592 | </script>'; |
@@ -61,13 +61,13 @@ discard block |
||
61 | 61 | $is_certificate_mode = false; |
62 | 62 | |
63 | 63 | if (isset($_REQUEST['certificate']) && $_REQUEST['certificate'] == 'true') { |
64 | - $is_certificate_mode = true; |
|
64 | + $is_certificate_mode = true; |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | if ($is_certificate_mode) { |
68 | - $nameTools = get_lang('CreateCertificate'); |
|
68 | + $nameTools = get_lang('CreateCertificate'); |
|
69 | 69 | } else { |
70 | - $nameTools = get_lang('CreateDocument'); |
|
70 | + $nameTools = get_lang('CreateDocument'); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /* Constants and variables */ |
@@ -124,26 +124,26 @@ discard block |
||
124 | 124 | |
125 | 125 | // Please, do not modify this dirname formatting |
126 | 126 | if (strstr($dir, '..')) { |
127 | - $dir = '/'; |
|
127 | + $dir = '/'; |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | if ($dir[0] == '.') { |
131 | - $dir = substr($dir, 1); |
|
131 | + $dir = substr($dir, 1); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | if ($dir[0] != '/') { |
135 | - $dir = '/'.$dir; |
|
135 | + $dir = '/'.$dir; |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | if ($dir[strlen($dir) - 1] != '/') { |
139 | - $dir .= '/'; |
|
139 | + $dir .= '/'; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | if ($is_certificate_mode) { |
143 | - $document_id = DocumentManager::get_document_id(api_get_course_info(), '/certificates'); |
|
144 | - $document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id(), true); |
|
145 | - $folder_id = $document_data['id']; |
|
146 | - $dir = '/certificates/'; |
|
143 | + $document_id = DocumentManager::get_document_id(api_get_course_info(), '/certificates'); |
|
144 | + $document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id(), true); |
|
145 | + $folder_id = $document_data['id']; |
|
146 | + $dir = '/certificates/'; |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | $doc_tree = explode('/', $dir); |
@@ -154,16 +154,16 @@ discard block |
||
154 | 154 | |
155 | 155 | // Level correction for group documents. |
156 | 156 | if (!empty($group_properties['directory'])) { |
157 | - $count_dir = $count_dir > 0 ? $count_dir - 1 : 0; |
|
157 | + $count_dir = $count_dir > 0 ? $count_dir - 1 : 0; |
|
158 | 158 | } |
159 | 159 | } |
160 | 160 | $relative_url = ''; |
161 | 161 | for ($i = 0; $i < ($count_dir); $i++) { |
162 | - $relative_url .= '../'; |
|
162 | + $relative_url .= '../'; |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | if ($relative_url== '') { |
166 | - $relative_url = '/'; |
|
166 | + $relative_url = '/'; |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | $is_allowed_to_edit = api_is_allowed_to_edit(null, true); |
@@ -175,11 +175,11 @@ discard block |
||
175 | 175 | 'cols-size' => [2, 10, 0], |
176 | 176 | 'FullPage' => true, |
177 | 177 | 'InDocument' => true, |
178 | - 'CreateDocumentDir' => $relative_url, |
|
179 | - 'CreateDocumentWebDir' => (empty($group_properties['directory'])) |
|
180 | - ? api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/' |
|
181 | - : api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document'.$group_properties['directory'].'/', |
|
182 | - 'BaseHref' => api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$dir |
|
178 | + 'CreateDocumentDir' => $relative_url, |
|
179 | + 'CreateDocumentWebDir' => (empty($group_properties['directory'])) |
|
180 | + ? api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/' |
|
181 | + : api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document'.$group_properties['directory'].'/', |
|
182 | + 'BaseHref' => api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$dir |
|
183 | 183 | ); |
184 | 184 | |
185 | 185 | if ($is_certificate_mode) { |
@@ -191,41 +191,41 @@ discard block |
||
191 | 191 | $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; |
192 | 192 | |
193 | 193 | if (!is_dir($filepath)) { |
194 | - $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/'; |
|
195 | - $dir = '/'; |
|
194 | + $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/'; |
|
195 | + $dir = '/'; |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | $to_group_id = 0; |
199 | 199 | if (!$is_certificate_mode) { |
200 | - if (api_is_in_group()) { |
|
200 | + if (api_is_in_group()) { |
|
201 | 201 | $interbreadcrumb[] = array( |
202 | 202 | "url" => "../group/group_space.php?".api_get_cidreq(), |
203 | 203 | "name" => get_lang('GroupSpace'), |
204 | 204 | ); |
205 | - $noPHP_SELF = true; |
|
206 | - $to_group_id = $group_properties['iid']; |
|
207 | - $path = explode('/', $dir); |
|
208 | - if ('/'.$path[1] != $group_properties['directory']) { |
|
209 | - api_not_allowed(true); |
|
210 | - } |
|
211 | - } |
|
205 | + $noPHP_SELF = true; |
|
206 | + $to_group_id = $group_properties['iid']; |
|
207 | + $path = explode('/', $dir); |
|
208 | + if ('/'.$path[1] != $group_properties['directory']) { |
|
209 | + api_not_allowed(true); |
|
210 | + } |
|
211 | + } |
|
212 | 212 | $interbreadcrumb[] = array( |
213 | 213 | "url" => "./document.php?curdirpath=".urlencode($dir)."&".api_get_cidreq(), |
214 | 214 | "name" => get_lang('Documents'), |
215 | 215 | ); |
216 | 216 | } else { |
217 | - $interbreadcrumb[]= array('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook')); |
|
217 | + $interbreadcrumb[]= array('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook')); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | if (!api_is_allowed_in_course()) { |
221 | - api_not_allowed(true); |
|
221 | + api_not_allowed(true); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | if (!($is_allowed_to_edit || |
225 | 225 | $groupRights || |
226 | 226 | DocumentManager::is_my_shared_folder($userId, $dir, api_get_session_id())) |
227 | 227 | ) { |
228 | - api_not_allowed(true); |
|
228 | + api_not_allowed(true); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | /* Header */ |
@@ -233,10 +233,10 @@ discard block |
||
233 | 233 | |
234 | 234 | $display_dir = $dir; |
235 | 235 | if (isset($group_properties)) { |
236 | - $display_dir = explode('/', $dir); |
|
237 | - unset($display_dir[0]); |
|
238 | - unset($display_dir[1]); |
|
239 | - $display_dir = implode('/', $display_dir); |
|
236 | + $display_dir = explode('/', $dir); |
|
237 | + unset($display_dir[0]); |
|
238 | + unset($display_dir[1]); |
|
239 | + $display_dir = implode('/', $display_dir); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | $select_cat = isset($_GET['selectcat']) ? intval($_GET['selectcat']) : null; |
@@ -253,9 +253,9 @@ discard block |
||
253 | 253 | $form->addElement('header', $nameTools); |
254 | 254 | |
255 | 255 | if ($is_certificate_mode) {//added condition for certicate in gradebook |
256 | - $form->addElement('hidden','certificate','true',array('id'=>'certificate')); |
|
257 | - if (isset($_GET['selectcat'])) { |
|
258 | - $form->addElement('hidden','selectcat', $select_cat); |
|
256 | + $form->addElement('hidden','certificate','true',array('id'=>'certificate')); |
|
257 | + if (isset($_GET['selectcat'])) { |
|
258 | + $form->addElement('hidden','selectcat', $select_cat); |
|
259 | 259 | } |
260 | 260 | } |
261 | 261 | |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | // new document created |
315 | 315 | |
316 | 316 | if (!$is_certificate_mode && |
317 | - !DocumentManager::is_my_shared_folder($userId, $dir, $current_session_id) |
|
317 | + !DocumentManager::is_my_shared_folder($userId, $dir, $current_session_id) |
|
318 | 318 | ) { |
319 | 319 | $folders = DocumentManager::get_all_document_folders( |
320 | 320 | $_course, |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | array('cols-size' => [2, 10, 0]) |
330 | 330 | ); |
331 | 331 | |
332 | - $folder_titles = array(); |
|
332 | + $folder_titles = array(); |
|
333 | 333 | if (is_array($folders)) { |
334 | 334 | $escaped_folders = array(); |
335 | 335 | foreach ($folders as $key => & $val) { |
@@ -366,22 +366,22 @@ discard block |
||
366 | 366 | } |
367 | 367 | } |
368 | 368 | |
369 | - if (empty($group_dir)) { |
|
370 | - $parent_select -> addOption(get_lang('HomeDirectory'), '/'); |
|
371 | - if (is_array($folders)) { |
|
372 | - foreach ($folders as & $folder) { |
|
373 | - //Hide some folders |
|
374 | - if ($folder=='/HotPotatoes_files' || $folder=='/certificates' || basename($folder)=='css') { |
|
369 | + if (empty($group_dir)) { |
|
370 | + $parent_select -> addOption(get_lang('HomeDirectory'), '/'); |
|
371 | + if (is_array($folders)) { |
|
372 | + foreach ($folders as & $folder) { |
|
373 | + //Hide some folders |
|
374 | + if ($folder=='/HotPotatoes_files' || $folder=='/certificates' || basename($folder)=='css') { |
|
375 | 375 | continue; |
376 | - } |
|
377 | - //Admin setting for Hide/Show the folders of all users |
|
378 | - if (api_get_setting('show_users_folders') == 'false' && |
|
376 | + } |
|
377 | + //Admin setting for Hide/Show the folders of all users |
|
378 | + if (api_get_setting('show_users_folders') == 'false' && |
|
379 | 379 | (strstr($folder, '/shared_folder') || strstr($folder, 'shared_folder_session_')) |
380 | 380 | ){ |
381 | - continue; |
|
382 | - } |
|
383 | - //Admin setting for Hide/Show Default folders to all users |
|
384 | - if (api_get_setting('show_default_folders') == 'false' && |
|
381 | + continue; |
|
382 | + } |
|
383 | + //Admin setting for Hide/Show Default folders to all users |
|
384 | + if (api_get_setting('show_default_folders') == 'false' && |
|
385 | 385 | ( |
386 | 386 | $folder == '/images' || |
387 | 387 | $folder == '/flash' || |
@@ -391,82 +391,82 @@ discard block |
||
391 | 391 | $folder == '/video/flv' |
392 | 392 | ) |
393 | 393 | ){ |
394 | - continue; |
|
395 | - } |
|
396 | - //Admin setting for Hide/Show chat history folder |
|
397 | - if (api_get_setting('show_chat_folder') == 'false' && |
|
394 | + continue; |
|
395 | + } |
|
396 | + //Admin setting for Hide/Show chat history folder |
|
397 | + if (api_get_setting('show_chat_folder') == 'false' && |
|
398 | 398 | $folder=='/chat_files' |
399 | 399 | ){ |
400 | - continue; |
|
401 | - } |
|
400 | + continue; |
|
401 | + } |
|
402 | 402 | |
403 | - $selected = (substr($dir,0,-1) == $folder) ? ' selected="selected"' : ''; |
|
404 | - $path_parts = explode('/', $folder); |
|
405 | - $folder_titles[$folder] = cut($folder_titles[$folder], 80); |
|
403 | + $selected = (substr($dir,0,-1) == $folder) ? ' selected="selected"' : ''; |
|
404 | + $path_parts = explode('/', $folder); |
|
405 | + $folder_titles[$folder] = cut($folder_titles[$folder], 80); |
|
406 | 406 | $space_counter =count($path_parts) - 2; |
407 | 407 | if ($space_counter > 0) { |
408 | 408 | $label = str_repeat(' ', $space_counter).' — '.$folder_titles[$folder]; |
409 | 409 | } else { |
410 | 410 | $label = ' — '.$folder_titles[$folder]; |
411 | 411 | } |
412 | - $parent_select -> addOption($label, $folder); |
|
413 | - if ($selected != '') { |
|
414 | - $parent_select->setSelected($folder); |
|
415 | - } |
|
416 | - } |
|
417 | - } |
|
418 | - } else { |
|
419 | - if (is_array($folders) && !empty($folders)) { |
|
420 | - foreach ($folders as & $folder) { |
|
421 | - $selected = (substr($dir, 0, -1) == $folder) ? ' selected="selected"' : ''; |
|
422 | - $label = $folder_titles[$folder]; |
|
423 | - if ($folder == $group_dir) { |
|
424 | - $label = '/ (' . get_lang('HomeDirectory') . ')'; |
|
425 | - } else { |
|
426 | - $path_parts = explode('/', str_replace($group_dir, '', $folder)); |
|
427 | - $label = cut($label, 80); |
|
428 | - $label = str_repeat(' ', count($path_parts) - 2) . ' — ' . $label; |
|
429 | - } |
|
430 | - $parent_select->addOption($label, $folder); |
|
431 | - if ($selected != '') { |
|
432 | - $parent_select->setSelected($folder); |
|
433 | - } |
|
434 | - } |
|
435 | - } |
|
436 | - } |
|
412 | + $parent_select -> addOption($label, $folder); |
|
413 | + if ($selected != '') { |
|
414 | + $parent_select->setSelected($folder); |
|
415 | + } |
|
416 | + } |
|
417 | + } |
|
418 | + } else { |
|
419 | + if (is_array($folders) && !empty($folders)) { |
|
420 | + foreach ($folders as & $folder) { |
|
421 | + $selected = (substr($dir, 0, -1) == $folder) ? ' selected="selected"' : ''; |
|
422 | + $label = $folder_titles[$folder]; |
|
423 | + if ($folder == $group_dir) { |
|
424 | + $label = '/ (' . get_lang('HomeDirectory') . ')'; |
|
425 | + } else { |
|
426 | + $path_parts = explode('/', str_replace($group_dir, '', $folder)); |
|
427 | + $label = cut($label, 80); |
|
428 | + $label = str_repeat(' ', count($path_parts) - 2) . ' — ' . $label; |
|
429 | + } |
|
430 | + $parent_select->addOption($label, $folder); |
|
431 | + if ($selected != '') { |
|
432 | + $parent_select->setSelected($folder); |
|
433 | + } |
|
434 | + } |
|
435 | + } |
|
436 | + } |
|
437 | 437 | } |
438 | 438 | |
439 | 439 | $form->addHidden('dirValue', ''); |
440 | 440 | |
441 | 441 | if ($is_certificate_mode) { |
442 | - $form->addButtonCreate(get_lang('CreateCertificate')); |
|
442 | + $form->addButtonCreate(get_lang('CreateCertificate')); |
|
443 | 443 | } else { |
444 | - $form->addButtonCreate(get_lang('CreateDoc')); |
|
444 | + $form->addButtonCreate(get_lang('CreateDoc')); |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | $form->setDefaults($defaults); |
448 | 448 | |
449 | 449 | // If form validates -> save the new document |
450 | 450 | if ($form->validate()) { |
451 | - $values = $form->exportValues(); |
|
452 | - $readonly = isset($values['readonly']) ? 1 : 0; |
|
453 | - $values['title'] = trim($values['title']); |
|
451 | + $values = $form->exportValues(); |
|
452 | + $readonly = isset($values['readonly']) ? 1 : 0; |
|
453 | + $values['title'] = trim($values['title']); |
|
454 | 454 | |
455 | 455 | if (!empty($values['dirValue'])) { |
456 | 456 | $dir = $values['dirValue']; |
457 | 457 | } |
458 | 458 | |
459 | 459 | if ($dir[strlen($dir) - 1] != '/') { |
460 | - $dir .= '/'; |
|
461 | - } |
|
460 | + $dir .= '/'; |
|
461 | + } |
|
462 | 462 | $filepath = $filepath.$dir; |
463 | 463 | |
464 | 464 | // Setting the filename |
465 | - $filename = $values['title']; |
|
466 | - $filename = addslashes(trim($filename)); |
|
467 | - $filename = Security::remove_XSS($filename); |
|
468 | - $filename = api_replace_dangerous_char($filename); |
|
469 | - $filename = disable_dangerous_file($filename); |
|
465 | + $filename = $values['title']; |
|
466 | + $filename = addslashes(trim($filename)); |
|
467 | + $filename = Security::remove_XSS($filename); |
|
468 | + $filename = api_replace_dangerous_char($filename); |
|
469 | + $filename = disable_dangerous_file($filename); |
|
470 | 470 | $filename .= DocumentManager::getDocumentSuffix( |
471 | 471 | $_course, |
472 | 472 | api_get_session_id(), |
@@ -474,14 +474,14 @@ discard block |
||
474 | 474 | ); |
475 | 475 | |
476 | 476 | // Setting the title |
477 | - $title = $values['title']; |
|
477 | + $title = $values['title']; |
|
478 | 478 | |
479 | 479 | // Setting the extension |
480 | - $extension = 'html'; |
|
480 | + $extension = 'html'; |
|
481 | 481 | |
482 | - $content = Security::remove_XSS($values['content'], COURSEMANAGERLOWSECURITY); |
|
482 | + $content = Security::remove_XSS($values['content'], COURSEMANAGERLOWSECURITY); |
|
483 | 483 | |
484 | - /*if (strpos($content, '/css/frames.css') == false) { |
|
484 | + /*if (strpos($content, '/css/frames.css') == false) { |
|
485 | 485 | $content = str_replace('</head>', '<link rel="stylesheet" href="./css/frames.css" type="text/css" /><style> body{margin:50px;}</style></head>', $content); |
486 | 486 | }*/ |
487 | 487 | |
@@ -494,21 +494,21 @@ discard block |
||
494 | 494 | exit; |
495 | 495 | } |
496 | 496 | |
497 | - if ($fp = @fopen($filepath.$filename.'.'.$extension, 'w')) { |
|
497 | + if ($fp = @fopen($filepath.$filename.'.'.$extension, 'w')) { |
|
498 | 498 | |
499 | - $content = str_replace( |
|
500 | - api_get_path(WEB_COURSE_PATH), |
|
499 | + $content = str_replace( |
|
500 | + api_get_path(WEB_COURSE_PATH), |
|
501 | 501 | api_get_configuration_value('url_append').api_get_path(REL_COURSE_PATH), |
502 | 502 | $content |
503 | 503 | ); |
504 | 504 | |
505 | - fputs($fp, $content); |
|
506 | - fclose($fp); |
|
507 | - chmod($filepath.$filename.'.'.$extension, api_get_permissions_for_new_files()); |
|
505 | + fputs($fp, $content); |
|
506 | + fclose($fp); |
|
507 | + chmod($filepath.$filename.'.'.$extension, api_get_permissions_for_new_files()); |
|
508 | 508 | |
509 | 509 | |
510 | - $file_size = filesize($filepath.$filename.'.'.$extension); |
|
511 | - $save_file_path = $dir.$filename.'.'.$extension; |
|
510 | + $file_size = filesize($filepath.$filename.'.'.$extension); |
|
511 | + $save_file_path = $dir.$filename.'.'.$extension; |
|
512 | 512 | |
513 | 513 | $document_id = add_document( |
514 | 514 | $_course, |
@@ -520,8 +520,8 @@ discard block |
||
520 | 520 | $readonly |
521 | 521 | ); |
522 | 522 | |
523 | - if ($document_id) { |
|
524 | - api_item_property_update( |
|
523 | + if ($document_id) { |
|
524 | + api_item_property_update( |
|
525 | 525 | $_course, |
526 | 526 | TOOL_DOCUMENT, |
527 | 527 | $document_id, |
@@ -533,13 +533,13 @@ discard block |
||
533 | 533 | null, |
534 | 534 | $current_session_id |
535 | 535 | ); |
536 | - // Update parent folders |
|
537 | - item_property_update_on_folder($_course, $dir, $userId); |
|
538 | - $new_comment = isset($_POST['comment']) ? trim($_POST['comment']) : ''; |
|
539 | - $new_title = isset($_POST['title']) ? trim($_POST['title']) : ''; |
|
536 | + // Update parent folders |
|
537 | + item_property_update_on_folder($_course, $dir, $userId); |
|
538 | + $new_comment = isset($_POST['comment']) ? trim($_POST['comment']) : ''; |
|
539 | + $new_title = isset($_POST['title']) ? trim($_POST['title']) : ''; |
|
540 | 540 | $new_title = htmlspecialchars($new_title); |
541 | - if ($new_comment || $new_title) { |
|
542 | - $ct = ''; |
|
541 | + if ($new_comment || $new_title) { |
|
542 | + $ct = ''; |
|
543 | 543 | $params = []; |
544 | 544 | if ($new_comment) { |
545 | 545 | $params['comment'] = $new_comment; |
@@ -554,39 +554,39 @@ discard block |
||
554 | 554 | ['c_id = ? AND id = ?' => [$course_id, $document_id]] |
555 | 555 | ); |
556 | 556 | } |
557 | - } |
|
558 | - $dir= substr($dir,0,-1); |
|
559 | - $selectcat = ''; |
|
557 | + } |
|
558 | + $dir= substr($dir,0,-1); |
|
559 | + $selectcat = ''; |
|
560 | 560 | if (isset($_REQUEST['selectcat'])) { |
561 | 561 | $selectcat = "&selectcat=".intval($_REQUEST['selectcat']); |
562 | 562 | } |
563 | - $certificate_condition = ''; |
|
564 | - if ($is_certificate_mode) { |
|
565 | - $df = DocumentManager::get_default_certificate_id($_course['code']); |
|
563 | + $certificate_condition = ''; |
|
564 | + if ($is_certificate_mode) { |
|
565 | + $df = DocumentManager::get_default_certificate_id($_course['code']); |
|
566 | 566 | if (!isset($df)) { |
567 | 567 | DocumentManager::attach_gradebook_certificate($_course['code'],$document_id); |
568 | - } |
|
569 | - $certificate_condition = '&certificate=true&curdirpath=/certificates'; |
|
570 | - } |
|
568 | + } |
|
569 | + $certificate_condition = '&certificate=true&curdirpath=/certificates'; |
|
570 | + } |
|
571 | 571 | Display::addFlash(Display::return_message(get_lang('ItemAdded'))); |
572 | - header('Location: document.php?'.api_get_cidreq().'&id='.$folder_id.$selectcat.$certificate_condition); |
|
573 | - exit(); |
|
574 | - } else { |
|
575 | - Display :: display_header($nameTools, 'Doc'); |
|
576 | - Display :: display_error_message(get_lang('Impossible')); |
|
577 | - Display :: display_footer(); |
|
578 | - } |
|
579 | - } else { |
|
580 | - Display :: display_header($nameTools, 'Doc'); |
|
581 | - Display :: display_error_message(get_lang('Impossible')); |
|
582 | - Display :: display_footer(); |
|
583 | - } |
|
572 | + header('Location: document.php?'.api_get_cidreq().'&id='.$folder_id.$selectcat.$certificate_condition); |
|
573 | + exit(); |
|
574 | + } else { |
|
575 | + Display :: display_header($nameTools, 'Doc'); |
|
576 | + Display :: display_error_message(get_lang('Impossible')); |
|
577 | + Display :: display_footer(); |
|
578 | + } |
|
579 | + } else { |
|
580 | + Display :: display_header($nameTools, 'Doc'); |
|
581 | + Display :: display_error_message(get_lang('Impossible')); |
|
582 | + Display :: display_footer(); |
|
583 | + } |
|
584 | 584 | } else { |
585 | - // Copied from document.php |
|
586 | - $dir_array = explode('/', $dir); |
|
587 | - $array_len = count($dir_array); |
|
585 | + // Copied from document.php |
|
586 | + $dir_array = explode('/', $dir); |
|
587 | + $array_len = count($dir_array); |
|
588 | 588 | |
589 | - // Breadcrumb for the current directory root path |
|
589 | + // Breadcrumb for the current directory root path |
|
590 | 590 | if (!empty($document_data)) { |
591 | 591 | if (empty($document_data['parents'])) { |
592 | 592 | $interbreadcrumb[] = array( |
@@ -603,11 +603,11 @@ discard block |
||
603 | 603 | } |
604 | 604 | } |
605 | 605 | |
606 | - Display :: display_header($nameTools, "Doc"); |
|
607 | - // actions |
|
606 | + Display :: display_header($nameTools, "Doc"); |
|
607 | + // actions |
|
608 | 608 | |
609 | - // link back to the documents overview |
|
610 | - if ($is_certificate_mode) { |
|
609 | + // link back to the documents overview |
|
610 | + if ($is_certificate_mode) { |
|
611 | 611 | $actionsLeft = '<a href="document.php?certificate=true&id='.$folder_id.'&selectcat=' . Security::remove_XSS($_GET['selectcat']).'">'. |
612 | 612 | Display::return_icon('back.png',get_lang('Back').' '.get_lang('To').' '.get_lang('CertificateOverview'),'',ICON_SIZE_MEDIUM).'</a>'; |
613 | 613 | $actionsLeft .= '<a id="hide_bar_template" href="#" role="button">'. |
@@ -622,19 +622,19 @@ discard block |
||
622 | 622 | |
623 | 623 | echo $toolbar = Display::toolbarAction('actions-documents', array($actionsLeft)); |
624 | 624 | |
625 | - if ($is_certificate_mode) { |
|
625 | + if ($is_certificate_mode) { |
|
626 | 626 | $all_information_by_create_certificate = DocumentManager::get_all_info_to_certificate( |
627 | 627 | api_get_user_id(), |
628 | 628 | api_get_course_id() |
629 | 629 | ); |
630 | 630 | |
631 | - $str_info = ''; |
|
632 | - foreach ($all_information_by_create_certificate[0] as $info_value) { |
|
633 | - $str_info.=$info_value.'<br/>'; |
|
634 | - } |
|
635 | - $create_certificate = get_lang('CreateCertificateWithTags'); |
|
636 | - Display::display_normal_message($create_certificate.': <br /><br/>'.$str_info,false); |
|
637 | - } |
|
631 | + $str_info = ''; |
|
632 | + foreach ($all_information_by_create_certificate[0] as $info_value) { |
|
633 | + $str_info.=$info_value.'<br/>'; |
|
634 | + } |
|
635 | + $create_certificate = get_lang('CreateCertificateWithTags'); |
|
636 | + Display::display_normal_message($create_certificate.': <br /><br/>'.$str_info,false); |
|
637 | + } |
|
638 | 638 | |
639 | 639 | // HTML-editor |
640 | 640 | echo '<div class="page-create"> |
@@ -650,5 +650,5 @@ discard block |
||
650 | 650 | '.$form->returnForm().' |
651 | 651 | </div> |
652 | 652 | </div></div>'; |
653 | - Display :: display_footer(); |
|
653 | + Display :: display_footer(); |
|
654 | 654 | } |