ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilPCProfile.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 
33  $this->user = $DIC->user();
34  $this->setType("prof");
35  }
36 
37  public function setNode(php4DOMElement $a_node): void
38  {
39  parent::setNode($a_node); // this is the PageContent node
40  $this->prof_node = $a_node->first_child(); // this is the profile node
41  }
42 
43  public function create(
44  ilPageObject $a_pg_obj,
45  string $a_hier_id,
46  string $a_pc_id = ""
47  ): void {
48  $this->node = $this->createPageContentNode();
49  $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
50  $this->prof_node = $this->dom->create_element("Profile");
51  $this->prof_node = $this->node->append_child($this->prof_node);
52  }
53 
54  public function setFields(
55  string $a_mode,
56  array $a_fields = null
57  ): void {
59 
60  $this->prof_node->set_attribute("Mode", $a_mode);
61  $this->prof_node->set_attribute("User", $ilUser->getId());
62 
63  // remove all children first
64  $children = $this->prof_node->child_nodes();
65  if ($children) {
66  foreach ($children as $child) {
67  $this->prof_node->remove_child($child);
68  }
69  }
70 
71  if ($a_mode == "manual") {
72  foreach ($a_fields as $field) {
73  $field_node = $this->dom->create_element("ProfileField");
74  $field_node = $this->prof_node->append_child($field_node);
75  $field_node->set_attribute("Name", $field);
76  }
77  }
78  }
79 
80  public function getMode(): string
81  {
82  if (is_object($this->prof_node)) {
83  return $this->prof_node->get_attribute("Mode");
84  }
85  return "";
86  }
87 
91  public function getFields(): array
92  {
93  $res = array();
94  if (is_object($this->prof_node)) {
95  $children = $this->prof_node->child_nodes();
96  if ($children) {
97  foreach ($children as $child) {
98  $res[] = $child->get_attribute("Name");
99  }
100  }
101  }
102  return $res;
103  }
104 
105  public static function getLangVars(): array
106  {
107  return array("pc_prof", "ed_insert_profile");
108  }
109 }
setType(string $a_type)
Set Type.
$res
Definition: ltiservices.php:69
setFields(string $a_mode, array $a_fields=null)
static getLangVars()
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)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
create(ilPageObject $a_pg_obj, string $a_hier_id, string $a_pc_id="")
php4DOMElement $prof_node
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) ...
getFields()
Get profile settings.
setNode(php4DOMElement $a_node)
$ilUser
Definition: imgupload.php:34