ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilForumModeratorsGUI Class Reference

Class ilForumModeratorsGUI. More...

+ Collaboration diagram for ilForumModeratorsGUI:

Public Member Functions

 __construct ()
 
 executeCommand ()
 
 addModerator ($users=array())
 
 detachModeratorRole ()
 

Private Attributes

 $ctrl
 
 $tpl
 
 $lng
 
 $tabs
 
 $error
 
 $user
 
 $toolbar
 
 $oForumModerators
 
 $ref_id = 0
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilForumModeratorsGUI::__construct ( )

Definition at line 33 of file class.ilForumModeratorsGUI.php.

References $_GET, $DIC, and user().

34  {
35  global $DIC;
36  $this->ctrl = $DIC->ctrl();
37  $this->tpl = $DIC->ui()->mainTemplate();
38  $this->lng = $DIC->language();
39  $this->access = $DIC->access();
40  $this->tabs = $DIC->tabs();
41  $this->error = $DIC['ilErr'];
42  $this->user = $DIC->user();
43  $this->toolbar = $DIC->toolbar();
44 
45  $this->tabs->activateTab('frm_moderators');
46  $this->lng->loadLanguageModule('search');
47 
48  if (!$this->access->checkAccess('write', '', (int) $_GET['ref_id'])) {
49  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
50  }
51 
52  $this->oForumModerators = new ilForumModerators((int) $_GET['ref_id']);
53  $this->ref_id = (int) $_GET['ref_id'];
54  }
global $DIC
Definition: saml.php:7
$_GET["client_id"]
user()
Definition: user.php:4
Class ilForumModerators.
+ Here is the call graph for this function:

Member Function Documentation

◆ addModerator()

ilForumModeratorsGUI::addModerator (   $users = array())

Definition at line 85 of file class.ilForumModeratorsGUI.php.

References $users, ilForumNotification\_isParentNodeGrpCrs(), ilObject\_lookupObjId(), ilForumProperties\getInstance(), ilUtil\sendFailure(), ilUtil\sendSuccess(), and user().

86  {
87  if (!$users) {
88  ilUtil::sendFailure($this->lng->txt('frm_moderators_select_one'));
89  return;
90  }
91 
92  include_once "Modules/Forum/classes/class.ilForumNotification.php";
93  $isCrsGrp = ilForumNotification::_isParentNodeGrpCrs($this->ref_id);
94  include_once "Modules/Forum/classes/class.ilForumProperties.php";
95  $objFrmProps = ilForumProperties::getInstance(ilObject::_lookupObjId($this->ref_id));
96  $frm_noti_type = $objFrmProps->getNotificationType();
97 
98  foreach ($users as $user_id) {
99  $this->oForumModerators->addModeratorRole((int) $user_id);
100  if ($isCrsGrp && $frm_noti_type != 'default') {
101  $tmp_frm_noti = new ilForumNotification($this->ref_id);
102  $tmp_frm_noti->setUserId((int) $user_id);
103  $tmp_frm_noti->setUserIdNoti($this->user->getId());
104  $tmp_frm_noti->setUserToggle((int) $objFrmProps->getUserToggleNoti());
105  $tmp_frm_noti->setAdminForce((int) $objFrmProps->getAdminForceNoti());
106 
107  $tmp_frm_noti->insertAdminForce();
108  }
109  }
110 
111  ilUtil::sendSuccess($this->lng->txt('frm_moderator_role_added_successfully'), true);
112  $this->ctrl->redirect($this, 'showModerators');
113  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static _isParentNodeGrpCrs($a_ref_id)
Class ilForumNotification.
user()
Definition: user.php:4
static getInstance($a_obj_id=0)
static _lookupObjId($a_id)
$users
Definition: authpage.php:44
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:

◆ detachModeratorRole()

ilForumModeratorsGUI::detachModeratorRole ( )

Definition at line 118 of file class.ilForumModeratorsGUI.php.

References $_GET, $_POST, $i, $result, $tbl, $user, ilForumNotification\_isParentNodeGrpCrs(), ilParticipants\_isParticipant(), ilObject\_lookupObjId(), array, ilRepositorySearchGUI\fillAutoCompleteToolbar(), ilUtil\formCheckbox(), ilForumProperties\getInstance(), ilObjectFactory\getInstanceByObjId(), ilUtil\sendFailure(), and ilUtil\sendSuccess().

119  {
120  if (!isset($_POST['usr_id']) || !is_array($_POST['usr_id'])) {
121  ilUtil::sendFailure($this->lng->txt('frm_moderators_select_at_least_one'));
122  return $this->showModerators();
123  }
124 
125  $entries = $this->oForumModerators->getCurrentModerators();
126  if (count($_POST['usr_id']) == count($entries)) {
127  ilUtil::sendFailure($this->lng->txt('frm_at_least_one_moderator'));
128  return $this->showModerators();
129  }
130 
131  include_once "Modules/Forum/classes/class.ilForumNotification.php";
132  $isCrsGrp = ilForumNotification::_isParentNodeGrpCrs($this->ref_id);
133 
134  if ($isCrsGrp) {
135  include_once "Services/Membership/classes/class.ilParticipants.php";
136  }
137 
138  include_once "Modules/Forum/classes/class.ilForumProperties.php";
139  $objFrmProps = ilForumProperties::getInstance(ilObject::_lookupObjId($this->ref_id));
140  $frm_noti_type = $objFrmProps->getNotificationType();
141 
142  foreach ($_POST['usr_id'] as $usr_id) {
143  $this->oForumModerators->detachModeratorRole((int) $usr_id);
144 
145  if ($isCrsGrp && $frm_noti_type != 'default') {
146  if (!ilParticipants::_isParticipant($this->ref_id, $usr_id)) {
147  $tmp_frm_noti = new ilForumNotification($this->ref_id);
148  $tmp_frm_noti->setUserId((int) $usr_id);
149  $tmp_frm_noti->setForumId(ilObject::_lookupObjId($this->ref_id));
150 
151  $tmp_frm_noti->deleteAdminForce();
152  }
153  }
154  }
155 
156  ilUtil::sendSuccess($this->lng->txt('frm_moderators_detached_role_successfully'), true);
157  $this->ctrl->redirect($this, 'showModerators');
158  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static _isParentNodeGrpCrs($a_ref_id)
static _isParticipant($a_ref_id, $a_usr_id)
Static function to check if a user is a participant of the container object.
Class ilForumNotification.
static getInstance($a_obj_id=0)
static _lookupObjId($a_id)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$_POST["username"]
+ Here is the call graph for this function:

◆ executeCommand()

ilForumModeratorsGUI::executeCommand ( )

Definition at line 59 of file class.ilForumModeratorsGUI.php.

60  {
61  $next_class = $this->ctrl->getNextClass($this);
62  $cmd = $this->ctrl->getCmd();
63 
64  switch ($next_class) {
65  case 'ilrepositorysearchgui':
66  include_once 'Services/Search/classes/class.ilRepositorySearchGUI.php';
67  $rep_search = new ilRepositorySearchGUI();
68  $rep_search->setCallback($this, 'addModerator');
69  $this->ctrl->setReturn($this, 'showModerators');
70  $this->ctrl->forwardCommand($rep_search);
71  break;
72 
73  default:
74  if (!$cmd) {
75  $cmd = 'showModerators';
76  }
77  $this->$cmd();
78  break;
79  }
80  }

Field Documentation

◆ $ctrl

ilForumModeratorsGUI::$ctrl
private

Definition at line 18 of file class.ilForumModeratorsGUI.php.

◆ $error

ilForumModeratorsGUI::$error
private

Definition at line 22 of file class.ilForumModeratorsGUI.php.

◆ $lng

ilForumModeratorsGUI::$lng
private

Definition at line 20 of file class.ilForumModeratorsGUI.php.

◆ $oForumModerators

ilForumModeratorsGUI::$oForumModerators
private

Definition at line 29 of file class.ilForumModeratorsGUI.php.

◆ $ref_id

ilForumModeratorsGUI::$ref_id = 0
private

Definition at line 31 of file class.ilForumModeratorsGUI.php.

◆ $tabs

ilForumModeratorsGUI::$tabs
private

Definition at line 21 of file class.ilForumModeratorsGUI.php.

◆ $toolbar

ilForumModeratorsGUI::$toolbar
private

Definition at line 24 of file class.ilForumModeratorsGUI.php.

◆ $tpl

ilForumModeratorsGUI::$tpl
private

Definition at line 19 of file class.ilForumModeratorsGUI.php.

◆ $user

ilForumModeratorsGUI::$user
private

Definition at line 23 of file class.ilForumModeratorsGUI.php.

Referenced by detachModeratorRole().


The documentation for this class was generated from the following file: