|
@@ 624-694 (lines=71) @@
|
| 621 |
|
* @param string $commentsDelete Set to 'on' to register as 'article_comments_delete' in tasks permissions |
| 622 |
|
* @param string $color |
| 623 |
|
*/ |
| 624 |
|
public static function addTask( |
| 625 |
|
$blog_id, |
| 626 |
|
$title, |
| 627 |
|
$description, |
| 628 |
|
$articleDelete, |
| 629 |
|
$articleEdit, |
| 630 |
|
$commentsDelete, |
| 631 |
|
$color |
| 632 |
|
) { |
| 633 |
|
$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
| 634 |
|
$tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
| 635 |
|
|
| 636 |
|
$course_id = api_get_course_int_id(); |
| 637 |
|
$blog_id = intval($blog_id); |
| 638 |
|
$title = Database::escape_string($title); |
| 639 |
|
$description = Database::escape_string($description); |
| 640 |
|
$color = Database::escape_string($color); |
| 641 |
|
|
| 642 |
|
// Create the task |
| 643 |
|
$sql = "INSERT INTO $tbl_blogs_tasks (c_id, blog_id, title, description, color, system_task) |
| 644 |
|
VALUES ($course_id , $blog_id, '$title', '$description', '$color', '0');"; |
| 645 |
|
Database::query($sql); |
| 646 |
|
|
| 647 |
|
$task_id = Database::insert_id(); |
| 648 |
|
|
| 649 |
|
if ($task_id) { |
| 650 |
|
$sql = "UPDATE $tbl_blogs_tasks SET task_id = iid WHERE iid = $task_id"; |
| 651 |
|
Database::query($sql); |
| 652 |
|
} |
| 653 |
|
|
| 654 |
|
$tool = 'BLOG_'.$blog_id; |
| 655 |
|
|
| 656 |
|
if ($articleDelete == 'on') { |
| 657 |
|
$sql = "INSERT INTO $tbl_tasks_permissions ( c_id, task_id, tool, action) |
| 658 |
|
VALUES ($course_id, $task_id, '$tool', 'article_delete')"; |
| 659 |
|
Database::query($sql); |
| 660 |
|
|
| 661 |
|
$id = Database::insert_id(); |
| 662 |
|
|
| 663 |
|
if ($id) { |
| 664 |
|
$sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id"; |
| 665 |
|
Database::query($sql); |
| 666 |
|
} |
| 667 |
|
} |
| 668 |
|
|
| 669 |
|
if ($articleEdit == 'on') { |
| 670 |
|
$sql = " |
| 671 |
|
INSERT INTO $tbl_tasks_permissions (c_id, task_id, tool, action ) |
| 672 |
|
VALUES ($course_id, $task_id, '$tool', 'article_edit')"; |
| 673 |
|
Database::query($sql); |
| 674 |
|
$id = Database::insert_id(); |
| 675 |
|
|
| 676 |
|
if ($id) { |
| 677 |
|
$sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id"; |
| 678 |
|
Database::query($sql); |
| 679 |
|
} |
| 680 |
|
} |
| 681 |
|
|
| 682 |
|
if ($commentsDelete == 'on') { |
| 683 |
|
$sql = " |
| 684 |
|
INSERT INTO $tbl_tasks_permissions (c_id, task_id, tool, action ) |
| 685 |
|
VALUES ($course_id, $task_id, '$tool', 'article_comments_delete')"; |
| 686 |
|
Database::query($sql); |
| 687 |
|
$id = Database::insert_id(); |
| 688 |
|
|
| 689 |
|
if ($id) { |
| 690 |
|
$sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id"; |
| 691 |
|
Database::query($sql); |
| 692 |
|
} |
| 693 |
|
} |
| 694 |
|
} |
| 695 |
|
|
| 696 |
|
/** |
| 697 |
|
* Edit a task in a blog |
|
@@ 708-777 (lines=70) @@
|
| 705 |
|
* @param string $commentsDelete Set to 'on' to register as 'article_comments_delete' in tasks permissions |
| 706 |
|
* @param string $color The color code |
| 707 |
|
*/ |
| 708 |
|
public static function editTask( |
| 709 |
|
$blog_id, |
| 710 |
|
$task_id, |
| 711 |
|
$title, |
| 712 |
|
$description, |
| 713 |
|
$articleDelete, |
| 714 |
|
$articleEdit, |
| 715 |
|
$commentsDelete, |
| 716 |
|
$color |
| 717 |
|
) { |
| 718 |
|
$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); |
| 719 |
|
$tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS); |
| 720 |
|
|
| 721 |
|
$course_id = api_get_course_int_id(); |
| 722 |
|
$blog_id = intval($blog_id); |
| 723 |
|
$task_id = intval($task_id); |
| 724 |
|
$title = Database::escape_string($title); |
| 725 |
|
$description = Database::escape_string($description); |
| 726 |
|
$color = Database::escape_string($color); |
| 727 |
|
|
| 728 |
|
// Create the task |
| 729 |
|
$sql = "UPDATE $tbl_blogs_tasks SET |
| 730 |
|
title = '$title', |
| 731 |
|
description = '$description', |
| 732 |
|
color = '$color' |
| 733 |
|
WHERE c_id = $course_id AND task_id = task_id LIMIT 1"; |
| 734 |
|
Database::query($sql); |
| 735 |
|
|
| 736 |
|
$tool = 'BLOG_'.$blog_id; |
| 737 |
|
$sql = "DELETE FROM $tbl_tasks_permissions |
| 738 |
|
WHERE c_id = $course_id AND task_id = $task_id"; |
| 739 |
|
Database::query($sql); |
| 740 |
|
|
| 741 |
|
if ($articleDelete == 'on') { |
| 742 |
|
$sql = "INSERT INTO $tbl_tasks_permissions ( c_id, task_id, tool, action) |
| 743 |
|
VALUES ($course_id, $task_id, '$tool', 'article_delete')"; |
| 744 |
|
Database::query($sql); |
| 745 |
|
$id = Database::insert_id(); |
| 746 |
|
|
| 747 |
|
if ($id) { |
| 748 |
|
$sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id"; |
| 749 |
|
Database::query($sql); |
| 750 |
|
} |
| 751 |
|
} |
| 752 |
|
|
| 753 |
|
if ($articleEdit == 'on') { |
| 754 |
|
$sql = "INSERT INTO $tbl_tasks_permissions (c_id, task_id, tool, action) |
| 755 |
|
VALUES ($course_id, $task_id, '$tool', 'article_edit')"; |
| 756 |
|
Database::query($sql); |
| 757 |
|
$id = Database::insert_id(); |
| 758 |
|
|
| 759 |
|
if ($id) { |
| 760 |
|
$sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id"; |
| 761 |
|
Database::query($sql); |
| 762 |
|
} |
| 763 |
|
} |
| 764 |
|
|
| 765 |
|
if ($commentsDelete == 'on') { |
| 766 |
|
$sql = "INSERT INTO $tbl_tasks_permissions (c_id, task_id, tool, action) |
| 767 |
|
VALUES ($course_id, $task_id, '$tool', 'article_comments_delete')"; |
| 768 |
|
Database::query($sql); |
| 769 |
|
$id = Database::insert_id(); |
| 770 |
|
|
| 771 |
|
if ($id) { |
| 772 |
|
$sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id"; |
| 773 |
|
Database::query($sql); |
| 774 |
|
} |
| 775 |
|
} |
| 776 |
|
} |
| 777 |
|
|
| 778 |
|
/** |
| 779 |
|
* Deletes a task from a blog |
| 780 |
|
* @param int $blog_id |