// user preferred sorting column
$_prefs['sortby'] = array(
- 'value' => MNEMO_SORT_DESC,
+ 'value' => Mnemo::SORT_DESC,
'type' => 'enum',
'enum' => array(
- MNEMO_SORT_DESC => _("Note Text"),
- MNEMO_SORT_CATEGORY => _("Note Category"),
- MNEMO_SORT_NOTEPAD => _("Notepad")
+ Mnemo::SORT_DESC => _("Note Text"),
+ Mnemo::SORT_CATEGORY => _("Note Category"),
+ Mnemo::SORT_NOTEPAD => _("Notepad")
),
'desc' => _("Default sorting criteria:")
);
'value' => 0,
'type' => 'enum',
'enum' => array(
- MNEMO_SORT_ASCEND => _("Ascending"),
- MNEMO_SORT_DESCEND => _("Descending")
+ Mnemo::SORT_ASCEND => _("Ascending"),
+ Mnemo::SORT_DESCEND => _("Descending")
),
'desc' => _("Default sorting direction:")
);
}
if (is_a($memo['body'], 'PEAR_Error')) {
- if ($memo['body']->getCode() == MNEMO_ERR_NO_PASSPHRASE ||
- $memo['body']->getCode() == MNEMO_ERR_DECRYPT) {
+ if ($memo['body']->getCode() == Mnemo::ERR_NO_PASSPHRASE ||
+ $memo['body']->getCode() == Mnemo::ERR_DECRYPT) {
$memo['body'] = _("This note has been encrypted.");
} else {
return $memo['body'];
// Create the new iCalendar container.
$iCal = new Horde_iCalendar('1.1');
$iCal->setAttribute('VERSION', '1.1');
- $iCal->setAttribute('PRODID', '-//The Horde Project//Mnemo ' . MNEMO_VERSION . '//EN');
+ $iCal->setAttribute('PRODID', '-//The Horde Project//Mnemo ' . Mnemo::VERSION . '//EN');
$iCal->setAttribute('METHOD', 'PUBLISH');
// Create a new vNote.
$passphrase = Mnemo::getPassphrase($note['uid']);
}
if (empty($passphrase)) {
- $body = PEAR::raiseError(_("This note has been encrypted."), MNEMO_ERR_NO_PASSPHRASE);
+ $body = PEAR::raiseError(_("This note has been encrypted."), Mnemo::ERR_NO_PASSPHRASE);
} else {
$body = $this->decrypt($body, $passphrase);
if (is_a($body, 'PEAR_Error')) {
- $body->code = MNEMO_ERR_DECRYPT;
+ $body->code = Mnemo::ERR_DECRYPT;
} else {
$body = $body->message;
Mnemo::storePassphrase($note['memo_id'], $passphrase);
$passphrase = Mnemo::getPassphrase($row['memo_id']);
}
if (empty($passphrase)) {
- $body = PEAR::raiseError(_("This note has been encrypted."), MNEMO_ERR_NO_PASSPHRASE);
+ $body = PEAR::raiseError(_("This note has been encrypted."), Mnemo::ERR_NO_PASSPHRASE);
} else {
$body = $this->decrypt($body, $passphrase);
if (is_a($body, 'PEAR_Error')) {
- $body->code = MNEMO_ERR_DECRYPT;
+ $body->code = Mnemo::ERR_DECRYPT;
} else {
$body = $body->message;
Mnemo::storePassphrase($row['memo_id'], $passphrase);
*/
/**
- * Sort by memo description.
- */
-define('MNEMO_SORT_DESC', 0);
-
-/**
- * Sort by memo category.
- */
-define('MNEMO_SORT_CATEGORY', 1);
-
-/**
- * Sort by notepad.
- */
-define('MNEMO_SORT_NOTEPAD', 2);
-
-/**
- * Sort in ascending order.
- */
-define('MNEMO_SORT_ASCEND', 0);
-
-/**
- * Sort in descending order.
- */
-define('MNEMO_SORT_DESCEND', 1);
-
-/**
- * No passphrase provided.
- */
-define('MNEMO_ERR_NO_PASSPHRASE', 100);
-
-/**
- * Decrypting failed
- */
-define('MNEMO_ERR_DECRYPT', 101);
-
-/**
* Mnemo Base Class.
*
* @author Jon Parise <jon@horde.org>
* @package Mnemo
*/
class Mnemo {
+ /**
+ * Sort by memo description.
+ */
+ const SORT_DESC = 0;
+
+ /**
+ * Sort by memo category.
+ */
+ const SORT_CATEGORY = 1;
+
+ /**
+ * Sort by notepad.
+ */
+ const SORT_NOTEPAD = 2;
+
+ /**
+ * Sort in ascending order.
+ */
+ const SORT_ASCEND = 0;
+
+ /**
+ * Sort in descending order.
+ */
+ const SORT_DESCEND = 1;
+
+ /**
+ * No passphrase provided.
+ */
+ const ERR_NO_PASSPHRASE = 100;
+
+ /**
+ * Decrypting failed
+ */
+ const ERR_DECRYPT = 101;
/**
* Retrieves the current user's note list from storage. This function will
* also sort the resulting list, if requested.
*
- * @param constant $sortby The field by which to sort. (MNEMO_SORT_DESC,
- * MNEMO_SORT_CATEGORY, MNEMO_SORT_NOTEPAD)
+ * @param constant $sortby The field by which to sort. (self::SORT_DESC,
+ * self::SORT_CATEGORY, self::SORT_NOTEPAD)
* @param constant $sortdir The direction by which to sort.
- * (MNEMO_SORT_ASC, MNEMO_SORT_DESC)
+ * (self::SORT_ASC, self::SORT_DESC)
*
* @return array A list of the requested notes.
*
* @see Mnemo_Driver::listMemos()
*/
- public static function listMemos($sortby = MNEMO_SORT_DESC,
- $sortdir = MNEMO_SORT_ASCEND)
+ public static function listMemos($sortby = self::SORT_DESC,
+ $sortdir = self::SORT_ASCEND)
{
global $conf, $display_notepads;
$memos = array();
/* Sort the memo list. */
$sort_functions = array(
- MNEMO_SORT_DESC => 'ByDesc',
- MNEMO_SORT_CATEGORY => 'ByCategory',
- MNEMO_SORT_NOTEPAD => 'ByNotepad',
+ self::SORT_DESC => 'ByDesc',
+ self::SORT_CATEGORY => 'ByCategory',
+ self::SORT_NOTEPAD => 'ByNotepad',
);
foreach ($display_notepads as $notepad) {
/* Sort the array if we have a sort function defined for this
* field. */
if (isset($sort_functions[$sortby])) {
- $prefix = ($sortdir == MNEMO_SORT_DESCEND) ? '_rsort' : '_sort';
+ $prefix = ($sortdir == self::SORT_DESCEND) ? '_rsort' : '_sort';
uasort($memos, array('Mnemo', $prefix . $sort_functions[$sortby]));
}
/* Check for secure connection. */
$secure_check = Horde::isConnectionSecure();
- if ($memo['body']->getCode() == MNEMO_ERR_NO_PASSPHRASE) {
+ if ($memo['body']->getCode() == Mnemo::ERR_NO_PASSPHRASE) {
if ($secure_check) {
$notification->push(_("This note has been encrypted, please provide the password below"), 'horde.message');
return true;
return false;
}
- if ($memo['body']->getCode() == MNEMO_ERR_DECRYPT) {
+ if ($memo['body']->getCode() == Mnemo::ERR_DECRYPT) {
if ($secure_check) {
$notification->push(_("This note cannot be decrypted:") . ' ' . $memo['body']->getMessage(), 'horde.message');
return true;
<tr class="item leftAlign">
<th class="nosort" width="3%"><?php echo Horde::img('edit.png', _("Edit Note"), '') ?></th>
<?php if ($showNotepad): ?>
- <th id="s<?php echo MNEMO_SORT_NOTEPAD ?>"<?php if ($sortby == MNEMO_SORT_NOTEPAD) echo ' class="' . $sortdirclass . '"' ?> width="2%">
- <?php echo Horde::widget(Horde::applicationUrl(Horde_Util::addParameter($baseurl, 'sortby', MNEMO_SORT_NOTEPAD)), _("Sort by Notepad"), 'sortlink', '', '', _("Notepad")) ?>
+ <th id="s<?php echo Mnemo::SORT_NOTEPAD ?>"<?php if ($sortby == Mnemo::SORT_NOTEPAD) echo ' class="' . $sortdirclass . '"' ?> width="2%">
+ <?php echo Horde::widget(Horde::applicationUrl(Horde_Util::addParameter($baseurl, 'sortby', Mnemo::SORT_NOTEPAD)), _("Sort by Notepad"), 'sortlink', '', '', _("Notepad")) ?>
</th>
<?php endif; ?>
- <th id="s<?php echo MNEMO_SORT_DESC ?>"<?php if ($sortby == MNEMO_SORT_DESC) echo ' class="' . $sortdirclass . '"' ?> width="82%">
- <?php echo Horde::widget(Horde::applicationUrl(Horde_Util::addParameter('list.php', 'sortby', MNEMO_SORT_DESC)), _("Sort by Note Text"), 'sortlink', '', '', _("No_te")) ?>
+ <th id="s<?php echo Mnemo::SORT_DESC ?>"<?php if ($sortby == Mnemo::SORT_DESC) echo ' class="' . $sortdirclass . '"' ?> width="82%">
+ <?php echo Horde::widget(Horde::applicationUrl(Horde_Util::addParameter('list.php', 'sortby', Mnemo::SORT_DESC)), _("Sort by Note Text"), 'sortlink', '', '', _("No_te")) ?>
</th>
- <th id="s<?php echo MNEMO_SORT_CATEGORY ?>"<?php if ($sortby == MNEMO_SORT_CATEGORY) echo ' class="' . $sortdirclass . '"' ?> width="15%">
+ <th id="s<?php echo Mnemo::SORT_CATEGORY ?>"<?php if ($sortby == Mnemo::SORT_CATEGORY) echo ' class="' . $sortdirclass . '"' ?> width="15%">
<?php
- echo Horde::widget(Horde::applicationUrl(Horde_Util::addParameter('list.php', 'sortby', MNEMO_SORT_CATEGORY)), _("Sort by Category"), 'sortlink', '', '', _("_Category"));
+ echo Horde::widget(Horde::applicationUrl(Horde_Util::addParameter('list.php', 'sortby', Mnemo::SORT_CATEGORY)), _("Sort by Category"), 'sortlink', '', '', _("_Category"));
if (Horde_Auth::getAuth() && (!$GLOBALS['prefs']->isLocked('categories') ||
!$GLOBALS['prefs']->isLocked('category_colors'))) {
$categoryUrl = Horde_Util::addParameter(Horde::url($GLOBALS['registry']->get('webroot', 'horde') . '/services/prefs.php'), array('app' => 'horde', 'group' => 'categories'));
if (is_a($memo['body'], 'PEAR_Error')) {
/* Check for secure connection. */
$secure_check = Horde::isConnectionSecure();
- if ($memo['body']->getCode() == MNEMO_ERR_NO_PASSPHRASE) {
+ if ($memo['body']->getCode() == Mnemo::ERR_NO_PASSPHRASE) {
if ($secure_check) {
$notification->push(_("This note has been encrypted, please provide the password below"), 'horde.message');
$show_passphrase = true;
$notification->push(_("This note has been encrypted, and cannot be decrypted without a secure web connection"), 'horde.error');
$memo['body'] = '';
}
- } elseif ($memo['body']->getCode() == MNEMO_ERR_DECRYPT) {
+ } elseif ($memo['body']->getCode() == Mnemo::ERR_DECRYPT) {
if ($secure_check) {
$notification->push(_("This note cannot be decrypted:") . ' ' . $memo['body']->getMessage(), 'horde.message');
$show_passphrase = true;