ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilLearningSequenceRoles Class Reference

Provides Role actions. More...

+ Collaboration diagram for ilLearningSequenceRoles:

Public Member Functions

 __construct (int $ls_ref_id, int $ls_obj_id, 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, int $role=null)
 
 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)
 
 isMember (int $usr_id)
 
 isCompletedByUser (int $usr_id)
 

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 ( int  $ls_ref_id,
int  $ls_obj_id,
ilLearningSequenceParticipants  $participants,
ilCtrl  $ctrl,
ilRbacAdmin  $rbacadmin,
ilRbacReview  $rbacreview,
ilDBInterface  $database,
ilObjUser  $user 
)

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

62 {
63 //$this->object = $object;
64 $this->ref_id = $ls_ref_id;
65 $this->obj_id = $ls_obj_id;
66 $this->participants = $participants;
67 $this->ctrl = $ctrl;
68 $this->rbacadmin = $rbacadmin;
69 $this->rbacreview = $rbacreview;
70 $this->database = $database;
71 $this->user = $user;
72
73 $this->local_roles = array();
74 }
user()
Definition: user.php:4

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

+ Here is the call graph for this function:

Member Function Documentation

◆ addLSMember()

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

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

137 : bool
138 {
139 return $this->join($user_id, $role);
140 }
join(int $user_id, int $role=null)

References join().

+ Here is the call graph for this function:

◆ getDefaultAdminRole()

ilLearningSequenceRoles::getDefaultAdminRole ( )

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

131 : int
132 {
133 $local_ls_roles = $this->getLocalLearningSequenceRoles();
134 return $local_ls_roles[self::ROLE_LS_ADMIN . "_" . $this->ref_id];
135 }
getLocalLearningSequenceRoles(bool $translate=false)

References getLocalLearningSequenceRoles().

+ Here is the call graph for this function:

◆ getDefaultLearningSequenceRoles()

ilLearningSequenceRoles::getDefaultLearningSequenceRoles ( string  $lso_id)

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

244 : array
245 {
246 if (strlen($lso_id) == 0) {
247 $lso_id = $this->ref_id;
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 }

References $object, and getRoleObject().

Referenced by getLearningSequenceAdminIds().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDefaultMemberRole()

ilLearningSequenceRoles::getDefaultMemberRole ( )

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

125 : int
126 {
127 $local_ls_roles = $this->getLocalLearningSequenceRoles();
128 return $local_ls_roles[self::ROLE_LS_MEMBER . "_" . $this->ref_id];
129 }

References getLocalLearningSequenceRoles().

Referenced by join().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLearningSequenceAdminIds()

ilLearningSequenceRoles::getLearningSequenceAdminIds ( )

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

233 {
234 $users = array();
235 $roles = $this->getDefaultLearningSequenceRoles((string) $this->ref_id);
236
237 foreach ($this->rbacreview->assignedUsers($this->getDefaultAdminRole()) as $admin_id) {
238 array_push($users, $admin_id);
239 }
240
241 return $users;
242 }

References getDefaultLearningSequenceRoles().

Referenced by leaveLearningSequence().

+ 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.

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
static quoteArray($a_array)
Quotes all members of an array for usage in DB query statement.
$query

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

+ Here is the call graph for this function:

◆ getLearningSequenceMemberIds()

ilLearningSequenceRoles::getLearningSequenceMemberIds ( )

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

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 }

References getLocalLearningSequenceRoles().

Referenced by leaveLearningSequence().

+ 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 96 of file class.ilLearningSequenceRoles.php.

96 : array
97 {
98 if (count($this->local_roles) == 0) {
99 $role_ids = $this->rbacreview->getRolesOfRoleFolder(
100 $this->ref_id
101 );
102
103 foreach ($role_ids as $role_id) {
104 if ($this->rbacreview->isAssignable(
105 $role_id,
106 $this->ref_id
107 ) == true
108 ) {
109 $role = $this->getRoleObject((int) $role_id);
110
111 if ($translate) {
112 $role_name = ilObjRole::_getTranslation($role->getTitle());
113 } else {
114 $role_name = $role->getTitle();
115 }
116
117 $this->local_roles[$role_name] = (int) $role->getId();
118 }
119 }
120 }
121
122 return $this->local_roles;
123 }
static _getTranslation($a_role_title)

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

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

+ 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.

272 {
274 }
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id

References ilObjectFactory\getInstanceByObjId().

Referenced by getDefaultLearningSequenceRoles(), and getLocalLearningSequenceRoles().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initDefaultRoles()

ilLearningSequenceRoles::initDefaultRoles ( )

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

77 {
79 self::ROLE_LS_ADMIN . '_' . $this->ref_id,
80 "LSO admin learning sequence obj_no." . $this->obj_id,
81 self::ROLE_LS_ADMIN,
82 $this->ref_id
83 );
84
86 self::ROLE_LS_MEMBER . '_' . $this->ref_id,
87 "LSO member of learning sequence obj_no." . $this->obj_id,
88 self::ROLE_LS_MEMBER,
89 $this->ref_id
90 );
91 }
static createDefaultRole($a_title, $a_description, $a_tpl_name, $a_ref_id)

References ilObjRole\createDefaultRole().

+ Here is the call graph for this function:

◆ isCompletedByUser()

ilLearningSequenceRoles::isCompletedByUser ( int  $usr_id)

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

377 : bool
378 {
379 \ilLPStatusWrapper::_updateStatus($this->obj_id, $usr_id);
381 $user_completion = ilLPStatus::_hasUserCompleted($this->obj_id, $usr_id);
382 return ($tracking_active && $user_completion);
383 }
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
static _hasUserCompleted($a_obj_id, $a_user_id)
Lookup user object completion.
static _enabledLearningProgress()
check wether learing progress is enabled or not

References ilObjUserTracking\_enabledLearningProgress(), ilLPStatus\_hasUserCompleted(), and ilLPStatusWrapper\_updateStatus().

+ Here is the call graph for this function:

◆ isMember()

ilLearningSequenceRoles::isMember ( int  $usr_id)

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

373 {
374 return $this->participants->isMember($usr_id);
375 }

◆ isPortfolio()

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

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

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

References $columns.

Referenced by readMemberData().

+ Here is the caller graph for this function:

◆ isTrackingEnabled()

ilLearningSequenceRoles::isTrackingEnabled ( )
protected

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

356 : bool
357 {
358 return
361 ;
362 }
static _enabledUserRelatedData()
check wether user related tracking is enabled or not

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

Referenced by readMemberData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ join()

ilLearningSequenceRoles::join ( int  $user_id,
int  $role = null 
)

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

142 : bool
143 {
144 if (is_null($role)) {
145 $role = $this->getDefaultMemberRole();
146 }
147 $this->rbacadmin->assignUser($role, $user_id);
148 return true;
149 }

References getDefaultMemberRole().

Referenced by addLSMember().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ leave()

ilLearningSequenceRoles::leave ( int  $user_id)

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

185 : bool
186 {
187 $roles = $this->participants::getMemberRoles($this->ref_id);
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 }

Referenced by leaveLearningSequence().

+ Here is the caller graph for this function:

◆ leaveLearningSequence()

ilLearningSequenceRoles::leaveLearningSequence ( )

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

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 }

References getLearningSequenceAdminIds(), getLearningSequenceMemberIds(), leave(), and user().

+ 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.

276 : array
277 {
278 $portfolio_enabled = $this->isPortfolio($selected_columns);
279 $tracking_enabled = $this->isTrackingEnabled();
281
282 if ($tracking_enabled) {
283 $olp = ilObjectLP::getInstance($this->obj_id);
284 $tracking_enabled = $olp->isActive();
285
286 $completed = ilLPStatusWrapper::_lookupCompletedForObject($this->obj_id);
287 $in_progress = ilLPStatusWrapper::_lookupInProgressForObject($this->obj_id);
289 }
290
291 if ($privacy->enabledLearningSequenceAccessTimes()) {
292 $progress = ilLearningProgress::_lookupProgressByObjId($this->obj_id);
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->participants->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)) {
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 }
$failed
Definition: Utf8Test.php:85
const IL_CAL_UNIX
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
@classDescription Date and time handling
static _lookupCompletedForObject($a_obj_id, $a_user_ids=null)
Get completed users for object.
static _lookupFailedForObject($a_obj_id, $a_user_ids=null)
Get failed users for object.
static _lookupInProgressForObject($a_obj_id, $a_user_ids=null)
Get in progress users for object.
const LP_STATUS_COMPLETED
const LP_STATUS_FAILED
const LP_STATUS_NOT_ATTEMPTED
const LP_STATUS_IN_PROGRESS
static _lookupProgressByObjId($a_obj_id)
lookup progress for a specific object
static getAvailablePortfolioLinksForUserIds(array $a_owner_ids, $a_back_url=null)
static _lookupLogin($a_user_id)
lookup login
static _lookupName($a_user_id)
lookup user name
static _readUsersProfileData($a_user_ids)
STATIC METHOD get user data of selected users.
static getInstance($a_obj_id)
static _getInstance()
Get instance of ilPrivacySettings.
if($format !==null) $name
Definition: metadata.php:230
$data
Definition: storeScorm.php:23

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.

+ 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

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

Referenced by getDefaultLearningSequenceRoles().

◆ $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: