ILIAS  release_8 Revision v8.24
class.ilPageActivationDBRepository.php
Go to the documentation of this file.
1<?php
2
23{
24 protected ilDBInterface $db;
25
26 public function __construct(\ilDBInterface $db = null)
27 {
28 global $DIC;
29
30 $this->db = (is_null($db))
31 ? $DIC->database()
32 : $db;
33 }
34
38 public function get(
39 string $parent_type,
40 array $ids,
41 bool $check_scheduled_activation = false,
42 string $lang = ""
43 ): array {
44
45
46 // language must be set at least to "-"
47 if ($lang == "") {
48 $lang = "-";
49 }
50
51 $active = [];
52
53 // for special languages initialize with master language
54 if ($lang != "-") {
55 foreach ($this->getData($parent_type, $ids, $check_scheduled_activation, "-") as $k => $v) {
56 $active[$k] = $v;
57 }
58 }
59
60 foreach ($this->getData($parent_type, $ids, $check_scheduled_activation, $lang) as $k => $v) {
61 $active[$k] = $v;
62 }
63
64 return $active;
65 }
66
67 protected function getData(
68 string $parent_type,
69 array $ids,
70 bool $check_scheduled_activation = false,
71 string $lang = ""
72 ): array {
73 $db = $this->db;
74 $set = $db->queryF(
75 "SELECT page_id, active, activation_start, activation_end, show_activation_info FROM page_object WHERE " .
76 $db->in("page_id", $ids, false, "integer") .
77 " AND parent_type = %s AND lang = %s",
78 ["text", "text"],
79 [$parent_type, $lang]
80 );
81 $active = [];
82 $now = ilUtil::now();
83 while ($rec = $db->fetchAssoc($set)) {
84 if (!$rec["active"] && $check_scheduled_activation) {
85 if ($now >= $rec["activation_start"] &&
86 $now <= $rec["activation_end"]) {
87 $active[$rec["page_id"]] = [
88 "active" => true,
89 "start" => $rec["activation_start"],
90 "end" => $rec["activation_end"],
91 "show_info" => (bool) $rec["show_activation_info"]
92 ];
93 } else {
94 $active[$rec["page_id"]] = [
95 "active" => false,
96 "start" => $rec["activation_start"],
97 "end" => $rec["activation_end"],
98 "show_info" => (bool) $rec["show_activation_info"]
99 ];
100 }
101 } else {
102 $active[$rec["page_id"]] = [
103 "active" => (bool) $rec["active"],
104 "start" => null,
105 "end" => null,
106 "show_info" => false
107 ];
108 }
109 }
110 return $active;
111 }
112}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getData(string $parent_type, array $ids, bool $check_scheduled_activation=false, string $lang="")
static now()
Return current timestamp in Y-m-d H:i:s format.
global $DIC
Definition: feed.php:28
Interface ilDBInterface.
fetchAssoc(ilDBStatement $statement)
queryF(string $query, array $types, array $values)
in(string $field, array $values, bool $negate=false, string $type="")
$lang
Definition: xapiexit.php:26