ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPCProfile.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 
6 require_once("./Services/COPage/classes/class.ilPageContent.php");
7 
19 {
20  var $dom;
21 
25  function init()
26  {
27  $this->setType("prof");
28  }
29 
33  function setNode(&$a_node)
34  {
35  parent::setNode($a_node); // this is the PageContent node
36  $this->prof_node =& $a_node->first_child(); // this is the profile node
37  }
38 
45  function create(&$a_pg_obj, $a_hier_id, $a_pc_id = "")
46  {
47  $this->node = $this->createPageContentNode();
48  $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
49  $this->prof_node = $this->dom->create_element("Profile");
50  $this->prof_node = $this->node->append_child($this->prof_node);
51  }
52 
59  function setFields($a_mode, array $a_fields = null)
60  {
61  global $ilUser;
62 
63  $this->prof_node->set_attribute("Mode", $a_mode);
64  $this->prof_node->set_attribute("User", $ilUser->getId());
65 
66  // remove all children first
67  $children = $this->prof_node->child_nodes();
68  if($children)
69  {
70  foreach($children as $child)
71  {
72  $this->prof_node->remove_child($child);
73  }
74  }
75 
76  if($a_mode == "manual")
77  {
78  foreach($a_fields as $field)
79  {
80  $field_node = $this->dom->create_element("ProfileField");
81  $field_node = $this->prof_node->append_child($field_node);
82  $field_node->set_attribute("Name", $field);
83  }
84  }
85  }
86 
92  function getMode()
93  {
94  if (is_object($this->prof_node))
95  {
96  return $this->prof_node->get_attribute("Mode");
97  }
98  }
99 
105  function getFields()
106  {
107  $res = array();
108  if (is_object($this->prof_node))
109  {
110  $children = $this->prof_node->child_nodes();
111  if($children)
112  {
113  foreach($children as $child)
114  {
115  $res[] = $child->get_attribute("Name");
116  }
117  }
118  }
119  return $res;
120  }
121 
126  static function getLangVars()
127  {
128  return array("pc_prof", "ed_insert_profile");
129  }
130 
131 }
132 ?>