ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilPageActivationDBRepository.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4
9{
13 protected $db;
14
18 public function __construct(\ilDBInterface $db = null)
19 {
20 global $DIC;
21
22 $this->db = (is_null($db))
23 ? $DIC->database()
24 : $db;
25 }
26
35 public function get(string $parent_type, array $ids, bool $check_scheduled_activation = false, string $lang = "")
36 {
37
38
39 // language must be set at least to "-"
40 if ($lang == "") {
41 $lang = "-";
42 }
43
44 $active = [];
45
46 // for special languages initialize with master language
47 if ($lang != "-") {
48 foreach ($this->getData($parent_type, $ids, $check_scheduled_activation, "-") as $k => $v) {
49 $active[$k] = $v;
50 }
51 }
52
53 foreach ($this->getData($parent_type, $ids, $check_scheduled_activation, $lang) as $k => $v) {
54 $active[$k] = $v;
55 }
56
57 return $active;
58 }
59
60 protected function getData(string $parent_type, array $ids, bool $check_scheduled_activation = false, string $lang = "")
61 {
62 $db = $this->db;
63 $set = $db->queryF(
64 "SELECT page_id, active, activation_start, activation_end, show_activation_info FROM page_object WHERE " .
65 $db->in("page_id", $ids, false, "integer") .
66 " AND parent_type = %s AND lang = %s",
67 ["text", "text"],
68 [$parent_type, $lang]
69 );
70 $active = [];
71 $now = ilUtil::now();
72 while ($rec = $db->fetchAssoc($set)) {
73 if (!$rec["active"] && $check_scheduled_activation) {
74 if ($now >= $rec["activation_start"] &&
75 $now <= $rec["activation_end"]) {
76 $active[$rec["page_id"]] = [
77 "active" => true,
78 "start" => $rec["activation_start"],
79 "end" => $rec["activation_end"],
80 "show_info" => (bool) $rec["show_activation_info"]
81 ];
82 } else {
83 $active[$rec["page_id"]] = [
84 "active" => false,
85 "start" => $rec["activation_start"],
86 "end" => $rec["activation_end"],
87 "show_info" => (bool) $rec["show_activation_info"]
88 ];
89 }
90 } else {
91 $active[$rec["page_id"]] = [
92 "active" => (bool) $rec["active"],
93 "start" => null,
94 "end" => null,
95 "show_info" => false
96 ];
97 }
98 }
99 return $active;
100 }
101}
An exception for terminatinating execution or to throw for unit testing.
__construct(\ilDBInterface $db=null)
Constructor.
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: goto.php:24
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$lang
Definition: xapiexit.php:8