| @@ 390-418 (lines=29) @@ | ||
| 387 | * @param int $course_id |
|
| 388 | * @return array |
|
| 389 | */ |
|
| 390 | public function get_usergroup_by_course($course_id) |
|
| 391 | { |
|
| 392 | if ($this->useMultipleUrl) { |
|
| 393 | $urlId = api_get_current_access_url_id(); |
|
| 394 | $options = array( |
|
| 395 | 'where' => array( |
|
| 396 | 'c.course_id = ? AND access_url_id = ?' => array( |
|
| 397 | $course_id, |
|
| 398 | $urlId, |
|
| 399 | ), |
|
| 400 | ), |
|
| 401 | ); |
|
| 402 | $from = $this->usergroup_rel_course_table." as c INNER JOIN ".$this->access_url_rel_usergroup." a |
|
| 403 | ON c.usergroup_id = a.usergroup_id"; |
|
| 404 | } else { |
|
| 405 | $options = array('where' => array('c.course_id = ?' => $course_id)); |
|
| 406 | $from = $this->usergroup_rel_course_table." c"; |
|
| 407 | } |
|
| 408 | ||
| 409 | $results = Database::select('c.usergroup_id', $from, $options); |
|
| 410 | $array = array(); |
|
| 411 | if (!empty($results)) { |
|
| 412 | foreach ($results as $row) { |
|
| 413 | $array[] = $row['usergroup_id']; |
|
| 414 | } |
|
| 415 | } |
|
| 416 | ||
| 417 | return $array; |
|
| 418 | } |
|
| 419 | ||
| 420 | /** |
|
| 421 | * @param int $usergroup_id |
|
| @@ 564-589 (lines=26) @@ | ||
| 561 | * @param int $userId user id |
|
| 562 | * @return array |
|
| 563 | */ |
|
| 564 | public function get_usergroup_by_user($userId) |
|
| 565 | { |
|
| 566 | if ($this->useMultipleUrl) { |
|
| 567 | $urlId = api_get_current_access_url_id(); |
|
| 568 | $from = $this->usergroup_rel_user_table." u |
|
| 569 | INNER JOIN {$this->access_url_rel_usergroup} a ON (a.usergroup_id AND u.usergroup_id)"; |
|
| 570 | $where = array('where' => array('user_id = ? AND access_url_id = ? ' => array($userId, $urlId))); |
|
| 571 | } else { |
|
| 572 | $from = $this->usergroup_rel_user_table." u "; |
|
| 573 | $where = array('where' => array('user_id = ?' => $userId)); |
|
| 574 | } |
|
| 575 | ||
| 576 | $results = Database::select( |
|
| 577 | 'u.usergroup_id', |
|
| 578 | $from, |
|
| 579 | $where |
|
| 580 | ); |
|
| 581 | $array = array(); |
|
| 582 | if (!empty($results)) { |
|
| 583 | foreach ($results as $row) { |
|
| 584 | $array[] = $row['usergroup_id']; |
|
| 585 | } |
|
| 586 | } |
|
| 587 | ||
| 588 | return $array; |
|
| 589 | } |
|
| 590 | ||
| 591 | /** |
|
| 592 | * Subscribes sessions to a group (also adding the members of the group in the session and course) |
|