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

This class provides processing control methods. More...

+ Collaboration diagram for ilCtrl:

Public Member Functions

 __construct ()
 control class constructor More...
 
 callBaseClass ()
 Calls base class of current request. More...
 
 getModuleDir ()
 get directory of current module More...
 
 forwardCommand ($a_gui_object)
 Forward flow of control to next gui class this invokes the executeCommand() method of the gui object that is passed via reference. More...
 
 getHTML ($a_gui_object, array $a_parameters=null)
 Gets an HTML output from another GUI class and returns the flow of control to the calling class. More...
 
 setContext ($a_obj_id, $a_obj_type, $a_sub_obj_id=0, $a_sub_obj_type="")
 Set context of current user interface. More...
 
 getContextObjId ()
 Get context object id. More...
 
 getContextObjType ()
 Get context object type. More...
 
 getContextSubObjId ()
 Get context subobject id. More...
 
 getContextSubObjType ()
 Get context subobject type. More...
 
 checkTargetClass ($a_class)
 Check whether target is valid. More...
 
 getCmdNode ()
 Get command target node. More...
 
 addTab ($a_lang_var, $a_link, $a_cmd, $a_class)
 Add a tab to tabs array (. More...
 
 getTabs ()
 Get tabs array (. More...
 
 getCallHistory ()
 Get controller call history. More...
 
 getCallStructure ($a_class)
 Get call structure of class context. More...
 
 readCallStructure ($a_class, $a_nr=0, $a_parent=0)
 Reads call structure from db. More...
 
 saveParameter ($a_obj, $a_parameter)
 Set parameters that should be passed in every form and link of a gui class. More...
 
 saveParameterByClass ($a_class, $a_parameter)
 Save parameter for a class. More...
 
 setParameter ($a_obj, $a_parameter, $a_value)
 Set parameters that should be passed a form and link of a gui class. More...
 
 setParameterByClass ($a_class, $a_parameter, $a_value)
 Same as setParameterByClass, except that a class name is passed. More...
 
 clearParameterByClass ($a_class, $a_parameter)
 Same as setParameterByClass, except that a class name is passed. More...
 
 clearParameters ($a_obj)
 Clears all parameters that have been set via setParameter for a GUI class. More...
 
 clearParametersByClass ($a_class)
 Clears all parameters that have been set via setParameter for a GUI class. More...
 
 getNextClass ($a_gui_class=null)
 Get next class in the control path from the current class to the target command class. More...
 
 lookupClassPath ($a_class_name)
 Get class path that can be used in include statements for a given class name. More...
 
 getClassForClasspath ($a_class_path)
 this method assumes that the class path has the format "dir/class.<class_name>.php" More...
 
 setTargetScript (string $a_target_script)
 set target script name More...
 
 getTargetScript ()
 Get target script name. More...
 
 initBaseClass ($a_base_class)
 Initialises new base class. More...
 
 getCmd ($a_default_cmd="", $a_safe_commands="")
 Determines current get/post command. More...
 
 setCmd ($a_cmd)
 Set the current command. More...
 
 setCmdClass ($a_cmd_class)
 Set the current command class. More...
 
 getCmdClass ()
 Determines class that should execute the current command. More...
 
 getFormAction ( $a_gui_obj, $a_fallback_cmd="", $a_anchor="", $a_asynch=false, $xml_style=true)
 Get form action url for gui class object. More...
 
 getFormActionByClass ( $a_class, $a_fallback_cmd="", $a_anchor="", $a_asynch=false, $xml_style=true)
 Get form action url for gui class name. More...
 
 appendRequestTokenParameterString ($a_url, $xml_style=true)
 Append request token as url parameter. More...
 
 getRequestToken ()
 Get request token. More...
 
 redirect ($a_gui_obj, $a_cmd="", $a_anchor="", $a_asynch=false)
 Redirect to another command. More...
 
 redirectToURL ($a_script)
 
 redirectByClass ($a_class, $a_cmd="", $a_anchor="", $a_asynch=false)
 Redirect to other gui class using class name. More...
 
 isAsynch ()
 Is current command an asynchronous command? More...
 
 getLinkTarget ( $a_gui_obj, $a_cmd="", $a_anchor="", $a_asynch=false, $xml_style=true)
 Get link target for command using gui object. More...
 
 getLinkTargetByClass ( $a_class, $a_cmd="", $a_anchor="", $a_asynch=false, $xml_style=true)
 Get link target for command using gui class name. More...
 
 setReturn ($a_gui_obj, $a_cmd)
 Set return command. More...
 
 setReturnByClass ($a_class, $a_cmd)
 Set return command. More...
 
 returnToParent ($a_gui_obj, $a_anchor="")
 Redirects to next parent class that used setReturn. More...
 
 getParentReturn ($a_gui_obj)
 Get return script url. More...
 
 getReturnClass ($a_class)
 Get return class. More...
 
 getRedirectSource ()
 Get current redirect source. More...
 
 getUrlParameters ($a_class, $a_str, $a_cmd="", $xml_style=false)
 Get URL parameters for a class and append them to a string. More...
 
 getParameterArray ($a_gui_obj, $a_cmd="")
 Get all set/save parameters for a gui object. More...
 
 getParameterArrayByClass ($a_class, $a_cmd="")
 Get all set/save parameters using gui class name. More...
 
 insertCtrlCalls ($a_parent, $a_child, $a_comp_prefix)
 Insert ctrl calls record. More...
 
 checkCurrentPathForClass ($gui_class)
 Check if current path contains a certain gui class. More...
 

Data Fields

const IL_RTOKEN_NAME = 'rtoken'
 

Protected Member Functions

 initializeMemberVariables ()
 Initialize member variables. More...
 
 checkLPSettingsForward ($a_gui_obj, $a_cmd_node)
 
 getParentReturnByClass ($a_class)
 Get return script url. More...
 

Protected Attributes

 $db
 
 $plugin_admin
 
 $save_parameter
 
 $parameter
 
 $return
 
 $call_hist = array()
 Stores the order in which different GUI classes were called. More...
 
 $calls = array()
 Stores which class calls which other class. More...
 
 $rtoken = false
 
 $target_script = "ilias.php"
 

Private Member Functions

 getNodeIdForTargetClass ($a_par_node, $a_class, $a_check=false)
 Searches a node for a given class ($a_class) "near" another node ($a_par_node). More...
 
 getPathNew ($a_source_node, $a_target_node)
 Get path in call structure. More...
 
 verifyToken ()
 Verify Token. More...
 
 searchReturnClass ($a_class)
 Determine current return class. More...
 
 classCidUnknown ($a_class)
 
 getCidForClass ($a_class, $a_check=false)
 Get class id for class after fetching and storing corresponding information, if necessary. More...
 
 cidClassUnknown ($a_cid)
 
 getClassForCid ($a_cid)
 Get class for class id after fetching and storing corresponding information, if necessary. More...
 
 fetchCallsOfClassFromCache ($a_class, ilCachedCtrl $a_cached_ctrl)
 
 readCidInfo ($a_cid)
 Save class respective to $a_cid and store corresponding class calls for future reference. More...
 
 readNodeInfo ($a_node)
 Save classes respective to the class id's of a node and store corresponding class calls for future reference. More...
 
 readClassInfo ($a_class)
 Save class id respective to $a_class and store corresponding class calls for future reference. More...
 
 callOfClassNotKnown ($a_class, $a_child)
 
 updateClassCidMap ($a_class, $a_cid)
 
 getParentCidOfNode ($a_node)
 Get 2nd to last class id of node. More...
 
 removeLastCid ($a_node)
 Remove the class id that comes at the beginning the sequence. More...
 
 getCurrentCidOfNode ($a_node)
 Get cid of node. More...
 

Detailed Description

This class provides processing control methods.

A global instance is available via variable $ilCtrl

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 12 of file class.ilCtrl.php.

Constructor & Destructor Documentation

◆ __construct()

ilCtrl::__construct ( )

control class constructor

Definition at line 94 of file class.ilCtrl.php.

References initializeMemberVariables().

95  {
97 
98  // this information should go to xml files one day
99  $this->stored_trees = array("ilrepositorygui", "ilpersonaldesktopgui",
100  "illmpresentationgui", "illmeditorgui",
101  "iladministrationgui");
102  }
initializeMemberVariables()
Initialize member variables.
+ Here is the call graph for this function:

Member Function Documentation

◆ addTab()

ilCtrl::addTab (   $a_lang_var,
  $a_link,
  $a_cmd,
  $a_class 
)

Add a tab to tabs array (.

Deprecated:
use $ilTabs)
Parameters
string$a_lang_varlanguage variable
string$a_linklink
string$a_cmdcommand (must be same as in link)
string$a_classcommand class (must be same as in link)

Definition at line 473 of file class.ilCtrl.php.

474  {
475  $a_class = strtolower($a_class);
476 
477  $this->tab[] = array("lang_var" => $a_lang_var,
478  "link" => $a_link, "cmd" => $a_cmd, "class" => $a_class);
479  }

◆ appendRequestTokenParameterString()

ilCtrl::appendRequestTokenParameterString (   $a_url,
  $xml_style = true 
)

Append request token as url parameter.

Parameters
stringurl
booleanxml style

Definition at line 1073 of file class.ilCtrl.php.

References ilUtil\appendUrlParameterString(), and getRequestToken().

1074  {
1076  $a_url,
1077  self::IL_RTOKEN_NAME . '=' . $this->getRequestToken(),
1078  $xml_style
1079  );
1080  }
getRequestToken()
Get request token.
static appendUrlParameterString($a_url, $a_par, $xml_style=false)
append URL parameter string ("par1=value1&par2=value2...") to given URL string
+ Here is the call graph for this function:

◆ callBaseClass()

ilCtrl::callBaseClass ( )

Calls base class of current request.

The base class is passed via $_GET["baseClass"] and is the first class in the call sequence of the request. Do not call this method within other scripts than ilias.php.

Definition at line 130 of file class.ilCtrl.php.

References $_GET, $_SERVER, $DIC, $ilDB, $module, forwardCommand(), getCallStructure(), ilComponent\getComponentInfo(), and ilCachedCtrl\getInstance().

131  {
132  global $DIC;
133 
134  $ilDB = $DIC->database();
135 
136  $baseClass = strtolower($_GET["baseClass"]);
137 
138  $module_class = ilCachedCtrl::getInstance();
139  $mc_rec = $module_class->lookupModuleClass($baseClass);
140 
141  $module = $mc_rec["module"];
142  $class = $mc_rec["class"];
143  $class_dir = $mc_rec["dir"];
144 
145  if ($module != "") {
146  $m_set = $ilDB->query("SELECT * FROM il_component WHERE name = " .
147  $ilDB->quote($module, "text"));
148  $m_rec = $ilDB->fetchAssoc($m_set);
149  $this->module_dir = $m_rec["type"] . "/" . $m_rec["name"];
150  include_once $this->module_dir . "/" . $class_dir . "/class." . $class . ".php";
151  } else { // check whether class belongs to a service
152  $mc_rec = $module_class->lookupServiceClass($baseClass);
153 
154  $service = $mc_rec["service"];
155  $class = $mc_rec["class"];
156  $class_dir = $mc_rec["dir"];
157 
158  if ($service == "") {
159  include_once("./Services/UICore/exceptions/class.ilCtrlException.php");
160  throw new ilCtrlException("Could not find entry in modules.xml or services.xml for " .
161  $baseClass . " <br/>" . str_replace("&", "<br />&", htmlentities($_SERVER["REQUEST_URI"])));
162  }
163 
164  $m_rec = ilComponent::getComponentInfo('Services', $service);
165 
166  $this->service_dir = $m_rec["type"] . "/" . $m_rec["name"];
167 
168  include_once $this->service_dir . "/" . $class_dir . "/class." . $class . ".php";
169  ;
170  }
171 
172  // forward processing to base class
173  $this->getCallStructure(strtolower($baseClass));
174  $base_class_gui = new $class();
175  $this->forwardCommand($base_class_gui);
176  }
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
global $DIC
Definition: saml.php:7
$_GET["client_id"]
getCallStructure($a_class)
Get call structure of class context.
if($modEnd===false) $module
Definition: module.php:59
ilCtrl exceptions
global $ilDB
forwardCommand($a_gui_object)
Forward flow of control to next gui class this invokes the executeCommand() method of the gui object ...
static getComponentInfo($a_type, $a_name)
+ Here is the call graph for this function:

◆ callOfClassNotKnown()

ilCtrl::callOfClassNotKnown (   $a_class,
  $a_child 
)
private

Definition at line 1724 of file class.ilCtrl.php.

Referenced by fetchCallsOfClassFromCache().

1725  {
1726  return !isset($this->calls[$a_class])
1727  || !is_array($this->calls[$a_class])
1728  || !in_array($a_child, $this->calls[$a_class]);
1729  }
+ Here is the caller graph for this function:

◆ checkCurrentPathForClass()

ilCtrl::checkCurrentPathForClass (   $gui_class)

Check if current path contains a certain gui class.

Parameters
$gui_class
Returns
bool
Exceptions
ilCtrlException

Definition at line 1805 of file class.ilCtrl.php.

References getClassForCid(), and getCmdNode().

1806  {
1807  foreach (explode(":", $this->getCmdNode()) as $cid) {
1808  if ($cid != "" && strtolower($this->getClassForCid($cid)) == strtolower($gui_class)) {
1809  return true;
1810  }
1811  }
1812  return false;
1813  }
getCmdNode()
Get command target node.
getClassForCid($a_cid)
Get class for class id after fetching and storing corresponding information, if necessary.
+ Here is the call graph for this function:

◆ checkLPSettingsForward()

ilCtrl::checkLPSettingsForward (   $a_gui_obj,
  $a_cmd_node 
)
protected

Definition at line 671 of file class.ilCtrl.php.

References $_GET, $DIC, $GLOBALS, $type, ilObject\_lookupObjectId(), ilObjSAHSLearningModule\_lookupSubType(), ilObject\_lookupType(), getNodeIdForTargetClass(), ilObjectLP\isSupportedObjectType(), redirectByClass(), and setParameterByClass().

Referenced by getNextClass().

672  {
673  global $DIC;
674 
675  $objDefinition = $DIC["objDefinition"];
676 
677  // forward to learning progress settings if possible and accessible
678  if ($_GET["gotolp"] &&
679  $a_gui_obj) {
680  $ref_id = $_GET["ref_id"];
681  if (!$ref_id) {
682  $ref_id = $_REQUEST["ref_id"];
683  }
684 
685  $gui_class = get_class($a_gui_obj);
686 
687  if ($gui_class == "ilSAHSEditGUI") {
688  // #1625 - because of scorm "sub-types" this is all very special
689  include_once "./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php";
690  $obj_id = ilObject::_lookupObjectId($ref_id);
691  switch (ilObjSAHSLearningModule::_lookupSubType($obj_id)) {
692  case "scorm2004":
693  $class = "ilObjSCORM2004LearningModuleGUI";
694  break;
695 
696  case "scorm":
697  $class = "ilObjSCORMLearningModuleGUI";
698  break;
699 
700  case "aicc":
701  $class = "ilObjAICCLearningModuleGUI";
702  break;
703 
704  case "hacp":
705  $class = "ilObjHACPLearningModuleGUI";
706  break;
707  }
708  if ($GLOBALS["ilAccess"]->checkAccess("edit_learning_progress", "", $ref_id)) {
709  $this->redirectByClass(array($gui_class, $class, "illearningprogressgui", "illplistofsettingsgui"), "");
710  }
711  }
712  // special case: cannot use any presentation GUIs
713  elseif ($gui_class == "ilLMPresentationGUI") {
714  $this->setParameterByClass("ilObjLearningModuleGUI", "gotolp", 1);
715  $this->redirectByClass(array("ilLMEditorGUI", "ilObjLearningModuleGUI"), "");
716  }
717 
718  include_once "Services/Object/classes/class.ilObjectLP.php";
719  $type = ilObject::_lookupType($ref_id, true);
720  $class = "ilObj" . $objDefinition->getClassName($type) . "GUI";
721 
722  if ($gui_class == $class &&
724  $GLOBALS["ilAccess"]->checkAccess("edit_learning_progress", "", $ref_id)) {
725  // add path to repository object gui if missing from cmdNode
726  if (!$a_cmd_node) {
727  $repo_node = $this->getNodeIdForTargetClass(null, "ilrepositorygui");
728  $obj_node = $this->getNodeIdForTargetClass($repo_node["node_id"], $gui_class);
729  $a_cmd_node = $obj_node["node_id"];
730  }
731  // find path to lp settings
732  $lp_node = $this->getNodeIdForTargetClass($a_cmd_node, "illearningprogressgui");
733  $lp_settings_node = $this->getNodeIdForTargetClass($lp_node["node_id"], "illplistofsettingsgui");
734  $_GET["cmdNode"] = $lp_settings_node["node_id"];
735  $_GET["cmdClass"] = "ilLPListOfSettingsGUI";
736  $_GET["cmd"] = "";
737  return "illearningprogressgui";
738  }
739  }
740  }
$type
global $DIC
Definition: saml.php:7
$_GET["client_id"]
static isSupportedObjectType($a_type)
getNodeIdForTargetClass($a_par_node, $a_class, $a_check=false)
Searches a node for a given class ($a_class) "near" another node ($a_par_node).
static _lookupSubType($a_obj_id)
lookup subtype id (scorm, )
static _lookupObjectId($a_ref_id)
lookup object id
redirectByClass($a_class, $a_cmd="", $a_anchor="", $a_asynch=false)
Redirect to other gui class using class name.
static _lookupType($a_id, $a_reference=false)
lookup object type
setParameterByClass($a_class, $a_parameter, $a_value)
Same as setParameterByClass, except that a class name is passed.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkTargetClass()

ilCtrl::checkTargetClass (   $a_class)

Check whether target is valid.

Parameters

Definition at line 432 of file class.ilCtrl.php.

References getCidForClass(), and getNodeIdForTargetClass().

433  {
434  if (!is_array($a_class)) {
435  $a_class = array($a_class);
436  }
437 
438  $nr = $this->current_node;
439  foreach ($a_class as $class) {
440  $class = strtolower($class);
441 
442  if (!$this->getCidForClass($class, true)) {
443  return false;
444  }
445 
446  $nr = $this->getNodeIdForTargetClass($nr, $class, true);
447  $nr = $nr["node_id"];
448  if ($nr === false) {
449  return false;
450  }
451  }
452  return true;
453  }
getNodeIdForTargetClass($a_par_node, $a_class, $a_check=false)
Searches a node for a given class ($a_class) "near" another node ($a_par_node).
getCidForClass($a_class, $a_check=false)
Get class id for class after fetching and storing corresponding information, if necessary.
+ Here is the call graph for this function:

◆ cidClassUnknown()

ilCtrl::cidClassUnknown (   $a_cid)
private

Definition at line 1631 of file class.ilCtrl.php.

Referenced by getClassForCid().

1632  {
1633  return $this->cid_class[$a_cid] == "";
1634  }
+ Here is the caller graph for this function:

◆ classCidUnknown()

ilCtrl::classCidUnknown (   $a_class)
private

Definition at line 1603 of file class.ilCtrl.php.

Referenced by getCidForClass().

1604  {
1605  return $this->class_cid[$a_class] == "";
1606  }
+ Here is the caller graph for this function:

◆ clearParameterByClass()

ilCtrl::clearParameterByClass (   $a_class,
  $a_parameter 
)

Same as setParameterByClass, except that a class name is passed.

Parameters
string$a_classgui class name
string$a_parameterparameter name
string$a_parameterparameter value

Definition at line 644 of file class.ilCtrl.php.

645  {
646  unset($this->parameter[strtolower($a_class)][$a_parameter]);
647  }

◆ clearParameters()

ilCtrl::clearParameters (   $a_obj)

Clears all parameters that have been set via setParameter for a GUI class.

Parameters
object$a_objgui object

Definition at line 655 of file class.ilCtrl.php.

References clearParametersByClass().

656  {
657  $this->clearParametersByClass(strtolower(get_class($a_obj)));
658  }
clearParametersByClass($a_class)
Clears all parameters that have been set via setParameter for a GUI class.
+ Here is the call graph for this function:

◆ clearParametersByClass()

ilCtrl::clearParametersByClass (   $a_class)

Clears all parameters that have been set via setParameter for a GUI class.

Parameters
string$a_classgui class name

Definition at line 666 of file class.ilCtrl.php.

Referenced by clearParameters().

667  {
668  $this->parameter[strtolower($a_class)] = array();
669  }
+ Here is the caller graph for this function:

◆ fetchCallsOfClassFromCache()

ilCtrl::fetchCallsOfClassFromCache (   $a_class,
ilCachedCtrl  $a_cached_ctrl 
)
private

Definition at line 1652 of file class.ilCtrl.php.

References callOfClassNotKnown(), and ilCachedCtrl\lookupCall().

Referenced by readCidInfo(), and readClassInfo().

1653  {
1654  foreach ($a_cached_ctrl->lookupCall($a_class) as $call) {
1655  if ($call["child"] != "" && $this->callOfClassNotKnown($a_class, $call['child'])) {
1656  $this->calls[$a_class][] = $call["child"];
1657  }
1658  }
1659  }
callOfClassNotKnown($a_class, $a_child)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ forwardCommand()

ilCtrl::forwardCommand (   $a_gui_object)

Forward flow of control to next gui class this invokes the executeCommand() method of the gui object that is passed via reference.

Parameters
objectgui object that should receive the flow of control
Returns
mixed return data of invoked executeCommand() method

Definition at line 195 of file class.ilCtrl.php.

References $html, getCmd(), and getNodeIdForTargetClass().

Referenced by callBaseClass(), ilLTIRouterGUI\executeCommand(), ilObjectPermissionStatusGUI\executeCommand(), and ilChatroomInfoGUI\executeDefault().

196  {
197  $class = strtolower(get_class($a_gui_object));
198  $nr = $this->getNodeIdForTargetClass($this->current_node, $class);
199  $nr = $nr["node_id"];
200  if ($nr != "") {
201  $current_node = $this->current_node;
202 
203  $this->current_node = $nr;
204 
205  // always populate the call history
206  // it will only be displayed in DEVMODE but is needed for UI plugins, too
207  $this->call_hist[] = array("class" => get_class($a_gui_object),
208  "mode" => "execComm", "cmd" => $this->getCmd());
209 
210  $html = $a_gui_object->executeCommand();
211 
212  // reset current node
213  $this->current_node = $current_node;
214 
215  return $html;
216  }
217 
218  include_once("./Services/UICore/exceptions/class.ilCtrlException.php");
219  throw new ilCtrlException("ERROR: Can't forward to class $class.");
220  }
getNodeIdForTargetClass($a_par_node, $a_class, $a_check=false)
Searches a node for a given class ($a_class) "near" another node ($a_par_node).
getCmd($a_default_cmd="", $a_safe_commands="")
Determines current get/post command.
ilCtrl exceptions
$html
Definition: example_001.php:87
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCallHistory()

ilCtrl::getCallHistory ( )

Get controller call history.

This is used for the developer mode and presented in the footer

Returns
array array of call history entries

Definition at line 498 of file class.ilCtrl.php.

References $call_hist.

499  {
500  return $this->call_hist;
501  }
$call_hist
Stores the order in which different GUI classes were called.

◆ getCallStructure()

ilCtrl::getCallStructure (   $a_class)

Get call structure of class context.

This method must be called for the top level gui class in the leading php script. It must be called before the the current command is forwarded to the top level gui class. Example:

include_once "classes/class.ilRepositoryGUI.php"; $ilCtrl->getCallStructure("ilrepositorygui"); $repository_gui = new ilRepositoryGUI(); $ilCtrl->forwardCommand($repository_gui);

Parameters
string$a_classgui class name

public

Definition at line 518 of file class.ilCtrl.php.

References readClassInfo().

Referenced by callBaseClass(), and getNodeIdForTargetClass().

519  {
520  $this->readClassInfo($a_class);
521  }
readClassInfo($a_class)
Save class id respective to $a_class and store corresponding class calls for future reference...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCidForClass()

ilCtrl::getCidForClass (   $a_class,
  $a_check = false 
)
private

Get class id for class after fetching and storing corresponding information, if necessary.

Definition at line 1611 of file class.ilCtrl.php.

References classCidUnknown(), and readClassInfo().

Referenced by checkTargetClass(), and getNodeIdForTargetClass().

1612  {
1613  if ($this->classCidUnknown($a_class)) {
1614  $this->readClassInfo($a_class);
1615  }
1616  if ($this->classCidUnknown($a_class)) {
1617  if ($a_check) {
1618  return false;
1619  }
1620  if (DEVMODE == 1) {
1621  $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
1622  may solve the issue by putting an empty * @ilCtrl_Calls [YourClassName]: into your class header." .
1623  " In both cases you need to reload the control structure in the setup.";
1624  }
1625  include_once("./Services/UICore/exceptions/class.ilCtrlException.php");
1626  throw new ilCtrlException("Cannot find cid for class " . $a_class . "." . $add);
1627  }
1628  return $this->class_cid[$a_class];
1629  }
readClassInfo($a_class)
Save class id respective to $a_class and store corresponding class calls for future reference...
ilCtrl exceptions
classCidUnknown($a_class)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getClassForCid()

ilCtrl::getClassForCid (   $a_cid)
private

Get class for class id after fetching and storing corresponding information, if necessary.

Definition at line 1640 of file class.ilCtrl.php.

References cidClassUnknown(), and readCidInfo().

Referenced by checkCurrentPathForClass(), getNodeIdForTargetClass(), getParameterArrayByClass(), and searchReturnClass().

1641  {
1642  if ($this->cidClassUnknown($a_cid)) {
1643  $this->readCidInfo($a_cid);
1644  }
1645  if ($this->cidClassUnknown($a_cid)) {
1646  include_once("./Services/UICore/exceptions/class.ilCtrlException.php");
1647  throw new ilCtrlException("Cannot find class for cid " . $a_cid . ".");
1648  }
1649  return $this->cid_class[$a_cid];
1650  }
cidClassUnknown($a_cid)
readCidInfo($a_cid)
Save class respective to $a_cid and store corresponding class calls for future reference.
ilCtrl exceptions
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getClassForClasspath()

ilCtrl::getClassForClasspath (   $a_class_path)

this method assumes that the class path has the format "dir/class.<class_name>.php"

Parameters
string$a_class_pathclass path public
Returns
string class name

Definition at line 798 of file class.ilCtrl.php.

References $path.

799  {
800  $path = pathinfo($a_class_path);
801  $file = $path["basename"];
802  $class = substr($file, 6, strlen($file) - 10);
803 
804  return $class;
805  }
$path
Definition: aliased.php:25

◆ getCmd()

ilCtrl::getCmd (   $a_default_cmd = "",
  $a_safe_commands = "" 
)

Determines current get/post command.

Parameters
stringdefault command
arraysafe commands: for these commands no token is checked for post requests

Definition at line 896 of file class.ilCtrl.php.

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

Referenced by ilTestSignatureGUI\executeCommand(), ilObjectPermissionStatusGUI\executeCommand(), ilObjWorkflowEngineGUI\executeCommand(), forwardCommand(), and getHTML().

897  {
898  $cmd = "";
899  if (isset($_GET["cmd"])) {
900  $cmd = $_GET["cmd"];
901  }
902  if ($cmd == "post") {
903  if (isset($_POST["cmd"]) && is_array($_POST["cmd"])) {
904  reset($_POST["cmd"]);
905  }
906  $cmd = @key($_POST["cmd"]);
907 
908  // verify command
909  if ($this->verified_cmd != "") {
910  return $this->verified_cmd;
911  } else {
912  if (!$this->verifyToken() &&
913  (!is_array($a_safe_commands) || !in_array($cmd, $a_safe_commands))) {
914  return $a_default_cmd;
915  }
916  }
917 
918  $this->verified_cmd = $cmd;
919  if ($cmd == "" && isset($_POST["table_top_cmd"])) { // selected command in multi-list (table2)
920  $cmd = @key($_POST["table_top_cmd"]);
921  $this->verified_cmd = $cmd;
922  $_POST[$_POST["cmd_sv"][$cmd]] = $_POST[$_POST["cmd_sv"][$cmd] . "_2"];
923  }
924  if ($cmd == "" && isset($_POST["select_cmd2"])) { // selected command in multi-list (table2)
925  if (isset($_POST["select_cmd_all2"])) {
926  $_POST["select_cmd_all"] = $_POST["select_cmd_all2"];
927  } else {
928  $_POST["select_cmd_all"] = $_POST["select_cmd_all2"] = null;
929  }
930  $cmd = $_POST["selected_cmd2"];
931  $this->verified_cmd = $cmd;
932  }
933  if ($cmd == "" && isset($_POST["select_cmd"])) { // selected command in multi-list (table2)
934  if (isset($_POST["select_cmd_all"])) {
935  $_POST["select_cmd_all2"] = $_POST["select_cmd_all"];
936  } else {
937  $_POST["select_cmd_all"] = $_POST["select_cmd_all2"] = null;
938  }
939  $cmd = $_POST["selected_cmd"];
940  $this->verified_cmd = $cmd;
941  }
942  if ($cmd == "") {
943  $cmd = $_GET["fallbackCmd"];
944  $this->verified_cmd = $cmd;
945  }
946  }
947  if ($cmd == "") {
948  $cmd = $a_default_cmd;
949  }
950  return $cmd;
951  }
$_GET["client_id"]
verifyToken()
Verify Token.
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCmdClass()

ilCtrl::getCmdClass ( )

Determines class that should execute the current command.

Returns
string class name

Definition at line 992 of file class.ilCtrl.php.

References $_GET.

993  {
994  return strtolower($_GET["cmdClass"]);
995  }
$_GET["client_id"]

◆ getCmdNode()

ilCtrl::getCmdNode ( )

Get command target node.

Returns
string id of current command target node

Definition at line 460 of file class.ilCtrl.php.

References $_GET.

Referenced by checkCurrentPathForClass(), and getNextClass().

461  {
462  return $_GET["cmdNode"];
463  }
$_GET["client_id"]
+ Here is the caller graph for this function:

◆ getContextObjId()

ilCtrl::getContextObjId ( )

Get context object id.

Returns
int object id

Definition at line 288 of file class.ilCtrl.php.

289  {
290  return $this->context_obj_id;
291  }

◆ getContextObjType()

ilCtrl::getContextObjType ( )

Get context object type.

Returns
string object type

Definition at line 298 of file class.ilCtrl.php.

299  {
300  return $this->context_obj_type;
301  }

◆ getContextSubObjId()

ilCtrl::getContextSubObjId ( )

Get context subobject id.

Returns
int subobject id

Definition at line 308 of file class.ilCtrl.php.

309  {
310  return $this->context_sub_obj_id;
311  }

◆ getContextSubObjType()

ilCtrl::getContextSubObjType ( )

Get context subobject type.

Returns
string subobject type

Definition at line 318 of file class.ilCtrl.php.

319  {
320  return $this->context_sub_obj_type;
321  }

◆ getCurrentCidOfNode()

ilCtrl::getCurrentCidOfNode (   $a_node)
private

Get cid of node.

Definition at line 1758 of file class.ilCtrl.php.

Referenced by getNextClass(), getNodeIdForTargetClass(), and getParameterArrayByClass().

1759  {
1760  $n_arr = explode(":", $a_node);
1761  return $n_arr[count($n_arr) - 1];
1762  }
+ Here is the caller graph for this function:

◆ getFormAction()

ilCtrl::getFormAction (   $a_gui_obj,
  $a_fallback_cmd = "",
  $a_anchor = "",
  $a_asynch = false,
  $xml_style = true 
)

Get form action url for gui class object.

Parameters
objectgui object
stringfallback command
stringanchor
boolasynchronous call
boolxml style t/f
Returns
string script url

Definition at line 1007 of file class.ilCtrl.php.

References getFormActionByClass().

Referenced by ilWorkflowEngineDefinitionsTableGUI\__construct(), ilTestSkillLevelThresholdsTableGUI\__construct(), ilObjectPermissionStatusGUI\accessStatusInfo(), ilObjectPermissionStatusGUI\addToolbar(), ilChatroomHistoryGUI\byDay(), ilChatroomHistoryGUI\bySession(), ilChatroomAdminViewGUI\clientsettings(), ilChatroomAdminSmileyGUI\deleteMultipleObject(), ilChatroomSettingsGUI\general(), ilChatroomAdminSmileyGUI\initSmiliesEditForm(), ilChatroomAdminSmileyGUI\initSmiliesForm(), ilHistoryTableGUI\initTable(), ilChatroomAdminViewGUI\serversettings(), ilChatroomAdminSmileyGUI\showDeleteSmileyFormObject(), and ilChatroomViewGUI\showNameSelection().

1013  {
1014  $script = $this->getFormActionByClass(
1015  strtolower(get_class($a_gui_obj)),
1016  $a_fallback_cmd,
1017  $a_anchor,
1018  $a_asynch,
1019  $xml_style
1020  );
1021  return $script;
1022  }
getFormActionByClass( $a_class, $a_fallback_cmd="", $a_anchor="", $a_asynch=false, $xml_style=true)
Get form action url for gui class name.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFormActionByClass()

ilCtrl::getFormActionByClass (   $a_class,
  $a_fallback_cmd = "",
  $a_anchor = "",
  $a_asynch = false,
  $xml_style = true 
)

Get form action url for gui class name.

Parameters
stringgui class name
stringfallback command
stringanchor
boolasynchronous call
boolxml style t/f
Returns
string script url

Definition at line 1034 of file class.ilCtrl.php.

References ilUtil\appendUrlParameterString(), getLinkTargetByClass(), and getRequestToken().

Referenced by getFormAction().

1040  {
1041  if (!is_array($a_class)) {
1042  $a_class = strtolower($a_class);
1043  }
1044 
1045  $tok = $this->getRequestToken();
1046 
1047  if ($a_asynch) {
1048  $xml_style = false;
1049  }
1050 
1051  $script = $this->getLinkTargetByClass($a_class, "post", "", $a_asynch, $xml_style);
1052  if ($a_fallback_cmd != "") {
1053  $script = ilUtil::appendUrlParameterString($script, "fallbackCmd=" . $a_fallback_cmd, $xml_style);
1054  }
1056  $script,
1057  self::IL_RTOKEN_NAME . '=' . $this->getRequestToken(),
1058  $xml_style
1059  );
1060  if ($a_anchor != "") {
1061  $script = $script . "#" . $a_anchor;
1062  }
1063 
1064  return $script;
1065  }
getRequestToken()
Get request token.
static appendUrlParameterString($a_url, $a_par, $xml_style=false)
append URL parameter string ("par1=value1&par2=value2...") to given URL string
getLinkTargetByClass( $a_class, $a_cmd="", $a_anchor="", $a_asynch=false, $xml_style=true)
Get link target for command using gui class name.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getHTML()

ilCtrl::getHTML (   $a_gui_object,
array  $a_parameters = null 
)

Gets an HTML output from another GUI class and returns the flow of control to the calling class.

Parameters
object$a_gui_objectGUI class that implements getHTML() method to return its HTML
array | null$a_parametersparameter array
Returns
string
Exceptions
ilCtrlException

Definition at line 231 of file class.ilCtrl.php.

References $html, getCmd(), and getNodeIdForTargetClass().

232  {
233  $class = strtolower(get_class($a_gui_object));
234 
235  $nr = $this->getNodeIdForTargetClass($this->current_node, $class);
236  $nr = $nr["node_id"];
237  if ($nr != "") {
238  $current_node = $this->current_node;
239 
240  // set current node to new gui class
241  $this->current_node = $nr;
242 
243  // always populate the call history
244  // it will only be displayed in DEVMODE but is needed for UI plugins, too
245  $this->call_hist[] = array("class" => get_class($a_gui_object),
246  "mode" => "getHtml", "cmd" => $this->getCmd());
247 
248  // get block
249  if ($a_parameters != null) {
250  $html = $a_gui_object->getHTML($a_parameters);
251  } else {
252  $html = $a_gui_object->getHTML();
253  }
254 
255  // reset current node
256  $this->current_node = $current_node;
257 
258  // return block
259  return $html;
260  }
261 
262  include_once("./Services/UICore/exceptions/class.ilCtrlException.php");
263  throw new ilCtrlException("ERROR: Can't getHTML from class $class.");
264  }
getNodeIdForTargetClass($a_par_node, $a_class, $a_check=false)
Searches a node for a given class ($a_class) "near" another node ($a_par_node).
getCmd($a_default_cmd="", $a_safe_commands="")
Determines current get/post command.
ilCtrl exceptions
$html
Definition: example_001.php:87
+ Here is the call graph for this function:

◆ getLinkTarget()

ilCtrl::getLinkTarget (   $a_gui_obj,
  $a_cmd = "",
  $a_anchor = "",
  $a_asynch = false,
  $xml_style = true 
)

Get link target for command using gui object.

Parameters
objectgui object (usually $this)
stringcommand
string# anchor
booleanasynchronous mode
booleanxml style t/f
Returns
string target link

Definition at line 1334 of file class.ilCtrl.php.

References getLinkTargetByClass().

Referenced by ilWorkflowEngineDefinitionsTableGUI\fillRow(), ilObjWorkflowEngineGUI\initLocator(), ilObjWorkflowEngineGUI\prepareAdminOutput(), and ilChatroomViewGUI\showRoom().

1340  {
1341  $script = $this->getLinkTargetByClass(
1342  strtolower(get_class($a_gui_obj)),
1343  $a_cmd,
1344  $a_anchor,
1345  $a_asynch,
1346  $xml_style
1347  );
1348  return $script;
1349  }
getLinkTargetByClass( $a_class, $a_cmd="", $a_anchor="", $a_asynch=false, $xml_style=true)
Get link target for command using gui class name.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLinkTargetByClass()

ilCtrl::getLinkTargetByClass (   $a_class,
  $a_cmd = "",
  $a_anchor = "",
  $a_asynch = false,
  $xml_style = true 
)

Get link target for command using gui class name.

Parameters
string/arraycommand target class
stringcommand
string# anchor
booleanasynchronous mode
booleanxml style t/f
Returns
string target link

Definition at line 1363 of file class.ilCtrl.php.

References getTargetScript(), and getUrlParameters().

Referenced by ilObjectPermissionStatusGUI\addToolbar(), ilHistoryTableGUI\fillRow(), getFormActionByClass(), getLinkTarget(), ilObjWorkflowEngineGUI\prepareAdminOutput(), redirect(), redirectByClass(), and ilChatroomViewGUI\showRoom().

1369  {
1370  if ($a_asynch) {
1371  $xml_style = false;
1372  }
1373 
1374  $script = $this->getTargetScript();
1375  $script = $this->getUrlParameters($a_class, $script, $a_cmd, $xml_style);
1376 
1377  if ($a_asynch) {
1378  $amp = "&";
1379  $script .= $amp . "cmdMode=asynch";
1380  }
1381 
1382  if ($a_anchor != "") {
1383  $script = $script . "#" . $a_anchor;
1384  }
1385 
1386  return $script;
1387  }
getUrlParameters($a_class, $a_str, $a_cmd="", $xml_style=false)
Get URL parameters for a class and append them to a string.
getTargetScript()
Get target script name.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getModuleDir()

ilCtrl::getModuleDir ( )

get directory of current module

Definition at line 181 of file class.ilCtrl.php.

182  {
183  return $this->module_dir;
184  }

◆ getNextClass()

ilCtrl::getNextClass (   $a_gui_class = null)

Get next class in the control path from the current class to the target command class.

This is the class that should be instantiated and be invoked via $ilCtrl->forwardCommand($class) next.

Returns
string class name of next class

Definition at line 750 of file class.ilCtrl.php.

References $path, checkLPSettingsForward(), getCmdNode(), getCurrentCidOfNode(), getPathNew(), and readCidInfo().

Referenced by ilLTIRouterGUI\executeCommand(), ilTestSignatureGUI\executeCommand(), ilObjectPermissionStatusGUI\executeCommand(), and ilObjWorkflowEngineGUI\executeCommand().

751  {
752  $cmdNode = $this->getCmdNode();
753  if ($cmdNode == "") {
754  return ($class = $this->checkLPSettingsForward($a_gui_class, $cmdNode))
755  ? $class
756  : false;
757  } else {
758  if ($this->current_node == $cmdNode) {
759  return ($class = $this->checkLPSettingsForward($a_gui_class, $cmdNode))
760  ? $class
761  : "";
762  } else {
763  $path = $this->getPathNew($this->current_node, $cmdNode);
764  $this->readCidInfo($this->getCurrentCidOfNode($path[1]));
765  return $this->cid_class[$this->getCurrentCidOfNode($path[1])];
766  }
767  }
768  }
getCurrentCidOfNode($a_node)
Get cid of node.
$path
Definition: aliased.php:25
getCmdNode()
Get command target node.
checkLPSettingsForward($a_gui_obj, $a_cmd_node)
readCidInfo($a_cid)
Save class respective to $a_cid and store corresponding class calls for future reference.
getPathNew($a_source_node, $a_target_node)
Get path in call structure.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNodeIdForTargetClass()

ilCtrl::getNodeIdForTargetClass (   $a_par_node,
  $a_class,
  $a_check = false 
)
private

Searches a node for a given class ($a_class) "near" another node ($a_par_node).

It first looks if the given class is a child class of the current node. If such a child node has been found, its id is returned.

If not, this method determines, whether the given class is a sibling of the current node within the call structure. If this is the case, then the corresponding id is returned.

At last the method searches for the given class along the path from the current node to the root class of the call structure.

Parameters
stringid of starting node for the search
stringclass that should be searched
Returns
int id of target node that has been found

Definition at line 341 of file class.ilCtrl.php.

References Monolog\Handler\error_log(), getCallStructure(), getCidForClass(), getClassForCid(), getCurrentCidOfNode(), ilCachedCtrl\getInstance(), getParentCidOfNode(), readClassInfo(), readNodeInfo(), and removeLastCid().

Referenced by checkLPSettingsForward(), checkTargetClass(), forwardCommand(), getHTML(), getParameterArrayByClass(), searchReturnClass(), and setCmdClass().

342  {
343  $class = strtolower($a_class);
344  $this->readClassInfo($class);
345 
346  if ($a_par_node === 0 || $a_par_node == "") {
347  return array("node_id" => $this->getCidForClass($class),
348  "base_class" => "");
349  }
350 
351  $this->readNodeInfo($a_par_node);
352 
353  $node_cid = $this->getCurrentCidOfNode($a_par_node);
354 
355  // target class is class of current node id
356  if ($class == $this->getClassForCid($node_cid)) {
357  return array("node_id" => $a_par_node,
358  "base_class" => "");
359  }
360 
361  // target class is child of current node id
362  if (isset($this->calls[$this->getClassForCid($node_cid)]) &&
363  is_array($this->calls[$this->getClassForCid($node_cid)]) &&
364  in_array($a_class, $this->calls[$this->getClassForCid($node_cid)])) {
365  return array("node_id" => $a_par_node . ":" . $this->getCidForClass($class),
366  "base_class" => "");
367  }
368 
369  // target class is sibling
370  $par_cid = $this->getParentCidOfNode($a_par_node);
371  if ($par_cid != "") {
372  if (is_array($this->calls[$this->getClassForCid($par_cid)]) &&
373  in_array($a_class, $this->calls[$this->getClassForCid($par_cid)])) {
374  return array("node_id" =>
375  $this->removeLastCid($a_par_node) . ":" . $this->getCidForClass($class),
376  "base_class" => "");
377  }
378  }
379 
380  // target class is parent
381  $temp_node = $this->removeLastCid($a_par_node);
382  while ($temp_node != "") {
383  $temp_cid = $this->getCurrentCidOfNode($temp_node);
384  if ($this->getClassForCid($temp_cid) == $a_class) {
385  return array("node_id" => $temp_node,
386  "base_class" => "");
387  }
388  $temp_node = $this->removeLastCid($temp_node);
389  }
390 
391  // target class is another base class
392  $n_class = "";
393  if ($a_class != "") {
394  $module_class = ilCachedCtrl::getInstance();
395  $mc_rec = $module_class->lookupModuleClass($class);
396  $n_class = $mc_rec['lower_class'];
397 
398  if ($n_class == "") {
399  $mc_rec = $module_class->lookupServiceClass($class);
400  $n_class = $mc_rec['lower_class'];
401  }
402 
403  if ($n_class != "") {
404  $this->getCallStructure($n_class);
405  return array("node_id" => $this->getCidForClass($n_class),
406  "base_class" => $class);
407  }
408  }
409 
410  if ($a_check) {
411  return false;
412  }
413 
414  // Please do NOT change these lines.
415  // Developers must be aware, if they use classes unknown to the controller
416  // otherwise certain problem will be extremely hard to track down...
417 
418  error_log("ERROR: Can't find target class $a_class for node $a_par_node " .
419  "(" . $this->cid_class[$this->getParentCidOfNode($a_par_node)] . ")");
420 
421  include_once("./Services/UICore/exceptions/class.ilCtrlException.php");
422  throw new ilCtrlException("ERROR: Can't find target class $a_class for node $a_par_node " .
423  "(" . $this->cid_class[$this->getParentCidOfNode($a_par_node)] . ").");
424  }
getCurrentCidOfNode($a_node)
Get cid of node.
removeLastCid($a_node)
Remove the class id that comes at the beginning the sequence.
getParentCidOfNode($a_node)
Get 2nd to last class id of node.
getClassForCid($a_cid)
Get class for class id after fetching and storing corresponding information, if necessary.
getCallStructure($a_class)
Get call structure of class context.
getCidForClass($a_class, $a_check=false)
Get class id for class after fetching and storing corresponding information, if necessary.
readClassInfo($a_class)
Save class id respective to $a_class and store corresponding class calls for future reference...
readNodeInfo($a_node)
Save classes respective to the class id&#39;s of a node and store corresponding class calls for future re...
ilCtrl exceptions
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getParameterArray()

ilCtrl::getParameterArray (   $a_gui_obj,
  $a_cmd = "" 
)

Get all set/save parameters for a gui object.

Definition at line 1527 of file class.ilCtrl.php.

References getParameterArrayByClass().

1528  {
1529  $par_arr = $this->getParameterArrayByClass(strtolower(get_class($a_gui_obj)), $a_cmd);
1530 
1531  return $par_arr;
1532  }
getParameterArrayByClass($a_class, $a_cmd="")
Get all set/save parameters using gui class name.
+ Here is the call graph for this function:

◆ getParameterArrayByClass()

ilCtrl::getParameterArrayByClass (   $a_class,
  $a_cmd = "" 
)

Get all set/save parameters using gui class name.

Parameters
stringclass name
stringcmd $
Returns
array parameter array

Definition at line 1541 of file class.ilCtrl.php.

References $_GET, $_POST, PHPMailer\PHPMailer\$params, $path, getClassForCid(), getCurrentCidOfNode(), getNodeIdForTargetClass(), getPathNew(), and ilUtil\stripSlashesRecursive().

Referenced by getParameterArray(), and getUrlParameters().

1542  {
1543  if ($a_class == "") {
1544  return array();
1545  }
1546 
1547  if (!is_array($a_class)) {
1548  $a_class = array($a_class);
1549  }
1550 
1551  $nr = $this->current_node;
1552  $new_baseclass = "";
1553  foreach ($a_class as $class) {
1554  $class = strtolower($class);
1555  $nr = $this->getNodeIdForTargetClass($nr, $class);
1556  if ($nr["base_class"] != "") {
1557  $new_baseclass = $nr["base_class"];
1558  }
1559  $nr = $nr["node_id"];
1560  $target_class = $class;
1561  }
1562 
1563  $path = $this->getPathNew(1, $nr);
1564  $params = array();
1565 
1566  // append parameters of parent classes
1567  foreach ($path as $node_id) {
1568  $class = ($node_id == "")
1569  ? strtolower($_GET["baseClass"])
1570  : $this->getClassForCid($this->getCurrentCidOfNode($node_id));
1571  if (isset($this->save_parameter[$class]) && is_array($this->save_parameter[$class])) {
1572  foreach ($this->save_parameter[$class] as $par) {
1573  if (isset($_GET[$par])) {
1574  $params[$par] = $_GET[$par];
1575  } elseif (isset($_POST[$par])) {
1577  }
1578  }
1579  }
1580 
1581  if (isset($this->parameter[$class]) && is_array($this->parameter[$class])) {
1582  foreach ($this->parameter[$class] as $par => $value) {
1583  $params[$par] = $value;
1584  }
1585  }
1586  }
1587 
1588  if ($a_cmd != "") {
1589  $params["cmd"] = $a_cmd;
1590  }
1591 
1592  $params["cmdClass"] = $target_class;
1593  $params["cmdNode"] = $nr;
1594  if ($new_baseclass == "") {
1595  $params["baseClass"] = $_GET["baseClass"];
1596  } else {
1597  $params["baseClass"] = $new_baseclass;
1598  }
1599 
1600  return $params;
1601  }
getCurrentCidOfNode($a_node)
Get cid of node.
$path
Definition: aliased.php:25
$_GET["client_id"]
getNodeIdForTargetClass($a_par_node, $a_class, $a_check=false)
Searches a node for a given class ($a_class) "near" another node ($a_par_node).
getClassForCid($a_cid)
Get class for class id after fetching and storing corresponding information, if necessary.
getPathNew($a_source_node, $a_target_node)
Get path in call structure.
static stripSlashesRecursive($a_data, $a_strip_html=true, $a_allow="")
Strip slashes from array and sub-arrays.
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getParentCidOfNode()

ilCtrl::getParentCidOfNode (   $a_node)
private

Get 2nd to last class id of node.

Definition at line 1740 of file class.ilCtrl.php.

Referenced by getNodeIdForTargetClass().

1741  {
1742  $class_ids = explode(":", $a_node);
1743  return $class_ids[count($class_ids) - 2];
1744  }
+ Here is the caller graph for this function:

◆ getParentReturn()

ilCtrl::getParentReturn (   $a_gui_obj)

Get return script url.

Used in conjunction with ilTabs->setBackTarget and ilBlockGUI->addHeaderCommand.

Definition at line 1440 of file class.ilCtrl.php.

References getParentReturnByClass().

Referenced by returnToParent().

1441  {
1442  return $this->getParentReturnByClass(strtolower(get_class($a_gui_obj)));
1443  }
getParentReturnByClass($a_class)
Get return script url.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getParentReturnByClass()

ilCtrl::getParentReturnByClass (   $a_class)
protected

Get return script url.

Only used in getParentReturn.

Definition at line 1451 of file class.ilCtrl.php.

References searchReturnClass().

Referenced by getParentReturn().

1452  {
1453  $a_class = strtolower($a_class);
1454  $ret_class = $this->searchReturnClass($a_class);
1455  if ($ret_class) {
1456  return $this->return[$ret_class];
1457  }
1458  }
searchReturnClass($a_class)
Determine current return class.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPathNew()

ilCtrl::getPathNew (   $a_source_node,
  $a_target_node 
)
private

Get path in call structure.

Parameters
string$a_source_nodesource node id
string$a_source_nodetarget node id

Definition at line 813 of file class.ilCtrl.php.

References $failure, $GLOBALS, $path, and redirectToURL().

Referenced by getNextClass(), and getParameterArrayByClass().

814  {
815  if ($a_source_node == "1") {
816  $a_source_node = "";
817  }
818  if (substr($a_target_node, 0, strlen($a_source_node)) != $a_source_node) {
819  $failure = "ERROR: Path not found. Source:" . $a_source_node .
820  ", Target:" . $a_target_node;
821  if (DEVMODE == 1) {
822  include_once("./Services/UICore/exceptions/class.ilCtrlException.php");
823  throw new ilCtrlException($failure);
824  }
825  $GLOBALS['ilLog']->write(__METHOD__ . ' ' . $failure);
826  $this->redirectToURL('./ilias.php?baseClass=ilRepositoryGUI');
827  }
828  $temp_node = $a_source_node;
829 
830  $path = array();
831  if ($a_source_node != "") {
832  $path = array($a_source_node);
833  }
834 
835  $diffstart = ($a_source_node == "")
836  ? 0
837  : strlen($a_source_node) + 1;
838  $diff = substr($a_target_node, $diffstart);
839  $diff_arr = explode(":", $diff);
840  foreach ($diff_arr as $cid) {
841  if ($temp_node != "") {
842  $temp_node .= ":";
843  }
844  $temp_node .= $cid;
845  $path[] = $temp_node;
846  }
847  return $path;
848  }
$path
Definition: aliased.php:25
$failure
redirectToURL($a_script)
ilCtrl exceptions
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRedirectSource()

ilCtrl::getRedirectSource ( )

Get current redirect source.

Returns
string redirect source class

Definition at line 1503 of file class.ilCtrl.php.

References $_GET.

1504  {
1505  return $_GET["redirectSource"];
1506  }
$_GET["client_id"]

◆ getRequestToken()

ilCtrl::getRequestToken ( )

Get request token.

Returns
string request token for user and session

Definition at line 1087 of file class.ilCtrl.php.

References $DIC, $ilDB, $ilUser, $res, $rtoken, IL_CAL_DATETIME, IL_CAL_DAY, IL_CAL_HOUR, and IL_CAL_UNIX.

Referenced by appendRequestTokenParameterString(), and getFormActionByClass().

1088  {
1089  global $DIC;
1090 
1091  $ilUser = $DIC["ilUser"];
1092  $ilDB = $DIC->database();
1093 
1094 
1095  if ($this->rtoken != "") {
1096  return $this->rtoken;
1097  } else {
1098  if (is_object($ilDB) && is_object($ilUser) && $ilUser->getId() > 0 &&
1099  $ilUser->getId() != ANONYMOUS_USER_ID) {
1100  $res = $ilDB->query("SELECT token FROM il_request_token WHERE user_id = " .
1101  $ilDB->quote($ilUser->getId(), "integer") .
1102  " AND session_id = " . $ilDB->quote(session_id(), "text"));
1103  $rec = $ilDB->fetchAssoc($res);
1104  if ($rec["token"] != "") {
1105  $this->rtoken = $rec["token"];
1106  return $rec["token"];
1107  }
1108  //echo "new rtoken, new entry for :".$ilUser->getId().":".session_id().":"; exit;
1109  $random = new \ilRandom();
1110  $this->rtoken = md5(uniqid($random->int(), true));
1111 
1112  // delete entries older than one and a half days
1113  if ($random->int(1, 200) == 2) {
1114  $dt = new ilDateTime(time(), IL_CAL_UNIX);
1115  $dt->increment(IL_CAL_DAY, -1);
1116  $dt->increment(IL_CAL_HOUR, -12);
1117  $dq = "DELETE FROM il_request_token WHERE " .
1118  " stamp < " . $ilDB->quote($dt->get(IL_CAL_DATETIME), "timestamp");
1119  $ilDB->manipulate($dq);
1120  }
1121 
1122  // IMPORTANT: Please do NOT try to move this implementation to a
1123  // session basis. This will fail due to framesets that are used
1124  // occasionally in ILIAS, e.g. in the chat, where multiple
1125  // forms are loaded in different frames.
1126  $ilDB->manipulate("INSERT INTO il_request_token (user_id, token, stamp, session_id) VALUES " .
1127  "(" .
1128  $ilDB->quote($ilUser->getId(), "integer") . "," .
1129  $ilDB->quote($this->rtoken, "text") . "," .
1130  $ilDB->now() . "," .
1131  $ilDB->quote(session_id(), "text") . ")");
1132  return $this->rtoken;
1133  }
1134  }
1135  return "";
1136  }
const IL_CAL_DATETIME
global $DIC
Definition: saml.php:7
const IL_CAL_HOUR
const IL_CAL_UNIX
const IL_CAL_DAY
foreach($_POST as $key=> $value) $res
Date and time handling
$ilUser
Definition: imgupload.php:18
global $ilDB
+ Here is the caller graph for this function:

◆ getReturnClass()

ilCtrl::getReturnClass (   $a_class)

Get return class.

Only used in COPage/ilPCParagraphGUI and COPage/ilPCPlaceHolderGUI

Parameters
string | object$class
Returns
string|bool

Definition at line 1468 of file class.ilCtrl.php.

References searchReturnClass().

1469  {
1470  if (is_object($a_class)) {
1471  $class = strtolower(get_class($a_class));
1472  } else {
1473  $class = strtolower($a_class);
1474  }
1475  return $this->searchReturnClass($class);
1476  }
searchReturnClass($a_class)
Determine current return class.
+ Here is the call graph for this function:

◆ getTabs()

ilCtrl::getTabs ( )

Get tabs array (.

Deprecated:
, use $ilTabs)
Returns
array array of tab entries (array("lang_var", "link", "cmd", "class))

Definition at line 486 of file class.ilCtrl.php.

References $tab.

487  {
488  return $this->tab;
489  }

◆ getTargetScript()

ilCtrl::getTargetScript ( )

Get target script name.

Returns
string target script name

Definition at line 866 of file class.ilCtrl.php.

References $target_script.

Referenced by getLinkTargetByClass(), setReturn(), and setReturnByClass().

866  : string
867  {
868  return $this->target_script;
869  }
+ Here is the caller graph for this function:

◆ getUrlParameters()

ilCtrl::getUrlParameters (   $a_class,
  $a_str,
  $a_cmd = "",
  $xml_style = false 
)

Get URL parameters for a class and append them to a string.

Definition at line 1511 of file class.ilCtrl.php.

References PHPMailer\PHPMailer\$params, ilUtil\appendUrlParameterString(), and getParameterArrayByClass().

Referenced by getLinkTargetByClass(), setReturn(), and setReturnByClass().

1512  {
1513  $params = $this->getParameterArrayByClass($a_class, $a_cmd);
1514 
1515  foreach ($params as $par => $value) {
1516  if (strlen((string) $value)) {
1517  $a_str = ilUtil::appendUrlParameterString($a_str, $par . "=" . $value, $xml_style);
1518  }
1519  }
1520 
1521  return $a_str;
1522  }
getParameterArrayByClass($a_class, $a_cmd="")
Get all set/save parameters using gui class name.
static appendUrlParameterString($a_url, $a_par, $xml_style=false)
append URL parameter string ("par1=value1&par2=value2...") to given URL string
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initBaseClass()

ilCtrl::initBaseClass (   $a_base_class)

Initialises new base class.

Note: this resets the whole current ilCtrl context completely. You can call callBaseClass() after that.

Parameters
stringbase class name

Definition at line 880 of file class.ilCtrl.php.

References $_GET, and initializeMemberVariables().

881  {
882  $_GET["baseClass"] = $a_base_class;
883  $_GET["cmd"] = "";
884  $_GET["cmdClass"] = "";
885  $_GET["cmdNode"] = "";
886  $this->initializeMemberVariables();
887  }
$_GET["client_id"]
initializeMemberVariables()
Initialize member variables.
+ Here is the call graph for this function:

◆ initializeMemberVariables()

ilCtrl::initializeMemberVariables ( )
protected

Initialize member variables.

This is used in __construct and initBaseClass.

Returns
null

Definition at line 111 of file class.ilCtrl.php.

Referenced by __construct(), and initBaseClass().

112  {
113  $this->save_parameter = array();
114  $this->parameter = array(); // save parameter array
115  $this->return = array(); // return commmands
116  $this->tab = array();
117  $this->current_node = 0;
118  $this->module_dir = "";
119  $this->service_dir = "";
120  $this->call_node = array();
121  $this->root_class = "";
122  }
+ Here is the caller graph for this function:

◆ insertCtrlCalls()

ilCtrl::insertCtrlCalls (   $a_parent,
  $a_child,
  $a_comp_prefix 
)

Insert ctrl calls record.

Parameters

Definition at line 1770 of file class.ilCtrl.php.

References $DIC, and $ilDB.

1771  {
1772  global $DIC;
1773 
1774  $ilDB = $DIC->database();
1775  ;
1776 
1777  $a_parent = strtolower($a_parent);
1778  $a_child = strtolower($a_child);
1779  $a_comp_prefix = strtolower($a_comp_prefix);
1780 
1781  $set = $ilDB->query(
1782  "SELECT * FROM ctrl_calls WHERE " .
1783  " parent = " . $ilDB->quote($a_parent, "text") . " AND " .
1784  " child = " . $ilDB->quote($a_child, "text") . " AND " .
1785  " comp_prefix = " . $ilDB->quote($a_comp_prefix, "text")
1786  );
1787  if ($rec = $ilDB->fetchAssoc($set)) {
1788  return;
1789  }
1790  $ilDB->manipulate("INSERT INTO ctrl_calls " .
1791  "(parent, child, comp_prefix) VALUES (" .
1792  $ilDB->quote($a_parent, "text") . "," .
1793  $ilDB->quote($a_child, "text") . "," .
1794  $ilDB->quote($a_comp_prefix, "text") .
1795  ")");
1796  }
global $DIC
Definition: saml.php:7
global $ilDB

◆ isAsynch()

ilCtrl::isAsynch ( )

Is current command an asynchronous command?

Returns
boolean asynchronous t/f

Definition at line 1313 of file class.ilCtrl.php.

References $_GET.

1314  {
1315  if (isset($_GET["cmdMode"]) && $_GET["cmdMode"] == "asynch") {
1316  return true;
1317  } else {
1318  return false;
1319  }
1320  }
$_GET["client_id"]

◆ lookupClassPath()

ilCtrl::lookupClassPath (   $a_class_name)

Get class path that can be used in include statements for a given class name.

Parameters
string$a_class_nameclass name

Definition at line 776 of file class.ilCtrl.php.

References ilCachedCtrl\getInstance().

Referenced by ilLTIRouterGUI\executeCommand().

777  {
778  $a_class_name = strtolower($a_class_name);
779 
780  $cached_ctrl = ilCachedCtrl::getInstance();
781  $class_rec = $cached_ctrl->lookupClassFile($a_class_name);
782 
783  if ($class_rec["plugin_path"] != "") {
784  return $class_rec["plugin_path"] . "/" . $class_rec["filename"];
785  } else {
786  return $class_rec["filename"];
787  }
788  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readCallStructure()

ilCtrl::readCallStructure (   $a_class,
  $a_nr = 0,
  $a_parent = 0 
)

Reads call structure from db.

Definition at line 526 of file class.ilCtrl.php.

References $DIC, and $ilDB.

527  {
528  global $DIC;
529 
530  $ilDB = $DIC->database();
531 
532  $a_class = strtolower($a_class);
533 
534  $a_nr++;
535 
536  // determine call node structure
537  $this->call_node[$a_nr] = array("class" => $a_class, "parent" => $a_parent);
538 
539  $call_set = $ilDB->query("SELECT * FROM ctrl_calls WHERE parent = " .
540  $ilDB->quote(strtolower($a_class), "text") .
541  " ORDER BY child", array("text"));
542  $a_parent = $a_nr;
543  while ($call_rec = $ilDB->fetchAssoc($call_set)) {
544  $a_nr = $this->readCallStructure($call_rec["child"], $a_nr, $a_parent);
545  $forw[] = $call_rec["child"];
546  }
547 
548  // determine root class
549  $this->root_class = $a_class;
550  return $a_nr;
551  }
global $DIC
Definition: saml.php:7
global $ilDB
readCallStructure($a_class, $a_nr=0, $a_parent=0)
Reads call structure from db.

◆ readCidInfo()

ilCtrl::readCidInfo (   $a_cid)
private

Save class respective to $a_cid and store corresponding class calls for future reference.

Parameters
object$a_cidcid

Definition at line 1667 of file class.ilCtrl.php.

References fetchCallsOfClassFromCache(), ilCachedCtrl\getInstance(), and updateClassCidMap().

Referenced by getClassForCid(), getNextClass(), and readNodeInfo().

1668  {
1669  if (isset($this->info_read_cid[$a_cid])) {
1670  return;
1671  }
1672 
1673  $cached_ctrl = ilCachedCtrl::getInstance();
1674  $cid_info = $cached_ctrl->lookupCid($a_cid);
1675 
1676  if ($cid_info) {
1677  $this->updateClassCidMap($cid_info['class'], $a_cid);
1678  $this->fetchCallsOfClassFromCache($cid_info['class'], $cached_ctrl);
1679  $this->info_read_class[$cid_info["class"]] = true;
1680  }
1681 
1682  $this->info_read_cid[$a_cid] = true;
1683  }
updateClassCidMap($a_class, $a_cid)
fetchCallsOfClassFromCache($a_class, ilCachedCtrl $a_cached_ctrl)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readClassInfo()

ilCtrl::readClassInfo (   $a_class)
private

Save class id respective to $a_class and store corresponding class calls for future reference.

Parameters
object$a_classclass name

Definition at line 1705 of file class.ilCtrl.php.

References fetchCallsOfClassFromCache(), ilCachedCtrl\getInstance(), and updateClassCidMap().

Referenced by getCallStructure(), getCidForClass(), and getNodeIdForTargetClass().

1706  {
1707  $a_class = strtolower($a_class);
1708  if (isset($this->info_read_class[$a_class])) {
1709  return;
1710  }
1711 
1712  $cached_ctrl = ilCachedCtrl::getInstance();
1713  $class_info = $cached_ctrl->lookupClassFile($a_class);
1714 
1715  if ($class_info) {
1716  $this->updateClassCidMap($a_class, $class_info['cid']);
1717  }
1718  $this->fetchCallsOfClassFromCache($a_class, $cached_ctrl);
1719 
1720  $this->info_read_class[$a_class] = true;
1721  $this->info_read_cid[$this->class_cid[$a_class]] = true;
1722  }
updateClassCidMap($a_class, $a_cid)
fetchCallsOfClassFromCache($a_class, ilCachedCtrl $a_cached_ctrl)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readNodeInfo()

ilCtrl::readNodeInfo (   $a_node)
private

Save classes respective to the class id's of a node and store corresponding class calls for future reference.

Parameters
string$a_node

Definition at line 1691 of file class.ilCtrl.php.

References readCidInfo().

Referenced by getNodeIdForTargetClass().

1692  {
1693  $class_ids = explode(":", $a_node);
1694  foreach ($class_ids as $cid) {
1695  $this->readCidInfo($cid);
1696  }
1697  }
readCidInfo($a_cid)
Save class respective to $a_cid and store corresponding class calls for future reference.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ redirect()

ilCtrl::redirect (   $a_gui_obj,
  $a_cmd = "",
  $a_anchor = "",
  $a_asynch = false 
)

Redirect to another command.

Parameters
objectgui object
stringcommand
stringanchor

Definition at line 1217 of file class.ilCtrl.php.

References getLinkTargetByClass(), and redirectToURL().

Referenced by ilChatroomAdminSmileyGUI\confirmedDeleteMultipleObject(), ilChatroomBanGUI\delete(), ilChatroomAdminSmileyGUI\deleteMultipleObject(), ilChatroomAdminSmileyGUI\deleteSmileyObject(), ilChatroomAdminViewGUI\executeDefault(), ilChatroomViewGUI\executeDefault(), ilChatroomViewGUI\invitePD(), ilChatroomCreateGUI\save(), ilChatroomAdminViewGUI\saveClientSettings(), ilChatroomSettingsGUI\saveGeneral(), and ilChatroomAdminViewGUI\saveSettings().

1218  {
1219  $script = $this->getLinkTargetByClass(
1220  strtolower(get_class($a_gui_obj)),
1221  $a_cmd,
1222  "",
1223  $a_asynch,
1224  false
1225  );
1226  if ($a_anchor != "") {
1227  $script = $script . "#" . $a_anchor;
1228  }
1229  $this->redirectToURL($script);
1230  }
redirectToURL($a_script)
getLinkTargetByClass( $a_class, $a_cmd="", $a_anchor="", $a_asynch=false, $xml_style=true)
Get link target for command using gui class name.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ redirectByClass()

ilCtrl::redirectByClass (   $a_class,
  $a_cmd = "",
  $a_anchor = "",
  $a_asynch = false 
)

Redirect to other gui class using class name.

Parameters
stringcommand target class
stringcommand

Definition at line 1299 of file class.ilCtrl.php.

References getLinkTargetByClass(), and redirectToURL().

Referenced by checkLPSettingsForward(), ilChatroomSettingsGUI\general(), ilChatroomViewGUI\logout(), ilChatroomViewGUI\lostConnection(), ilChatroomGUIHandler\redirectIfNoPermission(), ilChatroomViewGUI\showRoom(), and ilChatroomKickGUI\sub().

1300  {
1301  $script = $this->getLinkTargetByClass($a_class, $a_cmd, "", $a_asynch, false);
1302  if ($a_anchor != "") {
1303  $script = $script . "#" . $a_anchor;
1304  }
1305  $this->redirectToURL($script);
1306  }
redirectToURL($a_script)
getLinkTargetByClass( $a_class, $a_cmd="", $a_anchor="", $a_asynch=false, $xml_style=true)
Get link target for command using gui class name.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ redirectToURL()

ilCtrl::redirectToURL (   $a_script)
Parameters
$a_script

Definition at line 1236 of file class.ilCtrl.php.

References $_SERVER, $DIC, $http, GuzzleHttp\Psr7\$stream, exit, ilPluginAdmin\getPluginObject(), IL_COMP_SERVICE, ilUIHookPluginGUI\KEEP, and ILIAS\Filesystem\Stream\Streams\ofString().

Referenced by getPathNew(), redirect(), redirectByClass(), and returnToParent().

1237  {
1238  global $DIC;
1239 
1240  $ilPluginAdmin = null;
1241  if (isset($DIC["ilPluginAdmin"])) {
1242  $ilPluginAdmin = $DIC["ilPluginAdmin"];
1243  }
1244 
1245  if (!is_int(strpos($a_script, "://"))) {
1246  if (substr($a_script, 0, 1) != "/" && defined("ILIAS_HTTP_PATH")) {
1247  if (is_int(strpos($_SERVER["PHP_SELF"], "/setup/"))) {
1248  $a_script = "setup/" . $a_script;
1249  }
1250  $a_script = ILIAS_HTTP_PATH . "/" . $a_script;
1251  }
1252  }
1253 
1254  // include the user interface hook
1255  if (is_object($ilPluginAdmin)) {
1256  $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "UIComponent", "uihk");
1257  foreach ($pl_names as $pl) {
1258  $ui_plugin = ilPluginAdmin::getPluginObject(IL_COMP_SERVICE, "UIComponent", "uihk", $pl);
1259  $gui_class = $ui_plugin->getUIClassInstance();
1260  $resp = $gui_class->getHTML("Services/Utilities", "redirect", array( "html" => $a_script ));
1261  if ($resp["mode"] != ilUIHookPluginGUI::KEEP) {
1262  $a_script = $gui_class->modifyHTML($a_script, $resp);
1263  }
1264  }
1265  }
1266 
1267  // Manually trigger to write and close the session. This has the advantage that if an exception is thrown
1268  // during the writing of the session (ILIAS writes the session into the database by default) we get an exception
1269  // if the session_write_close() is triggered by exit() then the exception will be dismissed but the session
1270  // is never written, which is a nightmare to develop with.
1271  session_write_close();
1272 
1273  global $DIC;
1274  $http = $DIC->http();
1275  switch ($http->request()->getHeaderLine('Accept')) {
1276  case 'application/json':
1278  'success' => true,
1279  'message' => 'Called redirect after async fileupload request',
1280  "redirect_url" => $a_script,
1281  ]));
1282  $http->saveResponse($http->response()->withBody($stream));
1283  break;
1284  default:
1285  $http->saveResponse($http->response()->withAddedHeader("Location", $a_script));
1286  break;
1287  }
1288  $http->sendResponse();
1289  exit;
1290  }
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
global $DIC
Definition: saml.php:7
$stream
PHP stream implementation.
static ofString($string)
Creates a new stream with an initial value.
Definition: Streams.php:30
static getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get Plugin Object.
$http
Definition: raiseError.php:7
exit
Definition: backend.php:16
const IL_COMP_SERVICE
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeLastCid()

ilCtrl::removeLastCid (   $a_node)
private

Remove the class id that comes at the beginning the sequence.

Definition at line 1749 of file class.ilCtrl.php.

Referenced by getNodeIdForTargetClass().

1750  {
1751  $lpos = strrpos($a_node, ":");
1752  return substr($a_node, 0, $lpos);
1753  }
+ Here is the caller graph for this function:

◆ returnToParent()

ilCtrl::returnToParent (   $a_gui_obj,
  $a_anchor = "" 
)

Redirects to next parent class that used setReturn.

Definition at line 1415 of file class.ilCtrl.php.

References $_GET, ilUtil\appendUrlParameterString(), getParentReturn(), and redirectToURL().

1416  {
1417  $script = $this->getParentReturn($a_gui_obj);
1418 
1420  $script,
1421  "redirectSource=" . strtolower(get_class($a_gui_obj))
1422  );
1424  $script,
1425  "cmdMode=" . $_GET["cmdMode"]
1426  );
1427  if ($a_anchor != "") {
1428  $script = $script . "#" . $a_anchor;
1429  }
1430 
1431  $this->redirectToURL($script);
1432  }
redirectToURL($a_script)
$_GET["client_id"]
static appendUrlParameterString($a_url, $a_par, $xml_style=false)
append URL parameter string ("par1=value1&par2=value2...") to given URL string
getParentReturn($a_gui_obj)
Get return script url.
+ Here is the call graph for this function:

◆ saveParameter()

ilCtrl::saveParameter (   $a_obj,
  $a_parameter 
)

Set parameters that should be passed in every form and link of a gui class.

All links that relate to the specified gui object class and are build e.g. by using getLinkTarger() or getFormAction() will include this parameter. This is the mechanism to add url parameters to the standard url target everytime.

A typical example is the "ref_id" that should be included in almost every link or form action url. So the constructor of ilRepositoryGUI includes the command:

$this->ctrl->saveParameter($this, array("ref_id"));

Parameters
object$a_objgui object that will process the parameter
mixed$a_parameterparameter name (string) or array of parameter names

public

Definition at line 572 of file class.ilCtrl.php.

References saveParameterByClass().

Referenced by ilChatroomAdminSmileyGUI\initSmiliesEditForm(), and ilChatroomViewGUI\showNameSelection().

573  {
574  if (is_object($a_obj)) {
575  $this->saveParameterByClass(get_class($a_obj), $a_parameter);
576  }
577  }
saveParameterByClass($a_class, $a_parameter)
Save parameter for a class.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveParameterByClass()

ilCtrl::saveParameterByClass (   $a_class,
  $a_parameter 
)

Save parameter for a class.

Parameters
stringclass name
stringparameter name

Definition at line 585 of file class.ilCtrl.php.

References $parameter.

Referenced by saveParameter().

586  {
587  if (is_array($a_parameter)) {
588  foreach ($a_parameter as $parameter) {
589  $this->save_parameter[strtolower($a_class)][] = $parameter;
590  }
591  } else {
592  $this->save_parameter[strtolower($a_class)][] = $a_parameter;
593  }
594  }
+ Here is the caller graph for this function:

◆ searchReturnClass()

ilCtrl::searchReturnClass (   $a_class)
private

Determine current return class.

Definition at line 1482 of file class.ilCtrl.php.

References $i, getClassForCid(), and getNodeIdForTargetClass().

Referenced by getParentReturnByClass(), and getReturnClass().

1483  {
1484  $a_class = strtolower($a_class);
1485 
1486  $node = $this->getNodeIdForTargetClass($this->current_node, $a_class);
1487  $node = $node["node_id"];
1488  $n_arr = explode(":", $node);
1489  for ($i = count($n_arr) - 2; $i >= 0; $i--) {
1490  if ($this->return[$this->getClassForCid($n_arr[$i])] != "") {
1491  return $this->getClassForCid($n_arr[$i]);
1492  }
1493  }
1494 
1495  return false;
1496  }
getNodeIdForTargetClass($a_par_node, $a_class, $a_check=false)
Searches a node for a given class ($a_class) "near" another node ($a_par_node).
getClassForCid($a_cid)
Get class for class id after fetching and storing corresponding information, if necessary.
$i
Definition: disco.tpl.php:19
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCmd()

ilCtrl::setCmd (   $a_cmd)

Set the current command.

IMPORTANT NOTE:

please use this function only in exceptional cases it is not intended for setting commands in forms or links! use the corresponding parameters of getFormAction() and getLinkTarget() instead.

Definition at line 963 of file class.ilCtrl.php.

References $_GET.

Referenced by ilChatroomInfoGUI\executeDefault().

964  {
965  $_GET["cmd"] = $a_cmd;
966  }
$_GET["client_id"]
+ Here is the caller graph for this function:

◆ setCmdClass()

ilCtrl::setCmdClass (   $a_cmd_class)

Set the current command class.

IMPORTANT NOTE:

please use this function only in exceptional cases it is not intended for setting the command class in forms or links! use the corresponding parameters of getFormAction() and getLinkTarget() instead.

Definition at line 978 of file class.ilCtrl.php.

References $_GET, and getNodeIdForTargetClass().

979  {
980  $a_cmd_class = strtolower($a_cmd_class);
981  $nr = $this->getNodeIdForTargetClass($this->current_node, $a_cmd_class);
982  $nr = $nr["node_id"];
983  $_GET["cmdClass"] = $a_cmd_class;
984  $_GET["cmdNode"] = $nr;
985  }
$_GET["client_id"]
getNodeIdForTargetClass($a_par_node, $a_class, $a_check=false)
Searches a node for a given class ($a_class) "near" another node ($a_par_node).
+ Here is the call graph for this function:

◆ setContext()

ilCtrl::setContext (   $a_obj_id,
  $a_obj_type,
  $a_sub_obj_id = 0,
  $a_sub_obj_type = "" 
)

Set context of current user interface.

A context is a ILIAS repository object (obj ID + obj type) with an additional optional subobject (ID + Type)

Parameters
integerobject ID
stringobject type
integersubobject ID
stringsubobject type

Definition at line 275 of file class.ilCtrl.php.

276  {
277  $this->context_obj_id = $a_obj_id;
278  $this->context_obj_type = $a_obj_type;
279  $this->context_sub_obj_id = $a_sub_obj_id;
280  $this->context_sub_obj_type = $a_sub_obj_type;
281  }

◆ setParameter()

ilCtrl::setParameter (   $a_obj,
  $a_parameter,
  $a_value 
)

Set parameters that should be passed a form and link of a gui class.

All links that relate to the specified gui object class and are build e.g. by using getLinkTarger() or getFormAction() will include this parameter. This is the mechanism to add url parameters to the standard url target. The difference to the saveParameter() method is, that setParameter() does not simply forward the url parameter of the last request. You can set a spefific value.

If this parameter is also a "saved parameter" (set by saveParameter() method) the saved value will be overwritten.

The method is usually used in conjunction with a getFormAction() or getLinkTarget() call. E.g.:

    $this->ctrl->setParameter($this, "obj_id", $data_row["obj_id"]);
    $obj_link = $this->ctrl->getLinkTarget($this, "view");
Parameters
object$a_objgui object
string$a_parameterparameter name
string$a_parameterparameter value

Definition at line 619 of file class.ilCtrl.php.

Referenced by ilWorkflowEngineDefinitionsTableGUI\fillRow(), ilObjWorkflowEngineGUI\initLocator(), ilChatroomViewGUI\invitePD(), and ilChatroomCreateGUI\save().

620  {
621  $this->parameter[strtolower(get_class($a_obj))][$a_parameter] = $a_value;
622  }
+ Here is the caller graph for this function:

◆ setParameterByClass()

ilCtrl::setParameterByClass (   $a_class,
  $a_parameter,
  $a_value 
)

Same as setParameterByClass, except that a class name is passed.

Parameters
string$a_classgui class name
string$a_parameterparameter name
string$a_parameterparameter value

Definition at line 632 of file class.ilCtrl.php.

Referenced by checkLPSettingsForward(), ilHistoryTableGUI\fillRow(), ilChatroomSettingsGUI\general(), ilChatroomViewGUI\logout(), ilChatroomGUIHandler\redirectIfNoPermission(), and ilChatroomKickGUI\sub().

633  {
634  $this->parameter[strtolower($a_class)][$a_parameter] = $a_value;
635  }
+ Here is the caller graph for this function:

◆ setReturn()

ilCtrl::setReturn (   $a_gui_obj,
  $a_cmd 
)

Set return command.

Definition at line 1392 of file class.ilCtrl.php.

References getTargetScript(), and getUrlParameters().

Referenced by ilObjectPermissionStatusGUI\executeCommand().

1393  {
1394  $script = $this->getTargetScript();
1395  $script = $this->getUrlParameters(strtolower(get_class($a_gui_obj)), $script, $a_cmd);
1396  $this->return[strtolower(get_class($a_gui_obj))] = $script;
1397  }
getUrlParameters($a_class, $a_str, $a_cmd="", $xml_style=false)
Get URL parameters for a class and append them to a string.
getTargetScript()
Get target script name.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setReturnByClass()

ilCtrl::setReturnByClass (   $a_class,
  $a_cmd 
)

Set return command.

Definition at line 1402 of file class.ilCtrl.php.

References getTargetScript(), and getUrlParameters().

1403  {
1404  // may not be an array!
1405  $a_class = strtolower($a_class);
1406 
1407  $script = $this->getTargetScript();
1408  $script = $this->getUrlParameters($a_class, $script, $a_cmd);
1409  $this->return[strtolower($a_class)] = $script;
1410  }
getUrlParameters($a_class, $a_str, $a_cmd="", $xml_style=false)
Get URL parameters for a class and append them to a string.
getTargetScript()
Get target script name.
+ Here is the call graph for this function:

◆ setTargetScript()

ilCtrl::setTargetScript ( string  $a_target_script)

set target script name

Parameters
string$a_target_scripttarget script name

Definition at line 855 of file class.ilCtrl.php.

856  {
857  $this->target_script = $a_target_script;
858  }

◆ updateClassCidMap()

ilCtrl::updateClassCidMap (   $a_class,
  $a_cid 
)
private

Definition at line 1731 of file class.ilCtrl.php.

Referenced by readCidInfo(), and readClassInfo().

1732  {
1733  $this->cid_class[$a_cid] = $a_class;
1734  $this->class_cid[$a_class] = $a_cid;
1735  }
+ Here is the caller graph for this function:

◆ verifyToken()

ilCtrl::verifyToken ( )
private

Verify Token.

Returns
boolean valid t/f

Definition at line 1143 of file class.ilCtrl.php.

References $_GET, $_SESSION, $DIC, $ilDB, $ilUser, $time, IL_CAL_DATETIME, IL_CAL_DAY, IL_CAL_HOUR, and IL_CAL_UNIX.

Referenced by getCmd().

1144  {
1145  global $DIC;
1146 
1147  $ilUser = $DIC["ilUser"];
1148 
1149  $ilDB = $DIC->database();
1150  ;
1151 
1152  if (is_object($ilUser) && is_object($ilDB) && $ilUser->getId() > 0 &&
1153  $ilUser->getId() != ANONYMOUS_USER_ID) {
1154  if ($_GET["rtoken"] == "") {
1155  return false;
1156  }
1157 
1158  $set = $ilDB->query("SELECT * FROM il_request_token WHERE " .
1159  " user_id = " . $ilDB->quote($ilUser->getId(), "integer") . " AND " .
1160  " token = " . $ilDB->quote($_GET[self::IL_RTOKEN_NAME]), "text");
1161  if ($ilDB->numRows($set) > 0) {
1162  // remove tokens from older sessions
1163  // if we do this immediately, working with multiple windows does not work:
1164  // - window one: open form (with token a)
1165  // - window two: open form (with token b)
1166  // - submit window one: a is verified, but b must not be deleted immediately, otherwise
1167  // - window two: submit results in invalid token
1168  // see also bug #13551
1169  $dt = new ilDateTime(time(), IL_CAL_UNIX);
1170  $dt->increment(IL_CAL_DAY, -1);
1171  $dt->increment(IL_CAL_HOUR, -12);
1172  $ilDB->manipulate("DELETE FROM il_request_token WHERE " .
1173  " user_id = " . $ilDB->quote($ilUser->getId(), "integer") . " AND " .
1174  " session_id != " . $ilDB->quote(session_id(), "text") . " AND " .
1175  " stamp < " . $ilDB->quote($dt->get(IL_CAL_DATETIME), "timestamp"));
1176  return true;
1177  } else {
1178  return false;
1179  }
1180 
1181  if ($_SESSION["rtokens"][$_GET[self::IL_RTOKEN_NAME]] != "") {
1182  // remove used token
1183  unset($_SESSION["rtokens"][$_GET[self::IL_RTOKEN_NAME]]);
1184 
1185  // remove old tokens
1186  if (count($_SESSION["rtokens"]) > 100) {
1187  $to_remove = array();
1188  $sec = 7200; // two hours
1189 
1190  foreach ($_SESSION["rtokens"] as $tok => $time) {
1191  if (time() - $time > $sec) {
1192  $to_remove[] = $tok;
1193  }
1194  }
1195  foreach ($to_remove as $tok) {
1196  unset($_SESSION["rtokens"][$tok]);
1197  }
1198  }
1199 
1200  return true;
1201  }
1202  return false;
1203  } else {
1204  return true; // do not verify, if user or db object is missing
1205  }
1206 
1207  return false;
1208  }
const IL_CAL_DATETIME
$_SESSION["AccountId"]
global $DIC
Definition: saml.php:7
$_GET["client_id"]
const IL_CAL_HOUR
const IL_CAL_UNIX
$time
Definition: cron.php:21
const IL_CAL_DAY
Date and time handling
$ilUser
Definition: imgupload.php:18
global $ilDB
+ Here is the caller graph for this function:

Field Documentation

◆ $call_hist

ilCtrl::$call_hist = array()
protected

Stores the order in which different GUI classes were called.

TODO: Might better be called call_stack.

This is used in: forwardCommand, getHTML, getCallHistory

Definition at line 67 of file class.ilCtrl.php.

Referenced by getCallHistory().

◆ $calls

ilCtrl::$calls = array()
protected

Stores which class calls which other class.

This is used in: getNodeIdForTargetClass, fetchCallsOfClassFromCache, callOfClassNotKnown

Definition at line 74 of file class.ilCtrl.php.

◆ $db

ilCtrl::$db
protected

Definition at line 17 of file class.ilCtrl.php.

◆ $parameter

ilCtrl::$parameter
protected

Definition at line 47 of file class.ilCtrl.php.

Referenced by saveParameterByClass().

◆ $plugin_admin

ilCtrl::$plugin_admin
protected

Definition at line 23 of file class.ilCtrl.php.

◆ $return

ilCtrl::$return
protected

Definition at line 58 of file class.ilCtrl.php.

◆ $rtoken

ilCtrl::$rtoken = false
protected

Definition at line 83 of file class.ilCtrl.php.

Referenced by getRequestToken().

◆ $save_parameter

ilCtrl::$save_parameter
protected

Definition at line 36 of file class.ilCtrl.php.

◆ $target_script

ilCtrl::$target_script = "ilias.php"
protected

Definition at line 89 of file class.ilCtrl.php.

Referenced by getTargetScript().

◆ IL_RTOKEN_NAME

const ilCtrl::IL_RTOKEN_NAME = 'rtoken'

Definition at line 25 of file class.ilCtrl.php.


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