ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilPCProfileGUI.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
24require_once("./Services/COPage/classes/class.ilPCProfile.php");
25require_once("./Services/COPage/classes/class.ilPageContentGUI.php");
26
38{
39
44 function __construct(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id = "")
45 {
46 parent::__construct($a_pg_obj, $a_content_obj, $a_hier_id, $a_pc_id);
47 }
48
52 function executeCommand()
53 {
54 // get next class that processes or forwards current command
55 $next_class = $this->ctrl->getNextClass($this);
56
57 // get current command
58 $cmd = $this->ctrl->getCmd();
59
60 switch($next_class)
61 {
62 default:
63 $ret = $this->$cmd();
64 break;
65 }
66
67 return $ret;
68 }
69
75 function insert(ilPropertyFormGUI $a_form = null)
76 {
77 global $tpl;
78
80
81 if(!$a_form)
82 {
83 $a_form = $this->initForm(true);
84 }
85 $tpl->setContent($a_form->getHTML());
86 }
87
93 function edit(ilPropertyFormGUI $a_form = null)
94 {
95 global $tpl;
96
98
99 if(!$a_form)
100 {
101 $a_form = $this->initForm();
102 }
103 $tpl->setContent($a_form->getHTML());
104 }
105
112 protected function initForm($a_insert = false)
113 {
114 global $ilCtrl, $ilToolbar;
115
116 $is_template = ($this->getPageConfig()->getEnablePCType("PlaceHolder"));
117
118 if(!$is_template)
119 {
120 $ilToolbar->addButton($this->lng->txt("cont_edit_personal_data"),
121 $ilCtrl->getLinkTargetByClass("ilpersonaldesktopgui", "jumptoprofile"),
122 "profile");
123
124 $lng_suffix = "";
125 }
126 else
127 {
128 $lng_suffix = "_template";
129 }
130
131 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
132 $form = new ilPropertyFormGUI();
133 $form->setFormAction($ilCtrl->getFormAction($this));
134 if ($a_insert)
135 {
136 $form->setTitle($this->lng->txt("cont_insert_profile"));
137 }
138 else
139 {
140 $form->setTitle($this->lng->txt("cont_update_profile"));
141 }
142
143 $mode = new ilRadioGroupInputGUI($this->lng->txt("cont_profile_mode"), "mode");
144 $form->addItem($mode);
145
146 $mode_inherit = new ilRadioOption($this->lng->txt("cont_profile_mode_inherit"), "inherit");
147 $mode_inherit->setInfo($this->lng->txt("cont_profile_mode".$lng_suffix."_inherit_info"));
148 $mode->addOption($mode_inherit);
149
150 $mode_manual = new ilRadioOption($this->lng->txt("cont_profile_mode_manual"), "manual");
151 $mode_manual->setInfo($this->lng->txt("cont_profile_mode_manual_info"));
152 $mode->addOption($mode_manual);
153
154 $prefs = array();
155 if ($a_insert)
156 {
157 $mode->setValue("inherit");
158 }
159 else
160 {
161 $mode_value = $this->content_obj->getMode();
162 $mode->setValue($mode_value);
163
164 $prefs = array();
165 if($mode_value == "manual")
166 {
167 foreach($this->content_obj->getFields() as $name)
168 {
169 $prefs["public_".$name] = "y";
170 }
171 }
172 }
173
174 include_once "Services/User/classes/class.ilPersonalProfileGUI.php";
175 $profile = new ilPersonalProfileGUI();
176 $profile->showPublicProfileFields($form, $prefs, $mode_manual, $is_template);
177
178 if ($a_insert)
179 {
180
181 $form->addCommandButton("create_profile", $this->lng->txt("save"));
182 $form->addCommandButton("cancelCreate", $this->lng->txt("cancel"));
183 }
184 else
185 {
186
187 $form->addCommandButton("update", $this->lng->txt("save"));
188 $form->addCommandButton("cancelUpdate", $this->lng->txt("cancel"));
189 }
190
191 return $form;
192 }
193
199 protected function getFieldsValues()
200 {
201 $fields = array();
202 foreach($_POST as $name => $value)
203 {
204 if(substr($name, 0, 4) == "chk_")
205 {
206 if($value)
207 {
208 $fields[] = substr($name, 4);
209 }
210 }
211 }
212 return $fields;
213 }
214
218 function create()
219 {
220 $form = $this->initForm(true);
221 if($form->checkInput())
222 {
223 $this->content_obj = new ilPCProfile($this->getPage());
224 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
225 $this->content_obj->setFields($form->getInput("mode"),
226 $this->getFieldsValues());
227 $this->updated = $this->pg_obj->update();
228 if ($this->updated === true)
229 {
230 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
231 }
232 }
233
234 $this->insert($form);
235 }
236
240 function update()
241 {
242 $form = $this->initForm(true);
243 if($form->checkInput())
244 {
245 $this->content_obj->setFields($form->getInput("mode"),
246 $this->getFieldsValues());
247 $this->updated = $this->pg_obj->update();
248 if ($this->updated === true)
249 {
250 $this->ctrl->returnToParent($this, "jump".$this->hier_id);
251 }
252 }
253
254 $this->pg_obj->addHierIDs();
255 $this->edit($form);
256 }
257}
258
259?>
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
Class ilPCProfileGUI.
create()
Create new personal data.
edit(ilPropertyFormGUI $a_form=null)
Edit personal data form.
__construct(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id="")
Constructor @access public.
initForm($a_insert=false)
Init profile form.
getFieldsValues()
Gather field values.
executeCommand()
execute command
insert(ilPropertyFormGUI $a_form=null)
Insert new personal data form.
update()
Update personal data.
Class ilPCProfile.
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
getPageConfig()
Get Page Config.
displayValidationError()
display validation errors
GUI class for personal profile.
This class represents a property form user interface.
This class represents a property in a property form.
This class represents an option in a radio group.
global $ilCtrl
Definition: ilias.php:18
$ret
Definition: parser.php:6
$cmd
Definition: sahs_server.php:35