ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 global $DIC;
77
78 $mparams = '';
79 $referer = '';
80
81 foreach ($mail_params as $key => $value) {
82 $mparams .= $argument_separator . $key . '=' . urlencode($value);
83 }
84
85 foreach ($context_params as $key => $value) {
86 if ($key == self::CONTEXT_KEY) {
87 $mparams .= $argument_separator . $key . '=' . urlencode($value);
88 } else {
89 $mparams .= $argument_separator . self::CONTEXT_PREFIX . '_' . $key . '=' . urlencode($value);
90 }
91 }
92
93 if (is_object($gui)) {
94 $ilCtrlTmp = clone $DIC->ctrl();
95 foreach ($gui_params as $key => $value) {
96 $ilCtrlTmp->setParameter($gui, $key, $value);
97 }
98 $referer = $ilCtrlTmp->getLinkTarget($gui, $cmd, '', false, false);
99 } elseif (is_string($gui)) {
100 $referer = $gui;
101 }
102
103 $referer = $argument_separator . self::REFERER_KEY . '=' . rawurlencode(base64_encode($referer));
104
105 return 'ilias.php?baseClass=ilMailGUI' . $referer . $mparams;
106 }
107
112 public static function storeReferer($request_params)
113 {
114 $session = ilSession::get(self::SESSION_KEY);
115 if (isset($request_params[self::REFERER_KEY])) {
116 $session[self::REFERER_KEY] = base64_decode(rawurldecode($request_params[self::REFERER_KEY]));
117 $session[self::SIGNATURE_KEY] = base64_decode(rawurldecode($request_params[self::SIGNATURE_KEY]));
118
119 $ctx_params = array();
120 foreach ($request_params as $key => $value) {
121 $prefix = substr($key, 0, strlen(self::CONTEXT_PREFIX));
122 if ($prefix == self::CONTEXT_PREFIX) {
123 if ($key == self::CONTEXT_KEY) {
124 $ctx_params[$key] = $value;
125 } else {
126 $ctx_params[substr($key, strlen(self::CONTEXT_PREFIX . '_'))] = $value;
127 }
128 }
129 }
130 $session[self::CONTEXT_PREFIX] = $ctx_params;
131 } else {
132 unset($session[self::REFERER_KEY]);
133 unset($session[self::SIGNATURE_KEY]);
134 unset($session[self::CONTEXT_PREFIX]);
135 }
136 ilSession::set(self::SESSION_KEY, $session);
137 }
138
144 public static function getSignature()
145 {
146 $session = ilSession::get(self::SESSION_KEY);
147
149
150 unset($session[self::SIGNATURE_KEY]);
151 ilSession::set(self::SESSION_KEY, $session);
152
153 return $sig;
154 }
155
160 public static function getRefererRedirectUrl()
161 {
162 $session = ilSession::get(self::SESSION_KEY);
163
165 if (strlen($url)) {
166 $parts = parse_url($url);
167 if (isset($parts['query']) && strlen($parts['query'])) {
168 $url .= '&returned_from_mail=1';
169 } else {
170 $url .= '?returned_from_mail=1';
171 }
172
173 $ilias_url_parts = parse_url(ilUtil::_getHttpPath());
174 if (isset($parts['host']) && $ilias_url_parts['host'] !== $parts['host']) {
175 $url = 'ilias.php?baseClass=ilMailGUI';
176 }
177 }
178
179 unset($session[self::REFERER_KEY]);
180 ilSession::set(self::SESSION_KEY, $session);
181
182 return $url;
183 }
184
189 public static function isRefererStored()
190 {
191 $session = ilSession::get(self::SESSION_KEY);
192 return isset($session[self::REFERER_KEY]) && strlen($session[self::REFERER_KEY]) ? true : false;
193 }
194
198 public static function getContextId()
199 {
200 $session = ilSession::get(self::SESSION_KEY);
201 return (
202 isset($session[self::CONTEXT_PREFIX][self::CONTEXT_KEY]) &&
203 strlen($session[self::CONTEXT_PREFIX][self::CONTEXT_KEY]) ?
204 $session[self::CONTEXT_PREFIX][self::CONTEXT_KEY] : null
205 );
206 }
207
211 public static function setContextId($id)
212 {
213 $session = ilSession::get(self::SESSION_KEY);
215 ilSession::set(self::SESSION_KEY, $session);
216 }
217
221 public static function getContextParameters()
222 {
223 $session = ilSession::get(self::SESSION_KEY);
224 if (isset($session[self::CONTEXT_PREFIX])) {
225 return (array) $session[self::CONTEXT_PREFIX];
226 }
227 return array();
228 }
229
234 public static function setContextParameters(array $parameters)
235 {
236 $session = ilSession::get(self::SESSION_KEY);
237 $session[self::CONTEXT_PREFIX] = $parameters;
238 ilSession::set(self::SESSION_KEY, $session);
239 }
240
244 public static function setRecipients(array $recipients)
245 {
246 $session = ilSession::get(self::SESSION_KEY);
247 $session['rcp_to'] = $recipients;
248 ilSession::set(self::SESSION_KEY, $session);
249 }
250
254 public static function getRecipients()
255 {
256 $session = ilSession::get(self::SESSION_KEY);
257 return (array) $session['rcp_to'];
258 }
259}
An exception for terminatinating execution or to throw for unit testing.
Statically used helper class for generating links to the mail form user interface.
const REFERER_KEY
HTTP-GET parameter for the referer url.
static getRedirectTarget($gui, $cmd, array $gui_params=array(), array $mail_params=array(), array $context_params=array())
const CONTEXT_PREFIX
Session parameter for the context.
static getLinkTarget($gui, $cmd, array $gui_params=array(), array $mail_params=array(), $context_params=array())
static storeReferer($request_params)
static getSignature()
Get preset signature.
static getTargetUrl($argument_separator, $gui, $cmd, array $gui_params=array(), array $mail_params=array(), array $context_params=array())
const SIGNATURE_KEY
Session parameter for the hash.
static setRecipients(array $recipients)
const CONTEXT_KEY
Session parameter for the context.
static setContextParameters(array $parameters)
static set($a_var, $a_val)
Set a value.
static get($a_var)
Get a value.
static _getHttpPath()
$session
$url
$DIC
Definition: xapitoken.php:46