ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilPCConsultationHours.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 
13 {
17  protected $user;
18 
19  public $dom;
20 
24  public function init()
25  {
26  global $DIC;
27  $this->user = $DIC->user();
28  $this->setType("cach");
29  }
30 
35  public static function getLangVars()
36  {
37  return array("ed_insert_consultation_hours", "pc_cach");
38  }
39 
43  public function setNode($a_node)
44  {
45  parent::setNode($a_node); // this is the PageContent node
46  $this->cach_node = &$a_node->first_child(); // this is the consultation hours node
47  }
48 
55  public function create(&$a_pg_obj, $a_hier_id, $a_pc_id = "")
56  {
57  $this->node = $this->createPageContentNode();
58  $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
59  $this->cach_node = $this->dom->create_element("ConsultationHours");
60  $this->cach_node = $this->node->append_child($this->cach_node);
61  }
62 
69  public function setData($a_mode, array $a_grp_ids)
70  {
72 
73  $this->cach_node->set_attribute("Mode", $a_mode);
74  $this->cach_node->set_attribute("User", $ilUser->getId());
75 
76  // remove all children first
77  $children = $this->cach_node->child_nodes();
78  if ($children) {
79  foreach ($children as $child) {
80  $this->cach_node->remove_child($child);
81  }
82  }
83 
84  if ($a_mode == "manual") {
85  foreach ($a_grp_ids as $grp_id) {
86  $field_node = $this->dom->create_element("ConsultationHoursGroup");
87  $field_node = $this->cach_node->append_child($field_node);
88  $field_node->set_attribute("Id", $grp_id);
89  }
90  }
91  }
92 
98  public function getGroupIds()
99  {
100  $res = array();
101  if (is_object($this->cach_node)) {
102  $children = $this->cach_node->child_nodes();
103  if ($children) {
104  foreach ($children as $child) {
105  $res[] = $child->get_attribute("Id");
106  }
107  }
108  }
109  return $res;
110  }
111 }
getGroupIds()
Get consultation hours group ids.
setData($a_mode, array $a_grp_ids)
Set consultation hours settings.
Class ilPCConsultationHours.
setType($a_type)
Set Type.
user()
Definition: user.php:4
Class ilPageContent.
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24
const IL_INSERT_AFTER
createPageContentNode($a_set_this_node=true)
Create page content node (always use this method first when adding a new element) ...
static getLangVars()
Get lang vars needed for editing.
init()
Init page content component.
$ilUser
Definition: imgupload.php:18
create(&$a_pg_obj, $a_hier_id, $a_pc_id="")
Create consultation hours node in xml.