ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
class.ilOrgUnitObjectPositionSetting.php
Go to the documentation of this file.
1 <?php
2 
20 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
21 
27 {
28  protected ilDBInterface $db;
29  private int $obj_id;
30  private ?bool $active = null;
31 
32  public function __construct(int $a_obj_id)
33  {
34  $this->db = $GLOBALS['DIC']->database();
35  $this->obj_id = $a_obj_id;
36  $this->readSettings();
37  }
38 
42  public function lookupActive(int $a_obj_id): bool
43  {
44  $db = $GLOBALS['DIC']->database();
45 
46  $query = 'select * from orgu_obj_pos_settings ' . 'where obj_id = '
47  . $db->quote($a_obj_id, 'integer');
48  $res = $this->db->query($query);
49  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
50  return (bool) $row->active;
51  }
52  }
53 
57  public function isActive(): ?bool
58  {
59  return $this->active;
60  }
61 
65  public function setActive(bool $a_status): void
66  {
67  $this->active = $a_status;
68  }
69 
70  public function update(): void
71  {
72  $this->db->replace('orgu_obj_pos_settings', [
73  'obj_id' => ['integer', $this->obj_id],
74  ], [
75  'active' => ['integer', (int) $this->isActive()],
76  ]);
77  }
78 
79  public function delete(): void
80  {
81  $query = 'DELETE from orgu_obj_pos_settings ' . 'WHERE obj_id = '
82  . $this->db->quote($this->obj_id, 'integer');
83  $this->db->manipulate($query);
84  }
85 
90  public function hasObjectSpecificActivation(): bool
91  {
92  return $this->active !== null;
93  }
94 
95  private function readSettings(): void
96  {
97  if (!$this->obj_id) {
98  return;
99  }
100  $query = 'select * from orgu_obj_pos_settings ' . 'where obj_id = '
101  . $this->db->quote($this->obj_id, 'integer');
102  $res = $this->db->query($query);
103  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
104  $this->active = (bool) $row->active;
105  }
106 
107  return;
108  }
109 }
setActive(bool $a_status)
Set active for object.
$res
Definition: ltiservices.php:69
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
quote($value, string $type)
$GLOBALS["DIC"]
Definition: wac.php:30
isActive()
Check if position access is active.
lookupActive(int $a_obj_id)
Lookup activation status.