ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilUnitConfigurationGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
5 
10 abstract class ilUnitConfigurationGUI
11 {
15  protected $unit_cat_form;
16 
20  protected $unit_form;
21 
25  protected $repository = null;
26 
30  protected $tpl;
31 
35  protected $lng;
36 
40  protected $ctrl;
41 
45  public function __construct(ilUnitConfigurationRepository $repository)
46  {
52  global $DIC;
53  $lng = $DIC['lng'];
54  $ilCtrl = $DIC['ilCtrl'];
55  $tpl = $DIC['tpl'];
56 
57  $this->repository = $repository;
58  $this->lng = $lng;
59  $this->ctrl = $ilCtrl;
60  $this->tpl = $tpl;
61 
62  $this->lng->loadLanguageModule('assessment');
63  }
64 
69  abstract protected function getDefaultCommand();
70 
75  abstract public function getUnitCategoryOverviewCommand();
76 
81  abstract public function isCRUDContext();
82 
87  abstract public function getUniqueId();
88 
92  abstract protected function showUnitCategories(array $categories);
93 
99  protected function getCategoryById($id, $for_CRUD = true)
100  {
101  $category = $this->repository->getUnitCategoryById($id);
102  if ($for_CRUD && $category->getQuestionFi() != $this->repository->getConsumerId()) {
103  ilUtil::sendFailure($this->lng->txt('change_adm_categories_not_allowed'), true);
104  $this->ctrl->redirect($this, $this->getDefaultCommand());
105  }
106  return $category;
107  }
108 
112  protected function handleSubtabs()
113  {
114  }
115 
119  protected function checkPermissions($cmd)
120  {
121  }
122 
126  public function executeCommand()
127  {
128  $this->ctrl->saveParameter($this, 'category_id');
129 
130  $cmd = $this->ctrl->getCmd($this->getDefaultCommand());
131  $nextClass = $this->ctrl->getNextClass($this);
132  switch ($nextClass) {
133  default:
134  $this->checkPermissions($cmd);
135  $this->$cmd();
136  break;
137  }
138 
139  $this->handleSubtabs();
140  }
141 
145  protected function confirmDeleteUnit()
146  {
147  if (!isset($_GET['unit_id'])) {
148  $this->showUnitsOfCategory();
149  return;
150  }
151 
152  $_POST['unit_ids'] = array($_GET['unit_id']);
153  $this->confirmDeleteUnits();
154  }
155 
159  protected function confirmDeleteUnits()
160  {
161  if (!$this->isCRUDContext()) {
162  $this->showUnitsOfCategory();
163  return;
164  }
165 
166  if (!isset($_POST['unit_ids']) || !is_array($_POST['unit_ids'])) {
167  $this->showUnitsOfCategory();
168  return;
169  }
170 
171  require_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
172  $confirmation = new ilConfirmationGUI();
173  $confirmation->setFormAction($this->ctrl->getFormAction($this, 'deleteUnits'));
174  $confirmation->setConfirm($this->lng->txt('confirm'), 'deleteUnits');
175  $confirmation->setCancel($this->lng->txt('cancel'), 'showUnitsOfCategory');
176 
177  $errors = array();
178  $num_to_confirm = 0;
179  foreach ($_POST['unit_ids'] as $unit_id) {
180  try {
181  $unit = $this->repository->getUnit((int) $unit_id);
182  if (!$unit) {
183  continue;
184  }
185 
186  if ($check_result = $this->repository->checkDeleteUnit($unit->getId())) {
187  $errors[] = $unit->getDisplayString() . ' - ' . $check_result;
188  continue;
189  }
190 
191  $confirmation->addItem('unit_ids[]', $unit->getId(), $unit->getDisplayString());
192  ++$num_to_confirm;
193  } catch (ilException $e) {
194  continue;
195  }
196  }
197 
198  if ($errors) {
199  $num_errors = count($errors);
200 
201  $error_message = array_map(function ($message) {
202  return '<li>' . $message . '</li>';
203  }, $errors);
204  if ($num_errors == 1) {
205  ilUtil::sendFailure($this->lng->txt('un_unit_deletion_errors_f_s') . '<ul>' . implode('', $error_message) . '<ul>');
206  } else {
207  ilUtil::sendFailure($this->lng->txt('un_unit_deletion_errors_f') . '<ul>' . implode('', $error_message) . '<ul>');
208  }
209  }
210 
211  if ($num_to_confirm) {
212  if ($num_to_confirm == 1) {
213  $confirmation->setHeaderText($this->lng->txt('un_sure_delete_units_s'));
214  } else {
215  $confirmation->setHeaderText($this->lng->txt('un_sure_delete_units'));
216  }
217 
218  $this->tpl->setContent($confirmation->getHTML());
219  } else {
220  $this->showUnitsOfCategory();
221  }
222  }
223 
227  public function deleteUnits()
228  {
229  if (!$this->isCRUDContext()) {
230  $this->showUnitsOfCategory();
231  return;
232  }
233 
234  if (!is_array($_POST['unit_ids']) || !$_POST['unit_ids']) {
235  $this->showUnitsOfCategory();
236  return;
237  }
238 
239  $errors = array();
240  $num_deleted = 0;
241  foreach ($_POST['unit_ids'] as $unit_id) {
242  try {
243  $unit = $this->repository->getUnit((int) $unit_id);
244  if (!$unit) {
245  continue;
246  }
247 
248  $check_result = $this->repository->deleteUnit($unit->getId());
249  if (!is_null($check_result)) {
250  $errors[] = $unit->getDisplayString() . ' - ' . $check_result;
251  continue;
252  }
253 
254  ++$num_deleted;
255  } catch (ilException $e) {
256  continue;
257  }
258  }
259 
260  if ($errors) {
261  $num_errors = count($errors);
262 
263  $error_message = array_map(function ($message) {
264  return '<li>' . $message . '</li>';
265  }, $errors);
266  if ($num_errors == 1) {
267  ilUtil::sendFailure($this->lng->txt('un_unit_deletion_errors_p_s') . '<ul>' . implode('', $error_message) . '<ul>');
268  } else {
269  ilUtil::sendFailure($this->lng->txt('un_unit_deletion_errors_p') . '<ul>' . implode('', $error_message) . '<ul>');
270  }
271  }
272 
273  if ($num_deleted) {
274  if ($num_deleted == 1) {
275  ilUtil::sendSuccess($this->lng->txt('un_deleted_units_s'));
276  } else {
277  ilUtil::sendSuccess($this->lng->txt('un_deleted_units'));
278  }
279  }
280 
281  $this->showUnitsOfCategory();
282  }
283 
287  protected function saveOrder()
288  {
289  if (!$this->isCRUDContext()) {
290  $this->showUnitsOfCategory();
291  return;
292  }
293 
294  if (!isset($_POST['sequence']) || !is_array($_POST['sequence'])) {
295  $this->showUnitsOfCategory();
296  return;
297  }
298 
299  foreach ($_POST['sequence'] as $id => $sequence) {
300  $sorting_value = str_replace(',', '.', $sequence);
301  $sorting_value = (int) $sorting_value * 100;
302  $this->repository->saveUnitOrder((int) $id, $sorting_value);
303  }
304 
305  ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
306  $this->showUnitsOfCategory();
307  return;
308  }
309 
313  protected function saveUnit()
314  {
315  if (!$this->isCRUDContext()) {
316  $this->showUnitsOfCategory();
317  return;
318  }
319 
320  $category = $this->getCategoryById((int) $_GET['category_id']);
321  $unit = $this->repository->getUnit((int) $_GET['unit_id']);
322 
323  if ($this->repository->isUnitInUse($unit->getId())) {
324  $this->showUnitModificationForm();
325  return;
326  }
327 
328  $this->initUnitForm($category, $unit);
329  if ($this->unit_form->checkInput()) {
330  $unit->setUnit($this->unit_form->getInput('unit_title'));
331  $unit->setFactor((float) $this->unit_form->getInput('factor'));
332  $unit->setBaseUnit((int) $this->unit_form->getInput('base_unit') != $unit->getId() ? (int) $this->unit_form->getInput('base_unit') : 0);
333  $unit->setCategory($category->getId());
334  $this->repository->saveUnit($unit);
335  ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
336  $this->showUnitsOfCategory();
337  return;
338  } else {
339  $this->unit_form->setValuesByPost();
340  }
341 
342  $this->tpl->setContent($this->unit_form->getHtml());
343  }
344 
348  protected function showUnitModificationForm()
349  {
350  if (!$this->isCRUDContext()) {
351  $this->showUnitsOfCategory();
352  return;
353  }
354 
355  $category = $this->getCategoryById((int) $_GET['category_id']);
356  $unit = $this->repository->getUnit((int) $_GET['unit_id']);
357 
358  $this->initUnitForm($category, $unit);
359  $this->unit_form->setValuesByArray(array(
360  'factor' => $unit->getFactor(),
361  'unit_title' => $unit->getUnit(),
362  'base_unit' => ($unit->getBaseUnit() != $unit->getId() ? $unit->getBaseUnit() : 0)
363  ));
364 
365  $this->tpl->setContent($this->unit_form->getHtml());
366  }
367 
371  protected function addUnit()
372  {
373  if (!$this->isCRUDContext()) {
374  $this->showUnitsOfCategory();
375  return;
376  }
377 
378  $category = $this->getCategoryById((int) $_GET['category_id']);
379 
380  $this->initUnitForm($category);
381  if ($this->unit_form->checkInput()) {
382  $unit = new assFormulaQuestionUnit();
383  $unit->setUnit($this->unit_form->getInput('unit_title'));
384  $unit->setCategory($category->getId());
385 
386  $this->repository->createNewUnit($unit);
387 
388  $unit->setBaseUnit((int) $this->unit_form->getInput('base_unit'));
389  $unit->setFactor((float) $this->unit_form->getInput('factor'));
390 
391  $this->repository->saveUnit($unit);
392 
393  ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
394  $this->showUnitsOfCategory();
395  return;
396  }
397 
398  $this->unit_form->setValuesByPost();
399 
400  $this->tpl->setContent($this->unit_form->getHtml());
401  }
402 
406  protected function showUnitCreationForm()
407  {
408  if (!$this->isCRUDContext()) {
409  $this->showUnitsOfCategory();
410  return;
411  }
412 
413  $category = $this->getCategoryById((int) $_GET['category_id']);
414 
415  $this->initUnitForm($category);
416  $this->unit_form->setValuesByArray(array(
417  'factor' => 1,
418  'unit_title' => $this->lng->txt('unit_placeholder')
419  ));
420 
421  $this->tpl->setContent($this->unit_form->getHtml());
422  }
423 
429  protected function initUnitForm(assFormulaQuestionUnitCategory $category = null, assFormulaQuestionUnit $unit = null)
430  {
431  if ($this->unit_form instanceof ilPropertyFormGUI) {
432  return $this->unit_form;
433  }
434 
435  $unit_in_use = false;
436  if ($unit instanceof assFormulaQuestionUnit && $this->repository->isUnitInUse($unit->getId())) {
437  $unit_in_use = true;
438  }
439 
440  $this->unit_form = new ilPropertyFormGUI();
441 
442  $title = new ilTextInputGUI($this->lng->txt('unit'), 'unit_title');
443  $title->setDisabled($unit_in_use);
444  $title->setRequired(true);
445  $this->unit_form->addItem($title);
446 
447  $baseunit = new ilSelectInputGUI($this->lng->txt('baseunit'), 'base_unit');
448  $items = $this->repository->getCategorizedUnits();
449  $options = array();
450  $category_name = '';
451  $new_category = false;
452  foreach ((array) $items as $item) {
453  if (
454  $unit instanceof assFormulaQuestionUnit &&
455  $unit->getId() == $item->getId()
456  ) {
457  continue;
458  }
459 
463  if ($item instanceof assFormulaQuestionUnitCategory) {
464  if ($category_name != $item->getDisplayString()) {
465  $new_category = true;
466  $category_name = $item->getDisplayString();
467  }
468  continue;
469  }
470  $options[$item->getId()] = $item->getDisplayString() . ($new_category ? ' (' . $category_name . ')' : '');
471  $new_category = false;
472  }
473  $baseunit->setDisabled($unit_in_use);
474  $baseunit->setOptions(array(0 => $this->lng->txt('no_selection')) + $options);
475  $this->unit_form->addItem($baseunit);
476 
477  $factor = new ilNumberInputGUI($this->lng->txt('factor'), 'factor');
478  $factor->setRequired(true);
479  $factor->setSize(3);
480  $factor->setMinValue(0);
481  $factor->allowDecimals(true);
482  $factor->setDisabled($unit_in_use);
483  $this->unit_form->addItem($factor);
484 
485  if (null === $unit) {
486  $this->unit_form->setTitle($this->lng->txt('new_unit'));
487  $this->unit_form->setFormAction($this->ctrl->getFormAction($this, 'addUnit'));
488  $this->unit_form->addCommandButton('addUnit', $this->lng->txt('save'));
489  } else {
490  $this->ctrl->setParameter($this, 'unit_id', $unit->getId());
491  if ($unit_in_use) {
492  $this->unit_form->setFormAction($this->ctrl->getFormAction($this, 'showUnitsOfCategory'));
493  } else {
494  $this->unit_form->addCommandButton('saveUnit', $this->lng->txt('save'));
495  $this->unit_form->setFormAction($this->ctrl->getFormAction($this, 'saveUnit'));
496  }
497  $this->unit_form->setTitle(sprintf($this->lng->txt('un_sel_cat_sel_unit'), $category->getDisplayString(), $unit->getDisplayString()));
498  }
499 
500  $this->unit_form->addCommandButton('showUnitsOfCategory', $this->lng->txt('cancel'));
501  return $this->unit_form;
502  }
503 
507  protected function showUnitsOfCategory()
508  {
512  global $DIC;
513  $ilToolbar = $DIC['ilToolbar'];
514 
515  $category = $this->getCategoryById((int) $_GET['category_id'], false);
516 
517  $this->tpl->addJavaScript("./Services/JavaScript/js/Basic.js");
518  $this->tpl->addJavaScript("./Services/Form/js/Form.js");
519  $this->lng->loadLanguageModule('form');
520 
521  require_once 'Modules/TestQuestionPool/classes/tables/class.ilUnitTableGUI.php';
522  $ilToolbar->addButton($this->lng->txt('back'), $this->ctrl->getLinkTarget($this, $this->getUnitCategoryOverviewCommand()));
523  if ($this->isCRUDContext()) {
524  $ilToolbar->addButton($this->lng->txt('un_add_unit'), $this->ctrl->getLinkTarget($this, 'showUnitCreationForm'));
525  }
526  $table = new ilUnitTableGUI($this, 'showUnitsOfCategory', $category);
527  $units = $this->repository->loadUnitsForCategory($category->getId());
528  $data = array();
529  foreach ($units as $unit) {
533  $data[] = array(
534  'unit_id' => $unit->getId(),
535  'unit' => $unit->getUnit(),
536  'baseunit' => $unit->getBaseunitTitle(),
537  'baseunit_id' => $unit->getBaseUnit(),
538  'factor' => $unit->getFactor(),
539  'sequence' => $unit->getSequence(),
540  );
541  }
542  $table->setData($data);
543 
544  $this->tpl->setContent($table->getHTML());
545  }
546 
550  protected function showGlobalUnitCategories()
551  {
552  $categories = array_filter(
553  $this->repository->getAllUnitCategories(),
554  function (assFormulaQuestionUnitCategory $category) {
555  return !$category->getQuestionFi() ? true : false;
556  }
557  );
558  $data = array();
559  foreach ($categories as $category) {
563  $data[] = array(
564  'category_id' => $category->getId(),
565  'category' => $category->getDisplayString()
566  );
567  }
568 
569  $this->showUnitCategories($data);
570  }
571 
575  protected function confirmDeleteCategory()
576  {
577  if (!isset($_GET['category_id'])) {
578  $this->{$this->getUnitCategoryOverviewCommand()}();
579  return;
580  }
581  $_POST['category_ids'] = array($_GET['category_id']);
582 
583  $this->confirmDeleteCategories();
584  }
585 
589  protected function confirmDeleteCategories()
590  {
591  if (!$this->isCRUDContext()) {
592  $this->{$this->getDefaultCommand()}();
593  return;
594  }
595 
596  if (!isset($_POST['category_ids']) || !is_array($_POST['category_ids'])) {
597  $this->{$this->getUnitCategoryOverviewCommand()}();
598  return;
599  }
600 
601  require_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
602  $confirmation = new ilConfirmationGUI();
603  $confirmation->setFormAction($this->ctrl->getFormAction($this, 'deleteCategories'));
604  $confirmation->setConfirm($this->lng->txt('confirm'), 'deleteCategories');
605  $confirmation->setCancel($this->lng->txt('cancel'), $this->getUnitCategoryOverviewCommand());
606 
607  $errors = array();
608  $num_to_confirm = 0;
609  foreach ($_POST['category_ids'] as $category_id) {
610  try {
611  $category = $this->repository->getUnitCategoryById((int) $category_id);
612  } catch (ilException $e) {
613  continue;
614  }
615 
616  if (!$this->repository->isCRUDAllowed((int) $category_id)) {
617  $errors[] = $category->getDisplayString() . ' - ' . $this->lng->txt('change_adm_categories_not_allowed');
618  continue;
619  }
620 
621  $possible_error = $this->repository->checkDeleteCategory($category_id);
622  if (strlen($possible_error)) {
623  $errors[] = $category->getDisplayString() . ' - ' . $possible_error;
624  continue;
625  }
626 
627  $confirmation->addItem('category_ids[]', $category->getId(), $category->getDisplayString());
628  ++$num_to_confirm;
629  }
630 
631  if ($errors) {
632  $num_errors = count($errors);
633 
634  $error_message = array_map(function ($message) {
635  return '<li>' . $message . '</li>';
636  }, $errors);
637  if ($num_errors == 1) {
638  ilUtil::sendFailure($this->lng->txt('un_cat_deletion_errors_f_s') . '<ul>' . implode('', $error_message) . '<ul>');
639  } else {
640  ilUtil::sendFailure($this->lng->txt('un_cat_deletion_errors_f') . '<ul>' . implode('', $error_message) . '<ul>');
641  }
642  }
643 
644  if ($num_to_confirm) {
645  if ($num_to_confirm == 1) {
646  $confirmation->setHeaderText($this->lng->txt('un_sure_delete_categories_s'));
647  } else {
648  $confirmation->setHeaderText($this->lng->txt('un_sure_delete_categories'));
649  }
650 
651  $this->tpl->setContent($confirmation->getHTML());
652  } else {
653  $this->{$this->getUnitCategoryOverviewCommand()}();
654  }
655  }
656 
660  protected function deleteCategories()
661  {
662  if (!$this->isCRUDContext()) {
663  $this->{$this->getDefaultCommand()}();
664  return;
665  }
666 
667  if (!is_array($_POST['category_ids']) || !$_POST['category_ids']) {
668  $this->{$this->getUnitCategoryOverviewCommand()}();
669  return;
670  }
671 
672  $errors = array();
673  $num_deleted = 0;
674  foreach ($_POST['category_ids'] as $category_id) {
675  try {
676  $category = $this->repository->getUnitCategoryById((int) $category_id);
677  } catch (ilException $e) {
678  continue;
679  }
680 
681  if (!$this->repository->isCRUDAllowed((int) $category_id)) {
682  $errors[] = $category->getDisplayString() . ' - ' . $this->lng->txt('change_adm_categories_not_allowed');
683  continue;
684  }
685 
686  $possible_error = $this->repository->deleteCategory($category_id);
687  if (strlen($possible_error)) {
688  $errors[] = $category->getDisplayString() . ' - ' . $possible_error;
689  continue;
690  }
691 
692  ++$num_deleted;
693  }
694 
695  if ($errors) {
696  $num_errors = count($errors);
697 
698  $error_message = array_map(function ($message) {
699  return '<li>' . $message . '</li>';
700  }, $errors);
701  if ($num_errors == 1) {
702  ilUtil::sendFailure($this->lng->txt('un_cat_deletion_errors_p_s') . '<ul>' . implode('', $error_message) . '<ul>');
703  } else {
704  ilUtil::sendFailure($this->lng->txt('un_cat_deletion_errors_p') . '<ul>' . implode('', $error_message) . '<ul>');
705  }
706  }
707 
708  if ($num_deleted) {
709  if ($num_deleted == 1) {
710  ilUtil::sendSuccess($this->lng->txt('un_deleted_categories_s'));
711  } else {
712  ilUtil::sendSuccess($this->lng->txt('un_deleted_categories'));
713  }
714  }
715 
716  $this->{$this->getUnitCategoryOverviewCommand()}();
717  }
718 
723  protected function initUnitCategoryForm(assFormulaQuestionUnitCategory $cat = null)
724  {
725  if ($this->unit_cat_form instanceof ilPropertyFormGUI) {
726  return $this->unit_cat_form;
727  }
728 
729  $this->unit_cat_form = new ilPropertyFormGUI();
730 
731  $title = new ilTextInputGUI($this->lng->txt('title'), 'category_name');
732  $title->setRequired(true);
733  $this->unit_cat_form->addItem($title);
734 
735  if (null === $cat) {
736  $this->unit_cat_form->setTitle($this->lng->txt('new_category'));
737  $this->unit_cat_form->setFormAction($this->ctrl->getFormAction($this, 'addCategory'));
738  $this->unit_cat_form->addCommandButton('addCategory', $this->lng->txt('save'));
739  } else {
740  $this->ctrl->setParameter($this, 'category_id', $cat->getId());
741  $this->unit_cat_form->addCommandButton('saveCategory', $this->lng->txt('save'));
742  $this->unit_cat_form->setFormAction($this->ctrl->getFormAction($this, 'saveCategory'));
743  $this->unit_cat_form->setTitle(sprintf($this->lng->txt('selected_category'), $cat->getDisplayString()));
744  }
745 
746  $this->unit_cat_form->addCommandButton($this->getUnitCategoryOverviewCommand(), $this->lng->txt('cancel'));
747  return $this->unit_cat_form;
748  }
749 
753  protected function addCategory()
754  {
755  if (!$this->isCRUDContext()) {
756  $this->{$this->getDefaultCommand()}();
757  return;
758  }
759 
760  $this->initUnitCategoryForm();
761  if ($this->unit_cat_form->checkInput()) {
762  try {
763  $category = new assFormulaQuestionUnitCategory();
764  $category->setCategory($this->unit_cat_form->getInput('category_name'));
765  $this->repository->saveNewUnitCategory($category);
766  ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
767 
768  $this->{$this->getUnitCategoryOverviewCommand()}();
769  return;
770  } catch (ilException $e) {
771  $this->unit_cat_form->getItemByPostVar('category_name')->setAlert($this->lng->txt($e->getMessage()));
772  ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
773  }
774  }
775 
776  $this->unit_cat_form->setValuesByPost();
777 
778  $this->tpl->setContent($this->unit_cat_form->getHtml());
779  }
780 
784  protected function showUnitCategoryCreationForm()
785  {
786  if (!$this->isCRUDContext()) {
787  $this->{$this->getDefaultCommand()}();
788  return;
789  }
790 
791  $this->initUnitCategoryForm();
792 
793  $this->tpl->setContent($this->unit_cat_form->getHtml());
794  }
795 
799  protected function saveCategory()
800  {
801  if (!$this->isCRUDContext()) {
802  $this->{$this->getDefaultCommand()}();
803  return;
804  }
805 
806  $category = $this->getCategoryById((int) $_GET['category_id']);
807 
808  $this->initUnitCategoryForm($category);
809  if ($this->unit_cat_form->checkInput()) {
810  try {
811  $category->setCategory($this->unit_cat_form->getInput('category_name'));
812  $this->repository->saveCategory($category);
813  ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
814 
815  $this->{$this->getUnitCategoryOverviewCommand()}();
816  return;
817  } catch (ilException $e) {
818  $this->unit_cat_form->getItemByPostVar('category_name')->setAlert($this->lng->txt($e->getMessage()));
819  ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
820  }
821  }
822 
823  $this->unit_cat_form->setValuesByPost();
824 
825  $this->tpl->setContent($this->unit_cat_form->getHtml());
826  }
827 
831  protected function showUnitCategoryModificationForm()
832  {
833  if (!$this->isCRUDContext()) {
834  $this->{$this->getDefaultCommand()}();
835  return;
836  }
837 
838  $category = $this->getCategoryById((int) $_GET['category_id']);
839 
840  $this->initUnitCategoryForm($category);
841  $this->unit_cat_form->setValuesByArray(array(
842  'category_name' => $category->getCategory()
843  ));
844 
845  $this->tpl->setContent($this->unit_cat_form->getHtml());
846  }
847 }
This class represents a selection list property in a property form.
This class represents a property form user interface.
global $DIC
Definition: saml.php:7
$_GET["client_id"]
initUnitCategoryForm(assFormulaQuestionUnitCategory $cat=null)
if(!array_key_exists('StateId', $_REQUEST)) $id
Class ilUnitConfigurationRepository.
Class ilUnitConfigurationGUI .
showUnitCategories(array $categories)
global $ilCtrl
Definition: ilias.php:18
catch(Exception $e) $message
repository()
Definition: repository.php:5
This class represents a number property in a property form.
This class represents a text property in a property form.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$errors
Definition: index.php:6
Class ilUnitTableGUI.
if(empty($password)) $table
Definition: pwgen.php:24
$_POST["username"]
setRequired($a_required)
Set Required.
Confirmation screen class.
$data
Definition: bench.php:6