Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SS4 improvements #138

Merged
merged 13 commits into from
Apr 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .upgrade.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
--------------
Expand Down Expand Up @@ -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
--------
Expand Down Expand Up @@ -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'
```
Expand All @@ -119,12 +119,13 @@ 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
```

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)
2 changes: 1 addition & 1 deletion _config/legacy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion _config/routes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ After: framework/routes#coreroutes
---
SilverStripe\Control\Director:
rules:
member-approval: Symbiote\MemberProfiles\Controllers\MemberApprovalController
member-approval: Symbiote\MemberProfiles\Pages\MemberApprovalController
File renamed without changes
14 changes: 14 additions & 0 deletions client/javascript/ConfirmedPasswordField.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* extracted from silverstripe/framework */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this not something that we can reference from silverstripe/framework, rather than copy and pasting it across here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the main thing that jumps out to me from the PR. In regards to your PSR-2 comments, I'm planning to run PSR-2 formatting across all of our modules in the near future (hooking them up to Travis to enforce this).

Copy link
Contributor Author

@JorisDebonnet JorisDebonnet Feb 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand the issue, but this code does not appear in a separate .js file anymore. SS4 now bundles nearly all cms js in a single .js file. I tried searching for showOnClickContainer in the vendor/silverstripe folder, but it's only to be found in admin/client/dist/js/bundle.js. I remember reading about this in the upgrade guide:
https://docs.silverstripe.org/en/4/changelogs/4.0.0#js-in-framework

It suggests transpiling source es6 files in our own build process, but I can't find those source files. Perhaps they're not shipped to the packagist release or something? So in that case, since it's only a small piece of .js, I thought I'd just integrate it directly...

("extracted from silverstripe/framework" actually means I got it from the SS3 code; nowadays, it is actually found in silverstripe/admin, so perhaps I should change that comment)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah okay, that makes sense. It feels like the confirm password field was never intended for the front end. In which case, happy for this to stay until we come up with a better solution. Thanks for all your work on this PR. I'll probably have a quick play with it before merging :)


(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);
76 changes: 35 additions & 41 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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": "[email protected]"
}
],
"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": "[email protected]"
}
],
"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"
}
}
2 changes: 1 addition & 1 deletion lang/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
2 changes: 1 addition & 1 deletion lang/en_US.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

use Symbiote\MemberProfiles\Model\MemberProfileField;
use Symbiote\MemberProfiles\Model\MemberProfilePage;
use Symbiote\MemberProfiles\Pages\MemberProfilePage;

global $lang;

Expand Down
2 changes: 1 addition & 1 deletion lang/es_ES.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use SilverStripe\i18n\i18n;
use Symbiote\MemberProfiles\Model\MemberProfileField;
use Symbiote\MemberProfiles\Model\MemberProfilePage;
use Symbiote\MemberProfiles\Pages\MemberProfilePage;
/**
* Spanish (Spain) language pack.
*
Expand Down
2 changes: 1 addition & 1 deletion lang/sk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ sk:
DefaultTitle: Pole
PLURALNAME: Políčka
SINGULARNAME: Políčko
Symbiote\MemberProfiles\Model\MemberProfilePage:
Symbiote\MemberProfiles\Pages\MemberProfilePage:
DESCRIPTION: 'Stránka slúži na správu profilu, pridávanie a registráciu užívateľov.'
PLURALNAME: 'Profilové stránky'
SINGULARNAME: 'Profilová stránka'
2 changes: 1 addition & 1 deletion src/Email/MemberConfirmationEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/Extensions/MemberProfileExtension.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

namespace Symbiote\MemberProfiles\Extensions;
use Symbiote\MemberProfiles\Model\MemberProfilePage;
use Symbiote\MemberProfiles\Pages\MemberProfilePage;
use Symbiote\MemberProfiles\Email\MemberConfirmationEmail;
use SilverStripe\Forms\CheckboxSetField;
use SilverStripe\Forms\FieldList;
Expand All @@ -26,7 +26,7 @@ class MemberProfileExtension extends DataExtension {
);

private static $has_one = array(
'ProfilePage' => MemberProfilePage::class
'ProfilePage' => MemberProfilePage::class
);

public function getPublicFields() {
Expand Down
2 changes: 1 addition & 1 deletion src/Forms/MemberProfileValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
4 changes: 2 additions & 2 deletions src/Forms/MemberProfilesAddSectionAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)'));
Expand Down
4 changes: 2 additions & 2 deletions src/Model/MemberProfileField.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

namespace Symbiote\MemberProfiles\Model;
use Symbiote\MemberProfiles\Model\MemberProfilePage;
use Symbiote\MemberProfiles\Pages\MemberProfilePage;
use SilverStripe\View\Requirements;
use SilverStripe\Forms\ReadonlyField;
use SilverStripe\Forms\HeaderField;
Expand Down Expand Up @@ -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();
Expand Down
1 change: 0 additions & 1 deletion src/Model/MemberProfileFieldsSection.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php

namespace Symbiote\MemberProfiles\Model;
use Symbiote\MemberProfiles\Model\MemberProfileSection;
use SilverStripe\ORM\ArrayList;
use SilverStripe\View\ArrayData;

Expand Down
2 changes: 1 addition & 1 deletion src/Model/MemberProfileSection.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

namespace Symbiote\MemberProfiles\Model;
use Symbiote\MemberProfiles\Model\MemberProfilePage;
use Symbiote\MemberProfiles\Pages\MemberProfilePage;
use SilverStripe\Forms\ReadonlyField;
use SilverStripe\Forms\HiddenField;
use SilverStripe\ORM\DataObject;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Symbiote\MemberProfiles\Controllers;
namespace Symbiote\MemberProfiles\Pages;
use SilverStripe\Security\Member;
use SilverStripe\ORM\DataObject;
use SilverStripe\Security\Security;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Symbiote\MemberProfiles\Model;
namespace Symbiote\MemberProfiles\Pages;
use Page;
use Symbiote\GridFieldExtensions\GridFieldOrderableRows;
use UndefinedOffset\SortableGridField\Forms\GridFieldSortableRows;
Expand All @@ -12,7 +12,6 @@
use SilverStripe\Security\Member;
use SilverStripe\Forms\TabSet;
use SilverStripe\Forms\Tab;
use SilverStripe\Control\Email\Email;
use SilverStripe\Forms\GridField\GridFieldConfig_RecordEditor;
use SilverStripe\Forms\GridField\GridFieldDeleteAction;
use SilverStripe\Forms\GridField\GridFieldAddNewButton;
Expand Down Expand Up @@ -90,7 +89,7 @@ class MemberProfilePage extends Page implements PermissionProvider {
'AllowProfileViewing' => true,
'AllowProfileEditing' => true,
'ConfirmationTitle' => 'Account Confirmed',
'ConfirmationContent' => '<p>Your account is now active, and you have been logged in. Thankyou!</p>'
'ConfirmationContent' => '<p>Your account is now active, and you have been logged in. Thank you!</p>'
);

private static $table_name = 'MemberProfilePage';
Expand All @@ -104,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',
Expand All @@ -121,13 +122,14 @@ class MemberProfilePage extends Page implements PermissionProvider {
),
'Password' => array(
'RegistrationVisibility' => 'Edit',
'ProfileVisibility' => 'Edit'
'ProfileVisibility' => 'Edit',
'Required' => true
)
);

private static $description = '';

private static $icon = 'memberprofiles/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,
Expand Down
Loading