API CHANGE: Rename 'PastMember' to 'IsRepeatMember' in templates.

API CHANGE: Move Controller::PastMember() to Member::is_repeat_member() in code.
API CHANGE: Removed Controller::CurrentMember(), it was only ever intended as a template global provider.
This commit is contained in:
Sam Minnee 2012-03-16 14:14:45 +13:00
parent acdd07ac6f
commit 6c35588eda
3 changed files with 15 additions and 24 deletions

View File

@ -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.

View File

@ -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

View File

@ -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',
);
}
}