forked from burnbright/silverstripe-members
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
helpfulrobot
committed
Dec 31, 2015
1 parent
9d77e60
commit 4fd55a7
Showing
12 changed files
with
571 additions
and
533 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,32 @@ | ||
<?php | ||
|
||
class MemberAdmin extends ModelAdmin{ | ||
|
||
private static $url_segment = "members"; | ||
private static $menu_title = "Members"; | ||
private static $menu_icon = 'members/images/members-icon.png'; | ||
class MemberAdmin extends ModelAdmin | ||
{ | ||
|
||
private static $url_segment = "members"; | ||
private static $menu_title = "Members"; | ||
private static $menu_icon = 'members/images/members-icon.png'; | ||
|
||
private static $managed_models = array( | ||
'Member' | ||
); | ||
private static $managed_models = array( | ||
'Member' | ||
); | ||
|
||
private static $model_importers = array( | ||
'Member' => 'MemberBulkLoader' | ||
); | ||
private static $model_importers = array( | ||
'Member' => 'MemberBulkLoader' | ||
); | ||
|
||
public function getEditForm($id = null, $fields = null) { | ||
$form = parent::getEditForm(); | ||
public function getEditForm($id = null, $fields = null) | ||
{ | ||
$form = parent::getEditForm(); | ||
|
||
if($this->modelClass == "Member"){ | ||
if($columns = Member::config()->export_fields){ | ||
$form->Fields()->fieldByName("Member")->getConfig() | ||
->getComponentByType("GridFieldExportButton") | ||
->setExportColumns($columns); | ||
} | ||
} | ||
if ($this->modelClass == "Member") { | ||
if ($columns = Member::config()->export_fields) { | ||
$form->Fields()->fieldByName("Member")->getConfig() | ||
->getComponentByType("GridFieldExportButton") | ||
->setExportColumns($columns); | ||
} | ||
} | ||
|
||
return $form; | ||
} | ||
|
||
} | ||
return $form; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,36 @@ | ||
<?php | ||
|
||
/** | ||
* Add some additional functionality to MemberCsvBulkLoader | ||
*/ | ||
class MemberBulkLoader extends MemberCsvBulkLoader { | ||
|
||
public $columnMap = array( | ||
'Name' => '->importFirstAndLastName' | ||
); | ||
|
||
static function importFirstAndLastName(&$obj, $val, $record) { | ||
$nameParts = explode(' ', trim($val)); | ||
$obj->FirstName = array_shift($nameParts); | ||
$obj->Surname = join(' ', $nameParts); | ||
} | ||
|
||
public function processRecord($record, $columnMap, &$results, $preview = false) { | ||
$skip = false; | ||
$this->extend('preprocess', $record, $columnMap, $results, $preview, $skip); | ||
if($skip){ | ||
return 0; | ||
} | ||
$id = parent::processRecord($record, $columnMap, $results, $preview); | ||
if($member = Member::get()->byID($id)){ | ||
$this->extend('postprocess', $member, $record, $columnMap, $results, $preview);//callback for doing other custom stuff | ||
$member->write(); | ||
$member->destroy(); | ||
unset($member); | ||
} | ||
return $id; | ||
} | ||
|
||
} | ||
<?php | ||
|
||
/** | ||
* Add some additional functionality to MemberCsvBulkLoader | ||
*/ | ||
class MemberBulkLoader extends MemberCsvBulkLoader | ||
{ | ||
|
||
public $columnMap = array( | ||
'Name' => '->importFirstAndLastName' | ||
); | ||
|
||
public static function importFirstAndLastName(&$obj, $val, $record) | ||
{ | ||
$nameParts = explode(' ', trim($val)); | ||
$obj->FirstName = array_shift($nameParts); | ||
$obj->Surname = join(' ', $nameParts); | ||
} | ||
|
||
public function processRecord($record, $columnMap, &$results, $preview = false) | ||
{ | ||
$skip = false; | ||
$this->extend('preprocess', $record, $columnMap, $results, $preview, $skip); | ||
if ($skip) { | ||
return 0; | ||
} | ||
$id = parent::processRecord($record, $columnMap, $results, $preview); | ||
if ($member = Member::get()->byID($id)) { | ||
$this->extend('postprocess', $member, $record, $columnMap, $results, $preview);//callback for doing other custom stuff | ||
$member->write(); | ||
$member->destroy(); | ||
unset($member); | ||
} | ||
return $id; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,59 @@ | ||
<?php | ||
|
||
class MemberProfileExtension extends DataExtension{ | ||
|
||
private static $has_one = array( | ||
'Image' => 'Image' | ||
); | ||
|
||
public function updateCMSFields(FieldList $fields) { | ||
$fields->addFieldToTab("Root.Image", | ||
UploadField::create("Image","Profile Image") | ||
); | ||
} | ||
|
||
public function getProfileLink($action = null) { | ||
if($directorypage = MembersDirectoryPage::get()->first()){ | ||
return Controller::join_links( | ||
$directorypage->Link(), | ||
"view", | ||
$this->owner->ID, | ||
$action | ||
); | ||
} | ||
return Director::baseURL().MemberProfilePage_Controller::config()->url_segment; | ||
} | ||
|
||
//allow content editors to CVED (CRUD) | ||
|
||
public function canCreate($member = null) { | ||
if(Permission::check("CMS_ACCESS_CMSMain")){ | ||
return true; | ||
} | ||
} | ||
|
||
public function canView($member = null) { | ||
if(Permission::check("CMS_ACCESS_CMSMain")){ | ||
return true; | ||
} | ||
} | ||
|
||
public function canEdit($member = null) { | ||
if(Permission::check("CMS_ACCESS_CMSMain")){ | ||
return true; | ||
} | ||
} | ||
|
||
public function canDelete($member = null) { | ||
if(Permission::check("CMS_ACCESS_CMSMain")){ | ||
return true; | ||
} | ||
} | ||
|
||
} | ||
class MemberProfileExtension extends DataExtension | ||
{ | ||
|
||
private static $has_one = array( | ||
'Image' => 'Image' | ||
); | ||
|
||
public function updateCMSFields(FieldList $fields) | ||
{ | ||
$fields->addFieldToTab("Root.Image", | ||
UploadField::create("Image", "Profile Image") | ||
); | ||
} | ||
|
||
public function getProfileLink($action = null) | ||
{ | ||
if ($directorypage = MembersDirectoryPage::get()->first()) { | ||
return Controller::join_links( | ||
$directorypage->Link(), | ||
"view", | ||
$this->owner->ID, | ||
$action | ||
); | ||
} | ||
return Director::baseURL().MemberProfilePage_Controller::config()->url_segment; | ||
} | ||
|
||
//allow content editors to CVED (CRUD) | ||
|
||
public function canCreate($member = null) | ||
{ | ||
if (Permission::check("CMS_ACCESS_CMSMain")) { | ||
return true; | ||
} | ||
} | ||
|
||
public function canView($member = null) | ||
{ | ||
if (Permission::check("CMS_ACCESS_CMSMain")) { | ||
return true; | ||
} | ||
} | ||
|
||
public function canEdit($member = null) | ||
{ | ||
if (Permission::check("CMS_ACCESS_CMSMain")) { | ||
return true; | ||
} | ||
} | ||
|
||
public function canDelete($member = null) | ||
{ | ||
if (Permission::check("CMS_ACCESS_CMSMain")) { | ||
return true; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.