Elgg  Version 2.3
RedirectService.php
Go to the documentation of this file.
1 <?php
2 namespace Elgg;
3 
5 
10 
14  protected $session;
15 
19  protected $is_xhr;
20 
24  protected $site_url;
25 
29  protected $current_url;
30 
39  public function __construct(ElggSession $session, $is_xhr, $site_url, $current_url) {
40  $this->session = $session;
41  $this->is_xhr = $is_xhr;
42  $this->site_url = $site_url;
43  $this->current_url = $current_url;
44  }
45 
51  public function setLastForwardFrom() {
52  if ($this->is_xhr) {
53  return;
54  }
55 
56  if (0 !== strpos($this->current_url, $this->site_url)) {
57  return;
58  }
59  $path = substr($this->current_url, strlen($this->site_url));
60 
61  $patterns = [
62  '~^action/~',
63  '~^cache/~',
64  '~^serve-file/~',
65  ];
66  foreach ($patterns as $pattern) {
67  if (preg_match($pattern, $path)) {
68  return;
69  }
70  }
71 
72  $this->session->set('last_forward_from', $this->current_url);
73  }
74 }
__construct(ElggSession $session, $is_xhr, $site_url, $current_url)
Constructor.
$path
Definition: details.php:88
setLastForwardFrom()
Capture the URL the user requested when they were redirected.
Handles common tasks when redirecting a request.
Save menu items.
$site_url
Definition: header_logo.php:8
$session
Definition: login.php:9
http free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:5