Elgg  Version 4.3
RedirectService.php
Go to the documentation of this file.
1 <?php
2 namespace Elgg;
3 
8 
12  protected $session;
13 
17  protected $is_xhr;
18 
22  protected $site_url;
23 
27  protected $current_url;
28 
37  $this->session = $session;
38  $this->is_xhr = $request->isXmlHttpRequest();
39  $this->site_url = $config->wwwroot;
40  $this->current_url = $request->getCurrentURL();
41  }
42 
48  public function setLastForwardFrom() {
49  if ($this->is_xhr) {
50  return;
51  }
52 
53  if (0 !== elgg_strpos($this->current_url, $this->site_url)) {
54  return;
55  }
56  $path = elgg_substr($this->current_url, elgg_strlen($this->site_url));
57 
58  $patterns = [
59  '~^action/~',
60  '~^cache/~',
61  '~^serve-file/~',
62  ];
63  foreach ($patterns as $pattern) {
64  if (preg_match($pattern, $path)) {
65  return;
66  }
67  }
68 
69  $this->session->set('last_forward_from', $this->current_url);
70  }
71 }
$request
Definition: livesearch.php:11
setLastForwardFrom()
Capture the URL the user requested when they were redirected.
elgg_strlen()
Wrapper function for mb_strlen().
Definition: mb_wrapper.php:52
$config
Advanced site settings, debugging section.
Definition: debugging.php:6
$path
Definition: details.php:68
Handles common tasks when redirecting a request.
elgg_strpos()
Wrapper function for mb_strpos().
Definition: mb_wrapper.php:69
__construct(\ElggSession $session,\Elgg\Http\Request $request,\Elgg\Config $config)
Constructor.
elgg_substr()
Wrapper function for mb_substr().
Definition: mb_wrapper.php:219
if(isset($_COOKIE['elggperm'])) $session
Definition: login_as.php:28
Request container.
Definition: Request.php:12