diff --git a/client/css/MultisitesErrorPage.css b/client/css/MultisitesErrorPage.css new file mode 100644 index 0000000..a0609dd --- /dev/null +++ b/client/css/MultisitesErrorPage.css @@ -0,0 +1,28 @@ + +/* Used in MultisitesErrorPageExtension */ +.MultisitesErrorPage_NoPubMsg { + margin: -5px 0 20px 0; + padding: 5px 8px 5px 8px; + border-radius: 3px; + border: 1px solid #da273b; + color: #da273b; + text-align: center; +} + +/* Used in MultisitesErrorPageExtension */ +.MultisitesErrorPage_NoPubBtn { + padding: 5px 8px 5px 8px; + border-radius: 0 3px 3px 0; + color: #da273b; + border: 1px solid #da273b; + border-left: none; + pointer-events: none; + cursor: none; + + -webkit-touch-callout: none; /* iOS Safari */ + -webkit-user-select: none; /* Safari */ + -khtml-user-select: none; /* Konqueror HTML */ + -moz-user-select: none; /* Firefox */ + -ms-user-select: none; /* Internet Explorer/Edge */ + user-select: none; /* Chrome and Opera */ +} \ No newline at end of file diff --git a/src/Extension/MultisitesErrorPageExtension.php b/src/Extension/MultisitesErrorPageExtension.php index 62ce612..6846e79 100644 --- a/src/Extension/MultisitesErrorPageExtension.php +++ b/src/Extension/MultisitesErrorPageExtension.php @@ -1,17 +1,24 @@ Host.'-', $name); } } + + public function canPublish($member = null) + { + //only allow publish if user logged into page's domain. + $parent = $this->owner->parent; + $siteID = $parent ? $parent->ID : null; + $multiID = Multisites::inst()->getCurrentSiteId(); + + if ($siteID == $multiID) { + return true; + } + + //this actually removes the publish btn + return false; + } + + public function updateCMSFields($fields) + { + //if cant publish (see canPublish) + if (!$this->canPublish()) { + //attach message above page title informing authors + $url = $this->owner->parent->Link(); + $nopubmsg = new LiteralField( + "nopubmsg", + '
To publish this page, you need to log in via: ' . $url . '
' + ); + $fields->insertBefore("Title", $nopubmsg); + } + } + + public function updateCMSActions($actions) + { + //if cant publish (see canPublish) + if (!$this->canPublish()) { + //mimic publish button with a disabled appearance + $nopubbtn = new LiteralField( + "nopubbtn", + '
Publish
' + ); + $actions->insertAfter("action_save", $nopubbtn); + } + } } \ No newline at end of file