Ejemplo n.º 1
0
 function addApproval()
 {
     global $USERINFO;
     global $ID;
     global $INFO;
     if (!$INFO['exists']) {
         msg($this->getLang('cannot approve a non-existing revision'), -1);
         return;
     }
     $approvalRevision = $this->helper->getRevision();
     $approvals = $this->helper->getApprovals();
     if (!isset($approvals[$approvalRevision])) {
         $approvals[$approvalRevision] = array();
     }
     $approvals[$approvalRevision][$INFO['client']] = array($INFO['client'], $_SERVER['REMOTE_USER'], $USERINFO['mail'], time());
     $success = p_set_metadata($ID, array('approval' => $approvals), true, true);
     if ($success) {
         msg($this->getLang('version approved'), 1);
         $data = array();
         $data['rev'] = $approvalRevision;
         $data['id'] = $ID;
         $data['approver'] = $_SERVER['REMOTE_USER'];
         $data['approver_info'] = $USERINFO;
         if ($this->getConf('send_mail_on_approve') && $this->helper->isRevisionApproved($approvalRevision)) {
             /** @var action_plugin_publish_mail $mail */
             $mail = plugin_load('action', 'publish_mail');
             $mail->send_approve_mail();
         }
         trigger_event('PLUGIN_PUBLISH_APPROVE', $data);
     } else {
         msg($this->getLang('cannot approve error'), -1);
     }
     send_redirect(wl($ID, array('rev' => $this->helper->getRevision()), true, '&'));
 }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
 function showLatestDraftIfNewer()
 {
     global $ID;
     $revision = $this->hlp->getRevision();
     $latestRevision = $this->hlp->getLastestRevision();
     if ($revision >= $latestRevision) {
         return;
     }
     if ($this->hlp->isRevisionApproved($latestRevision)) {
         return;
     }
     echo '<span class="approval_latest_draft">';
     printf($this->getLang('apr_recent_draft'), wl($ID, 'force_rev=1'));
     echo $this->difflink($ID, null, $revision) . '</span>';
 }