hlp = plugin_load('helper','publish'); } function register(Doku_Event_Handler $controller) { $controller->register_hook('TPL_ACT_RENDER', 'BEFORE', $this, 'handle_display_banner', array()); } function handle_display_banner(&$event, $param) { global $INFO; if (!$this->hlp->isActive()) { return; } if ($event->data != 'show') { return; } if (!$INFO['exists']) { return; } $meta = $INFO['meta']; if (!$meta['approval']) { $meta['approval'] = array(); } if($INFO['perm'] <= AUTH_READ && $this->getConf('hidereaderbanner')){ return; } if ($this->hlp->isCurrentRevisionApproved() && $this->getConf('hide_approved_banner')) { return; } $this->showBanner(); return; } function difflink($id, $rev1, $rev2) { if($rev1 == $rev2) { return ''; } $difflink = $this->hlp->getDifflink($id,$rev1,$rev2); return '' . 'Diff' . ''; } function showBanner() { if ($this->hlp->isCurrentRevisionApproved()) { $class = 'approved_yes'; } else { if ($this->hlp->isHiddenForUser()) { return; } $class = 'approved_no'; } printf('
', $class); $this->showLatestDraftIfNewer(); $this->showLatestApprovedVersion(); $this->showDraft(); $this->showApproved(); $this->showPreviousApproved(); $this->showApproveAction(); $this->showInternalNote(); echo '
'; global $INFO; if ($this->getConf('apr_mail_receiver') !== '' && $INFO['isadmin']) { $addr = $this->getConf('apr_mail_receiver'); if(!mail_isvalid($addr)) { msg(sprintf($this->getLang('mail_invalid'),htmlspecialchars($addr)),-1); } } } function showInternalNote() { $note = trim($this->getConf('internal note')); if ($note === '') { return; } if (!$this->hlp->isHidden()) { return; } printf('%s', hsc($note)); } function showLatestDraftIfNewer() { global $ID; $revision = $this->hlp->getRevision(); $latestRevision = $this->hlp->getLastestRevision(); if ($revision >= $latestRevision) { return; } if ($this->hlp->isRevisionApproved($latestRevision)) { return; } echo ''; printf($this->getLang('apr_recent_draft'), wl($ID, 'force_rev=1')); echo $this->difflink($ID, null, $revision) . ''; } function showLatestApprovedVersion() { global $ID; $revision = $this->hlp->getRevision(); $latestApprovedRevision = $this->hlp->getLatestApprovedRevision(); if ($latestApprovedRevision <= $revision) { return; } $latestRevision = $this->hlp->getLastestRevision(); if ($latestApprovedRevision == $latestRevision) { //$latestApprovedRevision = ''; } echo ''; printf($this->getLang('apr_outdated'), wl($ID, 'rev=' . $latestApprovedRevision)); echo $this->difflink($ID, $latestApprovedRevision, $revision) . ''; } function showDraft() { $revision = $this->hlp->getRevision(); if ($this->hlp->isCurrentRevisionApproved()) { return; } $approvals = $this->hlp->getApprovalsOnRevision($this->hlp->getRevision()); $approvalCount = count($approvals); echo ''; printf($this->getLang('apr_draft'), '' . dformat($revision) . ''); echo '
'; printf(' ' . $this->getLang('approvals'), $approvalCount, $this->getConf('number_of_approved')); if ($approvalCount != 0) { printf(' ' . $this->getLang('approved by'), implode(', ', $this->hlp->getApprovers())); } echo '
'; } function showApproved() { if (!$this->hlp->isCurrentRevisionApproved()) { return; } echo ''; printf($this->getLang('apr_approved'), '' . dformat($this->hlp->getApprovalDate()) . '', implode(', ', $this->hlp->getApprovers())); echo ''; } function showPreviousApproved() { global $ID; $previousApproved = $this->hlp->getPreviousApprovedRevision(); if (!$previousApproved) { return; } echo ''; printf($this->getLang('apr_previous'), wl($ID, 'rev=' . $previousApproved), dformat($previousApproved)); echo $this->difflink($ID, $previousApproved, $this->hlp->getRevision()) . ''; } private function showApproveAction() { global $ID; global $REV; global $USERINFO; if (!$this->hlp->canApprove()) { return; } $approvals = $this->hlp->getApprovalsOnRevision($this->hlp->getRevision()); foreach ($approvals as $approve) { if ($approve[1] == $_SERVER['REMOTE_USER']) { return; } if ($approve[1] == $USERINFO['mail']) { return; } } echo ''; echo ''; echo $this->getLang('approve action'); echo ''; echo ' '; } }