ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
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 Member Functions

 getData (string $parent_type, array $ids, bool $check_scheduled_activation=false, string $lang="")
 

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: goto.php:24

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 getData().

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  }
$lang
Definition: xapiexit.php:8
getData(string $parent_type, array $ids, bool $check_scheduled_activation=false, string $lang="")
+ Here is the call graph for this function:

◆ getData()

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

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

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

Referenced by get().

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  }
static now()
Return current timestamp in Y-m-d H:i:s format.
$lang
Definition: xapiexit.php:8
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $db

ilPageActivationDBRepository::$db
protected

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

Referenced by __construct(), and getData().


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