mirror of
https://github.com/processwire/processwire.git
synced 2025-08-24 15:23:11 +02:00
Update ProcessPageEdit and ProcessPageList to implement the getAfterLoginUrl() method
This commit is contained in:
@@ -3072,6 +3072,42 @@ class ProcessPageEdit extends Process implements WirePageEditor, ConfigurableMod
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* URL to redirect to after non-authenticated user is logged-in, or false if module does not support
|
||||
*
|
||||
* @param Page $page
|
||||
* @return bool|string
|
||||
* @sine 3.0.167
|
||||
*
|
||||
*/
|
||||
public static function getAfterLoginUrl(Page $page) {
|
||||
$sanitizer = $page->wire()->sanitizer;
|
||||
$input = $page->wire()->input;
|
||||
if($input->urlSegmentStr === 'bookmarks') return $page->url . 'bookmarks/';
|
||||
$qs = array(
|
||||
'id' => (int) $input->get('id'),
|
||||
'language' => (int) $input->get('language'),
|
||||
'template' => (int) $input->get('template'), // used by executeTemplate() only
|
||||
'uploadOnlyMode' => (int) $input->get('uploadOnlyMode'),
|
||||
'fnsx' => $input->get->fieldName('fnsx'),
|
||||
'context' => $input->get->name('context'),
|
||||
'field' => $input->get->fieldName('field'),
|
||||
'fields' => array(),
|
||||
);
|
||||
if($input->urlSegmentStr === 'template') {
|
||||
return "$page->url?id=$qs[id]&template=$qs[template]";
|
||||
}
|
||||
if($input->get('fields')) {
|
||||
foreach(explode(',', $input->get('fields')) as $value) {
|
||||
$qs['fields'] .= ($qs['fields'] ? ',' : '') . $sanitizer->fieldName($value);
|
||||
}
|
||||
}
|
||||
$a = array();
|
||||
foreach($qs as $name => $value) {
|
||||
if(!empty($value)) $a[] = "$name=$value";
|
||||
}
|
||||
return "$page->url?" . implode('&', $a);
|
||||
}
|
||||
|
||||
/**
|
||||
* Module config
|
||||
|
@@ -646,6 +646,34 @@ class ProcessPageList extends Process implements ConfigurableModule {
|
||||
return $bookmarks->editBookmarks();
|
||||
}
|
||||
|
||||
/**
|
||||
* URL to redirect to after non-authenticated user is logged-in, or false if module does not support
|
||||
*
|
||||
* @param Page $page
|
||||
* @return bool|string
|
||||
* @sine 3.0.167
|
||||
*
|
||||
*/
|
||||
public static function getAfterLoginUrl(Page $page) {
|
||||
$url = $page->url();
|
||||
$input = $page->wire()->input;
|
||||
list($s1, $s2) = array($input->urlSegment1, $input->urlSegment2);
|
||||
if(ctype_digit($s2) && ($s1 === 'id' || $s1 === 'open')) {
|
||||
return $url . "$s1/" . (int) $s2; // i.e. /id/123 or /open/456
|
||||
} else {
|
||||
$intVars = array('limit', 'start', 'lang', 'open', 'id', 'n');
|
||||
$data = array();
|
||||
foreach($intVars as $name) {
|
||||
$value = (int) $input->get($name);
|
||||
if($value > 0) $data[$name] = $value;
|
||||
}
|
||||
$render = $input->get->name('render');
|
||||
if($render) $data['render'] = strtoupper($render);
|
||||
if(count($data)) $url .= "?" . implode('&', $data);
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a form allowing configuration of this Module
|
||||
*
|
||||
|
Reference in New Issue
Block a user