@@ -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 |
@@ -333,7 +332,7 @@ discard block |
||
333 | 332 | // Storing the attachments if any |
334 | 333 | if ($result) { |
335 | 334 | $sql = 'INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size, blog_id,comment_id) '. |
336 | - "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' )"; |
|
335 | + "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 | 336 | Database::query($sql); |
338 | 337 | $id = Database::insert_id(); |
339 | 338 | if ($id) { |
@@ -470,7 +469,7 @@ discard block |
||
470 | 469 | // Storing the attachments if any |
471 | 470 | if ($result) { |
472 | 471 | $sql='INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size,blog_id,comment_id) '. |
473 | - "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."' )"; |
|
472 | + "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."' )"; |
|
474 | 473 | Database::query($sql); |
475 | 474 | |
476 | 475 | $id = Database::insert_id(); |
@@ -1389,10 +1388,10 @@ discard block |
||
1389 | 1388 | echo '<span class="blogpost_title">' . get_lang('TaskList') . '</span><br />'; |
1390 | 1389 | echo "<table class=\"data_table\">"; |
1391 | 1390 | echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">", |
1392 | - "<th width='240'><b>",get_lang('Title'),"</b></th>", |
|
1393 | - "<th><b>",get_lang('Description'),"</b></th>", |
|
1394 | - "<th><b>",get_lang('Color'),"</b></th>", |
|
1395 | - "<th width='50'><b>",get_lang('Modify'),"</b></th>", |
|
1391 | + "<th width='240'><b>",get_lang('Title'),"</b></th>", |
|
1392 | + "<th><b>",get_lang('Description'),"</b></th>", |
|
1393 | + "<th><b>",get_lang('Color'),"</b></th>", |
|
1394 | + "<th width='50'><b>",get_lang('Modify'),"</b></th>", |
|
1396 | 1395 | "</tr>"; |
1397 | 1396 | |
1398 | 1397 | |
@@ -1424,14 +1423,14 @@ discard block |
||
1424 | 1423 | echo '<td width="50">'; |
1425 | 1424 | echo '<a href="'.api_get_self().'?action=manage_tasks&blog_id='.$task['blog_id'].'&do=edit&task_id='.$task['task_id'].'">'; |
1426 | 1425 | echo Display::return_icon('edit.png', get_lang('EditTask')); |
1427 | - echo "</a>"; |
|
1428 | - echo '<a href="'.$delete_link.'"'; |
|
1429 | - echo $delete_confirm; |
|
1430 | - echo '>'; |
|
1426 | + echo "</a>"; |
|
1427 | + echo '<a href="'.$delete_link.'"'; |
|
1428 | + echo $delete_confirm; |
|
1429 | + echo '>'; |
|
1431 | 1430 | echo Display::return_icon($delete_icon, $delete_title); |
1432 | - echo "</a>"; |
|
1433 | - echo '</td>'; |
|
1434 | - echo '</tr>'; |
|
1431 | + echo "</a>"; |
|
1432 | + echo '</td>'; |
|
1433 | + echo '</tr>'; |
|
1435 | 1434 | } |
1436 | 1435 | echo "</table>"; |
1437 | 1436 | } |
@@ -1455,11 +1454,11 @@ discard block |
||
1455 | 1454 | echo '<span class="blogpost_title">' . get_lang('AssignedTasks') . '</span><br />'; |
1456 | 1455 | echo "<table class=\"data_table\">"; |
1457 | 1456 | echo "<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">", |
1458 | - "<th width='240'><b>",get_lang('Member'),"</b></th>", |
|
1459 | - "<th><b>",get_lang('Task'),"</b></th>", |
|
1460 | - "<th><b>",get_lang('Description'),"</b></th>", |
|
1461 | - "<th><b>",get_lang('TargetDate'),"</b></th>", |
|
1462 | - "<th width='50'><b>",get_lang('Modify'),"</b></th>", |
|
1457 | + "<th width='240'><b>",get_lang('Member'),"</b></th>", |
|
1458 | + "<th><b>",get_lang('Task'),"</b></th>", |
|
1459 | + "<th><b>",get_lang('Description'),"</b></th>", |
|
1460 | + "<th><b>",get_lang('TargetDate'),"</b></th>", |
|
1461 | + "<th width='50'><b>",get_lang('Modify'),"</b></th>", |
|
1463 | 1462 | "</tr>"; |
1464 | 1463 | |
1465 | 1464 | $course_id = api_get_course_int_id(); |
@@ -2307,7 +2306,7 @@ discard block |
||
2307 | 2306 | * @param Integer $year: the 4-digit year indication e.g. 2005 |
2308 | 2307 | * |
2309 | 2308 | * @return html code |
2310 | - */ |
|
2309 | + */ |
|
2311 | 2310 | public static function display_minimonthcalendar($month, $year, $blog_id) |
2312 | 2311 | { |
2313 | 2312 | // Init |
@@ -2600,34 +2599,34 @@ discard block |
||
2600 | 2599 | */ |
2601 | 2600 | function get_blog_attachment($blog_id, $post_id=null,$comment_id=null) |
2602 | 2601 | { |
2603 | - $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
2604 | - |
|
2605 | - $blog_id = intval($blog_id); |
|
2606 | - $comment_id = intval($comment_id); |
|
2607 | - $post_id = intval($post_id); |
|
2608 | - $row=array(); |
|
2609 | - $where=''; |
|
2610 | - if (!empty ($post_id) && is_numeric($post_id)) { |
|
2611 | - $where.=' AND post_id ="'.$post_id.'" '; |
|
2612 | - } |
|
2613 | - |
|
2614 | - if (!empty ($comment_id) && is_numeric($comment_id)) { |
|
2615 | - if (!empty ($post_id)) { |
|
2616 | - $where.= ' AND '; |
|
2617 | - } |
|
2618 | - $where.=' comment_id ="'.$comment_id.'" '; |
|
2619 | - } |
|
2602 | + $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
2603 | + |
|
2604 | + $blog_id = intval($blog_id); |
|
2605 | + $comment_id = intval($comment_id); |
|
2606 | + $post_id = intval($post_id); |
|
2607 | + $row=array(); |
|
2608 | + $where=''; |
|
2609 | + if (!empty ($post_id) && is_numeric($post_id)) { |
|
2610 | + $where.=' AND post_id ="'.$post_id.'" '; |
|
2611 | + } |
|
2612 | + |
|
2613 | + if (!empty ($comment_id) && is_numeric($comment_id)) { |
|
2614 | + if (!empty ($post_id)) { |
|
2615 | + $where.= ' AND '; |
|
2616 | + } |
|
2617 | + $where.=' comment_id ="'.$comment_id.'" '; |
|
2618 | + } |
|
2620 | 2619 | |
2621 | 2620 | $course_id = api_get_course_int_id(); |
2622 | 2621 | |
2623 | - $sql = 'SELECT path, filename, comment FROM '. $blog_table_attachment.' |
|
2622 | + $sql = 'SELECT path, filename, comment FROM '. $blog_table_attachment.' |
|
2624 | 2623 | WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; |
2625 | 2624 | |
2626 | - $result=Database::query($sql); |
|
2627 | - if (Database::num_rows($result)!=0) { |
|
2628 | - $row=Database::fetch_array($result); |
|
2629 | - } |
|
2630 | - return $row; |
|
2625 | + $result=Database::query($sql); |
|
2626 | + if (Database::num_rows($result)!=0) { |
|
2627 | + $row=Database::fetch_array($result); |
|
2628 | + } |
|
2629 | + return $row; |
|
2631 | 2630 | } |
2632 | 2631 | |
2633 | 2632 | /** |
@@ -2644,16 +2643,16 @@ discard block |
||
2644 | 2643 | |
2645 | 2644 | function delete_all_blog_attachment($blog_id,$post_id=null,$comment_id=null) |
2646 | 2645 | { |
2647 | - $_course = api_get_course_info(); |
|
2648 | - $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
2649 | - $blog_id = intval($blog_id); |
|
2650 | - $comment_id = intval($comment_id); |
|
2651 | - $post_id = intval($post_id); |
|
2646 | + $_course = api_get_course_info(); |
|
2647 | + $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT); |
|
2648 | + $blog_id = intval($blog_id); |
|
2649 | + $comment_id = intval($comment_id); |
|
2650 | + $post_id = intval($post_id); |
|
2652 | 2651 | |
2653 | 2652 | $course_id = api_get_course_int_id(); |
2654 | - $where = null; |
|
2653 | + $where = null; |
|
2655 | 2654 | |
2656 | - // delete files in DB |
|
2655 | + // delete files in DB |
|
2657 | 2656 | if (!empty ($post_id) && is_numeric($post_id)) { |
2658 | 2657 | $where .= ' AND post_id ="'.$post_id.'" '; |
2659 | 2658 | } |
@@ -2665,25 +2664,25 @@ discard block |
||
2665 | 2664 | $where .= ' comment_id ="'.$comment_id.'" '; |
2666 | 2665 | } |
2667 | 2666 | |
2668 | - // delete all files in directory |
|
2669 | - $courseDir = $_course['path'].'/upload/blog'; |
|
2670 | - $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
2671 | - $updir = $sys_course_path.$courseDir; |
|
2667 | + // delete all files in directory |
|
2668 | + $courseDir = $_course['path'].'/upload/blog'; |
|
2669 | + $sys_course_path = api_get_path(SYS_COURSE_PATH); |
|
2670 | + $updir = $sys_course_path.$courseDir; |
|
2672 | 2671 | |
2673 | - $sql = 'SELECT path FROM '.$blog_table_attachment.' |
|
2672 | + $sql = 'SELECT path FROM '.$blog_table_attachment.' |
|
2674 | 2673 | WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; |
2675 | - $result=Database::query($sql); |
|
2676 | - |
|
2677 | - while ($row=Database::fetch_row($result)) { |
|
2678 | - $file=$updir.'/'.$row[0]; |
|
2679 | - if (Security::check_abs_path($file,$updir) ) |
|
2680 | - { |
|
2681 | - @ unlink($file); |
|
2682 | - } |
|
2683 | - } |
|
2684 | - $sql = 'DELETE FROM '. $blog_table_attachment.' |
|
2674 | + $result=Database::query($sql); |
|
2675 | + |
|
2676 | + while ($row=Database::fetch_row($result)) { |
|
2677 | + $file=$updir.'/'.$row[0]; |
|
2678 | + if (Security::check_abs_path($file,$updir) ) |
|
2679 | + { |
|
2680 | + @ unlink($file); |
|
2681 | + } |
|
2682 | + } |
|
2683 | + $sql = 'DELETE FROM '. $blog_table_attachment.' |
|
2685 | 2684 | WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; |
2686 | - Database::query($sql); |
|
2685 | + Database::query($sql); |
|
2687 | 2686 | } |
2688 | 2687 | |
2689 | 2688 | /** |
@@ -2693,12 +2692,12 @@ discard block |
||
2693 | 2692 | */ |
2694 | 2693 | function get_blog_post_from_user($course_code, $user_id) |
2695 | 2694 | { |
2696 | - $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
2697 | - $tbl_blog_post = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
2698 | - $course_info = api_get_course_info($course_code); |
|
2699 | - $course_id = $course_info['real_id']; |
|
2695 | + $tbl_blogs = Database::get_course_table(TABLE_BLOGS); |
|
2696 | + $tbl_blog_post = Database::get_course_table(TABLE_BLOGS_POSTS); |
|
2697 | + $course_info = api_get_course_info($course_code); |
|
2698 | + $course_id = $course_info['real_id']; |
|
2700 | 2699 | |
2701 | - $sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation |
|
2700 | + $sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation |
|
2702 | 2701 | FROM $tbl_blogs blog |
2703 | 2702 | INNER JOIN $tbl_blog_post post |
2704 | 2703 | ON (blog.blog_id = post.blog_id) |
@@ -2707,19 +2706,19 @@ discard block |
||
2707 | 2706 | post.c_id = $course_id AND |
2708 | 2707 | author_id = $user_id AND visibility = 1 |
2709 | 2708 | ORDER BY post.date_creation DESC "; |
2710 | - $result = Database::query($sql); |
|
2711 | - $return_data = ''; |
|
2712 | - |
|
2713 | - if (Database::num_rows($result)!=0) { |
|
2714 | - while ($row=Database::fetch_array($result)) { |
|
2715 | - $return_data.= '<div class="clear"></div><br />'; |
|
2716 | - $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>'; |
|
2717 | - $return_data.= '<br / >'; |
|
2718 | - $return_data.= $row['full_text']; |
|
2719 | - $return_data.= '<br /><br />'; |
|
2720 | - } |
|
2721 | - } |
|
2722 | - return $return_data; |
|
2709 | + $result = Database::query($sql); |
|
2710 | + $return_data = ''; |
|
2711 | + |
|
2712 | + if (Database::num_rows($result)!=0) { |
|
2713 | + while ($row=Database::fetch_array($result)) { |
|
2714 | + $return_data.= '<div class="clear"></div><br />'; |
|
2715 | + $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>'; |
|
2716 | + $return_data.= '<br / >'; |
|
2717 | + $return_data.= $row['full_text']; |
|
2718 | + $return_data.= '<br /><br />'; |
|
2719 | + } |
|
2720 | + } |
|
2721 | + return $return_data; |
|
2723 | 2722 | } |
2724 | 2723 | |
2725 | 2724 | /** |
@@ -2736,7 +2735,7 @@ discard block |
||
2736 | 2735 | $course_info = api_get_course_info($course_code); |
2737 | 2736 | $course_id = $course_info['real_id']; |
2738 | 2737 | |
2739 | - $sql = "SELECT DISTINCT blog.blog_id, comment_id, title, comment, comment.date_creation |
|
2738 | + $sql = "SELECT DISTINCT blog.blog_id, comment_id, title, comment, comment.date_creation |
|
2740 | 2739 | FROM $tbl_blogs blog INNER JOIN $tbl_blog_comment comment |
2741 | 2740 | ON (blog.blog_id = comment.blog_id) |
2742 | 2741 | WHERE blog.c_id = $course_id AND |
@@ -2744,18 +2743,18 @@ discard block |
||
2744 | 2743 | author_id = $user_id AND |
2745 | 2744 | visibility = 1 |
2746 | 2745 | ORDER BY blog_name"; |
2747 | - $result = Database::query($sql); |
|
2748 | - $return_data = ''; |
|
2749 | - if (Database::num_rows($result)!=0) { |
|
2750 | - while ($row=Database::fetch_array($result)) { |
|
2751 | - $return_data.= '<div class="clear"></div><br />'; |
|
2752 | - $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>'; |
|
2753 | - $return_data.= '<br / >'; |
|
2754 | - //$return_data.= '<strong>'.$row['title'].'</strong>'; echo '<br>';*/ |
|
2755 | - $return_data.= $row['comment']; |
|
2756 | - $return_data.= '<br />'; |
|
2757 | - } |
|
2758 | - } |
|
2759 | - return $return_data; |
|
2746 | + $result = Database::query($sql); |
|
2747 | + $return_data = ''; |
|
2748 | + if (Database::num_rows($result)!=0) { |
|
2749 | + while ($row=Database::fetch_array($result)) { |
|
2750 | + $return_data.= '<div class="clear"></div><br />'; |
|
2751 | + $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>'; |
|
2752 | + $return_data.= '<br / >'; |
|
2753 | + //$return_data.= '<strong>'.$row['title'].'</strong>'; echo '<br>';*/ |
|
2754 | + $return_data.= $row['comment']; |
|
2755 | + $return_data.= '<br />'; |
|
2756 | + } |
|
2757 | + } |
|
2758 | + return $return_data; |
|
2760 | 2759 | } |
2761 | 2760 |
@@ -51,15 +51,15 @@ discard block |
||
51 | 51 | /** |
52 | 52 | * Displays the title + grid |
53 | 53 | */ |
54 | - public function display() |
|
54 | + public function display() |
|
55 | 55 | { |
56 | - // action links |
|
57 | - echo '<div class="actions" style="margin-bottom:20px">'; |
|
56 | + // action links |
|
57 | + echo '<div class="actions" style="margin-bottom:20px">'; |
|
58 | 58 | echo '<a href="grade_models.php">'.Display::return_icon('back.png',get_lang('Back'),'', ICON_SIZE_MEDIUM).'</a>'; |
59 | - echo '<a href="'.api_get_self().'?action=add">'.Display::return_icon('add.png', get_lang('Add'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
60 | - echo '</div>'; |
|
59 | + echo '<a href="'.api_get_self().'?action=add">'.Display::return_icon('add.png', get_lang('Add'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
60 | + echo '</div>'; |
|
61 | 61 | echo Display::grid_html('grade_model'); |
62 | - } |
|
62 | + } |
|
63 | 63 | |
64 | 64 | /** |
65 | 65 | * Returns a Form validator Obj |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | } |
118 | 118 | |
119 | 119 | $form->addElement('hidden', 'maxvalue', '100'); |
120 | - $form->addElement('hidden', 'minvalue', '0'); |
|
120 | + $form->addElement('hidden', 'minvalue', '0'); |
|
121 | 121 | $renderer = & $form->defaultRenderer(); |
122 | 122 | |
123 | 123 | $component_array = array(); |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | // Setting the rules |
193 | 193 | $form->addRule('name', get_lang('ThisFieldIsRequired'), 'required'); |
194 | 194 | |
195 | - return $form; |
|
195 | + return $form; |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | /** |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | */ |
256 | 256 | public function delete($id) |
257 | 257 | { |
258 | - parent::delete($id); |
|
258 | + parent::delete($id); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | /** |
@@ -309,11 +309,11 @@ discard block |
||
309 | 309 | /** |
310 | 310 | * GradeModelComponents constructor. |
311 | 311 | */ |
312 | - public function __construct() |
|
312 | + public function __construct() |
|
313 | 313 | { |
314 | 314 | parent::__construct(); |
315 | 315 | $this->table = Database::get_main_table(TABLE_GRADE_MODEL_COMPONENTS); |
316 | - } |
|
316 | + } |
|
317 | 317 | |
318 | 318 | /** |
319 | 319 | * @param array $params |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | */ |
323 | 323 | public function save($params, $show_query = false) |
324 | 324 | { |
325 | - $id = parent::save($params, $show_query); |
|
325 | + $id = parent::save($params, $show_query); |
|
326 | 326 | |
327 | 327 | return $id; |
328 | 328 | } |
@@ -307,8 +307,8 @@ discard block |
||
307 | 307 | } |
308 | 308 | } |
309 | 309 | |
310 | - return $block_data; |
|
311 | - } |
|
310 | + return $block_data; |
|
311 | + } |
|
312 | 312 | |
313 | 313 | /** |
314 | 314 | * get data about enabled dashboard block (stored insise block table) |
@@ -491,42 +491,42 @@ discard block |
||
491 | 491 | return $data; |
492 | 492 | } |
493 | 493 | |
494 | - /** |
|
495 | - * This function update extra user blocks data after closing a dashboard block |
|
496 | - * @param int User id |
|
497 | - * @param string plugin path |
|
498 | - * @param integer $user_id |
|
499 | - * @return bool |
|
500 | - */ |
|
501 | - public static function close_user_block($user_id, $path) |
|
494 | + /** |
|
495 | + * This function update extra user blocks data after closing a dashboard block |
|
496 | + * @param int User id |
|
497 | + * @param string plugin path |
|
498 | + * @param integer $user_id |
|
499 | + * @return bool |
|
500 | + */ |
|
501 | + public static function close_user_block($user_id, $path) |
|
502 | 502 | { |
503 | - $enabled_dashboard_blocks = self::get_enabled_dashboard_blocks($path); |
|
504 | - $user_block_data = self::get_user_block_data($user_id); |
|
505 | - |
|
506 | - foreach ($enabled_dashboard_blocks as $enabled_block) { |
|
507 | - unset($user_block_data[$enabled_block['id']]); |
|
508 | - } |
|
509 | - |
|
510 | - // get columns and blocks id for updating extra user data |
|
511 | - $columns = array(); |
|
512 | - $user_blocks_id = array(); |
|
513 | - foreach ($user_block_data as $data) { |
|
514 | - $user_blocks_id[$data['block_id']] = true; |
|
515 | - $columns[$data['block_id']] = $data['column']; |
|
516 | - } |
|
517 | - |
|
518 | - // update extra user blocks data |
|
519 | - $upd_extra_field = self::store_user_blocks($user_id, $user_blocks_id, $columns); |
|
520 | - |
|
521 | - return $upd_extra_field; |
|
522 | - } |
|
523 | - |
|
524 | - /** |
|
525 | - * get links for styles from dashboard plugins |
|
526 | - * @return string links |
|
527 | - */ |
|
528 | - public static function get_links_for_styles_from_dashboard_plugins() { |
|
529 | - |
|
530 | - return '<link rel="stylesheet" href="'.api_get_path(WEB_PLUGIN_PATH).'dashboard/css/default.css" type="text/css" />'.PHP_EOL; |
|
531 | - } |
|
503 | + $enabled_dashboard_blocks = self::get_enabled_dashboard_blocks($path); |
|
504 | + $user_block_data = self::get_user_block_data($user_id); |
|
505 | + |
|
506 | + foreach ($enabled_dashboard_blocks as $enabled_block) { |
|
507 | + unset($user_block_data[$enabled_block['id']]); |
|
508 | + } |
|
509 | + |
|
510 | + // get columns and blocks id for updating extra user data |
|
511 | + $columns = array(); |
|
512 | + $user_blocks_id = array(); |
|
513 | + foreach ($user_block_data as $data) { |
|
514 | + $user_blocks_id[$data['block_id']] = true; |
|
515 | + $columns[$data['block_id']] = $data['column']; |
|
516 | + } |
|
517 | + |
|
518 | + // update extra user blocks data |
|
519 | + $upd_extra_field = self::store_user_blocks($user_id, $user_blocks_id, $columns); |
|
520 | + |
|
521 | + return $upd_extra_field; |
|
522 | + } |
|
523 | + |
|
524 | + /** |
|
525 | + * get links for styles from dashboard plugins |
|
526 | + * @return string links |
|
527 | + */ |
|
528 | + public static function get_links_for_styles_from_dashboard_plugins() { |
|
529 | + |
|
530 | + return '<link rel="stylesheet" href="'.api_get_path(WEB_PLUGIN_PATH).'dashboard/css/default.css" type="text/css" />'.PHP_EOL; |
|
531 | + } |
|
532 | 532 | } |
@@ -10,12 +10,12 @@ discard block |
||
10 | 10 | CONST VISIBLE_STUDENT = 2; |
11 | 11 | CONST VISIBLE_TEACHER = 3; |
12 | 12 | |
13 | - /** |
|
14 | - * Displays all announcements |
|
15 | - * @param int $visible VISIBLE_GUEST, VISIBLE_STUDENT or VISIBLE_TEACHER |
|
16 | - * @param int $id The identifier of the announcement to display |
|
17 | - */ |
|
18 | - public static function display_announcements($visible, $id = -1) |
|
13 | + /** |
|
14 | + * Displays all announcements |
|
15 | + * @param int $visible VISIBLE_GUEST, VISIBLE_STUDENT or VISIBLE_TEACHER |
|
16 | + * @param int $id The identifier of the announcement to display |
|
17 | + */ |
|
18 | + public static function display_announcements($visible, $id = -1) |
|
19 | 19 | { |
20 | 20 | $user_selected_language = api_get_interface_language(); |
21 | 21 | $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
@@ -424,10 +424,10 @@ discard block |
||
424 | 424 | } |
425 | 425 | |
426 | 426 | /** |
427 | - * Makes the announcement id visible only for groups in groups_array |
|
428 | - * @param int $announcement_id |
|
429 | - * @param array $group_array array of group id |
|
430 | - **/ |
|
427 | + * Makes the announcement id visible only for groups in groups_array |
|
428 | + * @param int $announcement_id |
|
429 | + * @param array $group_array array of group id |
|
430 | + **/ |
|
431 | 431 | public static function announcement_for_groups($announcement_id, $group_array) |
432 | 432 | { |
433 | 433 | $tbl_announcement_group = Database:: get_main_table( |
@@ -460,10 +460,10 @@ discard block |
||
460 | 460 | } |
461 | 461 | |
462 | 462 | /** |
463 | - * Gets the groups of this announce |
|
464 | - * @param int announcement id |
|
465 | - * @return array array of group id |
|
466 | - **/ |
|
463 | + * Gets the groups of this announce |
|
464 | + * @param int announcement id |
|
465 | + * @return array array of group id |
|
466 | + **/ |
|
467 | 467 | public static function get_announcement_groups($announcement_id) |
468 | 468 | { |
469 | 469 | $tbl_announcement_group = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS_GROUPS); |
@@ -483,15 +483,15 @@ discard block |
||
483 | 483 | return $groups; |
484 | 484 | } |
485 | 485 | |
486 | - /** |
|
487 | - * Updates an announcement to the database |
|
488 | - * @param integer $id : id of the announcement |
|
489 | - * @param string $title : title of the announcement |
|
490 | - * @param string $content : content of the announcement |
|
491 | - * @param array $date_start: start date of announcement (0 => day ; 1 => month ; 2 => year ; 3 => hour ; 4 => minute) |
|
492 | - * @param array $date_end : end date of announcement (0 => day ; 1 => month ; 2 => year ; 3 => hour ; 4 => minute) |
|
493 | - * @return bool True on success, false on failure |
|
494 | - */ |
|
486 | + /** |
|
487 | + * Updates an announcement to the database |
|
488 | + * @param integer $id : id of the announcement |
|
489 | + * @param string $title : title of the announcement |
|
490 | + * @param string $content : content of the announcement |
|
491 | + * @param array $date_start: start date of announcement (0 => day ; 1 => month ; 2 => year ; 3 => hour ; 4 => minute) |
|
492 | + * @param array $date_end : end date of announcement (0 => day ; 1 => month ; 2 => year ; 3 => hour ; 4 => minute) |
|
493 | + * @return bool True on success, false on failure |
|
494 | + */ |
|
495 | 495 | public static function update_announcement( |
496 | 496 | $id, |
497 | 497 | $title, |
@@ -525,26 +525,26 @@ discard block |
||
525 | 525 | return false; |
526 | 526 | } |
527 | 527 | |
528 | - if (($date_end_to_compare[1] || |
|
528 | + if (($date_end_to_compare[1] || |
|
529 | 529 | $date_end_to_compare[2] || |
530 | 530 | $date_end_to_compare[0]) && |
531 | 531 | !checkdate($date_end_to_compare[1], $date_end_to_compare[2], $date_end_to_compare[0]) |
532 | 532 | ) { |
533 | - Display :: display_normal_message(get_lang('InvalidEndDate')); |
|
534 | - return false; |
|
535 | - } |
|
533 | + Display :: display_normal_message(get_lang('InvalidEndDate')); |
|
534 | + return false; |
|
535 | + } |
|
536 | 536 | |
537 | - if (strlen(trim($title)) == 0) { |
|
538 | - Display::display_normal_message(get_lang('InvalidTitle')); |
|
539 | - return false; |
|
540 | - } |
|
537 | + if (strlen(trim($title)) == 0) { |
|
538 | + Display::display_normal_message(get_lang('InvalidTitle')); |
|
539 | + return false; |
|
540 | + } |
|
541 | 541 | |
542 | - $start = api_get_utc_datetime($date_start); |
|
542 | + $start = api_get_utc_datetime($date_start); |
|
543 | 543 | $end = api_get_utc_datetime($date_end); |
544 | 544 | |
545 | - //Fixing urls that are sent by email |
|
546 | - //$content = str_replace('src=\"/home/', 'src=\"'.api_get_path(WEB_PATH).'home/', $content); |
|
547 | - //$content = str_replace('file=/home/', 'file='.api_get_path(WEB_PATH).'home/', $content); |
|
545 | + //Fixing urls that are sent by email |
|
546 | + //$content = str_replace('src=\"/home/', 'src=\"'.api_get_path(WEB_PATH).'home/', $content); |
|
547 | + //$content = str_replace('file=/home/', 'file='.api_get_path(WEB_PATH).'home/', $content); |
|
548 | 548 | $content = str_replace('src=\"'.api_get_path(REL_HOME_PATH), 'src=\"'.api_get_path(WEB_PATH).api_get_path(REL_HOME_PATH), $content); |
549 | 549 | $content = str_replace('file='.api_get_path(REL_HOME_PATH), 'file='.api_get_path(WEB_PATH).api_get_path(REL_HOME_PATH), $content); |
550 | 550 | |
@@ -594,81 +594,81 @@ discard block |
||
594 | 594 | $em->merge($announcement); |
595 | 595 | $em->flush(); |
596 | 596 | |
597 | - return true; |
|
598 | - } |
|
597 | + return true; |
|
598 | + } |
|
599 | 599 | |
600 | - /** |
|
601 | - * Deletes an announcement |
|
602 | - * @param int $id The identifier of the announcement that should be |
|
603 | - * @return bool True on success, false on failure |
|
604 | - */ |
|
605 | - public static function delete_announcement($id) |
|
600 | + /** |
|
601 | + * Deletes an announcement |
|
602 | + * @param int $id The identifier of the announcement that should be |
|
603 | + * @return bool True on success, false on failure |
|
604 | + */ |
|
605 | + public static function delete_announcement($id) |
|
606 | 606 | { |
607 | - $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
608 | - $id = intval($id); |
|
609 | - $sql = "DELETE FROM ".$db_table." WHERE id =".$id; |
|
610 | - $res = Database::query($sql); |
|
611 | - if ($res === false) { |
|
612 | - |
|
613 | - return false; |
|
614 | - } |
|
615 | - return true; |
|
616 | - } |
|
617 | - |
|
618 | - /** |
|
619 | - * Gets an announcement |
|
620 | - * @param int $id The identifier of the announcement that should be |
|
621 | - * @return object Object of class StdClass or the required class, containing the query result row |
|
622 | - */ |
|
623 | - public static function get_announcement($id) |
|
607 | + $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
608 | + $id = intval($id); |
|
609 | + $sql = "DELETE FROM ".$db_table." WHERE id =".$id; |
|
610 | + $res = Database::query($sql); |
|
611 | + if ($res === false) { |
|
612 | + |
|
613 | + return false; |
|
614 | + } |
|
615 | + return true; |
|
616 | + } |
|
617 | + |
|
618 | + /** |
|
619 | + * Gets an announcement |
|
620 | + * @param int $id The identifier of the announcement that should be |
|
621 | + * @return object Object of class StdClass or the required class, containing the query result row |
|
622 | + */ |
|
623 | + public static function get_announcement($id) |
|
624 | 624 | { |
625 | - $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
626 | - $id = intval($id); |
|
627 | - $sql = "SELECT * FROM ".$db_table." WHERE id = ".$id; |
|
628 | - $announcement = Database::fetch_object(Database::query($sql)); |
|
629 | - |
|
630 | - return $announcement; |
|
631 | - } |
|
632 | - |
|
633 | - /** |
|
634 | - * Change the visibility of an announcement |
|
635 | - * @param int $announcement_id |
|
636 | - * @param int $user For who should the visibility be changed |
|
625 | + $db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
626 | + $id = intval($id); |
|
627 | + $sql = "SELECT * FROM ".$db_table." WHERE id = ".$id; |
|
628 | + $announcement = Database::fetch_object(Database::query($sql)); |
|
629 | + |
|
630 | + return $announcement; |
|
631 | + } |
|
632 | + |
|
633 | + /** |
|
634 | + * Change the visibility of an announcement |
|
635 | + * @param int $announcement_id |
|
636 | + * @param int $user For who should the visibility be changed |
|
637 | 637 | * (possible values are VISIBLE_TEACHER, VISIBLE_STUDENT, VISIBLE_GUEST) |
638 | - * @return bool True on success, false on failure |
|
639 | - */ |
|
640 | - public static function set_visibility($announcement_id, $user, $visible) |
|
638 | + * @return bool True on success, false on failure |
|
639 | + */ |
|
640 | + public static function set_visibility($announcement_id, $user, $visible) |
|
641 | 641 | { |
642 | - $db_table = Database::get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
643 | - $visible = intval($visible); |
|
644 | - $announcement_id = intval($announcement_id); |
|
642 | + $db_table = Database::get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS); |
|
643 | + $visible = intval($visible); |
|
644 | + $announcement_id = intval($announcement_id); |
|
645 | 645 | |
646 | 646 | if (!in_array($user, array(self::VISIBLE_GUEST, self::VISIBLE_STUDENT, self::VISIBLE_TEACHER))) { |
647 | 647 | return false; |
648 | 648 | } |
649 | 649 | |
650 | - $field = ($user == self::VISIBLE_TEACHER ? 'visible_teacher' : ($user == self::VISIBLE_STUDENT ? 'visible_student' : 'visible_guest')); |
|
650 | + $field = ($user == self::VISIBLE_TEACHER ? 'visible_teacher' : ($user == self::VISIBLE_STUDENT ? 'visible_student' : 'visible_guest')); |
|
651 | 651 | |
652 | - $sql = "UPDATE ".$db_table." SET ".$field." = '".$visible."' |
|
652 | + $sql = "UPDATE ".$db_table." SET ".$field." = '".$visible."' |
|
653 | 653 | WHERE id='".$announcement_id."'"; |
654 | - $res = Database::query($sql); |
|
655 | - |
|
656 | - if ($res === false) { |
|
657 | - return false; |
|
658 | - } |
|
659 | - |
|
660 | - return true; |
|
661 | - } |
|
662 | - |
|
663 | - /** |
|
664 | - * Send a system announcement by e-mail to all teachers/students depending on parameters |
|
665 | - * @param string Title |
|
666 | - * @param string Content |
|
667 | - * @param int Whether to send to all teachers (1) or not (0) |
|
668 | - * @param int Whether to send to all students (1) or not (0) |
|
669 | - * @param string Language (optional, considered for all languages if left empty) |
|
654 | + $res = Database::query($sql); |
|
655 | + |
|
656 | + if ($res === false) { |
|
657 | + return false; |
|
658 | + } |
|
659 | + |
|
660 | + return true; |
|
661 | + } |
|
662 | + |
|
663 | + /** |
|
664 | + * Send a system announcement by e-mail to all teachers/students depending on parameters |
|
665 | + * @param string Title |
|
666 | + * @param string Content |
|
667 | + * @param int Whether to send to all teachers (1) or not (0) |
|
668 | + * @param int Whether to send to all students (1) or not (0) |
|
669 | + * @param string Language (optional, considered for all languages if left empty) |
|
670 | 670 | * @return bool True if the message was sent or there was no destination matching. False on database or e-mail sending error. |
671 | - */ |
|
671 | + */ |
|
672 | 672 | public static function send_system_announcement_by_email( |
673 | 673 | $title, |
674 | 674 | $content, |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | $language = null, |
678 | 678 | $sendEmailTest = false |
679 | 679 | ) { |
680 | - global $charset; |
|
680 | + global $charset; |
|
681 | 681 | |
682 | 682 | $title = api_html_entity_decode(stripslashes($title), ENT_QUOTES, $charset); |
683 | 683 | $content = api_html_entity_decode(stripslashes(str_replace(array('\r\n', '\n', '\r'),'', $content)), ENT_QUOTES, $charset); |
@@ -696,22 +696,22 @@ discard block |
||
696 | 696 | } |
697 | 697 | |
698 | 698 | if ($teacher <> 0 AND $student == 0) { |
699 | - $sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE status = '1' "; |
|
700 | - } |
|
699 | + $sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE status = '1' "; |
|
700 | + } |
|
701 | 701 | |
702 | - if ($teacher == 0 AND $student <> 0) { |
|
703 | - $sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE status = '5' "; |
|
704 | - } |
|
702 | + if ($teacher == 0 AND $student <> 0) { |
|
703 | + $sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE status = '5' "; |
|
704 | + } |
|
705 | 705 | |
706 | - if ($teacher<> 0 AND $student <> 0) { |
|
707 | - $sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE 1 = 1 "; |
|
708 | - } |
|
706 | + if ($teacher<> 0 AND $student <> 0) { |
|
707 | + $sql = "SELECT DISTINCT u.user_id FROM $user_table u $url_condition WHERE 1 = 1 "; |
|
708 | + } |
|
709 | 709 | |
710 | - if (!empty($language)) { //special condition because language was already treated for SQL insert before |
|
711 | - $sql .= " AND language = '".Database::escape_string($language)."' "; |
|
712 | - } |
|
710 | + if (!empty($language)) { //special condition because language was already treated for SQL insert before |
|
711 | + $sql .= " AND language = '".Database::escape_string($language)."' "; |
|
712 | + } |
|
713 | 713 | |
714 | - if (api_is_multiple_url_enabled()) { |
|
714 | + if (api_is_multiple_url_enabled()) { |
|
715 | 715 | $sql .= " AND access_url_id = '".$current_access_url_id."' "; |
716 | 716 | } |
717 | 717 | |
@@ -721,25 +721,25 @@ discard block |
||
721 | 721 | // Expiration date |
722 | 722 | $sql .= " AND (expiration_date = '' OR expiration_date IS NULL OR expiration_date > '$now') "; |
723 | 723 | |
724 | - if ((empty($teacher) or $teacher == '0') AND (empty($student) or $student == '0')) { |
|
725 | - return true; |
|
726 | - } |
|
724 | + if ((empty($teacher) or $teacher == '0') AND (empty($student) or $student == '0')) { |
|
725 | + return true; |
|
726 | + } |
|
727 | 727 | |
728 | - $result = Database::query($sql); |
|
729 | - if ($result === false) { |
|
730 | - return false; |
|
731 | - } |
|
728 | + $result = Database::query($sql); |
|
729 | + if ($result === false) { |
|
730 | + return false; |
|
731 | + } |
|
732 | 732 | |
733 | 733 | $message_sent = false; |
734 | 734 | |
735 | - while ($row = Database::fetch_array($result,'ASSOC')) { |
|
735 | + while ($row = Database::fetch_array($result,'ASSOC')) { |
|
736 | 736 | MessageManager::send_message_simple($row['user_id'], $title, $content); |
737 | 737 | $message_sent = true; |
738 | - } |
|
739 | - return $message_sent; //true if at least one e-mail was sent |
|
740 | - } |
|
738 | + } |
|
739 | + return $message_sent; //true if at least one e-mail was sent |
|
740 | + } |
|
741 | 741 | |
742 | - /** |
|
742 | + /** |
|
743 | 743 | * Displays announcements as an slideshow |
744 | 744 | * @param int $visible VISIBLE_GUEST, VISIBLE_STUDENT or VISIBLE_TEACHER |
745 | 745 | * @param int $id The identifier of the announcement to display |
@@ -15,15 +15,15 @@ discard block |
||
15 | 15 | { |
16 | 16 | } |
17 | 17 | |
18 | - /** |
|
19 | - * Add a new Term and Condition |
|
20 | - * @param int $language language id |
|
21 | - * @param string $content content |
|
22 | - * @param int $type term and condition type (0 or 1) |
|
23 | - * @param string $changes explain changes |
|
24 | - * @return boolean success |
|
25 | - */ |
|
26 | - public static function add($language, $content, $type, $changes) |
|
18 | + /** |
|
19 | + * Add a new Term and Condition |
|
20 | + * @param int $language language id |
|
21 | + * @param string $content content |
|
22 | + * @param int $type term and condition type (0 or 1) |
|
23 | + * @param string $changes explain changes |
|
24 | + * @return boolean success |
|
25 | + */ |
|
26 | + public static function add($language, $content, $type, $changes) |
|
27 | 27 | { |
28 | 28 | $legal_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
29 | 29 | $last = self::get_last_condition($language); |
@@ -96,27 +96,27 @@ discard block |
||
96 | 96 | } |
97 | 97 | } |
98 | 98 | |
99 | - /** |
|
100 | - * Gets the data of a Term and condition by language |
|
101 | - * @param int $language language id |
|
102 | - * @return array all the info of a Term and condition |
|
103 | - */ |
|
104 | - public static function get_last_condition($language) |
|
99 | + /** |
|
100 | + * Gets the data of a Term and condition by language |
|
101 | + * @param int $language language id |
|
102 | + * @return array all the info of a Term and condition |
|
103 | + */ |
|
104 | + public static function get_last_condition($language) |
|
105 | 105 | { |
106 | - $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
|
107 | - $language= Database::escape_string($language); |
|
108 | - $sql = "SELECT * FROM $legal_conditions_table |
|
106 | + $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
|
107 | + $language= Database::escape_string($language); |
|
108 | + $sql = "SELECT * FROM $legal_conditions_table |
|
109 | 109 | WHERE language_id = '".$language."' |
110 | 110 | ORDER BY version DESC |
111 | 111 | LIMIT 1 "; |
112 | - $result = Database::query($sql); |
|
113 | - $result = Database::fetch_array($result, 'ASSOC'); |
|
112 | + $result = Database::query($sql); |
|
113 | + $result = Database::fetch_array($result, 'ASSOC'); |
|
114 | 114 | |
115 | 115 | if (isset($result['content'])) { |
116 | 116 | $result['content'] = self::replaceTags($result['content']); |
117 | 117 | } |
118 | 118 | return $result; |
119 | - } |
|
119 | + } |
|
120 | 120 | |
121 | 121 | /** |
122 | 122 | * @param string $content |
@@ -140,12 +140,12 @@ discard block |
||
140 | 140 | return $content; |
141 | 141 | } |
142 | 142 | |
143 | - /** |
|
144 | - * Gets the last version of a Term and condition by language |
|
145 | - * @param int $language language id |
|
146 | - * @return boolean | int the version or false if does not exist |
|
147 | - */ |
|
148 | - public static function get_last_version($language) |
|
143 | + /** |
|
144 | + * Gets the last version of a Term and condition by language |
|
145 | + * @param int $language language id |
|
146 | + * @return boolean | int the version or false if does not exist |
|
147 | + */ |
|
148 | + public static function get_last_version($language) |
|
149 | 149 | { |
150 | 150 | $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
151 | 151 | $language = intval($language); |
@@ -163,15 +163,15 @@ discard block |
||
163 | 163 | |
164 | 164 | return false; |
165 | 165 | } |
166 | - } |
|
166 | + } |
|
167 | 167 | |
168 | - /** |
|
169 | - * Show the last condition |
|
170 | - * @param array $term_preview with type and content i.e array('type'=>'1', 'content'=>'hola'); |
|
168 | + /** |
|
169 | + * Show the last condition |
|
170 | + * @param array $term_preview with type and content i.e array('type'=>'1', 'content'=>'hola'); |
|
171 | 171 | * |
172 | - * @return string html preview |
|
173 | - */ |
|
174 | - public static function show_last_condition($term_preview) |
|
172 | + * @return string html preview |
|
173 | + */ |
|
174 | + public static function show_last_condition($term_preview) |
|
175 | 175 | { |
176 | 176 | $preview = ''; |
177 | 177 | switch ($term_preview['type']) { |
@@ -201,37 +201,37 @@ discard block |
||
201 | 201 | default: |
202 | 202 | break; |
203 | 203 | } |
204 | - return $preview; |
|
205 | - } |
|
204 | + return $preview; |
|
205 | + } |
|
206 | 206 | |
207 | - /** |
|
208 | - * Get the terms and condition table (only for maintenance) |
|
209 | - * @param int $from |
|
210 | - * @param int $number_of_items |
|
211 | - * @param int $column |
|
212 | - * @return array |
|
213 | - */ |
|
214 | - public static function get_legal_data($from, $number_of_items, $column) |
|
207 | + /** |
|
208 | + * Get the terms and condition table (only for maintenance) |
|
209 | + * @param int $from |
|
210 | + * @param int $number_of_items |
|
211 | + * @param int $column |
|
212 | + * @return array |
|
213 | + */ |
|
214 | + public static function get_legal_data($from, $number_of_items, $column) |
|
215 | 215 | { |
216 | - $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
|
217 | - $lang_table = Database::get_main_table(TABLE_MAIN_LANGUAGE); |
|
218 | - $from = intval($from); |
|
219 | - $number_of_items = intval($number_of_items); |
|
220 | - $column = intval($column); |
|
216 | + $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
|
217 | + $lang_table = Database::get_main_table(TABLE_MAIN_LANGUAGE); |
|
218 | + $from = intval($from); |
|
219 | + $number_of_items = intval($number_of_items); |
|
220 | + $column = intval($column); |
|
221 | 221 | |
222 | - $sql = "SELECT version, original_name as language, content, changes, type, FROM_UNIXTIME(date) |
|
222 | + $sql = "SELECT version, original_name as language, content, changes, type, FROM_UNIXTIME(date) |
|
223 | 223 | FROM $legal_conditions_table inner join $lang_table l on(language_id = l.id) "; |
224 | - $sql .= "ORDER BY language, version ASC "; |
|
225 | - $sql .= "LIMIT $from, $number_of_items "; |
|
224 | + $sql .= "ORDER BY language, version ASC "; |
|
225 | + $sql .= "LIMIT $from, $number_of_items "; |
|
226 | 226 | |
227 | - $result = Database::query($sql); |
|
228 | - $legals = array(); |
|
229 | - $versions = array(); |
|
230 | - while ($legal = Database::fetch_array($result)) { |
|
231 | - // max 2000 chars |
|
232 | - //echo strlen($legal[1]); echo '<br>'; |
|
233 | - $versions[] = $legal[0]; |
|
234 | - $languages[] = $legal[1]; |
|
227 | + $result = Database::query($sql); |
|
228 | + $legals = array(); |
|
229 | + $versions = array(); |
|
230 | + while ($legal = Database::fetch_array($result)) { |
|
231 | + // max 2000 chars |
|
232 | + //echo strlen($legal[1]); echo '<br>'; |
|
233 | + $versions[] = $legal[0]; |
|
234 | + $languages[] = $legal[1]; |
|
235 | 235 | if (strlen($legal[2]) > 2000) { |
236 | 236 | $legal[2] = substr($legal[2], 0, 2000).' ... '; |
237 | 237 | } |
@@ -240,50 +240,50 @@ discard block |
||
240 | 240 | } elseif ($legal[4] == 1) { |
241 | 241 | $legal[4] = get_lang('PageLink'); |
242 | 242 | } |
243 | - $legals[] = $legal; |
|
244 | - } |
|
245 | - return $legals; |
|
246 | - } |
|
243 | + $legals[] = $legal; |
|
244 | + } |
|
245 | + return $legals; |
|
246 | + } |
|
247 | 247 | |
248 | - /** |
|
249 | - * Gets the number of terms and conditions available |
|
250 | - * @return int |
|
251 | - */ |
|
252 | - public static function count() |
|
248 | + /** |
|
249 | + * Gets the number of terms and conditions available |
|
250 | + * @return int |
|
251 | + */ |
|
252 | + public static function count() |
|
253 | 253 | { |
254 | - $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
|
255 | - $sql = "SELECT count(*) as count_result |
|
254 | + $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
|
255 | + $sql = "SELECT count(*) as count_result |
|
256 | 256 | FROM $legal_conditions_table |
257 | 257 | ORDER BY id DESC "; |
258 | - $result = Database::query($sql); |
|
259 | - $url = Database::fetch_array($result,'ASSOC'); |
|
260 | - $result = $url['count_result']; |
|
258 | + $result = Database::query($sql); |
|
259 | + $url = Database::fetch_array($result,'ASSOC'); |
|
260 | + $result = $url['count_result']; |
|
261 | 261 | |
262 | - return $result; |
|
263 | - } |
|
262 | + return $result; |
|
263 | + } |
|
264 | 264 | |
265 | - /** |
|
266 | - * Get type of terms and conditions |
|
267 | - * @param int $legal_id |
|
268 | - * @param int $language_id |
|
269 | - * @return int The current type of terms and conditions |
|
270 | - */ |
|
271 | - public static function get_type_of_terms_and_conditions($legal_id, $language_id) |
|
265 | + /** |
|
266 | + * Get type of terms and conditions |
|
267 | + * @param int $legal_id |
|
268 | + * @param int $language_id |
|
269 | + * @return int The current type of terms and conditions |
|
270 | + */ |
|
271 | + public static function get_type_of_terms_and_conditions($legal_id, $language_id) |
|
272 | 272 | { |
273 | - $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
|
274 | - $legal_id = intval($legal_id); |
|
275 | - $language_id = intval($language_id); |
|
276 | - $sql = 'SELECT type FROM '.$legal_conditions_table.' |
|
273 | + $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); |
|
274 | + $legal_id = intval($legal_id); |
|
275 | + $language_id = intval($language_id); |
|
276 | + $sql = 'SELECT type FROM '.$legal_conditions_table.' |
|
277 | 277 | WHERE id = "'.$legal_id.'" AND language_id="'.$language_id.'"'; |
278 | - $rs = Database::query($sql); |
|
278 | + $rs = Database::query($sql); |
|
279 | 279 | |
280 | - return Database::result($rs,0,'type'); |
|
281 | - } |
|
280 | + return Database::result($rs,0,'type'); |
|
281 | + } |
|
282 | 282 | |
283 | 283 | /** |
284 | 284 | * @param int $userId |
285 | 285 | */ |
286 | - public static function sendLegal($userId) |
|
286 | + public static function sendLegal($userId) |
|
287 | 287 | { |
288 | 288 | $subject = get_lang('SendTermsSubject'); |
289 | 289 | $content = sprintf( |
@@ -8,101 +8,101 @@ discard block |
||
8 | 8 | */ |
9 | 9 | class StudentPublicationLink extends AbstractLink |
10 | 10 | { |
11 | - private $studpub_table = null; |
|
12 | - private $itemprop_table = null; |
|
13 | - |
|
14 | - /** |
|
15 | - * Constructor |
|
16 | - */ |
|
17 | - public function __construct() |
|
18 | - { |
|
19 | - parent::__construct(); |
|
20 | - $this->set_type(LINK_STUDENTPUBLICATION); |
|
21 | - } |
|
22 | - |
|
23 | - /** |
|
24 | - * |
|
25 | - * Returns the URL of a document |
|
26 | - * This function is loaded when using a gradebook as a tab (gradebook = -1) |
|
27 | - * see issue #2705 |
|
28 | - * |
|
29 | - */ |
|
30 | - public function get_view_url($stud_id) |
|
31 | - { |
|
32 | - // find a file uploaded by the given student, |
|
33 | - // with the same title as the evaluation name |
|
34 | - |
|
35 | - $eval = $this->get_evaluation(); |
|
36 | - $stud_id = intval($stud_id); |
|
37 | - |
|
38 | - $sql = 'SELECT pub.url |
|
11 | + private $studpub_table = null; |
|
12 | + private $itemprop_table = null; |
|
13 | + |
|
14 | + /** |
|
15 | + * Constructor |
|
16 | + */ |
|
17 | + public function __construct() |
|
18 | + { |
|
19 | + parent::__construct(); |
|
20 | + $this->set_type(LINK_STUDENTPUBLICATION); |
|
21 | + } |
|
22 | + |
|
23 | + /** |
|
24 | + * |
|
25 | + * Returns the URL of a document |
|
26 | + * This function is loaded when using a gradebook as a tab (gradebook = -1) |
|
27 | + * see issue #2705 |
|
28 | + * |
|
29 | + */ |
|
30 | + public function get_view_url($stud_id) |
|
31 | + { |
|
32 | + // find a file uploaded by the given student, |
|
33 | + // with the same title as the evaluation name |
|
34 | + |
|
35 | + $eval = $this->get_evaluation(); |
|
36 | + $stud_id = intval($stud_id); |
|
37 | + |
|
38 | + $sql = 'SELECT pub.url |
|
39 | 39 | FROM '.$this->get_itemprop_table().' prop, '.$this->get_studpub_table().' pub' |
40 | - ." WHERE |
|
40 | + ." WHERE |
|
41 | 41 | prop.c_id = ".$this->course_id." AND |
42 | 42 | pub.c_id = ".$this->course_id." AND |
43 | 43 | prop.tool = 'work'" |
44 | - .' AND prop.insert_user_id = '.$stud_id |
|
45 | - .' AND prop.ref = pub.id' |
|
46 | - ." AND pub.title = '".Database::escape_string($eval->get_name())."' AND pub.session_id=".api_get_session_id().""; |
|
47 | - |
|
48 | - $result = Database::query($sql); |
|
49 | - if ($fileurl = Database::fetch_row($result)) { |
|
50 | - return null; |
|
51 | - } else { |
|
52 | - return null; |
|
53 | - } |
|
54 | - } |
|
55 | - |
|
56 | - public function get_type_name() |
|
57 | - { |
|
58 | - return get_lang('Works'); |
|
59 | - } |
|
60 | - |
|
61 | - public function is_allowed_to_change_name() |
|
62 | - { |
|
63 | - return false; |
|
64 | - } |
|
65 | - |
|
66 | - /** |
|
67 | - * Generate an array of exercises that a teacher hasn't created a link for. |
|
68 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
69 | - */ |
|
70 | - public function get_not_created_links() |
|
71 | - { |
|
72 | - return false; |
|
73 | - if (empty($this->course_code)) { |
|
74 | - die('Error in get_not_created_links() : course code not set'); |
|
75 | - } |
|
76 | - $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
77 | - |
|
78 | - $sql = 'SELECT id, url from '.$this->get_studpub_table() |
|
79 | - .' pup WHERE c_id = '.$this->course_id.' AND has_properties != '."''".' AND id NOT IN' |
|
80 | - .' (SELECT ref_id FROM '.$tbl_grade_links |
|
81 | - .' WHERE type = '.LINK_STUDENTPUBLICATION |
|
82 | - ." AND course_code = '".Database::escape_string($this->get_course_code())."'" |
|
83 | - .') AND pub.session_id='.api_get_session_id().''; |
|
84 | - |
|
85 | - $result = Database::query($sql); |
|
86 | - |
|
87 | - $cats=array(); |
|
88 | - while ($data=Database::fetch_array($result)) { |
|
89 | - $cats[] = array ($data['id'], $data['url']); |
|
90 | - } |
|
91 | - return $cats; |
|
92 | - } |
|
93 | - |
|
94 | - /** |
|
95 | - * Generate an array of all exercises available. |
|
96 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
97 | - */ |
|
98 | - public function get_all_links() |
|
99 | - { |
|
100 | - if (empty($this->course_code)) { |
|
101 | - die('Error in get_not_created_links() : course code not set'); |
|
102 | - } |
|
103 | - $em = Database::getManager(); |
|
44 | + .' AND prop.insert_user_id = '.$stud_id |
|
45 | + .' AND prop.ref = pub.id' |
|
46 | + ." AND pub.title = '".Database::escape_string($eval->get_name())."' AND pub.session_id=".api_get_session_id().""; |
|
47 | + |
|
48 | + $result = Database::query($sql); |
|
49 | + if ($fileurl = Database::fetch_row($result)) { |
|
50 | + return null; |
|
51 | + } else { |
|
52 | + return null; |
|
53 | + } |
|
54 | + } |
|
55 | + |
|
56 | + public function get_type_name() |
|
57 | + { |
|
58 | + return get_lang('Works'); |
|
59 | + } |
|
60 | + |
|
61 | + public function is_allowed_to_change_name() |
|
62 | + { |
|
63 | + return false; |
|
64 | + } |
|
65 | + |
|
66 | + /** |
|
67 | + * Generate an array of exercises that a teacher hasn't created a link for. |
|
68 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
69 | + */ |
|
70 | + public function get_not_created_links() |
|
71 | + { |
|
72 | + return false; |
|
73 | + if (empty($this->course_code)) { |
|
74 | + die('Error in get_not_created_links() : course code not set'); |
|
75 | + } |
|
76 | + $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
77 | + |
|
78 | + $sql = 'SELECT id, url from '.$this->get_studpub_table() |
|
79 | + .' pup WHERE c_id = '.$this->course_id.' AND has_properties != '."''".' AND id NOT IN' |
|
80 | + .' (SELECT ref_id FROM '.$tbl_grade_links |
|
81 | + .' WHERE type = '.LINK_STUDENTPUBLICATION |
|
82 | + ." AND course_code = '".Database::escape_string($this->get_course_code())."'" |
|
83 | + .') AND pub.session_id='.api_get_session_id().''; |
|
84 | + |
|
85 | + $result = Database::query($sql); |
|
86 | + |
|
87 | + $cats=array(); |
|
88 | + while ($data=Database::fetch_array($result)) { |
|
89 | + $cats[] = array ($data['id'], $data['url']); |
|
90 | + } |
|
91 | + return $cats; |
|
92 | + } |
|
93 | + |
|
94 | + /** |
|
95 | + * Generate an array of all exercises available. |
|
96 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
97 | + */ |
|
98 | + public function get_all_links() |
|
99 | + { |
|
100 | + if (empty($this->course_code)) { |
|
101 | + die('Error in get_not_created_links() : course code not set'); |
|
102 | + } |
|
103 | + $em = Database::getManager(); |
|
104 | 104 | $session = $em->find('ChamiloCoreBundle:Session', api_get_session_id()); |
105 | - /* |
|
105 | + /* |
|
106 | 106 | if (empty($session_id)) { |
107 | 107 | $session_condition = api_get_session_condition(0, true); |
108 | 108 | } else { |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | $sql = "SELECT id, url, title FROM $tbl_grade_links |
112 | 112 | WHERE c_id = {$this->course_id} AND filetype='folder' AND active = 1 $session_condition ";*/ |
113 | 113 | |
114 | - //Only show works from the session |
|
115 | - //AND has_properties != '' |
|
114 | + //Only show works from the session |
|
115 | + //AND has_properties != '' |
|
116 | 116 | $links = $em |
117 | 117 | ->getRepository('ChamiloCourseBundle:CStudentPublication') |
118 | 118 | ->findBy([ |
@@ -123,22 +123,22 @@ discard block |
||
123 | 123 | ]); |
124 | 124 | |
125 | 125 | foreach ($links as $data) { |
126 | - $work_name = $data->getTitle(); |
|
127 | - if (empty($work_name)) { |
|
128 | - $work_name = basename($data->getUrl()); |
|
129 | - } |
|
130 | - $cats[] = array ($data->getId(), $work_name); |
|
131 | - } |
|
132 | - $cats=isset($cats) ? $cats : array(); |
|
133 | - return $cats; |
|
134 | - } |
|
135 | - |
|
136 | - /** |
|
137 | - * Has anyone done this exercise yet ? |
|
138 | - */ |
|
139 | - public function has_results() |
|
140 | - { |
|
141 | - $em = Database::getManager(); |
|
126 | + $work_name = $data->getTitle(); |
|
127 | + if (empty($work_name)) { |
|
128 | + $work_name = basename($data->getUrl()); |
|
129 | + } |
|
130 | + $cats[] = array ($data->getId(), $work_name); |
|
131 | + } |
|
132 | + $cats=isset($cats) ? $cats : array(); |
|
133 | + return $cats; |
|
134 | + } |
|
135 | + |
|
136 | + /** |
|
137 | + * Has anyone done this exercise yet ? |
|
138 | + */ |
|
139 | + public function has_results() |
|
140 | + { |
|
141 | + $em = Database::getManager(); |
|
142 | 142 | $session = $em->find('ChamiloCoreBundle:Session', api_get_session_id()); |
143 | 143 | $results = $em |
144 | 144 | ->getRepository('ChamiloCourseBundle:CStudentPublication') |
@@ -149,15 +149,15 @@ discard block |
||
149 | 149 | ]); |
150 | 150 | |
151 | 151 | return count($results) != 0; |
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * @param null $stud_id |
|
156 | - * @return array|null |
|
157 | - */ |
|
158 | - public function calc_score($stud_id = null, $type = null) |
|
159 | - { |
|
160 | - $stud_id = intval($stud_id); |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * @param null $stud_id |
|
156 | + * @return array|null |
|
157 | + */ |
|
158 | + public function calc_score($stud_id = null, $type = null) |
|
159 | + { |
|
160 | + $stud_id = intval($stud_id); |
|
161 | 161 | $em = Database::getManager(); |
162 | 162 | |
163 | 163 | $session = $em->find('ChamiloCoreBundle:Session', api_get_session_id()); |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | |
173 | 173 | $parentId = !$assignment ? 0 : $assignment->getId(); |
174 | 174 | |
175 | - $dql = 'SELECT a FROM ChamiloCourseBundle:CStudentPublication a |
|
175 | + $dql = 'SELECT a FROM ChamiloCourseBundle:CStudentPublication a |
|
176 | 176 | WHERE |
177 | 177 | a.cId = :course AND |
178 | 178 | active = 1 AND |
@@ -182,31 +182,31 @@ discard block |
||
182 | 182 | '; |
183 | 183 | $params = ['course' => $this->course_id, 'parent' => $parentId, 'session' => $session]; |
184 | 184 | |
185 | - if (!empty($stud_id)) { |
|
186 | - $dql .= ' AND a.userId = :student '; |
|
185 | + if (!empty($stud_id)) { |
|
186 | + $dql .= ' AND a.userId = :student '; |
|
187 | 187 | $params['student'] = $stud_id; |
188 | - } |
|
189 | - |
|
190 | - $order = api_get_setting('student_publication_to_take_in_gradebook'); |
|
191 | - |
|
192 | - switch ($order) { |
|
193 | - case 'last': |
|
194 | - // latest attempt |
|
195 | - $dql .= ' ORDER BY a.sentDate DESC'; |
|
196 | - break; |
|
197 | - case 'first': |
|
198 | - default: |
|
199 | - // first attempt |
|
200 | - $dql .= ' ORDER BY a.id'; |
|
201 | - break; |
|
202 | - } |
|
188 | + } |
|
189 | + |
|
190 | + $order = api_get_setting('student_publication_to_take_in_gradebook'); |
|
191 | + |
|
192 | + switch ($order) { |
|
193 | + case 'last': |
|
194 | + // latest attempt |
|
195 | + $dql .= ' ORDER BY a.sentDate DESC'; |
|
196 | + break; |
|
197 | + case 'first': |
|
198 | + default: |
|
199 | + // first attempt |
|
200 | + $dql .= ' ORDER BY a.id'; |
|
201 | + break; |
|
202 | + } |
|
203 | 203 | |
204 | 204 | $scores = $em->createQuery($dql)->execute([$params]); |
205 | 205 | |
206 | - // for 1 student |
|
207 | - if (!empty($stud_id)) { |
|
208 | - if (!count($scores)) { |
|
209 | - return ''; |
|
206 | + // for 1 student |
|
207 | + if (!empty($stud_id)) { |
|
208 | + if (!count($scores)) { |
|
209 | + return ''; |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | $data = $scores[0]; |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | $data->getQualification(), |
216 | 216 | $assignment->getQualification() |
217 | 217 | ]; |
218 | - } |
|
218 | + } |
|
219 | 219 | |
220 | 220 | $students = array(); // user list, needed to make sure we only |
221 | 221 | // take first attempts into account |
@@ -259,116 +259,116 @@ discard block |
||
259 | 259 | return array($sum, $rescount); |
260 | 260 | break; |
261 | 261 | } |
262 | - } |
|
263 | - |
|
264 | - /** |
|
265 | - * Lazy load function to get the database table of the student publications |
|
266 | - */ |
|
267 | - private function get_studpub_table() |
|
268 | - { |
|
269 | - return $this->studpub_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION); |
|
270 | - } |
|
271 | - |
|
272 | - /** |
|
273 | - * Lazy load function to get the database table of the item properties |
|
274 | - */ |
|
275 | - private function get_itemprop_table() |
|
276 | - { |
|
277 | - return $this->itemprop_table = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
|
278 | - } |
|
279 | - |
|
280 | - public function needs_name_and_description() |
|
281 | - { |
|
282 | - return false; |
|
283 | - } |
|
284 | - |
|
285 | - public function get_name() |
|
286 | - { |
|
287 | - $this->get_exercise_data(); |
|
288 | - return (isset($this->exercise_data['title']) && !empty($this->exercise_data['title'])) ? $this->exercise_data['title'] : get_lang('Untitled'); |
|
289 | - } |
|
290 | - |
|
291 | - public function get_description() |
|
292 | - { |
|
293 | - $this->get_exercise_data(); |
|
294 | - return isset($this->exercise_data['description']) ? $this->exercise_data['description'] : null; |
|
295 | - } |
|
296 | - |
|
297 | - public function get_test_id() |
|
298 | - { |
|
299 | - return 'DEBUG:ID'; |
|
300 | - } |
|
301 | - |
|
302 | - public function get_link() |
|
303 | - { |
|
304 | - $session_id = api_get_session_id(); |
|
305 | - $url = api_get_path(WEB_PATH).'main/work/work.php?'.api_get_cidreq_params($this->get_course_code(), $session_id).'&id='.$this->exercise_data['id'].'&gradebook=view'; |
|
306 | - |
|
307 | - return $url; |
|
308 | - } |
|
309 | - |
|
310 | - private function get_exercise_data() |
|
311 | - { |
|
312 | - $tbl_name = $this->get_studpub_table(); |
|
313 | - $course_info = api_get_course_info($this->get_course_code()); |
|
314 | - if ($tbl_name=='') { |
|
315 | - return false; |
|
316 | - } elseif (!isset($this->exercise_data)) { |
|
317 | - $sql = 'SELECT * FROM '.$this->get_studpub_table()." |
|
262 | + } |
|
263 | + |
|
264 | + /** |
|
265 | + * Lazy load function to get the database table of the student publications |
|
266 | + */ |
|
267 | + private function get_studpub_table() |
|
268 | + { |
|
269 | + return $this->studpub_table = Database :: get_course_table(TABLE_STUDENT_PUBLICATION); |
|
270 | + } |
|
271 | + |
|
272 | + /** |
|
273 | + * Lazy load function to get the database table of the item properties |
|
274 | + */ |
|
275 | + private function get_itemprop_table() |
|
276 | + { |
|
277 | + return $this->itemprop_table = Database :: get_course_table(TABLE_ITEM_PROPERTY); |
|
278 | + } |
|
279 | + |
|
280 | + public function needs_name_and_description() |
|
281 | + { |
|
282 | + return false; |
|
283 | + } |
|
284 | + |
|
285 | + public function get_name() |
|
286 | + { |
|
287 | + $this->get_exercise_data(); |
|
288 | + return (isset($this->exercise_data['title']) && !empty($this->exercise_data['title'])) ? $this->exercise_data['title'] : get_lang('Untitled'); |
|
289 | + } |
|
290 | + |
|
291 | + public function get_description() |
|
292 | + { |
|
293 | + $this->get_exercise_data(); |
|
294 | + return isset($this->exercise_data['description']) ? $this->exercise_data['description'] : null; |
|
295 | + } |
|
296 | + |
|
297 | + public function get_test_id() |
|
298 | + { |
|
299 | + return 'DEBUG:ID'; |
|
300 | + } |
|
301 | + |
|
302 | + public function get_link() |
|
303 | + { |
|
304 | + $session_id = api_get_session_id(); |
|
305 | + $url = api_get_path(WEB_PATH).'main/work/work.php?'.api_get_cidreq_params($this->get_course_code(), $session_id).'&id='.$this->exercise_data['id'].'&gradebook=view'; |
|
306 | + |
|
307 | + return $url; |
|
308 | + } |
|
309 | + |
|
310 | + private function get_exercise_data() |
|
311 | + { |
|
312 | + $tbl_name = $this->get_studpub_table(); |
|
313 | + $course_info = api_get_course_info($this->get_course_code()); |
|
314 | + if ($tbl_name=='') { |
|
315 | + return false; |
|
316 | + } elseif (!isset($this->exercise_data)) { |
|
317 | + $sql = 'SELECT * FROM '.$this->get_studpub_table()." |
|
318 | 318 | WHERE |
319 | 319 | c_id ='".$course_info['real_id']."' AND |
320 | 320 | id = '".intval($this->get_ref_id())."' "; |
321 | - $query = Database::query($sql); |
|
322 | - $this->exercise_data = Database::fetch_array($query); |
|
323 | - } |
|
324 | - return $this->exercise_data; |
|
325 | - } |
|
326 | - |
|
327 | - public function needs_max() |
|
328 | - { |
|
329 | - return false; |
|
330 | - } |
|
331 | - |
|
332 | - public function needs_results() |
|
333 | - { |
|
334 | - return false; |
|
335 | - } |
|
336 | - |
|
337 | - public function is_valid_link() |
|
338 | - { |
|
339 | - $sql = 'SELECT count(id) FROM '.$this->get_studpub_table().' |
|
321 | + $query = Database::query($sql); |
|
322 | + $this->exercise_data = Database::fetch_array($query); |
|
323 | + } |
|
324 | + return $this->exercise_data; |
|
325 | + } |
|
326 | + |
|
327 | + public function needs_max() |
|
328 | + { |
|
329 | + return false; |
|
330 | + } |
|
331 | + |
|
332 | + public function needs_results() |
|
333 | + { |
|
334 | + return false; |
|
335 | + } |
|
336 | + |
|
337 | + public function is_valid_link() |
|
338 | + { |
|
339 | + $sql = 'SELECT count(id) FROM '.$this->get_studpub_table().' |
|
340 | 340 | WHERE c_id = "'.$this->course_id.'" AND id = '.intval($this->get_ref_id()).''; |
341 | - $result = Database::query($sql); |
|
342 | - $number = Database::fetch_row($result); |
|
343 | - return ($number[0] != 0); |
|
344 | - } |
|
345 | - |
|
346 | - public function get_icon_name() |
|
347 | - { |
|
348 | - return 'studentpublication'; |
|
349 | - } |
|
350 | - |
|
351 | - public function save_linked_data() |
|
352 | - { |
|
353 | - $weight = (float)$this->get_weight(); |
|
354 | - $ref_id = $this->get_ref_id(); |
|
355 | - |
|
356 | - if (!empty($ref_id)) { |
|
357 | - //Cleans works |
|
358 | - $sql = 'UPDATE '.$this->get_studpub_table().' SET weight= '.$weight.' |
|
341 | + $result = Database::query($sql); |
|
342 | + $number = Database::fetch_row($result); |
|
343 | + return ($number[0] != 0); |
|
344 | + } |
|
345 | + |
|
346 | + public function get_icon_name() |
|
347 | + { |
|
348 | + return 'studentpublication'; |
|
349 | + } |
|
350 | + |
|
351 | + public function save_linked_data() |
|
352 | + { |
|
353 | + $weight = (float)$this->get_weight(); |
|
354 | + $ref_id = $this->get_ref_id(); |
|
355 | + |
|
356 | + if (!empty($ref_id)) { |
|
357 | + //Cleans works |
|
358 | + $sql = 'UPDATE '.$this->get_studpub_table().' SET weight= '.$weight.' |
|
359 | 359 | WHERE c_id = '.$this->course_id.' AND id ='.$ref_id; |
360 | - Database::query($sql); |
|
361 | - } |
|
362 | - } |
|
363 | - |
|
364 | - public function delete_linked_data() |
|
365 | - { |
|
366 | - $ref_id = $this->get_ref_id(); |
|
367 | - if (!empty($ref_id)) { |
|
368 | - //Cleans works |
|
369 | - $sql = 'UPDATE '.$this->get_studpub_table().' SET weight=0 |
|
360 | + Database::query($sql); |
|
361 | + } |
|
362 | + } |
|
363 | + |
|
364 | + public function delete_linked_data() |
|
365 | + { |
|
366 | + $ref_id = $this->get_ref_id(); |
|
367 | + if (!empty($ref_id)) { |
|
368 | + //Cleans works |
|
369 | + $sql = 'UPDATE '.$this->get_studpub_table().' SET weight=0 |
|
370 | 370 | WHERE c_id = '.$this->course_id.' AND id ='.$ref_id; |
371 | - Database::query($sql); |
|
372 | - } |
|
373 | - } |
|
371 | + Database::query($sql); |
|
372 | + } |
|
373 | + } |
|
374 | 374 | } |
@@ -607,7 +607,7 @@ |
||
607 | 607 | .' width="40px">'; |
608 | 608 | $userInfo = api_get_user_info($user_invitation_id); |
609 | 609 | $invitations .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php?u='.$user_invitation_id.'">' |
610 | - .api_get_person_name($userInfo['firstname'],$userInfo['lastname']).'</a>'; |
|
610 | + .api_get_person_name($userInfo['firstname'],$userInfo['lastname']).'</a>'; |
|
611 | 611 | |
612 | 612 | $invitations .='<div class="pull-right">'; |
613 | 613 | $invitations .= '<a title="'.get_lang('SocialAddToFriends').'" id="btn_accepted_'.$user_invitation_id.'" class="btn btn-default btn-sm" onclick="register_friend(this)" href="javascript:void(0)">' |
@@ -137,11 +137,11 @@ discard block |
||
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
140 | - * provides a side connection to a vchamilo database |
|
141 | - * @param array $_configuration |
|
140 | + * provides a side connection to a vchamilo database |
|
141 | + * @param array $_configuration |
|
142 | 142 | * |
143 | - * @return \Doctrine\DBAL\Driver\Connection |
|
144 | - */ |
|
143 | + * @return \Doctrine\DBAL\Driver\Connection |
|
144 | + */ |
|
145 | 145 | public static function bootConnection(&$_configuration) |
146 | 146 | { |
147 | 147 | $dbParams = array( |
@@ -249,10 +249,10 @@ discard block |
||
249 | 249 | } |
250 | 250 | |
251 | 251 | /** |
252 | - * drop a vchamilo instance databases using the physical connection |
|
253 | - * @param stdClass $params |
|
254 | - * return an array of errors or false if ok |
|
255 | - */ |
|
252 | + * drop a vchamilo instance databases using the physical connection |
|
253 | + * @param stdClass $params |
|
254 | + * return an array of errors or false if ok |
|
255 | + */ |
|
256 | 256 | public static function dropDatabase($params) |
257 | 257 | { |
258 | 258 | $params = clone $params; |
@@ -302,10 +302,10 @@ discard block |
||
302 | 302 | } |
303 | 303 | |
304 | 304 | /** |
305 | - * get a proper SQLdump command |
|
306 | - * @param object $vmoodledata the complete new host information |
|
307 | - * @return string the shell command |
|
308 | - */ |
|
305 | + * get a proper SQLdump command |
|
306 | + * @param object $vmoodledata the complete new host information |
|
307 | + * @return string the shell command |
|
308 | + */ |
|
309 | 309 | public static function getDatabaseDumpCmd($vchamilodata) |
310 | 310 | { |
311 | 311 | $pgm = self::getConfig('vchamilo', 'mysql_cmd'); |
@@ -469,8 +469,8 @@ discard block |
||
469 | 469 | } |
470 | 470 | |
471 | 471 | /** |
472 | - * read manifest values in vchamilo template. |
|
473 | - */ |
|
472 | + * read manifest values in vchamilo template. |
|
473 | + */ |
|
474 | 474 | public static function getVmanifest($version) |
475 | 475 | { |
476 | 476 | $file = api_get_path(SYS_PATH).'/plugin/vchamilo/templates/'.$version.'/manifest.php'; |
@@ -490,8 +490,8 @@ discard block |
||
490 | 490 | } |
491 | 491 | |
492 | 492 | /** |
493 | - * make a fake vchamilo that represents the current host |
|
494 | - */ |
|
493 | + * make a fake vchamilo that represents the current host |
|
494 | + */ |
|
495 | 495 | public static function makeThis() |
496 | 496 | { |
497 | 497 | global $_configuration; |
@@ -556,11 +556,11 @@ discard block |
||
556 | 556 | } |
557 | 557 | |
558 | 558 | /** |
559 | - * this function set will map standard moodle API calls to chamilo |
|
560 | - * internal primitives. This avoids too many changes to do in imported |
|
561 | - * code |
|
562 | - * |
|
563 | - */ |
|
559 | + * this function set will map standard moodle API calls to chamilo |
|
560 | + * internal primitives. This avoids too many changes to do in imported |
|
561 | + * code |
|
562 | + * |
|
563 | + */ |
|
564 | 564 | public static function getConfig($module, $key, $isplugin = true) |
565 | 565 | { |
566 | 566 | if ($isplugin) { |
@@ -43,7 +43,7 @@ |
||
43 | 43 | $event = $agenda->get_event($id); |
44 | 44 | |
45 | 45 | if (!empty($event)) { |
46 | - define('ICAL_LANG', api_get_language_isocode()); |
|
46 | + define('ICAL_LANG', api_get_language_isocode()); |
|
47 | 47 | |
48 | 48 | $ical = new vcalendar(); |
49 | 49 | $ical->setConfig('unique_id',api_get_path(WEB_PATH)); |