/** * RevertPageToPreviousById * * Reverts a page to the version immediately preceding the "latest" * version. New page is created with previous version's metadata. * * @param object $wakka Wakka class instantiation * @param string $id Page id (converted to page tag) * @param string $comment Page comment (defaults to T_("Reverting last edit by %s [%d] to previous version [%d]")) * @return string T_("Reverted to previous version") or T_("Reversion to previous version FAILED!") * */ function RevertPageToPreviousById($wakka, $id, $comment = '') { $message = T_("Reversion to previous version FAILED!"); $id = mysql_real_escape_string($id); if (TRUE === $wakka->IsAdmin()) { $res = $wakka->LoadPageById($id); if (TRUE === isset($res)) { $tag = $res['tag']; if (TRUE === isset($tag)) { return RevertPageToPreviousByTag($wakka, $tag, $comment); } } } return $message; }
* @uses RevertPageToPreviousByTag() * @uses Wakka::GetPageTag() * @uses Wakka::Redirect() * */ $tag = $this->GetPageTag(); // cancel operation and return to the page if ($this->GetSafeVar('cancel', 'post') == T_("Cancel")) { $this->Redirect($this->Href()); } if ($this->HasAccess('write')) { if (NULL != $_POST) { include_once $this->BuildFullpathFromMultipath('..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'libs' . DIRECTORY_SEPARATOR . 'admin.lib.php', $this->GetConfigValue('action_path')); $comment = T_("Reverted to previous revision"); $tag = mysql_real_escape_string($this->GetPageTag()); $message = RevertPageToPreviousByTag($this, $tag, $comment); $this->Redirect($this->Href(), $message); } else { // show form ?> <h3><?php printf(T_("Revert %s to previous version"), $this->Link($tag)); ?> </h3> <br /> <?php echo $this->FormOpen('revert'); ?> <table border="0" cellspacing="0" cellpadding="0"> <tr>