ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 SESSION_KEY = 'mail_transport';
16 
20  const REFERER_KEY = 'r';
21 
25  const SIGNATURE_KEY = 'sig';
26 
30  const CONTEXT_PREFIX = 'ctx';
31 
35  const CONTEXT_KEY = 'ctx_template';
36 
46  public static function getLinkTarget($gui, $cmd, Array $gui_params = array(), Array $mail_params = array(), $context_params = array())
47  {
48  return self::getTargetUrl('&amp;', $gui, $cmd, $gui_params, $mail_params, $context_params);
49  }
50 
60  public static function getRedirectTarget($gui, $cmd, array $gui_params = array(), array $mail_params = array(), array $context_params = array())
61  {
62  return self::getTargetUrl('&', $gui, $cmd, $gui_params, $mail_params, $context_params);
63  }
64 
74  protected static function getTargetUrl($argument_separator, $gui, $cmd, array $gui_params = array(), array $mail_params = array(), array $context_params = array())
75  {
76  $mparams = '';
77  $referer = '';
78 
79  foreach($mail_params as $key => $value)
80  {
81  $mparams .= $argument_separator . $key . '=' . urlencode($value);
82  }
83 
84  foreach($context_params as $key => $value)
85  {
86  if($key == self::CONTEXT_KEY)
87  {
88  $mparams .= $argument_separator . $key . '=' . urlencode($value);
89  }
90  else
91  {
92  $mparams .= $argument_separator . self::CONTEXT_PREFIX . '_' . $key . '=' . urlencode($value);
93  }
94  }
95 
96  if(is_object($gui))
97  {
101  global $ilCtrl;
102  $ilCtrlTmp = clone $ilCtrl;
103  foreach($gui_params as $key => $value)
104  {
105  $ilCtrlTmp->setParameter($gui, $key, $value);
106  }
107  $referer = $ilCtrlTmp->getLinkTarget($gui, $cmd, '', false, false);
108  }
109  else if(is_string($gui))
110  {
111  $referer = $gui;
112  }
113 
114  $referer = $argument_separator . self::REFERER_KEY . '=' . rawurlencode(base64_encode($referer));
115 
116  return 'ilias.php?baseClass=ilMailGUI' . $referer . $mparams;
117  }
118 
123  public static function storeReferer($request_params)
124  {
125  $session = ilSession::get(self::SESSION_KEY);
126  if(isset($request_params[self::REFERER_KEY]))
127  {
128  $session[self::REFERER_KEY] = base64_decode(rawurldecode($request_params[self::REFERER_KEY]));
129  $session[self::SIGNATURE_KEY] = base64_decode(rawurldecode($request_params[self::SIGNATURE_KEY]));
130 
131  $ctx_params = array();
132  foreach($request_params as $key => $value)
133  {
134  $prefix = substr($key, 0, strlen(self::CONTEXT_PREFIX));
135  if($prefix == self::CONTEXT_PREFIX)
136  {
137  if($key == self::CONTEXT_KEY)
138  {
139  $ctx_params[$key] = $value;
140  }
141  else
142  {
143  $ctx_params[substr($key, strlen(self::CONTEXT_PREFIX . '_'))] = $value;
144  }
145  }
146  }
147  $session[self::CONTEXT_PREFIX] = $ctx_params;
148  }
149  else
150  {
151  unset($session[self::REFERER_KEY]);
152  unset($session[self::SIGNATURE_KEY]);
153  unset($session[self::CONTEXT_PREFIX]);
154  }
155  ilSession::set(self::SESSION_KEY, $session);
156  }
157 
163  public static function getSignature()
164  {
165  $session = ilSession::get(self::SESSION_KEY);
166 
167  $sig = $session[self::SIGNATURE_KEY];
168 
169  unset($session[self::SIGNATURE_KEY]);
170  ilSession::set(self::SESSION_KEY, $session);
171 
172  return $sig;
173  }
174 
179  public static function getRefererRedirectUrl()
180  {
181  $session = ilSession::get(self::SESSION_KEY);
182 
183  $url = $session[self::REFERER_KEY];
184  if(strlen($url))
185  {
186  $parts = parse_url($url);
187  if(isset($parts['query']) && strlen($parts['query']))
188  {
189  $url .= '&returned_from_mail=1';
190  }
191  else
192  {
193  $url .= '?returned_from_mail=1';
194  }
195  }
196 
197  unset($session[self::REFERER_KEY]);
198  ilSession::set(self::SESSION_KEY, $session);
199 
200  return $url;
201  }
202 
207  public static function isRefererStored()
208  {
209  $session = ilSession::get(self::SESSION_KEY);
210  return isset($session[self::REFERER_KEY]) && strlen($session[self::REFERER_KEY]) ? true : false;
211  }
212 
216  public static function getContextId()
217  {
218  $session = ilSession::get(self::SESSION_KEY);
219  return (
220  isset($session[self::CONTEXT_PREFIX][self::CONTEXT_KEY]) &&
221  strlen($session[self::CONTEXT_PREFIX][self::CONTEXT_KEY]) ?
222  $session[self::CONTEXT_PREFIX][self::CONTEXT_KEY] : NULL
223  );
224  }
225 
229  public static function setContextId($id)
230  {
231  $session = ilSession::get(self::SESSION_KEY);
232  $session[self::CONTEXT_KEY] = $id;
233  ilSession::set(self::SESSION_KEY, $session);
234  }
235 
239  public static function getContextParameters()
240  {
241  $session = ilSession::get(self::SESSION_KEY);
242  if(isset($session[self::CONTEXT_PREFIX]))
243  {
244  return (array)$session[self::CONTEXT_PREFIX];
245  }
246  return array();
247  }
248 
253  public static function setContextParameters(array $parameters)
254  {
255  $session = ilSession::get(self::SESSION_KEY);
256  $session[self::CONTEXT_PREFIX] = $parameters;
257  ilSession::set(self::SESSION_KEY, $session);
258  }
259 
263  public static function setRecipients(array $recipients)
264  {
265  $session = ilSession::get(self::SESSION_KEY);
266  $session['rcp_to'] = $recipients;
267  ilSession::set(self::SESSION_KEY, $session);
268  }
269 
273  public static function getRecipients()
274  {
275  $session = ilSession::get(self::SESSION_KEY);
276  return (array)$session['rcp_to'];
277  }
278 }
$cmd
Definition: sahs_server.php:35
static get($a_var)
Get a value.
static set($a_var, $a_val)
Set a value.
Statically used helper class for generating links to the mail form user interface.
$url
Definition: shib_logout.php:72
static storeReferer($request_params)
const CONTEXT_PREFIX
Session parameter for the context.
global $ilCtrl
Definition: ilias.php:18
const REFERER_KEY
HTTP-GET parameter for the referer url.
static setContextParameters(array $parameters)
Create styles array
The data for the language used.
const SIGNATURE_KEY
Session parameter for the hash.
const CONTEXT_KEY
Session parameter for the context.
static getLinkTarget($gui, $cmd, Array $gui_params=array(), Array $mail_params=array(), $context_params=array())
static getRedirectTarget($gui, $cmd, array $gui_params=array(), array $mail_params=array(), array $context_params=array())
static getSignature()
Get preset signature.
static setRecipients(array $recipients)