diff --git a/control/Controller.php b/control/Controller.php index 0f7b124e3..df424c000 100644 --- a/control/Controller.php +++ b/control/Controller.php @@ -415,23 +415,6 @@ class Controller extends RequestHandler implements TemplateGlobalProvider { $d->setValue(date("Y-m-d h:i:s")); return $d; } - - /** - * Returns the currently logged in user - */ - function CurrentMember() { - return Member::currentUser(); - } - - /** - * Return true if the visitor has signed up for a login account before - * @return boolean - */ - function PastMember() { - return Cookie::get("PastMember") ? true : false; - } - - /** * Pushes this controller onto the stack of current controllers. * This means that any redirection, session setting, or other things that rely on Controller::curr() will now write to this * controller object. diff --git a/docs/en/reference/built-in-page-controls.md b/docs/en/reference/built-in-page-controls.md index 73ff32f1c..e4a3c4b08 100644 --- a/docs/en/reference/built-in-page-controls.md +++ b/docs/en/reference/built-in-page-controls.md @@ -210,13 +210,13 @@ If the user is logged in this will print out Welcome Back, Admin -#### <% if PastMember %> +#### <% if IsRepeatMember %> -Detect the visitor's previous experience with the site. `$PastMember` will return true if the visitor has signed up or -logged in on the site before. +Detect the visitor's previous experience with the site. `$IsRepeatMember` will return true if the visitor has signed up or logged in on the site before. -Note that as of version 2.4 `$PastVisitor` is deprecated. If you wish to check if a visitor has been to the site before, -set a cookie with `Cookie::set()` and test for it with `Cookie::get()`. +Note that as of version 2.4 `$PastVisitor` is deprecated. If you wish to check if a visitor has been to the site before, set a cookie with `Cookie::set()` and test for it with `Cookie::get()`. + +Note that in 2.4 this variable was called `$PastMember`. This still works in 3.0 but is deprecated. ### Date and Time diff --git a/security/Member.php b/security/Member.php index b1e12a1c7..e4a44e761 100644 --- a/security/Member.php +++ b/security/Member.php @@ -559,7 +559,13 @@ class Member extends DataObject implements TemplateGlobalProvider { return DataObject::get_one("Member", "\"Member\".\"ID\" = $id", true, 1); } } - + + /** + * Returns true if the current member is a repeat visitor who has logged in more than once. + */ + static function is_repeat_member() { + return Cookie::get("PastMember") ? true : false; + } /** * Get the ID of the current logged in user @@ -1377,7 +1383,9 @@ class Member extends DataObject implements TemplateGlobalProvider { public static function get_template_global_variables() { return array( 'CurrentMember' => 'currentUser', - 'currentUser' + 'currentUser', + 'PastMember' => 'is_repeat_member', + 'IsRepeatMember' => 'is_repeat_member', ); } }