ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPCSkillsGUI.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 
24 require_once("./Services/COPage/classes/class.ilPCSkills.php");
25 require_once("./Services/COPage/classes/class.ilPageContentGUI.php");
26 
38 {
39 
44  function ilPCSkillsGUI(&$a_pg_obj, &$a_content_obj, $a_hier_id, $a_pc_id = "")
45  {
46  parent::ilPageContentGUI($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 
79  $this->displayValidationError();
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 
97  $this->displayValidationError();
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, $ilUser, $lng;
115 
116  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
117  $form = new ilPropertyFormGUI();
118  $form->setFormAction($ilCtrl->getFormAction($this));
119  if ($a_insert)
120  {
121  $form->setTitle($this->lng->txt("cont_insert_skills"));
122  }
123  else
124  {
125  $form->setTitle($this->lng->txt("cont_update_skills"));
126  }
127 
128  $options = array();
129  include_once "Services/Skill/classes/class.ilPersonalSkill.php";
130  $skills = ilPersonalSkill::getSelectedUserSkills($ilUser->getId());
131  if($skills)
132  {
133  foreach($skills as $skill)
134  {
135  $options[$skill["skill_node_id"]] = $skill["title"];
136  }
137  asort($options);
138  }
139  else
140  {
141  ilUtil::sendFailure("cont_no_skills");
142  }
143  $obj = new ilSelectInputGUI($this->lng->txt("cont_pc_skills"), "skill_id");
144  $obj->setRequired(true);
145  $obj->setOptions($options);
146  $form->addItem($obj);
147 
148  if ($a_insert)
149  {
150  $form->addCommandButton("create_skill", $this->lng->txt("select"));
151  $form->addCommandButton("cancelCreate", $this->lng->txt("cancel"));
152  }
153  else
154  {
155  $obj->setValue($this->content_obj->getSkillId());
156  $form->addCommandButton("update", $this->lng->txt("select"));
157  $form->addCommandButton("cancelUpdate", $this->lng->txt("cancel"));
158  }
159 
160  return $form;
161  }
162 
166  function create()
167  {
168  $form = $this->initForm(true);
169  if($form->checkInput())
170  {
171  $this->content_obj = new ilPCSkills($this->dom);
172  $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
173  $this->content_obj->setData($form->getInput("skill_id"));
174  $this->updated = $this->pg_obj->update();
175  if ($this->updated === true)
176  {
177  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
178  }
179  }
180 
181  $form->setValuesByPost();
182  return $this->insert($form);
183  }
184 
188  function update()
189  {
190  $form = $this->initForm();
191  if($form->checkInput())
192  {
193  $this->content_obj->setData($form->getInput("skill_id"));
194  $this->updated = $this->pg_obj->update();
195  if ($this->updated === true)
196  {
197  $this->ctrl->returnToParent($this, "jump".$this->hier_id);
198  }
199  }
200 
201  $this->pg_obj->addHierIDs();
202  $form->setValuesByPost();
203  return $this->edit($form);
204  }
205 }
206 
207 ?>