ILIAS  release_8 Revision v8.24
class.ilOrgUnitObjectPositionSetting.php
Go to the documentation of this file.
1<?php
19/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
20
26{
27 protected ilDBInterface $db;
28 private int $obj_id;
29 private ?bool $active = null;
30
31 public function __construct(int $a_obj_id)
32 {
33 $this->db = $GLOBALS['DIC']->database();
34 $this->obj_id = $a_obj_id;
35 $this->readSettings();
36 }
37
41 public function lookupActive(int $a_obj_id): bool
42 {
43 $db = $GLOBALS['DIC']->database();
44
45 $query = 'select * from orgu_obj_pos_settings ' . 'where obj_id = '
46 . $db->quote($a_obj_id, 'integer');
47 $res = $this->db->query($query);
48 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
49 return (bool) $row->active;
50 }
51 }
52
56 public function isActive(): ?bool
57 {
58 return $this->active;
59 }
60
64 public function setActive(bool $a_status): void
65 {
66 $this->active = $a_status;
67 }
68
69 public function update(): void
70 {
71 $this->db->replace('orgu_obj_pos_settings', [
72 'obj_id' => ['integer', $this->obj_id],
73 ], [
74 'active' => ['integer', (int) $this->isActive()],
75 ]);
76 }
77
78 public function delete(): void
79 {
80 $query = 'DELETE from orgu_obj_pos_settings ' . 'WHERE obj_id = '
81 . $this->db->quote($this->obj_id, 'integer');
82 $this->db->manipulate($query);
83 }
84
89 public function hasObjectSpecificActivation(): bool
90 {
91 return $this->active !== null;
92 }
93
94 private function readSettings(): void
95 {
96 if (!$this->obj_id) {
97 return;
98 }
99 $query = 'select * from orgu_obj_pos_settings ' . 'where obj_id = '
100 . $this->db->quote($this->obj_id, 'integer');
101 $res = $this->db->query($query);
102 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
103 $this->active = (bool) $row->active;
104 }
105
106 return;
107 }
108}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
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
$query