ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilObjStudyProgrammeReferenceGUI.php
Go to the documentation of this file.
1<?php
6{
14 public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = false)
15 {
16 $this->target_type = 'prg';
17 $this->reference_type = 'prgr';
18 parent::__construct($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
19 }
20
26 public static function _goto($a_target)
27 {
29 ilObjStudyProgrammeGUI::_goto($target_ref_id);
30 }
31
39 public function saveObject()
40 {
41 $ilAccess = $this->access;
42
43 if (!(int) $_REQUEST['target_id']) {
44 $this->createObject();
45 return false;
46 }
47 if (!$ilAccess->checkAccess('visible', '', (int) $_REQUEST['target_id'])) {
48 ilUtil::sendFailure($this->lng->txt('permission_denied'));
49 $this->createObject();
50 return false;
51 }
52 if ($this->tryingToCreateCircularReference((int) $_REQUEST['target_id'], (int) $_REQUEST['ref_id'])) {
53 ilUtil::sendFailure($this->lng->txt('prgr_may_not_create_circular_reference'));
54 $this->createObject();
55 return false;
56 }
57 parent::saveObject();
58 }
59
60
61 public function putObjectInTree(ilObject $a_obj, $a_parent_node_id = null)
62 {
63 // when this is called, the target allready should be defined...
64 $target_obj_id = ilObject::_lookupObjId((int) $this->form->getInput('target_id'));
65 $a_obj->setTargetId($target_obj_id);
66 $a_obj->update();
67 parent::putObjectInTree($a_obj, $a_parent_node_id);
68 }
69
70 protected function tryingToCreateCircularReference($obj_to_be_referenced, $reference_position)
71 {
72 if ($reference_position === $obj_to_be_referenced) {
73 return true;
74 }
75 $queque = [$reference_position];
76 while ($parent = array_shift($queque)) {
77 $p_parent = (int) $this->tree->getParentId($parent);
78 if ($p_parent === $obj_to_be_referenced) {
79 return true;
80 }
81 if (ilObject::_lookupType($p_parent, true) === 'prg') {
82 array_push($queque, $p_parent);
83 }
84 foreach (ilContainerReference::_lookupSourceIds(ilObject::_lookupObjId($parent)) as $parent_ref_obj_id) {
85 $parent_ref_ref_id = (int) array_shift(ilObject::_getAllReferences($parent_ref_obj_id));
86 $parent_ref_loc = (int) $this->tree->getParentId($parent_ref_ref_id);
87 if ($parent_ref_loc === $obj_to_be_referenced) {
88 return true;
89 }
90 if (ilObject::_lookupType($parent_ref_loc, true) === 'prg') {
91 array_push($queque, $parent_ref_loc);
92 }
93 }
94 }
95 return false;
96 }
97}
An exception for terminatinating execution or to throw for unit testing.
static _lookupTargetRefId($a_obj_id)
Lookup target ref_id.
static _lookupSourceIds($a_target_id)
Get ids of all container references that target the object with the given id.
static _goto($a_target)
_goto Deep link
@ilCtrl_Calls ilObjStudyProgrammeReferenceGUI: ilPermissionGUI, ilInfoScreenGUI, ilPropertyFormGUI
static _goto($a_target)
Support for goto php.
__construct($a_data, $a_id, $a_call_by_reference=true, $a_prepare_output=false)
ilObjGroupReferenceGUI constructor.
tryingToCreateCircularReference($obj_to_be_referenced, $reference_position)
putObjectInTree(ilObject $a_obj, $a_parent_node_id=null)
Add object to tree at given position.
Class ilObject Basic functions for all objects.
static _lookupObjId($a_id)
update()
update object in db
static _getAllReferences($a_id)
get all reference ids of object
static _lookupType($a_id, $a_reference=false)
lookup object type
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc