function handle_start(&$event, $param) { global $ACT; global $REV; global $INFO; global $ID; if ($ACT !== 'show') { return; } if ($REV != '') { return; } if ($INFO['perm'] != AUTH_READ) { return; } global $_GET; if ($_GET['force_rev']) { return; } if (!$this->hlp->isActive()) { return; } if (!$this->hlp->isCurrentRevisionApproved()) { $latestApproved = $this->hlp->getLatestApprovedRevision(); if ($latestApproved) { $REV = $latestApproved; $INFO['rev'] = $latestApproved; } } }
/** * Create the body of mails to inform about a changed or an approved page * * @param string $action Must either be "change" or "approve" * @return bool|string * */ public function create_mail_body($action) { global $ID; global $conf; $pageinfo = pageinfo(); // get mail text $rev = $pageinfo['lastmod']; if ($action === 'change') { $body = io_readFile($this->localFN('mailchangetext')); //If there is no approved revision show the diff to the revision before. Otherwise show the diff to the last approved revision. if ($this->hlp->hasApprovals($pageinfo['meta'])) { $aprpre = 'Aproved'; $oldrev = $this->hlp->getLatestApprovedRevision($ID); $difflink = $this->hlp->getDifflink($ID, $oldrev, $rev); } else { $aprpre = 'Previous'; $changelog = new PageChangelog($ID); $oldrev = $changelog->getRelativeRevision($rev, -1); $difflink = $this->hlp->getDifflink($ID, $oldrev, $rev); } $body = str_replace('@DIFF@', $difflink, $body); $body = str_replace('@APRPRE@', $aprpre, $body); $summary = $pageinfo['meta']['last_change']['sum']; $body = str_replace('@SUMMARY@', $summary, $body); if ($oldrev === false) { $oldlink = '---'; } else { $oldlink = $this->revlink($ID, $oldrev); } $body = str_replace('@OLDPAGE@', $oldlink, $body); $newlink = $this->revlink($ID, $rev); $body = str_replace('@NEWPAGE@', $newlink, $body); } elseif ($action === 'approve') { $body = io_readFile($this->localFN('mailapprovetext')); $newlink = $this->revlink($ID, $rev); $body = str_replace('@URL@', $newlink, $body); $changelog = new PageChangelog($ID); $revinfo = $changelog->getRevisionInfo($rev); /** @var DokuWiki_Auth_Plugin $auth */ global $auth; $userinfo = $auth->getUserData($revinfo['user']); $body = str_replace('@FULLNAME@', $userinfo['name'], $body); } else { return false; } $body = str_replace('@DOKUWIKIURL@', DOKU_URL, $body); $body = str_replace('@TITLE@', $conf['title'], $body); return $body; }
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 '<span class="approval_outdated">'; printf($this->getLang('apr_outdated'), wl($ID, 'rev=' . $latestApprovedRevision)); echo $this->difflink($ID, $latestApprovedRevision, $revision) . '</span>'; }