Skip to content

Commit

Permalink
Converted to PSR-2
Browse files Browse the repository at this point in the history
  • Loading branch information
helpfulrobot committed Dec 31, 2015
1 parent 0a5a61a commit 1c4258a
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 86 deletions.
22 changes: 14 additions & 8 deletions code/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
* @author i-lateral (http://www.i-lateral.com)
* @package users
*/
class Users extends Object {
class Users extends Object
{

/**
* Stipulate if a user requires verification. NOTE this does not
Expand Down Expand Up @@ -63,7 +64,8 @@ class Users extends Object {
*
* @param string Group code that will be used
*/
public static function addNewUserGroup($code) {
public static function addNewUserGroup($code)
{
self::$new_user_groups[] = $code;
}

Expand All @@ -73,9 +75,11 @@ public static function addNewUserGroup($code) {
*
* @param string Group code that will be used
*/
public static function removeNewUserGroup($code) {
if(isset(self::$new_user_groups[$code]))
public static function removeNewUserGroup($code)
{
if (isset(self::$new_user_groups[$code])) {
unset(self::$new_user_groups[$code]);
}
}

/**
Expand All @@ -95,7 +99,8 @@ public static function removeNewUserGroup($code) {
*
* @param string Group code that will be used
*/
public static function addVerificationGroup($code) {
public static function addVerificationGroup($code)
{
self::$verification_groups[] = $code;
}

Expand All @@ -105,9 +110,10 @@ public static function addVerificationGroup($code) {
*
* @param string Group code that will be used
*/
public static function removeVerificationGroup($code) {
if(isset(self::$verification_groups[$code]))
public static function removeVerificationGroup($code)
{
if (isset(self::$verification_groups[$code])) {
unset(self::$verification_groups[$code]);
}
}

}
60 changes: 36 additions & 24 deletions code/control/Users_Account_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
* the front end of the site.
*
*/
class Users_Account_Controller extends Controller implements PermissionProvider {
class Users_Account_Controller extends Controller implements PermissionProvider
{

protected $member;

Expand All @@ -29,24 +30,30 @@ class Users_Account_Controller extends Controller implements PermissionProvider
*
* @return Boolean
*/
public function RequireVerification() {
if(!$this->member->isVerified() && Users::config()->require_verification)
public function RequireVerification()
{
if (!$this->member->isVerified() && Users::config()->require_verification) {
return true;
else
} else {
return false;
}
}

public function init() {
public function init()
{
parent::init();

// Check we are logged in as a user who can access front end management
if(!Permission::check("USERS_MANAGE_ACCOUNT")) Security::permissionFailure();
if (!Permission::check("USERS_MANAGE_ACCOUNT")) {
Security::permissionFailure();
}

// Set our member object
$this->member = Member::currentUser();
}

public function Link($action = null) {
public function Link($action = null)
{
return Controller::join_links(
BASE_URL,
$this->config()->url_segment,
Expand All @@ -58,7 +65,8 @@ public function Link($action = null) {
* Display the currently outstanding orders for the current user
*
*/
public function index() {
public function index()
{
$member = Member::currentUser();

$this->customise(array(
Expand All @@ -74,7 +82,8 @@ public function index() {
));
}

public function edit() {
public function edit()
{
$member = Member::currentUser();

$this->customise(array(
Expand All @@ -91,9 +100,10 @@ public function edit() {
));
}

public function changepassword() {
public function changepassword()
{
// Set the back URL for this form
Session::set("BackURL",$this->Link("changepassword"));
Session::set("BackURL", $this->Link("changepassword"));

$this->customise(array(
"ClassName" => "AccountPage",
Expand All @@ -115,7 +125,8 @@ public function changepassword() {
*
* @return Form
*/
public function EditAccountForm() {
public function EditAccountForm()
{
$form = Users_EditAccountForm::create($this, "EditAccountForm");

$this->extend("updateEditAccountForm", $form);
Expand All @@ -129,12 +140,13 @@ public function EditAccountForm() {
*
* @return Form
*/
public function ChangePasswordForm() {
$form = ChangePasswordForm::create($this,"ChangePasswordForm");
public function ChangePasswordForm()
{
$form = ChangePasswordForm::create($this, "ChangePasswordForm");

$form
->Actions()
->find("name","action_doChangePassword")
->find("name", "action_doChangePassword")
->addExtraClass("btn")
->addExtraClass("btn-green");

Expand All @@ -145,7 +157,7 @@ public function ChangePasswordForm() {

$form
->Actions()
->insertBefore($cancel_btn,"action_doChangePassword");
->insertBefore($cancel_btn, "action_doChangePassword");

$this->extend("updateChangePasswordForm", $form);

Expand All @@ -158,38 +170,40 @@ public function ChangePasswordForm() {
*
* @return ArrayList
*/
public function getAccountMenu() {
public function getAccountMenu()
{
$menu = new ArrayList();

$curr_action = $this->request->param("Action");

$menu->add(new ArrayData(array(
"ID" => 0,
"Title" => _t('Users.PROFILESUMMARY',"Profile Summary"),
"Title" => _t('Users.PROFILESUMMARY', "Profile Summary"),
"Link" => $this->Link(),
"LinkingMode" => (!$curr_action) ? "current" : "link"
)));

$menu->add(new ArrayData(array(
"ID" => 10,
"Title" => _t('Users.EDITDETAILS',"Edit account details"),
"Title" => _t('Users.EDITDETAILS', "Edit account details"),
"Link" => $this->Link("edit"),
"LinkingMode" => ($curr_action == "edit") ? "current" : "link"
)));

$menu->add(new ArrayData(array(
"ID" => 30,
"Title" => _t('Users.CHANGEPASSWORD',"Change password"),
"Title" => _t('Users.CHANGEPASSWORD', "Change password"),
"Link" => $this->Link("changepassword"),
"LinkingMode" => ($curr_action == "changepassword") ? "current" : "link"
)));

$this->extend("updateAccountMenu", $menu);

return $menu->sort("ID","ASC");
return $menu->sort("ID", "ASC");
}

public function providePermissions() {
public function providePermissions()
{
return array(
"USERS_MANAGE_ACCOUNT" => array(
'name' => 'Manage user account',
Expand All @@ -205,6 +219,4 @@ public function providePermissions() {
),
);
}


}
Loading

0 comments on commit 1c4258a

Please sign in to comment.