function handle_revisions(Doku_Event &$event, $param) { global $ID; global $INFO; if (!$this->hlp->isActive()) { return; } $meta = p_get_metadata($ID); $latest_rev = $meta['last_change']['date']; $member = null; foreach ($event->data->_content as $key => $ref) { if (isset($ref['_elem']) && $ref['_elem'] == 'opentag' && $ref['_tag'] == 'div' && $ref['class'] == 'li') { $member = $key; } if ($member && $ref['_elem'] == 'tag' && $ref['_tag'] == 'input' && $ref['name'] == 'rev2[]') { $revision = $ref['value']; if ($revision == 'current') { $revision = $INFO['meta']['date']['modified']; } if ($this->hlp->isRevisionApproved($revision)) { $event->data->_content[$member]['class'] = 'li approved_revision'; } else { $event->data->_content[$member]['class'] = 'li unapproved_revision'; } $member = null; } } return true; }
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 handle_recent(Doku_Event &$event, $param) { if (!$this->hlp->isActive()) { return; } $render = $event->data->_content; $parent = null; foreach ($render as $id => $element) { if ($this->isParentTag($element)) { $parent = $id; continue; } if ($parent === null) { continue; } $id = $this->getPageId($element); if (!$id) { continue; } if ($this->hlp->isCurrentRevisionApproved($id)) { $event->data->_content[$parent]['class'] .= ' approved_revision'; } else { $event->data->_content[$parent]['class'] .= ' unapproved_revision'; } $parent = null; } return true; }
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; } } }
/** * send an email to inform about a changed page * * @param $event * @param $param * @return bool false if the receiver is invalid or there was an error passing the mail to the MTA */ function send_change_mail(&$event, $param) { global $ID; global $ACT; global $INFO; global $conf; $data = pageinfo(); if ($ACT != 'save') { return true; } // IO_WIKIPAGE_WRITE is always called twice when saving a page. This makes sure to only send the mail once. if (!$event->data[3]) { return true; } // Does the publish plugin apply to this page? if (!$this->hlp->isActive($ID)) { return true; } //are we supposed to send change-mails at all? if ($this->getConf('apr_mail_receiver') === '') { return true; } // get mail receiver $receiver = $this->getConf('apr_mail_receiver'); $validator = new EmailAddressValidator(); $validator->allowLocalAddresses = true; if (!$validator->check_email_address($receiver)) { dbglog(sprintf($this->getLang('mail_invalid'), htmlspecialchars($receiver))); return false; } // get mail sender $ReplyTo = $data['userinfo']['mail']; if ($ReplyTo == $receiver) { return true; } if ($INFO['isadmin'] == '1') { return true; } // get mail subject $timestamp = dformat($data['lastmod'], $conf['dformat']); $subject = $this->getLang('apr_mail_subject') . ': ' . $ID . ' - ' . $timestamp; $body = $this->create_mail_body('change'); $mail = new Mailer(); $mail->to($receiver); $mail->subject($subject); $mail->setBody($body); $mail->setHeader("Reply-To", $ReplyTo); $returnStatus = $mail->send(); return $returnStatus; }
/** * @param Doku_Event $event * @param array $param */ function hide(Doku_Event &$event, $param) { if (!$this->hlp->isActive()) { return; } if (!$this->hlp->isHiddenForUser()) { return; } global $ACT; if (!in_array($ACT, array('show', 'edit', 'source', 'diff'))) { return; } $ACT = 'denied'; $event->preventDefault(); $event->stopPropagation(); print p_locale_xhtml('denied'); }
/** * @param Doku_Event $event * @param array $param */ function remove(&$event, $param) { if (!$this->hlp->isActive()) { return; } if (!$this->getConf('delete attic on first approve')) { return; } if ($this->hlp->getPreviousApprovedRevision()) { return; // previous version exist } global $ID; $revisions = getRevisions($ID, 0, 0, 0); foreach ($revisions as $revision) { $fn = wikiFN($ID, $revision); if (file_exists($fn)) { @unlink($fn); } } }