ILIAS  trunk Revision v11.0_alpha-1731-gff9cd7e2bd3
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilLPXmlWriter.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=0);
26 {
27  private bool $add_header = true;
28  private string $timestamp = "";
29  private bool $include_ref_ids = false;
30  private array $type_filter = array();
31 
32  protected ilDBInterface $db;
33 
37  public function __construct(bool $a_add_header)
38  {
39  global $DIC;
40 
41  $this->db = $DIC->database();
42  $this->add_header = $a_add_header;
44  }
45 
50  public function setTimestamp(string $a_val): void
51  {
52  $this->timestamp = $a_val;
53  }
54 
59  public function getTimestamp(): string
60  {
61  return $this->timestamp;
62  }
63 
64  public function setIncludeRefIds(bool $a_val): void
65  {
66  $this->include_ref_ids = $a_val;
67  }
68 
69  public function getIncludeRefIds(): bool
70  {
72  }
73 
78  public function setTypeFilter(array $a_val): void
79  {
80  $this->type_filter = $a_val;
81  }
82 
87  public function getTypeFilter(): array
88  {
89  return $this->type_filter;
90  }
91 
97  public function write(): void
98  {
99  $this->init();
100  if ($this->add_header) {
101  $this->buildHeader();
102  }
103  $this->addLPInformation();
104  }
105 
106  protected function buildHeader(): void
107  {
108  $this->xmlHeader();
109  }
110 
111  protected function init(): void
112  {
113  $this->xmlClear();
114  }
115 
116  public function addLPInformation(): void
117  {
118  $this->xmlStartTag('LPData', array());
119  $set = $this->db->query(
120  $q = "SELECT * FROM ut_lp_marks " .
121  " WHERE status_changed >= " . $this->db->quote(
122  $this->getTimestamp(),
123  "timestamp"
124  )
125  );
126 
127  while ($rec = $this->db->fetchAssoc($set)) {
128  $ref_ids = array();
129  if ($this->getIncludeRefIds()) {
130  $ref_ids = ilObject::_getAllReferences((int) $rec["obj_id"]);
131  }
132 
133  if (!is_array($this->getTypeFilter()) ||
134  (count($this->getTypeFilter()) == 0) ||
135  in_array(
136  ilObject::_lookupType((int) $rec["obj_id"]),
137  $this->getTypeFilter()
138  )) {
139  $this->xmlElement(
140  'LPChange',
141  array(
142  'UserId' => (int) $rec["usr_id"],
143  'ObjId' => (int) $rec["obj_id"],
144  'RefIds' => implode(",", $ref_ids),
145  'Timestamp' => $rec["status_changed"],
146  'LPStatus' => (int) $rec["status"]
147  )
148  );
149  }
150  }
151  $this->xmlEndTag('LPData');
152  }
153 }
ilDBInterface $db
static _getAllReferences(int $id)
get all reference ids for object ID
setTimestamp(string $a_val)
Set timestamp.
write()
Write XML.
getTimestamp()
Get timestamp.
xmlEndTag(string $tag)
Writes an endtag.
XML writer learning progress.
getTypeFilter()
Get type filter.
global $DIC
Definition: shib_login.php:22
xmlHeader()
Writes xml header.
setTypeFilter(array $a_val)
Set type filter.
__construct(Container $dic, ilPlugin $plugin)
$q
Definition: shib_logout.php:21
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
xmlClear()
clears xmlStr
static _lookupType(int $id, bool $reference=false)
__construct(bool $a_add_header)
Constructor.
setIncludeRefIds(bool $a_val)