-
-
Save anonymous/0d08e66e610a828592d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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