From d2e69f8207c2b46d8b8a58c80200c2a950bfa38c Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 7 Jun 2012 14:11:20 +0200 Subject: [PATCH] Minor usergroup fixes --- main/admin/add_users_to_usergroup.php | 60 +++++---- main/admin/group_add.php | 18 +-- main/admin/usergroups.php | 39 +++--- main/inc/lib/group_portal_manager.lib.php | 67 +++++----- main/inc/lib/usergroup.lib.php | 146 +++++++++++----------- 5 files changed, 163 insertions(+), 167 deletions(-) diff --git a/main/admin/add_users_to_usergroup.php b/main/admin/add_users_to_usergroup.php index d5c98b3c4e..765788dfe1 100644 --- a/main/admin/add_users_to_usergroup.php +++ b/main/admin/add_users_to_usergroup.php @@ -13,7 +13,6 @@ $cidReset = true; // including some necessary files require_once '../inc/global.inc.php'; require_once '../inc/lib/xajax/xajax.inc.php'; -require_once api_get_path(LIBRARY_PATH).'usergroup.lib.php'; // setting the section (for the tabs) $this_section = SECTION_PLATFORM_ADMIN; @@ -36,7 +35,7 @@ if(isset($_REQUEST['add_type']) && $_REQUEST['add_type']!=''){ } $htmlHeadXtra[] = ' -'; // Database table definitions -$table_admin = Database :: get_main_table(TABLE_MAIN_ADMIN); -$table_user = Database :: get_main_table(TABLE_MAIN_USER); -$database = Database::get_main_database(); - if (!empty($_GET['message'])) { $message = urldecode($_GET['message']); } @@ -49,7 +44,7 @@ $tool_name = get_lang('AddGroups'); // Create the form $form = new FormValidator('group_add'); -$form->addElement('header', '', $tool_name); +$form->addElement('header', $tool_name); // name $form->addElement('text', 'name', get_lang('Name'), array('size'=>60, 'maxlength'=>120)); @@ -108,11 +103,10 @@ if( $form->validate()) { $url = $values['url']; $status = intval($values['visibility']); $picture = $_FILES['picture']; - $parent_group_id = intval($values['parent_group']); + $parent_group_id = intval($values['parent_group']); $group_id = GroupPortalManager::add($name, $description, $url, $status); - GroupPortalManager::set_parent_group($group_id,$parent_group_id); - + GroupPortalManager::set_parent_group($group_id,$parent_group_id); if (!empty($picture['name'])) { $picture_uri = GroupPortalManager::update_group_picture($group_id, $_FILES['picture']['name'], $_FILES['picture']['tmp_name']); @@ -144,7 +138,7 @@ if( $form->validate()) { Security::clear_token(); $tok = Security::get_token(); header('Location: group_list.php?action=show_message&message='.urlencode(get_lang('GroupAdded')).'&sec_token='.$tok); - exit (); + exit (); } } else { if (isset($_POST['submit'])) { @@ -164,4 +158,4 @@ if(!empty($message)){ $form->display(); // Footer -Display::display_footer(); +Display::display_footer(); \ No newline at end of file diff --git a/main/admin/usergroups.php b/main/admin/usergroups.php index 7e0e3f189b..460c8b22ef 100755 --- a/main/admin/usergroups.php +++ b/main/admin/usergroups.php @@ -10,7 +10,6 @@ $language_file = array('admin'); $cidReset = true; require_once '../inc/global.inc.php'; -require_once api_get_path(LIBRARY_PATH).'usergroup.lib.php'; $this_section = SECTION_PLATFORM_ADMIN; api_protect_admin_script(); @@ -24,7 +23,7 @@ if ($action == 'add') { $interbreadcrumb[]=array('url' => 'usergroups.php','name' => get_lang('Classes')); $interbreadcrumb[]=array('url' => '#','name' => get_lang('Add')); } elseif ($action == 'edit') { - $interbreadcrumb[]=array('url' => 'usergroups.php','name' => get_lang('Classes')); + $interbreadcrumb[]=array('url' => 'usergroups.php','name' => get_lang('Classes')); $interbreadcrumb[]=array('url' => '#','name' => get_lang('Edit')); } else { $interbreadcrumb[]=array('url' => '#','name' => get_lang('Classes')); @@ -47,7 +46,7 @@ if (isset($_GET['action']) && $_GET['action'] == 'editnote') { $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_usergroups'; -//The order is important you need to check the the $column variable in the model.ajax.php file +//The order is important you need to check the the $column variable in the model.ajax.php file $columns = array(get_lang('Name'), get_lang('Users'), get_lang('Courses'), get_lang('Sessions'), get_lang('Actions')); //Column config @@ -58,11 +57,11 @@ $column_model = array( array('name'=>'courses', 'index'=>'courses', 'width'=>'15', 'align'=>'left'), array('name'=>'sessions', 'index'=>'sessions', 'width'=>'15', 'align'=>'left'), array('name'=>'actions', 'index'=>'actions', 'width'=>'20', 'align'=>'left','sortable'=>'false','formatter'=>'action_formatter'), - ); -//Autowidth + ); +//Autowidth $extra_params['autowidth'] = 'true'; -//height auto -$extra_params['height'] = 'auto'; +//height auto +$extra_params['height'] = 'auto'; //With this function we can add actions to the jgrid $action_links = 'function action_formatter (cellvalue, options, rowObject) { @@ -70,18 +69,18 @@ $action_links = 'function action_formatter (cellvalue, options, rowObject) { .' ' .' ' .' ' - .' ' - .' \'; + .' ' + .' \'; }'; ?> + addElement('header', '', get_lang('Add')); + $form->addElement('header', get_lang('Add')); $form->addElement('text', 'name', get_lang('name'), array('size' => '70', 'id' => 'name')); //$form->applyFilter('note_title', 'html_filter'); $form->add_html_editor('description', get_lang('Description'), false, false, array('Width' => '95%', 'Height' => '250')); @@ -113,10 +112,10 @@ if (isset($_GET['action']) && $_GET['action'] == 'add') { if ($form->validate()) { $check = Security::check_token('post'); if ($check) { - $values = $form->exportValues(); - $res = $usergroup->save($values); + $values = $form->exportValues(); + $res = $usergroup->save($values); if ($res) { - Display::display_confirmation_message(get_lang('Added')); + Display::display_confirmation_message(get_lang('ItemAdded')); } } Security::clear_token(); @@ -152,7 +151,7 @@ elseif (isset($_GET['action']) && $_GET['action'] == 'edit' && is_numeric($_GET[ if ($form->validate()) { $check = Security::check_token('post'); if ($check) { - $values = $form->exportValues(); + $values = $form->exportValues(); $res = $usergroup->update($values); if ($res) { Display::display_confirmation_message(get_lang('Updated')); @@ -178,7 +177,7 @@ elseif (isset($_GET['action']) && $_GET['action'] == 'delete' && is_numeric($_GE } $usergroup->display(); } else { - $usergroup->display(); + $usergroup->display(); } Display :: display_footer(); diff --git a/main/inc/lib/group_portal_manager.lib.php b/main/inc/lib/group_portal_manager.lib.php index 05784bd6de..36f4c73859 100644 --- a/main/inc/lib/group_portal_manager.lib.php +++ b/main/inc/lib/group_portal_manager.lib.php @@ -46,7 +46,7 @@ class GroupPortalManager { * @return boolean if success */ public static function add($name, $description, $url, $visibility, $picture='') { - $tms = time(); + $now = api_get_utc_datetime(); $table = Database :: get_main_table(TABLE_MAIN_GROUP); $sql = "INSERT INTO $table SET name = '".Database::escape_string($name)."', @@ -54,9 +54,9 @@ class GroupPortalManager { picture_uri = '".Database::escape_string($picture)."', url = '".Database::escape_string($url)."', visibility = '".Database::escape_string($visibility)."', - created_on = FROM_UNIXTIME(".$tms."), - updated_on = FROM_UNIXTIME(".$tms.")"; - $result = Database::query($sql); + created_on = '".$now."', + updated_on = '".$now."'"; + Database::query($sql); $return = Database::insert_id(); return $return; } @@ -74,14 +74,14 @@ class GroupPortalManager { public static function update($group_id, $name, $description, $url, $visibility, $picture_uri) { $group_id = intval($group_id); $table = Database::get_main_table(TABLE_MAIN_GROUP); - $tms = time(); + $now = api_get_utc_datetime(); $sql = "UPDATE $table SET name = '".Database::escape_string($name)."', description = '".Database::escape_string($description)."', picture_uri = '".Database::escape_string($picture_uri)."', url = '".Database::escape_string($url)."', visibility = '".Database::escape_string($visibility)."', - updated_on = FROM_UNIXTIME(".$tms.") + updated_on = '".$now."' WHERE id = '$group_id'"; $result = Database::query($sql); return $result; @@ -120,7 +120,6 @@ class GroupPortalManager { { $table = Database :: get_main_table(TABLE_MAIN_GROUP); $visibility = intval($visibility); - $user_condition = ''; $sql = "SELECT name, description, picture_uri FROM $table WHERE visibility = $visibility "; $res = Database::query($sql); $data = array (); @@ -137,7 +136,7 @@ class GroupPortalManager { public static function get_groups_list($without_this_one = NULL ) { $where=''; if ( isset($without_this_one) && (intval($without_this_one) == $without_this_one) ) { - $where = "WHERE id <> $without_this_one"; + $where = "WHERE id <> $without_this_one"; } $table = Database :: get_main_table(TABLE_MAIN_GROUP); $sql = "SELECT id, name FROM $table $where order by name"; @@ -162,7 +161,7 @@ class GroupPortalManager { $sql = "SELECT id, name, description, picture_uri, url, visibility FROM $table WHERE id = $group_id "; $res = Database::query($sql); $item = array(); - if (Database::num_rows($res)>0) { + if (Database::num_rows($res)>0) { $item = Database::fetch_array($res,'ASSOC'); } return $item; @@ -174,7 +173,7 @@ class GroupPortalManager { * @param parent_group, if 0, we delete the parent_group association * @param relation_type * @return true or false - **/ + **/ public static function set_parent_group($group_id, $parent_group_id, $relation_type = 1){ $table = Database :: get_main_table(TABLE_MAIN_GROUP_REL_GROUP); $group_id = intval($group_id); @@ -187,7 +186,7 @@ class GroupPortalManager { if (Database::num_rows($res)==0) { $sql = "INSERT INTO $table SET group_id = $parent_group_id, subgroup_id = $group_id, relation_type = $relation_type"; } else { - $sql = "UPDATE $table SET group_id = $parent_group_id, relation_type = $relation_type WHERE subgroup_id = $group_id"; + $sql = "UPDATE $table SET group_id = $parent_group_id, relation_type = $relation_type WHERE subgroup_id = $group_id"; } } $res = Database::query($sql); @@ -217,16 +216,16 @@ class GroupPortalManager { $t_rel_group = Database :: get_main_table(TABLE_MAIN_GROUP_REL_GROUP); $select_part = "SELECT "; $cond_part=''; - for ($i=1; $i <= $level; $i++) { + for ($i=1; $i <= $level; $i++) { $g_number=$i; $rg_number=$i-1; - if ( $i == $level) { + if ( $i == $level) { $select_part .= "g$i.id as id_$i, g$i.name as name_$i "; } else { $select_part .="g$i.id as id_$i, g$i.name name_$i, "; } if ($i == 1) { - $cond_part .= "FROM $t_group g1 JOIN $t_rel_group rg0 on g1.id = rg0.subgroup_id and rg0.group_id = $root "; + $cond_part .= "FROM $t_group g1 JOIN $t_rel_group rg0 on g1.id = rg0.subgroup_id and rg0.group_id = $root "; } else { $cond_part .= "LEFT JOIN $t_rel_group rg$rg_number on g$rg_number.id = rg$rg_number.group_id "; $cond_part .= "LEFT JOIN $t_group g$g_number on rg$rg_number.subgroup_id = g$g_number.id "; @@ -236,7 +235,7 @@ class GroupPortalManager { $res = Database::query($sql); $toreturn = array(); - while ($item = Database::fetch_assoc($res)) { + while ($item = Database::fetch_assoc($res)) { foreach ($item as $key => $value ){ if ($key == 'id_1') { $toreturn[$value]['name'] = $item['name_1']; @@ -413,13 +412,13 @@ class GroupPortalManager { $num = 6; } else { $num = intval($num); - } + } $where_relation_condition = " WHERE gu.relation_type IN ('".GROUP_USER_PERMISSION_ADMIN."' , '".GROUP_USER_PERMISSION_READER."', '".GROUP_USER_PERMISSION_HRM."') "; $sql = "SELECT DISTINCT count(user_id) as count, g.picture_uri, g.name, g.description, g.id - FROM $tbl_group g INNER JOIN $table_group_rel_user gu ON gu.group_id = g.id + FROM $tbl_group g INNER JOIN $table_group_rel_user gu ON gu.group_id = g.id $where_relation_condition ORDER BY created_on desc LIMIT $num "; - + $result=Database::query($sql); $array = array(); while ($row = Database::fetch_array($result, 'ASSOC')) { @@ -451,17 +450,17 @@ class GroupPortalManager { $table_group_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_GROUP); $tbl_user = Database::get_main_table(TABLE_MAIN_USER); $group_id = intval($group_id); - + if (empty($group_id)){ return array(); - } + } - $limit_text = ''; + $limit_text = ''; if (isset($from) && isset($limit)) { $from = intval($from); - $limit = intval($limit); + $limit = intval($limit); $limit_text = "LIMIT $from, $limit"; - } + } if (count($relation_type) == 0) { $where_relation_condition = ''; @@ -476,10 +475,10 @@ class GroupPortalManager { $where_relation_condition = "AND gu.relation_type IN ($relation_type) "; } - $sql = "SELECT picture_uri as image, u.user_id, u.firstname, u.lastname, relation_type + $sql = "SELECT picture_uri as image, u.user_id, u.firstname, u.lastname, relation_type FROM $tbl_user u INNER JOIN $table_group_rel_user gu - ON (gu.user_id = u.user_id) - WHERE gu.group_id= $group_id $where_relation_condition + ON (gu.user_id = u.user_id) + WHERE gu.group_id= $group_id $where_relation_condition ORDER BY relation_type, firstname $limit_text"; $result = Database::query($sql); @@ -489,7 +488,7 @@ class GroupPortalManager { $image_path = UserManager::get_user_picture_path_by_id($row['user_id'], 'web', false, true); $picture = UserManager::get_picture_user($row['user_id'], $image_path['file'], $image_conf['height'], $image_conf['size']); $row['image'] = ''; - } + } $array[$row['user_id']] = $row; } return $array; @@ -829,7 +828,7 @@ class GroupPortalManager { $ok = $small->send_image($path.'small_'.$filename) && $medium->send_image($path.'medium_'.$filename) && $normal->send_image($path.'big_'.$filename) - && $big->send_image($path.$filename); + && $big->send_image($path.$filename); return $ok ? $filename : false; } @@ -903,7 +902,7 @@ class GroupPortalManager { * @param int size in pixels * @return obj image object */ - public static function resize_picture($file, $max_size_for_picture) { + public static function resize_picture($file, $max_size_for_picture) { $temp = new Image($file); $picture_infos = api_getimagesize($file); if ($picture_infos['width'] > $max_size_for_picture) { @@ -1032,7 +1031,7 @@ class GroupPortalManager { //$picture = GroupPortalManager::get_picture_group($group_id, $group_info['picture_uri'],160,GROUP_IMAGE_SIZE_MEDIUM); //$big_image = GroupPortalManager::get_picture_group($group_id, $group_info['picture_uri'],'',GROUP_IMAGE_SIZE_BIG); //$tags = GroupPortalManager::get_group_tags($group_id, true); - + //$groups_by_user = GroupPortalManager::get_groups_by_user($user_id, 0); //my relation with the group is set here @@ -1048,12 +1047,12 @@ class GroupPortalManager { '; //Loading group permission - + $links = ''; switch ($my_group_role) { case GROUP_USER_PERMISSION_READER: // I'm just a reader - $relation_group_title = get_lang('IAmAReader'); + $relation_group_title = get_lang('IAmAReader'); $links .= '
  • '. Display::return_icon('invitation_friend.png', get_lang('InviteFriends'), array('hspace'=>'6')).''.get_lang('InviteFriends').'
  • '; $links .= '
  • '. Display::return_icon('group_leave.png', get_lang('LeaveGroup'), array('hspace'=>'6')).'
  • '; break; @@ -1101,10 +1100,10 @@ class GroupPortalManager { } $html .= $links; $html .= ''; - } + } return $html; } - + function delete_topic($group_id, $topic_id) { $table_message = Database::get_main_table(TABLE_MESSAGE); $topic_id = intval($topic_id); diff --git a/main/inc/lib/usergroup.lib.php b/main/inc/lib/usergroup.lib.php index 91d4a54584..1bf2fd1aa7 100644 --- a/main/inc/lib/usergroup.lib.php +++ b/main/inc/lib/usergroup.lib.php @@ -16,14 +16,20 @@ require_once 'model.lib.php'; class UserGroup extends Model { var $columns = array('id', 'name','description'); - + public function __construct() { $this->table = Database::get_main_table(TABLE_USERGROUP); $this->usergroup_rel_user_table = Database::get_main_table(TABLE_USERGROUP_REL_USER); $this->usergroup_rel_course_table = Database::get_main_table(TABLE_USERGROUP_REL_COURSE); $this->usergroup_rel_session_table = Database::get_main_table(TABLE_USERGROUP_REL_SESSION); } - + + public function get_count() { + $row = Database::select('count(*) as count', $this->table, array(),'first'); + return $row['count']; + } + + /** * Displays the title + grid */ @@ -31,44 +37,44 @@ class UserGroup extends Model { // action links echo '
    '; echo ''.Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('PlatformAdmin'),'','32').''; - //echo ''.Display::return_icon('back.png',get_lang('Back')).get_lang('Back').''; - echo ''.Display::return_icon('new_class.png',get_lang('langAddClasses'),'','32').''; - echo '
    '; - echo Display::grid_html('usergroups'); - } - + //echo ''.Display::return_icon('back.png',get_lang('Back')).get_lang('Back').''; + echo ''.Display::return_icon('new_class.png',get_lang('langAddClasses'),'','32').''; + echo ''; + echo Display::grid_html('usergroups'); + } + /** * Gets a list of course ids by user group * @param int user group id - * @return array - */ - public function get_courses_by_usergroup($id) { + * @return array + */ + public function get_courses_by_usergroup($id) { $results = Database::select('course_id',$this->usergroup_rel_course_table, array('where'=>array('usergroup_id = ?'=>$id))); $array = array(); - if (!empty($results)) { + if (!empty($results)) { foreach($results as $row) { - $array[]= $row['course_id']; + $array[]= $row['course_id']; } - } + } return $array; - } - + } + /** * Gets a list of session ids by user group * @param int user group id - * @return array + * @return array */ public function get_sessions_by_usergroup($id) { $results = Database::select('session_id',$this->usergroup_rel_session_table, array('where'=>array('usergroup_id = ?'=>$id))); $array = array(); - if (!empty($results)) { + if (!empty($results)) { foreach($results as $row) { - $array[]= $row['session_id']; + $array[]= $row['session_id']; } - } + } return $array; - } - + } + /** * Gets a list of user ids by user group * @param int user group id @@ -82,14 +88,14 @@ class UserGroup extends Model { } $results = Database::select('user_id', $this->usergroup_rel_user_table, $conditions, true); $array = array(); - if (!empty($results)) { + if (!empty($results)) { foreach($results as $row) { - $array[]= $row['user_id']; + $array[]= $row['user_id']; } - } - return $array; + } + return $array; } - + /** * Gets the usergroup id list by user id * @param int user id @@ -97,37 +103,37 @@ class UserGroup extends Model { public function get_usergroup_by_user($id) { $results = Database::select('usergroup_id',$this->usergroup_rel_user_table, array('where'=>array('user_id = ?'=>$id))); $array = array(); - if (!empty($results)) { + if (!empty($results)) { foreach($results as $row) { - $array[]= $row['usergroup_id']; + $array[]= $row['usergroup_id']; } - } - return $array; - } - - + } + return $array; + } + + /** * Subscribes sessions to a group (also adding the members of the group in the session and course) * @param int usergroup id * @param array list of session ids */ - function subscribe_sessions_to_usergroup($usergroup_id, $list) { + function subscribe_sessions_to_usergroup($usergroup_id, $list) { $current_list = self::get_sessions_by_usergroup($usergroup_id); $user_list = self::get_users_by_usergroup($usergroup_id); - + $delete_items = $new_items = array(); - if (!empty($list)) { + if (!empty($list)) { foreach ($list as $session_id) { if (!in_array($session_id, $current_list)) { $new_items[] = $session_id; - } + } } - } - if (!empty($current_list)) { + } + if (!empty($current_list)) { foreach($current_list as $session_id) { if (!in_array($session_id, $list)) { $delete_items[] = $session_id; - } + } } } @@ -136,7 +142,7 @@ class UserGroup extends Model { foreach($delete_items as $session_id) { if (!empty($user_list)) { foreach($user_list as $user_id) { - + SessionManager::unsubscribe_user_from_session($session_id, $user_id); /*foreach ($course_list as $course_data) { foreach($user_list as $user_id) { @@ -147,14 +153,14 @@ class UserGroup extends Model { } Database::delete($this->usergroup_rel_session_table, array('usergroup_id = ? AND session_id = ?'=>array($usergroup_id, $session_id))); } - } - + } + //Addding new relationships if (!empty($new_items)) { - foreach($new_items as $session_id) { + foreach($new_items as $session_id) { $params = array('session_id'=>$session_id, 'usergroup_id'=>$usergroup_id); - Database::insert($this->usergroup_rel_session_table, $params); - + Database::insert($this->usergroup_rel_session_table, $params); + if (!empty($user_list)) { SessionManager::suscribe_users_to_session($session_id, $user_list, null, false); } @@ -168,85 +174,85 @@ class UserGroup extends Model { } } } - + /** * Subscribes courses to a group (also adding the members of the group in the course) * @param int usergroup id * @param array list of course ids */ function subscribe_courses_to_usergroup($usergroup_id, $list) { - + $current_list = self::get_courses_by_usergroup($usergroup_id); $user_list = self::get_users_by_usergroup($usergroup_id); - + $delete_items = $new_items = array(); - if (!empty($list)) { + if (!empty($list)) { foreach ($list as $id) { if (!in_array($id, $current_list)) { $new_items[] = $id; - } + } } } - if (!empty($current_list)) { + if (!empty($current_list)) { foreach($current_list as $id) { if (!in_array($id, $list)) { $delete_items[] = $id; - } + } } } - + //Deleting items if (!empty($delete_items)) { foreach($delete_items as $course_id) { - $course_info = api_get_course_info_by_id($course_id); + $course_info = api_get_course_info_by_id($course_id); if (!empty($user_list)) { - foreach($user_list as $user_id) { - CourseManager::unsubscribe_user($user_id, $course_info['code']); + foreach($user_list as $user_id) { + CourseManager::unsubscribe_user($user_id, $course_info['code']); } } Database::delete($this->usergroup_rel_course_table, array('usergroup_id = ? AND course_id = ?'=>array($usergroup_id, $course_id))); } } - + //Addding new relationships if (!empty($new_items)) { - foreach($new_items as $course_id) { - $course_info = api_get_course_info_by_id($course_id); + foreach($new_items as $course_id) { + $course_info = api_get_course_info_by_id($course_id); if (!empty($user_list)) { - foreach($user_list as $user_id) { + foreach($user_list as $user_id) { CourseManager::subscribe_user($user_id, $course_info['code']); } } - + $params = array('course_id'=>$course_id, 'usergroup_id'=>$usergroup_id); Database::insert($this->usergroup_rel_course_table, $params); } } - } - + } + /** * Subscribes users to a group * @param int usergroup id * @param array list of user ids */ function subscribe_users_to_usergroup($usergroup_id, $list) { - $current_list = self::get_users_by_usergroup($usergroup_id); + $current_list = self::get_users_by_usergroup($usergroup_id); $course_list = self::get_courses_by_usergroup($usergroup_id); $session_list = self::get_sessions_by_usergroup($usergroup_id); - + $delete_items = $new_items = array(); if (!empty($list)) { foreach ($list as $user_id) { if (!in_array($user_id, $current_list)) { $new_items[] = $user_id; - } + } } } if (!empty($current_list)) { foreach($current_list as $user_id) { if (!in_array($user_id, $list)) { $delete_items[] = $user_id; - } + } } } @@ -257,7 +263,7 @@ class UserGroup extends Model { if (!empty($course_list)) { foreach($course_list as $course_id) { $course_info = api_get_course_info_by_id($course_id); - CourseManager::unsubscribe_user($user_id, $course_info['code']); + CourseManager::unsubscribe_user($user_id, $course_info['code']); } } //Removing sessions