19declare(strict_types=1);
54 self::START_PD_OVERVIEW =>
'ilias.php?baseClass=ilDashboardGUI&cmd=jumpToSelectedItems',
55 self::START_PD_SUBSCRIPTION =>
'ilias.php?baseClass=ilMembershipOverviewGUI',
56 self::START_PD_WORKSPACE =>
'ilias.php?baseClass=ilDashboardGUI&cmd=jumpToWorkspace',
57 self::START_PD_CALENDAR =>
'ilias.php?baseClass=ilDashboardGUI&cmd=jumpToCalendar',
67 private readonly \
ilTree $tree,
71 private readonly UserSettingsRepository $user_settings_repository
77 ))->hasCurrentUserAccessToMyStaff();
86 $query =
'SELECT * FROM usr_starting_point WHERE id = ' . $this->db->quote(
$id,
'integer');
87 $res = $this->db->query($query);
88 $starting_point_array = $this->db->fetchAssoc(
$res);
90 if ($starting_point_array ===
null) {
91 $default_starting_point =
new StartingPoint(self::DEFAULT_STARTING_POINT_ID);
96 return $default_starting_point;
101 $starting_point_array[
'starting_point'],
102 $starting_point_array[
'starting_object'],
103 $starting_point_array[
'position'],
104 $starting_point_array[
'rule_type'],
105 $starting_point_array[
'rule_options'],
106 $starting_point_array[
'calendar_view'],
107 $starting_point_array[
'calendar_period']
116 $query =
'SELECT * FROM usr_starting_point';
117 $res = $this->db->query($query);
118 $starting_points = [];
119 while ($starting_point_array = $this->db->fetchAssoc(
$res)) {
121 $starting_point_array[
'id'],
122 $starting_point_array[
'starting_point'],
123 $starting_point_array[
'starting_object'],
124 $starting_point_array[
'position'],
125 $starting_point_array[
'rule_type'],
126 $starting_point_array[
'rule_options'],
127 $starting_point_array[
'calendar_view'],
128 $starting_point_array[
'calendar_period']
131 $starting_points[] = $starting_point;
134 return $starting_points;
150 if ($role_id === $role->
getId()
152 || !($maybe_deleted_role instanceof \
ilObjRole)
154 $this->
delete(
$data[
'id']);
164 $query =
'SELECT * FROM usr_starting_point WHERE rule_options LIKE %s ORDER BY position ASC';
165 $res = $this->db->queryF($query, [
'text'], [
'%role_id%']);
168 while ($sp = $this->db->fetchAssoc(
$res)) {
169 $options = unserialize($sp[
'rule_options']);
171 $roles[(
int) $options[
'role_id']] = [
172 'id' => (
int) $sp[
'id'],
173 'starting_point' => (
int) $sp[
'starting_point'],
174 'starting_object' => (
int) $sp[
'starting_object'],
175 'calendar_view' => (
int) $sp[
'calendar_view'],
176 'calendar_period' => (
int) $sp[
'calendar_period'],
177 'position' => (
int) $sp[
'position'],
178 'role_id' => (
int) $options[
'role_id'],
187 $global_roles = $this->rbac_review->getGlobalRoles();
190 $ids_roles_with_sp = [];
191 foreach ($roles_with_starting_point as $role) {
192 $ids_roles_with_sp[] = $role[
'role_id'];
195 $ids_roles_without_sp = array_diff($global_roles, $ids_roles_with_sp);
198 foreach ($ids_roles_without_sp as $roleid) {
202 $role_obj = new \ilObjRole($roleid);
204 'id' => $role_obj->getId(),
205 'title' => $role_obj->getTitle(),
214 if ($starting_point->
getId() === $this->getDefaultStartingPointID()) {
220 $position = $max_position + 10;
222 $next_id = $this->db->nextId(
'usr_starting_point');
234 $this->db->manipulateF(
235 'INSERT INTO usr_starting_point (id, starting_point, starting_object, position, rule_type, rule_options, calendar_view, calendar_period) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)',
255 if ($starting_point->
getId() === $this->getDefaultStartingPointID()) {
260 $this->db->manipulateF(
261 'UPDATE usr_starting_point
262 SET starting_point = %s,
263 starting_object = %s,
288 $starting_point->
getId()
293 public function delete(
int $starting_point_id):
void
295 $query =
'DELETE FROM usr_starting_point WHERE id = ' . $this->db->quote($starting_point_id,
'integer');
296 $this->db->manipulate($query);
302 $result = $this->db->query(
'SELECT max(position) as max_order FROM usr_starting_point');
305 while ($row = $this->db->fetchAssoc($result)) {
306 $order_val = (
int) $row[
'max_order'];
315 foreach ($a_items as $v) {
316 $v[
'starting_position'] = $ord_const;
317 $rearranged[$ord_const] = $v;
327 foreach ($a_items as
$id => $position) {
328 if ($position > self::ORDER_POSITION_MIN && $position < self::ORDER_POSITION_MAX) {
329 $this->db->manipulate(
330 'UPDATE usr_starting_point SET' .
331 ' position = ' . $this->db->quote($nr,
'integer') .
332 ' WHERE id = ' . $this->db->quote(
$id,
'integer')
346 if ($this->current_user_has_access_to_my_staff) {
350 if ($force_all || !$this->
settings->get(
'disable_personal_workspace')) {
354 if ($force_all || $calendar_settings->isEnabled()) {
367 $current = (
int) $this->
settings->get(
'usr_starting_point');
368 if (!$current || !in_array($current,
$valid)) {
373 || !$this->user->getId()) {
381 if ($this->
settings->get(
'disable_my_offers') ===
'0' &&
382 $this->settings->get(
'disable_my_memberships') ===
'0' &&
383 $this->settings->get(
'personal_items_default_view') ===
'1') {
393 $starting_point_type = $starting_point->getStartingPointType();
396 if (in_array($starting_point_type, $valid_starting_points)) {
397 $this->
settings->set(
'usr_starting_point', (
string) $starting_point_type);
412 $starting_point = $this->getApplicableStartingPointTypeInfo($this->
user);
414 if ($starting_point[
'type'] === self::START_REPOSITORY_OBJ
416 $starting_point[
'object'] ===
null
418 || $this->tree->isDeleted($starting_point[
'object'])
419 || !$this->rbac_system->checkAccessOfUser(
420 $this->user->getId(),
422 $starting_point[
'object']
426 $this->log->user()->debug(sprintf(
'Permission to Starting Point Denied. Starting Point Type: %s.', $starting_point[
'type']));
427 $starting_point[
'type'] = self::START_REPOSITORY;
430 if ($starting_point[
'type'] === self::START_REPOSITORY
431 && !$this->rbac_system->checkAccessOfUser(
432 $this->user->getId(),
434 $this->tree->getRootId()
436 || $starting_point[
'type'] === self::START_PD_CALENDAR
439 $this->log->user()->debug(sprintf(
'Permission to Starting Point Denied. Starting Point Type: %s.', $starting_point[
'type']));
440 $starting_point[
'type'] = $this->getFallbackStartingPointType();
443 if ($starting_point[
'type'] === self::START_REPOSITORY) {
444 $starting_point[
'object'] = $this->tree->getRootId();
447 return $this->getLinkUrlByStartingPointTypeInfo($starting_point);
453 if ($this->isPersonalStartingPointEnabled()
454 && $this->getPersonalStartingPointForUser($user) !== 0) {
456 'type' => $this->getPersonalStartingPointForUser($user),
457 'object' => $this->getPersonalStartingObjectForUser($user)
461 $role = $this->getFirstRoleWithStartingPointForUserId($this->
user->getId());
464 'type' => $role[
'starting_point'],
465 'object' => $role[
'starting_object'],
466 'cal_view' => $role[
'calendar_view'],
467 'cal_period' => $role[
'calendar_period']
472 'type' => $this->getSystemDefaultStartingPointType(),
473 'object' => $this->getSystemDefaultStartingObject(),
474 'cal_view' => $this->getSystemDefaultCalendarView(),
475 'cal_period' => $this->getSystemDefaultCalendarPeriod()
481 $roles = $this->getRolesWithStartingPoint();
482 $role_ids = array_keys($roles);
483 foreach ($role_ids as $role_id) {
484 if ($this->rbac_review->isAssigned(
$user_id, $role_id)) {
485 return $roles[$role_id];
493 $type = $starting_point[
'type'];
494 if ($type === self::START_REPOSITORY
495 || $type === self::START_REPOSITORY_OBJ) {
496 return \ilLink::_getStaticLink($starting_point[
'object'],
'',
true);
499 $url = self::URL_LINKS_BY_TYPE[$type];
500 if ($type == self::START_PD_CALENDAR) {
501 $cal_view = $starting_point[
'cal_view'] ??
'';
502 $cal_period = $starting_point[
'cal_period'] ??
'';
503 $calendar_string =
'';
504 if (!empty($cal_view) && !empty($cal_period)) {
505 $calendar_string =
'&cal_view=' . $cal_view .
'&cal_agenda_per=' . $cal_period;
507 $url .= $calendar_string;
515 return (
int) $this->
settings->get(
'usr_starting_point_ref_id');
523 return (
int) $this->
settings->get(
'user_calendar_view');
531 return (
int) $this->
settings->get(
'user_cal_period');
539 $this->
settings->set(
'usr_starting_point_personal', $value ?
'1' :
'0');
544 return $this->user_settings_repository->getByIdentifier(
'starting_point')->isChangeableByUser();
550 return !empty($user->getPref(
'usr_starting_point'));
556 $current = $user->getPref(
'usr_starting_point');
557 if ($current !==
null
558 && in_array((
int) $current, array_keys($this->getPossibleStartingPoints()))) {
559 return (
int) $current;
570 int $starting_point_type,
573 if ($starting_point_type === 0) {
575 $user->
deletePref(
'usr_starting_point_ref_id');
579 if ($starting_point_type === self::START_REPOSITORY_OBJ) {
581 !$this->tree->isDeleted(
$ref_id)) {
582 $user->
setPref(
'usr_starting_point', (
string) $starting_point_type);
587 $valid = array_keys($this->getPossibleStartingPoints());
588 if (in_array($starting_point_type,
$valid)) {
589 $user->
setPref(
'usr_starting_point', (
string) $starting_point_type);
598 $personal_starting_object = $user->getPref(
'usr_starting_point_ref_id');
599 if ($personal_starting_object !==
null) {
600 return (
int) $personal_starting_object;
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Provides fluid interface to LoggingServices.
saveOrder(array $a_items)
getFirstRoleWithStartingPointForUserId(int $user_id)
save(StartingPoint $starting_point)
getDefaultStartingPointID()
getLinkUrlByStartingPointTypeInfo(array $starting_point)
getPersonalStartingPointForUser(\ilObjUser $user)
getRolesWithStartingPoint()
getPossibleStartingPoints(bool $force_all=false)
getSystemDefaultStartingObject()
reArrangePositions(array $a_items)
getApplicableStartingPointTypeInfo(\ilObjUser $user)
getSystemDefaultCalendarView()
Get specific view of calendar starting point.
__construct(private readonly \ilObjUser $user, private readonly \ilDBInterface $db, private readonly LoggingServices $log, private readonly \ilTree $tree, private readonly \ilRbacReview $rbac_review, private readonly \ilRbacSystem $rbac_system, private readonly \ilSetting $settings, private readonly UserSettingsRepository $user_settings_repository)
update(StartingPoint $starting_point)
update starting point
getGlobalRolesWithoutStartingPoint()
isPersonalStartingPointEnabledForUser(\ilObjUser $user)
setPersonalStartingPointForUser(\ilObjUser $user, int $starting_point_type, ?int $ref_id=null)
Set personal starting point setting.
const DEFAULT_STARTING_POINT_ID
const START_REPOSITORY_OBJ
getStartingPointById(?int $id)
const USER_STARTING_POINT_ID
getValidAndAccessibleStartingPointAsUrl()
getFallbackStartingPointType()
getSystemDefaultStartingPointType()
bool $current_user_has_access_to_my_staff
getSystemDefaultCalendarPeriod()
Get time frame of calendar view.
getPersonalStartingObjectForUser(\ilObjUser $user)
setSystemDefaultStartingPoint(StartingPoint $starting_point)
onRoleDeleted(\ilObjRole $role)
togglePersonalStartingPointActivation(bool $value)
Toggle personal starting point setting.
isPersonalStartingPointEnabled()
const START_PD_SUBSCRIPTION
getCalendarView()
Gets calendar view.
const CMD_JUMP_TO_MY_STAFF
setPref(string $a_keyword, ?string $a_value)
deletePref(string $keyword)
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
static _lookupObjId(int $ref_id)
class ilRbacReview Contains Review functions of core Rbac.
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if(!file_exists('../ilias.ini.php'))