protected static function isHidden(AbstractRevision $revision) { return $revision->isModerated() && $revision->getModerationState() !== $revision::MODERATED_LOCKED; }
/** * Returns the permission specified in FlowActions for the given action * against the given revision's moderation state. * * @param AbstractRevision|null $revision * @param string $action * @param string $type * @return Closure|string */ public function getPermission(AbstractRevision $revision = null, $action, $type = 'permissions') { // $revision may be null if the revision has yet to be created $moderationState = AbstractRevision::MODERATED_NONE; if ($revision !== null) { $moderationState = $revision->getModerationState(); } $permission = $this->actions->getValue($action, $type, $moderationState); // Some permissions may be more complex to be defined as simple array // values, in which case they're a Closure (which will accept // AbstractRevision & FlowActionPermissions as arguments) if ($permission instanceof Closure) { $permission = $permission($revision, $this); } return $permission; }
/** * @todo Move this to AbstractBlock and use for summary/header/etc. * @param AbstractRevision $revision * @return Message */ protected function getDisallowedErrorMessage(AbstractRevision $revision) { if (in_array($this->action, array('moderate-topic', 'moderate-post'))) { /* * When failing to moderate an already moderated action (like * undo), show the more general "you have insufficient * permissions for this action" message, rather than the * specialized "this topic is <hidden|deleted|suppressed>" msg. */ return $this->context->msg('flow-error-not-allowed'); } $state = $revision->getModerationState(); // display simple message // i18n messages: // flow-error-not-allowed-hide, // flow-error-not-allowed-reply-to-hide-topic // flow-error-not-allowed-delete // flow-error-not-allowed-reply-to-delete-topic // flow-error-not-allowed-suppress // flow-error-not-allowed-reply-to-suppress-topic if ($revision instanceof PostRevision) { $type = $revision->isTopicTitle() ? 'topic' : 'post'; } else { $type = $revision->getRevisionType(); } // Show a snippet of the relevant log entry if available. if (\LogPage::isLogType($state)) { // check if user has sufficient permissions to see log $logPage = new \LogPage($state); if ($this->context->getUser()->isAllowed($logPage->getRestriction())) { // LogEventsList::showLogExtract will write to OutputPage, but we // actually just want that text, to write it ourselves wherever we want, // so let's create an OutputPage object to then get the content from. $rc = new \RequestContext(); $output = $rc->getOutput(); // get log extract $entries = \LogEventsList::showLogExtract($output, array($state), $this->workflow->getArticleTitle()->getPrefixedText(), '', array('lim' => 10, 'showIfEmpty' => false, 'msgKey' => array(array("flow-error-not-allowed-{$this->action}-to-{$state}-{$type}", "flow-error-not-allowed-{$state}-extract")))); // check if there were any log extracts if ($entries) { $message = new \RawMessage('$1'); return $message->rawParams($output->getHTML()); } } } return $this->context->msg(array("flow-error-not-allowed-{$this->action}-to-{$state}-{$type}", "flow-error-not-allowed-{$state}", "flow-error-not-allowed")); }