Reputation: 229
In Silverstripe (4.7) how can i manage the member only to view, edit and delete its own created Dataobjects? I thought i could use canView() but no success.
Ive tried with PermissionProvider and Security...
class ProjectCatObject extends DataObject implements PermissionProvider
{
private static $db = array(
'OwnerID' => 'Int'
.......
);
}
public function onBeforeWrite() {
parent::onBeforeWrite();
//Debug::show(Security::getCurrentUser());
$member = Security::getCurrentUser();
$this->OwnerID = $member->ID;
}
and
public function canView($member = null) {
$member = Security::getCurrentUser();
return (Permission::check("CMS_ACCESS_LeftAndMain", "any", $member) || $member->ID == $this->OwnerID);
}
But This gives me an ERROR on Creating a new entry.
It seems you don't have the necessary permissions to view "Projekt-Kategorie"
How can this be made ?
Upvotes: 0
Views: 63