ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilCtrl.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
3require_once('class.ilCachedCtrl.php');
4
15class ilCtrl
16{
17 const IL_RTOKEN_NAME = 'rtoken';
18
28 protected $save_parameter;
29
39 protected $parameter;
40
52 protected $return;
53
61 protected $call_hist = array(); // calling history
62
68 protected $calls = array();
69
77 protected $rtoken = false;
78
83 protected $target_script = "ilias.php";
84
88 protected $module_dir;
89
96
102 protected $inner_base_class = "";
103
107 public function __construct()
108 {
110
111 // this information should go to xml files one day
112 $this->stored_trees = array("ilrepositorygui", "ildashboardgui",
113 "illmpresentationgui", "illmeditorgui",
114 "iladministrationgui");
115 }
116
122 protected function initializeMemberVariables()
123 {
124 $this->save_parameter = array();
125 $this->parameter = array(); // save parameter array
126 $this->return = array(); // return commmands
127 $this->tab = array();
128 $this->current_node = 0;
129 $this->call_node = array();
130 $this->root_class = "";
131 }
132
140 public function callBaseClass()
141 {
142 global $DIC;
143
144 $ilDB = $DIC->database();
145
146 $baseClass = strtolower($_GET["baseClass"]);
147
148 $module_class = ilCachedCtrl::getInstance();
149 $mc_rec = $module_class->lookupModuleClass($baseClass);
150
151 $module = $mc_rec["module"];
152 $class = $mc_rec["class"];
153 $class_dir = $mc_rec["dir"];
154
155 if ($module != "") {
156 $m_set = $ilDB->query("SELECT * FROM il_component WHERE name = " .
157 $ilDB->quote($module, "text"));
158 $m_rec = $ilDB->fetchAssoc($m_set);
159 } else { // check whether class belongs to a service
160 $mc_rec = $module_class->lookupServiceClass($baseClass);
161
162 $service = $mc_rec["service"];
163 $class = $mc_rec["class"];
164 $class_dir = $mc_rec["dir"];
165
166 if ($service == "") {
167 include_once("./Services/UICore/exceptions/class.ilCtrlException.php");
168 throw new ilCtrlException("Could not find entry in modules.xml or services.xml for " .
169 $baseClass . " <br/>" . str_replace("&", "<br />&", htmlentities($_SERVER["REQUEST_URI"])));
170 }
171
172 $m_rec = ilComponent::getComponentInfo('Services', $service);
173 }
174
175 // forward processing to base class
176 $this->getCallStructure(strtolower($baseClass));
177 $base_class_gui = new $class();
178 $this->forwardCommand($base_class_gui);
179 }
180
187 public function getModuleDir()
188 {
189 throw new Exception("ilCtrl::getModuleDir is deprecated.");
190 //return $this->module_dir;
191 }
192
202 public function forwardCommand($a_gui_object)
203 {
204 $class = strtolower(get_class($a_gui_object));
205 $nr = $this->getNodeIdForTargetClass($this->current_node, $class);
206 $nr = $nr["node_id"];
207 if ($nr != "") {
208 $current_node = $this->current_node;
209
210 $this->current_node = $nr;
211
212 // always populate the call history
213 // it will only be displayed in DEVMODE but is needed for UI plugins, too
214 $this->call_hist[] = array("class" => get_class($a_gui_object),
215 "mode" => "execComm", "cmd" => $this->getCmd());
216
217 $html = $a_gui_object->executeCommand();
218
219 // reset current node
220 $this->current_node = $current_node;
221
222 return $html;
223 }
224
225 include_once("./Services/UICore/exceptions/class.ilCtrlException.php");
226 throw new ilCtrlException("ERROR: Can't forward to class $class.");
227 }
228
238 public function getHTML($a_gui_object, array $a_parameters = null, array $class_path = [])
239 {
240 $class = strtolower(get_class($a_gui_object));
241
242 if (count($class_path) > 0) {
243 $class_path = array_merge($class_path, [$class]);
244 $p = $this->getParameterArrayByClass($class_path);
245 $nr = $p["cmdNode"];
246 $baseclass = $p["baseClass"];
247 $this->inner_base_class = $p["cmdNode"];
248 } else {
249 $nr = $this->getNodeIdForTargetClass($this->current_node, $class);
250 $nr = $nr["node_id"];
251 }
252 if ($nr != "") {
253 $current_inner_base_class = $this->inner_base_class;
254 $this->use_current_to_determine_next = true;
255
256 if ($baseclass != $_GET["baseClass"]) {
257 $this->inner_base_class = $baseclass;
258 }
259 $current_node = $this->current_node;
260
261 // set current node to new gui class
262 $this->current_node = $nr;
263
264 // always populate the call history
265 // it will only be displayed in DEVMODE but is needed for UI plugins, too
266 $this->call_hist[] = array("class" => get_class($a_gui_object),
267 "mode" => "getHtml", "cmd" => $this->getCmd());
268
269 // get block
270 if ($a_parameters != null) {
271 $html = $a_gui_object->getHTML($a_parameters);
272 } else {
273 $html = $a_gui_object->getHTML();
274 }
275
276 // reset current node
277 $this->current_node = $current_node;
278 $this->inner_base_class = $current_inner_base_class;
279 $this->use_current_to_determine_next = false;
280
281 // return block
282 return $html;
283 }
284
285 include_once("./Services/UICore/exceptions/class.ilCtrlException.php");
286 throw new ilCtrlException("ERROR: Can't getHTML from class $class.");
287 }
288
298 public function setContext($a_obj_id, $a_obj_type, $a_sub_obj_id = 0, $a_sub_obj_type = "")
299 {
300 $this->context_obj_id = $a_obj_id;
301 $this->context_obj_type = $a_obj_type;
302 $this->context_sub_obj_id = $a_sub_obj_id;
303 $this->context_sub_obj_type = $a_sub_obj_type;
304 }
305
311 public function getContextObjId()
312 {
313 return $this->context_obj_id;
314 }
315
321 public function getContextObjType()
322 {
323 return $this->context_obj_type;
324 }
325
331 public function getContextSubObjId()
332 {
333 return $this->context_sub_obj_id;
334 }
335
341 public function getContextSubObjType()
342 {
343 return $this->context_sub_obj_type;
344 }
345
366 private function getNodeIdForTargetClass($a_par_node, $a_class, $a_check = false)
367 {
368 $class = strtolower($a_class);
369 $this->readClassInfo($class);
370
371 if ($a_par_node === 0 || $a_par_node == "") {
372 return array("node_id" => $this->getCidForClass($class),
373 "base_class" => $class);
374 }
375
376 $this->readNodeInfo($a_par_node);
377
378 $node_cid = $this->getCurrentCidOfNode($a_par_node);
379
380 // target class is class of current node id
381 if ($class == $this->getClassForCid($node_cid)) {
382 return array("node_id" => $a_par_node,
383 "base_class" => "");
384 }
385
386 // target class is child of current node id
387 if (isset($this->calls[$this->getClassForCid($node_cid)]) &&
388 is_array($this->calls[$this->getClassForCid($node_cid)]) &&
389 in_array($a_class, $this->calls[$this->getClassForCid($node_cid)])) {
390 return array("node_id" => $a_par_node . ":" . $this->getCidForClass($class),
391 "base_class" => "");
392 }
393
394 // target class is sibling
395 $par_cid = $this->getParentCidOfNode($a_par_node);
396 if ($par_cid != "") {
397 if (is_array($this->calls[$this->getClassForCid($par_cid)]) &&
398 in_array($a_class, $this->calls[$this->getClassForCid($par_cid)])) {
399 return array("node_id" =>
400 $this->removeLastCid($a_par_node) . ":" . $this->getCidForClass($class),
401 "base_class" => "");
402 }
403 }
404
405 // target class is parent
406 $temp_node = $this->removeLastCid($a_par_node);
407 while ($temp_node != "") {
408 $temp_cid = $this->getCurrentCidOfNode($temp_node);
409 if ($this->getClassForCid($temp_cid) == $a_class) {
410 return array("node_id" => $temp_node,
411 "base_class" => "");
412 }
413 $temp_node = $this->removeLastCid($temp_node);
414 }
415
416 // target class is another base class
417 $n_class = "";
418 if ($a_class != "") {
419 $module_class = ilCachedCtrl::getInstance();
420 $mc_rec = $module_class->lookupModuleClass($class);
421 $n_class = $mc_rec['lower_class'];
422
423 if ($n_class == "") {
424 $mc_rec = $module_class->lookupServiceClass($class);
425 $n_class = $mc_rec['lower_class'];
426 }
427
428 if ($n_class != "") {
429 $this->getCallStructure($n_class);
430 return array("node_id" => $this->getCidForClass($n_class),
431 "base_class" => $class);
432 }
433 }
434
435 if ($a_check) {
436 return false;
437 }
438
439 // Please do NOT change these lines.
440 // Developers must be aware, if they use classes unknown to the controller
441 // otherwise certain problem will be extremely hard to track down...
442
443 error_log("ERROR: Can't find target class $a_class for node $a_par_node " .
444 "(" . $this->cid_class[$this->getCidOfNode($a_par_node)] . ")");
445
446 include_once("./Services/UICore/exceptions/class.ilCtrlException.php");
447 throw new ilCtrlException("ERROR: Can't find target class $a_class for node $a_par_node " .
448 "(" . $this->cid_class[$this->getCidOfNode($a_par_node)] . ").");
449 }
450
457 public function checkTargetClass($a_class)
458 {
459 if (!is_array($a_class)) {
460 $a_class = array($a_class);
461 }
462
463 $nr = $this->current_node;
464 foreach ($a_class as $class) {
465 $class = strtolower($class);
466
467 if (!$this->getCidForClass($class, true)) {
468 return false;
469 }
470
471 $nr = $this->getNodeIdForTargetClass($nr, $class, true);
472 $nr = $nr["node_id"];
473 if ($nr === false) {
474 return false;
475 }
476 }
477 return true;
478 }
479
485 public function getCmdNode()
486 {
487 return $_GET["cmdNode"];
488 }
489
498 public function addTab($a_lang_var, $a_link, $a_cmd, $a_class)
499 {
500 $a_class = strtolower($a_class);
501
502 $this->tab[] = array("lang_var" => $a_lang_var,
503 "link" => $a_link, "cmd" => $a_cmd, "class" => $a_class);
504 }
505
511 public function getTabs()
512 {
513 return $this->tab;
514 }
515
523 public function getCallHistory()
524 {
525 return $this->call_hist;
526 }
527
543 public function getCallStructure($a_class)
544 {
545 $this->readClassInfo($a_class);
546 }
547
551 public function readCallStructure($a_class, $a_nr = 0, $a_parent = 0)
552 {
553 global $DIC;
554
555 $ilDB = $DIC->database();
556
557 $a_class = strtolower($a_class);
558
559 $a_nr++;
560
561 // determine call node structure
562 $this->call_node[$a_nr] = array("class" => $a_class, "parent" => $a_parent);
563
564 $call_set = $ilDB->query("SELECT * FROM ctrl_calls WHERE parent = " .
565 $ilDB->quote(strtolower($a_class), "text") .
566 " ORDER BY child", array("text"));
567 $a_parent = $a_nr;
568 while ($call_rec = $ilDB->fetchAssoc($call_set)) {
569 $a_nr = $this->readCallStructure($call_rec["child"], $a_nr, $a_parent);
570 $forw[] = $call_rec["child"];
571 }
572
573 // determine root class
574 $this->root_class = $a_class;
575 return $a_nr;
576 }
577
597 public function saveParameter($a_obj, $a_parameter)
598 {
599 if (is_object($a_obj)) {
600 $this->saveParameterByClass(get_class($a_obj), $a_parameter);
601 }
602 }
603
610 public function saveParameterByClass($a_class, $a_parameter)
611 {
612 if (is_array($a_parameter)) {
613 foreach ($a_parameter as $parameter) {
614 $this->save_parameter[strtolower($a_class)][] = $parameter;
615 }
616 } else {
617 $this->save_parameter[strtolower($a_class)][] = $a_parameter;
618 }
619 }
620
621
644 public function setParameter($a_obj, $a_parameter, $a_value)
645 {
646 $this->parameter[strtolower(get_class($a_obj))][$a_parameter] = $a_value;
647 }
648
649
657 public function setParameterByClass($a_class, $a_parameter, $a_value)
658 {
659 $this->parameter[strtolower($a_class)][$a_parameter] = $a_value;
660 }
661
669 public function clearParameterByClass($a_class, $a_parameter)
670 {
671 unset($this->parameter[strtolower($a_class)][$a_parameter]);
672 }
673
680 public function clearParameters($a_obj)
681 {
682 $this->clearParametersByClass(strtolower(get_class($a_obj)));
683 }
684
691 public function clearParametersByClass($a_class)
692 {
693 $this->parameter[strtolower($a_class)] = array();
694 }
695
696 protected function checkLPSettingsForward($a_gui_obj, $a_cmd_node)
697 {
698 global $DIC;
699
700 $objDefinition = $DIC["objDefinition"];
701
702 // forward to learning progress settings if possible and accessible
703 if ($_GET["gotolp"] &&
704 $a_gui_obj) {
705 $ref_id = $_GET["ref_id"];
706 if (!$ref_id) {
707 $ref_id = $_REQUEST["ref_id"];
708 }
709
710 $gui_class = get_class($a_gui_obj);
711
712 if ($gui_class == "ilSAHSEditGUI") {
713 // #1625 - because of scorm "sub-types" this is all very special
714 include_once "./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php";
715 $obj_id = ilObject::_lookupObjectId($ref_id);
717 case "scorm2004":
718 $class = "ilObjSCORM2004LearningModuleGUI";
719 break;
720
721 case "scorm":
722 $class = "ilObjSCORMLearningModuleGUI";
723 break;
724
725 case "aicc":
726 $class = "ilObjAICCLearningModuleGUI";
727 break;
728
729 case "hacp":
730 $class = "ilObjHACPLearningModuleGUI";
731 break;
732 }
733 if ($GLOBALS["ilAccess"]->checkAccess("edit_learning_progress", "", $ref_id)) {
734 $this->redirectByClass(array($gui_class, $class, "illearningprogressgui", "illplistofsettingsgui"), "");
735 }
736 }
737 // special case: cannot use any presentation GUIs
738 elseif ($gui_class == "ilLMPresentationGUI") {
739 $this->setParameterByClass("ilObjLearningModuleGUI", "gotolp", 1);
740 $this->redirectByClass(array("ilLMEditorGUI", "ilObjLearningModuleGUI"), "");
741 }
742
743 include_once "Services/Object/classes/class.ilObjectLP.php";
744 $type = ilObject::_lookupType($ref_id, true);
745 $class = "ilObj" . $objDefinition->getClassName($type) . "GUI";
746
747 if ($gui_class == $class &&
749 $GLOBALS["ilAccess"]->checkAccess("edit_learning_progress", "", $ref_id)) {
750 // add path to repository object gui if missing from cmdNode
751 if (!$a_cmd_node) {
752 $repo_node = $this->getNodeIdForTargetClass(null, "ilrepositorygui");
753 $obj_node = $this->getNodeIdForTargetClass($repo_node["node_id"], $gui_class);
754 $a_cmd_node = $obj_node["node_id"];
755 }
756 // find path to lp settings
757 $lp_node = $this->getNodeIdForTargetClass($a_cmd_node, "illearningprogressgui");
758 $lp_settings_node = $this->getNodeIdForTargetClass($lp_node["node_id"], "illplistofsettingsgui");
759 $_GET["cmdNode"] = $lp_settings_node["node_id"];
760 $_GET["cmdClass"] = "ilLPListOfSettingsGUI";
761 $_GET["cmd"] = "";
762 return "illearningprogressgui";
763 }
764 }
765 }
766
775 public function getNextClass($a_gui_class = null)
776 {
777 if ($this->use_current_to_determine_next) {
778 $cmdNode = $this->current_node;
779 } else {
780 $cmdNode = $this->getCmdNode();
781 }
782
783 if ($cmdNode == "") {
784 return ($class = $this->checkLPSettingsForward($a_gui_class, $cmdNode))
785 ? $class
786 : false;
787 } else {
788 if ($this->current_node == $cmdNode) {
789 return ($class = $this->checkLPSettingsForward($a_gui_class, $cmdNode))
790 ? $class
791 : "";
792 } else {
793 $path = $this->getPathNew($this->current_node, $cmdNode);
794 $this->readCidInfo($this->getCurrentCidOfNode($path[1]));
795 return $this->cid_class[$this->getCurrentCidOfNode($path[1])];
796 }
797 }
798 }
799
806 public function lookupClassPath($a_class_name)
807 {
808 $a_class_name = strtolower($a_class_name);
809
810 $cached_ctrl = ilCachedCtrl::getInstance();
811 $class_rec = $cached_ctrl->lookupClassFile($a_class_name);
812
813 if ($class_rec["plugin_path"] != "") {
814 return $class_rec["plugin_path"] . "/" . $class_rec["filename"];
815 } else {
816 return $class_rec["filename"];
817 }
818 }
819
828 public function getClassForClasspath($a_class_path)
829 {
830 $path = pathinfo($a_class_path);
831 $file = $path["basename"];
832 $class = substr($file, 6, strlen($file) - 10);
833
834 return $class;
835 }
836
843 private function getPathNew($a_source_node, $a_target_node)
844 {
845 if ($a_source_node == "1") {
846 $a_source_node = "";
847 }
848 if (substr($a_target_node, 0, strlen($a_source_node)) != $a_source_node) {
849 $failure = "ERROR: Path not found. Source:" . $a_source_node .
850 ", Target:" . $a_target_node;
851 if (DEVMODE == 1) {
852 include_once("./Services/UICore/exceptions/class.ilCtrlException.php");
853 throw new ilCtrlException($failure);
854 }
855 $GLOBALS['ilLog']->write(__METHOD__ . ' ' . $failure);
856 $this->redirectToURL('./ilias.php?baseClass=ilRepositoryGUI');
857 }
858 $temp_node = $a_source_node;
859
860 $path = array();
861 if ($a_source_node != "") {
862 $path = array($a_source_node);
863 }
864
865 $diffstart = ($a_source_node == "")
866 ? 0
867 : strlen($a_source_node) + 1;
868 $diff = substr($a_target_node, $diffstart);
869 $diff_arr = explode(":", $diff);
870 foreach ($diff_arr as $cid) {
871 if ($temp_node != "") {
872 $temp_node .= ":";
873 }
874 $temp_node .= $cid;
875 $path[] = $temp_node;
876 }
877 return $path;
878 }
879
885 public function setTargetScript(string $a_target_script)
886 {
887 $this->target_script = $a_target_script;
888 }
889
895 protected function getReadableNode($node)
896 {
897 return implode(
898 ":",
899 array_map(function ($cid) {
900 return $this->getClassForCid($cid);
901 }, explode(":", $node))
902 );
903 }
904
910 public function getTargetScript() : string
911 {
913 }
914
915
924 public function initBaseClass($a_base_class)
925 {
926 $_GET["baseClass"] = $a_base_class;
927 $_GET["cmd"] = "";
928 $_GET["cmdClass"] = "";
929 $_GET["cmdNode"] = "";
931 }
932
940 public function getCmd($a_default_cmd = "", $a_safe_commands = "")
941 {
942 $cmd = "";
943 if (isset($_GET["cmd"])) {
944 $cmd = $_GET["cmd"];
945 }
946 if ($cmd == "post") {
947 if (isset($_POST["cmd"]) && is_array($_POST["cmd"])) {
948 reset($_POST["cmd"]);
949 }
950 $cmd = @key($_POST["cmd"]);
951
952 // verify command
953 if ($this->verified_cmd != "") {
954 return $this->verified_cmd;
955 } else {
956 if (!$this->verifyToken() &&
957 (!is_array($a_safe_commands) || !in_array($cmd, $a_safe_commands))) {
958 return $a_default_cmd;
959 }
960 }
961
962 $this->verified_cmd = $cmd;
963 if ($cmd == "" && isset($_POST["table_top_cmd"])) { // selected command in multi-list (table2)
964 $cmd = @key($_POST["table_top_cmd"]);
965 $this->verified_cmd = $cmd;
966 $_POST[$_POST["cmd_sv"][$cmd]] = $_POST[$_POST["cmd_sv"][$cmd] . "_2"];
967 }
968 if ($cmd == "" && isset($_POST["select_cmd2"])) { // selected command in multi-list (table2)
969 if (isset($_POST["select_cmd_all2"])) {
970 $_POST["select_cmd_all"] = $_POST["select_cmd_all2"];
971 } else {
972 $_POST["select_cmd_all"] = $_POST["select_cmd_all2"] = null;
973 }
974 $cmd = $_POST["selected_cmd2"];
975 $this->verified_cmd = $cmd;
976 }
977 if ($cmd == "" && isset($_POST["select_cmd"])) { // selected command in multi-list (table2)
978 if (isset($_POST["select_cmd_all"])) {
979 $_POST["select_cmd_all2"] = $_POST["select_cmd_all"];
980 } else {
981 $_POST["select_cmd_all"] = $_POST["select_cmd_all2"] = null;
982 }
983 $cmd = $_POST["selected_cmd"];
984 $this->verified_cmd = $cmd;
985 }
986 if ($cmd == "") {
987 $cmd = $_GET["fallbackCmd"];
988 $this->verified_cmd = $cmd;
989 }
990 }
991 if ($cmd == "") {
992 $cmd = $a_default_cmd;
993 }
994 return $cmd;
995 }
996
1007 public function setCmd($a_cmd)
1008 {
1009 $_GET["cmd"] = $a_cmd;
1010 }
1011
1022 public function setCmdClass($a_cmd_class)
1023 {
1024 $a_cmd_class = strtolower($a_cmd_class);
1025 $nr = $this->getNodeIdForTargetClass($this->current_node, $a_cmd_class);
1026 $nr = $nr["node_id"];
1027 $_GET["cmdClass"] = $a_cmd_class;
1028 $_GET["cmdNode"] = $nr;
1029 }
1030
1036 public function getCmdClass()
1037 {
1038 return strtolower($_GET["cmdClass"]);
1039 }
1040
1051 public function getFormAction(
1052 $a_gui_obj,
1053 $a_fallback_cmd = "",
1054 $a_anchor = "",
1055 $a_asynch = false,
1056 $xml_style = false
1057 ) {
1058 $script = $this->getFormActionByClass(
1059 strtolower(get_class($a_gui_obj)),
1060 $a_fallback_cmd,
1061 $a_anchor,
1062 $a_asynch,
1063 $xml_style
1064 );
1065 return $script;
1066 }
1067
1078 public function getFormActionByClass(
1079 $a_class,
1080 $a_fallback_cmd = "",
1081 $a_anchor = "",
1082 $a_asynch = false,
1083 $xml_style = false
1084 ) {
1085 if (!is_array($a_class)) {
1086 $a_class = strtolower($a_class);
1087 }
1088
1089 $tok = $this->getRequestToken();
1090
1091 if ($a_asynch) {
1092 $xml_style = false;
1093 }
1094
1095 $script = $this->getLinkTargetByClass($a_class, "post", "", $a_asynch, $xml_style);
1096 if ($a_fallback_cmd != "") {
1097 $script = ilUtil::appendUrlParameterString($script, "fallbackCmd=" . $a_fallback_cmd, $xml_style);
1098 }
1100 $script,
1101 self::IL_RTOKEN_NAME . '=' . $this->getRequestToken(),
1102 $xml_style
1103 );
1104 if ($a_anchor != "") {
1105 $script = $script . "#" . $a_anchor;
1106 }
1107
1108 return $script;
1109 }
1110
1117 public function appendRequestTokenParameterString($a_url, $xml_style = false)
1118 {
1120 $a_url,
1121 self::IL_RTOKEN_NAME . '=' . $this->getRequestToken(),
1122 $xml_style
1123 );
1124 }
1125
1131 public function getRequestToken()
1132 {
1133 global $DIC;
1134
1135 $ilUser = $DIC["ilUser"];
1136 $ilDB = $DIC->database();
1137
1138
1139 if ($this->rtoken != "") {
1140 return $this->rtoken;
1141 } else {
1142 if (is_object($ilDB) && is_object($ilUser) && $ilUser->getId() > 0 &&
1143 $ilUser->getId() != ANONYMOUS_USER_ID) {
1144 $res = $ilDB->query("SELECT token FROM il_request_token WHERE user_id = " .
1145 $ilDB->quote($ilUser->getId(), "integer") .
1146 " AND session_id = " . $ilDB->quote(session_id(), "text"));
1147 $rec = $ilDB->fetchAssoc($res);
1148 if ($rec["token"] != "") {
1149 $this->rtoken = $rec["token"];
1150 return $rec["token"];
1151 }
1152 //echo "new rtoken, new entry for :".$ilUser->getId().":".session_id().":"; exit;
1153 $random = new \ilRandom();
1154 $this->rtoken = md5(uniqid($random->int(), true));
1155
1156 // delete entries older than one and a half days
1157 if ($random->int(1, 200) == 2) {
1158 $dt = new ilDateTime(time(), IL_CAL_UNIX);
1159 $dt->increment(IL_CAL_DAY, -1);
1160 $dt->increment(IL_CAL_HOUR, -12);
1161 $dq = "DELETE FROM il_request_token WHERE " .
1162 " stamp < " . $ilDB->quote($dt->get(IL_CAL_DATETIME), "timestamp");
1163 $ilDB->manipulate($dq);
1164 }
1165
1166 // IMPORTANT: Please do NOT try to move this implementation to a
1167 // session basis. This will fail due to framesets that are used
1168 // occasionally in ILIAS, e.g. in the chat, where multiple
1169 // forms are loaded in different frames.
1170 $ilDB->manipulate("INSERT INTO il_request_token (user_id, token, stamp, session_id) VALUES " .
1171 "(" .
1172 $ilDB->quote($ilUser->getId(), "integer") . "," .
1173 $ilDB->quote($this->rtoken, "text") . "," .
1174 $ilDB->now() . "," .
1175 $ilDB->quote(session_id(), "text") . ")");
1176 return $this->rtoken;
1177 }
1178 }
1179 return "";
1180 }
1181
1187 private function verifyToken()
1188 {
1189 global $DIC;
1190
1191 $ilUser = $DIC["ilUser"];
1192
1193 $ilDB = $DIC->database();
1194 ;
1195
1196 if (is_object($ilUser) && is_object($ilDB) && $ilUser->getId() > 0 &&
1197 $ilUser->getId() != ANONYMOUS_USER_ID) {
1198 if ($_GET["rtoken"] == "") {
1199 return false;
1200 }
1201
1202 $set = $ilDB->query("SELECT * FROM il_request_token WHERE " .
1203 " user_id = " . $ilDB->quote($ilUser->getId(), "integer") . " AND " .
1204 " token = " . $ilDB->quote($_GET[self::IL_RTOKEN_NAME]), "text");
1205 if ($ilDB->numRows($set) > 0) {
1206 // remove tokens from older sessions
1207 // if we do this immediately, working with multiple windows does not work:
1208 // - window one: open form (with token a)
1209 // - window two: open form (with token b)
1210 // - submit window one: a is verified, but b must not be deleted immediately, otherwise
1211 // - window two: submit results in invalid token
1212 // see also bug #13551
1213 $dt = new ilDateTime(time(), IL_CAL_UNIX);
1214 $dt->increment(IL_CAL_DAY, -1);
1215 $dt->increment(IL_CAL_HOUR, -12);
1216 $ilDB->manipulate("DELETE FROM il_request_token WHERE " .
1217 " user_id = " . $ilDB->quote($ilUser->getId(), "integer") . " AND " .
1218 " session_id != " . $ilDB->quote(session_id(), "text") . " AND " .
1219 " stamp < " . $ilDB->quote($dt->get(IL_CAL_DATETIME), "timestamp"));
1220 return true;
1221 } else {
1222 return false;
1223 }
1224
1225 if ($_SESSION["rtokens"][$_GET[self::IL_RTOKEN_NAME]] != "") {
1226 // remove used token
1227 unset($_SESSION["rtokens"][$_GET[self::IL_RTOKEN_NAME]]);
1228
1229 // remove old tokens
1230 if (count($_SESSION["rtokens"]) > 100) {
1231 $to_remove = array();
1232 $sec = 7200; // two hours
1233
1234 foreach ($_SESSION["rtokens"] as $tok => $time) {
1235 if (time() - $time > $sec) {
1236 $to_remove[] = $tok;
1237 }
1238 }
1239 foreach ($to_remove as $tok) {
1240 unset($_SESSION["rtokens"][$tok]);
1241 }
1242 }
1243
1244 return true;
1245 }
1246 return false;
1247 } else {
1248 return true; // do not verify, if user or db object is missing
1249 }
1250
1251 return false;
1252 }
1253
1261 public function redirect($a_gui_obj, $a_cmd = "", $a_anchor = "", $a_asynch = false)
1262 {
1263 $script = $this->getLinkTargetByClass(
1264 strtolower(get_class($a_gui_obj)),
1265 $a_cmd,
1266 "",
1267 $a_asynch,
1268 false
1269 );
1270 if ($a_anchor != "") {
1271 $script = $script . "#" . $a_anchor;
1272 }
1273 $this->redirectToURL($script);
1274 }
1275
1276
1280 public function redirectToURL($a_script)
1281 {
1282 global $DIC;
1283
1284 $ilPluginAdmin = null;
1285 if (isset($DIC["ilPluginAdmin"])) {
1286 $ilPluginAdmin = $DIC["ilPluginAdmin"];
1287 }
1288
1289 if (!is_int(strpos($a_script, "://"))) {
1290 if (substr($a_script, 0, 1) != "/" && defined("ILIAS_HTTP_PATH")) {
1291 if (is_int(strpos($_SERVER["PHP_SELF"], "/setup/"))) {
1292 $a_script = "setup/" . $a_script;
1293 }
1294 $a_script = ILIAS_HTTP_PATH . "/" . $a_script;
1295 }
1296 }
1297
1298 // include the user interface hook
1299 if (is_object($ilPluginAdmin)) {
1300 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "UIComponent", "uihk");
1301 foreach ($pl_names as $pl) {
1302 $ui_plugin = ilPluginAdmin::getPluginObject(IL_COMP_SERVICE, "UIComponent", "uihk", $pl);
1303 $gui_class = $ui_plugin->getUIClassInstance();
1304 $resp = $gui_class->getHTML("Services/Utilities", "redirect", array( "html" => $a_script ));
1305 if ($resp["mode"] != ilUIHookPluginGUI::KEEP) {
1306 $a_script = $gui_class->modifyHTML($a_script, $resp);
1307 }
1308 }
1309 }
1310
1311 // Manually trigger to write and close the session. This has the advantage that if an exception is thrown
1312 // during the writing of the session (ILIAS writes the session into the database by default) we get an exception
1313 // if the session_write_close() is triggered by exit() then the exception will be dismissed but the session
1314 // is never written, which is a nightmare to develop with.
1315 session_write_close();
1316
1317 global $DIC;
1318 $http = $DIC->http();
1319 switch ($http->request()->getHeaderLine('Accept')) {
1320 case 'application/json':
1321 $stream = \ILIAS\Filesystem\Stream\Streams::ofString(json_encode([
1322 'success' => true,
1323 'message' => 'Called redirect after async fileupload request',
1324 "redirect_url" => $a_script,
1325 ]));
1326 $http->saveResponse($http->response()->withBody($stream));
1327 break;
1328 default:
1329 $http->saveResponse($http->response()->withAddedHeader("Location", $a_script));
1330 break;
1331 }
1332 $http->sendResponse();
1333 exit;
1334 }
1335
1336
1343 public function redirectByClass($a_class, $a_cmd = "", $a_anchor = "", $a_asynch = false)
1344 {
1345 $script = $this->getLinkTargetByClass($a_class, $a_cmd, "", $a_asynch, false);
1346 if ($a_anchor != "") {
1347 $script = $script . "#" . $a_anchor;
1348 }
1349 $this->redirectToURL($script);
1350 }
1351
1357 public function isAsynch()
1358 {
1359 if (isset($_GET["cmdMode"]) && $_GET["cmdMode"] == "asynch") {
1360 return true;
1361 } else {
1362 return false;
1363 }
1364 }
1365
1366
1378 public function getLinkTarget(
1379 $a_gui_obj,
1380 $a_cmd = "",
1381 $a_anchor = "",
1382 $a_asynch = false,
1383 $xml_style = false
1384 ) {
1385 $script = $this->getLinkTargetByClass(
1386 strtolower(get_class($a_gui_obj)),
1387 $a_cmd,
1388 $a_anchor,
1389 $a_asynch,
1390 $xml_style
1391 );
1392 return $script;
1393 }
1394
1395
1407 public function getLinkTargetByClass(
1408 $a_class,
1409 $a_cmd = "",
1410 $a_anchor = "",
1411 $a_asynch = false,
1412 $xml_style = false
1413 ) {
1414 if ($a_asynch) {
1415 $xml_style = false;
1416 }
1417
1418 $script = $this->getTargetScript();
1419 $script = $this->getUrlParameters($a_class, $script, $a_cmd, $xml_style);
1420
1421 if ($a_asynch) {
1422 $amp = "&";
1423 $script .= $amp . "cmdMode=asynch";
1424 }
1425
1426 if ($a_anchor != "") {
1427 $script = $script . "#" . $a_anchor;
1428 }
1429
1430 return $script;
1431 }
1432
1436 public function setReturn($a_gui_obj, $a_cmd)
1437 {
1438 $script = $this->getTargetScript();
1439 $script = $this->getUrlParameters(strtolower(get_class($a_gui_obj)), $script, $a_cmd);
1440 $this->return[strtolower(get_class($a_gui_obj))] = $script;
1441 }
1442
1446 public function setReturnByClass($a_class, $a_cmd)
1447 {
1448 // may not be an array!
1449 $a_class = strtolower($a_class);
1450
1451 $script = $this->getTargetScript();
1452 $script = $this->getUrlParameters($a_class, $script, $a_cmd);
1453 $this->return[strtolower($a_class)] = $script;
1454 }
1455
1459 public function returnToParent($a_gui_obj, $a_anchor = "")
1460 {
1461 $script = $this->getParentReturn($a_gui_obj);
1462
1464 $script,
1465 "redirectSource=" . strtolower(get_class($a_gui_obj))
1466 );
1468 $script,
1469 "cmdMode=" . $_GET["cmdMode"]
1470 );
1471 if ($a_anchor != "") {
1472 $script = $script . "#" . $a_anchor;
1473 }
1474
1475 $this->redirectToURL($script);
1476 }
1477
1478
1484 public function getParentReturn($a_gui_obj)
1485 {
1486 return $this->getParentReturnByClass(strtolower(get_class($a_gui_obj)));
1487 }
1488
1489
1495 public function getParentReturnByClass($a_class)
1496 {
1497 $a_class = strtolower($a_class);
1498 $ret_class = $this->searchReturnClass($a_class);
1499 if ($ret_class) {
1500 return $this->return[$ret_class];
1501 }
1502 }
1503
1512 public function getReturnClass($a_class)
1513 {
1514 if (is_object($a_class)) {
1515 $class = strtolower(get_class($a_class));
1516 } else {
1517 $class = strtolower($a_class);
1518 }
1519 return $this->searchReturnClass($class);
1520 }
1521
1522
1526 private function searchReturnClass($a_class)
1527 {
1528 $a_class = strtolower($a_class);
1529
1530 $node = $this->getNodeIdForTargetClass($this->current_node, $a_class);
1531 $node = $node["node_id"];
1532 $n_arr = explode(":", $node);
1533 for ($i = count($n_arr) - 2; $i >= 0; $i--) {
1534 if ($this->return[$this->getClassForCid($n_arr[$i])] != "") {
1535 return $this->getClassForCid($n_arr[$i]);
1536 }
1537 }
1538
1539 return false;
1540 }
1541
1547 public function getRedirectSource()
1548 {
1549 return $_GET["redirectSource"];
1550 }
1551
1560 public function getUrlParameters($a_class, $a_str, $a_cmd = "", $xml_style = false)
1561 {
1562 $params = $this->getParameterArrayByClass($a_class, $a_cmd);
1563
1564 foreach ($params as $par => $value) {
1565 if (strlen((string) $value)) {
1566 $a_str = ilUtil::appendUrlParameterString($a_str, $par . "=" . $value, $xml_style);
1567 }
1568 }
1569
1570 return $a_str;
1571 }
1572
1576 public function getParameterArray($a_gui_obj, $a_cmd = "")
1577 {
1578 $par_arr = $this->getParameterArrayByClass(strtolower(get_class($a_gui_obj)), $a_cmd);
1579
1580 return $par_arr;
1581 }
1582
1590 public function getParameterArrayByClass($a_class, $a_cmd = "")
1591 {
1592 if ($a_class == "") {
1593 return array();
1594 }
1595
1596 $current_base_class = $_GET["baseClass"];
1597 if ($this->use_current_to_determine_next && $this->inner_base_class != "") {
1598 $current_base_class = $this->inner_base_class;
1599 }
1600
1601 if (!is_array($a_class)) {
1602 $a_class = array($a_class);
1603 }
1604
1605 $nr = $this->current_node;
1606 $new_baseclass = "";
1607 foreach ($a_class as $class) {
1608 $class = strtolower($class);
1609 $nr = $this->getNodeIdForTargetClass($nr, $class);
1610 if ($nr["base_class"] != "") {
1611 $new_baseclass = $nr["base_class"];
1612 }
1613 $nr = $nr["node_id"];
1614 $target_class = $class;
1615 }
1616
1617 $path = $this->getPathNew(1, $nr);
1618 $params = array();
1619
1620 // append parameters of parent classes
1621 foreach ($path as $node_id) {
1622 $class = ($node_id == "")
1623 ? strtolower($current_base_class)
1624 : $this->getClassForCid($this->getCurrentCidOfNode($node_id));
1625 if (isset($this->save_parameter[$class]) && is_array($this->save_parameter[$class])) {
1626 foreach ($this->save_parameter[$class] as $par) {
1627 if (isset($_GET[$par])) {
1628 $params[$par] = $_GET[$par];
1629 } elseif (isset($_POST[$par])) {
1630 $params[$par] = ilUtil::stripSlashesRecursive($_POST[$par]);
1631 }
1632 }
1633 }
1634
1635 if (isset($this->parameter[$class]) && is_array($this->parameter[$class])) {
1636 foreach ($this->parameter[$class] as $par => $value) {
1637 $params[$par] = $value;
1638 }
1639 }
1640 }
1641
1642 if ($a_cmd != "") {
1643 $params["cmd"] = $a_cmd;
1644 }
1645
1646 $params["cmdClass"] = $target_class;
1647 $params["cmdNode"] = $nr;
1648 if ($new_baseclass == "") {
1649 $params["baseClass"] = $current_base_class;
1650 } else {
1651 $params["baseClass"] = $new_baseclass;
1652 }
1653
1654 return $params;
1655 }
1656
1657 private function classCidUnknown($a_class)
1658 {
1659 return $this->class_cid[$a_class] == "";
1660 }
1661
1665 private function getCidForClass($a_class, $a_check = false)
1666 {
1667 if ($this->classCidUnknown($a_class)) {
1668 $this->readClassInfo($a_class);
1669 }
1670 if ($this->classCidUnknown($a_class)) {
1671 if ($a_check) {
1672 return false;
1673 }
1674 if (DEVMODE == 1) {
1675 $add = "<br><br>Please make sure your GUI class name ends with 'GUI' and that the filename is 'class.[YourClassName].php'. In exceptional cases you
1676 may solve the issue by putting an empty * @ilCtrl_Calls [YourClassName]: into your class header." .
1677 " In both cases you need to reload the control structure in the setup.";
1678 }
1679 include_once("./Services/UICore/exceptions/class.ilCtrlException.php");
1680 throw new ilCtrlException("Cannot find cid for class " . $a_class . "." . $add);
1681 }
1682 return $this->class_cid[$a_class];
1683 }
1684
1685 private function cidClassUnknown($a_cid)
1686 {
1687 return $this->cid_class[$a_cid] == "";
1688 }
1689
1690
1694 private function getClassForCid($a_cid)
1695 {
1696 if ($this->cidClassUnknown($a_cid)) {
1697 $this->readCidInfo($a_cid);
1698 }
1699 if ($this->cidClassUnknown($a_cid)) {
1700 include_once("./Services/UICore/exceptions/class.ilCtrlException.php");
1701 throw new ilCtrlException("Cannot find class for cid " . $a_cid . ".");
1702 }
1703 return $this->cid_class[$a_cid];
1704 }
1705
1706 private function fetchCallsOfClassFromCache($a_class, ilCachedCtrl $a_cached_ctrl)
1707 {
1708 foreach ($a_cached_ctrl->lookupCall($a_class) as $call) {
1709 if ($call["child"] != "" && $this->callOfClassNotKnown($a_class, $call['child'])) {
1710 $this->calls[$a_class][] = $call["child"];
1711 }
1712 }
1713 }
1714
1721 private function readCidInfo($a_cid)
1722 {
1723 if (isset($this->info_read_cid[$a_cid])) {
1724 return;
1725 }
1726
1727 $cached_ctrl = ilCachedCtrl::getInstance();
1728 $cid_info = $cached_ctrl->lookupCid($a_cid);
1729
1730 if ($cid_info) {
1731 $this->updateClassCidMap($cid_info['class'], $a_cid);
1732 $this->fetchCallsOfClassFromCache($cid_info['class'], $cached_ctrl);
1733 $this->info_read_class[$cid_info["class"]] = true;
1734 }
1735
1736 $this->info_read_cid[$a_cid] = true;
1737 }
1738
1745 private function readNodeInfo($a_node)
1746 {
1747 $class_ids = explode(":", $a_node);
1748 foreach ($class_ids as $cid) {
1749 $this->readCidInfo($cid);
1750 }
1751 }
1752
1759 private function readClassInfo($a_class)
1760 {
1761 $a_class = strtolower($a_class);
1762 if (isset($this->info_read_class[$a_class])) {
1763 return;
1764 }
1765
1766 $cached_ctrl = ilCachedCtrl::getInstance();
1767 $class_info = $cached_ctrl->lookupClassFile($a_class);
1768
1769 if ($class_info) {
1770 $this->updateClassCidMap($a_class, $class_info['cid']);
1771 }
1772 $this->fetchCallsOfClassFromCache($a_class, $cached_ctrl);
1773
1774 $this->info_read_class[$a_class] = true;
1775 $this->info_read_cid[$this->class_cid[$a_class]] = true;
1776 }
1777
1778 private function callOfClassNotKnown($a_class, $a_child)
1779 {
1780 return !isset($this->calls[$a_class])
1781 || !is_array($this->calls[$a_class])
1782 || !in_array($a_child, $this->calls[$a_class]);
1783 }
1784
1785 private function updateClassCidMap($a_class, $a_cid)
1786 {
1787 $this->cid_class[$a_cid] = $a_class;
1788 $this->class_cid[$a_class] = $a_cid;
1789 }
1790
1794 private function getParentCidOfNode($a_node)
1795 {
1796 $class_ids = explode(":", $a_node);
1797 return $class_ids[count($class_ids) - 2];
1798 }
1799
1803 private function getCidOfNode($a_node)
1804 {
1805 $class_ids = explode(":", $a_node);
1806 return $class_ids[count($class_ids) - 1];
1807 }
1808
1812 private function removeLastCid($a_node)
1813 {
1814 $lpos = strrpos($a_node, ":");
1815 return substr($a_node, 0, $lpos);
1816 }
1817
1821 private function getCurrentCidOfNode($a_node)
1822 {
1823 $n_arr = explode(":", $a_node);
1824 return $n_arr[count($n_arr) - 1];
1825 }
1826
1833 public function insertCtrlCalls($a_parent, $a_child, $a_comp_prefix)
1834 {
1835 global $DIC;
1836
1837 $ilDB = $DIC->database();
1838 ;
1839
1840 $a_parent = strtolower($a_parent);
1841 $a_child = strtolower($a_child);
1842 $a_comp_prefix = strtolower($a_comp_prefix);
1843
1844 $set = $ilDB->query(
1845 "SELECT * FROM ctrl_calls WHERE " .
1846 " parent = " . $ilDB->quote($a_parent, "text") . " AND " .
1847 " child = " . $ilDB->quote($a_child, "text") . " AND " .
1848 " comp_prefix = " . $ilDB->quote($a_comp_prefix, "text")
1849 );
1850 if ($rec = $ilDB->fetchAssoc($set)) {
1851 return;
1852 }
1853 $ilDB->manipulate("INSERT IGNORE INTO ctrl_calls " .
1854 "(parent, child, comp_prefix) VALUES (" .
1855 $ilDB->quote($a_parent, "text") . "," .
1856 $ilDB->quote($a_child, "text") . "," .
1857 $ilDB->quote($a_comp_prefix, "text") .
1858 ")");
1859 }
1860
1868 public function checkCurrentPathForClass($gui_class)
1869 {
1870 foreach (explode(":", $this->getCmdNode()) as $cid) {
1871 if ($cid != "" && strtolower($this->getClassForCid($cid)) == strtolower($gui_class)) {
1872 return true;
1873 }
1874 }
1875 return false;
1876 }
1877
1884 public function getCurrentClassPath() : array
1885 {
1886 $path = [];
1887 foreach (explode(":", $this->getCmdNode()) as $cid) {
1888 if ($cid != "") {
1889 $path[] = $this->getClassForCid($cid);
1890 }
1891 }
1892 if ($this->getCmdNode() == "" && $_GET["baseClass"] != "") {
1893 $path[] = $_GET["baseClass"];
1894 }
1895 return $path;
1896 }
1897}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
$failure
$_GET["client_id"]
$_POST["username"]
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
static ofString($string)
Creates a new stream with an initial value.
Definition: Streams.php:25
const IL_COMP_SERVICE
const IL_CAL_UNIX
const IL_CAL_DATETIME
const IL_CAL_HOUR
const IL_CAL_DAY
Class ilCachedCtrl.
static getComponentInfo($a_type, $a_name)
ilCtrl exceptions
This class provides processing control methods.
initializeMemberVariables()
Initialize member variables.
getCurrentClassPath()
Get current class path as array of class file names.
getCidForClass($a_class, $a_check=false)
Get class id for class after fetching and storing corresponding information, if necessary.
cidClassUnknown($a_cid)
checkLPSettingsForward($a_gui_obj, $a_cmd_node)
getFormAction( $a_gui_obj, $a_fallback_cmd="", $a_anchor="", $a_asynch=false, $xml_style=false)
Get form action url for gui class object.
getCallHistory()
Get controller call history.
setCmdClass($a_cmd_class)
Set the current command class.
clearParameterByClass($a_class, $a_parameter)
Same as setParameterByClass, except that a class name is passed.
getCmd($a_default_cmd="", $a_safe_commands="")
Determines current get/post command.
getParentReturnByClass($a_class)
Get return script url.
getContextSubObjId()
Get context subobject id.
getContextObjId()
Get context object id.
getCmdNode()
Get command target node.
readCallStructure($a_class, $a_nr=0, $a_parent=0)
Reads call structure from db.
getParentCidOfNode($a_node)
Get 2nd to last class id of node.
readCidInfo($a_cid)
Save class respective to $a_cid and store corresponding class calls for future reference.
getParentReturn($a_gui_obj)
Get return script url.
getCidOfNode($a_node)
Get last class id of node.
getTargetScript()
Get target script name.
getModuleDir()
get directory of current module
getHTML($a_gui_object, array $a_parameters=null, array $class_path=[])
Gets an HTML output from another GUI class and returns the flow of control to the calling class.
verifyToken()
Verify Token.
addTab($a_lang_var, $a_link, $a_cmd, $a_class)
Add a tab to tabs array (.
removeLastCid($a_node)
Remove the class id that comes at the beginning the sequence.
setReturn($a_gui_obj, $a_cmd)
Set return command.
$calls
Stores which class calls which other class.
__construct()
control class constructor
getPathNew($a_source_node, $a_target_node)
Get path in call structure.
getNodeIdForTargetClass($a_par_node, $a_class, $a_check=false)
Searches a node for a given class ($a_class) "near" another node ($a_par_node).
checkCurrentPathForClass($gui_class)
Check if current path contains a certain gui class.
getCmdClass()
Determines class that should execute the current command.
appendRequestTokenParameterString($a_url, $xml_style=false)
Append request token as url parameter.
getNextClass($a_gui_class=null)
Get next class in the control path from the current class to the target command class.
getCallStructure($a_class)
Get call structure of class context.
getRequestToken()
Get request token.
getRedirectSource()
Get current redirect source.
searchReturnClass($a_class)
Determine current return class.
getClassForClasspath($a_class_path)
this method assumes that the class path has the format "dir/class.<class_name>.php"
readNodeInfo($a_node)
Save classes respective to the class id's of a node and store corresponding class calls for future re...
returnToParent($a_gui_obj, $a_anchor="")
Redirects to next parent class that used setReturn.
setContext($a_obj_id, $a_obj_type, $a_sub_obj_id=0, $a_sub_obj_type="")
Set context of current user interface.
getTabs()
Get tabs array (.
redirectToURL($a_script)
setReturnByClass($a_class, $a_cmd)
Set return command.
setTargetScript(string $a_target_script)
set target script name
const IL_RTOKEN_NAME
readClassInfo($a_class)
Save class id respective to $a_class and store corresponding class calls for future reference.
getReturnClass($a_class)
Get return class.
getContextObjType()
Get context object type.
getCurrentCidOfNode($a_node)
Get cid of node.
callBaseClass()
Calls base class of current request.
classCidUnknown($a_class)
getLinkTargetByClass( $a_class, $a_cmd="", $a_anchor="", $a_asynch=false, $xml_style=false)
Get link target for command using gui class name.
fetchCallsOfClassFromCache($a_class, ilCachedCtrl $a_cached_ctrl)
getUrlParameters($a_class, $a_str, $a_cmd="", $xml_style=false)
Get URL parameters for a class and append them to a string.
getParameterArrayByClass($a_class, $a_cmd="")
Get all set/save parameters using gui class name.
saveParameter($a_obj, $a_parameter)
Set parameters that should be passed in every form and link of a gui class.
getContextSubObjType()
Get context subobject type.
$call_hist
Stores the order in which different GUI classes were called.
isAsynch()
Is current command an asynchronous command?
setParameterByClass($a_class, $a_parameter, $a_value)
Same as setParameterByClass, except that a class name is passed.
clearParametersByClass($a_class)
Clears all parameters that have been set via setParameter for a GUI class.
insertCtrlCalls($a_parent, $a_child, $a_comp_prefix)
Insert ctrl calls record.
redirectByClass($a_class, $a_cmd="", $a_anchor="", $a_asynch=false)
Redirect to other gui class using class name.
lookupClassPath($a_class_name)
Get class path that can be used in include statements for a given class name.
saveParameterByClass($a_class, $a_parameter)
Save parameter for a class.
getFormActionByClass( $a_class, $a_fallback_cmd="", $a_anchor="", $a_asynch=false, $xml_style=false)
Get form action url for gui class name.
updateClassCidMap($a_class, $a_cid)
redirect($a_gui_obj, $a_cmd="", $a_anchor="", $a_asynch=false)
Redirect to another command.
getClassForCid($a_cid)
Get class for class id after fetching and storing corresponding information, if necessary.
forwardCommand($a_gui_object)
Forward flow of control to next gui class this invokes the executeCommand() method of the gui object ...
getLinkTarget( $a_gui_obj, $a_cmd="", $a_anchor="", $a_asynch=false, $xml_style=false)
Get link target for command using gui object.
setCmd($a_cmd)
Set the current command.
clearParameters($a_obj)
Clears all parameters that have been set via setParameter for a GUI class.
callOfClassNotKnown($a_class, $a_child)
checkTargetClass($a_class)
Check whether target is valid.
getReadableNode($node)
Get readable node.
setParameter($a_obj, $a_parameter, $a_value)
Set parameters that should be passed a form and link of a gui class.
initBaseClass($a_base_class)
Initialises new base class.
$use_current_to_determine_next
getParameterArray($a_gui_obj, $a_cmd="")
Get all set/save parameters for a gui object.
@classDescription Date and time handling
static _lookupSubType($a_obj_id)
lookup subtype id (scorm, )
static isSupportedObjectType($type)
static _lookupObjectId($a_ref_id)
lookup object id
static _lookupType($a_id, $a_reference=false)
lookup object type
static getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get Plugin Object.
static appendUrlParameterString($a_url, $a_par, $xml_style=false)
append URL parameter string ("par1=value1&par2=value2...") to given URL string
static stripSlashesRecursive($a_data, $a_strip_html=true, $a_allow="")
Strip slashes from array and sub-arrays.
const ANONYMOUS_USER_ID
Definition: constants.php:25
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18
exit
Definition: login.php:29
$i
Definition: metadata.php:24
$type
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
$http
Definition: raiseError.php:7
$service
Definition: result.php:17
foreach($_POST as $key=> $value) $res
global $ilDB