mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Set default edit rights on pages to be only administrators
API CHANGE: Use return value of alternateCanPublish() BUGFIX: Fixed the Link() value for homepage BUGFIX: Allow DBField::__construct() without a name API CAHNGE: Allow augmentPopulateDefaults on data object decorators git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@65229 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
61a856503e
commit
72d90ab270
@ -629,6 +629,8 @@ class DataObject extends ViewableData implements DataObjectInterface,i18nEntityP
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->extend('augmentPopulateDefaults');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -81,7 +81,7 @@ class SiteTree extends DataObject {
|
|||||||
"Priority" => "Float",
|
"Priority" => "Float",
|
||||||
|
|
||||||
"CanViewType" => "Enum('Anyone, LoggedInUsers, OnlyTheseUsers, Inherit', 'Anyone')",
|
"CanViewType" => "Enum('Anyone, LoggedInUsers, OnlyTheseUsers, Inherit', 'Anyone')",
|
||||||
"CanEditType" => "Enum('LoggedInUsers, OnlyTheseUsers, Inherit', 'LoggedInUsers')",
|
"CanEditType" => "Enum('LoggedInUsers, OnlyTheseUsers, Inherit', 'OnlyTheseUsers')",
|
||||||
|
|
||||||
// Simple task tracking
|
// Simple task tracking
|
||||||
"ToDo" => "Text",
|
"ToDo" => "Text",
|
||||||
@ -124,7 +124,7 @@ class SiteTree extends DataObject {
|
|||||||
"ShowInSearch" => 1,
|
"ShowInSearch" => 1,
|
||||||
"Status" => "New page",
|
"Status" => "New page",
|
||||||
"CanViewType" => "Anyone",
|
"CanViewType" => "Anyone",
|
||||||
"CanEditType" => "LoggedInUsers"
|
"CanEditType" => "OnlyTheseUsers"
|
||||||
);
|
);
|
||||||
|
|
||||||
static $has_one = array(
|
static $has_one = array(
|
||||||
@ -185,7 +185,6 @@ class SiteTree extends DataObject {
|
|||||||
'Content',
|
'Content',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the URL for this page.
|
* Get the URL for this page.
|
||||||
*
|
*
|
||||||
@ -196,7 +195,8 @@ class SiteTree extends DataObject {
|
|||||||
if($action == "index") {
|
if($action == "index") {
|
||||||
$action = "";
|
$action = "";
|
||||||
}
|
}
|
||||||
return Director::baseURL() . $this->URLSegment . "/$action";
|
if($this->URLSegment == 'home' && !$action) return Director::baseURL();
|
||||||
|
else return Director::baseURL() . $this->URLSegment . "/$action";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -715,10 +715,8 @@ class SiteTree extends DataObject {
|
|||||||
* @return boolean True if the current user can edit this page.
|
* @return boolean True if the current user can edit this page.
|
||||||
*/
|
*/
|
||||||
public function canEdit($member = null) {
|
public function canEdit($member = null) {
|
||||||
if(!isset($member)) $member = Member::currentUser();
|
if(Permission::checkMember($member, "ADMIN")) return true;
|
||||||
|
if(!$member) $member = Member::currentUser();
|
||||||
// admin override
|
|
||||||
if($member && $member->isAdmin()) return true;
|
|
||||||
|
|
||||||
// decorated access checks
|
// decorated access checks
|
||||||
$args = array($member, true);
|
$args = array($member, true);
|
||||||
@ -769,14 +767,12 @@ class SiteTree extends DataObject {
|
|||||||
* @return boolean True if the current user can publish this page.
|
* @return boolean True if the current user can publish this page.
|
||||||
*/
|
*/
|
||||||
public function canPublish($member = null) {
|
public function canPublish($member = null) {
|
||||||
if(!isset($member)) $member = Member::currentUser();
|
// If we have a result, then that means at least one decorator specified alternateCanPublish
|
||||||
|
// Allow the permission check only if *all* voting decorators allow it.
|
||||||
if($member && $member->isAdmin()) return true;
|
$results = $this->extend('alternateCanPublish', $member);
|
||||||
|
if(is_array($results)) return min($results);
|
||||||
$args = array($member, true);
|
|
||||||
$this->extend('alternateCanPublish', $args);
|
|
||||||
if($args[1] == false) return false;
|
|
||||||
|
|
||||||
|
// Normal case
|
||||||
return $this->canEdit();
|
return $this->canEdit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ abstract class DBField extends ViewableData {
|
|||||||
*/
|
*/
|
||||||
protected $defaultVal;
|
protected $defaultVal;
|
||||||
|
|
||||||
function __construct($name) {
|
function __construct($name = null) {
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
Loading…
Reference in New Issue
Block a user