ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilLearningSequenceRoles Class Reference

Provides Role actions. More...

+ Collaboration diagram for ilLearningSequenceRoles:

Public Member Functions

 __construct (ilObjLearningSequence $object, ilLearningSequenceParticipants $participants, ilCtrl $ctrl, ilRbacAdmin $rbacadmin, ilRbacReview $rbacreview, ilDBInterface $database, ilObjUser $user)
 
 initDefaultRoles ()
 
 getLocalLearningSequenceRoles (bool $translate=false)
 
 getDefaultMemberRole ()
 
 getDefaultAdminRole ()
 
 addLSMember (int $user_id, int $role)
 
 join (int $user_id, $roles)
 
 leaveLearningSequence ()
 
 getLearningSequenceMemberIds ()
 
 leave (int $user_id)
 
 getLearningSequenceMemberData (array $user_ids, int $active=1)
 
 getLearningSequenceAdminIds ()
 
 getDefaultLearningSequenceRoles (string $lso_id)
 
 readMemberData (array $user_ids, array $selected_columns=null)
 

Data Fields

const ROLE_LS_ADMIN = "il_lso_admin"
 
const ROLE_LS_MEMBER = "il_lso_member"
 
const TYPE_PORTFOLIO = "prtf"
 

Protected Member Functions

 getRoleObject (int $obj_id)
 
 isTrackingEnabled ()
 
 isPortfolio (array $columns=null)
 

Protected Attributes

 $object
 
 $participants
 
 $rbacadmin
 
 $rbacreview
 
 $database
 
 $user
 
 $local_roles
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilLearningSequenceRoles::__construct ( ilObjLearningSequence  $object,
ilLearningSequenceParticipants  $participants,
ilCtrl  $ctrl,
ilRbacAdmin  $rbacadmin,
ilRbacReview  $rbacreview,
ilDBInterface  $database,
ilObjUser  $user 
)

Definition at line 52 of file class.ilLearningSequenceRoles.php.

References $database, $object, $participants, $rbacadmin, $rbacreview, $user, and user().

60  {
61  $this->object = $object;
62  $this->participants = $participants;
63  $this->ctrl = $ctrl;
64  $this->rbacadmin = $rbacadmin;
65  $this->rbacreview = $rbacreview;
66  $this->database = $database;
67  $this->user = $user;
68 
69  $this->local_roles = array();
70  }
user()
Definition: user.php:4
+ Here is the call graph for this function:

Member Function Documentation

◆ addLSMember()

ilLearningSequenceRoles::addLSMember ( int  $user_id,
int  $role 
)

Definition at line 133 of file class.ilLearningSequenceRoles.php.

References join().

133  : bool
134  {
135  return $this->join($user_id, $role);
136  }
+ Here is the call graph for this function:

◆ getDefaultAdminRole()

ilLearningSequenceRoles::getDefaultAdminRole ( )

Definition at line 127 of file class.ilLearningSequenceRoles.php.

References getLocalLearningSequenceRoles().

127  : int
128  {
129  $local_ls_roles = $this->getLocalLearningSequenceRoles();
130  return $local_ls_roles[self::ROLE_LS_ADMIN . "_" . $this->object->getRefId()];
131  }
getLocalLearningSequenceRoles(bool $translate=false)
+ Here is the call graph for this function:

◆ getDefaultLearningSequenceRoles()

ilLearningSequenceRoles::getDefaultLearningSequenceRoles ( string  $lso_id)

Definition at line 244 of file class.ilLearningSequenceRoles.php.

References $object, and getRoleObject().

Referenced by getLearningSequenceAdminIds().

244  : array
245  {
246  if (strlen($lso_id) == 0) {
247  $lso_id = $this->object->getRefId();
248  }
249 
250  $roles = $this->rbacreview->getRolesOfRoleFolder($lso_id);
251 
252  $default_roles = array();
253  foreach ($roles as $role) {
254  $object = $this->getRoleObject((int) $role);
255 
256  $member = self::ROLE_LS_MEMBER . "_" . $lso_id;
257  $admin = self::ROLE_LS_ADMIN . "_" . $lso_id;
258 
259  if (strcmp($object->getTitle(), $member) == 0) {
260  $default_roles["lso_member_role"] = $object->getId();
261  }
262 
263  if (strcmp($object->getTitle(), $admin) == 0) {
264  $default_roles["lso_admin_role"] = $object->getId();
265  }
266  }
267 
268  return $default_roles;
269  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDefaultMemberRole()

ilLearningSequenceRoles::getDefaultMemberRole ( )

Definition at line 121 of file class.ilLearningSequenceRoles.php.

References getLocalLearningSequenceRoles().

121  : int
122  {
123  $local_ls_roles = $this->getLocalLearningSequenceRoles();
124  return $local_ls_roles[self::ROLE_LS_MEMBER . "_" . $this->object->getRefId()];
125  }
getLocalLearningSequenceRoles(bool $translate=false)
+ Here is the call graph for this function:

◆ getLearningSequenceAdminIds()

ilLearningSequenceRoles::getLearningSequenceAdminIds ( )

Definition at line 232 of file class.ilLearningSequenceRoles.php.

References $users, and getDefaultLearningSequenceRoles().

Referenced by leaveLearningSequence().

233  {
234  $users = array();
235  $roles = $this->getDefaultLearningSequenceRoles((string) $this->object->getRefId());
236 
237  foreach ($this->rbacreview->assignedUsers($this->getDefaultAdminRole()) as $admin_id) {
238  array_push($users, $admin_id);
239  }
240 
241  return $users;
242  }
$users
Definition: authpage.php:44
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLearningSequenceMemberData()

ilLearningSequenceRoles::getLearningSequenceMemberData ( array  $user_ids,
int  $active = 1 
)

Definition at line 200 of file class.ilLearningSequenceRoles.php.

References $query, $result, $row, $users, ilDBConstants\FETCHMODE_OBJECT, PHP_EOL, and ilUtil\quoteArray().

201  {
202  $users = array();
203  $additional_where = "";
204 
205  if (is_numeric($active) && $active > -1) {
206  $additional_where = "AND active = '$active'" . PHP_EOL;
207  }
208 
209  $query =
210  "SELECT login, firstname, lastname, title, usr_id, last_login" . PHP_EOL
211  . "FROM usr_data " . PHP_EOL
212  . "WHERE usr_id IN (" . implode(',', ilUtil::quoteArray($user_ids)) . ") " . PHP_EOL
213  . $additional_where . PHP_EOL
214  . "ORDER BY lastname, firstname" . PHP_EOL
215  ;
216 
217  $result = $this->database->query($query);
218 
219  while ($row = $result->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
220  $users[] = [
221  "id" => $row->usr_id,
222  "login" => $row->login,
223  "firstname" => $row->firstname,
224  "lastname" => $row->lastname,
225  "last_login" => $row->last_login
226  ];
227  }
228 
229  return $users;
230  }
$result
PHP_EOL
Definition: complexTest.php:5
$query
$users
Definition: authpage.php:44
$row
static quoteArray($a_array)
Quotes all members of an array for usage in DB query statement.
+ Here is the call graph for this function:

◆ getLearningSequenceMemberIds()

ilLearningSequenceRoles::getLearningSequenceMemberIds ( )

Definition at line 169 of file class.ilLearningSequenceRoles.php.

References $users, and getLocalLearningSequenceRoles().

Referenced by leaveLearningSequence().

169  : array
170  {
171  $users = array();
172  $roles = $this->getLocalLearningSequenceRoles();
173 
174  foreach ($roles as $role) {
175  foreach ($this->rbacreview->assignedUsers($role) as $member_id) {
176  array_push($users, $member_id);
177  }
178  }
179 
180  $users = array_unique($users);
181 
182  return $users;
183  }
getLocalLearningSequenceRoles(bool $translate=false)
$users
Definition: authpage.php:44
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLocalLearningSequenceRoles()

ilLearningSequenceRoles::getLocalLearningSequenceRoles ( bool  $translate = false)
Returns
array [title|id] of roles...

Definition at line 92 of file class.ilLearningSequenceRoles.php.

References $local_roles, ilObjRole\_getTranslation(), and getRoleObject().

Referenced by getDefaultAdminRole(), getDefaultMemberRole(), and getLearningSequenceMemberIds().

92  : array
93  {
94  if (count($this->local_roles) == 0) {
95  $role_ids = $this->rbacreview->getRolesOfRoleFolder(
96  $this->object->getRefId()
97  );
98 
99  foreach ($role_ids as $role_id) {
100  if ($this->rbacreview->isAssignable(
101  $role_id,
102  $this->object->getRefId()
103  ) == true
104  ) {
105  $role = $this->getRoleObject((int) $role_id);
106 
107  if ($translate) {
108  $role_name = ilObjRole::_getTranslation($role->getTitle());
109  } else {
110  $role_name = $role->getTitle();
111  }
112 
113  $this->local_roles[$role_name] = (int) $role->getId();
114  }
115  }
116  }
117 
118  return $this->local_roles;
119  }
static _getTranslation($a_role_title)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRoleObject()

ilLearningSequenceRoles::getRoleObject ( int  $obj_id)
protected

Definition at line 271 of file class.ilLearningSequenceRoles.php.

References ilObjectFactory\getInstanceByObjId().

Referenced by getDefaultLearningSequenceRoles(), and getLocalLearningSequenceRoles().

272  {
273  return ilObjectFactory::getInstanceByObjId($obj_id);
274  }
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initDefaultRoles()

ilLearningSequenceRoles::initDefaultRoles ( )

Definition at line 72 of file class.ilLearningSequenceRoles.php.

References ilObjRole\createDefaultRole().

73  {
75  self::ROLE_LS_ADMIN . '_' . $this->object->getRefId(),
76  "LSO admin learning sequence obj_no." . $this->object->getId(),
77  self::ROLE_LS_ADMIN,
78  $this->object->getRefId()
79  );
80 
82  self::ROLE_LS_MEMBER . '_' . $this->object->getRefId(),
83  "LSO member of learning sequence obj_no." . $this->object->getId(),
84  self::ROLE_LS_MEMBER,
85  $this->object->getRefId()
86  );
87  }
static createDefaultRole($a_title, $a_description, $a_tpl_name, $a_ref_id)
+ Here is the call graph for this function:

◆ isPortfolio()

ilLearningSequenceRoles::isPortfolio ( array  $columns = null)
protected

Definition at line 364 of file class.ilLearningSequenceRoles.php.

References $columns.

Referenced by readMemberData().

364  : bool
365  {
366  if (is_null($columns)) {
367  return false;
368  }
369  return in_array(self::TYPE_PORTFOLIO, $columns);
370  }
if(! $in) $columns
Definition: Utf8Test.php:45
+ Here is the caller graph for this function:

◆ isTrackingEnabled()

ilLearningSequenceRoles::isTrackingEnabled ( )
protected

Definition at line 356 of file class.ilLearningSequenceRoles.php.

References ilObjUserTracking\_enabledLearningProgress(), and ilObjUserTracking\_enabledUserRelatedData().

Referenced by readMemberData().

356  : bool
357  {
358  return
361  ;
362  }
static _enabledUserRelatedData()
check wether user related tracking is enabled or not
static _enabledLearningProgress()
check wether learing progress is enabled or not
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ join()

ilLearningSequenceRoles::join ( int  $user_id,
  $roles 
)

Definition at line 138 of file class.ilLearningSequenceRoles.php.

Referenced by addLSMember().

138  : bool
139  {
140  if (is_array($roles)) {
141  foreach ($roles as $role) {
142  $this->rbacadmin->assignUser($role, $user_id, false);
143  }
144  } else {
145  $this->rbacadmin->assignUser($roles, $user_id, false);
146  }
147 
148  return true;
149  }
+ Here is the caller graph for this function:

◆ leave()

ilLearningSequenceRoles::leave ( int  $user_id)

Definition at line 185 of file class.ilLearningSequenceRoles.php.

Referenced by leaveLearningSequence().

185  : bool
186  {
187  $roles = $this->participants::getMemberRoles($this->object->getRefId());
188 
189  if (!is_array($roles)) {
190  return $this->rbacadmin->deassignUser($roles, $user_id);
191  }
192 
193  foreach ($roles as $role) {
194  $this->rbacadmin->deassignUser($role, $user_id);
195  }
196 
197  return true;
198  }
+ Here is the caller graph for this function:

◆ leaveLearningSequence()

ilLearningSequenceRoles::leaveLearningSequence ( )

Definition at line 151 of file class.ilLearningSequenceRoles.php.

References ilObjUser\dropDesktopItem(), getLearningSequenceAdminIds(), getLearningSequenceMemberIds(), leave(), and user().

151  : int
152  {
153  $member_ids = $this->getLearningSequenceMemberIds();
154 
155  if (count($member_ids) <= 1 || !in_array($this->user->getId(), $member_ids)) {
156  return 2;
157  } else {
158  if (!$this->isAdmin($this->user->getId())) {
159  $this->leave($this->user->getId());
160  $member = new ilObjUser($this->user->getId());
161  $member->dropDesktopItem($this->getRefId(), "lso");
162  return 0;
163  } elseif (count($this->getLearningSequenceAdminIds()) == 1) {
164  return 1;
165  }
166  }
167  }
dropDesktopItem($a_item_id, $a_type)
drop an item from user&#39;s personal desktop
user()
Definition: user.php:4
+ Here is the call graph for this function:

◆ readMemberData()

ilLearningSequenceRoles::readMemberData ( array  $user_ids,
array  $selected_columns = null 
)

Definition at line 276 of file class.ilLearningSequenceRoles.php.

References $data, $failed, $name, ilPrivacySettings\_getInstance(), ilLPStatusWrapper\_lookupCompletedForObject(), ilLPStatusWrapper\_lookupFailedForObject(), ilLPStatusWrapper\_lookupInProgressForObject(), ilObjUser\_lookupLogin(), ilObjUser\_lookupName(), ilLearningProgress\_lookupProgressByObjId(), ilObjUser\_readUsersProfileData(), ilDatePresentation\formatDate(), ilObjPortfolio\getAvailablePortfolioLinksForUserIds(), ilObjectLP\getInstance(), IL_CAL_UNIX, isPortfolio(), isTrackingEnabled(), ilLPStatus\LP_STATUS_COMPLETED, ilLPStatus\LP_STATUS_FAILED, ilLPStatus\LP_STATUS_IN_PROGRESS, and ilLPStatus\LP_STATUS_NOT_ATTEMPTED.

276  : array
277  {
278  $portfolio_enabled = $this->isPortfolio($selected_columns);
279  $tracking_enabled = $this->isTrackingEnabled();
280  $privacy = ilPrivacySettings::_getInstance();
281 
282  if ($tracking_enabled) {
283  $olp = ilObjectLP::getInstance($this->object->getId());
284  $tracking_enabled = $olp->isActive();
285 
286  $completed = ilLPStatusWrapper::_lookupCompletedForObject($this->object->getId());
287  $in_progress = ilLPStatusWrapper::_lookupInProgressForObject($this->object->getId());
288  $failed = ilLPStatusWrapper::_lookupFailedForObject($this->object->getId());
289  }
290 
291  if ($privacy->enabledLearningSequenceAccessTimes()) {
292  $progress = ilLearningProgress::_lookupProgressByObjId($this->object->getId());
293  }
294 
295  if ($portfolio_enabled) {
297  $user_ids,
298  $this->ctrl->getLinkTargetByClass("ilLearningSequenceMembershipGUI", "members")
299  );
300  }
301 
302  $members = array();
303  $profile_data = ilObjUser::_readUsersProfileData($user_ids);
304  foreach ($user_ids as $usr_id) {
305  $data = array();
306  $name = ilObjUser::_lookupName($usr_id);
307 
308  $data['firstname'] = $name['firstname'];
309  $data['lastname'] = $name['lastname'];
310  $data['login'] = ilObjUser::_lookupLogin($usr_id);
311  $data['usr_id'] = $usr_id;
312 
313  $data['notification'] = 0;
314  if ($this->object->getLSParticipants()->isNotificationEnabled($usr_id)) {
315  $data['notification'] = 1;
316  }
317 
318  foreach ($profile_data[$usr_id] as $field => $value) {
319  $data[$field] = $value;
320  }
321 
322  if ($tracking_enabled) {
323  if (in_array($usr_id, $completed)) {
325  } elseif (in_array($usr_id, $in_progress)) {
327  } elseif (in_array($usr_id, $failed)) {
328  $data['progress'] = ilLPStatus::LP_STATUS_FAILED;
329  } else {
331  }
332  }
333 
334  if ($privacy->enabledLearningSequenceAccessTimes()) {
335  if (isset($progress[$usr_id]['ts']) and $progress[$usr_id]['ts']) {
336  $data['access_time'] = ilDatePresentation::formatDate(
337  $date = new ilDateTime($progress[$usr_id]['ts'], IL_CAL_UNIX)
338  );
339  $data['access_time_unix'] = $date->get(IL_CAL_UNIX);
340  } else {
341  $data['access_time'] = $this->lng->txt('no_date');
342  $data['access_time_unix'] = 0;
343  }
344  }
345 
346  if ($portfolio_enabled) {
347  $data['prtf'] = $portfolios[$usr_id];
348  }
349 
350  $members[$usr_id] = $data;
351  }
352 
353  return $members;
354  }
static _lookupLogin($a_user_id)
lookup login
static _lookupName($a_user_id)
lookup user name
const LP_STATUS_NOT_ATTEMPTED
static _lookupFailedForObject($a_obj_id, $a_user_ids=null)
Get failed users for object.
const IL_CAL_UNIX
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
static _readUsersProfileData($a_user_ids)
STATIC METHOD get user data of selected users.
const LP_STATUS_IN_PROGRESS
const LP_STATUS_FAILED
static _lookupProgressByObjId($a_obj_id)
lookup progress for a specific object
Date and time handling
static getAvailablePortfolioLinksForUserIds(array $a_owner_ids, $a_back_url=null)
$failed
Definition: Utf8Test.php:85
static _lookupInProgressForObject($a_obj_id, $a_user_ids=null)
Get in progress users for object.
static _getInstance()
Get instance of ilPrivacySettings.
static _lookupCompletedForObject($a_obj_id, $a_user_ids=null)
Get completed users for object.
const LP_STATUS_COMPLETED
static getInstance($a_obj_id)
$data
Definition: bench.php:6
+ Here is the call graph for this function:

Field Documentation

◆ $database

ilLearningSequenceRoles::$database
protected

Definition at line 40 of file class.ilLearningSequenceRoles.php.

Referenced by __construct().

◆ $local_roles

ilLearningSequenceRoles::$local_roles
protected

Definition at line 50 of file class.ilLearningSequenceRoles.php.

Referenced by getLocalLearningSequenceRoles().

◆ $object

ilLearningSequenceRoles::$object
protected

◆ $participants

ilLearningSequenceRoles::$participants
protected

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

Referenced by __construct().

◆ $rbacadmin

ilLearningSequenceRoles::$rbacadmin
protected

Definition at line 30 of file class.ilLearningSequenceRoles.php.

Referenced by __construct().

◆ $rbacreview

ilLearningSequenceRoles::$rbacreview
protected

Definition at line 35 of file class.ilLearningSequenceRoles.php.

Referenced by __construct().

◆ $user

ilLearningSequenceRoles::$user
protected

Definition at line 45 of file class.ilLearningSequenceRoles.php.

Referenced by __construct().

◆ ROLE_LS_ADMIN

const ilLearningSequenceRoles::ROLE_LS_ADMIN = "il_lso_admin"

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

◆ ROLE_LS_MEMBER

const ilLearningSequenceRoles::ROLE_LS_MEMBER = "il_lso_member"

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

◆ TYPE_PORTFOLIO

const ilLearningSequenceRoles::TYPE_PORTFOLIO = "prtf"

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


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