ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilPCConsultationHours.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once("./Services/COPage/classes/class.ilPageContent.php");
5 
17 {
21  protected $user;
22 
23  public $dom;
24 
28  public function init()
29  {
30  global $DIC;
31  $this->user = $DIC->user();
32  $this->setType("cach");
33  }
34 
39  public static function getLangVars()
40  {
41  return array("ed_insert_consultation_hours", "pc_cach");
42  }
43 
47  public function setNode($a_node)
48  {
49  parent::setNode($a_node); // this is the PageContent node
50  $this->cach_node = &$a_node->first_child(); // this is the consultation hours node
51  }
52 
59  public function create(&$a_pg_obj, $a_hier_id, $a_pc_id = "")
60  {
61  $this->node = $this->createPageContentNode();
62  $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
63  $this->cach_node = $this->dom->create_element("ConsultationHours");
64  $this->cach_node = $this->node->append_child($this->cach_node);
65  }
66 
73  public function setData($a_mode, array $a_grp_ids)
74  {
76 
77  $this->cach_node->set_attribute("Mode", $a_mode);
78  $this->cach_node->set_attribute("User", $ilUser->getId());
79 
80  // remove all children first
81  $children = $this->cach_node->child_nodes();
82  if ($children) {
83  foreach ($children as $child) {
84  $this->cach_node->remove_child($child);
85  }
86  }
87 
88  if ($a_mode == "manual") {
89  foreach ($a_grp_ids as $grp_id) {
90  $field_node = $this->dom->create_element("ConsultationHoursGroup");
91  $field_node = $this->cach_node->append_child($field_node);
92  $field_node->set_attribute("Id", $grp_id);
93  }
94  }
95  }
96 
102  public function getGroupIds()
103  {
104  $res = array();
105  if (is_object($this->cach_node)) {
106  $children = $this->cach_node->child_nodes();
107  if ($children) {
108  foreach ($children as $child) {
109  $res[] = $child->get_attribute("Id");
110  }
111  }
112  }
113  return $res;
114  }
115 }
global $DIC
Definition: saml.php:7
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
$ilUser
Definition: imgupload.php:18
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.
create(&$a_pg_obj, $a_hier_id, $a_pc_id="")
Create consultation hours node in xml.