Inheritance: extends ChangeLog
 function getOldDiffLink($id, $lastmod)
 {
     // get revision from before translation
     $orev = false;
     $changelog = new PageChangelog($id);
     $revs = $changelog->getRevisions(0, 100);
     foreach ($revs as $rev) {
         if ($rev < $lastmod) {
             $orev = $rev;
             break;
         }
     }
     if ($orev && !page_exists($id, $orev)) {
         return false;
     }
     $id = cleanID($id);
     return wl($id, array('do' => 'diff', 'rev' => $orev));
 }
Example #2
0
 /**
  * Send approve-mail to editor of the now approved revision
  *
  * @return bool false if there was an error passing the mail to the MTA
  */
 public function send_approve_mail()
 {
     global $ID;
     global $REV;
     /** @var DokuWiki_Auth_Plugin $auth */
     global $auth;
     $data = pageinfo();
     // get mail receiver
     if (!$REV) {
         $rev = $data['lastmod'];
     } else {
         $rev = $REV;
     }
     $changelog = new PageChangelog($ID);
     $revinfo = $changelog->getRevisionInfo($rev);
     $userinfo = $auth->getUserData($revinfo['user']);
     $receiver = $userinfo['mail'];
     // get mail sender
     $ReplyTo = $data['userinfo']['mail'];
     if ($ReplyTo == $receiver) {
         return true;
     }
     // get mail subject
     $subject = $this->getLang('apr_mail_app_subject');
     // get mail text
     $body = $this->create_mail_body('approve');
     $mail = new Mailer();
     $mail->to($receiver);
     $mail->subject($subject);
     $mail->setBody($body);
     $mail->setHeader("Reply-To", $ReplyTo);
     $returnStatus = $mail->send();
     return $returnStatus;
 }
 /**
  * @group slow
  */
 public function test_revert_page()
 {
     $page = 'test_revert_page';
     $assignment = new meta\Assignments();
     $schema = 'Schema2';
     $assignment->addPattern($page, $schema);
     $wikitext = 'teststring';
     global $conf;
     $conf['useacl'] = 1;
     $conf['superuser'] = '******';
     $_SERVER['REMOTE_USER'] = '******';
     //now it's testing as admin
     global $default_server_vars;
     $default_server_vars['REMOTE_USER'] = '******';
     //Hack until Issue #1099 is fixed
     $USERINFO['grps'] = array('admin', 'user');
     // first save;
     $request = new \TestRequest();
     $structData = array($schema => array('afirst' => 'foo', 'asecond' => 'bar, baz', 'athird' => 'foobar', 'afourth' => '42'));
     $request->setPost('struct_schema_data', $structData);
     $request->setPost('wikitext', $wikitext);
     $request->setPost('summary', 'content and struct data saved');
     $request->post(array('id' => $page, 'do' => 'save', 'sectok' => getSecurityToken()), '/doku.php');
     $this->waitForTick(true);
     // second save
     $request = new \TestRequest();
     $structData = array($schema => array('afirst' => 'foo2', 'asecond' => 'bar2, baz2', 'athird' => 'foobar2', 'afourth' => '43'));
     $request->setPost('struct_schema_data', $structData);
     $request->setPost('wikitext', $wikitext . $wikitext);
     $request->setPost('summary', 'delete page');
     $request->post(array('id' => $page, 'do' => 'save', 'sectok' => getSecurityToken()), '/doku.php');
     $this->waitForTick(true);
     // revert to first save
     $actpagelog = new \PageChangelog($page);
     $actrevisions = $actpagelog->getRevisions(0, 200);
     $actrevinfo = $actpagelog->getRevisionInfo($actrevisions[0]);
     $request = new \TestRequest();
     $request->setPost('summary', 'revert page');
     $request->post(array('id' => $page, 'do' => 'revert', 'rev' => $actrevinfo['date'], 'sectok' => getSecurityToken()), '/doku.php');
     // assert
     $pagelog = new \PageChangelog($page);
     $revisions = $pagelog->getRevisions(-1, 200);
     $revinfo = $pagelog->getRevisionInfo($revisions[0]);
     $schemaData = meta\AccessTable::byTableName($schema, $page, 0);
     $actual_struct_data = $schemaData->getDataArray();
     $expected_struct_data = array('afirst' => 'foo', 'asecond' => array('bar', 'baz'), 'athird' => 'foobar', 'afourth' => '42');
     $this->assertEquals(3, count($revisions), 'there should be 3 (three) revisions');
     $this->assertContains('restored', $revinfo['sum']);
     $this->assertEquals(DOKU_CHANGE_TYPE_REVERT, $revinfo['type']);
     $this->assertEquals($expected_struct_data, $actual_struct_data);
     // todo: timestamps?
 }