ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilPageActivationDBRepository Class Reference
+ Collaboration diagram for ilPageActivationDBRepository:

Public Member Functions

 __construct (\ilDBInterface $db=null)
 Constructor. More...
 
 get (string $parent_type, array $ids, bool $check_scheduled_activation=false, string $lang="")
 Get activation data for a set of page ids. More...
 

Protected Attributes

 $db
 

Detailed Description

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 8 of file class.ilPageActivationDBRepository.php.

Constructor & Destructor Documentation

◆ __construct()

ilPageActivationDBRepository::__construct ( \ilDBInterface  $db = null)

Constructor.

Definition at line 18 of file class.ilPageActivationDBRepository.php.

References $db, and $DIC.

19  {
20  global $DIC;
21 
22  $this->db = (is_null($db))
23  ? $DIC->database()
24  : $db;
25  }
global $DIC
Definition: saml.php:7

Member Function Documentation

◆ get()

ilPageActivationDBRepository::get ( string  $parent_type,
array  $ids,
bool  $check_scheduled_activation = false,
string  $lang = "" 
)

Get activation data for a set of page ids.

Parameters
string$parent_type
array$ids
bool$check_scheduled_activation
string$lang
Returns
array

Definition at line 35 of file class.ilPageActivationDBRepository.php.

References $db, $lang, and ilUtil\now().

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  }
static now()
Return current timestamp in Y-m-d H:i:s format.
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
Definition: langwiz.php:349
+ Here is the call graph for this function:

Field Documentation

◆ $db

ilPageActivationDBRepository::$db
protected

Definition at line 13 of file class.ilPageActivationDBRepository.php.

Referenced by __construct(), and get().


The documentation for this class was generated from the following file: