ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 27 of file class.ilForumModeratorsGUI.php.

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

28  {
29  global $DIC;
30  $this->ctrl = $DIC->ctrl();
31  $this->tpl = $DIC->ui()->mainTemplate();
32  $this->lng = $DIC->language();
33  $this->access = $DIC->access();
34  $this->tabs = $DIC->tabs();
35  $this->error = $DIC['ilErr'];
36  $this->user = $DIC->user();
37  $this->toolbar = $DIC->toolbar();
38 
39  $this->tabs->activateTab('frm_moderators');
40  $this->lng->loadLanguageModule('search');
41 
42  if (!$this->access->checkAccess('write', '', (int) $_GET['ref_id'])) {
43  $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
44  }
45 
46  $this->oForumModerators = new ilForumModerators((int) $_GET['ref_id']);
47  $this->ref_id = (int) $_GET['ref_id'];
48  }
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 78 of file class.ilForumModeratorsGUI.php.

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

79  {
80  if (!$users) {
81  ilUtil::sendFailure($this->lng->txt('frm_moderators_select_one'));
82  return;
83  }
84 
85  $isCrsGrp = ilForumNotification::_isParentNodeGrpCrs($this->ref_id);
86  $objFrmProps = ilForumProperties::getInstance(ilObject::_lookupObjId($this->ref_id));
87  $frm_noti_type = $objFrmProps->getNotificationType();
88 
89  foreach ($users as $user_id) {
90  $this->oForumModerators->addModeratorRole((int) $user_id);
91  if ($isCrsGrp && $frm_noti_type != 'default') {
92  $tmp_frm_noti = new ilForumNotification($this->ref_id);
93  $tmp_frm_noti->setUserId((int) $user_id);
94  $tmp_frm_noti->setUserIdNoti($this->user->getId());
95  $tmp_frm_noti->setUserToggle((int) $objFrmProps->getUserToggleNoti());
96  $tmp_frm_noti->setAdminForce((int) $objFrmProps->getAdminForceNoti());
97 
98  $tmp_frm_noti->insertAdminForce();
99  }
100  }
101 
102  ilUtil::sendSuccess($this->lng->txt('frm_moderator_role_added_successfully'), true);
103  $this->ctrl->redirect($this, 'showModerators');
104  }
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 109 of file class.ilForumModeratorsGUI.php.

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

110  {
111  if (!isset($_POST['usr_id']) || !is_array($_POST['usr_id'])) {
112  ilUtil::sendFailure($this->lng->txt('frm_moderators_select_at_least_one'));
113  return $this->showModerators();
114  }
115 
116  $entries = $this->oForumModerators->getCurrentModerators();
117  if (count($_POST['usr_id']) == count($entries)) {
118  ilUtil::sendFailure($this->lng->txt('frm_at_least_one_moderator'));
119  return $this->showModerators();
120  }
121 
122  $isCrsGrp = ilForumNotification::_isParentNodeGrpCrs($this->ref_id);
123 
124  $objFrmProps = ilForumProperties::getInstance(ilObject::_lookupObjId($this->ref_id));
125  $frm_noti_type = $objFrmProps->getNotificationType();
126 
127  foreach ($_POST['usr_id'] as $usr_id) {
128  $this->oForumModerators->detachModeratorRole((int) $usr_id);
129 
130  if ($isCrsGrp && $frm_noti_type != 'default') {
131  if (!ilParticipants::_isParticipant($this->ref_id, $usr_id)) {
132  $tmp_frm_noti = new ilForumNotification($this->ref_id);
133  $tmp_frm_noti->setUserId((int) $usr_id);
134  $tmp_frm_noti->setForumId(ilObject::_lookupObjId($this->ref_id));
135 
136  $tmp_frm_noti->deleteAdminForce();
137  }
138  }
139  }
140 
141  ilUtil::sendSuccess($this->lng->txt('frm_moderators_detached_role_successfully'), true);
142  $this->ctrl->redirect($this, 'showModerators');
143  }
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 53 of file class.ilForumModeratorsGUI.php.

54  {
55  $next_class = $this->ctrl->getNextClass($this);
56  $cmd = $this->ctrl->getCmd();
57 
58  switch ($next_class) {
59  case 'ilrepositorysearchgui':
60  $rep_search = new ilRepositorySearchGUI();
61  $rep_search->setCallback($this, 'addModerator');
62  $this->ctrl->setReturn($this, 'showModerators');
63  $this->ctrl->forwardCommand($rep_search);
64  break;
65 
66  default:
67  if (!$cmd) {
68  $cmd = 'showModerators';
69  }
70  $this->$cmd();
71  break;
72  }
73  }

Field Documentation

◆ $ctrl

ilForumModeratorsGUI::$ctrl
private

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

◆ $error

ilForumModeratorsGUI::$error
private

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

◆ $lng

ilForumModeratorsGUI::$lng
private

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

◆ $oForumModerators

ilForumModeratorsGUI::$oForumModerators
private

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

◆ $ref_id

ilForumModeratorsGUI::$ref_id = 0
private

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

◆ $tabs

ilForumModeratorsGUI::$tabs
private

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

◆ $toolbar

ilForumModeratorsGUI::$toolbar
private

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

◆ $tpl

ilForumModeratorsGUI::$tpl
private

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

◆ $user

ilForumModeratorsGUI::$user
private

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

Referenced by detachModeratorRole().


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