ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilMailFormCall.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
11 {
15  const REFERER_KEY = 'r';
16 
20  const SIGNATURE_KEY = 'sig';
21 
30  public static function getLinkTarget($gui, $cmd, Array $gui_params = array(), Array $mail_params = array())
31  {
32  return self::getTargetUrl('&amp;', $gui, $cmd, $gui_params, $mail_params);
33  }
34 
43  public static function getRedirectTarget($gui, $cmd, Array $gui_params = array(), Array $mail_params = array())
44  {
45  return self::getTargetUrl('&', $gui, $cmd, $gui_params, $mail_params);
46  }
47 
57  protected static function getTargetUrl($argument_separator, $gui, $cmd, Array $gui_params = array(), Array $mail_params = array())
58  {
59  $mparams = '';
60  $referer = '';
61 
62  foreach($mail_params as $key => $value)
63  {
64  $mparams .= $argument_separator . $key . '=' . $value;
65  }
66 
67  if(is_object($gui))
68  {
72  global $ilCtrl;
73  $ilCtrlTmp = clone $ilCtrl;
74  foreach($gui_params as $key => $value)
75  {
76  $ilCtrlTmp->setParameter($gui, $key, $value);
77  }
78  $referer = $ilCtrlTmp->getLinkTarget($gui, $cmd, '', false, false);
79  }
80  else if(is_string($gui))
81  {
82  $referer = $gui;
83  }
84 
85  $referer = $argument_separator . self::REFERER_KEY . '=' . rawurlencode(base64_encode($referer));
86 
87  return 'ilias.php?baseClass=ilMailGUI' . $referer . $mparams;
88  }
89 
94  public static function storeReferer($request_params)
95  {
96  if(isset($request_params[self::REFERER_KEY]))
97  {
98  $_SESSION[self::REFERER_KEY] = base64_decode(rawurldecode($request_params[self::REFERER_KEY]));
99  $_SESSION[self::SIGNATURE_KEY] = base64_decode(rawurldecode($request_params[self::SIGNATURE_KEY]));
100  }
101  else
102  {
103  unset($_SESSION[self::REFERER_KEY]);
104  unset($_SESSION[self::SIGNATURE_KEY]);
105  }
106  }
107 
113  public static function getSignature()
114  {
116 
117  unset($_SESSION[self::SIGNATURE_KEY]);
118 
119  return $sig;
120  }
121 
126  public static function getRefererRedirectUrl()
127  {
129 
130  if(strlen($url))
131  {
132  $parts = parse_url($url);
133  if(isset($parts['query']) && strlen($parts['query']))
134  {
135  $url .= '&returned_from_mail=1';
136  }
137  else
138  {
139  $url .= '?returned_from_mail=1';
140  }
141  }
142 
143  unset($_SESSION[self::REFERER_KEY]);
144 
145  return $url;
146  }
147 
152  public static function isRefererStored()
153  {
154  return isset($_SESSION[self::REFERER_KEY]) && strlen($_SESSION[self::REFERER_KEY]) ? true : false;
155  }
156 }