ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilPCConsultationHours.php
Go to the documentation of this file.
1 <?php
2 
25 {
27  protected ilObjUser $user;
28 
29  public function init(): void
30  {
31  global $DIC;
32  $this->user = $DIC->user();
33  $this->setType("cach");
34  }
35 
36  public static function getLangVars(): array
37  {
38  return array("ed_insert_consultation_hours", "pc_cach");
39  }
40 
41  public function setNode(php4DOMElement $a_node): void
42  {
43  parent::setNode($a_node); // this is the PageContent node
44  $this->cach_node = $a_node->first_child(); // this is the consultation hours node
45  }
46 
47  public function create(
48  ilPageObject $a_pg_obj,
49  string $a_hier_id,
50  string $a_pc_id = ""
51  ): void {
52  $this->node = $this->createPageContentNode();
53  $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
54  $this->cach_node = $this->dom->create_element("ConsultationHours");
55  $this->cach_node = $this->node->append_child($this->cach_node);
56  }
57 
61  public function setData(
62  string $a_mode,
63  array $a_grp_ids
64  ): void {
66 
67  $this->cach_node->set_attribute("Mode", $a_mode);
68  $this->cach_node->set_attribute("User", $ilUser->getId());
69 
70  // remove all children first
71  $children = $this->cach_node->child_nodes();
72  if ($children) {
73  foreach ($children as $child) {
74  $this->cach_node->remove_child($child);
75  }
76  }
77 
78  if ($a_mode === "manual") {
79  foreach ($a_grp_ids as $grp_id) {
80  $field_node = $this->dom->create_element("ConsultationHoursGroup");
81  $field_node = $this->cach_node->append_child($field_node);
82  $field_node->set_attribute("Id", $grp_id);
83  }
84  }
85  }
86 
90  public function getGroupIds(): array
91  {
92  $res = array();
93  if (is_object($this->cach_node)) {
94  $children = $this->cach_node->child_nodes();
95  if ($children) {
96  foreach ($children as $child) {
97  $res[] = $child->get_attribute("Id");
98  }
99  }
100  }
101  return $res;
102  }
103 }
setType(string $a_type)
Set Type.
$res
Definition: ltiservices.php:69
setNode(php4DOMElement $a_node)
getGroupIds()
Get consultation hours group ids.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
php4DomElement
insertContent(ilPageContent $a_cont_obj, string $a_pos, int $a_mode=IL_INSERT_AFTER, string $a_pcid="", bool $remove_placeholder=true)
insert a content node before/after a sibling or as first child of a parent
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
const IL_INSERT_AFTER
createPageContentNode(bool $a_set_this_node=true)
Create page content node (always use this method first when adding a new element) ...
create(ilPageObject $a_pg_obj, string $a_hier_id, string $a_pc_id="")
$ilUser
Definition: imgupload.php:34
setData(string $a_mode, array $a_grp_ids)
Set consultation hours settings.