|
|
|
@ -149,7 +149,7 @@ class UserGroup extends Model |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Gets a list of course ids by user group |
|
|
|
|
* @param int user group id |
|
|
|
|
* @param int $id user group id |
|
|
|
|
* @param array $loadCourseData |
|
|
|
|
* @return array |
|
|
|
|
*/ |
|
|
|
@ -331,6 +331,7 @@ class UserGroup extends Model |
|
|
|
|
$array[] = $row['usergroup_id']; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $array; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -346,15 +347,17 @@ class UserGroup extends Model |
|
|
|
|
$this->usergroup_rel_course_table, |
|
|
|
|
array('where' => array('course_id = ? AND usergroup_id = ?' => array($course_id, $usergroup_id))) |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if (empty($results)) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Gets a list of session ids by user group |
|
|
|
|
* @param int user group id |
|
|
|
|
* @param int $id user group id |
|
|
|
|
* @return array |
|
|
|
|
*/ |
|
|
|
|
public function get_sessions_by_usergroup($id) |
|
|
|
@ -371,12 +374,13 @@ class UserGroup extends Model |
|
|
|
|
$array[] = $row['session_id']; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $array; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Gets a list of user ids by user group |
|
|
|
|
* @param int user group id |
|
|
|
|
* @param int $id user group id |
|
|
|
|
* @return array with a list of user ids |
|
|
|
|
*/ |
|
|
|
|
public function get_users_by_usergroup($id = null) |
|
|
|
@ -393,12 +397,13 @@ class UserGroup extends Model |
|
|
|
|
$array[] = $row['user_id']; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $array; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Gets the usergroup id list by user id |
|
|
|
|
* @param int user id |
|
|
|
|
* @param int $userId user id |
|
|
|
|
* @return array |
|
|
|
|
*/ |
|
|
|
|
public function get_usergroup_by_user($userId) |
|
|
|
@ -424,13 +429,14 @@ class UserGroup extends Model |
|
|
|
|
$array[] = $row['usergroup_id']; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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 |
|
|
|
|
* @param int $usergroup_id usergroup id |
|
|
|
|
* @param array $list list of session ids |
|
|
|
|
*/ |
|
|
|
|
public function subscribe_sessions_to_usergroup($usergroup_id, $list) |
|
|
|
|
{ |
|
|
|
@ -483,8 +489,8 @@ 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 (integers) |
|
|
|
|
* @param int $usergroup_id usergroup id |
|
|
|
|
* @param array $list list of course ids (integers) |
|
|
|
|
* @param bool $delete_groups |
|
|
|
|
*/ |
|
|
|
|
public function subscribe_courses_to_usergroup($usergroup_id, $list, $delete_groups = true) |
|
|
|
@ -544,15 +550,18 @@ class UserGroup extends Model |
|
|
|
|
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))); |
|
|
|
|
Database::delete( |
|
|
|
|
$this->usergroup_rel_course_table, |
|
|
|
|
array('usergroup_id = ? AND course_id = ?' => array($usergroup_id, $course_id)) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Subscribe users to a group |
|
|
|
|
* @param int usergroup id |
|
|
|
|
* @param array list of user ids |
|
|
|
|
* @param int $usergroup_id usergroup id |
|
|
|
|
* @param array $list list of user ids |
|
|
|
|
* @param bool $delete_users_not_present_in_list |
|
|
|
|
*/ |
|
|
|
|
public function subscribe_users_to_usergroup($usergroup_id, $list, $delete_users_not_present_in_list = true) |
|
|
|
@ -698,16 +707,36 @@ class UserGroup extends Model |
|
|
|
|
* @param array $options |
|
|
|
|
* @return array |
|
|
|
|
*/ |
|
|
|
|
public function get_all_for_export($options = null) |
|
|
|
|
public function getDataToExport($options = array()) |
|
|
|
|
{ |
|
|
|
|
if ($this->useMultipleUrl) { |
|
|
|
|
$urlId = api_get_current_access_url_id(); |
|
|
|
|
$from = $this->table." u INNER JOIN {$this->access_url_rel_usergroup} a ON (u.id = a.usergroup_id)"; |
|
|
|
|
$from = $this->table." u INNER JOIN {$this->access_url_rel_usergroup} a |
|
|
|
|
ON (u.id = a.usergroup_id)"; |
|
|
|
|
$options = array('where' => array('access_url_id = ? ' => $urlId)); |
|
|
|
|
return Database::select('a.id, name, description', $from, $options); |
|
|
|
|
$classes = Database::select('a.id, name, description', $from, $options); |
|
|
|
|
} else { |
|
|
|
|
return Database::select('id, name, description', $this->table, $options); |
|
|
|
|
$classes = Database::select('id, name, description', $this->table, $options); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$result = array(); |
|
|
|
|
if (!empty($classes)) { |
|
|
|
|
foreach ($classes as $data) { |
|
|
|
|
$users = self::getUserListByUserGroup($data['id']); |
|
|
|
|
$userToString = null; |
|
|
|
|
if (!empty($users)) { |
|
|
|
|
$userNameList = array(); |
|
|
|
|
foreach ($users as $userData) { |
|
|
|
|
$userNameList[] = $userData['username']; |
|
|
|
|
} |
|
|
|
|
$userToString = implode(',', $userNameList); |
|
|
|
|
} |
|
|
|
|
$data['users'] = $userToString; |
|
|
|
|
$result[] = $data; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -753,10 +782,12 @@ class UserGroup extends Model |
|
|
|
|
{ |
|
|
|
|
$groupExists = $this->usergroup_exists(trim($params['name'])); |
|
|
|
|
if ($groupExists == false) { |
|
|
|
|
|
|
|
|
|
$id = parent::save($params, $show_query); |
|
|
|
|
if ($this->useMultipleUrl) { |
|
|
|
|
$this->subscribeToUrl($id, api_get_current_access_url_id()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $id; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|