ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilForumModerators.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
12 {
13  private $db = null;
14  private $ref_id = 0;
15  private $rbac;
16 
17  public function __construct($a_ref_id)
18  {
19  global $DIC;
20 
21  $this->db = $DIC->database();
22  $this->rbac = $DIC->rbac();
23  $this->ref_id = $a_ref_id;
24  }
25 
29  public function setRefId($ref_id)
30  {
31  $this->ref_id = $ref_id;
32  }
33 
37  public function getRefId()
38  {
39  return $this->ref_id;
40  }
41 
46  public function addModeratorRole($a_usr_id)
47  {
48  $role_list = $this->rbac->review()->getRoleListByObject($this->getRefId());
49  foreach ($role_list as $role) {
50  if (strpos($role['title'], 'il_frm_moderator') !== false) {
51  $a_rol_id = $role['obj_id'];
52  break;
53  }
54  }
55 
56  if ((int) $a_rol_id) {
57  $user = $this->rbac->admin()->assignUser($a_rol_id, $a_usr_id);
58  return true;
59  }
60 
61  return false;
62  }
63 
68  public function detachModeratorRole($a_usr_id)
69  {
70  $role_list = $this->rbac->review()->getRoleListByObject($this->getRefId());
71  foreach ($role_list as $role) {
72  if (strpos($role['title'], 'il_frm_moderator') !== false) {
73  $a_rol_id = $role['obj_id'];
74  break;
75  }
76  }
77 
78  if ((int) $a_rol_id) {
79  $user = $this->rbac->admin()->deassignUser($a_rol_id, $a_usr_id);
80  return true;
81  }
82 
83  return false;
84  }
85 
89  public function getCurrentModerators()
90  {
91  $roles = $this->rbac->review()->getRoleListByObject($this->getRefId());
92  foreach ($roles as $role) {
93  if (strpos($role['title'], 'il_frm_moderator') !== false) {
94  $assigned_users = $this->rbac->review()->assignedUsers($role['rol_id']);
95  break;
96  }
97  }
98  return is_array($assigned_users) ? $assigned_users : array();
99  }
100 
104  public function getUsers()
105  {
106  $roles = $this->rbac->review()->getRoleListByObject($this->getRefId());
107  foreach ($roles as $role) {
108  if (strpos($role['title'], 'il_frm_moderator') !== false) {
109  $assigned_users = $this->rbac->review()->assignedUsers($role['rol_id']);
110  //vd($assigned_users);
111  break;
112  }
113  }
114  return is_array($assigned_users) ? $assigned_users : array();
115  }
116 }
global $DIC
Definition: saml.php:7
Create styles array
The data for the language used.
Class ilForumModerators.