ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilOrgUnitObjectPositionSetting.php
Go to the documentation of this file.
1<?php
2
24{
25 protected ilDBInterface $db;
26 private int $obj_id;
27 private ?bool $active = null;
28
29 public function __construct(int $a_obj_id)
30 {
31 $this->db = $GLOBALS['DIC']->database();
32 $this->obj_id = $a_obj_id;
33 $this->readSettings();
34 }
35
39 public function lookupActive(int $a_obj_id): bool
40 {
41 $db = $GLOBALS['DIC']->database();
42
43 $query = 'select * from orgu_obj_pos_settings ' . 'where obj_id = '
44 . $db->quote($a_obj_id, 'integer');
45 $res = $this->db->query($query);
46 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
47 return (bool) $row->active;
48 }
49 }
50
54 public function isActive(): ?bool
55 {
56 return $this->active;
57 }
58
62 public function setActive(bool $a_status): void
63 {
64 $this->active = $a_status;
65 }
66
67 public function update(): void
68 {
69 $this->db->replace('orgu_obj_pos_settings', [
70 'obj_id' => ['integer', $this->obj_id],
71 ], [
72 'active' => ['integer', (int) $this->isActive()],
73 ]);
74 }
75
76 public function delete(): void
77 {
78 $query = 'DELETE from orgu_obj_pos_settings ' . 'WHERE obj_id = '
79 . $this->db->quote($this->obj_id, 'integer');
80 $this->db->manipulate($query);
81 }
82
87 public function hasObjectSpecificActivation(): bool
88 {
89 return $this->active !== null;
90 }
91
92 private function readSettings(): void
93 {
94 if (!$this->obj_id) {
95 return;
96 }
97 $query = 'select * from orgu_obj_pos_settings ' . 'where obj_id = '
98 . $this->db->quote($this->obj_id, 'integer');
99 $res = $this->db->query($query);
100 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
101 $this->active = (bool) $row->active;
102 }
103
104 return;
105 }
106}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
isActive()
Check if position access is active.
setActive(bool $a_status)
Set active for object.
lookupActive(int $a_obj_id)
Lookup activation status.
Interface ilDBInterface.
quote($value, string $type)
$res
Definition: ltiservices.php:69
$GLOBALS["DIC"]
Definition: wac.php:54