ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 // language must be set at least to "-"
45 if ($lang == "") {
46 $lang = "-";
47 }
48
49 $active = [];
50
51 // for special languages initialize with master language
52 if ($lang != "-") {
53 foreach ($this->getData($parent_type, $ids, $check_scheduled_activation, "-") as $k => $v) {
54 $active[$k] = $v;
55 }
56 }
57
58 foreach ($this->getData($parent_type, $ids, $check_scheduled_activation, $lang) as $k => $v) {
59 $active[$k] = $v;
60 }
61
62 return $active;
63 }
64
65 protected function getData(
66 string $parent_type,
67 array $ids,
68 bool $check_scheduled_activation = false,
69 string $lang = ""
70 ): array {
71 $db = $this->db;
72 $set = $db->queryF(
73 "SELECT page_id, active, activation_start, activation_end, show_activation_info FROM page_object WHERE " .
74 $db->in("page_id", $ids, false, "integer") .
75 " AND parent_type = %s AND lang = %s",
76 ["text", "text"],
77 [$parent_type, $lang]
78 );
79 $active = [];
80 $now = ilUtil::now();
81 while ($rec = $db->fetchAssoc($set)) {
82 if (!$rec["active"] && $check_scheduled_activation) {
83 if ($now >= $rec["activation_start"] &&
84 $now <= $rec["activation_end"]) {
85 $active[$rec["page_id"]] = [
86 "active" => true,
87 "start" => $rec["activation_start"],
88 "end" => $rec["activation_end"],
89 "show_info" => (bool) $rec["show_activation_info"]
90 ];
91 } else {
92 $active[$rec["page_id"]] = [
93 "active" => false,
94 "start" => $rec["activation_start"],
95 "end" => $rec["activation_end"],
96 "show_info" => (bool) $rec["show_activation_info"]
97 ];
98 }
99 } else {
100 $active[$rec["page_id"]] = [
101 "active" => (bool) $rec["active"],
102 "start" => null,
103 "end" => null,
104 "show_info" => false
105 ];
106 }
107 }
108 return $active;
109 }
110}
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.
Interface ilDBInterface.
fetchAssoc(ilDBStatement $statement)
queryF(string $query, array $types, array $values)
in(string $field, array $values, bool $negate=false, string $type="")
global $DIC
Definition: shib_login.php:26
$lang
Definition: xapiexit.php:25