ILIAS  release_8 Revision v8.24
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 {
58 $ilUser = $this->user;
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}
const IL_INSERT_AFTER
User class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
init()
Init object.
static getLangVars()
Get lang vars needed for editing.
setNode(php4DOMElement $a_node)
Set xml node of page content.
getFields()
Get profile settings.
setFields(string $a_mode, array $a_fields=null)
php4DOMElement $prof_node
create(ilPageObject $a_pg_obj, string $a_hier_id, string $a_pc_id="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
createPageContentNode(bool $a_set_this_node=true)
Create page content node (always use this method first when adding a new element)
setType(string $a_type)
Set Type.
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
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
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
$res
Definition: ltiservices.php:69