ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilUnitConfigurationGUI Class Reference

Class ilUnitConfigurationGUI . More...

+ Inheritance diagram for ilUnitConfigurationGUI:
+ Collaboration diagram for ilUnitConfigurationGUI:

Public Member Functions

 getUnitCategoryOverviewCommand ()
 
 isCRUDContext ()
 
 getUniqueId ()
 
 executeCommand ()
 
 deleteUnits ()
 

Protected Member Functions

 getDefaultCommand ()
 
 showUnitCategories (array $categories)
 
 getCategoryById ($id, $for_CRUD=true)
 
 handleSubtabs ()
 
 checkPermissions ($cmd)
 
 confirmDeleteUnit ()
 
 confirmDeleteUnits ()
 
 saveOrder ()
 
 saveUnit ()
 Save a unit. More...
 
 showUnitModificationForm ()
 
 addUnit ()
 Adds a new unit. More...
 
 showUnitCreationForm ()
 
 confirmDeleteCategory ()
 
 confirmDeleteCategories ()
 
 deleteCategories ()
 
 initUnitCategoryForm (assFormulaQuestionUnitCategory $cat=null)
 
 addCategory ()
 
 showUnitCategoryCreationForm ()
 
 saveCategory ()
 
 showUnitCategoryModificationForm ()
 

Protected Attributes

 $unit_cat_form
 
 $unit_form
 
 $repository = null
 
 $tpl
 
 $lng
 
 $ctrl
 

Detailed Description

Class ilUnitConfigurationGUI .

Definition at line 10 of file class.ilUnitConfigurationGUI.php.

Member Function Documentation

◆ addCategory()

ilUnitConfigurationGUI::addCategory ( )
protected

Definition at line 753 of file class.ilUnitConfigurationGUI.php.

References getDefaultCommand(), getUnitCategoryOverviewCommand(), initUnitCategoryForm(), isCRUDContext(), repository(), and ilUtil\sendFailure().

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  }
initUnitCategoryForm(assFormulaQuestionUnitCategory $cat=null)
repository()
Definition: repository.php:5
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:

◆ addUnit()

ilUnitConfigurationGUI::addUnit ( )
protected

Adds a new unit.

Definition at line 371 of file class.ilUnitConfigurationGUI.php.

References $_GET, getCategoryById(), isCRUDContext(), and repository().

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  }
$_GET["client_id"]
repository()
Definition: repository.php:5
+ Here is the call graph for this function:

◆ checkPermissions()

ilUnitConfigurationGUI::checkPermissions (   $cmd)
protected
Parameters
string$cmd

Definition at line 119 of file class.ilUnitConfigurationGUI.php.

Referenced by executeCommand().

120  {
121  }
+ Here is the caller graph for this function:

◆ confirmDeleteCategories()

ilUnitConfigurationGUI::confirmDeleteCategories ( )
protected

Definition at line 589 of file class.ilUnitConfigurationGUI.php.

References $_POST, $errors, $message, getDefaultCommand(), getUnitCategoryOverviewCommand(), isCRUDContext(), repository(), and ilUtil\sendFailure().

Referenced by confirmDeleteCategory().

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  }
catch(Exception $e) $message
repository()
Definition: repository.php:5
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$errors
Definition: index.php:6
$_POST["username"]
Confirmation screen class.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ confirmDeleteCategory()

ilUnitConfigurationGUI::confirmDeleteCategory ( )
protected

Definition at line 575 of file class.ilUnitConfigurationGUI.php.

References $_GET, $_POST, confirmDeleteCategories(), and getUnitCategoryOverviewCommand().

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  }
$_GET["client_id"]
$_POST["username"]
+ Here is the call graph for this function:

◆ confirmDeleteUnit()

ilUnitConfigurationGUI::confirmDeleteUnit ( )
protected

Definition at line 145 of file class.ilUnitConfigurationGUI.php.

References $_GET, $_POST, and confirmDeleteUnits().

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  }
$_GET["client_id"]
$_POST["username"]
+ Here is the call graph for this function:

◆ confirmDeleteUnits()

ilUnitConfigurationGUI::confirmDeleteUnits ( )
protected

Definition at line 159 of file class.ilUnitConfigurationGUI.php.

References $_POST, $errors, $message, isCRUDContext(), repository(), and ilUtil\sendFailure().

Referenced by confirmDeleteUnit().

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  }
catch(Exception $e) $message
repository()
Definition: repository.php:5
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$errors
Definition: index.php:6
$_POST["username"]
Confirmation screen class.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteCategories()

ilUnitConfigurationGUI::deleteCategories ( )
protected

Definition at line 660 of file class.ilUnitConfigurationGUI.php.

References $_POST, $errors, $message, getDefaultCommand(), getUnitCategoryOverviewCommand(), isCRUDContext(), repository(), and ilUtil\sendFailure().

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  }
catch(Exception $e) $message
repository()
Definition: repository.php:5
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$errors
Definition: index.php:6
$_POST["username"]
+ Here is the call graph for this function:

◆ deleteUnits()

ilUnitConfigurationGUI::deleteUnits ( )

Definition at line 227 of file class.ilUnitConfigurationGUI.php.

References $_POST, $errors, $message, isCRUDContext(), repository(), and ilUtil\sendFailure().

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  }
catch(Exception $e) $message
repository()
Definition: repository.php:5
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$errors
Definition: index.php:6
$_POST["username"]
+ Here is the call graph for this function:

◆ executeCommand()

ilUnitConfigurationGUI::executeCommand ( )

Definition at line 126 of file class.ilUnitConfigurationGUI.php.

References checkPermissions(), getDefaultCommand(), and handleSubtabs().

Referenced by ilLocalUnitConfigurationGUI\getUniqueId().

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  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCategoryById()

ilUnitConfigurationGUI::getCategoryById (   $id,
  $for_CRUD = true 
)
protected
Parameters
int$id
bool$for_CRUD
Returns
assFormulaQuestionUnitCategory

Definition at line 99 of file class.ilUnitConfigurationGUI.php.

References $id, getDefaultCommand(), repository(), and ilUtil\sendFailure().

Referenced by addUnit(), saveCategory(), saveUnit(), showUnitCategoryModificationForm(), showUnitCreationForm(), and showUnitModificationForm().

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  }
if(!array_key_exists('StateId', $_REQUEST)) $id
repository()
Definition: repository.php:5
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDefaultCommand()

ilUnitConfigurationGUI::getDefaultCommand ( )
abstractprotected

◆ getUniqueId()

ilUnitConfigurationGUI::getUniqueId ( )
abstract
Returns
string

◆ getUnitCategoryOverviewCommand()

ilUnitConfigurationGUI::getUnitCategoryOverviewCommand ( )
abstract

◆ handleSubtabs()

ilUnitConfigurationGUI::handleSubtabs ( )
protected

Definition at line 112 of file class.ilUnitConfigurationGUI.php.

Referenced by executeCommand(), and ilLocalUnitConfigurationGUI\getUniqueId().

113  {
114  }
+ Here is the caller graph for this function:

◆ initUnitCategoryForm()

ilUnitConfigurationGUI::initUnitCategoryForm ( assFormulaQuestionUnitCategory  $cat = null)
protected
Parameters
assFormulaQuestionUnitCategory$cat
Returns
ilPropertyFormGUI

Definition at line 723 of file class.ilUnitConfigurationGUI.php.

References $title, $unit_cat_form, and getUnitCategoryOverviewCommand().

Referenced by addCategory(), saveCategory(), showUnitCategoryCreationForm(), and showUnitCategoryModificationForm().

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  }
This class represents a property form user interface.
This class represents a text property in a property form.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isCRUDContext()

◆ saveCategory()

ilUnitConfigurationGUI::saveCategory ( )
protected

Definition at line 799 of file class.ilUnitConfigurationGUI.php.

References $_GET, getCategoryById(), getDefaultCommand(), getUnitCategoryOverviewCommand(), initUnitCategoryForm(), isCRUDContext(), repository(), and ilUtil\sendFailure().

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  }
$_GET["client_id"]
initUnitCategoryForm(assFormulaQuestionUnitCategory $cat=null)
repository()
Definition: repository.php:5
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:

◆ saveOrder()

ilUnitConfigurationGUI::saveOrder ( )
protected

Definition at line 287 of file class.ilUnitConfigurationGUI.php.

References $_POST, $id, isCRUDContext(), and repository().

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  }
if(!array_key_exists('StateId', $_REQUEST)) $id
repository()
Definition: repository.php:5
$_POST["username"]
+ Here is the call graph for this function:

◆ saveUnit()

ilUnitConfigurationGUI::saveUnit ( )
protected

Save a unit.

Definition at line 313 of file class.ilUnitConfigurationGUI.php.

References $_GET, getCategoryById(), isCRUDContext(), repository(), and showUnitModificationForm().

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  }
$_GET["client_id"]
repository()
Definition: repository.php:5
+ Here is the call graph for this function:

◆ showUnitCategories()

ilUnitConfigurationGUI::showUnitCategories ( array  $categories)
abstractprotected
Parameters
array$categories

Referenced by showUnitCreationForm().

+ Here is the caller graph for this function:

◆ showUnitCategoryCreationForm()

ilUnitConfigurationGUI::showUnitCategoryCreationForm ( )
protected

Definition at line 784 of file class.ilUnitConfigurationGUI.php.

References getDefaultCommand(), initUnitCategoryForm(), and isCRUDContext().

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  }
initUnitCategoryForm(assFormulaQuestionUnitCategory $cat=null)
+ Here is the call graph for this function:

◆ showUnitCategoryModificationForm()

ilUnitConfigurationGUI::showUnitCategoryModificationForm ( )
protected

Definition at line 831 of file class.ilUnitConfigurationGUI.php.

References $_GET, getCategoryById(), getDefaultCommand(), initUnitCategoryForm(), and isCRUDContext().

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  }
$_GET["client_id"]
initUnitCategoryForm(assFormulaQuestionUnitCategory $cat=null)
+ Here is the call graph for this function:

◆ showUnitCreationForm()

ilUnitConfigurationGUI::showUnitCreationForm ( )
protected

Definition at line 406 of file class.ilUnitConfigurationGUI.php.

References $_GET, $data, $DIC, PHPMailer\PHPMailer\$options, $table, $title, $unit_form, getCategoryById(), assFormulaQuestionUnit\getId(), getUnitCategoryOverviewCommand(), isCRUDContext(), repository(), ilFormPropertyGUI\setRequired(), and showUnitCategories().

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  }
$_GET["client_id"]
+ Here is the call graph for this function:

◆ showUnitModificationForm()

ilUnitConfigurationGUI::showUnitModificationForm ( )
protected

Definition at line 348 of file class.ilUnitConfigurationGUI.php.

References $_GET, getCategoryById(), isCRUDContext(), and repository().

Referenced by saveUnit().

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  }
$_GET["client_id"]
repository()
Definition: repository.php:5
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $ctrl

ilUnitConfigurationGUI::$ctrl
protected

Definition at line 40 of file class.ilUnitConfigurationGUI.php.

◆ $lng

ilUnitConfigurationGUI::$lng
protected

Definition at line 35 of file class.ilUnitConfigurationGUI.php.

◆ $repository

ilUnitConfigurationGUI::$repository = null
protected

◆ $tpl

ilUnitConfigurationGUI::$tpl
protected

Definition at line 30 of file class.ilUnitConfigurationGUI.php.

◆ $unit_cat_form

ilUnitConfigurationGUI::$unit_cat_form
protected

Definition at line 15 of file class.ilUnitConfigurationGUI.php.

Referenced by initUnitCategoryForm().

◆ $unit_form

ilUnitConfigurationGUI::$unit_form
protected

Definition at line 20 of file class.ilUnitConfigurationGUI.php.

Referenced by showUnitCreationForm().


The documentation for this class was generated from the following file: