Merge pull request #246 from assertchris/improve-member-blog-posts-grid

Improved member blog posts grid
This commit is contained in:
Damian Mooyman 2015-05-22 11:09:35 +12:00
commit 8feb8abee7
4 changed files with 30 additions and 4 deletions

View File

@ -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;
}
}

View File

@ -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())));
}

View File

@ -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;