ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilExtIdGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
10 class ilExtIdGUI {
11 
15  protected $tabs_gui;
19  protected $form;
23  protected $toolbar;
27  protected $ctrl;
31  protected $tpl;
35  protected $object;
39  protected $lng;
43  protected $ilAccess;
44 
45 
49  function __construct($parent_gui) {
50  global $tpl, $ilCtrl, $ilTabs, $ilToolbar, $lng, $ilAccess;
51  $this->tpl = $tpl;
52  $this->ctrl = $ilCtrl;
53  $this->parent_gui = $parent_gui;
54  $this->parent_object = $parent_gui->object;
55  $this->tabs_gui = $this->parent_gui->tabs_gui;
56  $this->toolbar = $ilToolbar;
57  $this->lng = $lng;
58  $this->ilAccess = $ilAccess;
59  $this->lng->loadLanguageModule('user');
60  if (! $this->ilAccess->checkaccess("write", "", $this->parent_gui->object->getRefId())) {
61  ilUtil::sendFailure($this->lng->txt("permission_denied"), true);
62  }
63  }
64 
68  public function executeCommand()
69  {
70  $cmd = $this->ctrl->getCmd();
71 
72  switch ($cmd) {
73  case 'edit':
74  $this->edit();
75  break;
76  case 'update':
77  $this->update();
78  break;
79  }
80  return true;
81  }
82 
83  public function edit() {
84  $form = $this->initForm();
85  $this->tpl->setContent($form->getHTML());
86  }
87 
88  public function initForm() {
89  $form = new ilPropertyFormGUI();
90  $input = new ilTextInputGUI($this->lng->txt("ext_id"), "ext_id");
91  $input->setValue($this->parent_object->getImportId());
92  $form->addItem($input);
93  $form->setFormAction($this->ctrl->getFormAction($this));
94  $form->addCommandButton("update", $this->lng->txt("save"));
95 
96  return $form;
97  }
98 
99  public function update() {
100  $form = $this->initForm();
101  $form->setValuesByPost();
102  if ($form->checkInput()) {
103  $this->parent_object->setImportId($form->getItemByPostVar("ext_id")->getValue());
104  $this->parent_object->update();
105  ilUtil::sendSuccess($this->lng->txt("ext_id_updated"), true);
106  $this->ctrl->redirect($this,"edit");
107  } else {
108  $this->tpl->setContent($form->getHTML());
109  }
110  }
111 }
112 ?>