19declare(strict_types=1);
51 $this->db =
$DIC->database();
58 $query =
"SELECT * FROM usr_starting_point WHERE id = " . $this->db->quote($this->
id,
'integer');
61 while ($point = $this->db->fetchAssoc(
$res)) {
74 $this->starting_point = $a_starting_point;
84 $this->starting_object = $a_starting_object;
94 $this->starting_position = $a_starting_position;
104 $this->rule_type = $a_rule_type;
117 $this->rule_options = $a_rule_options;
160 $query =
"SELECT * FROM usr_starting_point";
163 while ($point =
$ilDB->fetchAssoc(
$res)) {
165 "id" => $point[
"id"],
166 "position" => $point[
"position"],
167 "starting_point" => $point[
'starting_point'],
168 "starting_object" => $point[
'starting_object'],
169 "calendar_view" => $point[
'calendar_view'],
170 "calendar_period" => $point[
'calendar_period'],
171 "rule_type" => $point[
'rule_type'],
172 "rule_options" => $point[
'rule_options']
181 foreach (self::getRolesWithStartingPoint() as $roleId =>
$data) {
182 if ($roleId === $role->
getId()) {
187 !($maybeDeletedRole instanceof
ilObjRole)
204 $query =
"SELECT * FROM usr_starting_point WHERE rule_options LIKE %s";
209 $options = unserialize($sp[
'rule_options']);
211 $roles[(
int) $options[
'role_id']] = [
212 "id" => (
int) $sp[
'id'],
213 "starting_point" => (
int) $sp[
'starting_point'],
214 "starting_object" => (
int) $sp[
'starting_object'],
215 "calendar_view" => (
int) $sp[
'calendar_view'],
216 "calendar_period" => (
int) $sp[
'calendar_period'],
217 "position" => (
int) $sp[
'position'],
218 "role_id" => (
int) $options[
'role_id'],
232 $rbacreview =
$DIC[
'rbacreview'];
233 $global_roles = $rbacreview->getGlobalRoles();
236 $ids_roles_with_sp = array();
237 foreach ($roles_with_starting_point as $role) {
238 $ids_roles_with_sp[] = $role[
'role_id'];
241 $ids_roles_without_sp = array_diff($global_roles, $ids_roles_with_sp);
244 foreach ($ids_roles_without_sp as $roleid) {
250 "id" => $role_obj->getId(),
251 "title" => $role_obj->getTitle(),
265 $position = $max_position + 10;
267 $next_id = $this->db->nextId(
'usr_starting_point');
279 $this->db->manipulateF(
280 "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)",
299 $this->db->manipulateF(
300 'UPDATE usr_starting_point
301 SET starting_point = %s,
302 starting_object = %s,
333 public function delete():
void
335 $query =
"DELETE FROM usr_starting_point WHERE id = " . $this->db->quote($this->
id,
"integer");
336 $this->db->manipulate(
$query);
342 $result = $this->db->query(
"SELECT max(position) as max_order FROM usr_starting_point");
345 while ($row = $this->db->fetchAssoc($result)) {
346 $order_val = (
int) $row[
'max_order'];
355 foreach ($a_items as $v) {
356 $v[
'starting_position'] = $ord_const;
357 $rearranged[$ord_const] = $v;
370 foreach ($a_items as
$id => $position) {
371 if ($position > self::ORDER_POSITION_MIN && $position < self::ORDER_POSITION_MAX) {
372 $this->db->manipulate(
373 "UPDATE usr_starting_point SET" .
374 " position = " . $this->db->quote($nr,
'integer') .
375 " WHERE id = " . $this->db->quote(
$id,
'integer')
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
getCalendarView()
Gets calendar view.
save()
insert starting point into database
setRuleOptions(string $a_rule_options)
serialized string
saveOrder(array $a_items)
Save all starting point positions.
static getRolesWithStartingPoint()
get array with all roles which have starting point defined.
update()
update starting point
static getStartingPoints()
Get all the starting points in database.
static reArrangePositions(array $a_items)
setRuleType(int $a_rule_type)
setStartingObject(int $a_starting_object)
setCalendarPeriod(int $calendar_period)
setStartingPoint(int $a_starting_point)
const USER_SELECTION_RULE
static onRoleDeleted(ilObjRole $role)
setCalendarView(int $calendar_view)
Sets calendar view.
setPosition(int $a_starting_position)
static getGlobalRolesWithoutStartingPoint()
Get id and title of the roles without starting points.