ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
16 public function __construct($a_ref_id)
17 {
18 global $ilDB;
19
20 $this->db = $ilDB;
21 $this->ref_id = $a_ref_id;
22 }
23
27 public function setRefId($ref_id)
28 {
29 $this->ref_id = $ref_id;
30 }
31
35 public function getRefId()
36 {
37 return $this->ref_id;
38 }
39 public function addModeratorRole($a_usr_id)
40 {
41 global $rbacreview, $rbacadmin;
42
43 $role_list = $rbacreview->getRoleListByObject($this->getRefId());
44 foreach ($role_list as $role)
45 {
46 if(strpos($role['title'], 'il_frm_moderator') !== false)
47 {
48 $a_rol_id = $role['obj_id'];
49 break;
50 }
51 }
52
53 if((int)$a_rol_id)
54 {
55 $user = $rbacadmin->assignUser($a_rol_id, $a_usr_id);
56 return true;
57 }
58
59 return false;
60 }
61
62 public function detachModeratorRole($a_usr_id)
63 {
64 global $rbacreview, $rbacadmin;
65
66 $role_list = $rbacreview->getRoleListByObject($this->getRefId());
67 foreach ($role_list as $role)
68 {
69 if(strpos($role['title'], 'il_frm_moderator') !== false)
70 {
71 $a_rol_id = $role['obj_id'];
72 break;
73 }
74 }
75
76 if((int)$a_rol_id)
77 {
78 $user = $rbacadmin->deassignUser($a_rol_id, $a_usr_id);
79 return true;
80 }
81
82 return false;
83 }
84
85 public function getCurrentModerators()
86 {
87 global $rbacreview;
88
89 $roles = $rbacreview->getRoleListByObject($this->getRefId());
90 foreach($roles as $role)
91 {
92 if(strpos($role['title'], 'il_frm_moderator') !== false)
93 {
94 $assigned_users = $rbacreview->assignedUsers($role['rol_id']);
95 break;
96 }
97 }
98 return is_array($assigned_users) ? $assigned_users : array();
99 }
100
101
102 public function getUsers()
103 {
104 global $rbacreview;
105
106 $roles = $rbacreview->getRoleListByObject($this->getRefId());
107 foreach($roles as $role)
108 {
109 if(strpos($role['title'], 'il_frm_moderator') !== false)
110 {
111 $assigned_users = $rbacreview->assignedUsers($role['rol_id']);
112 //vd($assigned_users);
113 break;
114 }
115 }
116 return is_array($assigned_users) ? $assigned_users : array();
117 }
118}
119
120?>
Class ilForumModerators.
global $ilDB