ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 $db = $this->db;
38
39 // language must be set at least to "-"
40 if ($lang == "") {
41 $lang = "-";
42 }
43 $set = $db->queryF(
44 "SELECT page_id, active, activation_start, activation_end, show_activation_info FROM page_object WHERE " .
45 $db->in("page_id", $ids, false, "integer") .
46 " AND parent_type = %s AND lang = %s",
47 ["text", "text"],
48 [$parent_type, $lang]
49 );
50 $active = [];
51 $now = ilUtil::now();
52 while ($rec = $db->fetchAssoc($set)) {
53 if (!$rec["active"] && $check_scheduled_activation) {
54 if ($now >= $rec["activation_start"] &&
55 $now <= $rec["activation_end"]) {
56 $active[$rec["page_id"]] = [
57 "active" => true,
58 "start" => $rec["activation_start"],
59 "end" => $rec["activation_end"],
60 "show_info" => (bool) $rec["show_activation_info"]
61 ];
62 } else {
63 $active[$rec["page_id"]] = [
64 "active" => false,
65 "start" => $rec["activation_start"],
66 "end" => $rec["activation_end"],
67 "show_info" => (bool) $rec["show_activation_info"]
68 ];
69 }
70 } else {
71 $active[$rec["page_id"]] = [
72 "active" => (bool) $rec["active"],
73 "start" => null,
74 "end" => null,
75 "show_info" => false
76 ];
77 }
78 }
79 return $active;
80 }
81}
An exception for terminatinating execution or to throw for unit testing.
__construct(\ilDBInterface $db=null)
Constructor.
static now()
Return current timestamp in Y-m-d H:i:s format.
Interface ilDBInterface.
$lang
Definition: xapiexit.php:8
$DIC
Definition: xapitoken.php:46