From 6fd6cd379b05056e150fd41676bc9d5b3e8de66d Mon Sep 17 00:00:00 2001 From: Joris Debonnet Date: Wed, 21 Feb 2018 04:09:39 +0100 Subject: [PATCH 01/13] Rename src/Controllers to src/Pages and move all Page-stuff there --- .upgrade.yml | 8 ++++---- _config/legacy.yml | 2 +- _config/routes.yml | 2 +- lang/de.yml | 2 +- lang/en_US.php | 2 +- lang/es_ES.php | 2 +- lang/sk.yml | 2 +- src/Extensions/MemberProfileExtension.php | 4 ++-- src/Model/MemberProfileField.php | 2 +- src/Model/MemberProfileFieldsSection.php | 1 - src/Model/MemberProfileSection.php | 2 +- .../MemberApprovalController.php | 2 +- src/{Model => Pages}/MemberProfilePage.php | 3 +-- .../MemberProfilePageController.php | 13 +++++-------- src/{Controllers => Pages}/MemberProfileViewer.php | 3 +-- tests/MemberConfirmationEmailTest.php | 2 +- 16 files changed, 23 insertions(+), 29 deletions(-) rename src/{Controllers => Pages}/MemberApprovalController.php (98%) rename src/{Model => Pages}/MemberProfilePage.php (99%) rename src/{Model => Pages}/MemberProfilePageController.php (97%) rename src/{Controllers => Pages}/MemberProfileViewer.php (97%) diff --git a/.upgrade.yml b/.upgrade.yml index b4dd023b..3ddd488f 100644 --- a/.upgrade.yml +++ b/.upgrade.yml @@ -1,13 +1,13 @@ mappings: - MemberProfilePageController: Symbiote\MemberProfiles\Controllers\MemberProfilePageController - MemberApprovalController: Symbiote\MemberProfiles\Controllers\MemberApprovalController - MemberProfileViewer: Symbiote\MemberProfiles\Controllers\MemberProfileViewer + MemberProfilePageController: Symbiote\MemberProfiles\Pages\MemberProfilePageController + MemberApprovalController: Symbiote\MemberProfiles\Pages\MemberApprovalController + MemberProfileViewer: Symbiote\MemberProfiles\Pages\MemberProfileViewer MemberConfirmationEmail: Symbiote\MemberProfiles\Email\MemberConfirmationEmail MemberProfileValidator: Symbiote\MemberProfiles\Forms\MemberProfileValidator MemberProfilesAddSectionAction: Symbiote\MemberProfiles\Forms\MemberProfilesAddSectionAction MemberProfilesAddSectionAction_ItemRequest: Symbiote\MemberProfiles\Forms\MemberProfilesAddSectionAction_ItemRequest CheckableVisibilityField: Symbiote\MemberProfiles\Forms\CheckableVisibilityField - MemberProfilePage: Symbiote\MemberProfiles\Model\MemberProfilePage + MemberProfilePage: Symbiote\MemberProfiles\Pages\MemberProfilePage MemberProfileSection: Symbiote\MemberProfiles\Model\MemberProfileSection MemberProfileFieldsSection: Symbiote\MemberProfiles\Model\MemberProfileFieldsSection MemberProfileField: Symbiote\MemberProfiles\Model\MemberProfileField diff --git a/_config/legacy.yml b/_config/legacy.yml index 108e2511..9b102055 100644 --- a/_config/legacy.yml +++ b/_config/legacy.yml @@ -3,7 +3,7 @@ Name: memberprofileslegacy --- SilverStripe\ORM\DatabaseAdmin: classname_value_remapping: - MemberProfilePage: Symbiote\MemberProfiles\Model\MemberProfilePage + MemberProfilePage: Symbiote\MemberProfiles\Pages\MemberProfilePage MemberProfileSection: Symbiote\MemberProfiles\Model\MemberProfileSection MemberProfileFieldsSection: Symbiote\MemberProfiles\Model\MemberProfileFieldsSection MemberProfileField: Symbiote\MemberProfiles\Model\MemberProfileField diff --git a/_config/routes.yml b/_config/routes.yml index e003c178..377aa4c4 100644 --- a/_config/routes.yml +++ b/_config/routes.yml @@ -4,4 +4,4 @@ After: framework/routes#coreroutes --- SilverStripe\Control\Director: rules: - member-approval: Symbiote\MemberProfiles\Controllers\MemberApprovalController + member-approval: Symbiote\MemberProfiles\Pages\MemberApprovalController diff --git a/lang/de.yml b/lang/de.yml index fe284738..19968546 100644 --- a/lang/de.yml +++ b/lang/de.yml @@ -89,7 +89,7 @@ de: Symbiote\MemberProfiles\Model\MemberProfileField: PLURALNAME: 'Mitglieds-Profil Felder' SINGULARNAME: 'Mitglieds-Profil Feld' - Symbiote\MemberProfiles\Model\MemberProfilePage: + Symbiote\MemberProfiles\Pages\MemberProfilePage: DESCRIPTION: 'Profil & Registrierungsseiten für Mitglieder' PLURALNAME: 'Mitglieds-Profil Seiten' SINGULARNAME: 'Mitglieds-Profil Seite' diff --git a/lang/en_US.php b/lang/en_US.php index 281ff6cd..3f07a69e 100644 --- a/lang/en_US.php +++ b/lang/en_US.php @@ -1,7 +1,7 @@ MemberProfilePage::class + 'ProfilePage' => MemberProfilePage::class ); public function getPublicFields() { diff --git a/src/Model/MemberProfileField.php b/src/Model/MemberProfileField.php index 4b6c4cf4..91b1f2cf 100644 --- a/src/Model/MemberProfileField.php +++ b/src/Model/MemberProfileField.php @@ -1,7 +1,7 @@ Date: Fri, 23 Feb 2018 08:08:42 +0100 Subject: [PATCH 02/13] Move page templates into namespaced directories --- .../Includes}/MemberProfilePage_profile.ss | 34 +++++++++---------- .../Includes}/MemberProfilePage_register.ss | 26 +++++++------- .../Includes}/MemberProfileViewer_list.ss | 0 .../Includes}/MemberProfileViewer_view.ss | 0 4 files changed, 30 insertions(+), 30 deletions(-) rename templates/{Layout => Symbiote/MemberProfiles/Pages/Includes}/MemberProfilePage_profile.ss (96%) rename templates/{Layout => Symbiote/MemberProfiles/Pages/Includes}/MemberProfilePage_register.ss (96%) rename templates/{Layout => Symbiote/MemberProfiles/Pages/Includes}/MemberProfileViewer_list.ss (100%) rename templates/{Layout => Symbiote/MemberProfiles/Pages/Includes}/MemberProfileViewer_view.ss (100%) diff --git a/templates/Layout/MemberProfilePage_profile.ss b/templates/Symbiote/MemberProfiles/Pages/Includes/MemberProfilePage_profile.ss similarity index 96% rename from templates/Layout/MemberProfilePage_profile.ss rename to templates/Symbiote/MemberProfiles/Pages/Includes/MemberProfilePage_profile.ss index 16db6a6c..f599021d 100644 --- a/templates/Layout/MemberProfilePage_profile.ss +++ b/templates/Symbiote/MemberProfiles/Pages/Includes/MemberProfilePage_profile.ss @@ -1,17 +1,17 @@ -
-

$Title

- -
- $Content - - <% if $CanAddMembers %> -

<%t MemberProfiles.ADDMEMBER 'Add Member' %>

-

<%t MemberProfiles.ADDMEMBERLINK 'You can use this page to add a new member.' addLink=$Link(add) %>

- -

<%t MemberProfiles.YOURPROFILE 'Your Profile' %>

- $Form - <% else %> - $Form - <% end_if %> -
-
+
+

$Title

+ +
+ $Content + + <% if $CanAddMembers %> +

<%t MemberProfiles.ADDMEMBER 'Add Member' %>

+

<%t MemberProfiles.ADDMEMBERLINK 'You can use this page to add a new member.' addLink=$Link(add) %>

+ +

<%t MemberProfiles.YOURPROFILE 'Your Profile' %>

+ $Form + <% else %> + $Form + <% end_if %> +
+
diff --git a/templates/Layout/MemberProfilePage_register.ss b/templates/Symbiote/MemberProfiles/Pages/Includes/MemberProfilePage_register.ss similarity index 96% rename from templates/Layout/MemberProfilePage_register.ss rename to templates/Symbiote/MemberProfiles/Pages/Includes/MemberProfilePage_register.ss index eeffd062..7c5ab945 100644 --- a/templates/Layout/MemberProfilePage_register.ss +++ b/templates/Symbiote/MemberProfiles/Pages/Includes/MemberProfilePage_register.ss @@ -1,13 +1,13 @@ -
-

$Title

- -
- $Content - -

<%t MemberProfiles.LOGINHEADER "Log in" %>

-

<%t MemberProfiles.LOGIN "If you already have an account, you can log in here." loginLink=$LoginLink %>

- -

<%t MemberProfiles.REGISTER "Register" %>

- $Form -
-
+
+

$Title

+ +
+ $Content + +

<%t MemberProfiles.LOGINHEADER "Log in" %>

+

<%t MemberProfiles.LOGIN "If you already have an account, you can log in here." loginLink=$LoginLink %>

+ +

<%t MemberProfiles.REGISTER "Register" %>

+ $Form +
+
diff --git a/templates/Layout/MemberProfileViewer_list.ss b/templates/Symbiote/MemberProfiles/Pages/Includes/MemberProfileViewer_list.ss similarity index 100% rename from templates/Layout/MemberProfileViewer_list.ss rename to templates/Symbiote/MemberProfiles/Pages/Includes/MemberProfileViewer_list.ss diff --git a/templates/Layout/MemberProfileViewer_view.ss b/templates/Symbiote/MemberProfiles/Pages/Includes/MemberProfileViewer_view.ss similarity index 100% rename from templates/Layout/MemberProfileViewer_view.ss rename to templates/Symbiote/MemberProfiles/Pages/Includes/MemberProfileViewer_view.ss From c3202464cb35b98cc55a9bc2b8f83170dc1d3374 Mon Sep 17 00:00:00 2001 From: Joris Debonnet Date: Fri, 23 Feb 2018 08:04:28 +0100 Subject: [PATCH 03/13] Refactor page templates --- src/Pages/MemberProfilePageController.php | 37 +++---- src/Pages/MemberProfileViewer.php | 12 +-- .../Includes/MemberProfilePage_addmember.ss | 7 ++ .../Includes/MemberProfilePage_profile.ss | 23 ++--- .../Includes/MemberProfilePage_register.ss | 17 ++-- .../Includes/MemberProfileViewer_list.ss | 96 +++++++++---------- .../Includes/MemberProfileViewer_view.ss | 26 ++--- .../Pages/Layout/MemberProfilePage.ss | 11 +++ .../Pages/Layout/MemberProfileViewer.ss | 10 ++ 9 files changed, 125 insertions(+), 114 deletions(-) create mode 100644 templates/Symbiote/MemberProfiles/Pages/Includes/MemberProfilePage_addmember.ss create mode 100644 templates/Symbiote/MemberProfiles/Pages/Layout/MemberProfilePage.ss create mode 100644 templates/Symbiote/MemberProfiles/Pages/Layout/MemberProfileViewer.ss diff --git a/src/Pages/MemberProfilePageController.php b/src/Pages/MemberProfilePageController.php index 5c9fc1f2..5716446c 100644 --- a/src/Pages/MemberProfilePageController.php +++ b/src/Pages/MemberProfilePageController.php @@ -47,12 +47,8 @@ public function index() { if (isset($_GET['BackURL'])) { Session::set('MemberProfile.REDIRECT', $_GET['BackURL']); } - $mode = Member::currentUser() ? 'profile' : 'register'; - $data = Member::currentUser() ? $this->indexProfile() : $this->indexRegister(); - if (is_array($data)) { - return $this->customise($data)->renderWith(array('MemberProfilePage_'.$mode, MemberProfilePage::class, 'Page')); - } - return $data; + + return Member::currentUser() ? $this->indexProfile() : $this->indexRegister(); } /** @@ -66,11 +62,14 @@ protected function indexRegister() { 'You cannot register on this profile page. Please login to edit your profile.' )); - return array ( - 'Title' => $this->obj('RegistrationTitle'), - 'Content' => $this->obj('RegistrationContent'), - 'Form' => $this->RegisterForm() - ); + $data = array( + 'Type' => 'Register', + 'Title' => $this->obj('RegistrationTitle'), + 'Content' => $this->obj('RegistrationContent'), + 'Form' => $this->RegisterForm() + ); + + return $this->customise($data); } /** @@ -116,11 +115,14 @@ protected function indexProfile() { } } - return array ( - 'Title' => $this->obj('ProfileTitle'), - 'Content' => $this->obj('ProfileContent'), - 'Form' => $form - ); + $data = array( + 'Type' => 'Profile', + 'Title' => $this->obj('ProfileTitle'), + 'Content' => $this->obj('ProfileContent'), + 'Form' => $form + ); + + return $this->customise($data); } /** @@ -255,12 +257,13 @@ public function add($request) { } $data = array( + 'Type' => 'Add', 'Title' => _t('MemberProfiles.ADDMEMBER', 'Add Member'), 'Content' => '', 'Form' => $this->AddForm() ); - return $this->customise($data)->renderWith(array('MemberProfilePage_add', MemberProfilePage::class, 'Page')); + return $this->customise($data); } /** diff --git a/src/Pages/MemberProfileViewer.php b/src/Pages/MemberProfileViewer.php index 871e8494..8c4c8f2b 100644 --- a/src/Pages/MemberProfileViewer.php +++ b/src/Pages/MemberProfileViewer.php @@ -87,11 +87,11 @@ public function handleList($request) { $this->data()->Parent = $this->parent; $controller = $this->customise(array( + 'Type' => 'List', 'Members' => $list )); - return $controller->renderWith(array( - 'MemberProfileViewer_list', MemberProfileViewer::class, 'Page' - )); + + return $controller; } /** @@ -128,13 +128,13 @@ public function handleView($request) { $this->data()->Parent = $this->parent; $controller = $this->customise(array( + 'Type' => 'View', 'Member' => $member, 'Sections' => $sectionsList, 'IsSelf' => $member->ID == Member::currentUserID() )); - return $controller->renderWith(array( - 'MemberProfileViewer_view', MemberProfileViewer::class, 'Page' - )); + + return $controller; } /** diff --git a/templates/Symbiote/MemberProfiles/Pages/Includes/MemberProfilePage_addmember.ss b/templates/Symbiote/MemberProfiles/Pages/Includes/MemberProfilePage_addmember.ss new file mode 100644 index 00000000..b7e3546a --- /dev/null +++ b/templates/Symbiote/MemberProfiles/Pages/Includes/MemberProfilePage_addmember.ss @@ -0,0 +1,7 @@ +
+ $Content + +

<%t MemberProfiles.ADDMEMBER 'Add Member' %>

+ + $Form +
diff --git a/templates/Symbiote/MemberProfiles/Pages/Includes/MemberProfilePage_profile.ss b/templates/Symbiote/MemberProfiles/Pages/Includes/MemberProfilePage_profile.ss index f599021d..21f63773 100644 --- a/templates/Symbiote/MemberProfiles/Pages/Includes/MemberProfilePage_profile.ss +++ b/templates/Symbiote/MemberProfiles/Pages/Includes/MemberProfilePage_profile.ss @@ -1,17 +1,12 @@ -
-

$Title

- -
- $Content +
+ $Content - <% if $CanAddMembers %> -

<%t MemberProfiles.ADDMEMBER 'Add Member' %>

-

<%t MemberProfiles.ADDMEMBERLINK 'You can use this page to add a new member.' addLink=$Link(add) %>

+ <% if $CanAddMembers %> +

<%t MemberProfiles.ADDMEMBER 'Add Member' %>

+

<%t MemberProfiles.ADDMEMBERLINK 'You can use this page to add a new member.' addLink=$Link(add) %>

-

<%t MemberProfiles.YOURPROFILE 'Your Profile' %>

- $Form - <% else %> - $Form - <% end_if %> -
+

<%t MemberProfiles.YOURPROFILE 'Your Profile' %>

+ <% end_if %> + + $Form
diff --git a/templates/Symbiote/MemberProfiles/Pages/Includes/MemberProfilePage_register.ss b/templates/Symbiote/MemberProfiles/Pages/Includes/MemberProfilePage_register.ss index 7c5ab945..830d734d 100644 --- a/templates/Symbiote/MemberProfiles/Pages/Includes/MemberProfilePage_register.ss +++ b/templates/Symbiote/MemberProfiles/Pages/Includes/MemberProfilePage_register.ss @@ -1,13 +1,10 @@ -
-

$Title

- -
- $Content +
+ $Content -

<%t MemberProfiles.LOGINHEADER "Log in" %>

-

<%t MemberProfiles.LOGIN "If you already have an account, you can log in here." loginLink=$LoginLink %>

+

<%t MemberProfiles.LOGINHEADER "Log in" %>

+

<%t MemberProfiles.LOGIN "If you already have an account, you can log in here." loginLink=$LoginLink %>

-

<%t MemberProfiles.REGISTER "Register" %>

- $Form -
+

<%t MemberProfiles.REGISTER "Register" %>

+ + $Form
diff --git a/templates/Symbiote/MemberProfiles/Pages/Includes/MemberProfileViewer_list.ss b/templates/Symbiote/MemberProfiles/Pages/Includes/MemberProfileViewer_list.ss index 74b33c1b..13f83597 100644 --- a/templates/Symbiote/MemberProfiles/Pages/Includes/MemberProfileViewer_list.ss +++ b/templates/Symbiote/MemberProfiles/Pages/Includes/MemberProfileViewer_list.ss @@ -1,56 +1,50 @@ -<% require css(memberprofiles/client/css/MemberProfileViewer.css) %> - -
-

$Title

- -
- - - - <% with Members.First %> - <% loop Fields %> - <% if Sortable %> - - <% else %> - - <% end_if %> - <% end_loop %> - <% end_with %> - - - - <% loop Members %> - - <% loop Fields %> - - <% end_loop %> - +
+
$Title$Title
$Value
+ + + <% with Members.First %> + <% loop Fields %> + <% if Sortable %> + + <% else %> + + <% end_if %> <% end_loop %> - -
$Title$Title
+ <% end_with %> + + + + <% loop Members %> + + <% loop Fields %> + $Value + <% end_loop %> + + <% end_loop %> + + - <% if Members.MoreThanOnePage %> - + <% end_if %> + <% end_loop %> + + <% if Members.NotLastPage %> + + <% end_if %> +
+ <% end_if %>
diff --git a/templates/Symbiote/MemberProfiles/Pages/Includes/MemberProfileViewer_view.ss b/templates/Symbiote/MemberProfiles/Pages/Includes/MemberProfileViewer_view.ss index 5e4974ae..4eeacf61 100644 --- a/templates/Symbiote/MemberProfiles/Pages/Includes/MemberProfileViewer_view.ss +++ b/templates/Symbiote/MemberProfiles/Pages/Includes/MemberProfileViewer_view.ss @@ -1,17 +1,11 @@ -<% require css(memberprofiles/client/css/MemberProfileViewer.css) %> - -
-

$Title

- -
- <% if IsSelf %> -

<%t MemberProfiles.THISISYOURPROFILE 'This is your profile!' %> <%t MemberProfiles.EDITPROFILE 'Edit Profile' %>

- <% end_if %> - <% loop Sections %> -
- <% if ShowTitle %>

$Title

<% end_if %> - $Me -
- <% end_loop %> -
+
+ <% if IsSelf %> +

<%t MemberProfiles.THISISYOURPROFILE 'This is your profile!' %> <%t MemberProfiles.EDITPROFILE 'Edit Profile' %>

+ <% end_if %> + <% loop Sections %> +
+ <% if ShowTitle %>

$Title

<% end_if %> + $Me +
+ <% end_loop %>
diff --git a/templates/Symbiote/MemberProfiles/Pages/Layout/MemberProfilePage.ss b/templates/Symbiote/MemberProfiles/Pages/Layout/MemberProfilePage.ss new file mode 100644 index 00000000..3b99b907 --- /dev/null +++ b/templates/Symbiote/MemberProfiles/Pages/Layout/MemberProfilePage.ss @@ -0,0 +1,11 @@ +
+

$Title

+ + <% if $Type = 'Register' %> + <% include Symbiote/MemberProfiles/Pages/MemberProfilePage_register %> + <% else_if $Type = 'Add' %> + <% include Symbiote/MemberProfiles/Pages/MemberProfilePage_addmember %> + <% else %> + <% include Symbiote/MemberProfiles/Pages/MemberProfilePage_profile %> + <% end_if %> +
diff --git a/templates/Symbiote/MemberProfiles/Pages/Layout/MemberProfileViewer.ss b/templates/Symbiote/MemberProfiles/Pages/Layout/MemberProfileViewer.ss new file mode 100644 index 00000000..c7c22d81 --- /dev/null +++ b/templates/Symbiote/MemberProfiles/Pages/Layout/MemberProfileViewer.ss @@ -0,0 +1,10 @@ +<% require css(memberprofiles/client/css/MemberProfileViewer.css) %> +
+

$Title

+ + <% if $Type = 'List' %> + <% include Symbiote/MemberProfiles/Pages/MemberProfileViewer_list %> + <% else %> + <% include Symbiote/MemberProfiles/Pages/MemberProfileViewer_view %> + <% end_if %> +
From 5c274d7d445a65ba9d9ec09d67bd5bc16b7aa352 Mon Sep 17 00:00:00 2001 From: Joris Debonnet Date: Fri, 23 Feb 2018 04:01:22 +0100 Subject: [PATCH 04/13] Make CMS page icon accessible --- {images => client/images}/memberprofilepage.png | Bin src/Pages/MemberProfilePage.php | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename {images => client/images}/memberprofilepage.png (100%) diff --git a/images/memberprofilepage.png b/client/images/memberprofilepage.png similarity index 100% rename from images/memberprofilepage.png rename to client/images/memberprofilepage.png diff --git a/src/Pages/MemberProfilePage.php b/src/Pages/MemberProfilePage.php index 8897b4de..65b470c4 100644 --- a/src/Pages/MemberProfilePage.php +++ b/src/Pages/MemberProfilePage.php @@ -126,7 +126,7 @@ class MemberProfilePage extends Page implements PermissionProvider { private static $description = ''; - private static $icon = 'memberprofiles/images/memberprofilepage.png'; + private static $icon = 'memberprofiles/client/images/memberprofilepage.png'; /** * If profile editing is disabled, but the current user can add members, From 966c6a359fe857f7962ce4b222216b1c39fbab71 Mon Sep 17 00:00:00 2001 From: Joris Debonnet Date: Fri, 23 Feb 2018 04:57:33 +0100 Subject: [PATCH 05/13] Fix Password field (all CMS .js is in a bundle, so this needed to be extracted) --- client/javascript/ConfirmedPasswordField.js | 14 ++++++++++++++ src/Pages/MemberProfilePageController.php | 10 ++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 client/javascript/ConfirmedPasswordField.js diff --git a/client/javascript/ConfirmedPasswordField.js b/client/javascript/ConfirmedPasswordField.js new file mode 100644 index 00000000..ff0aa0bd --- /dev/null +++ b/client/javascript/ConfirmedPasswordField.js @@ -0,0 +1,14 @@ +/* extracted from silverstripe/framework */ + +(function ($) { + $(document).on('click', '.confirmedpassword .showOnClick a', function () { + var $container = $('.showOnClickContainer', $(this).parent()); + + $container.toggle('fast', function() { + $container.find('input[type="hidden"]').val($container.is(":visible") ? 1 : 0); + }); + + return false; + }) + .find(".confirmedpassword .showOnClickContainer").hide(); +})(jQuery); diff --git a/src/Pages/MemberProfilePageController.php b/src/Pages/MemberProfilePageController.php index 5716446c..44e1f029 100644 --- a/src/Pages/MemberProfilePageController.php +++ b/src/Pages/MemberProfilePageController.php @@ -15,6 +15,7 @@ use SilverStripe\Control\Email\Email; use SilverStripe\SiteConfig\SiteConfig; use SilverStripe\Forms\LiteralField; +use SilverStripe\View\Requirements; use Symbiote\MemberProfiles\Pages\MemberProfilePage; use Symbiote\MemberProfiles\Pages\MemberProfileViewer; use Symbiote\MemberProfiles\Email\MemberConfirmationEmail; @@ -523,8 +524,13 @@ protected function getProfileFields($context) { $field = $field->performReadonlyTransformation(); } - $field->setTitle($profileField->Title); - $field->setDescription($profileField->Note); + if($name == 'Password') { + Requirements::javascript("memberprofiles/client/javascript/ConfirmedPasswordField.js"); + } + + // The follow two if-conditions were added since the SS4 migration because a Password label disappeared + if($profileField->Title) $field->setTitle($profileField->Title); + if($profileField->Note) $field->setDescription($profileField->Note); if($context == 'Registration' && $profileField->DefaultValue) { $field->setValue($profileField->DefaultValue); From 9680060e4b478e37c662bc95cbe3515a593d9b3e Mon Sep 17 00:00:00 2001 From: Joris Debonnet Date: Fri, 23 Feb 2018 06:14:54 +0100 Subject: [PATCH 06/13] Fix MemberProfileValidator --- src/Forms/MemberProfileValidator.php | 2 +- src/Pages/MemberProfilePage.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Forms/MemberProfileValidator.php b/src/Forms/MemberProfileValidator.php index d2ecf901..7469594f 100644 --- a/src/Forms/MemberProfileValidator.php +++ b/src/Forms/MemberProfileValidator.php @@ -92,7 +92,7 @@ public function php($data) { if($validator = $member::password_validator()) { $results = $validator->validate($data['Password'], $member); - if(!$results->valid()) { + if(!$results->isValid()) { $valid = false; foreach($results->messageList() as $key => $value) { $this->validationError('Password', $value, 'required'); diff --git a/src/Pages/MemberProfilePage.php b/src/Pages/MemberProfilePage.php index 65b470c4..991cb97d 100644 --- a/src/Pages/MemberProfilePage.php +++ b/src/Pages/MemberProfilePage.php @@ -89,7 +89,7 @@ class MemberProfilePage extends Page implements PermissionProvider { 'AllowProfileViewing' => true, 'AllowProfileEditing' => true, 'ConfirmationTitle' => 'Account Confirmed', - 'ConfirmationContent' => '

Your account is now active, and you have been logged in. Thankyou!

' + 'ConfirmationContent' => '

Your account is now active, and you have been logged in. Thank you!

' ); private static $table_name = 'MemberProfilePage'; From 3ef352251bb8d4c612a51b0e3fa8a1b447ffa7ac Mon Sep 17 00:00:00 2001 From: Joris Debonnet Date: Tue, 27 Feb 2018 04:20:04 +0100 Subject: [PATCH 07/13] Set default Unique and Required fields for Email and Password (since they are invariably set that way when editing the Field anyway) --- src/Pages/MemberProfilePage.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Pages/MemberProfilePage.php b/src/Pages/MemberProfilePage.php index 991cb97d..f44ef759 100644 --- a/src/Pages/MemberProfilePage.php +++ b/src/Pages/MemberProfilePage.php @@ -103,7 +103,9 @@ class MemberProfilePage extends Page implements PermissionProvider { 'Email' => array( 'RegistrationVisibility' => 'Edit', 'ProfileVisibility' => 'Edit', - 'PublicVisibility' => 'MemberChoice' + 'PublicVisibility' => 'MemberChoice', + 'Unique' => true, + 'Required' => true ), 'FirstName' => array( 'RegistrationVisibility' => 'Edit', @@ -120,7 +122,8 @@ class MemberProfilePage extends Page implements PermissionProvider { ), 'Password' => array( 'RegistrationVisibility' => 'Edit', - 'ProfileVisibility' => 'Edit' + 'ProfileVisibility' => 'Edit', + 'Required' => true ) ); From 8431276b418211656033c29e7b7d991b8fc95b06 Mon Sep 17 00:00:00 2001 From: Joris Debonnet Date: Tue, 27 Feb 2018 05:27:58 +0100 Subject: [PATCH 08/13] Allow working without any Group, just showing all Members in the List --- src/Pages/MemberProfileViewer.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Pages/MemberProfileViewer.php b/src/Pages/MemberProfileViewer.php index 8c4c8f2b..08faafcf 100644 --- a/src/Pages/MemberProfileViewer.php +++ b/src/Pages/MemberProfileViewer.php @@ -47,7 +47,12 @@ public function __construct($parent, $name) { */ public function handleList($request) { $fields = $this->parent->Fields()->filter('MemberListVisible', true); - $members = $this->parent->Groups()->relation('Members'); + + $groups = $this->parent->Groups(); + if($groups->Count()) { + // todo: this ->relation method does not seem to work: no Members are found + $members = $groups->relation('Members'); + } else $members = Member::get(); $members = new PaginatedList($members, $request); $list = new PaginatedList(new ArrayList(), $request); @@ -109,7 +114,7 @@ public function handleView($request) { $member = Member::get()->byID($id); $groups = $this->parent->Groups(); - if(!$member->inGroups($groups)) { + if($groups->Count() && !$member->inGroups($groups)) { $this->httpError(403); } From 2b73c9971cea38b7adc403ab70262fe1a8c0f536 Mon Sep 17 00:00:00 2001 From: Joris Debonnet Date: Wed, 28 Feb 2018 05:29:56 +0100 Subject: [PATCH 09/13] Fix auto-login after register and email validate --- src/Pages/MemberProfilePageController.php | 29 ++++++++++++++--------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/Pages/MemberProfilePageController.php b/src/Pages/MemberProfilePageController.php index 44e1f029..324a3265 100644 --- a/src/Pages/MemberProfilePageController.php +++ b/src/Pages/MemberProfilePageController.php @@ -1,32 +1,32 @@ addMember($form)) { if(!$this->RequireApproval && $this->EmailType != 'Validation' && !$this->AllowAdding) { - $member->logIn(); + try { + Injector::inst()->get(IdentityStore::class)->logIn($member); + } catch (NotFoundExceptionInterface $e) { + } } if ($this->RegistrationRedirect) { @@ -400,7 +403,11 @@ public function confirm($request) { $this->extend('onConfirm', $member); - $member->logIn(); + try { + Injector::inst()->get(IdentityStore::class)->logIn($member); + } catch (NotFoundExceptionInterface $e) { + // todo: do something interesting, like telling the user to go to Security/login + } return array ( 'Title' => $this->obj('ConfirmationTitle'), From a5f90ec40aca9f0bc30171b3556d9265463de54a Mon Sep 17 00:00:00 2001 From: Joris Debonnet Date: Wed, 21 Mar 2018 03:34:33 +0100 Subject: [PATCH 10/13] fix Email::getAdminEmail() (no longer supported) --- src/Email/MemberConfirmationEmail.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Email/MemberConfirmationEmail.php b/src/Email/MemberConfirmationEmail.php index e56d2125..53af2af5 100644 --- a/src/Email/MemberConfirmationEmail.php +++ b/src/Email/MemberConfirmationEmail.php @@ -154,7 +154,7 @@ public function __construct($page, $member, $isSingleton = false) { $this->member = $member; if (!$isSingleton) { - $this->from = $page->EmailFrom ? $page->EmailFrom : Email::getAdminEmail(); + $this->from = $page->EmailFrom ? $page->EmailFrom : Email::config()->get('admin_email'); $this->to = $member->Email; $this->subject = $this->getParsedString($page->EmailSubject); $this->body = $this->getParsedString($page->EmailTemplate); From 83e47dbece56accdab7341d374347a1018e1768c Mon Sep 17 00:00:00 2001 From: Joris Debonnet Date: Mon, 30 Apr 2018 00:45:48 +0200 Subject: [PATCH 11/13] Update composer.json to install into /vendor/ folder (also removed broken screenshot links) --- composer.json | 76 ++++++++++++++++++++++++--------------------------- 1 file changed, 35 insertions(+), 41 deletions(-) diff --git a/composer.json b/composer.json index 65f5778d..80bb942c 100644 --- a/composer.json +++ b/composer.json @@ -1,45 +1,39 @@ { - "name": "symbiote/silverstripe-memberprofiles", - "description": "Member registration and profile management", - "type": "silverstripe-module", - "keywords": ["silverstripe", "member", "profile", "registration"], - "license": "BSD-3-Clause", - "authors": [ - { - "name": "Andrew Short", - "email": "andrewjshort@gmail.com" - } - ], - "require": { - "silverstripe/framework": "~4.0", - "silverstripe/cms": "~4.0" - }, - "suggest": { - "ajshort/silverstripe-gridfieldextensions": "Allows drag-and-drop reordering of fields" - }, - "extra": { - "expose": [ - "client" + "name": "symbiote/silverstripe-memberprofiles", + "description": "Member registration and profile management", + "type": "silverstripe-vendormodule", + "keywords": ["silverstripe", "member", "profile", "registration"], + "license": "BSD-3-Clause", + "authors": [ + { + "name": "Andrew Short", + "email": "andrewjshort@gmail.com" + } + ], + "require": { + "silverstripe/framework": "~4.0", + "silverstripe/cms": "~4.0" + }, + "suggest": { + "ajshort/silverstripe-gridfieldextensions": "Allows drag-and-drop reordering of fields" + }, + "extra": { + "expose": [ + "client" ], - "installer-name": "memberprofiles", - "branch-alias": { - "dev-master": "3.0.x-dev" - }, - "screenshots": [ - "http://ajshort.github.com/silverstripe-memberprofiles/screenshots/edit-profile.png", - "http://ajshort.github.com/silverstripe-memberprofiles/screenshots/cms-profile-fields.png", - "http://ajshort.github.com/silverstripe-memberprofiles/screenshots/member-list.png" - ] - }, - "autoload": { - "psr-4": { - "Symbiote\\MemberProfiles\\": "src/", - "Symbiote\\MemberProfiles\\Tests\\": "tests/" - } + "branch-alias": { + "dev-master": "3.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Symbiote\\MemberProfiles\\": "src/", + "Symbiote\\MemberProfiles\\Tests\\": "tests/" + } }, - "replace": { - "silverstripe/memberprofiles": "self.version", - "ajshort/silverstripe-memberprofiles": "self.version", - "silverstripe-australia/memberprofiles": "self.version" - } + "replace": { + "silverstripe/memberprofiles": "self.version", + "ajshort/silverstripe-memberprofiles": "self.version", + "silverstripe-australia/memberprofiles": "self.version" + } } From 74f98b7906aafcbc93a4c750cfd4c84e38a1df53 Mon Sep 17 00:00:00 2001 From: Joris Debonnet Date: Mon, 30 Apr 2018 01:00:58 +0200 Subject: [PATCH 12/13] Update README for SS4 --- README.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 45ea2711..88f9b7b6 100644 --- a/README.md +++ b/README.md @@ -8,16 +8,16 @@ Maintainer Contacts Requirements ------------ -* SilverStripe 4 - [master branch CURRENTLY ALPHA](https://github.com/ajshort/silverstripe-memberprofiles) -* SilverStripe 3.1 & 3.2 - [2.0 branch](https://github.com/ajshort/silverstripe-memberprofiles/tree/2.0) +* SilverStripe 4 - [master branch (currently alpha)](https://github.com/ajshort/silverstripe-memberprofiles) +* SilverStripe 3.1+ - [2.0 branch](https://github.com/ajshort/silverstripe-memberprofiles/tree/2.0) * SilverStripe 3.0 - [1.0 branch](https://github.com/ajshort/silverstripe-memberprofiles/tree/1.0) * SilverStripe 2.4 - [0.5 branch](https://github.com/ajshort/silverstripe-memberprofiles/tree/0.5) Installation Instructions ------------------------- -1. Place this directory in the root of your SilverStripe installation. -2. Visit yoursite.com/dev/build to rebuild the database. +1. `composer install symbiote/silverstripe-memberprofiles`, or download this module into the root of your SilverStripe installation. +2. Visit `yoursite.com/dev/build` to rebuild the database. Usage Overview -------------- @@ -66,7 +66,7 @@ registration. This requires the "RegistrationRedirect" property to be set on the After Registration tab. If you like, you can manually set a redirection target by setting -Session::set('MemberProfile.REDIRECT') to a URL value. +`Session::set('MemberProfile.REDIRECT')` to a URL value. Examples -------- @@ -94,7 +94,7 @@ class MemberExtension extends DataExtension { This example shows how to override the base URL so that MemberProfilePage will work with the Multisites module. ```yml -MemberConfirmationEmail: +Symbiote\MemberProfiles\Email\MemberConfirmationEmail: extensions: - 'MemberConfirmationEmailExtension' ``` @@ -119,7 +119,7 @@ class MemberConfirmationEmailExtension extends Extension { Configuration ------------ ```yml -MemberApprovalController: +Symbiote\MemberProfiles\Pages\MemberApprovalController: # Redirect the user to the 'admin/Security' member edit page instead # of immediately approving after visiting the approve link. redirect_to_admin: false @@ -127,4 +127,5 @@ MemberApprovalController: Known Issues ------------ -- [SS4](https://github.com/symbiote/silverstripe-memberprofiles/pull/137) +- [SS4 upgrade](https://github.com/symbiote/silverstripe-memberprofiles/pull/137#issuecomment-364824650) +- [Members List](https://github.com/symbiote/silverstripe-memberprofiles/pull/138#issuecomment-368744525) From 83176127f905e3e51b3584cdd93b6444d79114fc Mon Sep 17 00:00:00 2001 From: Joris Debonnet Date: Mon, 30 Apr 2018 01:37:38 +0200 Subject: [PATCH 13/13] Fix Requirements after installing into vendor folder --- src/Forms/MemberProfilesAddSectionAction.php | 4 ++-- src/Model/MemberProfileField.php | 2 +- src/Pages/MemberProfilePage.php | 2 +- src/Pages/MemberProfilePageController.php | 2 +- .../MemberProfiles/Pages/Layout/MemberProfileViewer.ss | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Forms/MemberProfilesAddSectionAction.php b/src/Forms/MemberProfilesAddSectionAction.php index 6fba9a5f..c75e55f9 100644 --- a/src/Forms/MemberProfilesAddSectionAction.php +++ b/src/Forms/MemberProfilesAddSectionAction.php @@ -40,8 +40,8 @@ public function getHTMLFragments($grid) { $links[Controller::join_links($base, $class)] = $title; } - Requirements::javascript('memberprofiles/client/javascript/MemberProfilesAddSection.js'); - Requirements::css('memberprofiles/client/css/MemberProfilesAddSection.css'); + Requirements::javascript('symbiote/silverstripe-memberprofiles: client/javascript/MemberProfilesAddSection.js'); + Requirements::css('symbiote/silverstripe-memberprofiles: client/css/MemberProfilesAddSection.css'); $select = new DropdownField("{$grid->getName()}[SectionClass]", '', $links); $select->setEmptyString(_t('MemberProfiles.SECTIONTYPE', '(Section type)')); diff --git a/src/Model/MemberProfileField.php b/src/Model/MemberProfileField.php index 91b1f2cf..f80c1f3c 100644 --- a/src/Model/MemberProfileField.php +++ b/src/Model/MemberProfileField.php @@ -64,7 +64,7 @@ class MemberProfileField extends DataObject { * @return */ public function getCMSFields() { - Requirements::javascript('memberprofiles/client/javascript/MemberProfileFieldCMS.js'); + Requirements::javascript('symbiote/silverstripe-memberprofiles: client/javascript/MemberProfileFieldCMS.js'); $fields = parent::getCMSFields(); $memberFields = $this->getMemberFields(); diff --git a/src/Pages/MemberProfilePage.php b/src/Pages/MemberProfilePage.php index f44ef759..4ea240f1 100644 --- a/src/Pages/MemberProfilePage.php +++ b/src/Pages/MemberProfilePage.php @@ -129,7 +129,7 @@ class MemberProfilePage extends Page implements PermissionProvider { private static $description = ''; - private static $icon = 'memberprofiles/client/images/memberprofilepage.png'; + private static $icon = 'symbiote/silverstripe-memberprofiles: client/images/memberprofilepage.png'; /** * If profile editing is disabled, but the current user can add members, diff --git a/src/Pages/MemberProfilePageController.php b/src/Pages/MemberProfilePageController.php index 324a3265..c7272c94 100644 --- a/src/Pages/MemberProfilePageController.php +++ b/src/Pages/MemberProfilePageController.php @@ -532,7 +532,7 @@ protected function getProfileFields($context) { } if($name == 'Password') { - Requirements::javascript("memberprofiles/client/javascript/ConfirmedPasswordField.js"); + Requirements::javascript("symbiote/silverstripe-memberprofiles: client/javascript/ConfirmedPasswordField.js"); } // The follow two if-conditions were added since the SS4 migration because a Password label disappeared diff --git a/templates/Symbiote/MemberProfiles/Pages/Layout/MemberProfileViewer.ss b/templates/Symbiote/MemberProfiles/Pages/Layout/MemberProfileViewer.ss index c7c22d81..9411a857 100644 --- a/templates/Symbiote/MemberProfiles/Pages/Layout/MemberProfileViewer.ss +++ b/templates/Symbiote/MemberProfiles/Pages/Layout/MemberProfileViewer.ss @@ -1,4 +1,4 @@ -<% require css(memberprofiles/client/css/MemberProfileViewer.css) %> +<% require css(symbiote/silverstripe-memberprofiles: client/css/MemberProfileViewer.css) %>

$Title