mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
Merge pull request #246 from assertchris/improve-member-blog-posts-grid
Improved member blog posts grid
This commit is contained in:
commit
8feb8abee7
@ -26,7 +26,7 @@ class BlogMemberExtension extends DataExtension {
|
||||
* @var array
|
||||
*/
|
||||
private static $belongs_many_many = array(
|
||||
'AuthoredPosts' => 'BlogPost',
|
||||
'BlogPosts' => 'BlogPost',
|
||||
);
|
||||
|
||||
/**
|
||||
@ -76,12 +76,35 @@ class BlogMemberExtension extends DataExtension {
|
||||
return $conflict->count() == 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function updateCMSFields(FieldList $fields) {
|
||||
$fields->removeByName('URLSegment');
|
||||
|
||||
// Remove the automatically-generated posts tab.
|
||||
|
||||
$fields->removeFieldFromTab('Root', 'BlogPosts');
|
||||
|
||||
// Construct a better posts tab.
|
||||
|
||||
Requirements::css(BLOGGER_DIR . '/css/cms.css');
|
||||
Requirements::javascript(BLOGGER_DIR . '/js/cms.js');
|
||||
|
||||
$tab = new Tab('BlogPosts', 'Blog Posts');
|
||||
|
||||
$gridField = new GridField(
|
||||
'BlogPosts',
|
||||
'Blog Posts',
|
||||
$this->owner->BlogPosts(),
|
||||
new GridFieldConfig_BlogPost()
|
||||
);
|
||||
|
||||
$tab->Fields()->add($gridField);
|
||||
|
||||
$fields->addFieldToTab('Root', $tab);
|
||||
|
||||
return $fields;
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,10 @@ class BlogPostFilter extends DataExtension {
|
||||
public function augmentSQL(SQLQuery &$query) {
|
||||
$stage = Versioned::current_stage();
|
||||
|
||||
if (Controller::curr() instanceof LeftAndMain) {
|
||||
return;
|
||||
}
|
||||
|
||||
if($stage == 'Live' || !Permission::check('VIEW_DRAFT_CONTENT')) {
|
||||
$query->addWhere(sprintf('"PublishDate" < \'%s\'', Convert::raw2sql(SS_Datetime::now())));
|
||||
}
|
||||
|
@ -582,7 +582,6 @@ class Blog extends Page implements PermissionProvider {
|
||||
|
||||
return $group;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -683,7 +682,7 @@ class Blog_Controller extends Page_Controller {
|
||||
$profile = $this->getCurrentProfile();
|
||||
|
||||
if($profile) {
|
||||
return $profile->AuthoredPosts()->filter('ParentID', $this->ID);
|
||||
return $profile->BlogPosts()->filter('ParentID', $this->ID);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
Loading…
Reference in New Issue
Block a user