Format code, fix PHP warning, add/fix docs

1.10.x
Julio Montoya 10 years ago
parent 39503d9ad0
commit e326572e46
  1. 9
      main/inc/lib/AnnouncementManager.php
  2. 44
      main/inc/lib/agenda.lib.php
  3. 2
      main/inc/lib/attendance.lib.php
  4. 4
      main/inc/lib/auth.lib.php
  5. 209
      main/inc/lib/blog.lib.php
  6. 2
      main/inc/lib/certificate.lib.php
  7. 3
      main/inc/lib/course_description.lib.php
  8. 6
      main/inc/lib/course_home.lib.php
  9. 7
      main/inc/lib/course_request.lib.php
  10. 12
      main/inc/lib/dashboard.lib.php
  11. 14
      main/inc/lib/event_email_template.class.php
  12. 2
      main/inc/lib/export.lib.inc.php
  13. 2
      main/inc/lib/redirect.class.php
  14. 29
      main/newscorm/learnpath.class.php
  15. 69
      main/permissions/blog_permissions.inc.php

@ -194,7 +194,7 @@ class AnnouncementManager
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
if (api_is_allowed_to_edit(false, true) || (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) { if (api_is_allowed_to_edit(false, true) || (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) {
$sql_query = " SELECT announcement.*, toolitemproperties.* $sql = "SELECT announcement.*, toolitemproperties.*
FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
WHERE WHERE
announcement.id = toolitemproperties.ref AND announcement.id = toolitemproperties.ref AND
@ -209,7 +209,7 @@ class AnnouncementManager
$group_list[] = 0; $group_list[] = 0;
} }
if (api_get_user_id() != 0) { if (api_get_user_id() != 0) {
$sql_query = " SELECT announcement.*, toolitemproperties.* $sql = "SELECT announcement.*, toolitemproperties.*
FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
WHERE WHERE
announcement.id = toolitemproperties.ref AND announcement.id = toolitemproperties.ref AND
@ -225,7 +225,7 @@ class AnnouncementManager
toolitemproperties.c_id = $course_id toolitemproperties.c_id = $course_id
ORDER BY display_order DESC"; ORDER BY display_order DESC";
} else { } else {
$sql_query = " SELECT announcement.*, toolitemproperties.* $sql = "SELECT announcement.*, toolitemproperties.*
FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
WHERE WHERE
announcement.id = toolitemproperties.ref AND announcement.id = toolitemproperties.ref AND
@ -239,7 +239,7 @@ class AnnouncementManager
} }
} }
$sql_result = Database::query($sql_query); $sql_result = Database::query($sql);
$html = null; $html = null;
if (Database::num_rows($sql_result) > 0) { if (Database::num_rows($sql_result) > 0) {
$result = Database::fetch_array($sql_result, 'ASSOC'); $result = Database::fetch_array($sql_result, 'ASSOC');
@ -312,6 +312,7 @@ class AnnouncementManager
$html .= '</td></tr>'; $html .= '</td></tr>';
} }
$html .= "</table>"; $html .= "</table>";
return $html; return $html;
} }

@ -522,7 +522,8 @@ class Agenda
// Get the agenda item. // Get the agenda item.
$item_id = intval($item_id); $item_id = intval($item_id);
$sql = "SELECT * FROM $table_agenda WHERE c_id = $course_id AND id = ".$item_id; $sql = "SELECT * FROM $table_agenda
WHERE c_id = $course_id AND id = ".$item_id;
$res = Database::query($sql); $res = Database::query($sql);
if (Database::num_rows($res) > 0) { if (Database::num_rows($res) > 0) {
@ -538,9 +539,11 @@ class Agenda
$row['end_date'] $row['end_date']
); );
AnnouncementManager::send_email($id); AnnouncementManager::send_email($id);
}
return $id; return $id;
} }
}
return -1; return -1;
} }
@ -1088,17 +1091,20 @@ class Agenda
if (!empty($event)) { if (!empty($event)) {
switch ($this->type) { switch ($this->type) {
case 'personal': case 'personal':
$sql = "UPDATE $this->tbl_personal_agenda SET all_day = 0, enddate = DATE_ADD(enddate, INTERVAL $delta MINUTE) $sql = "UPDATE $this->tbl_personal_agenda SET
all_day = 0, enddate = DATE_ADD(enddate, INTERVAL $delta MINUTE)
WHERE id=".intval($id); WHERE id=".intval($id);
Database::query($sql); Database::query($sql);
break; break;
case 'course': case 'course':
$sql = "UPDATE $this->tbl_course_agenda SET all_day = 0, end_date = DATE_ADD(end_date, INTERVAL $delta MINUTE) $sql = "UPDATE $this->tbl_course_agenda SET
all_day = 0, end_date = DATE_ADD(end_date, INTERVAL $delta MINUTE)
WHERE c_id = ".$this->course['real_id']." AND id=".intval($id); WHERE c_id = ".$this->course['real_id']." AND id=".intval($id);
Database::query($sql); Database::query($sql);
break; break;
case 'admin': case 'admin':
$sql = "UPDATE $this->tbl_global_agenda SET all_day = 0, end_date = DATE_ADD(end_date, INTERVAL $delta MINUTE) $sql = "UPDATE $this->tbl_global_agenda SET
all_day = 0, end_date = DATE_ADD(end_date, INTERVAL $delta MINUTE)
WHERE id=".intval($id); WHERE id=".intval($id);
Database::query($sql); Database::query($sql);
break; break;
@ -1129,19 +1135,26 @@ class Agenda
if (!empty($event)) { if (!empty($event)) {
switch ($this->type) { switch ($this->type) {
case 'personal': case 'personal':
$sql = "UPDATE $this->tbl_personal_agenda SET all_day = $allDay, date = DATE_ADD(date, INTERVAL $delta MINUTE), enddate = DATE_ADD(enddate, INTERVAL $delta MINUTE) $sql = "UPDATE $this->tbl_personal_agenda SET
all_day = $allDay, date = DATE_ADD(date, INTERVAL $delta MINUTE),
enddate = DATE_ADD(enddate, INTERVAL $delta MINUTE)
WHERE id=".intval($id); WHERE id=".intval($id);
$result = Database::query($sql); Database::query($sql);
break; break;
case 'course': case 'course':
$sql = "UPDATE $this->tbl_course_agenda SET all_day = $allDay, start_date = DATE_ADD(start_date,INTERVAL $delta MINUTE), end_date = DATE_ADD(end_date, INTERVAL $delta MINUTE) $sql = "UPDATE $this->tbl_course_agenda SET
all_day = $allDay, start_date = DATE_ADD(start_date,INTERVAL $delta MINUTE),
end_date = DATE_ADD(end_date, INTERVAL $delta MINUTE)
WHERE c_id = ".$this->course['real_id']." AND id=".intval($id); WHERE c_id = ".$this->course['real_id']." AND id=".intval($id);
$result = Database::query($sql); Database::query($sql);
break; break;
case 'admin': case 'admin':
$sql = "UPDATE $this->tbl_global_agenda SET all_day = $allDay, start_date = DATE_ADD(start_date,INTERVAL $delta MINUTE), end_date = DATE_ADD(end_date, INTERVAL $delta MINUTE) $sql = "UPDATE $this->tbl_global_agenda SET
all_day = $allDay,
start_date = DATE_ADD(start_date,INTERVAL $delta MINUTE),
end_date = DATE_ADD(end_date, INTERVAL $delta MINUTE)
WHERE id=".intval($id); WHERE id=".intval($id);
$result = Database::query($sql); Database::query($sql);
break; break;
} }
} }
@ -2549,12 +2562,17 @@ class Agenda
} }
} }
$actionsRight = '';
if ($view == 'calendar') { if ($view == 'calendar') {
$actionsRight .= $form; $actionsRight .= $form;
} }
$toolbar = Display::toolbarAction('toolbar-agenda', array( 0 => $actionsLeft, 1 => $actionsRight), 2, false); $toolbar = Display::toolbarAction(
'toolbar-agenda',
array(0 => $actionsLeft, 1 => $actionsRight),
2,
false
);
return $toolbar; return $toolbar;
} }

@ -64,7 +64,6 @@ class Attendance
*/ */
public function get_attendances_list($course_id = '', $session_id = null) public function get_attendances_list($course_id = '', $session_id = null)
{ {
// Initializing database table and variables
$tbl_attendance = Database :: get_course_table(TABLE_ATTENDANCE); $tbl_attendance = Database :: get_course_table(TABLE_ATTENDANCE);
$data = array(); $data = array();
@ -849,7 +848,6 @@ class Attendance
} }
// get count of presences by users inside current attendance and save like results // get count of presences by users inside current attendance and save like results
$count_presences = 0;
if (count($user_ids) > 0) { if (count($user_ids) > 0) {
foreach ($user_ids as $uid) { foreach ($user_ids as $uid) {
$count_presences = 0; $count_presences = 0;

@ -102,7 +102,9 @@ class Auth
{ {
$user_id = api_get_user_id(); $user_id = api_get_user_id();
$table_category = Database::get_main_table(TABLE_USER_COURSE_CATEGORY); $table_category = Database::get_main_table(TABLE_USER_COURSE_CATEGORY);
$sql = "SELECT * FROM " . $table_category . " WHERE user_id=$user_id ORDER BY sort ASC"; $sql = "SELECT * FROM " . $table_category . "
WHERE user_id=$user_id
ORDER BY sort ASC";
$result = Database::query($sql); $result = Database::query($sql);
$output = array(); $output = array();
while ($row = Database::fetch_array($result)) { while ($row = Database::fetch_array($result)) {

@ -124,10 +124,15 @@ class Blog
if ($info_count == 0) { if ($info_count == 0) {
// Create the blog // Create the blog
$sql = "INSERT INTO $tbl_blogs (c_id, blog_name, blog_subtitle, date_creation, visibility, session_id ) $params = [
VALUES ($course_id, '".Database::escape_string($title)."', '".Database::escape_string($subtitle)."', '".$current_date."', '1', '$session_id');"; 'c_id' => $course_id,
Database::query($sql); 'blog_name' => $title,
$this_blog_id = Database::insert_id(); 'blog_subtitle' => $subtitle,
'date_creation' => $current_date,
'visibility' => 1 ,
'session_id' => $session_id,
];
$this_blog_id = Database::insert($tbl_blogs, $params);
if ($this_blog_id > 0) { if ($this_blog_id > 0) {
@ -145,10 +150,16 @@ class Blog
} }
// Make first post. :) // Make first post. :)
$sql = "INSERT INTO $tbl_blogs_posts (c_id, title, full_text, date_creation, blog_id, author_id)
VALUES ($course_id, '".get_lang("Welcome")."', '" . get_lang('FirstPostText')."','".$current_date."', '".Database::escape_string((int)$this_blog_id)."', '".Database::escape_string((int)$_user['user_id'])."');"; $params = [
Database::query($sql); 'c_id' => $course_id,
$postId = Database::insert_id(); 'title' => get_lang("Welcome"),
'full_text' => get_lang('FirstPostText'),
'date_creation' => $current_date,
'blog_id' => $this_blog_id,
'author_id' => $_user['user_id'],
];
$postId = Database::insert($tbl_blogs_posts, $params);
if ($postId) { if ($postId) {
$sql = "UPDATE $tbl_blogs_posts SET post_id = iid WHERE iid = $postId"; $sql = "UPDATE $tbl_blogs_posts SET post_id = iid WHERE iid = $postId";
Database::query($sql); Database::query($sql);
@ -165,7 +176,6 @@ class Blog
Database::query($sql); Database::query($sql);
} }
// Subscribe the teacher to this blog // Subscribe the teacher to this blog
Blog::set_user_subscribed($this_blog_id, $_user['user_id']); Blog::set_user_subscribed($this_blog_id, $_user['user_id']);
} }
@ -180,8 +190,6 @@ class Blog
*/ */
public static function edit_blog($blog_id, $title, $subtitle) public static function edit_blog($blog_id, $title, $subtitle)
{ {
$_user = api_get_user_info();
// Table definitions // Table definitions
$tbl_blogs = Database::get_course_table(TABLE_BLOGS); $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
$tbl_tool = Database::get_course_table(TABLE_TOOL_LIST); $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST);
@ -197,7 +205,6 @@ class Blog
blog_id ='".Database::escape_string((int)$blog_id)."' blog_id ='".Database::escape_string((int)$blog_id)."'
LIMIT 1"; LIMIT 1";
Database::query($sql); Database::query($sql);
$this_blog_id = Database::insert_id();
//update item_property (update) //update item_property (update)
api_item_property_update( api_item_property_update(
@ -211,7 +218,7 @@ class Blog
// Update course homepage link // Update course homepage link
$sql = "UPDATE $tbl_tool SET $sql = "UPDATE $tbl_tool SET
name = '".Database::escape_string($title)."' name = '".Database::escape_string($title)."'
WHERE c_id = $course_id AND link = 'blog/blog.php?blog_id=".Database::escape_string((int)$blog_id)."' LIMIT 1"; WHERE c_id = $course_id AND link = 'blog/blog.php?blog_id=".(int)$blog_id."' LIMIT 1";
Database::query($sql); Database::query($sql);
} }
@ -357,7 +364,6 @@ class Blog
*/ */
public static function edit_post($post_id, $title, $full_text, $blog_id) public static function edit_post($post_id, $title, $full_text, $blog_id)
{ {
// Init
$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
@ -420,7 +426,7 @@ class Blog
$upload_ok = true; $upload_ok = true;
$has_attachment = false; $has_attachment = false;
$current_date = date('Y-m-d H:i:s', time()); $current_date = api_get_utc_datetime();
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
if (!empty($_FILES['user_upload']['name'])) { if (!empty($_FILES['user_upload']['name'])) {
@ -732,7 +738,6 @@ class Blog
{ {
$_user = api_get_user_info(); $_user = api_get_user_info();
// Init
$tbl_blogs = Database::get_course_table(TABLE_BLOGS); $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
$tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
@ -742,8 +747,10 @@ class Blog
if ($_user['user_id']) { if ($_user['user_id']) {
$sql = "SELECT task_rel_user.*, task.title, blog.blog_name $sql = "SELECT task_rel_user.*, task.title, blog.blog_name
FROM $tbl_blogs_tasks_rel_user task_rel_user FROM $tbl_blogs_tasks_rel_user task_rel_user
INNER JOIN $tbl_blogs_tasks task ON task_rel_user.task_id = task.task_id INNER JOIN $tbl_blogs_tasks task
INNER JOIN $tbl_blogs blog ON task_rel_user.blog_id = blog.blog_id ON task_rel_user.task_id = task.task_id
INNER JOIN $tbl_blogs blog
ON task_rel_user.blog_id = blog.blog_id
AND blog.blog_id = ".intval($_GET['blog_id'])." AND blog.blog_id = ".intval($_GET['blog_id'])."
WHERE WHERE
task.c_id = $course_id AND task.c_id = $course_id AND
@ -791,11 +798,11 @@ class Blog
// Change visibility state, remove from course home. // Change visibility state, remove from course home.
$sql = "UPDATE $tbl_blogs SET visibility = '0' $sql = "UPDATE $tbl_blogs SET visibility = '0'
WHERE c_id = $course_id AND blog_id ='".(int)$blog_id."' LIMIT 1"; WHERE c_id = $course_id AND blog_id ='".(int)$blog_id."' LIMIT 1";
$result = Database::query($sql); Database::query($sql);
$sql = "DELETE FROM $tbl_tool $sql = "DELETE FROM $tbl_tool
WHERE c_id = $course_id AND name = '".Database::escape_string($title)."' LIMIT 1"; WHERE c_id = $course_id AND name = '".Database::escape_string($title)."' LIMIT 1";
$result = Database::query($sql); Database::query($sql);
} else { } else {
// Change visibility state, add to course home. // Change visibility state, add to course home.
$sql = "UPDATE $tbl_blogs SET visibility = '1' $sql = "UPDATE $tbl_blogs SET visibility = '1'
@ -826,7 +833,6 @@ class Blog
$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
$tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
$tbl_users = Database::get_main_table(TABLE_MAIN_USER); $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
global $dateFormatLong;
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
@ -848,7 +854,10 @@ class Blog
// Get number of comments // Get number of comments
$sql = "SELECT COUNT(1) as number_of_comments $sql = "SELECT COUNT(1) as number_of_comments
FROM $tbl_blogs_comments FROM $tbl_blogs_comments
WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND post_id = '" . (int)$blog_post['post_id']."'"; WHERE
c_id = $course_id AND
blog_id = '".(int)$blog_id."' AND
post_id = '" . (int)$blog_post['post_id']."'";
$tmp = Database::query($sql); $tmp = Database::query($sql);
$blog_post_comments = Database::fetch_array($tmp); $blog_post_comments = Database::fetch_array($tmp);
@ -931,7 +940,6 @@ class Blog
*/ */
public static function display_day_results($blog_id, $query_string) public static function display_day_results($blog_id, $query_string)
{ {
// Init
$date_output = $query_string; $date_output = $query_string;
$date = explode('-',$query_string); $date = explode('-',$query_string);
$query_string = ' DAYOFMONTH(date_creation) =' . intval($date[2]) . ' AND MONTH(date_creation) =' . intval($date[1]) . ' AND YEAR(date_creation) =' . intval($date[0]); $query_string = ' DAYOFMONTH(date_creation) =' . intval($date[2]) . ' AND MONTH(date_creation) =' . intval($date[1]) . ' AND YEAR(date_creation) =' . intval($date[0]);
@ -952,7 +960,6 @@ class Blog
*/ */
public static function display_post($blog_id, $post_id) public static function display_post($blog_id, $post_id)
{ {
// Init
$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
$tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
$tbl_users = Database::get_main_table(TABLE_MAIN_USER); $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
@ -961,10 +968,11 @@ class Blog
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
// Get posts and author // Get posts and author
$sql = "SELECT post.*, user.lastname, user.firstname, user.username FROM $tbl_blogs_posts post $sql = "SELECT post.*, user.lastname, user.firstname, user.username
INNER JOIN $tbl_users user ON post.author_id = user.user_id FROM $tbl_blogs_posts post
INNER JOIN $tbl_users user
ON post.author_id = user.user_id
WHERE WHERE
post.c_id = $course_id AND post.c_id = $course_id AND
post.blog_id = '".(int)$blog_id."' AND post.blog_id = '".(int)$blog_id."' AND
@ -974,7 +982,8 @@ class Blog
$blog_post = Database::fetch_array($result); $blog_post = Database::fetch_array($result);
// Get number of comments // Get number of comments
$sql = "SELECT COUNT(1) as number_of_comments FROM $tbl_blogs_comments $sql = "SELECT COUNT(1) as number_of_comments
FROM $tbl_blogs_comments
WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND post_id = '".(int)$post_id."'"; WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND post_id = '".(int)$post_id."'";
$result = Database::query($sql); $result = Database::query($sql);
$blog_post_comments = Database::fetch_array($result); $blog_post_comments = Database::fetch_array($result);
@ -1057,18 +1066,19 @@ class Blog
// Check if the user has already rated this post/comment // Check if the user has already rated this post/comment
$sql = "SELECT rating_id FROM $tbl_blogs_rating $sql = "SELECT rating_id FROM $tbl_blogs_rating
WHERE c_id = $course_id AND WHERE
blog_id = '".(int)$blog_id."' c_id = $course_id AND
AND item_id = '".(int)$item_id."' blog_id = '".(int)$blog_id."' AND
AND rating_type = '".Database::escape_string($type)."' item_id = '".(int)$item_id."' AND
AND user_id = '".(int)$_user['user_id']."'"; rating_type = '".Database::escape_string($type)."' AND
user_id = '".(int)$_user['user_id']."'";
$result = Database::query($sql); $result = Database::query($sql);
// Add rating // Add rating
if (Database::num_rows($result) == 0) { if (Database::num_rows($result) == 0) {
$sql = "INSERT INTO $tbl_blogs_rating (c_id, blog_id, rating_type, item_id, user_id, rating ) $sql = "INSERT INTO $tbl_blogs_rating (c_id, blog_id, rating_type, item_id, user_id, rating )
VALUES ($course_id, '".(int)$blog_id."', '".Database::escape_string($type)."', '".(int)$item_id."', '".(int)$_user['user_id']."', '".Database::escape_string($rating)."')"; VALUES ($course_id, '".(int)$blog_id."', '".Database::escape_string($type)."', '".(int)$item_id."', '".(int)$_user['user_id']."', '".Database::escape_string($rating)."')";
$result = Database::query($sql); Database::query($sql);
$id = Database::insert_id(); $id = Database::insert_id();
if ($id) { if ($id) {
@ -1168,11 +1178,10 @@ class Blog
*/ */
public static function get_threaded_comments($current = 0, $current_level = 0, $blog_id, $post_id, $task_id = 0) public static function get_threaded_comments($current = 0, $current_level = 0, $blog_id, $post_id, $task_id = 0)
{ {
// Init
$tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS); $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
$tbl_users = Database::get_main_table(TABLE_MAIN_USER); $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
global $charset,$dateFormatLong; global $charset;
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
@ -1180,9 +1189,12 @@ class Blog
$next_level = $current_level + 1; $next_level = $current_level + 1;
$sql = "SELECT comments.*, user.lastname, user.firstname, user.username, task.color $sql = "SELECT comments.*, user.lastname, user.firstname, user.username, task.color
FROM $tbl_blogs_comments comments FROM $tbl_blogs_comments comments
INNER JOIN $tbl_users user ON comments.author_id = user.user_id INNER JOIN $tbl_users user
LEFT JOIN $tbl_blogs_tasks task ON comments.task_id = task.task_id AND task.c_id = $course_id ON comments.author_id = user.user_id
WHERE comments.c_id = $course_id AND LEFT JOIN $tbl_blogs_tasks task
ON comments.task_id = task.task_id AND task.c_id = $course_id
WHERE
comments.c_id = $course_id AND
parent_comment_id = $current AND parent_comment_id = $current AND
comments.blog_id = '".(int)$blog_id."' AND comments.blog_id = '".(int)$blog_id."' AND
comments.post_id = '".(int)$post_id."'"; comments.post_id = '".(int)$post_id."'";
@ -1190,8 +1202,10 @@ class Blog
while($comment = Database::fetch_array($result)) { while($comment = Database::fetch_array($result)) {
// Select the children recursivly // Select the children recursivly
$tmp = "SELECT comments.*, user.lastname, user.firstname, user.username FROM $tbl_blogs_comments comments $tmp = "SELECT comments.*, user.lastname, user.firstname, user.username
INNER JOIN $tbl_users user ON comments.author_id = user.user_id FROM $tbl_blogs_comments comments
INNER JOIN $tbl_users user
ON comments.author_id = user.user_id
WHERE WHERE
comments.c_id = $course_id AND comments.c_id = $course_id AND
comment_id = $current comment_id = $current
@ -1306,7 +1320,6 @@ class Blog
$blog_post = Database::fetch_array($result); $blog_post = Database::fetch_array($result);
// Form // Form
$form = new FormValidator( $form = new FormValidator(
'edit_post', 'edit_post',
'post', 'post',
@ -1343,7 +1356,6 @@ class Blog
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) { if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) {
// Init
$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
$counter = 0; $counter = 0;
global $color2; global $color2;
@ -1438,7 +1450,8 @@ class Blog
FROM $tbl_blogs_tasks_rel_user task_rel_user FROM $tbl_blogs_tasks_rel_user task_rel_user
INNER JOIN $tbl_blogs_tasks task ON task_rel_user.task_id = task.task_id INNER JOIN $tbl_blogs_tasks task ON task_rel_user.task_id = task.task_id
INNER JOIN $tbl_users user ON task_rel_user.user_id = user.user_id INNER JOIN $tbl_users user ON task_rel_user.user_id = user.user_id
WHERE task_rel_user.c_id = $course_id AND WHERE
task_rel_user.c_id = $course_id AND
task.c_id = $course_id AND task.c_id = $course_id AND
task_rel_user.blog_id = '".(int)$blog_id."' task_rel_user.blog_id = '".(int)$blog_id."'
ORDER BY target_date ASC"; ORDER BY target_date ASC";
@ -1531,22 +1544,22 @@ class Blog
' . get_lang('TaskManager') . ' ' . get_lang('TaskManager') . '
</label> </label>
<div class="controls">'; <div class="controls">';
echo "\t\t\t" . '<table class="data_table" cellspacing="0" style="border-collapse:collapse; width:446px;">'; echo '<table class="data_table" cellspacing="0" style="border-collapse:collapse; width:446px;">';
echo "\t\t\t\t" . '<tr>'; echo '<tr>';
echo '<th colspan="2" style="width:223px;">' . get_lang('ArticleManager') . '</th>'; echo '<th colspan="2" style="width:223px;">' . get_lang('ArticleManager') . '</th>';
echo '<th width:223px;>' . get_lang('CommentManager') . '</th>'; echo '<th width:223px;>' . get_lang('CommentManager') . '</th>';
echo "\t\t\t\t" . '</tr>'; echo '</tr>';
echo "\t\t\t\t" . '<tr>'; echo '<tr>';
echo '<th style="width:111px;"><label for="articleDelete">' . get_lang('Delete') . '</label></th>'; echo '<th style="width:111px;"><label for="articleDelete">' . get_lang('Delete') . '</label></th>';
echo '<th style="width:112px;"><label for="articleEdit">' . get_lang('Edit') . '</label></th>'; echo '<th style="width:112px;"><label for="articleEdit">' . get_lang('Edit') . '</label></th>';
echo '<th style="width:223px;"><label for="commentsDelete">' . get_lang('Delete') . '</label></th>'; echo '<th style="width:223px;"><label for="commentsDelete">' . get_lang('Delete') . '</label></th>';
echo "\t\t\t\t" . '</tr>'; echo '</tr>';
echo "\t\t\t\t" . '<tr>'; echo '<tr>';
echo '<td style="text-align:center;"><input id="articleDelete" name="chkArticleDelete" type="checkbox" /></td>'; echo '<td style="text-align:center;"><input id="articleDelete" name="chkArticleDelete" type="checkbox" /></td>';
echo '<td style="text-align:center;"><input id="articleEdit" name="chkArticleEdit" type="checkbox" /></td>'; echo '<td style="text-align:center;"><input id="articleEdit" name="chkArticleEdit" type="checkbox" /></td>';
echo '<td style="border:1px dotted #808080; text-align:center;"><input id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>'; echo '<td style="border:1px dotted #808080; text-align:center;"><input id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>';
echo "\t\t\t\t" . '</tr>'; echo '</tr>';
echo "\t\t\t" . '</table>'; echo '</table>';
echo ' </div> echo ' </div>
</div>'; </div>';
@ -1558,8 +1571,7 @@ class Blog
</label> </label>
<div class="controls">'; <div class="controls">';
echo '<select name="task_color" id="color" style="width: 150px; background-color: #eeeeee" onchange="document.getElementById(\'color\').style.backgroundColor=\'#\'+document.getElementById(\'color\').value" onkeypress="document.getElementById(\'color\').style.backgroundColor=\'#\'+document.getElementById(\'color\').value">'; echo '<select name="task_color" id="color" style="width: 150px; background-color: #eeeeee" onchange="document.getElementById(\'color\').style.backgroundColor=\'#\'+document.getElementById(\'color\').value" onkeypress="document.getElementById(\'color\').style.backgroundColor=\'#\'+document.getElementById(\'color\').value">';
foreach ($colors as $color) foreach ($colors as $color) {
{
$style = 'style="background-color: #' . $color . '"'; $style = 'style="background-color: #' . $color . '"';
echo '<option value="' . $color . '" ' . $style . '>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>'; echo '<option value="' . $color . '" ' . $style . '>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>';
} }
@ -1575,7 +1587,6 @@ class Blog
<button class="save" type="submit" name="Submit">' . get_lang('Save') . '</button> <button class="save" type="submit" name="Submit">' . get_lang('Save') . '</button>
</div> </div>
</div>'; </div>';
echo '</form>'; echo '</form>';
echo '<div style="clear:both; margin-bottom: 10px;"></div>'; echo '<div style="clear:both; margin-bottom: 10px;"></div>';
@ -1622,35 +1633,34 @@ class Blog
while ($row = Database::fetch_array($result)) while ($row = Database::fetch_array($result))
$arrPermissions[] = $row['action']; $arrPermissions[] = $row['action'];
echo "\t" . '<tr>'; echo '<tr>';
echo "\t\t" . '<td style="text-align:right; vertical-align:top;">' . get_lang('TaskManager') . ':&nbsp;&nbsp;</td>'; echo '<td style="text-align:right; vertical-align:top;">' . get_lang('TaskManager') . ':&nbsp;&nbsp;</td>';
echo "\t\t" . '<td>'; echo '<td>';
echo "\t\t\t" . '<table class="data_table" cellspacing="0" style="border-collapse:collapse; width:446px;">'; echo '<table class="data_table" cellspacing="0" style="border-collapse:collapse; width:446px;">';
echo "\t\t\t\t" . '<tr>'; echo '<tr>';
echo '<th colspan="2" style="width:223px;">' . get_lang('ArticleManager') . '</th>'; echo '<th colspan="2" style="width:223px;">' . get_lang('ArticleManager') . '</th>';
echo '<th width:223px;>' . get_lang('CommentManager') . '</th>'; echo '<th width:223px;>' . get_lang('CommentManager') . '</th>';
echo "\t\t\t\t" . '</tr>'; echo '</tr>';
echo "\t\t\t\t" . '<tr>'; echo '<tr>';
echo '<th style="width:111px;"><label for="articleDelete">' . get_lang('Delete') . '</label></th>'; echo '<th style="width:111px;"><label for="articleDelete">' . get_lang('Delete') . '</label></th>';
echo '<th style="width:112px;"><label for="articleEdit">' . get_lang('Edit') . '</label></th>'; echo '<th style="width:112px;"><label for="articleEdit">' . get_lang('Edit') . '</label></th>';
echo '<th style="width:223px;"><label for="commentsDelete">' . get_lang('Delete') . '</label></th>'; echo '<th style="width:223px;"><label for="commentsDelete">' . get_lang('Delete') . '</label></th>';
echo "\t\t\t\t" . '</tr>'; echo '</tr>';
echo "\t\t\t\t" . '<tr>'; echo '<tr>';
echo '<td style="text-align:center;"><input ' . ((in_array('article_delete', $arrPermissions)) ? 'checked ' : '') . 'id="articleDelete" name="chkArticleDelete" type="checkbox" /></td>'; echo '<td style="text-align:center;"><input ' . ((in_array('article_delete', $arrPermissions)) ? 'checked ' : '') . 'id="articleDelete" name="chkArticleDelete" type="checkbox" /></td>';
echo '<td style="text-align:center;"><input ' . ((in_array('article_edit', $arrPermissions)) ? 'checked ' : '') . 'id="articleEdit" name="chkArticleEdit" type="checkbox" /></td>'; echo '<td style="text-align:center;"><input ' . ((in_array('article_edit', $arrPermissions)) ? 'checked ' : '') . 'id="articleEdit" name="chkArticleEdit" type="checkbox" /></td>';
echo '<td style="text-align:center;"><input ' . ((in_array('article_comments_delete', $arrPermissions)) ? 'checked ' : '') . 'id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>'; echo '<td style="text-align:center;"><input ' . ((in_array('article_comments_delete', $arrPermissions)) ? 'checked ' : '') . 'id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>';
echo "\t\t\t\t" . '</tr>'; echo '</tr>';
echo "\t\t\t" . '</table>'; echo '</table>';
echo "\t\t" . '</td>'; echo '</td>';
echo "\t" . '</tr>'; echo '</tr>';
/* end of edit */ /* end of edit */
echo '<tr> echo '<tr>
<td align="right">' . get_lang('Color') . ':&nbsp;&nbsp;</td> <td align="right">' . get_lang('Color') . ':&nbsp;&nbsp;</td>
<td> <td>
<select name="task_color" id="color" style="width: 150px; background-color: #' . $task['color'] . '" onchange="document.getElementById(\'color\').style.backgroundColor=\'#\'+document.getElementById(\'color\').value" onkeypress="document.getElementById(\'color\').style.backgroundColor=\'#\'+document.getElementById(\'color\').value">'; <select name="task_color" id="color" style="width: 150px; background-color: #' . $task['color'] . '" onchange="document.getElementById(\'color\').style.backgroundColor=\'#\'+document.getElementById(\'color\').value" onkeypress="document.getElementById(\'color\').style.backgroundColor=\'#\'+document.getElementById(\'color\').value">';
foreach ($colors as $color) foreach ($colors as $color) {
{
$selected = ($color == $task['color']) ? ' selected' : ''; $selected = ($color == $task['color']) ? ' selected' : '';
$style = 'style="background-color: #' . $color . '"'; $style = 'style="background-color: #' . $color . '"';
echo '<option value="' . $color . '" ' . $style . ' ' . $selected . ' >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>'; echo '<option value="' . $color . '" ' . $style . ' ' . $selected . ' >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>';
@ -1676,7 +1686,6 @@ class Blog
*/ */
public static function getTaskForm($blog_id) public static function getTaskForm($blog_id)
{ {
// Init
$tbl_users = Database::get_main_table(TABLE_MAIN_USER); $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
$tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
@ -1692,7 +1701,6 @@ class Blog
$options = array(); $options = array();
while ($user = Database::fetch_array($result)) { while ($user = Database::fetch_array($result)) {
$username = api_htmlentities(sprintf(get_lang('LoginX'), $user['username']), ENT_QUOTES);
$options[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']); $options[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']);
} }
@ -1706,7 +1714,7 @@ class Blog
description, description,
color, color,
system_task system_task
FROM " . $tbl_blogs_tasks . " FROM $tbl_blogs_tasks
WHERE c_id = $course_id AND blog_id = " . (int)$blog_id . " WHERE c_id = $course_id AND blog_id = " . (int)$blog_id . "
ORDER BY system_task, title"; ORDER BY system_task, title";
$result = Database::query($sql); $result = Database::query($sql);
@ -1731,6 +1739,7 @@ class Blog
$form->addHidden('action', ''); $form->addHidden('action', '');
$form->addButtonSave(get_lang('Ok')); $form->addButtonSave(get_lang('Ok'));
return $form; return $form;
} }
@ -1754,9 +1763,6 @@ class Blog
*/ */
public static function display_edit_assigned_task_form($blog_id, $task_id, $user_id) public static function display_edit_assigned_task_form($blog_id, $task_id, $user_id)
{ {
$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
$tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
$tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER); $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
@ -1829,7 +1835,7 @@ class Blog
'" . Database::escape_string($target_date) . "' '" . Database::escape_string($target_date) . "'
)"; )";
$result = Database::query($sql); Database::query($sql);
} }
} }
@ -1881,8 +1887,7 @@ class Blog
task_id = " . (int)$old_task_id . " AND task_id = " . (int)$old_task_id . " AND
target_date = '" . Database::escape_string($old_target_date) . "' target_date = '" . Database::escape_string($old_target_date) . "'
"; ";
Database::query($sql);
$result = @Database::query($sql);
} }
} }
@ -1894,7 +1899,6 @@ class Blog
*/ */
public static function display_select_task_post($blog_id, $task_id) public static function display_select_task_post($blog_id, $task_id)
{ {
// Init
$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS); $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS); $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
$tbl_users = Database::get_main_table(TABLE_MAIN_USER); $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
@ -1947,12 +1951,12 @@ class Blog
// Subscribe the user // Subscribe the user
$sql = "INSERT INTO $tbl_blogs_rel_user (c_id, blog_id, user_id ) $sql = "INSERT INTO $tbl_blogs_rel_user (c_id, blog_id, user_id )
VALUES ($course_id, '".(int)$blog_id."', '".(int)$user_id."');"; VALUES ($course_id, '".(int)$blog_id."', '".(int)$user_id."');";
$result = Database::query($sql); Database::query($sql);
// Give this user basic rights // Give this user basic rights
$sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action) $sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action)
VALUES ($course_id, '".(int)$user_id."','BLOG_" . (int)$blog_id."','article_add')"; VALUES ($course_id, '".(int)$user_id."','BLOG_" . (int)$blog_id."','article_add')";
$result = Database::query($sql); Database::query($sql);
$id = Database::insert_id(); $id = Database::insert_id();
if ($id) { if ($id) {
@ -1962,7 +1966,7 @@ class Blog
$sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action) $sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action)
VALUES ($course_id, '".(int)$user_id."','BLOG_" . (int)$blog_id."','article_comments_add')"; VALUES ($course_id, '".(int)$user_id."','BLOG_" . (int)$blog_id."','article_comments_add')";
$result = Database::query($sql); Database::query($sql);
$id = Database::insert_id(); $id = Database::insert_id();
if ($id) { if ($id) {
@ -1988,12 +1992,12 @@ class Blog
// Unsubscribe the user // Unsubscribe the user
$sql = "DELETE FROM $tbl_blogs_rel_user $sql = "DELETE FROM $tbl_blogs_rel_user
WHERE blog_id = '".(int)$blog_id."' AND user_id = '".(int)$user_id."'"; WHERE blog_id = '".(int)$blog_id."' AND user_id = '".(int)$user_id."'";
$result = Database::query($sql); Database::query($sql);
// Remove this user's permissions. // Remove this user's permissions.
$sql = "DELETE FROM $tbl_user_permissions $sql = "DELETE FROM $tbl_user_permissions
WHERE user_id = '".(int)$user_id."'"; WHERE user_id = '".(int)$user_id."'";
$result = Database::query($sql); Database::query($sql);
} }
/** /**
@ -2214,11 +2218,8 @@ class Blog
* *
* @param Integer $blog_id * @param Integer $blog_id
*/ */
public static function display_form_user_rights ($blog_id) { public static function display_form_user_rights ($blog_id)
// Init {
$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
$tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
echo '<legend>'.get_lang('RightsManager').'</legend>'; echo '<legend>'.get_lang('RightsManager').'</legend>';
echo '<br />'; echo '<br />';
@ -2461,7 +2462,9 @@ class Blog
$blog_id= intval($blog_id); $blog_id= intval($blog_id);
$tbl_blogs = Database::get_course_table(TABLE_BLOGS); $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
$sql = "SELECT blog_id, blog_name, blog_subtitle FROM $tbl_blogs WHERE c_id = $course_id AND blog_id = '".$blog_id."'"; $sql = "SELECT blog_id, blog_name, blog_subtitle
FROM $tbl_blogs
WHERE c_id = $course_id AND blog_id = '".$blog_id."'";
$result = Database::query($sql); $result = Database::query($sql);
$blog = Database::fetch_array($result); $blog = Database::fetch_array($result);
@ -2490,12 +2493,11 @@ class Blog
/** /**
* Blog admin | Returns table with blogs in this course * Blog admin | Returns table with blogs in this course
*/ */
public static function display_blog_list () { public static function display_blog_list()
{
global $charset; global $charset;
$_user = api_get_user_info(); $_user = api_get_user_info();
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
// Init
$counter = 0;
$tbl_blogs = Database::get_course_table(TABLE_BLOGS); $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
@ -2516,7 +2518,6 @@ class Blog
$list_content_blog = array(); $list_content_blog = array();
$list_body_blog = array(); $list_body_blog = array();
$_user = api_get_user_info();
if (is_array($list_info)) { if (is_array($list_info)) {
foreach ($list_info as $key => $info_log) { foreach ($list_info as $key => $info_log) {
@ -2599,7 +2600,8 @@ function get_blog_attachment($blog_id, $post_id=null,$comment_id=null)
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
$sql = 'SELECT path, filename, comment FROM '. $blog_table_attachment.' WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; $sql = 'SELECT path, filename, comment FROM '. $blog_table_attachment.'
WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where;
$result=Database::query($sql); $result=Database::query($sql);
if (Database::num_rows($result)!=0) { if (Database::num_rows($result)!=0) {
@ -2629,15 +2631,12 @@ function delete_all_blog_attachment($blog_id,$post_id=null,$comment_id=null)
$where = null; $where = null;
// delete files in DB // delete files in DB
if (!empty ($post_id) && is_numeric($post_id) ) if (!empty ($post_id) && is_numeric($post_id)) {
{
$where .= ' AND post_id ="'.$post_id.'" '; $where .= ' AND post_id ="'.$post_id.'" ';
} }
if (!empty ($comment_id) && is_numeric($comment_id) ) if (!empty ($comment_id) && is_numeric($comment_id)) {
{ if (!empty ($post_id)) {
if (!empty ($post_id) )
{
$where .= ' AND '; $where .= ' AND ';
} }
$where .= ' comment_id ="'.$comment_id.'" '; $where .= ' comment_id ="'.$comment_id.'" ';
@ -2659,7 +2658,8 @@ function delete_all_blog_attachment($blog_id,$post_id=null,$comment_id=null)
@ unlink($file); @ unlink($file);
} }
} }
$sql = 'DELETE FROM '. $blog_table_attachment.' WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where; $sql = 'DELETE FROM '. $blog_table_attachment.'
WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'" '.$where;
Database::query($sql); Database::query($sql);
} }
@ -2676,7 +2676,8 @@ function get_blog_post_from_user($course_code, $user_id)
$course_id = $course_info['real_id']; $course_id = $course_info['real_id'];
$sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation $sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation
FROM $tbl_blogs blog INNER JOIN $tbl_blog_post post FROM $tbl_blogs blog
INNER JOIN $tbl_blog_post post
ON (blog.blog_id = post.blog_id) ON (blog.blog_id = post.blog_id)
WHERE WHERE
blog.c_id = $course_id AND blog.c_id = $course_id AND

@ -323,7 +323,6 @@ class Certificate extends Model
*/ */
public function parse_certificate_variables($array) public function parse_certificate_variables($array)
{ {
$text = '';
$headers = $array[0]; $headers = $array[0];
$content = $array[1]; $content = $array[1];
$final_content = array(); $final_content = array();
@ -361,6 +360,7 @@ class Certificate extends Model
get_lang('Date'). ': '.$final_content['date_certificate'].$break_space. get_lang('Date'). ': '.$final_content['date_certificate'].$break_space.
get_lang('Score'). ': '.$final_content['gradebook_grade'].$break_space. get_lang('Score'). ': '.$final_content['gradebook_grade'].$break_space.
'URL'. ': '.$final_content['certificate_link']; 'URL'. ': '.$final_content['certificate_link'];
return $text; return $text;
} }

@ -339,7 +339,8 @@ class CourseDescription
/** /**
* Get description id by description type * Get description id by description type
* @param int description type * @param int $description_type
*
* @return int description id * @return int description id
*/ */
public function get_id_by_description_type($description_type) public function get_id_by_description_type($description_type)

@ -994,8 +994,6 @@ class CourseHome
*/ */
public static function show_session_data($id_session) public static function show_session_data($id_session)
{ {
$session_table = Database::get_main_table(TABLE_MAIN_SESSION);
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$session_category_table = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY); $session_category_table = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
$sessionInfo = api_get_session_info($id_session); $sessionInfo = api_get_session_info($id_session);
@ -1332,9 +1330,7 @@ class CourseHome
/** /**
* @param int $id * @param int $id
* @param int $courseId * @param array $values
* @param int $sessionId
* @param $values
*/ */
public static function updateTool($id, $values) public static function updateTool($id, $values)
{ {

@ -37,6 +37,7 @@ class CourseRequestManager
$wanted_course_code $wanted_course_code
); );
$result = Database::fetch_array(Database::query($sql)); $result = Database::fetch_array(Database::query($sql));
return $result['number'] > 0; return $result['number'] > 0;
} }
@ -349,7 +350,8 @@ class CourseRequestManager
public static function delete_course_request($id) public static function delete_course_request($id)
{ {
$id = (int)$id; $id = (int)$id;
$sql = "DELETE FROM ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)." WHERE id = ".$id; $sql = "DELETE FROM ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)."
WHERE id = ".$id;
$result = Database::query($sql); $result = Database::query($sql);
return $result !== false; return $result !== false;
} }
@ -365,7 +367,8 @@ class CourseRequestManager
$sql = "SELECT COUNT(id) AS number FROM ".$course_table; $sql = "SELECT COUNT(id) AS number FROM ".$course_table;
} else { } else {
$status = (int)$status; $status = (int)$status;
$sql = "SELECT COUNT(id) AS number FROM ".$course_table." WHERE status = ".$status; $sql = "SELECT COUNT(id) AS number FROM ".$course_table."
WHERE status = ".$status;
} }
$result = Database::fetch_array(Database::query($sql)); $result = Database::fetch_array(Database::query($sql));
if (is_array($result)) { if (is_array($result)) {

@ -26,7 +26,7 @@ class DashboardManager
/* We scan the plugin directory. Each folder is a potential plugin. */ /* We scan the plugin directory. Each folder is a potential plugin. */
$dashboard_pluginpath = api_get_path(SYS_PLUGIN_PATH).'dashboard/'; $dashboard_pluginpath = api_get_path(SYS_PLUGIN_PATH).'dashboard/';
$possibleplugins = self::get_posible_dashboard_plugins_path(); $possibleplugins = self::getPossibleDashboardPluginsPath();
$table_cols = array('name', 'version', 'description'); $table_cols = array('name', 'version', 'description');
echo Display::page_subheader(get_lang('DashboardPlugins')); echo Display::page_subheader(get_lang('DashboardPlugins'));
@ -141,7 +141,7 @@ class DashboardManager
// get all plugins path inside plugin directory // get all plugins path inside plugin directory
$dashboard_pluginpath = api_get_path(SYS_PLUGIN_PATH).'dashboard/'; $dashboard_pluginpath = api_get_path(SYS_PLUGIN_PATH).'dashboard/';
$possibleplugins = self::get_posible_dashboard_plugins_path(); $possibleplugins = self::getPossibleDashboardPluginsPath();
if (count($possibleplugins) > 0) { if (count($possibleplugins) > 0) {
@ -251,7 +251,7 @@ class DashboardManager
* Get all plugins path inside dashboard directory * Get all plugins path inside dashboard directory
* @return array name plugins directories * @return array name plugins directories
*/ */
public static function get_posible_dashboard_plugins_path() { public static function getPossibleDashboardPluginsPath() {
// get all plugins path inside plugin directory // get all plugins path inside plugin directory
/* We scan the plugin directory. Each folder is a potential plugin. */ /* We scan the plugin directory. Each folder is a potential plugin. */
@ -274,7 +274,7 @@ class DashboardManager
public static function get_block_data_without_plugin() { public static function get_block_data_without_plugin() {
$tbl_block = Database :: get_main_table(TABLE_MAIN_BLOCK); $tbl_block = Database :: get_main_table(TABLE_MAIN_BLOCK);
$possibleplugins = self::get_posible_dashboard_plugins_path(); $possibleplugins = self::getPossibleDashboardPluginsPath();
// We check if plugin exists inside directory for updating active field // We check if plugin exists inside directory for updating active field
$sql = "SELECT * FROM $tbl_block"; $sql = "SELECT * FROM $tbl_block";
@ -311,7 +311,8 @@ class DashboardManager
* @param string plugin path * @param string plugin path
* @return array data * @return array data
*/ */
public static function get_enabled_dashboard_blocks($path = '') { public static function get_enabled_dashboard_blocks($path = '')
{
$tbl_block = Database :: get_main_table(TABLE_MAIN_BLOCK); $tbl_block = Database :: get_main_table(TABLE_MAIN_BLOCK);
$condition_path = ''; $condition_path = '';
if (!empty($path)) { if (!empty($path)) {
@ -505,7 +506,6 @@ class DashboardManager
$upd_extra_field = self::store_user_blocks($user_id, $user_blocks_id, $columns); $upd_extra_field = self::store_user_blocks($user_id, $user_blocks_id, $columns);
return $upd_extra_field; return $upd_extra_field;
} }
/** /**

@ -1,10 +1,5 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/**
* This class provides methods for the notebook management.
* Include/require it in your code to use its features.
* @package chamilo.library
*/
/** /**
* Class EventEmailTemplate * Class EventEmailTemplate
@ -58,10 +53,10 @@ class EventEmailTemplate extends Model
/** /**
* Returns a Form validator Obj * Returns a Form validator Obj
* @todo the form should be auto generated * @param string $url
* @param string url * @param string $action add, edit
* @param string action add, edit *
* @return obj form validator obj * @return FormValidator
*/ */
public function return_form($url, $action) public function return_form($url, $action)
{ {
@ -114,6 +109,7 @@ class EventEmailTemplate extends Model
// Setting the rules // Setting the rules
$form->addRule('name', get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
return $form; return $form;
} }

@ -29,7 +29,7 @@ class Export
/** /**
* Constructor * Constructor
*/ */
private function __construct() public function __construct()
{ {
} }

@ -140,7 +140,7 @@ class Redirect
*/ */
protected static function navigate($url) protected static function navigate($url)
{ {
session_write_close(); //should not be neeeded session_write_close(); //should not be needed
header("Location: $url"); header("Location: $url");
exit; exit;
} }

@ -7914,8 +7914,8 @@ class learnpath
$return .= '<tr>'; $return .= '<tr>';
$return .= '<td class="label"><label for="idParent">' . get_lang('Parent') . '</label></td>'; $return .= '<td class="label"><label for="idParent">' . get_lang('Parent') . '</label></td>';
$return .= '<td class="input">'; $return .= '<td class="input">';
$return .= "\t\t\t\t" . '<select id="idParent" name="parent" style="width:100%;" onChange="javascript: load_cbo(this.value);" class="learnpath_item_form" size="1">'; $return .= '<select id="idParent" name="parent" style="width:100%;" onChange="javascript: load_cbo(this.value);" class="learnpath_item_form" size="1">';
//$parent_item_id = $_SESSION['parent_item_id'];
$return .= '<option class="top" value="0">' . $this->name . '</option>'; $return .= '<option class="top" value="0">' . $this->name . '</option>';
$arrHide = array ( $arrHide = array (
$id $id
@ -7979,35 +7979,14 @@ class learnpath
} }
} }
// Commented the prerequisites, only visible in edit (work).
/*
$return .= '<tr>';
$return .= '<td class="label"><label for="idPrerequisites">'.get_lang('LearnpathPrerequisites').'</label></td>';
$return .= '<td class="input"><select name="prerequisites" id="prerequisites" class="learnpath_item_form"><option value="0">'.get_lang('NoPrerequisites').'</option>';
foreach($arrHide as $key => $value) {
if ($key == $s_selected_position && $action == 'add') {
$return .= '<option value="'.$key.'" selected="selected">'.$value['value'].'</option>';
}
elseif ($key == $id_prerequisite && $action == 'edit') {
$return .= '<option value="'.$key.'" selected="selected">'.$value['value'].'</option>';
}
else {
$return .= '<option value="'.$key.'">'.$value['value'].'</option>';
}
}
$return .= "</select></td>";
*/
$return .= '</tr>'; $return .= '</tr>';
} }
$return .= '<tr>'; $return .= '<tr>';
if ($action == 'add') { if ($action == 'add') {
$return .= '<td>&nbsp</td><td><button class="save" name="submit_button" type="submit">' . get_lang('AddAssignmentToCourse') . '</button></td>'; $return .= '<td>&nbsp</td><td><button class="btn btn-primary" name="submit_button" type="submit">' . get_lang('AddAssignmentToCourse') . '</button></td>';
} else { } else {
$return .= '<td>&nbsp</td><td><button class="save" name="submit_button" type="submit">' . get_lang('EditCurrentStudentPublication') . '</button></td>'; $return .= '<td>&nbsp</td><td><button class="btn btn-primary" name="submit_button" type="submit">' . get_lang('EditCurrentStudentPublication') . '</button></td>';
} }
$return .= '</tr>'; $return .= '</tr>';
$return .= '</table>'; $return .= '</table>';

@ -9,9 +9,31 @@
/** /**
* Init * Init
*/ */
$rights_full=array("article_add","article_delete","article_edit","article_rate","article_comments_add","article_comments_delete","article_comments_rate","task_management","member_management","role_management"); $rights_full = array(
"article_add",
"article_delete",
"article_edit",
"article_rate",
"article_comments_add",
"article_comments_delete",
"article_comments_rate",
"task_management",
"member_management",
"role_management",
);
$rights_limited = array("Add", "Edit", "Delete"); $rights_limited = array("Add", "Edit", "Delete");
$rights_blog=array("article_add","article_delete","article_edit","article_rate","article_comments_add","article_comments_delete","article_comments_rate","task_management","member_management","role_management"); $rights_blog = array(
"article_add",
"article_delete",
"article_edit",
"article_rate",
"article_comments_add",
"article_comments_delete",
"article_comments_rate",
"task_management",
"member_management",
"role_management",
);
$course_tool_table = Database::get_course_table(TABLE_TOOL_LIST); $course_tool_table = Database::get_course_table(TABLE_TOOL_LIST);
// Get all user // Get all user
@ -31,32 +53,32 @@ while ($user = Database::fetch_assoc($result)) {
} }
//$user_id=$userIdViewed; //$user_id=$userIdViewed;
if ($mainUserInfo['status']==1) if ($mainUserInfo['status'] == 1) {
{
$course_admin = 1; $course_admin = 1;
} }
include_once('permissions_functions.inc.php'); include_once('permissions_functions.inc.php');
include_once(api_get_path(LIBRARY_PATH) . "/groupmanager.lib.php");
// ACTIONS // ACTIONS
if (isset($_GET['do'])) if (isset($_GET['do'])) {
{ if (isset($_GET['permission']) AND isset($_GET['tool']) AND ($_GET['do'] == 'grant' OR $_GET['do'] == 'revoke')) {
if ( isset($_GET['permission']) AND isset($_GET['tool']) AND ($_GET['do']=='grant' OR $_GET['do']=='revoke')) $result_message = store_one_permission(
{ 'user',
$result_message=store_one_permission('user', $_GET['do'], $_GET['user_id'], $_GET['tool'], $_GET['permission']); $_GET['do'],
} $_GET['user_id'],
if (isset($_GET['role']) AND ($_GET['do']=='grant' OR $_GET['do']=='revoke')) $_GET['tool'],
{ $_GET['permission']
$result_message=assign_role('user', $_GET['do'], $user_id, $_GET['role'], $_GET['scope']); );
} }
if (isset($_GET['role']) AND ($_GET['do'] == 'grant' OR $_GET['do'] == 'revoke')) {
$result_message = assign_role(
'user',
$_GET['do'],
$user_id,
$_GET['role'],
$_GET['scope']
);
} }
/*
if (isset($result_message))
{
Display::display_normal_message($result_message);
} }
*/
// ------------------------------------------------------------------ // ------------------------------------------------------------------
// RETRIEVING THE PERMISSIONS OF THE ROLES OF THE USER // RETRIEVING THE PERMISSIONS OF THE ROLES OF THE USER
@ -80,17 +102,14 @@ if (api_get_setting('user_roles')=='true') {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
// RETRIEVING THE PERMISSIONS OF THE ROLES OF THE GROUPS OF THE USER // RETRIEVING THE PERMISSIONS OF THE ROLES OF THE GROUPS OF THE USER
// ------------------------------------------------------------------ // ------------------------------------------------------------------
if (api_get_setting('group_roles')=='true') if (api_get_setting('group_roles')=='true') {
{
// NOTE: DIT MOET NOG VERDER UITGEWERKT WORDEN // NOTE: DIT MOET NOG VERDER UITGEWERKT WORDEN
foreach ($groups_of_user as $group) foreach ($groups_of_user as $group) {
{
$this_current_group_role_permissions_of_user=get_roles_permissions('user',$user_id); $this_current_group_role_permissions_of_user=get_roles_permissions('user',$user_id);
//$inherited_permissions[$tool][]=$permission; //$inherited_permissions[$tool][]=$permission;
} }
} }
echo "<form method=\"post\" action=\"".str_replace('&', '&amp;', $_SERVER['REQUEST_URI'])."\">"; echo "<form method=\"post\" action=\"".str_replace('&', '&amp;', $_SERVER['REQUEST_URI'])."\">";
// --------------------------------------------------- // ---------------------------------------------------

Loading…
Cancel
Save