Skip to content

Instantly share code, notes, and snippets.

Created July 31, 2013 23:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/0d08e66e610a828592d4 to your computer and use it in GitHub Desktop.
Save anonymous/0d08e66e610a828592d4 to your computer and use it in GitHub Desktop.
<?php
class MemberLoginAttempts extends DataExtension implements PermissionProvider {
public static $db = array(
"IgnoreIP" => "boolean"
);
public static $has_many = array(
"LoginAttempts" => "LoginAttempt"
);
public function updateCMSFields(FieldList $fields) {
$fields->removeByName("LoginAttempts");
$fields->addFieldToTab("Root.Main", new CheckboxField("IgnoreIP", "Ignore multiple IPs for this user"), "Password");
$fields->addFieldToTab("Root.LoginAttempts", new GridField("LoginAttempts", "Login Attempts", $this->owner->LoginAttempts(), $config = new GridFieldConfig_RelationEditor()));
$config->getComponentByType("GridFieldDataColumns")->setDisplayFields(array(
"Created" => array(
"title" => "Time"
),
"IP" => array(
"title" => "IP Address"
),
"Status" => array(
"title" => "Result"
)
));
}
public function canView(Member $member = null) {
return Permission::check("LOGIN_ATTEMPTS_VIEW", "any", $member);
}
public function providePermissions() {
$category = "Customer Service";
return array (
"LOGIN_ATTEMPTS_VIEW" => array (
"category" => $category,
"name" => "View Login Attempts"
)
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment