ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilCtrl Class Reference

This class provides processing control methods. More...

+ Inheritance diagram for ilCtrl:
+ Collaboration diagram for ilCtrl:

Public Member Functions

 ilCtrl ()
 control class constructor
 debug ($str)
 Collect debugging strings (.
 getDebug ()
 Get debug message string (.
 init ()
 initialisation
 callBaseClass ()
 Calls base class of current request.
 getModuleDir ()
 get directory of current module
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.
getHTML (&$a_gui_object)
 Gets an HTML output from another GUI class and returns the flow of control to the calling class.
 setContext ($a_obj_id, $a_obj_type, $a_sub_obj_id=0, $a_sub_obj_type="")
 Set context of current user interface.
 getContextObjId ()
 Get context object id.
 getContextObjType ()
 Get context object type.
 getContextSubObjId ()
 Get context subobject id.
 getContextSubObjType ()
 Get context subobject type.
 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).
 checkTargetClass ($a_class)
 Check whether target is valid.
 getCmdNode ()
 Get command target node.
 addLocation ($a_title, $a_link, $a_target="", $a_ref_id=0)
 Add a location to the locator array (.
 getLocations ()
 Get locations array (.
 addTab ($a_lang_var, $a_link, $a_cmd, $a_class)
 Add a tab to tabs array (.
 getTabs ()
 Get tabs array (.
 getCallHistory ()
 Get controller call history.
 getCallStructure ($a_class)
 Get call structure of class context.
 readCallStructure ($a_class, $a_nr=0, $a_parent=0)
 stores often used common call structures (called from db_update script!!!)
 saveParameter (&$a_obj, $a_parameter)
 Set parameters that should be passed in every form and link of a gui class.
 saveParameterByClass ($a_class, $a_parameter)
 Save parameter for a class.
 setParameter (&$a_obj, $a_parameter, $a_value)
 Set parameters that should be passed a form and link of a gui class.
 setParameterByClass ($a_class, $a_parameter, $a_value)
 Same as setParameterByClass, except that a class name is passed.
 clearParameters (&$a_obj)
 Clears all parameters that have been set via setParameter for a GUI class.
 clearParametersByClass ($a_class)
 Clears all parameters that have been set via setParameter for a GUI class.
 getNextClass ()
 Get next class in the control path from the current class to the target command class.
 lookupClassPath ($a_class_name)
 Get class path that can be used in include statements for a given class name.
 getClassForClasspath ($a_class_path)
 this method assumes that the class path has the format "dir/class.<class_name>.php"
 setTargetScript ($a_target_script)
 set target script name
 getTargetScript ()
 Get target script name.
 initBaseClass ($a_base_class)
 Initialises new base class.
 getCmd ($a_default_cmd="", $a_safe_commands="")
 Determines current get/post command.
 setCmd ($a_cmd)
 Set the current command.
 setCmdClass ($a_cmd_class)
 Set the current command class.
 getCmdClass ()
 Determines class that should execute the current command.
 getFormAction (&$a_gui_obj, $a_fallback_cmd="", $a_anchor="", $a_asynch=false, $xml_style=true)
 Get form action url for gui class object.
 getFormActionByClass ($a_class, $a_fallback_cmd="", $a_anchor="", $a_asynch=false, $xml_style=true)
 Get form action url for gui class name.
 appendRequestTokenParameterString ($a_url, $xml_style=true)
 Append request token as url parameter.
 getRequestToken ()
 Get request token.
 redirect (&$a_gui_obj, $a_cmd="", $a_anchor="", $a_asynch=false)
 Redirect to another command.
 redirectByClass ($a_class, $a_cmd="", $a_anchor="", $a_asynch=false)
 Redirect to other gui class using class name.
 isAsynch ()
 Is current command an asynchronous command?
 getLinkTarget (&$a_gui_obj, $a_cmd="", $a_anchor="", $a_asynch=false, $xml_style=true)
 Get link target for command using gui object.
 getLinkTargetByClass ($a_class, $a_cmd="", $a_anchor="", $a_asynch=false, $xml_style=true)
 Get link target for command using gui class name.
 setReturn (&$a_gui_obj, $a_cmd)
 Set return command.
 setReturnByClass ($a_class, $a_cmd)
 Set return command.
 returnToParent (&$a_gui_obj, $a_anchor="")
 Redirects to next parent class that used setReturn.
 getRedirectSource ()
 Get current redirect source.
 getParentReturn (&$a_gui_obj)
 Get return script url.
 getParentReturnByClass ($a_class)
 Get return script url.
 getReturnClass ($a_class)
 Get return class.
 getUrlParameters ($a_class, $a_str, $a_cmd="", $xml_style=false)
 Get URL parameters for a class and append them to a string.
 getParameterArray (&$a_gui_obj, $a_cmd="")
 Get all set/save parameters for a gui object.
 getParameterArrayByClass ($a_class, $a_cmd="")
 Get all set/save parameters using gui class name.
 insertCtrlCalls ($a_parent, $a_child, $a_comp_prefix)
 Insert ctrl calls record.

Data Fields

const IL_RTOKEN_NAME = 'rtoken'
 $target_script
 $forward
 $parent
 $save_parameter
 $return
 $call_hist = array()
 $debug = array()
 $calls = array()
 $rtoken = false

Private Member Functions

 forwards ($a_from_class, $a_to_class)
 Stores which classes forwards commands to which other classes.
 getPathNew ($a_source_node, $a_target_node)
 Get path in call structure.
 verifyToken ()
 Verify Token.
 searchReturnClass ($a_class)
 Determine current return class.
 getCidForClass ($a_class, $a_check=false)
 Get Cid for Class.
 getClassForCid ($a_cid)
 Get class for cid.
 readCidInfo ($a_cid)
 Read information of class per cid.
 readNodeInfo ($a_node)
 Read info of node.
 readClassInfo ($a_class)
 Read info of class.
 getParentCidOfNode ($a_node)
 Get last but one cid of node id.
 removeLastCid ($a_node)
 Remove last cid of node.
 getCurrentCidOfNode ($a_node)
 Get last cid of node id.

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:
class.ilCtrl.php 32177 2011-12-19 07:49:05Z akill

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

Member Function Documentation

ilCtrl::addLocation (   $a_title,
  $a_link,
  $a_target = "",
  $a_ref_id = 0 
)

Add a location to the locator array (.

Deprecated:
, use $ilLocator)
Parameters
string$a_titlelink text
string$a_linklink
string$a_targettarget frame

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

{
$this->location[] = array("title" => $a_title,
"link" => $a_link, "target" => $a_target, "ref_id" => $a_ref_id);
}
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 447 of file class.ilCtrl.php.

{
$a_class = strtolower($a_class);
$this->tab[] = array("lang_var" => $a_lang_var,
"link" => $a_link, "cmd" => $a_cmd, "class" => $a_class);
}
ilCtrl::appendRequestTokenParameterString (   $a_url,
  $xml_style = true 
)

Append request token as url parameter.

Parameters
stringurl
booleanxml style

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

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

{
return ilUtil::appendUrlParameterString($a_url, self::IL_RTOKEN_NAME.'='.$this->getRequestToken(),
$xml_style);
}

+ Here is the call graph for this function:

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 91 of file class.ilCtrl.php.

References $_GET, $ilDB, exit, forwardCommand(), and getCallStructure().

{
global $ilDB;
$baseClass = strtolower($_GET["baseClass"]);
// get class information
$mc_set = $ilDB->query("SELECT * FROM module_class WHERE LOWER(class) = ".
$ilDB->quote($baseClass, "text"));
$mc_rec = $ilDB->fetchAssoc($mc_set);
$module = $mc_rec["module"];
$class = $mc_rec["class"];
$class_dir = $mc_rec["dir"];
if ($module != "")
{
$m_set = $ilDB->query("SELECT * FROM il_component WHERE name = ".
$ilDB->quote($module, "text"));
$m_rec = $ilDB->fetchAssoc($m_set);
$this->module_dir = $m_rec["type"]."/".$m_rec["name"];
include_once $this->module_dir."/".$class_dir."/class.".$class.".php";
}
else // check whether class belongs to a service
{
$mc_set = $ilDB->query("SELECT * FROM service_class WHERE LOWER(class) = ".
$ilDB->quote($baseClass, "text"));
$mc_rec = $ilDB->fetchAssoc($mc_set);
$service = $mc_rec["service"];
$class = $mc_rec["class"];
$class_dir = $mc_rec["dir"];
if ($service == "")
{
echo "Could not find entry in modules.xml or services.xml for ".
$baseClass." <br/>".str_replace("&", "<br />&", htmlentities($_SERVER["REQUEST_URI"]));
}
// get service information
$m_set = $ilDB->query("SELECT * FROM il_component WHERE name = ".
$ilDB->quote($service, "text"));
$m_rec = $ilDB->fetchAssoc($m_set);
$this->service_dir = $m_rec["type"]."/".$m_rec["name"];
include_once $this->service_dir."/".$class_dir."/class.".$class.".php";;
}
// forward processing to base class
$this->getCallStructure(strtolower($baseClass));
$base_class_gui =& new $class();
$this->forwardCommand($base_class_gui);
}

+ Here is the call graph for this function:

ilCtrl::checkTargetClass (   $a_class)

Check whether target is valid.

Parameters
@return

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

References getCidForClass(), and getNodeIdForTargetClass().

{
if (!is_array($a_class))
{
$a_class = array($a_class);
}
$nr = $this->current_node;
foreach ($a_class as $class)
{
$class = strtolower($class);
if (!$this->getCidForClass($class, true))
{
return false;
}
$nr = $this->getNodeIdForTargetClass($nr, $class, true);
if ($nr === false)
{
return false;
}
}
return true;
}

+ Here is the call graph for this function:

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 698 of file class.ilCtrl.php.

References clearParametersByClass().

{
$this->clearParametersByClass(strtolower(get_class($a_obj)));
}

+ Here is the call graph for this function:

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 709 of file class.ilCtrl.php.

Referenced by clearParameters().

{
$this->parameter[strtolower($a_class)] = array();
}

+ Here is the caller graph for this function:

ilCtrl::debug (   $str)

Collect debugging strings (.

Deprecated:
)
Parameters
stringdebug message

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

{
$this->debug[] = $str;
}
& 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 162 of file class.ilCtrl.php.

References exit, getCmd(), and getNodeIdForTargetClass().

Referenced by callBaseClass().

{
$class = strtolower(get_class($a_gui_object));
$nr = $this->getNodeIdForTargetClass($this->current_node, $class);
if ($nr != "")
{
$current_node = $this->current_node;
$this->current_node = $nr;
// always populate the call history
// it will only be displayed in DEVMODE but is needed for UI plugins, too
$this->call_hist[] = array("class" => get_class($a_gui_object),
"mode" => "execComm", "cmd" => $this->getCmd());
//echo "<br>class:".get_class($a_gui_object).":";
$html = $a_gui_object->executeCommand();
// reset current node
$this->current_node = $current_node;
return $html;
}
echo "ERROR: Can't forward to class $class."; exit;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCtrl::forwards (   $a_from_class,
  $a_to_class 
)
private

Stores which classes forwards commands to which other classes.

Parameters
string$a_from_classsource class name
string$a_to_classtarget class name

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

Referenced by init(), and readCallStructure().

{
$a_from_class = strtolower($a_from_class);
if (is_array($a_to_class))
{
foreach($a_to_class as $to_class)
{
if ($a_from_class != "" && $to_class != "")
{
if (!is_array($this->forward[$a_from_class]) || !in_array(strtolower($to_class), $this->forward[$a_from_class]))
{
$this->forward[$a_from_class][] = strtolower($to_class);
}
if (!is_array($this->parent[strtolower($to_class)]) || !in_array($a_from_class, $this->parent[strtolower($to_class)]))
{
$this->parent[strtolower($to_class)][] = $a_from_class;
}
}
}
}
else
{
$to_class = $a_to_class;
if ($a_from_class != "" && $to_class != "")
{
if (!is_array($this->forward[$a_from_class]) || !in_array(strtolower($to_class), $this->forward[$a_from_class]))
{
$this->forward[$a_from_class][] = strtolower($to_class);
}
if (!is_array($this->parent[strtolower($to_class)]) || !in_array($a_from_class, $this->parent[strtolower($to_class)]))
{
$this->parent[strtolower($to_class)][] = $a_from_class;
}
}
}
}

+ Here is the caller graph for this function:

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 471 of file class.ilCtrl.php.

References $call_hist.

{
}
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->setTargetScript("repository.php");
 $ilCtrl->getCallStructure("ilrepositorygui");
 $repository_gui =& new ilRepositoryGUI();
 $ilCtrl->forwardCommand($repository_gui);
Parameters
string$a_classgui class name

public

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

References readClassInfo().

Referenced by callBaseClass().

{
$this->readClassInfo($a_class);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Get Cid for Class.

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

References readClassInfo().

Referenced by checkTargetClass(), and getNodeIdForTargetClass().

{
if ($this->class_cid[$a_class] == "")
{
$this->readClassInfo($a_class);
}
if ($this->class_cid[$a_class] == "")
{
if ($a_check)
{
return false;
}
if (DEVMODE == 1)
{
$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
may solve the issue by putting an empty * @ilCtrl_Calls [YourClassName]: into your class header.".
" In both cases you need to reload the control structure in the setup.";
}
die("Cannot find cid for class ".$a_class.".".$add);
}
return $this->class_cid[$a_class];
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCtrl::getClassForCid (   $a_cid)
private

Get class for cid.

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

References readCidInfo().

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

{
if ($this->cid_class[$a_cid] == "")
{
$this->readCidInfo($a_cid);
}
if ($this->cid_class[$a_cid] == "")
{
die("Cannot find class for cid ".$a_cid.".");
}
return $this->cid_class[$a_cid];
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 783 of file class.ilCtrl.php.

References $file, and $path.

{
$path = pathinfo($a_class_path);
$file = $path["basename"];
$class = substr($file, 6, strlen($file) - 10);
return $class;
}
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 893 of file class.ilCtrl.php.

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

Referenced by forwardCommand(), and getHTML().

{
$cmd = "";
if (isset($_GET["cmd"]))
{
$cmd = $_GET["cmd"];
}
if($cmd == "post")
{
if (isset($_POST["cmd"]) && is_array($_POST["cmd"]))
{
reset($_POST["cmd"]);
}
$cmd = @key($_POST["cmd"]);
// verify command
if ($this->verified_cmd != "")
{
return $this->verified_cmd;
}
else
{
if (!$this->verifyToken() &&
(!is_array($a_safe_commands) || !in_array($cmd, $a_safe_commands)))
{
return $a_default_cmd;
}
}
$this->verified_cmd = $cmd;
if($cmd == "" && isset($_POST["table_top_cmd"])) // selected command in multi-list (table2)
{
$cmd = @key($_POST["table_top_cmd"]);
$this->verified_cmd = $cmd;
$_POST[$_POST["cmd_sv"][$cmd]] = $_POST[$_POST["cmd_sv"][$cmd]."_2"];
}
if($cmd == "" && isset($_POST["select_cmd2"])) // selected command in multi-list (table2)
{
$cmd = $_POST["selected_cmd2"];
$this->verified_cmd = $cmd;
}
if($cmd == "" && isset($_POST["select_cmd"])) // selected command in multi-list (table2)
{
$cmd = $_POST["selected_cmd"];
$this->verified_cmd = $cmd;
}
if($cmd == "")
{
$cmd = $_GET["fallbackCmd"];
$this->verified_cmd = $cmd;
}
}
if($cmd == "")
{
$cmd = $a_default_cmd;
}
return $cmd;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCtrl::getCmdClass ( )

Determines class that should execute the current command.

Returns
string class name

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

References $_GET.

{
return strtolower($_GET["cmdClass"]);
}
ilCtrl::getCmdNode ( )

Get command target node.

Returns
string id of current command target node

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

References $_GET.

Referenced by getNextClass().

{
return $_GET["cmdNode"];
}

+ Here is the caller graph for this function:

ilCtrl::getContextObjId ( )

Get context object id.

Returns
int object id

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

{
return $this->context_obj_id;
}
ilCtrl::getContextObjType ( )

Get context object type.

Returns
string object type

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

{
return $this->context_obj_type;
}
ilCtrl::getContextSubObjId ( )

Get context subobject id.

Returns
int subobject id

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

{
return $this->context_sub_obj_id;
}
ilCtrl::getContextSubObjType ( )

Get context subobject type.

Returns
string subobject type

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

{
return $this->context_sub_obj_type;
}
ilCtrl::getCurrentCidOfNode (   $a_node)
private

Get last cid of node id.

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

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

{
$n_arr = explode(":", $a_node);
return $n_arr[count($n_arr) - 1];
}

+ Here is the caller graph for this function:

ilCtrl::getDebug ( )

Get debug message string (.

Deprecated:
)
Returns
array array of debug strings

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

References $debug.

{
return $this->debug;
}
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 1005 of file class.ilCtrl.php.

References getFormActionByClass().

{
$script = $this->getFormActionByClass(strtolower(get_class($a_gui_obj)),
$a_fallback_cmd, $a_anchor, $a_asynch, $xml_style);
return $script;
}

+ Here is the call graph for this function:

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 1023 of file class.ilCtrl.php.

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

Referenced by getFormAction().

{
if(!is_array($a_class))
{
$a_class = strtolower($a_class);
}
$tok = $this->getRequestToken();
if ($a_asynch)
{
$xml_style = false;
}
$script = $this->getLinkTargetByClass($a_class, "post", "", $a_asynch);
if ($a_fallback_cmd != "")
{
$script = ilUtil::appendUrlParameterString($script, "fallbackCmd=".$a_fallback_cmd, $xml_style);
}
$script = ilUtil::appendUrlParameterString($script, self::IL_RTOKEN_NAME.'='.$this->getRequestToken(),
$xml_style);
if ($a_anchor != "")
{
$script = $script."#".$a_anchor;
}
return $script;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

& ilCtrl::getHTML ( $a_gui_object)

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

Parameters
objectgui object that returns the HTML block
Returns
string HTML

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

References exit, getCmd(), and getNodeIdForTargetClass().

{
$class = strtolower(get_class($a_gui_object));
$nr = $this->getNodeIdForTargetClass($this->current_node, $class);
if ($nr != "")
{
$current_node = $this->current_node;
// set current node to new gui class
$this->current_node = $nr;
// always populate the call history
// it will only be displayed in DEVMODE but is needed for UI plugins, too
$this->call_hist[] = array("class" => get_class($a_gui_object),
"mode" => "getHtml", "cmd" => $this->getCmd());
// get block
$html = $a_gui_object->getHTML();
// reset current node
$this->current_node = $current_node;
// return block
return $html;
}
echo "ERROR: Can't getHTML from class $class."; exit;
}

+ Here is the call graph for this function:

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 1271 of file class.ilCtrl.php.

References getLinkTargetByClass().

{
$script = $this->getLinkTargetByClass(strtolower(get_class($a_gui_obj)), $a_cmd, $a_anchor, $a_asynch,
$xml_style);
return $script;
}

+ Here is the call graph for this function:

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 1291 of file class.ilCtrl.php.

References getTargetScript(), and getUrlParameters().

Referenced by getFormActionByClass(), getLinkTarget(), redirect(), and redirectByClass().

{
if ($a_asynch)
{
$xml_style = false;
}
// note: $a_class may be an array
//$a_class = strtolower($a_class);
//echo "<br>getLinkTargetByClass";
$script = $this->getTargetScript();
$script = $this->getUrlParameters($a_class, $script, $a_cmd, $xml_style);
if ($a_asynch)
{
//$amp = $xml_style
// ? "&amp;"
// : "&";
$amp = "&";
$script.= $amp."cmdMode=asynch";
}
if ($a_anchor != "")
{
$script = $script."#".$a_anchor;
}
return $script;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCtrl::getLocations ( )

Get locations array (.

Deprecated:
, use $ilLocator)
Returns
array array of locations (array("title", "link", "target"))

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

References $location.

{
}
ilCtrl::getModuleDir ( )

get directory of current module

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

{
return $this->module_dir;
}
ilCtrl::getNextClass ( )

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 722 of file class.ilCtrl.php.

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

{
$cmdNode = $this->getCmdNode();
//echo "<br>getNextClass (current node: ".$this->current_node."; cmd node: ".$cmdNode.") ";
if ($cmdNode == "")
{
return false;
}
else
{
if ($this->current_node == $cmdNode)
{
//echo "1:".$this->call_node[$cmdNode]["class"]."<br>";
//return $this->call_node[$cmdNode]["class"];
return "";
}
else
{
$path = $this->getPathNew($this->current_node, $cmdNode);
//var_dump($path);
//echo " - Next Node: ".$path[1];
//echo ":".$this->cid_class[$this->getCurrentCidOfNode($path[1])].":".$this->getCurrentCidOfNode($path[1]).":";
return $this->cid_class[$this->getCurrentCidOfNode($path[1])];
}
}
}

+ Here is the call graph for this function:

ilCtrl::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).

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 wether 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 methode searchs 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 301 of file class.ilCtrl.php.

References exit, getCidForClass(), getClassForCid(), getCurrentCidOfNode(), getParentCidOfNode(), ilUtil\printBacktrace(), readClassInfo(), readNodeInfo(), and removeLastCid().

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

{
$class = strtolower($a_class);
$this->readClassInfo($class);
if ($a_par_node === 0 || $a_par_node == "")
{
return $this->getCidForClass($class);
}
//return parent::getNodeIdForTargetClass($a_par_node, $a_class);
$this->readNodeInfo($a_par_node);
$node_cid = $this->getCurrentCidOfNode($a_par_node);
// target class is class of current node id
if ($class == $this->getClassForCid($node_cid))
{
return $a_par_node;
}
// target class is child of current node id
if (isset($this->calls[$this->getClassForCid($node_cid)]) &&
is_array($this->calls[$this->getClassForCid($node_cid)]) &&
in_array($a_class, $this->calls[$this->getClassForCid($node_cid)]))
{
return $a_par_node.":".$this->getCidForClass($class);
}
// target class is sibling
$par_cid = $this->getParentCidOfNode($a_par_node);
if ($par_cid != "")
{
if (is_array($this->calls[$this->getClassForCid($par_cid)]) &&
in_array($a_class, $this->calls[$this->getClassForCid($par_cid)]))
{
return $this->removeLastCid($a_par_node).":".$this->getCidForClass($class);;
}
}
// target class is parent
$temp_node = $this->removeLastCid($a_par_node);
while($temp_node != "")
{
$temp_cid = $this->getCurrentCidOfNode($temp_node);
if ($this->getClassForCid($temp_cid) == $a_class)
{
return $temp_node;
}
$temp_node = $this->removeLastCid($temp_node);
}
if ($a_check)
{
return false;
}
// Please do NOT change these lines.
// Developers must be aware, if they use classes unknown to the controller
// otherwise certain problem will be extremely hard to track down...
echo "ERROR: Can't find target class $a_class for node $a_par_node ".
"(".$this->cid_class[$this->getParentCidOfNode($a_par_node)].").<br>";
error_log( "ERROR: Can't find target class $a_class for node $a_par_node ".
"(".$this->cid_class[$this->getParentCidOfNode($a_par_node)].")");
if (DEVMODE == 1)
{
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Get all set/save parameters for a gui object.

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

References getParameterArrayByClass().

{
$par_arr = $this->getParameterArrayByClass(strtolower(get_class($a_gui_obj)), $a_cmd);
return $par_arr;
}

+ Here is the call graph for this function:

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 1480 of file class.ilCtrl.php.

References $_GET, $_POST, $path, getClassForCid(), getCurrentCidOfNode(), getNodeIdForTargetClass(), and getPathNew().

Referenced by getParameterArray(), and getUrlParameters().

{
if ($a_class == "")
{
return array();
}
if (!is_array($a_class))
{
$a_class = array($a_class);
}
$nr = $this->current_node;
foreach ($a_class as $class)
{
$class = strtolower($class);
$nr = $this->getNodeIdForTargetClass($nr, $class);
$target_class = $class;
}
$path = $this->getPathNew(1, $nr);
$params = array();
// append parameters of parent classes
foreach($path as $node_id)
{
$class = ($node_id == "")
? strtolower($_GET["baseClass"])
: $this->getClassForCid($this->getCurrentCidOfNode($node_id));
if (isset($this->save_parameter[$class]) && is_array($this->save_parameter[$class]))
{
foreach($this->save_parameter[$class] as $par)
{
if (isset($_GET[$par]))
{
$params[$par] = $_GET[$par];
}
else if (isset($_POST[$par]))
{
$params[$par] = $_POST[$par];
}
}
}
if (isset($this->parameter[$class]) && is_array($this->parameter[$class]))
{
foreach($this->parameter[$class] as $par => $value)
{
$params[$par] = $value;
}
}
}
if ($a_cmd != "")
{
$params["cmd"] = $a_cmd;
}
$params["cmdClass"] = $target_class;
$params["cmdNode"] = $nr;
$params["baseClass"] = $_GET["baseClass"];
return $params;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCtrl::getParentCidOfNode (   $a_node)
private

Get last but one cid of node id.

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

Referenced by getNodeIdForTargetClass().

{
$n_arr = explode(":", $a_node);
return $n_arr[count($n_arr) - 2];
}

+ Here is the caller graph for this function:

ilCtrl::getParentReturn ( $a_gui_obj)

Get return script url.

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

References getParentReturnByClass().

Referenced by returnToParent().

{
return $this->getParentReturnByClass(strtolower(get_class($a_gui_obj)));
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCtrl::getParentReturnByClass (   $a_class)

Get return script url.

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

References searchReturnClass().

Referenced by getParentReturn().

{
$a_class = strtolower($a_class);
$ret_class = $this->searchReturnClass($a_class);
//echo ":$ret_class:";
if($ret_class)
{
//echo ":".$this->return[$ret_class].":";
return $this->return[$ret_class];
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 798 of file class.ilCtrl.php.

References $path, exit, and ilUtil\printBacktrace().

Referenced by getNextClass(), and getParameterArrayByClass().

{
//if ($this->getCmdClass() == "ilmailfoldergui") echo "-".$a_source_node."-".$a_target_node."-";
//echo "-".$a_source_node."-".$a_target_node."-";
//echo "<br>:::$a_source_node:::";
if ($a_source_node == "1")
{
$a_source_node = "";
}
if (substr($a_target_node, 0, strlen($a_source_node)) != $a_source_node)
{
echo "ERROR: Path not found. Source:".$a_source_node.
", Target:".$a_target_node;
if (DEVMODE == 1)
{
}
}
//echo "<br>:::$a_source_node:::";
$temp_node = $a_source_node;
$path = array();
if ($a_source_node != "")
{
$path = array($a_source_node);
}
$diffstart = ($a_source_node == "")
? 0
: strlen($a_source_node) + 1;
$diff = substr($a_target_node, $diffstart);
//echo "=$diff=$diffstart=";
$diff_arr = explode(":", $diff);
foreach($diff_arr as $cid)
{
if ($temp_node != "")
{
$temp_node.= ":";
}
$temp_node.= $cid;
$path[] = $temp_node;
}
//if ($this->getCmdClass() == "ilmailfoldergui") var_dump($path);
//var_dump($path);
return $path;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCtrl::getRedirectSource ( )

Get current redirect source.

Returns
string redirect source class

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

References $_GET.

{
return $_GET["redirectSource"];
}
ilCtrl::getRequestToken ( )

Get request token.

Returns
string request token for user and session

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

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

Referenced by appendRequestTokenParameterString(), and getFormActionByClass().

{
global $ilDB, $ilUser;
if ($this->rtoken != "")
{
return $this->rtoken;
}
else
{
if (is_object($ilDB) && is_object($ilUser) && $ilUser->getId() > 0 &&
$ilUser->getId() != ANONYMOUS_USER_ID)
{
$res = $ilDB->query("SELECT token FROM il_request_token WHERE user_id = ".
$ilDB->quote($ilUser->getId(), "integer").
" AND session_id = ".$ilDB->quote(session_id(), "text"));
$rec = $ilDB->fetchAssoc($res);
if ($rec["token"] != "")
{
$this->rtoken = $rec["token"];
return $rec["token"];
}
$this->rtoken = md5(uniqid(rand(), true));
// delete entries older than one and a half days
if (rand(1, 200) == 2)
{
$dt = new ilDateTime(time(),IL_CAL_UNIX);
$dt->increment(IL_CAL_DAY, -1);
$dt->increment(IL_CAL_HOUR, -12);
$dq = "DELETE FROM il_request_token WHERE ".
" stamp < ".$ilDB->quote($dt->get(IL_CAL_DATETIME), "timestamp");
$ilDB->manipulate($dq);
}
// IMPORTANT: Please do NOT try to move this implementation to a
// session basis. This will fail due to framesets that are used
// occasionally in ILIAS, e.g. in the chat, where multiple
// forms are loaded in different frames.
$ilDB->manipulate("INSERT INTO il_request_token (user_id, token, stamp, session_id) VALUES ".
"(".
$ilDB->quote($ilUser->getId(), "integer").",".
$ilDB->quote($this->rtoken, "text").",".
$ilDB->now().",".
$ilDB->quote(session_id(), "text").")");
return $this->rtoken;
}
//$this->rtoken = md5(uniqid(rand(), true));
}
return "";
}

+ Here is the caller graph for this function:

ilCtrl::getReturnClass (   $a_class)

Get return class.

Parameters
@return

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

References searchReturnClass().

{
if (is_object($a_class))
{
$class = strtolower(get_class($a_class));
}
else
{
$class = strtolower($a_class);
}
return $this->searchReturnClass($class);
}

+ Here is the call graph for this function:

ilCtrl::getTabs ( )

Get tabs array (.

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

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

References $tab.

{
return $this->tab;
}
ilCtrl::getTargetScript ( )

Get target script name.

Returns
string target script name

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

References $target_script.

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

{
}

+ Here is the caller graph for this function:

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 1445 of file class.ilCtrl.php.

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

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

{
// note: $a_class may be an array!
//$a_class = strtolower($a_class);
$params = $this->getParameterArrayByClass($a_class, $a_cmd);
foreach ($params as $par => $value)
{
if (strlen((string) $value))
{
$a_str = ilUtil::appendUrlParameterString($a_str, $par."=".$value, $xml_style);
}
}
return $a_str;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCtrl::ilCtrl ( )

control class constructor

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

References $ilBench, and init().

{
global $ilBench;
$this->bench =& $ilBench;
// initialisation
$this->init();
// this information should go to xml files one day
$this->stored_trees = array
("ilrepositorygui", "ilpersonaldesktopgui",
"illmpresentationgui", "illmeditorgui",
"iladministrationgui");
}

+ Here is the call graph for this function:

ilCtrl::init ( )

initialisation

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

References forwards().

Referenced by ilCtrl(), and initBaseClass().

{
$this->transit = array();
$this->forward = array(); // forward array
$this->forwards = array(); // forward array
$this->parent = array(); // parent array (reverse forward)
$this->save_parameter = array(); // save parameter array
$this->parameter = array(); // save parameter array
$this->return = ""; // return commmands
$this->location = array();
$this->tab = array();
$this->current_node = 0;
$this->module_dir = "";
$this->service_dir = "";
$this->call_node = array();
$this->root_class = "";
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCtrl::initBaseClass (   $a_base_class)

Initialises new base class.

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

Parameters
stringbase class name

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

References $_GET, and init().

{
$_GET["baseClass"] = $a_base_class;
$_GET["cmd"] = "";
$_GET["cmdClass"] = "";
$_GET["cmdNode"] = "";
$this->init();
}

+ Here is the call graph for this function:

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

Insert ctrl calls record.

Parameters
@return

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

References $ilDB.

{
global $ilDB;
$a_parent = strtolower($a_parent);
$a_child = strtolower($a_child);
$a_comp_prefix = strtolower($a_comp_prefix);
$set = $ilDB->query("SELECT * FROM ctrl_calls WHERE ".
" parent = ".$ilDB->quote($a_parent, "text")." AND ".
" child = ".$ilDB->quote($a_child, "text")." AND ".
" comp_prefix = ".$ilDB->quote($a_comp_prefix, "text")
);
if ($rec = $ilDB->fetchAssoc($set))
{
return;
}
$ilDB->manipulate("INSERT INTO ctrl_calls ".
"(parent, child, comp_prefix) VALUES (".
$ilDB->quote($a_parent, "text").",".
$ilDB->quote($a_child, "text").",".
$ilDB->quote($a_comp_prefix, "text").
")");
}
ilCtrl::isAsynch ( )

Is current command an asynchronous command?

Returns
boolean asynchronous t/f

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

References $_GET.

{
if (isset($_GET["cmdMode"]) && $_GET["cmdMode"] == "asynch")
{
return true;
}
else
{
return false;
}
}
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 756 of file class.ilCtrl.php.

References $ilDB.

{
global $ilDB;
$a_class_name = strtolower($a_class_name);
$class_set = $ilDB->query("SELECT * FROM ctrl_classfile WHERE class = ".
$ilDB->quote($a_class_name, "text"));
$class_rec = $ilDB->fetchAssoc($class_set);
if ($class_rec["plugin_path"] != "")
{
return $class_rec["plugin_path"]."/".$class_rec["filename"];
}
else
{
return $class_rec["filename"];
}
}
ilCtrl::readCallStructure (   $a_class,
  $a_nr = 0,
  $a_parent = 0 
)

stores often used common call structures (called from db_update script!!!)

Reads call structure from db

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

References $ilDB, and forwards().

{
global $ilDB;
$a_class = strtolower($a_class);
$a_nr++;
// determine call node structure
$this->call_node[$a_nr] = array("class" => $a_class, "parent" => $a_parent);
//echo "<br>nr:$a_nr:class:$a_class:parent:$a_parent:";
$call_set = $ilDB->query("SELECT * FROM ctrl_calls WHERE parent = ".
$ilDB->quote(strtolower($a_class), "text").
" ORDER BY child", array("text"));
$a_parent = $a_nr;
while ($call_rec = $ilDB->fetchAssoc($call_set))
{
$a_nr = $this->readCallStructure($call_rec["child"], $a_nr, $a_parent);
$forw[] = $call_rec["child"];
}
// determin forward and parent array
$this->forwards($a_class, $forw);
//echo "<br>forwards:".$a_class."<br>"; var_dump($forw);
// determine root class
$this->root_class = $a_class;
return $a_nr;
}

+ Here is the call graph for this function:

ilCtrl::readCidInfo (   $a_cid)
private

Read information of class per cid.

Returns
Parameters
object$a_cidcid

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

References $ilDB.

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

{
global $ilDB;
if (isset($this->info_read_cid[$a_cid]))
{
return;
}
$set = $ilDB->query("SELECT * FROM ctrl_classfile ".
" WHERE cid = ".$ilDB->quote($a_cid, "text")
);
if ($rec = $ilDB->fetchAssoc($set))
{
$this->cid_class[$a_cid] = $rec["class"];
$this->class_cid[$rec["class"]] = $a_cid;
$set = $ilDB->query("SELECT * FROM ctrl_calls ".
" WHERE parent = ".$ilDB->quote($rec["class"], "text")
);
while ($rec2 = $ilDB->fetchAssoc($set))
{
if (!isset($this->calls[$rec["class"]]) || !is_array($this->calls[$rec["class"]]) || !in_array($rec2["child"], $this->calls[$rec["class"]]))
{
if ($rec2["child"] != "")
{
$this->calls[$rec["class"]][] = $rec2["child"];
}
}
}
$this->info_read_class[$rec["class"]] = true;
}
$this->info_read_cid[$a_cid] = true;
}

+ Here is the caller graph for this function:

ilCtrl::readClassInfo (   $a_class)
private

Read info of class.

Parameters
object$a_classclass name

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

References $ilDB.

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

{
global $ilDB;
$a_class = strtolower($a_class);
if (isset($this->info_read_class[$a_class]))
{
return;
}
$set = $ilDB->query("SELECT * FROM ctrl_classfile ".
" WHERE class = ".$ilDB->quote($a_class, "text")
);
if ($rec = $ilDB->fetchAssoc($set))
{
$this->cid_class[$rec["cid"]] = $a_class;
$this->class_cid[$a_class] = $rec["cid"];
}
$set = $ilDB->query("SELECT * FROM ctrl_calls ".
" WHERE parent = ".$ilDB->quote($a_class, "text")
);
while ($rec = $ilDB->fetchAssoc($set))
{
if (!isset($this->calls[$a_class]) || !is_array($this->calls[$a_class]) || !in_array($rec["child"], $this->calls[$a_class]))
{
if ($rec["child"] != "")
{
$this->calls[$a_class][] = $rec["child"];
}
}
}
$this->info_read_class[$a_class] = true;
$this->info_read_cid[$this->class_cid[$a_class]] = true;
}

+ Here is the caller graph for this function:

ilCtrl::readNodeInfo (   $a_node)
private

Read info of node.

Parameters
object$a_classclass name

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

References readCidInfo().

Referenced by getNodeIdForTargetClass().

{
$n_arr = explode(":", $a_node);
foreach ($n_arr as $cid)
{
$this->readCidInfo($cid);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Redirect to another command.

Parameters
objectgui object
stringcommand
stringanchor

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

References $ilBench, and getLinkTargetByClass().

Referenced by redirectByClass(), and returnToParent().

{
global $ilBench;
$script = $this->getLinkTargetByClass(strtolower(get_class($a_gui_obj)), $a_cmd,
"", $a_asynch, false);
if (is_object($ilBench))
{
$ilBench->save();
}
if ($a_anchor != "")
{
$script = $script."#".$a_anchor;
}
ilUtil::redirect($script);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 1232 of file class.ilCtrl.php.

References getLinkTargetByClass(), and redirect().

{
$script = $this->getLinkTargetByClass($a_class, $a_cmd, "", $a_asynch, false);
if ($a_anchor != "")
{
$script = $script."#".$a_anchor;
}
ilUtil::redirect($script);
}

+ Here is the call graph for this function:

ilCtrl::removeLastCid (   $a_node)
private

Remove last cid of node.

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

Referenced by getNodeIdForTargetClass().

{
$lpos = strrpos($a_node, ":");
return substr($a_node, 0, $lpos);
}

+ Here is the caller graph for this function:

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

Redirects to next parent class that used setReturn.

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

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

{
$script = $this->getParentReturn($a_gui_obj);
"redirectSource=".strtolower(get_class($a_gui_obj)));
"cmdMode=".$_GET["cmdMode"]);
if ($a_anchor != "")
{
$script = $script."#".$a_anchor;
}
ilUtil::redirect($script);
}

+ Here is the call graph for this function:

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 (which is set by the setTargetScript() method) 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 621 of file class.ilCtrl.php.

References saveParameterByClass().

{
if (is_object($a_obj))
{
$this->saveParameterByClass(get_class($a_obj), $a_parameter);
}
}

+ Here is the call graph for this function:

ilCtrl::saveParameterByClass (   $a_class,
  $a_parameter 
)

Save parameter for a class.

Parameters
stringclass name
stringparameter name

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

Referenced by saveParameter().

{
if (is_array($a_parameter))
{
foreach($a_parameter as $parameter)
{
$this->save_parameter[strtolower($a_class)][] = $parameter;
}
}
else
{
$this->save_parameter[strtolower($a_class)][] = $a_parameter;
}
}

+ Here is the caller graph for this function:

ilCtrl::searchReturnClass (   $a_class)
private

Determine current return class.

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

References getClassForCid(), and getNodeIdForTargetClass().

Referenced by getParentReturnByClass(), and getReturnClass().

{
$a_class = strtolower($a_class);
$node = $this->getNodeIdForTargetClass($this->current_node, $a_class);
$n_arr = explode(":", $node);
for($i = count($n_arr)-2; $i>=0; $i--)
{
if ($this->return[$this->getClassForCid($n_arr[$i])] != "")
{
return $this->getClassForCid($n_arr[$i]);
}
}
return false;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 962 of file class.ilCtrl.php.

References $_GET.

{
$_GET["cmd"] = $a_cmd;
}
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 977 of file class.ilCtrl.php.

References $_GET, and getNodeIdForTargetClass().

{
$a_cmd_class = strtolower($a_cmd_class);
$nr = $this->getNodeIdForTargetClass($this->current_node, $a_cmd_class);
$_GET["cmdClass"] = $a_cmd_class;
$_GET["cmdNode"] = $nr;
}

+ Here is the call graph for this function:

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 235 of file class.ilCtrl.php.

{
$this->context_obj_id = $a_obj_id;
$this->context_obj_type = $a_obj_type;
$this->context_sub_obj_id = $a_sub_obj_id;
$this->context_sub_obj_type = $a_sub_obj_type;
}
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 (which is set by the setTargetScript() method) 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 673 of file class.ilCtrl.php.

{
$this->parameter[strtolower(get_class($a_obj))][$a_parameter] = $a_value;
}
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 686 of file class.ilCtrl.php.

{
$this->parameter[strtolower($a_class)][$a_parameter] = $a_value;
}
ilCtrl::setReturn ( $a_gui_obj,
  $a_cmd 
)

Set return command.

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

References getTargetScript(), and getUrlParameters().

{
$script = $this->getTargetScript();
$script = $this->getUrlParameters(strtolower(get_class($a_gui_obj)), $script, $a_cmd);
//echo "<br>setReturn:".get_class($a_gui_obj).":".$script.":<br>";
$this->return[strtolower(get_class($a_gui_obj))] = $script;
}

+ Here is the call graph for this function:

ilCtrl::setReturnByClass (   $a_class,
  $a_cmd 
)

Set return command.

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

References getTargetScript(), and getUrlParameters().

{
// may not be an array!
$a_class = strtolower($a_class);
$script = $this->getTargetScript();
$script = $this->getUrlParameters($a_class, $script, $a_cmd);
//echo "<br>setReturn:".get_class($a_gui_obj).":".$script.":<br>";
$this->return[strtolower($a_class)] = $script;
}

+ Here is the call graph for this function:

ilCtrl::setTargetScript (   $a_target_script)

set target script name

Parameters
string$a_target_scripttarget script name

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

{
$this->target_script = $a_target_script;
}
ilCtrl::verifyToken ( )
private

Verify Token.

Returns
boolean valid t/f

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

References $_GET, $_SESSION, and $ilDB.

Referenced by getCmd().

{
global $ilDB, $ilUser;
if (is_object($ilUser) && is_object($ilDB) && $ilUser->getId() > 0 &&
$ilUser->getId() != ANONYMOUS_USER_ID)
{
if ($_GET["rtoken"] == "")
{
#echo "ilCtrl::No Request Token Given!"; // for debugging, maybe changed later
return false;
}
$set = $ilDB->query("SELECT * FROM il_request_token WHERE ".
" user_id = ".$ilDB->quote($ilUser->getId(), "integer")." AND ".
" token = ".$ilDB->quote($_GET[self::IL_RTOKEN_NAME]), "text");
if ($ilDB->numRows($set) > 0)
{
// remove used token
/*
$ilDB->query("DELETE FROM il_request_token WHERE ".
" user_id = ".$ilDB->quote($ilUser->getId())." AND ".
" token = ".$ilDB->quote($_GET[self::IL_RTOKEN_NAME]));
*/
// remove tokens from older sessions
$ilDB->manipulate("DELETE FROM il_request_token WHERE ".
" user_id = ".$ilDB->quote($ilUser->getId(), "integer")." AND ".
" session_id != ".$ilDB->quote(session_id(), "text"));
return true;
}
else
{
return false;
}
if ($_SESSION["rtokens"][$_GET[self::IL_RTOKEN_NAME]] != "")
{
// remove used token
unset($_SESSION["rtokens"][$_GET[self::IL_RTOKEN_NAME]]);
// remove old tokens
if (count($_SESSION["rtokens"]) > 100)
{
$to_remove = array();
$sec = 7200; // two hours
foreach($_SESSION["rtokens"] as $tok => $time)
{
if (time() - $time > $sec)
{
$to_remove[] = $tok;
}
}
foreach($to_remove as $tok)
{
unset($_SESSION["rtokens"][$tok]);
}
}
return true;
}
return false;
}
else
{
return true; // do not verify, if user or db object is missing
}
return false;
}

+ Here is the caller graph for this function:

Field Documentation

ilCtrl::$call_hist = array()

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

Referenced by getCallHistory().

ilCtrl::$calls = array()

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

ilCtrl::$debug = array()

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

Referenced by getDebug().

ilCtrl::$forward

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

ilCtrl::$parent

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

ilCtrl::$return

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

ilCtrl::$rtoken = false

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

Referenced by getRequestToken().

ilCtrl::$save_parameter

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

ilCtrl::$target_script

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

Referenced by getTargetScript().


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