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 UserSettingsConfigurationRepository $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'], [
'allowed_classes' =>
false]);
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'],
190 $global_roles = $this->rbac_review->getGlobalRoles();
193 $ids_roles_with_sp = [];
194 foreach ($roles_with_starting_point as $role) {
195 $ids_roles_with_sp[] = $role[
'role_id'];
198 $ids_roles_without_sp = array_diff($global_roles, $ids_roles_with_sp);
201 foreach ($ids_roles_without_sp as $roleid) {
205 $role_obj = new \ilObjRole($roleid);
207 'id' => $role_obj->getId(),
208 'title' => $role_obj->getTitle(),
217 if ($starting_point->
getId() === $this->getDefaultStartingPointID()) {
223 $position = $max_position + 10;
225 $next_id = $this->db->nextId(
'usr_starting_point');
237 $this->db->manipulateF(
238 '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)',
258 if ($starting_point->
getId() === $this->getDefaultStartingPointID()) {
263 $this->db->manipulateF(
264 'UPDATE usr_starting_point
265 SET starting_point = %s,
266 starting_object = %s,
291 $starting_point->
getId()
296 public function delete(
int $starting_point_id):
void
298 $query =
'DELETE FROM usr_starting_point WHERE id = ' . $this->db->quote($starting_point_id,
'integer');
299 $this->db->manipulate($query);
305 $result = $this->db->query(
'SELECT max(position) as max_order FROM usr_starting_point');
308 while ($row = $this->db->fetchAssoc($result)) {
309 $order_val = (
int) $row[
'max_order'];
322 foreach ($a_items as $v) {
323 $v[
'starting_position'] = $ord_const;
324 $rearranged[$ord_const] = $v;
334 foreach ($a_items as
$id => $position) {
335 if ($position > self::ORDER_POSITION_MIN && $position < self::ORDER_POSITION_MAX) {
336 $this->db->manipulate(
337 'UPDATE usr_starting_point SET' .
338 ' position = ' . $this->db->quote($nr,
'integer') .
339 ' WHERE id = ' . $this->db->quote(
$id,
'integer')
356 if ($this->current_user_has_access_to_my_staff) {
360 if ($force_all || !$this->
settings->get(
'disable_personal_workspace')) {
364 if ($force_all || $calendar_settings->isEnabled()) {
377 $current = (
int) $this->
settings->get(
'usr_starting_point');
378 if (!$current || !in_array($current,
$valid)) {
383 || !$this->user->getId()) {
391 if ($this->
settings->get(
'disable_my_offers') ===
'0' &&
392 $this->settings->get(
'disable_my_memberships') ===
'0' &&
393 $this->settings->get(
'personal_items_default_view') ===
'1') {
403 $starting_point_type = $starting_point->getStartingPointType();
406 if (in_array($starting_point_type, $valid_starting_points)) {
407 $this->
settings->set(
'usr_starting_point', (
string) $starting_point_type);
422 $starting_point = $this->getApplicableStartingPointTypeInfo($this->
user);
424 if ($starting_point[
'type'] === self::START_REPOSITORY_OBJ
426 $starting_point[
'object'] ===
null
428 || $this->tree->isDeleted($starting_point[
'object'])
429 || !$this->rbac_system->checkAccessOfUser(
430 $this->user->getId(),
432 $starting_point[
'object']
436 $this->log->user()->debug(sprintf(
'Permission to Starting Point Denied. Starting Point Type: %s.', $starting_point[
'type']));
437 $starting_point[
'type'] = self::START_REPOSITORY;
440 if ($starting_point[
'type'] === self::START_REPOSITORY
441 && !$this->rbac_system->checkAccessOfUser(
442 $this->user->getId(),
444 $this->tree->getRootId()
446 || $starting_point[
'type'] === self::START_PD_CALENDAR
449 $this->log->user()->debug(sprintf(
'Permission to Starting Point Denied. Starting Point Type: %s.', $starting_point[
'type']));
450 $starting_point[
'type'] = $this->getFallbackStartingPointType();
453 if ($starting_point[
'type'] === self::START_REPOSITORY) {
454 $starting_point[
'object'] = $this->tree->getRootId();
457 return $this->getLinkUrlByStartingPointTypeInfo($starting_point);
463 if ($this->isPersonalStartingPointEnabled()
464 && $this->getPersonalStartingPointForUser($user) !== 0) {
466 'type' => $this->getPersonalStartingPointForUser($user),
467 'object' => $this->getPersonalStartingObjectForUser($user)
471 $role = $this->getFirstRoleWithStartingPointForUserId($this->
user->getId());
474 'type' => $role[
'starting_point'],
475 'object' => $role[
'starting_object'],
476 'cal_view' => $role[
'calendar_view'],
477 'cal_period' => $role[
'calendar_period']
482 'type' => $this->getSystemDefaultStartingPointType(),
483 'object' => $this->getSystemDefaultStartingObject(),
484 'cal_view' => $this->getSystemDefaultCalendarView(),
485 'cal_period' => $this->getSystemDefaultCalendarPeriod()
491 $roles = $this->getRolesWithStartingPoint();
492 $role_ids = array_keys($roles);
493 foreach ($role_ids as $role_id) {
494 if ($this->rbac_review->isAssigned(
$user_id, $role_id)) {
495 return $roles[$role_id];
503 $type = $starting_point[
'type'];
504 if ($type === self::START_REPOSITORY
505 || $type === self::START_REPOSITORY_OBJ) {
506 return \ilLink::_getStaticLink($starting_point[
'object'],
'',
true);
509 $url = self::URL_LINKS_BY_TYPE[$type];
510 if ($type == self::START_PD_CALENDAR) {
511 $cal_view = $starting_point[
'cal_view'] ??
'';
512 $cal_period = $starting_point[
'cal_period'] ??
'';
513 $calendar_string =
'';
514 if (!empty($cal_view) && !empty($cal_period)) {
515 $calendar_string =
'&cal_view=' . $cal_view .
'&cal_agenda_per=' . $cal_period;
517 $url .= $calendar_string;
525 return (
int) $this->
settings->get(
'usr_starting_point_ref_id');
533 return (
int) $this->
settings->get(
'user_calendar_view');
541 return (
int) $this->
settings->get(
'user_calendar_period');
549 $this->
settings->set(
'usr_starting_point_personal', $value ?
'1' :
'0');
554 return $this->user_settings_repository->getByIdentifier(
'starting_point')->isChangeableByUser();
560 return !empty($user->getPref(
'usr_starting_point'));
566 $current = $user->getPref(
'usr_starting_point');
567 if ($current !==
null
568 && in_array((
int) $current, array_keys($this->getPossibleStartingPoints()))) {
569 return (
int) $current;
580 int $starting_point_type,
583 if ($starting_point_type === 0) {
585 $user->
deletePref(
'usr_starting_point_ref_id');
589 if ($starting_point_type === self::START_REPOSITORY_OBJ) {
591 !$this->tree->isDeleted(
$ref_id)) {
592 $user->
setPref(
'usr_starting_point', (
string) $starting_point_type);
597 $valid = array_keys($this->getPossibleStartingPoints());
598 if (in_array($starting_point_type,
$valid)) {
599 $user->
setPref(
'usr_starting_point', (
string) $starting_point_type);
608 $personal_starting_object = $user->getPref(
'usr_starting_point_ref_id');
609 if ($personal_starting_object !==
null) {
610 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.
update(StartingPoint $starting_point)
update starting point
getGlobalRolesWithoutStartingPoint()
isPersonalStartingPointEnabledForUser(\ilObjUser $user)
__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 UserSettingsConfigurationRepository $user_settings_repository)
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)
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'))