/* Kick back to the display page if we're not allowed to diff this
* page. */
-if (!$page->allows(WICKED_MODE_DIFF)) {
+if (!$page->allows(Wicked::MODE_DIFF)) {
Wicked::url($page->pageName(), true)
->add('actionID', 'diff')
->redirect();
$title = sprintf(_("Diff for %s between %s and %s"), $page->pageName(), $v1, $page->version());
require WICKED_TEMPLATES . '/common-header.inc';
require WICKED_TEMPLATES . '/menu.inc';
-$page->render(WICKED_MODE_DIFF, $v1);
+$page->render(Wicked::MODE_DIFF, $v1);
require $registry->get('templates', 'horde') . '/common-footer.inc';
$actionID = Horde_Util::getFormData('actionID');
switch ($actionID) {
case 'lock':
- if (!$page->allows(WICKED_MODE_LOCKING)) {
+ if (!$page->allows(Wicked::MODE_LOCKING)) {
$notification->push(_("You are not allowed to lock this page"),
'horde.error');
break;
break;
case 'unlock':
- if (!$page->allows(WICKED_MODE_UNLOCKING)) {
+ if (!$page->allows(Wicked::MODE_UNLOCKING)) {
$notification->push(_("You are not allowed to unlock this page"),
'horde.error');
}
break;
case 'history':
- if ($page->allows(WICKED_MODE_HISTORY)) {
+ if ($page->allows(Wicked::MODE_HISTORY)) {
/* Redirect to history page. */
Horde::url('history.php')
->add('page', $page->pageName())
break;
case 'export':
- if (!$page->allows(WICKED_MODE_DISPLAY)) {
+ if (!$page->allows(Wicked::MODE_DISPLAY)) {
$notification->push(_("You don't have permission to view this page."),
'horde.error');
if ($page->pageName() == 'WikiHome') {
$wicked->logPageView($page->pageName());
}
-if (!$page->allows(WICKED_MODE_DISPLAY)) {
+if (!$page->allows(Wicked::MODE_DISPLAY)) {
$notification->push(_("You don't have permission to view this page."),
'horde.error');
if ($page->pageName() == 'WikiHome') {
}
$params = Horde_Util::getFormData('params');
-$page->preDisplay(WICKED_MODE_DISPLAY, $params);
+$page->preDisplay(Wicked::MODE_DISPLAY, $params);
if (!isset($_SESSION['wickedSession']['history'])) {
$_SESSION['wickedSession']['history'] = array();
$title = $page->pageTitle();
require WICKED_TEMPLATES . '/common-header.inc';
require WICKED_TEMPLATES . '/menu.inc';
-$page->render(WICKED_MODE_DISPLAY, $params);
+$page->render(Wicked::MODE_DISPLAY, $params);
require $registry->get('templates', 'horde') . '/common-footer.inc';
if (is_a($page, 'StandardPage') &&
Wicked::url('WikiHome', true)->redirect();
}
-if (!$page->allows(WICKED_MODE_HISTORY)) {
+if (!$page->allows(Wicked::MODE_HISTORY)) {
/* Redirect to display page and force it to display an error. */
Wicked::url($page->pageName(), true)->add('actionID', 'history')->redirect();
}
$title = sprintf(_("History: %s"), $page->pageName());
require WICKED_TEMPLATES . '/common-header.inc';
require WICKED_TEMPLATES . '/menu.inc';
-$page->render(WICKED_MODE_HISTORY);
+$page->render(Wicked::MODE_HISTORY);
require $registry->get('templates', 'horde') . '/common-footer.inc';
if (is_a($page, 'PEAR_Error')) {
return $page;
}
- if (!$page->allows(WICKED_MODE_EDIT)) {
+ if (!$page->allows(Wicked::MODE_EDIT)) {
return PEAR::RaiseError(sprintf(_("You don't have permission to edit \"%s\"."), $pagename));
}
if ($GLOBALS['conf']['wicked']['require_change_log'] &&
$page = Wicked_Page::getPage($pagename, $version);
- if (!$page->allows(WICKED_MODE_CONTENT)) {
+ if (!$page->allows(Wicked::MODE_CONTENT)) {
return PEAR::raiseError(_("Permission denied."));
}
protected function _content()
{
$page = Wicked_Page::getPage($this->_params['page']);
- return $page->render(WICKED_MODE_BLOCK);
+ return $page->render(Wicked::MODE_BLOCK);
}
protected function _params()
* actually refer to $pagename. */
$patterns = array('/\(\(' . preg_quote($pagename, '/') . '(?:\|[^)]+)?\)\)/');
- if (preg_match('/^' . WICKED_REGEXP_WIKIWORD . '$/', $pagename)) {
+ if (preg_match('/^' . Wicked::REGEXP_WIKIWORD . '$/', $pagename)) {
$patterns[] = '/\b' . preg_quote($pagename, '/') . '\b/';
}
/**
* Display modes supported by this page. Possible modes:
*
- * WICKED_MODE_CONTENT
- * WICKED_MODE_DISPLAY
- * WICKED_MODE_EDIT
- * WICKED_MODE_REMOVE
- * WICKED_MODE_HISTORY
- * WICKED_MODE_DIFF
- * WICKED_MODE_LOCKING
- * WICKED_MODE_UNLOCKING
- * WICKED_MODE_CREATE
+ * Wicked::MODE_CONTENT
+ * Wicked::MODE_DISPLAY
+ * Wicked::MODE_EDIT
+ * Wicked::MODE_REMOVE
+ * Wicked::MODE_HISTORY
+ * Wicked::MODE_DIFF
+ * Wicked::MODE_LOCKING
+ * Wicked::MODE_UNLOCKING
+ * Wicked::MODE_CREATE
*
* @var array
*/
$pagePerms = $this->getPermissions();
switch ($mode) {
- case WICKED_MODE_CREATE:
+ case Wicked::MODE_CREATE:
// Special mode for pages that don't exist yet - generic
// to all pages.
if ($browser->isRobot()) {
}
break;
- case WICKED_MODE_EDIT:
+ case Wicked::MODE_EDIT:
if ($browser->isRobot()) {
return false;
}
}
break;
- case WICKED_MODE_REMOVE:
+ case Wicked::MODE_REMOVE:
if ($browser->isRobot()) {
return false;
}
}
$page = new StandardPage($pagename);
- if ($page->isValid() || !$page->allows(WICKED_MODE_EDIT)) {
+ if ($page->isValid() || !$page->allows(Wicked::MODE_EDIT)) {
return $page;
}
$this->_proc->setFormatConf('Xhtml', 'charset', $GLOBALS['registry']->getCharset());
$this->_proc->setFormatConf('Xhtml', 'translate', HTML_SPECIALCHARS);
- $create = $this->allows(WICKED_MODE_CREATE) ? 1 : 0;
+ $create = $this->allows(Wicked::MODE_CREATE) ? 1 : 0;
$linkConf = array(
'pages' => $wicked->getPages(),
'view_url' => $view_url,
function render($mode, $params = null)
{
switch ($mode) {
- case WICKED_MODE_CONTENT:
+ case Wicked::MODE_CONTENT:
return $this->content($params);
- case WICKED_MODE_DISPLAY:
+ case Wicked::MODE_DISPLAY:
return $this->display($params);
- case WICKED_MODE_BLOCK:
+ case Wicked::MODE_BLOCK:
return $this->block($params);
- case WICKED_MODE_REMOVE:
+ case Wicked::MODE_REMOVE:
return $this->remove();
- case WICKED_MODE_HISTORY:
+ case Wicked::MODE_HISTORY:
return $this->history();
- case WICKED_MODE_DIFF:
+ case Wicked::MODE_DIFF:
return $this->diff($params);
default:
* @var array
*/
var $supportedModes = array(
- WICKED_MODE_DISPLAY => true);
+ Wicked::MODE_DISPLAY => true);
/**
* The page to confirm creation of.
* Display modes supported by this page.
*/
var $supportedModes = array(
- WICKED_MODE_CONTENT => true,
- WICKED_MODE_DISPLAY => true);
+ Wicked::MODE_CONTENT => true,
+ Wicked::MODE_DISPLAY => true);
/**
* Render this page in Content mode.
* @var array
*/
var $supportedModes = array(
- WICKED_MODE_CONTENT => true,
- WICKED_MODE_EDIT => true,
- WICKED_MODE_REMOVE => true,
- WICKED_MODE_DISPLAY => true);
+ Wicked::MODE_CONTENT => true,
+ Wicked::MODE_EDIT => true,
+ Wicked::MODE_REMOVE => true,
+ Wicked::MODE_DISPLAY => true);
/**
* The page for which we'd like to manipulate attachments.
'version' => $attach['attachment_majorversion'] . '.'
. $attach['attachment_minorversion']));
- $attachments[$idx]['delete_form'] = $this->allows(WICKED_MODE_REMOVE);
+ $attachments[$idx]['delete_form'] = $this->allows(Wicked::MODE_REMOVE);
$this->_page['change_author'] = $attachments[$idx]['change_author'];
$attachments[$idx]['change_author'] = $this->author();
sort($files);
$template->set('files', $files);
$template->set('canUpdate',
- $this->allows(WICKED_MODE_EDIT) && count($files),
+ $this->allows(Wicked::MODE_EDIT) && count($files),
true);
- $template->set('canAttach', $this->allows(WICKED_MODE_EDIT), true);
+ $template->set('canAttach', $this->allows(Wicked::MODE_EDIT), true);
if ($conf['wicked']['require_change_log']) {
$template->set('requireChangelog', true, true);
} else {
// See if we're supposed to delete an attachment.
if ($cmd == 'delete' && $filename && $version) {
- if (!$this->allows(WICKED_MODE_REMOVE)) {
+ if (!$this->allows(Wicked::MODE_REMOVE)) {
$notification->push(_("You do not have permission to delete attachments from this page."), 'horde.error');
return;
}
return;
}
- if (!$this->allows(WICKED_MODE_EDIT)) {
+ if (!$this->allows(Wicked::MODE_EDIT)) {
$notification->push(
sprintf(_("You do not have permission to edit \"%s\""),
$this->referrer()),
* @var array
*/
var $supportedModes = array(
- WICKED_MODE_DISPLAY => true);
+ Wicked::MODE_DISPLAY => true);
/**
* The page that we're displaying backlinks to.
*
* @var array
*/
- var $supportedModes = array(WICKED_MODE_DISPLAY => true);
+ var $supportedModes = array(Wicked::MODE_DISPLAY => true);
/**
* The page that we're confirming deletion for.
function preDisplay()
{
$page = Wicked_Page::getPage($this->referrer());
- if (!$page->allows(WICKED_MODE_REMOVE)) {
+ if (!$page->allows(Wicked::MODE_REMOVE)) {
Wicked::url($this->referrer(), true)->redirect();
}
}
{
$pagename = $this->referrer();
$page = Wicked_Page::getPage($pagename);
- if ($page->allows(WICKED_MODE_REMOVE)) {
+ if ($page->allows(Wicked::MODE_REMOVE)) {
$version = Horde_Util::getFormData('version');
if (empty($version)) {
$GLOBALS['wicked']->removeAllVersions($pagename);
* @var array
*/
var $supportedModes = array(
- WICKED_MODE_DISPLAY => true,
- WICKED_MODE_EDIT => true);
+ Wicked::MODE_DISPLAY => true,
+ Wicked::MODE_EDIT => true);
/**
* The page that we're editing.
{
$this->_referrer = $referrer;
if ($GLOBALS['conf']['lock']['driver'] != 'none') {
- $this->supportedModes[WICKED_MODE_LOCKING] = $this->supportedModes[WICKED_MODE_UNLOCKING] = true;
+ $this->supportedModes[Wicked::MODE_LOCKING] = $this->supportedModes[Wicked::MODE_UNLOCKING] = true;
}
}
*/
function allows($mode)
{
- if ($mode == WICKED_MODE_EDIT) {
+ if ($mode == Wicked::MODE_EDIT) {
$page = Wicked_Page::getPage($this->referrer());
if ($page->isLocked(Wicked::lockUser())) {
return false;
*/
function preDisplay()
{
- if (!$this->allows(WICKED_MODE_EDIT)) {
+ if (!$this->allows(Wicked::MODE_EDIT)) {
Wicked::url($this->referrer(), true)->redirect();
}
- if ($this->allows(WICKED_MODE_LOCKING)) {
+ if ($this->allows(Wicked::MODE_LOCKING)) {
$page = Wicked_Page::getPage($this->referrer());
if ($page->isLocked()) {
$page->unlock();
global $notification, $conf;
$page = Wicked_Page::getPage($this->referrer());
- if (!$this->allows(WICKED_MODE_EDIT)) {
+ if (!$this->allows(Wicked::MODE_EDIT)) {
$notification->push(sprintf(_("You don't have permission to edit \"%s\"."), $page->pageName()));
} else {
if (!empty($GLOBALS['conf']['wicked']['captcha']) &&
}
}
- if ($page->allows(WICKED_MODE_UNLOCKING)) {
+ if ($page->allows(Wicked::MODE_UNLOCKING)) {
$result = $page->unlock();
if (is_a($result, 'PEAR_Error')) {
$GLOBALS['notification']->push(sprintf(_("Page failed to unlock: %s"), $result->getMessage()), 'horde.error');
* @var array
*/
var $supportedModes = array(
- WICKED_MODE_CONTENT => true,
- WICKED_MODE_DISPLAY => true);
+ Wicked::MODE_CONTENT => true,
+ Wicked::MODE_DISPLAY => true);
/**
* Render this page in Content mode.
* @var array
*/
var $supportedModes = array(
- WICKED_MODE_DISPLAY => true);
+ Wicked::MODE_DISPLAY => true);
/**
* The page that we're displaying similar pages to.
* @var array
*/
var $supportedModes = array(
- WICKED_MODE_EDIT => true,
- WICKED_MODE_DISPLAY => true);
+ Wicked::MODE_EDIT => true,
+ Wicked::MODE_DISPLAY => true);
/**
* The page that we're displaying similar pages to.
*/
function allows($mode)
{
- if ($mode == WICKED_MODE_EDIT) {
- if (!parent::allows(WICKED_MODE_REMOVE)) {
+ if ($mode == Wicked::MODE_EDIT) {
+ if (!parent::allows(Wicked::MODE_REMOVE)) {
return false;
}
$page = Wicked_Page::getPage($this->referrer());
$referrer, $sourcePage->getMessage()),
'horde.error');
return;
- } elseif (!$this->allows(WICKED_MODE_EDIT)) {
+ } elseif (!$this->allows(Wicked::MODE_EDIT)) {
$notification->push(sprintf(_("You do not have permission to edit \"%s\""),
$referrer), 'horde.error');
return;
$new_name), 'horde.error');
return;
}
- if (!$destPage->allows(WICKED_MODE_EDIT)) {
+ if (!$destPage->allows(Wicked::MODE_EDIT)) {
$notification->push(sprintf(_("You do not have permission to edit \"%s\""),
$new_name), 'horde.error');
return;
'Subject' => '[' . $registry->get('name') . '] renamed: ' . $referrer . ', ' . $new_name));
}
- $wikiWord = '/^' . WICKED_REGEXP_WIKIWORD . '$/';
+ $wikiWord = '/^' . Wicked::REGEXP_WIKIWORD . '$/';
// We don't check permissions on these pages since we want references
// to be fixed even if the user doing the editing couldn't fix that
* @var array
*/
var $supportedModes = array(
- WICKED_MODE_CONTENT => true,
- WICKED_MODE_DISPLAY => true);
+ Wicked::MODE_CONTENT => true,
+ Wicked::MODE_DISPLAY => true);
/**
* Render this page in Content mode.
* @var array
*/
var $supportedModes = array(
- WICKED_MODE_DISPLAY => true,
- WICKED_MODE_EDIT => true);
+ Wicked::MODE_DISPLAY => true,
+ Wicked::MODE_EDIT => true);
/**
* The page that we're creating.
Wicked::url('', true)->redirect();
}
- if (!$this->allows(WICKED_MODE_EDIT)) {
+ if (!$this->allows(Wicked::MODE_EDIT)) {
Wicked::url($this->referrer(), true)->redirect();
}
}
{
global $notification, $wicked;
- if (!$this->allows(WICKED_MODE_EDIT)) {
+ if (!$this->allows(Wicked::MODE_EDIT)) {
$notification->push(sprintf(_("You don't have permission to create \"%s\"."), $this->referrer()));
} else {
$text = Horde_Util::getPost('page_text');
* @var array
*/
var $supportedModes = array(
- WICKED_MODE_CONTENT => true,
- WICKED_MODE_DISPLAY => true);
+ Wicked::MODE_CONTENT => true,
+ Wicked::MODE_DISPLAY => true);
/**
* Render this page in Content mode.
*
* @var array
*/
- var $supportedModes = array(WICKED_MODE_DISPLAY => true);
+ var $supportedModes = array(Wicked::MODE_DISPLAY => true);
/**
* The page that we're confirming reversion for.
function preDisplay()
{
$page = Wicked_Page::getPage($this->referrer());
- if (!$page->allows(WICKED_MODE_EDIT)) {
+ if (!$page->allows(Wicked::MODE_EDIT)) {
Wicked::url($this->referrer(), true)->redirect();
}
}
global $notification;
$page = Wicked_Page::getPage($this->referrer());
- if ($page->allows(WICKED_MODE_EDIT)) {
+ if ($page->allows(Wicked::MODE_EDIT)) {
$version = Horde_Util::getPost('version');
if (empty($version)) {
$notification->push(sprintf(_("Can't revert to an unknown version.")), 'horde.error');
* @var array
*/
var $supportedModes = array(
- WICKED_MODE_CONTENT => true,
- WICKED_MODE_DISPLAY => true);
+ Wicked::MODE_CONTENT => true,
+ Wicked::MODE_DISPLAY => true);
/**
* Cached search results.
* @var array
*/
var $supportedModes = array(
- WICKED_MODE_DISPLAY => true,
- WICKED_MODE_EDIT => true,
- WICKED_MODE_REMOVE => true,
- WICKED_MODE_HISTORY => true,
- WICKED_MODE_DIFF => true);
+ Wicked::MODE_DISPLAY => true,
+ Wicked::MODE_EDIT => true,
+ Wicked::MODE_REMOVE => true,
+ Wicked::MODE_HISTORY => true,
+ Wicked::MODE_DIFF => true);
/**
* A Horde_Locks instance for un-/locking this page.
}
if ($GLOBALS['conf']['lock']['driver'] != 'none') {
- $this->supportedModes[WICKED_MODE_LOCKING] = $this->supportedModes[WICKED_MODE_UNLOCKING] = true;
+ $this->supportedModes[Wicked::MODE_LOCKING] = $this->supportedModes[Wicked::MODE_UNLOCKING] = true;
$this->_locks = $GLOBALS['injector']->getInstance('Horde_Lock');
$locks = $this->_locks->getLocks('wicked', $pagename, Horde_Lock::TYPE_EXCLUSIVE);
if ($locks) {
function allows($mode)
{
switch ($mode) {
- case WICKED_MODE_EDIT:
+ case Wicked::MODE_EDIT:
if ($this->isLocked()) {
return Wicked::lockUser() == $this->_lock['lock_owner'];
}
break;
- case WICKED_MODE_LOCKING:
+ case Wicked::MODE_LOCKING:
if ($GLOBALS['browser']->isRobot()) {
return false;
}
}
break;
- case WICKED_MODE_UNLOCKING:
+ case Wicked::MODE_UNLOCKING:
if ($GLOBALS['registry']->isAdmin()) {
return true;
}
* @var array
*/
var $supportedModes = array(
- WICKED_MODE_DISPLAY => true,
- WICKED_MODE_EDIT => false,
- WICKED_MODE_REMOVE => true,
- WICKED_MODE_HISTORY => true,
- WICKED_MODE_DIFF => true,
- WICKED_MODE_LOCKING => false,
- WICKED_MODE_UNLOCKING => false);
+ Wicked::MODE_DISPLAY => true,
+ Wicked::MODE_EDIT => false,
+ Wicked::MODE_REMOVE => true,
+ Wicked::MODE_HISTORY => true,
+ Wicked::MODE_DIFF => true,
+ Wicked::MODE_LOCKING => false,
+ Wicked::MODE_UNLOCKING => false);
/**
* Construct a standard history page class to represent an old
* Display modes supported by this page.
*/
var $supportedModes = array(
- WICKED_MODE_CONTENT => true,
- WICKED_MODE_DISPLAY => true);
+ Wicked::MODE_CONTENT => true,
+ Wicked::MODE_DISPLAY => true);
/**
* Sync driver
* Display modes supported by this page.
*/
var $supportedModes = array(
- WICKED_MODE_CONTENT => true);
+ Wicked::MODE_CONTENT => true);
/**
* Sync driver
return $page;
}
- if (!$page->allows(WICKED_MODE_EDIT)) {
+ if (!$page->allows(Wicked::MODE_EDIT)) {
return PEAR::RaiseError(sprintf(_("You don't have permission to edit \"%s\"."), $pageName));
}
{
parent::Text_Wiki_Parse($obj);
- $this->regex = '/((?:\[\[' . WICKED_REGEXP_WIKIWORD .
+ $this->regex = '/((?:\[\[' . Wicked::REGEXP_WIKIWORD .
':\s+.*?\]\]\s*)+)/';
}
// We should do full wiki formatting, I guess, but there isn't
// a convenient way to do it.
- if (preg_match('/^(' . WICKED_REGEXP_WIKIWORD . ')$/',
+ if (preg_match('/^(' . Wicked::REGEXP_WIKIWORD . ')$/',
$attribute['value'], $matches)) {
$vlink = array('page' => $matches[1],
'anchor' => '',
<?php
-// Modes we might be displaying a page in.
-/** Display mode. */
-define('WICKED_MODE_DISPLAY', 0);
+/**
+ * Wicked Base Class.
+ *
+ * Copyright 2003-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Tyler Colbert <tyler@colberts.us>
+ * @package Wicked
+ */
+class Wicked
+{
+ /** Display mode. */
+ const MODE_DISPLAY = 0;
-/** The edit screen. */
-define('WICKED_MODE_EDIT', 1);
+ /** The edit screen. */
+ const MODE_EDIT = 1;
-/** Page can be removed. */
-define('WICKED_MODE_REMOVE', 2);
+ /** Page can be removed. */
+ const MODE_REMOVE = 2;
-/** Display the page history. */
-define('WICKED_MODE_HISTORY', 3);
+ /** Display the page history. */
+ const MODE_HISTORY = 3;
-/** Diff two versions of the page. */
-define('WICKED_MODE_DIFF', 4);
+ /** Diff two versions of the page. */
+ const MODE_DIFF = 4;
-/** Page can be locked. */
-define('WICKED_MODE_LOCKING', 7);
+ /** Page can be locked. */
+ const MODE_LOCKING = 7;
-/** Page can be unlocked. */
-define('WICKED_MODE_UNLOCKING', 8);
+ /** Page can be unlocked. */
+ const MODE_UNLOCKING = 8;
-/** The ability to add a page. */
-define('WICKED_MODE_CREATE', 9);
+ /** The ability to add a page. */
+ const MODE_CREATE = 9;
-/** Raw content mode. */
-define('WICKED_MODE_CONTENT', 10);
+ /** Raw content mode. */
+ const MODE_CONTENT = 10;
-/** Like display, but for a block. */
-define('WICKED_MODE_BLOCK', 11);
+ /** Like display, but for a block. */
+ const MODE_BLOCK = 11;
-/** Our wiki word regexp (needed many places). */
-define('WICKED_REGEXP_WIKIWORD',
+ /** Our wiki word regexp (needed many places).
"(!?" . // START WikiPage pattern (1)
"[A-Z\xc0-\xde]" . // 1 upper
"[A-Za-z0-9\xc0-\xfe]*" . // 0+ alpha or digit
// colon, dot
"[-_A-Za-z0-9\xc0-\xfe]" . // 1 dash, alpha, digit, or underscore
")?)?)"); // end subpatterns (/4)(/3)(/2)
+ */
+ const REGEXP_WIKIWORD = "(!?[A-Z\xc0-\xde][A-Za-z0-9\xc0-\xfe]*[a-z0-9\xdf-\xfe]+[A-Z\xc0-\xde][A-Za-z0-9\xc0-\xfe]*)((\#[A-Za-z0-9\xc0-\xfe]([-_A-Za-z0-9\xc0-\xfe:.]*[-_A-Za-z0-9\xc0-\xfe])?)?)";
-/** Where we store our attachments in VFS. */
-define('WICKED_VFS_ATTACH_PATH', '.horde/wicked/attachments');
-
-/**
- * Wicked Base Class.
- *
- * Copyright 2003-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author Tyler Colbert <tyler@colberts.us>
- * @package Wicked
- */
-class Wicked {
+ /** Where we store our attachments in VFS. */
+ const WICKED_VFS_ATTACH_PATH = '.horde/wicked/attachments';
/**
* Puts together the URL to a Wicked page. Uses mod_rewrite or GET
*
* @return string The URL of $page.
*/
- function url($page, $full = false, $append_session = 0)
+ public static function url($page, $full = false, $append_session = 0)
{
global $conf;
/**
* Build Wicked's list of menu items.
*/
- function getMenu($returnType = 'object')
+ public static function getMenu($returnType = 'object')
{
global $conf, $page;
* @param string $message The message text to send out.
* @param array $headers Additional headers to add to the email.
*/
- function mail($message, $headers = array())
+ public static function mail($message, $headers = array())
{
global $conf, $registry;
*
* @return string A CAPTCHA string.
*/
- function getCAPTCHA($new = false)
+ public static function getCAPTCHA($new = false)
{
if ($new || empty($_SESSION['wickedSession']['CAPTCHA'])) {
$_SESSION['wickedSession']['CAPTCHA'] = '';
*
* @return string The user name used for locking.
*/
- function lockUser()
+ public static function lockUser()
{
return $GLOBALS['registry']->getAuth() ? $GLOBALS['registry']->getAuth() : $GLOBALS['browser']->getIPAddress();
}
separator(true);
-if ($this->allows(WICKED_MODE_EDIT) && !$this->isLocked(Wicked::lockUser())) {
+if ($this->allows(Wicked::MODE_EDIT) && !$this->isLocked(Wicked::lockUser())) {
separator();
$url = Horde_Util::addParameter(Wicked::url('EditPage'),
'referrer', $this->pageName());
}
if ($this->isLocked()) {
- if ($this->allows(WICKED_MODE_UNLOCKING)) {
+ if ($this->allows(Wicked::MODE_UNLOCKING)) {
separator();
echo Horde::widget(Horde_Util::removeParameter(
$this->pageUrl(null, 'unlock'),
'widget', '', '', _("Un_lock"));
}
} else {
- if ($this->allows(WICKED_MODE_LOCKING)) {
+ if ($this->allows(Wicked::MODE_LOCKING)) {
separator();
echo Horde::widget(Horde_Util::removeParameter(
$this->pageUrl(null, 'lock'),
}
}
-if ($this->allows(WICKED_MODE_REMOVE)) {
+if ($this->allows(Wicked::MODE_REMOVE)) {
separator();
$params = array('referrer' => $this->pageName());
if ($this->isOld()) {
'widget', '', '', _("_Delete"));
}
-if ($this->allows(WICKED_MODE_REMOVE) && !$this->isLocked(Wicked::lockUser())) {
+if ($this->allows(Wicked::MODE_REMOVE) && !$this->isLocked(Wicked::lockUser())) {
separator();
$url = Horde_Util::addParameter(Wicked::url('MergeOrRename'),
'referrer', $this->pageName());
echo Horde::widget($url, _("Attachments"), 'widget', '', '',
_("Attachments"));
-if ($this->allows(WICKED_MODE_HISTORY)) {
+if ($this->allows(Wicked::MODE_HISTORY)) {
separator();
echo Horde::widget(Horde_Util::removeParameter($this->pageUrl('history.php'),
'version'),
}
$v = $this->version();
-if (!is_a($v, 'PEAR_Error') && $this->allows(WICKED_MODE_DIFF)) {
+if (!is_a($v, 'PEAR_Error') && $this->allows(Wicked::MODE_DIFF)) {
$diff_url = Horde_Util::addParameter(Horde::url('diff.php'),
array('page' => $this->pageName(),
'v1' => '?',
<tr class="item">
<th align="left" width="1%"><?php echo _("Version") ?></th>
-<?php if ($this->allows(WICKED_MODE_REMOVE)): ?>
+<?php if ($this->allows(Wicked::MODE_REMOVE)): ?>
<th align="center" class="nowrap" style="width:1%"><?php echo Horde::img('delete.png', _("Delete Version")) ?></th>
-<?php endif; if ($this->allows(WICKED_MODE_EDIT)): ?>
+<?php endif; if ($this->allows(Wicked::MODE_EDIT)): ?>
<th align="center" class="nowrap" style="width:1%"><?php echo Horde::img('edit.png', _("Edit Version")) ?></th>
<th align="center" class="nowrap" style="width:1%"><?php echo Horde::img('restore.png', _("Restore Version")) ?></th>
<tr>
<td><?php echo Horde::link($page->pageUrl(), sprintf(_("Display Version %s"), $page->version())) . htmlspecialchars($page->version()) ?></a></td>
-<?php if ($this->allows(WICKED_MODE_REMOVE)): ?>
+<?php if ($this->allows(Wicked::MODE_REMOVE)): ?>
<td style="text-align:center">
<?php
$text = sprintf(_("Delete Version %s"), $page->version());
echo Horde::link($url, $text) . Horde::img('delete.png', $text) . '</a>';
?>
</td>
-<?php endif; if ($this->allows(WICKED_MODE_EDIT)): ?>
+<?php endif; if ($this->allows(Wicked::MODE_EDIT)): ?>
<td style="text-align:center">
<?php
if ($show_edit) {