Permalink
Browse files

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.
  • Loading branch information...
sminnee committed Mar 16, 2012
1 parent acdd07a commit 6c35588eda36d2433469adcde7d3afca53b40e0c
Showing with 15 additions and 24 deletions.
  1. +0 −17 control/Controller.php
  2. +5 −5 docs/en/reference/built-in-page-controls.md
  3. +10 −2 security/Member.php
View
@@ -415,23 +415,6 @@ function Now() {
$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.
@@ -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
@@ -559,7 +559,13 @@ static function currentUser() {
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 @@ function getHtmlEditorConfigForCMS() {
public static function get_template_global_variables() {
return array(
'CurrentMember' => 'currentUser',
- 'currentUser'
+ 'currentUser',
+ 'PastMember' => 'is_repeat_member',
+ 'IsRepeatMember' => 'is_repeat_member',
);
}
}

0 comments on commit 6c35588

Please sign in to comment.