ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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');
11class ilCtrl
12{
13 const IL_RTOKEN_NAME = 'rtoken';
14
16 var $forward; // forward array
17 var $parent; // parent array (reverse forward)
18 var $save_parameter; // save parameter array
19 var $return; // return commmands
20 var $call_hist = array(); // calling history
21 var $debug = array();
22 var $calls = array();
23 var $rtoken = false;
24
28 function ilCtrl()
29 {
30 global $ilBench;
31
32 $this->bench =& $ilBench;
33
34 // initialisation
35 $this->init();
36
37 // this information should go to xml files one day
38 $this->stored_trees = array
39 ("ilrepositorygui", "ilpersonaldesktopgui",
40 "illmpresentationgui", "illmeditorgui",
41 "iladministrationgui");
42 }
43
49 function debug($str)
50 {
51 $this->debug[] = $str;
52 }
53
59 function getDebug()
60 {
61 return $this->debug;
62 }
63
67 function init()
68 {
69 $this->transit = array();
70 $this->forward = array(); // forward array
71 $this->forwards = array(); // forward array
72 $this->parent = array(); // parent array (reverse forward)
73 $this->save_parameter = array(); // save parameter array
74 $this->parameter = array(); // save parameter array
75 $this->return = ""; // return commmands
76 $this->location = array();
77 $this->tab = array();
78 $this->current_node = 0;
79 $this->module_dir = "";
80 $this->service_dir = "";
81 $this->call_node = array();
82 $this->root_class = "";
83 }
84
91 function callBaseClass()
92 {
93 global $ilDB;
94
95 $baseClass = strtolower($_GET["baseClass"]);
96
97 $module_class = ilCachedCtrl::getInstance();
98 $mc_rec = $module_class->lookupModuleClass($baseClass);
99 // get class information
100// $mc_set = $ilDB->query("SELECT * FROM module_class WHERE LOWER(class) = ".
101// $ilDB->quote($baseClass, "text"));
102// $mc_rec = $ilDB->fetchAssoc($mc_set);
103
104 $module = $mc_rec["module"];
105 $class = $mc_rec["class"];
106 $class_dir = $mc_rec["dir"];
107
108 if ($module != "")
109 {
110 $m_set = $ilDB->query("SELECT * FROM il_component WHERE name = ".
111 $ilDB->quote($module, "text"));
112 $m_rec = $ilDB->fetchAssoc($m_set);
113 $this->module_dir = $m_rec["type"]."/".$m_rec["name"];
114 include_once $this->module_dir."/".$class_dir."/class.".$class.".php";
115 }
116 else // check whether class belongs to a service
117 {
118// $mc_set = $ilDB->query("SELECT * FROM service_class WHERE LOWER(class) = ".
119// $ilDB->quote($baseClass, "text"));
120// $mc_rec = $ilDB->fetchAssoc($mc_set);
121
122 $mc_rec = $module_class->lookupServiceClass($baseClass);
123
124 $service = $mc_rec["service"];
125 $class = $mc_rec["class"];
126 $class_dir = $mc_rec["dir"];
127
128 if ($service == "")
129 {
130 include_once("./Services/UICore/exceptions/class.ilCtrlException.php");
131 throw new ilCtrlException("Could not find entry in modules.xml or services.xml for ".
132 $baseClass." <br/>".str_replace("&", "<br />&", htmlentities($_SERVER["REQUEST_URI"])));
133 }
134
135 // get service information
136// $m_set = $ilDB->query("SELECT * FROM il_component WHERE name = ".
137// $ilDB->quote($service, "text"));
138// $m_rec = $ilDB->fetchAssoc($m_set);
139
140 $m_rec = ilComponent::getComponentInfo('Services', $service);
141
142 $this->service_dir = $m_rec["type"]."/".$m_rec["name"];
143
144 include_once $this->service_dir."/".$class_dir."/class.".$class.".php";;
145 }
146
147 // forward processing to base class
148 $this->getCallStructure(strtolower($baseClass));
149 $base_class_gui =& new $class();
150 $this->forwardCommand($base_class_gui);
151 }
152
156 function getModuleDir()
157 {
158 return $this->module_dir;
159 }
160
170 function &forwardCommand(&$a_gui_object)
171 {
172 $class = strtolower(get_class($a_gui_object));
173//echo "<br>class:".$class.":";
174 $nr = $this->getNodeIdForTargetClass($this->current_node, $class);
175 $nr = $nr["node_id"];
176 if ($nr != "")
177 {
178 $current_node = $this->current_node;
179
180 $this->current_node = $nr;
181
182 // always populate the call history
183 // it will only be displayed in DEVMODE but is needed for UI plugins, too
184 $this->call_hist[] = array("class" => get_class($a_gui_object),
185 "mode" => "execComm", "cmd" => $this->getCmd());
186
187//echo "<br>class:".get_class($a_gui_object).":";
188 $html = $a_gui_object->executeCommand();
189
190 // reset current node
191 $this->current_node = $current_node;
192
193 return $html;
194
195 }
196
197 include_once("./Services/UICore/exceptions/class.ilCtrlException.php");
198 throw new ilCtrlException("ERROR: Can't forward to class $class.");
199 }
200
208 function &getHTML(&$a_gui_object)
209 {
210 $class = strtolower(get_class($a_gui_object));
211
212 $nr = $this->getNodeIdForTargetClass($this->current_node, $class);
213 $nr = $nr["node_id"];
214 if ($nr != "")
215 {
216 $current_node = $this->current_node;
217
218 // set current node to new gui class
219 $this->current_node = $nr;
220
221 // always populate the call history
222 // it will only be displayed in DEVMODE but is needed for UI plugins, too
223 $this->call_hist[] = array("class" => get_class($a_gui_object),
224 "mode" => "getHtml", "cmd" => $this->getCmd());
225
226 // get block
227 $html = $a_gui_object->getHTML();
228
229 // reset current node
230 $this->current_node = $current_node;
231
232 // return block
233 return $html;
234 }
235
236 include_once("./Services/UICore/exceptions/class.ilCtrlException.php");
237 throw new ilCtrlException("ERROR: Can't getHTML from class $class.");
238
239 }
240
250 function setContext($a_obj_id, $a_obj_type, $a_sub_obj_id = 0, $a_sub_obj_type = "")
251 {
252 $this->context_obj_id = $a_obj_id;
253 $this->context_obj_type = $a_obj_type;
254 $this->context_sub_obj_id = $a_sub_obj_id;
255 $this->context_sub_obj_type = $a_sub_obj_type;
256 }
257
263 public function getContextObjId()
264 {
265 return $this->context_obj_id;
266 }
267
273 public function getContextObjType()
274 {
275 return $this->context_obj_type;
276 }
277
283 public function getContextSubObjId()
284 {
285 return $this->context_sub_obj_id;
286 }
287
293 public function getContextSubObjType()
294 {
295 return $this->context_sub_obj_type;
296 }
297
316 private function getNodeIdForTargetClass($a_par_node, $a_class, $a_check = false)
317 {
318 $class = strtolower($a_class);
319 $this->readClassInfo($class);
320
321 if ($a_par_node === 0 || $a_par_node == "")
322 {
323 return array("node_id" => $this->getCidForClass($class),
324 "base_class" => "");
325 }
326
327 $this->readNodeInfo($a_par_node);
328
329 $node_cid = $this->getCurrentCidOfNode($a_par_node);
330
331 // target class is class of current node id
332 if ($class == $this->getClassForCid($node_cid))
333 {
334 return array("node_id" => $a_par_node,
335 "base_class" => "");
336 }
337
338 // target class is child of current node id
339 if (isset($this->calls[$this->getClassForCid($node_cid)]) &&
340 is_array($this->calls[$this->getClassForCid($node_cid)]) &&
341 in_array($a_class, $this->calls[$this->getClassForCid($node_cid)]))
342 {
343 return array("node_id" => $a_par_node.":".$this->getCidForClass($class),
344 "base_class" => "");
345 }
346
347 // target class is sibling
348 $par_cid = $this->getParentCidOfNode($a_par_node);
349 if ($par_cid != "")
350 {
351 if (is_array($this->calls[$this->getClassForCid($par_cid)]) &&
352 in_array($a_class, $this->calls[$this->getClassForCid($par_cid)]))
353 {
354 return array("node_id" =>
355 $this->removeLastCid($a_par_node).":".$this->getCidForClass($class),
356 "base_class" => "");
357 }
358 }
359
360 // target class is parent
361 $temp_node = $this->removeLastCid($a_par_node);
362 while($temp_node != "")
363 {
364 $temp_cid = $this->getCurrentCidOfNode($temp_node);
365 if ($this->getClassForCid($temp_cid) == $a_class)
366 {
367 return array("node_id" => $temp_node,
368 "base_class" => "");
369 }
370 $temp_node = $this->removeLastCid($temp_node);
371 }
372
373 // target class is another base class
374 $n_class = "";
375 if ($a_class != "")
376 {
377 $module_class = ilCachedCtrl::getInstance();
378 $mc_rec = $module_class->lookupModuleClass($class);
379 $n_class = $mc_rec['lower_class'];
380// global $ilDB;
381//
382// get class information
383// $mc_set = $ilDB->query("SELECT * FROM module_class WHERE LOWER(class) = ".
384// $ilDB->quote($class, "text"));
385// $mc_rec = $ilDB->fetchAssoc($mc_set);
386// $n_class = strtolower($mc_rec["class"]);
387
388 if ($n_class == "")
389 {
390 $mc_rec = $module_class->lookupServiceClass($class);
391 $n_class = $mc_rec['lower_class'];
392
393// $mc_set = $ilDB->query("SELECT * FROM service_class WHERE LOWER(class) = ".
394// $ilDB->quote($class, "text"));
395// $mc_rec = $ilDB->fetchAssoc($mc_set);
396// $n_class = strtolower($mc_rec["class"]);
397
398 }
399
400 if ($n_class != "")
401 {
402 $this->getCallStructure($n_class);
403 return array("node_id" => $this->getCidForClass($n_class),
404 "base_class" => $class);
405 }
406 }
407
408 if ($a_check)
409 {
410 return false;
411 }
412
413 // Please do NOT change these lines.
414 // Developers must be aware, if they use classes unknown to the controller
415 // otherwise certain problem will be extremely hard to track down...
416
417// echo "ERROR: Can't find target class $a_class for node $a_par_node ".
418// "(".$this->cid_class[$this->getParentCidOfNode($a_par_node)].").<br>";
419 error_log( "ERROR: Can't find target class $a_class for node $a_par_node ".
420 "(".$this->cid_class[$this->getParentCidOfNode($a_par_node)].")");
421
422 if (DEVMODE == 1)
423 {
424// ilUtil::printBacktrace();
425 }
426
427 include_once("./Services/UICore/exceptions/class.ilCtrlException.php");
428 throw new ilCtrlException("ERROR: Can't find target class $a_class for node $a_par_node ".
429 "(".$this->cid_class[$this->getParentCidOfNode($a_par_node)].").");
430 }
431
438 function checkTargetClass($a_class)
439 {
440 if (!is_array($a_class))
441 {
442 $a_class = array($a_class);
443 }
444
445 $nr = $this->current_node;
446 foreach ($a_class as $class)
447 {
448 $class = strtolower($class);
449
450 if (!$this->getCidForClass($class, true))
451 {
452 return false;
453 }
454
455 $nr = $this->getNodeIdForTargetClass($nr, $class, true);
456 $nr = $nr["node_id"];
457 if ($nr === false)
458 {
459 return false;
460 }
461 }
462 return true;
463 }
464
470 function getCmdNode()
471 {
472 return $_GET["cmdNode"];
473 }
474
482 function addLocation($a_title, $a_link, $a_target = "", $a_ref_id = 0)
483 {
484 $this->location[] = array("title" => $a_title,
485 "link" => $a_link, "target" => $a_target, "ref_id" => $a_ref_id);
486 }
487
493 function getLocations()
494 {
495 return $this->location;
496 }
497
506 function addTab($a_lang_var, $a_link, $a_cmd, $a_class)
507 {
508 $a_class = strtolower($a_class);
509
510 $this->tab[] = array("lang_var" => $a_lang_var,
511 "link" => $a_link, "cmd" => $a_cmd, "class" => $a_class);
512 }
513
519 function getTabs()
520 {
521 return $this->tab;
522 }
523
530 function getCallHistory()
531 {
532 return $this->call_hist;
533 }
534
551 function getCallStructure($a_class)
552 {
553 $this->readClassInfo($a_class);
554 }
555
560/* function storeCommonStructures()
561 {
562 global $ilDB;
563
564 $ilDB->manipulate("DELETE FROM ctrl_structure");
565
566 foreach ($this->stored_trees as $root_gui_class)
567 {
568 $this->call_node = array();
569 $this->forward = array();
570 $this->parent = array();
571 $this->readCallStructure($root_gui_class);
572 $ilDB->insert("ctrl_structure", array(
573 "root_class" => array("text", $root_gui_class),
574 "call_node" => array("text", serialize($this->call_node)),
575 "forward" => array("text", serialize($this->forward)),
576 "parent" => array("clob", serialize($this->parent))));
577 }
578 }
579*/
580
584 function readCallStructure($a_class, $a_nr = 0, $a_parent = 0)
585 {
586 global $ilDB;
587
588 $a_class = strtolower($a_class);
589
590 $a_nr++;
591
592 // determine call node structure
593 $this->call_node[$a_nr] = array("class" => $a_class, "parent" => $a_parent);
594
595//echo "<br>nr:$a_nr:class:$a_class:parent:$a_parent:";
596 $call_set = $ilDB->query("SELECT * FROM ctrl_calls WHERE parent = ".
597 $ilDB->quote(strtolower($a_class), "text").
598 " ORDER BY child", array("text"));
599 $a_parent = $a_nr;
600 while ($call_rec = $ilDB->fetchAssoc($call_set))
601 {
602 $a_nr = $this->readCallStructure($call_rec["child"], $a_nr, $a_parent);
603 $forw[] = $call_rec["child"];
604 }
605
606 // determin forward and parent array
607 $this->forwards($a_class, $forw);
608//echo "<br>forwards:".$a_class."<br>"; var_dump($forw);
609
610 // determine root class
611 $this->root_class = $a_class;
612 return $a_nr;
613 }
614
615
622 private function forwards($a_from_class, $a_to_class)
623 {
624 $a_from_class = strtolower($a_from_class);
625
626 if (is_array($a_to_class))
627 {
628 foreach($a_to_class as $to_class)
629 {
630 if ($a_from_class != "" && $to_class != "")
631 {
632 if (!is_array($this->forward[$a_from_class]) || !in_array(strtolower($to_class), $this->forward[$a_from_class]))
633 {
634 $this->forward[$a_from_class][] = strtolower($to_class);
635 }
636 if (!is_array($this->parent[strtolower($to_class)]) || !in_array($a_from_class, $this->parent[strtolower($to_class)]))
637 {
638 $this->parent[strtolower($to_class)][] = $a_from_class;
639 }
640 }
641 }
642 }
643 else
644 {
645 $to_class = $a_to_class;
646 if ($a_from_class != "" && $to_class != "")
647 {
648 if (!is_array($this->forward[$a_from_class]) || !in_array(strtolower($to_class), $this->forward[$a_from_class]))
649 {
650 $this->forward[$a_from_class][] = strtolower($to_class);
651 }
652 if (!is_array($this->parent[strtolower($to_class)]) || !in_array($a_from_class, $this->parent[strtolower($to_class)]))
653 {
654 $this->parent[strtolower($to_class)][] = $a_from_class;
655 }
656 }
657 }
658 }
659
660
680 public function saveParameter(&$a_obj, $a_parameter)
681 {
682 if (is_object($a_obj))
683 {
684 $this->saveParameterByClass(get_class($a_obj), $a_parameter);
685 }
686 }
687
694 function saveParameterByClass($a_class, $a_parameter)
695 {
696 if (is_array($a_parameter))
697 {
698 foreach($a_parameter as $parameter)
699 {
700 $this->save_parameter[strtolower($a_class)][] = $parameter;
701 }
702 }
703 else
704 {
705 $this->save_parameter[strtolower($a_class)][] = $a_parameter;
706 }
707 }
708
709
732 public function setParameter(&$a_obj, $a_parameter, $a_value)
733 {
734 $this->parameter[strtolower(get_class($a_obj))][$a_parameter] = $a_value;
735 }
736
737
745 public function setParameterByClass($a_class, $a_parameter, $a_value)
746 {
747 $this->parameter[strtolower($a_class)][$a_parameter] = $a_value;
748 }
749
750
757 public function clearParameters(&$a_obj)
758 {
759 $this->clearParametersByClass(strtolower(get_class($a_obj)));
760 }
761
768 public function clearParametersByClass($a_class)
769 {
770 $this->parameter[strtolower($a_class)] = array();
771 }
772
773 protected function checkLPSettingsForward($a_gui_obj, $a_cmd_node)
774 {
775 global $objDefinition;
776
777 // forward to learning progress settings if possible and accessible
778 if($_GET["gotolp"] &&
779 $a_gui_obj)
780 {
781 $ref_id = $_GET["ref_id"];
782 if(!$ref_id)
783 {
784 $ref_id = $_REQUEST["ref_id"];
785 }
786
787 $gui_class = get_class($a_gui_obj);
788
789 if($gui_class == "ilSAHSEditGUI")
790 {
791 // #1625 - because of scorm "sub-types" this is all very special
792 include_once "./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php";
795 {
796 case "scorm2004":
797 $class = "ilObjSCORM2004LearningModuleGUI";
798 break;
799
800 case "scorm":
801 $class = "ilObjSCORMLearningModuleGUI";
802 break;
803
804 case "aicc":
805 $class = "ilObjAICCLearningModuleGUI";
806 break;
807
808 case "hacp":
809 $class = "ilObjHACPLearningModuleGUI";
810 break;
811 }
812 if($GLOBALS["ilAccess"]->checkAccess("edit_learning_progress", "", $ref_id))
813 {
814 $this->redirectByClass(array($gui_class, $class, "illearningprogressgui", "illplistofsettingsgui"), "");
815 }
816 }
817 // special case: cannot use any presentation GUIs
818 else if($gui_class == "ilLMPresentationGUI")
819 {
820 $this->setParameterByClass("ilObjLearningModuleGUI", "gotolp", 1);
821 $this->redirectByClass(array("ilLMEditorGUI", "ilObjLearningModuleGUI"), "");
822 }
823
824 include_once "Services/Object/classes/class.ilObjectLP.php";
825 $type = ilObject::_lookupType($ref_id, true);
826 $class = "ilObj".$objDefinition->getClassName($type)."GUI";
827
828 if($gui_class == $class &&
830 $GLOBALS["ilAccess"]->checkAccess("edit_learning_progress", "", $ref_id))
831 {
832 // add path to repository object gui if missing from cmdNode
833 if(!$a_cmd_node)
834 {
835 $repo_node = $this->getNodeIdForTargetClass(null, "ilrepositorygui");
836 $obj_node = $this->getNodeIdForTargetClass($repo_node["node_id"], $gui_class);
837 $a_cmd_node = $obj_node["node_id"];
838 }
839 // find path to lp settings
840 $lp_node = $this->getNodeIdForTargetClass($a_cmd_node, "illearningprogressgui");
841 $lp_settings_node = $this->getNodeIdForTargetClass($lp_node["node_id"], "illplistofsettingsgui");
842 $_GET["cmdNode"] = $lp_settings_node["node_id"];
843 $_GET["cmdClass"] = "ilLPListOfSettingsGUI";
844 $_GET["cmd"] = "";
845 return "illearningprogressgui";
846 }
847 }
848 }
849
858 function getNextClass($a_gui_class = null)
859 {
860 $cmdNode = $this->getCmdNode();
861//echo "<br>getNextClass (current node: ".$this->current_node."; cmd node: ".$cmdNode.") ";
862 if ($cmdNode == "")
863 {
864 return ($class = $this->checkLPSettingsForward($a_gui_class, $cmdNode))
865 ? $class
866 : false;
867 }
868 else
869 {
870 if ($this->current_node == $cmdNode)
871 {
872//echo "1:".$this->call_node[$cmdNode]["class"]."<br>";
873 //return $this->call_node[$cmdNode]["class"];
874 return ($class = $this->checkLPSettingsForward($a_gui_class, $cmdNode))
875 ? $class
876 : "";
877 }
878 else
879 {
880 $path = $this->getPathNew($this->current_node, $cmdNode);
881//var_dump($path);
882//echo " - Next Node: ".$path[1];
883 $this->readCidInfo($this->getCurrentCidOfNode($path[1]));
884//echo ":".$this->cid_class[$this->getCurrentCidOfNode($path[1])].":".$this->getCurrentCidOfNode($path[1]).":";
885 return $this->cid_class[$this->getCurrentCidOfNode($path[1])];
886 }
887 }
888 }
889
896 function lookupClassPath($a_class_name)
897 {
898 global $ilDB;
899 $a_class_name = strtolower($a_class_name);
900
901 $cached_ctrl = ilCachedCtrl::getInstance();
902 $class_rec = $cached_ctrl->lookupClassFile($a_class_name);
903
904 //$class_set = $ilDB->query("SELECT * FROM ctrl_classfile WHERE class = ".
905 // $ilDB->quote($a_class_name, "text"));
906 //$class_rec = $ilDB->fetchAssoc($class_set);
907
908 if ($class_rec["plugin_path"] != "")
909 {
910 return $class_rec["plugin_path"]."/".$class_rec["filename"];
911 }
912 else
913 {
914 return $class_rec["filename"];
915 }
916 }
917
926 function getClassForClasspath($a_class_path)
927 {
928 $path = pathinfo($a_class_path);
929 $file = $path["basename"];
930 $class = substr($file, 6, strlen($file) - 10);
931
932 return $class;
933 }
934
941 private function getPathNew($a_source_node, $a_target_node)
942 {
943//if ($this->getCmdClass() == "ilmailfoldergui") echo "-".$a_source_node."-".$a_target_node."-";
944//echo "-".$a_source_node."-".$a_target_node."-";
945//echo "<br>:::$a_source_node:::";
946 if ($a_source_node == "1")
947 {
948 $a_source_node = "";
949 }
950 if (substr($a_target_node, 0, strlen($a_source_node)) != $a_source_node)
951 {
952 $failure = "ERROR: Path not found. Source:".$a_source_node.
953 ", Target:".$a_target_node;
954 if (DEVMODE == 1)
955 {
956 include_once("./Services/UICore/exceptions/class.ilCtrlException.php");
957 throw new ilCtrlException($failure);
958 }
959 $GLOBALS['ilLog']->write(__METHOD__.' '.$failure);
960 ilUtil::redirect('./ilias.php?baseClass=ilRepositoryGUI');
961 }
962//echo "<br>:::$a_source_node:::";
963 $temp_node = $a_source_node;
964
965 $path = array();
966 if ($a_source_node != "")
967 {
968 $path = array($a_source_node);
969 }
970
971 $diffstart = ($a_source_node == "")
972 ? 0
973 : strlen($a_source_node) + 1;
974 $diff = substr($a_target_node, $diffstart);
975//echo "=$diff=$diffstart=";
976 $diff_arr = explode(":", $diff);
977 foreach($diff_arr as $cid)
978 {
979 if ($temp_node != "")
980 {
981 $temp_node.= ":";
982 }
983 $temp_node.= $cid;
984 $path[] = $temp_node;
985 }
986//if ($this->getCmdClass() == "ilmailfoldergui") var_dump($path);
987//var_dump($path);
988 return $path;
989 }
990
996 public function setTargetScript($a_target_script)
997 {
998 $this->target_script = $a_target_script;
999 }
1000
1001
1007 public function getTargetScript()
1008 {
1009 return $this->target_script;
1010 }
1011
1012
1021 public function initBaseClass($a_base_class)
1022 {
1023 $_GET["baseClass"] = $a_base_class;
1024 $_GET["cmd"] = "";
1025 $_GET["cmdClass"] = "";
1026 $_GET["cmdNode"] = "";
1027 $this->init();
1028 }
1029
1037 public function getCmd($a_default_cmd = "", $a_safe_commands = "")
1038 {
1039 $cmd = "";
1040 if (isset($_GET["cmd"]))
1041 {
1042 $cmd = $_GET["cmd"];
1043 }
1044 if($cmd == "post")
1045 {
1046 if (isset($_POST["cmd"]) && is_array($_POST["cmd"]))
1047 {
1048 reset($_POST["cmd"]);
1049 }
1050 $cmd = @key($_POST["cmd"]);
1051
1052 // verify command
1053 if ($this->verified_cmd != "")
1054 {
1055 return $this->verified_cmd;
1056 }
1057 else
1058 {
1059 if (!$this->verifyToken() &&
1060 (!is_array($a_safe_commands) || !in_array($cmd, $a_safe_commands)))
1061 {
1062 return $a_default_cmd;
1063 }
1064 }
1065
1066 $this->verified_cmd = $cmd;
1067 if($cmd == "" && isset($_POST["table_top_cmd"])) // selected command in multi-list (table2)
1068 {
1069 $cmd = @key($_POST["table_top_cmd"]);
1070 $this->verified_cmd = $cmd;
1071 $_POST[$_POST["cmd_sv"][$cmd]] = $_POST[$_POST["cmd_sv"][$cmd]."_2"];
1072 }
1073 if($cmd == "" && isset($_POST["select_cmd2"])) // selected command in multi-list (table2)
1074 {
1075 if(isset($_POST["select_cmd_all2"]))
1076 {
1077 $_POST["select_cmd_all"] = $_POST["select_cmd_all2"];
1078 }
1079 else
1080 {
1081 $_POST["select_cmd_all"] = $_POST["select_cmd_all2"] = null;
1082 }
1083 $cmd = $_POST["selected_cmd2"];
1084 $this->verified_cmd = $cmd;
1085 }
1086 if($cmd == "" && isset($_POST["select_cmd"])) // selected command in multi-list (table2)
1087 {
1088 if(isset($_POST["select_cmd_all"]))
1089 {
1090 $_POST["select_cmd_all2"] = $_POST["select_cmd_all"];
1091 }
1092 else
1093 {
1094 $_POST["select_cmd_all"] = $_POST["select_cmd_all2"] = null;
1095 }
1096 $cmd = $_POST["selected_cmd"];
1097 $this->verified_cmd = $cmd;
1098 }
1099 if($cmd == "")
1100 {
1101 $cmd = $_GET["fallbackCmd"];
1102 $this->verified_cmd = $cmd;
1103 }
1104 }
1105 if($cmd == "")
1106 {
1107 $cmd = $a_default_cmd;
1108 }
1109 return $cmd;
1110 }
1111
1122 function setCmd($a_cmd)
1123 {
1124 $_GET["cmd"] = $a_cmd;
1125 }
1126
1137 public function setCmdClass($a_cmd_class)
1138 {
1139 $a_cmd_class = strtolower($a_cmd_class);
1140 $nr = $this->getNodeIdForTargetClass($this->current_node, $a_cmd_class);
1141 $nr = $nr["node_id"];
1142 $_GET["cmdClass"] = $a_cmd_class;
1143 $_GET["cmdNode"] = $nr;
1144 }
1145
1151 function getCmdClass()
1152 {
1153 return strtolower($_GET["cmdClass"]);
1154 }
1155
1166 function getFormAction(&$a_gui_obj, $a_fallback_cmd = "", $a_anchor = "", $a_asynch = false,
1167 $xml_style = true)
1168 {
1169 $script = $this->getFormActionByClass(strtolower(get_class($a_gui_obj)),
1170 $a_fallback_cmd, $a_anchor, $a_asynch, $xml_style);
1171 return $script;
1172 }
1173
1184 function getFormActionByClass($a_class, $a_fallback_cmd = "", $a_anchor = "", $a_asynch = false,
1185 $xml_style = true)
1186 {
1187 if(!is_array($a_class))
1188 {
1189 $a_class = strtolower($a_class);
1190 }
1191
1192 $tok = $this->getRequestToken();
1193
1194 if ($a_asynch)
1195 {
1196 $xml_style = false;
1197 }
1198
1199 $script = $this->getLinkTargetByClass($a_class, "post", "", $a_asynch);
1200 if ($a_fallback_cmd != "")
1201 {
1202 $script = ilUtil::appendUrlParameterString($script, "fallbackCmd=".$a_fallback_cmd, $xml_style);
1203 }
1204 $script = ilUtil::appendUrlParameterString($script, self::IL_RTOKEN_NAME.'='.$this->getRequestToken(),
1205 $xml_style);
1206 if ($a_anchor != "")
1207 {
1208 $script = $script."#".$a_anchor;
1209 }
1210
1211 return $script;
1212 }
1213
1220 public function appendRequestTokenParameterString($a_url, $xml_style = true)
1221 {
1222 return ilUtil::appendUrlParameterString($a_url, self::IL_RTOKEN_NAME.'='.$this->getRequestToken(),
1223 $xml_style);
1224 }
1225
1231 public function getRequestToken()
1232 {
1233 global $ilDB, $ilUser;
1234
1235 if ($this->rtoken != "")
1236 {
1237 return $this->rtoken;
1238 }
1239 else
1240 {
1241 if (is_object($ilDB) && is_object($ilUser) && $ilUser->getId() > 0 &&
1242 $ilUser->getId() != ANONYMOUS_USER_ID)
1243 {
1244 $res = $ilDB->query("SELECT token FROM il_request_token WHERE user_id = ".
1245 $ilDB->quote($ilUser->getId(), "integer").
1246 " AND session_id = ".$ilDB->quote(session_id(), "text"));
1247 $rec = $ilDB->fetchAssoc($res);
1248//echo session_id();
1249 if ($rec["token"] != "")
1250 {
1251 $this->rtoken = $rec["token"];
1252 return $rec["token"];
1253 }
1254//echo "new rtoken, new entry for :".$ilUser->getId().":".session_id().":"; exit;
1255 $this->rtoken = md5(uniqid(rand(), true));
1256
1257 // delete entries older than one and a half days
1258 if (rand(1, 200) == 2)
1259 {
1260 $dt = new ilDateTime(time(),IL_CAL_UNIX);
1261 $dt->increment(IL_CAL_DAY, -1);
1262 $dt->increment(IL_CAL_HOUR, -12);
1263 $dq = "DELETE FROM il_request_token WHERE ".
1264 " stamp < ".$ilDB->quote($dt->get(IL_CAL_DATETIME), "timestamp");
1265 $ilDB->manipulate($dq);
1266 }
1267
1268 // IMPORTANT: Please do NOT try to move this implementation to a
1269 // session basis. This will fail due to framesets that are used
1270 // occasionally in ILIAS, e.g. in the chat, where multiple
1271 // forms are loaded in different frames.
1272 $ilDB->manipulate("INSERT INTO il_request_token (user_id, token, stamp, session_id) VALUES ".
1273 "(".
1274 $ilDB->quote($ilUser->getId(), "integer").",".
1275 $ilDB->quote($this->rtoken, "text").",".
1276 $ilDB->now().",".
1277 $ilDB->quote(session_id(), "text").")");
1278 return $this->rtoken;
1279 }
1280 //$this->rtoken = md5(uniqid(rand(), true));
1281 }
1282 return "";
1283 }
1284
1290 private function verifyToken()
1291 {
1292 global $ilDB, $ilUser;
1293
1294 if (is_object($ilUser) && is_object($ilDB) && $ilUser->getId() > 0 &&
1295 $ilUser->getId() != ANONYMOUS_USER_ID)
1296 {
1297 if ($_GET["rtoken"] == "")
1298 {
1299 #echo "ilCtrl::No Request Token Given!"; // for debugging, maybe changed later
1300 return false;
1301 }
1302
1303 $set = $ilDB->query("SELECT * FROM il_request_token WHERE ".
1304 " user_id = ".$ilDB->quote($ilUser->getId(), "integer")." AND ".
1305 " token = ".$ilDB->quote($_GET[self::IL_RTOKEN_NAME]), "text");
1306 if ($ilDB->numRows($set) > 0)
1307 {
1308 // remove used token
1309 /*
1310 $ilDB->query("DELETE FROM il_request_token WHERE ".
1311 " user_id = ".$ilDB->quote($ilUser->getId())." AND ".
1312 " token = ".$ilDB->quote($_GET[self::IL_RTOKEN_NAME]));
1313 */
1314
1315 // remove tokens from older sessions
1316 // if we do this immediately, working with multiple windows does not work:
1317 // - window one: open form (with token a)
1318 // - window two: open form (with token b)
1319 // - submit window one: a is verified, but b must not be deleted immediately, otherwise
1320 // - window two: submit results in invalid token
1321 // see also bug #13551
1322 $dt = new ilDateTime(time(),IL_CAL_UNIX);
1323 $dt->increment(IL_CAL_DAY, -1);
1324 $dt->increment(IL_CAL_HOUR, -12);
1325 $ilDB->manipulate("DELETE FROM il_request_token WHERE ".
1326 " user_id = ".$ilDB->quote($ilUser->getId(), "integer")." AND ".
1327 " session_id != ".$ilDB->quote(session_id(), "text")." AND ".
1328 " stamp < ".$ilDB->quote($dt->get(IL_CAL_DATETIME), "timestamp"));
1329 return true;
1330 }
1331 else
1332 {
1333 return false;
1334 }
1335
1336 if ($_SESSION["rtokens"][$_GET[self::IL_RTOKEN_NAME]] != "")
1337 {
1338 // remove used token
1339 unset($_SESSION["rtokens"][$_GET[self::IL_RTOKEN_NAME]]);
1340
1341 // remove old tokens
1342 if (count($_SESSION["rtokens"]) > 100)
1343 {
1344 $to_remove = array();
1345 $sec = 7200; // two hours
1346
1347 foreach($_SESSION["rtokens"] as $tok => $time)
1348 {
1349 if (time() - $time > $sec)
1350 {
1351 $to_remove[] = $tok;
1352 }
1353 }
1354 foreach($to_remove as $tok)
1355 {
1356 unset($_SESSION["rtokens"][$tok]);
1357 }
1358 }
1359
1360 return true;
1361 }
1362 return false;
1363 }
1364 else
1365 {
1366 return true; // do not verify, if user or db object is missing
1367 }
1368
1369 return false;
1370 }
1371
1379 public function redirect(&$a_gui_obj, $a_cmd = "", $a_anchor = "", $a_asynch = false)
1380 {
1381 global $ilBench;
1382
1383 $script = $this->getLinkTargetByClass(strtolower(get_class($a_gui_obj)), $a_cmd,
1384 "", $a_asynch, false);
1385 if (is_object($ilBench))
1386 {
1387 $ilBench->save();
1388 }
1389 if ($a_anchor != "")
1390 {
1391 $script = $script."#".$a_anchor;
1392 }
1393 ilUtil::redirect($script);
1394 }
1395
1396
1403 public function redirectByClass($a_class, $a_cmd = "", $a_anchor = "", $a_asynch = false)
1404 {
1405 $script = $this->getLinkTargetByClass($a_class, $a_cmd, "", $a_asynch, false);
1406 if ($a_anchor != "")
1407 {
1408 $script = $script."#".$a_anchor;
1409 }
1410 ilUtil::redirect($script);
1411 }
1412
1418 public function isAsynch()
1419 {
1420 if (isset($_GET["cmdMode"]) && $_GET["cmdMode"] == "asynch")
1421 {
1422 return true;
1423 }
1424 else
1425 {
1426 return false;
1427 }
1428 }
1429
1430
1442 function getLinkTarget(&$a_gui_obj, $a_cmd = "", $a_anchor = "", $a_asynch = false,
1443 $xml_style = true)
1444 {
1445 $script = $this->getLinkTargetByClass(strtolower(get_class($a_gui_obj)), $a_cmd, $a_anchor, $a_asynch,
1446 $xml_style);
1447 return $script;
1448 }
1449
1450
1462 function getLinkTargetByClass($a_class, $a_cmd = "", $a_anchor = "", $a_asynch = false,
1463 $xml_style = true)
1464 {
1465 if ($a_asynch)
1466 {
1467 $xml_style = false;
1468 }
1469
1470 // note: $a_class may be an array
1471 //$a_class = strtolower($a_class);
1472
1473//echo "<br>getLinkTargetByClass";
1474 $script = $this->getTargetScript();
1475 $script = $this->getUrlParameters($a_class, $script, $a_cmd, $xml_style);
1476
1477 if ($a_asynch)
1478 {
1479 //$amp = $xml_style
1480 // ? "&amp;"
1481 // : "&";
1482 $amp = "&";
1483 $script.= $amp."cmdMode=asynch";
1484 }
1485
1486 if ($a_anchor != "")
1487 {
1488 $script = $script."#".$a_anchor;
1489 }
1490
1491 return $script;
1492 }
1493
1497 function setReturn(&$a_gui_obj, $a_cmd)
1498 {
1499 $script = $this->getTargetScript();
1500 $script = $this->getUrlParameters(strtolower(get_class($a_gui_obj)), $script, $a_cmd);
1501//echo "<br>setReturn:".get_class($a_gui_obj).":".$script.":<br>";
1502 $this->return[strtolower(get_class($a_gui_obj))] = $script;
1503 }
1504
1508 function setReturnByClass($a_class, $a_cmd)
1509 {
1510 // may not be an array!
1511 $a_class = strtolower($a_class);
1512
1513 $script = $this->getTargetScript();
1514 $script = $this->getUrlParameters($a_class, $script, $a_cmd);
1515//echo "<br>setReturn:".get_class($a_gui_obj).":".$script.":<br>";
1516 $this->return[strtolower($a_class)] = $script;
1517 }
1518
1522 function returnToParent(&$a_gui_obj, $a_anchor = "")
1523 {
1524 $script = $this->getParentReturn($a_gui_obj);
1525
1526 $script = ilUtil::appendUrlParameterString($script,
1527 "redirectSource=".strtolower(get_class($a_gui_obj)));
1528 $script = ilUtil::appendUrlParameterString($script,
1529 "cmdMode=".$_GET["cmdMode"]);
1530 if ($a_anchor != "")
1531 {
1532 $script = $script."#".$a_anchor;
1533 }
1534
1535 ilUtil::redirect($script);
1536 }
1537
1538
1545 {
1546 return $_GET["redirectSource"];
1547 }
1548
1552 function getParentReturn(&$a_gui_obj)
1553 {
1554 return $this->getParentReturnByClass(strtolower(get_class($a_gui_obj)));
1555 }
1556
1557
1561 function getParentReturnByClass($a_class)
1562 {
1563 $a_class = strtolower($a_class);
1564 $ret_class = $this->searchReturnClass($a_class);
1565//echo ":$ret_class:";
1566 if($ret_class)
1567 {
1568//echo ":".$this->return[$ret_class].":";
1569 return $this->return[$ret_class];
1570 }
1571 }
1572
1579 function getReturnClass($a_class)
1580 {
1581 if (is_object($a_class))
1582 {
1583 $class = strtolower(get_class($a_class));
1584 }
1585 else
1586 {
1587 $class = strtolower($a_class);
1588 }
1589 return $this->searchReturnClass($class);
1590 }
1591
1592
1596 private function searchReturnClass($a_class)
1597 {
1598 $a_class = strtolower($a_class);
1599
1600 $node = $this->getNodeIdForTargetClass($this->current_node, $a_class);
1601 $node = $node["node_id"];
1602 $n_arr = explode(":", $node);
1603 for($i = count($n_arr)-2; $i>=0; $i--)
1604 {
1605 if ($this->return[$this->getClassForCid($n_arr[$i])] != "")
1606 {
1607 return $this->getClassForCid($n_arr[$i]);
1608 }
1609 }
1610
1611 return false;
1612 }
1613
1617 public function getUrlParameters($a_class, $a_str, $a_cmd = "", $xml_style = false)
1618 {
1619 // note: $a_class may be an array!
1620 //$a_class = strtolower($a_class);
1621
1622 $params = $this->getParameterArrayByClass($a_class, $a_cmd);
1623
1624 foreach ($params as $par => $value)
1625 {
1626 if (strlen((string) $value))
1627 {
1628 $a_str = ilUtil::appendUrlParameterString($a_str, $par."=".$value, $xml_style);
1629 }
1630 }
1631
1632 return $a_str;
1633 }
1634
1638 public function getParameterArray(&$a_gui_obj, $a_cmd = "")
1639 {
1640 $par_arr = $this->getParameterArrayByClass(strtolower(get_class($a_gui_obj)), $a_cmd);
1641
1642 return $par_arr;
1643 }
1644
1652 public function getParameterArrayByClass($a_class, $a_cmd = "")
1653 {
1654 if ($a_class == "")
1655 {
1656 return array();
1657 }
1658
1659 if (!is_array($a_class))
1660 {
1661 $a_class = array($a_class);
1662 }
1663
1664 $nr = $this->current_node;
1665 foreach ($a_class as $class)
1666 {
1667 $class = strtolower($class);
1668 $nr = $this->getNodeIdForTargetClass($nr, $class);
1669 if ($nr["base_class"] != "")
1670 {
1671 $new_baseclass = $nr["base_class"];
1672 }
1673 $nr = $nr["node_id"];
1674 $target_class = $class;
1675 }
1676
1677 $path = $this->getPathNew(1, $nr);
1678 $params = array();
1679
1680 // append parameters of parent classes
1681 foreach($path as $node_id)
1682 {
1683 $class = ($node_id == "")
1684 ? strtolower($_GET["baseClass"])
1685 : $this->getClassForCid($this->getCurrentCidOfNode($node_id));
1686 if (isset($this->save_parameter[$class]) && is_array($this->save_parameter[$class]))
1687 {
1688 foreach($this->save_parameter[$class] as $par)
1689 {
1690 if (isset($_GET[$par]))
1691 {
1692 $params[$par] = $_GET[$par];
1693 }
1694 else if (isset($_POST[$par]))
1695 {
1697 }
1698 }
1699 }
1700
1701 if (isset($this->parameter[$class]) && is_array($this->parameter[$class]))
1702 {
1703 foreach($this->parameter[$class] as $par => $value)
1704 {
1705 $params[$par] = $value;
1706 }
1707 }
1708 }
1709
1710 if ($a_cmd != "")
1711 {
1712 $params["cmd"] = $a_cmd;
1713 }
1714
1715 $params["cmdClass"] = $target_class;
1716 $params["cmdNode"] = $nr;
1717 if($new_baseclass == "")
1718 {
1719 $params["baseClass"] = $_GET["baseClass"];
1720 }
1721 else
1722 {
1723 $params["baseClass"] = $new_baseclass;
1724 }
1725
1726 return $params;
1727 }
1728
1732 private function getCidForClass($a_class, $a_check = false)
1733 {
1734 if ($this->class_cid[$a_class] == "")
1735 {
1736 $this->readClassInfo($a_class);
1737 }
1738 if ($this->class_cid[$a_class] == "")
1739 {
1740 if ($a_check)
1741 {
1742 return false;
1743 }
1744 if (DEVMODE == 1)
1745 {
1746 $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
1747 may solve the issue by putting an empty * @ilCtrl_Calls [YourClassName]: into your class header.".
1748 " In both cases you need to reload the control structure in the setup.";
1749 }
1750 include_once("./Services/UICore/exceptions/class.ilCtrlException.php");
1751 throw new ilCtrlException("Cannot find cid for class ".$a_class.".".$add);
1752 }
1753 return $this->class_cid[$a_class];
1754 }
1755
1759 private function getClassForCid($a_cid)
1760 {
1761 if ($this->cid_class[$a_cid] == "")
1762 {
1763 $this->readCidInfo($a_cid);
1764 }
1765 if ($this->cid_class[$a_cid] == "")
1766 {
1767 include_once("./Services/UICore/exceptions/class.ilCtrlException.php");
1768 throw new ilCtrlException("Cannot find class for cid ".$a_cid.".");
1769 }
1770 return $this->cid_class[$a_cid];
1771 }
1772
1778 private function readCidInfo($a_cid)
1779 {
1780 global $ilDB;
1781
1782 if (isset($this->info_read_cid[$a_cid]))
1783 {
1784 return;
1785 }
1786
1787 $cached_ctrl = ilCachedCtrl::getInstance();
1788 $rec = $cached_ctrl->lookupCid($a_cid);
1789
1790// $set = $ilDB->query("SELECT * FROM ctrl_classfile ".
1791// " WHERE cid = ".$ilDB->quote($a_cid, "text")
1792// );
1793// if ($rec = $ilDB->fetchAssoc($set))
1794 if($rec)
1795 {
1796 $this->cid_class[$a_cid] = $rec["class"];
1797 $this->class_cid[$rec["class"]] = $a_cid;
1798
1799 $calls = $cached_ctrl->lookupCall($rec["class"]);
1800
1801 // $set = $ilDB->query("SELECT * FROM ctrl_calls ".
1802 // " WHERE parent = ".$ilDB->quote($rec["class"], "text")
1803 // );
1804 // while ($rec2 = $ilDB->fetchAssoc($set))
1805 foreach($calls as $rec2)
1806 {
1807 if (!isset($this->calls[$rec["class"]]) || !is_array($this->calls[$rec["class"]]) || !in_array($rec2["child"], $this->calls[$rec["class"]]))
1808 {
1809 if ($rec2["child"] != "")
1810 {
1811 $this->calls[$rec["class"]][] = $rec2["child"];
1812 }
1813 }
1814 }
1815 $this->info_read_class[$rec["class"]] = true;
1816 }
1817
1818 $this->info_read_cid[$a_cid] = true;
1819 }
1820
1826 private function readNodeInfo($a_node)
1827 {
1828 $n_arr = explode(":", $a_node);
1829 foreach ($n_arr as $cid)
1830 {
1831 $this->readCidInfo($cid);
1832 }
1833 }
1834
1840 private function readClassInfo($a_class)
1841 {
1842 global $ilDB;
1843
1844 $a_class = strtolower($a_class);
1845 if (isset($this->info_read_class[$a_class]))
1846 {
1847 return;
1848 }
1849
1850 $cached_ctrl = ilCachedCtrl::getInstance();
1851 $rec = $cached_ctrl->lookupClassFile($a_class);
1852
1853
1854// $set = $ilDB->query("SELECT * FROM ctrl_classfile ".
1855// " WHERE class = ".$ilDB->quote($a_class, "text")
1856// );
1857// if ($rec = $ilDB->fetchAssoc($set))
1858 if($rec)
1859 {
1860 $this->cid_class[$rec["cid"]] = $a_class;
1861 $this->class_cid[$a_class] = $rec["cid"];
1862 }
1863
1864// $set = $ilDB->query("SELECT * FROM ctrl_calls ".
1865// " WHERE parent = ".$ilDB->quote($a_class, "text")
1866// );
1867 $recs = $cached_ctrl->lookupCall($a_class);
1868// while ($rec = $ilDB->fetchAssoc($set))
1869 foreach($recs as $rec)
1870 {
1871 if (!isset($this->calls[$a_class]) || !is_array($this->calls[$a_class]) || !in_array($rec["child"], $this->calls[$a_class]))
1872 {
1873 if ($rec["child"] != "")
1874 {
1875 $this->calls[$a_class][] = $rec["child"];
1876 }
1877 }
1878 }
1879
1880 $this->info_read_class[$a_class] = true;
1881 $this->info_read_cid[$this->class_cid[$a_class]] = true;
1882 }
1883
1887 private function getParentCidOfNode($a_node)
1888 {
1889 $n_arr = explode(":", $a_node);
1890 return $n_arr[count($n_arr) - 2];
1891 }
1892
1896 private function removeLastCid($a_node)
1897 {
1898 $lpos = strrpos($a_node, ":");
1899 return substr($a_node, 0, $lpos);
1900 }
1901
1905 private function getCurrentCidOfNode($a_node)
1906 {
1907 $n_arr = explode(":", $a_node);
1908 return $n_arr[count($n_arr) - 1];
1909 }
1910
1917 function insertCtrlCalls($a_parent, $a_child, $a_comp_prefix)
1918 {
1919 global $ilDB;
1920
1921 $a_parent = strtolower($a_parent);
1922 $a_child = strtolower($a_child);
1923 $a_comp_prefix = strtolower($a_comp_prefix);
1924
1925 $set = $ilDB->query("SELECT * FROM ctrl_calls WHERE ".
1926 " parent = ".$ilDB->quote($a_parent, "text")." AND ".
1927 " child = ".$ilDB->quote($a_child, "text")." AND ".
1928 " comp_prefix = ".$ilDB->quote($a_comp_prefix, "text")
1929 );
1930 if ($rec = $ilDB->fetchAssoc($set))
1931 {
1932 return;
1933 }
1934 $ilDB->manipulate("INSERT INTO ctrl_calls ".
1935 "(parent, child, comp_prefix) VALUES (".
1936 $ilDB->quote($a_parent, "text").",".
1937 $ilDB->quote($a_child, "text").",".
1938 $ilDB->quote($a_comp_prefix, "text").
1939 ")");
1940 }
1941
1942}
1943?>
print $file
$failure
$location
Definition: buildRTE.php:44
$_GET["client_id"]
$_SESSION["AccountId"]
const IL_CAL_UNIX
const IL_CAL_DATETIME
const IL_CAL_HOUR
const IL_CAL_DAY
static getComponentInfo($a_type, $a_name)
ilCtrl exceptions
This class provides processing control methods.
appendRequestTokenParameterString($a_url, $xml_style=true)
Append request token as url parameter.
getCidForClass($a_class, $a_check=false)
Get Cid for Class.
checkLPSettingsForward($a_gui_obj, $a_cmd_node)
getCallHistory()
Get controller call history.
setCmdClass($a_cmd_class)
Set the current command class.
redirect(&$a_gui_obj, $a_cmd="", $a_anchor="", $a_asynch=false)
Redirect to another command.
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.
ilCtrl()
control class constructor
& getHTML(&$a_gui_object)
Gets an HTML output from another GUI class and returns the flow of control to the calling class.
readCallStructure($a_class, $a_nr=0, $a_parent=0)
stores often used common call structures (called from db_update script!!!)
getParentCidOfNode($a_node)
Get last but one cid of node id.
readCidInfo($a_cid)
Read information of class per cid.
getFormActionByClass($a_class, $a_fallback_cmd="", $a_anchor="", $a_asynch=false, $xml_style=true)
Get form action url for gui class name.
getFormAction(&$a_gui_obj, $a_fallback_cmd="", $a_anchor="", $a_asynch=false, $xml_style=true)
Get form action url for gui class object.
getTargetScript()
Get target script name.
getModuleDir()
get directory of current module
verifyToken()
Verify Token.
addTab($a_lang_var, $a_link, $a_cmd, $a_class)
Add a tab to tabs array (.
removeLastCid($a_node)
Remove last cid of node.
getPathNew($a_source_node, $a_target_node)
Get path in call structure.
getNodeIdForTargetClass($a_par_node, $a_class, $a_check=false)
Searchs a node for a given class ($a_class) "near" the another node ($a_par_node).
getDebug()
Get debug message string (.
clearParameters(&$a_obj)
Clears all parameters that have been set via setParameter for a GUI class.
getLinkTargetByClass($a_class, $a_cmd="", $a_anchor="", $a_asynch=false, $xml_style=true)
Get link target for command using gui class name.
getCmdClass()
Determines class that should execute the current command.
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.
debug($str)
Collect debugging strings (.
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)
Read info of node.
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 (.
setTargetScript($a_target_script)
set target script name
setReturnByClass($a_class, $a_cmd)
Set return command.
& forwardCommand(&$a_gui_object)
Forward flow of control to next gui class this invokes the executeCommand() method of the gui object ...
const IL_RTOKEN_NAME
readClassInfo($a_class)
Read info of class.
getReturnClass($a_class)
Get return class.
getContextObjType()
Get context object type.
getCurrentCidOfNode($a_node)
Get last cid of node id.
callBaseClass()
Calls base class of current request.
init()
initialisation
getLinkTarget(&$a_gui_obj, $a_cmd="", $a_anchor="", $a_asynch=false, $xml_style=true)
Get link target for command using gui object.
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.
getContextSubObjType()
Get context subobject type.
returnToParent(&$a_gui_obj, $a_anchor="")
Redirects to next parent class that used setReturn.
isAsynch()
Is current command an asynchronous command?
setParameterByClass($a_class, $a_parameter, $a_value)
Same as setParameterByClass, except that a class name is passed.
getParameterArray(&$a_gui_obj, $a_cmd="")
Get all set/save parameters for a gui object.
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.
setParameter(&$a_obj, $a_parameter, $a_value)
Set parameters that should be passed a form and link of a gui class.
saveParameterByClass($a_class, $a_parameter)
Save parameter for a class.
getParentReturn(&$a_gui_obj)
Get return script url.
getClassForCid($a_cid)
Get class for cid.
saveParameter(&$a_obj, $a_parameter)
Set parameters that should be passed in every form and link of a gui class.
setReturn(&$a_gui_obj, $a_cmd)
Set return command.
setCmd($a_cmd)
Set the current command.
checkTargetClass($a_class)
Check whether target is valid.
forwards($a_from_class, $a_to_class)
Stores which classes forwards commands to which other classes.
initBaseClass($a_base_class)
Initialises new base class.
addLocation($a_title, $a_link, $a_target="", $a_ref_id=0)
Add a location to the locator array (.
getLocations()
Get locations array (.
@classDescription Date and time handling
_lookupSubType($a_obj_id)
lookup subtype id (scorm, aicc, hacp)
static isSupportedObjectType($a_type)
static _lookupObjectId($a_ref_id)
lookup object id
static _lookupType($a_id, $a_reference=false)
lookup object type
static appendUrlParameterString($a_url, $a_par, $xml_style=false)
append URL parameter string ("par1=value1&par2=value2...") to given URL string
static redirect($a_script)
http redirect to other script
static stripSlashesRecursive($a_data, $a_strip_html=true, $a_allow="")
Strip slashes from array and sub-arrays.
$_POST['username']
Definition: cron.php:12
$html
Definition: example_001.php:87
$params
Definition: example_049.php:96
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276
global $ilBench
Definition: ilias.php:18
$cmd
Definition: sahs_server.php:35
$ref_id
Definition: sahs_server.php:39
$path
Definition: index.php:22
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
global $ilDB
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
global $ilUser
Definition: imgupload.php:15