Migrate to H4 (imp (at) lx-soft (dot) com, Request #8950).
authorJan Schneider <jan@horde.org>
Wed, 7 Apr 2010 07:56:23 +0000 (09:56 +0200)
committerJan Schneider <jan@horde.org>
Wed, 7 Apr 2010 07:56:23 +0000 (09:56 +0200)
24 files changed:
mnemo/data.php
mnemo/lib/Api.php [new file with mode: 0644]
mnemo/lib/Application.php [new file with mode: 0644]
mnemo/lib/Block/summary.php
mnemo/lib/Block/tree_menu.php
mnemo/lib/Driver/sql.php
mnemo/lib/Mnemo.php
mnemo/lib/api.php [deleted file]
mnemo/lib/base.php [deleted file]
mnemo/lib/prefs.php [deleted file]
mnemo/lib/version.php [deleted file]
mnemo/list.php
mnemo/memo.php
mnemo/notepads/create.php
mnemo/notepads/delete.php
mnemo/notepads/edit.php
mnemo/notepads/index.php
mnemo/search.php
mnemo/templates/common-header.inc
mnemo/templates/list/header.inc
mnemo/templates/list/memo_headers.inc
mnemo/templates/list/memo_summaries.inc
mnemo/templates/menu.inc
mnemo/view.php

index 6a9ce0b..c9e64ac 100644 (file)
@@ -20,7 +20,8 @@ function _cleanup()
 }
 
 @define('MNEMO_BASE', dirname(__FILE__));
-require_once MNEMO_BASE . '/lib/base.php';
+require_once MNEMO_BASE . '/lib/Application.php';
+Horde_Registry::appInit('mnemo');
 
 if (!$conf['menu']['import_export']) {
     require MNEMO_BASE . '/index.php';
@@ -36,9 +37,9 @@ $templates = array(
     Horde_Data::IMPORT_CSV => array($registry->get('templates', 'horde') . '/data/csvinfo.inc'),
     Horde_Data::IMPORT_MAPPED => array($registry->get('templates', 'horde') . '/data/csvmap.inc'),
 );
-if (Mnemo::hasPermission('max_notes') !== true &&
-    Mnemo::hasPermission('max_notes') <= Mnemo::countMemos()) {
-    $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d notes."), Mnemo::hasPermission('max_notes')), ENT_COMPAT, Horde_Nls::getCharset());
+if ($GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_notes') !== true &&
+    $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_notes') <= Mnemo::countMemos()) {
+    $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d notes."), $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_notes')), ENT_COMPAT, Horde_Nls::getCharset());
     if (!empty($conf['hooks']['permsdenied'])) {
         $message = Horde::callHook('_perms_hook_denied', array('mnemo:max_notes'), 'horde', $message);
     }
@@ -120,11 +121,11 @@ if (is_array($next_step)) {
 
     /* Create a Mnemo storage instance. */
     $storage = &Mnemo_Driver::singleton($_SESSION['import_data']['target']);
-    $max_memos = Mnemo::hasPermission('max_notes');
+    $max_memos = $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_notes');
     $num_memos = Mnemo::countMemos();
     foreach ($next_step as $row) {
         if ($max_memos !== true && $num_memos >= $max_memos) {
-            $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d notes."), Mnemo::hasPermission('max_notes')), ENT_COMPAT, Horde_Nls::getCharset());
+            $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d notes."), $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_notes')), ENT_COMPAT, Horde_Nls::getCharset());
             if (!empty($conf['hooks']['permsdenied'])) {
                 $message = Horde::callHook('_perms_hook_denied', array('mnemo:max_notes'), 'horde', $message);
             }
@@ -204,6 +205,7 @@ if (is_array($next_step)) {
 $title = _("Import/Export Notes");
 require MNEMO_TEMPLATES . '/common-header.inc';
 require MNEMO_TEMPLATES . '/menu.inc';
+$notification->notify();
 
 if (isset($templates[$next_step])) {
     foreach ($templates[$next_step] as $template) {
diff --git a/mnemo/lib/Api.php b/mnemo/lib/Api.php
new file mode 100644 (file)
index 0000000..8f0717c
--- /dev/null
@@ -0,0 +1,535 @@
+<?php
+/**
+ * Mnemo external API interface.
+ *
+ * This file defines Mnemo's external API interface.  Other applications can
+ * interact with Mnemo through this API.
+ *
+ * $Horde: mnemo/lib/api.php,v 1.99 2009-11-24 04:13:44 chuck Exp $
+ *
+ * Copyright 2001-2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file LICENSE for license information (ASL). If you
+ * did not receive this file, see http://www.horde.org/licenses/asl.php.
+ *
+ * @since   Mnemo 1.0
+ * @package Mnemo
+ */
+
+$_services['perms'] = array(
+    'args' => array(),
+    'type' => '{urn:horde}stringArray'
+);
+
+$_services['removeUserData'] = array(
+    'args' => array('user' => 'string'),
+    'type' => 'boolean'
+);
+
+$_services['show'] = array(
+    'link' => '%application%/view.php?memolist=|notepad|&memo=|note|&uid=|uid|',
+);
+
+$_services['listNotepads'] = array(
+    'args' => array('owneronly' => 'boolean', 'permission' => 'int'),
+    'type' => '{urn:horde}stringArray',
+);
+
+$_services['list'] = array(
+    'args' => array(),
+    'type' => '{urn:horde}stringArray'
+);
+
+$_services['listBy'] = array(
+    'args' => array('action' => 'string', 'timestamp' => 'int'),
+    'type' => '{urn:horde}stringArray'
+);
+
+$_services['getActionTimestamp'] = array(
+    'args' => array('uid' => 'string', 'action' => 'string', 'notepad' => 'string'),
+    'type' => 'int',
+);
+
+$_services['import'] = array(
+    'args' => array('content' => 'string', 'contentType' => 'string'),
+    'type' => 'string'
+);
+
+$_services['export'] = array(
+    'args' => array('uid' => 'string', 'contentType' => 'string'),
+    'type' => 'string'
+);
+
+$_services['delete'] = array(
+    'args' => array('uid' => 'string'),
+    'type' => 'boolean'
+);
+
+$_services['replace'] = array(
+    'args' => array('uid' => 'string', 'content' => 'string', 'contentType' => 'string'),
+    'type' => 'boolean'
+);
+
+/**
+ * Returns a list of available permissions.
+ *
+ * @return array  An array describing all available permissions.
+ */
+function _mnemo_perms()
+{
+    $perms = array();
+    $perms['tree']['mnemo']['max_notes'] = false;
+    $perms['title']['mnemo:max_notes'] = _("Maximum Number of Notes");
+    $perms['type']['mnemo:max_notes'] = 'int';
+
+    return $perms;
+}
+
+/**
+ * Removes user data.
+ *
+ * @param string $user  Name of user to remove data for.
+ *
+ * @return mixed  true on success | PEAR_Error on failure
+ */
+function _mnemo_removeUserData($user)
+{
+    require_once dirname(__FILE__) . '/base.php';
+
+    if (!Horde_Auth::isAdmin() && $user != Horde_Auth::getAuth()) {
+        return PEAR::raiseError(_("You are not allowed to remove user data."));
+    }
+
+    /* Error flag */
+    $hasError = false;
+
+    /* Get the share object for later deletion */
+    $share = $GLOBALS['mnemo_shares']->getShare($user);
+    if (is_a($share, 'PEAR_Error')) {
+        Horde::logMessage($share->getMessage(), 'ERR');
+        unset($share);
+    } else {
+        $GLOBALS['display_notepads'] = array($user);
+        $memos = Mnemo::listMemos();
+        if (is_a($memos, 'PEAR_Error')) {
+            $hasError = true;
+            Horde::logMessage($mnemos->getMessage(), 'ERR');
+        } else {
+            $uids = array();
+            foreach ($memos as $memo) {
+                $uids[] = $memo['uid'];
+            }
+
+            /* ... and delete them. */
+            foreach ($uids as $uid) {
+                _mnemo_delete($uid);
+            }
+        }
+
+        /* Now delete history as well. */
+        $history = &Horde_History::singleton();
+        if (method_exists($history, 'removeByParent')) {
+            $histories = $history->removeByParent('mnemo:' . $user);
+        } else {
+            /* Remove entries 100 at a time. */
+            $all = $history->getByTimestamp('>', 0, array(), 'mnemo:' . $user);
+            if (is_a($all, 'PEAR_Error')) {
+                Horde::logMessage($all, 'ERR');
+            } else {
+                $all = array_keys($all);
+                while (count($d = array_splice($all, 0, 100)) > 0) {
+                    $history->removebyNames($d);
+                }
+            }
+        }
+
+        /* Remove the share itself */
+        if (!empty($share)) {
+            $result = $GLOBALS['mnemo_shares']->removeShare($share);
+            if (is_a($result, 'PEAR_Error')) {
+                $hasError = true;
+                Horde::logMessage($result->getMessage(), 'ERR');
+            }
+        }
+
+        /* Get a list of all shares this user has perms to and remove the perms */
+        $shares = $GLOBALS['mnemo_shares']->listShares($user);
+        if (is_a($shares, 'PEAR_Error')) {
+            $hasError = true;
+            Horde::logMessage($shares, 'ERR');
+        } else {
+            foreach ($shares as $share) {
+                $share->removeUser($user);
+            }
+        }
+    }
+
+    if ($hasError) {
+        return PEAR::raiseError(sprintf(_("There was an error removing notes for %s. Details have been logged."), $user));
+    } else {
+        return true;
+    }
+}
+
+/**
+ * @param boolean $owneronly   Only return notepads that this user owns?
+ *                             Defaults to false.
+ * @param integer $permission  The permission to filter notepads by.
+ *
+ * @return array  The notepads.
+ */
+function _mnemo_listNotepads($owneronly, $permission)
+{
+    require_once dirname(__FILE__) . '/base.php';
+
+    return Mnemo::listNotepads($owneronly, $permission);
+}
+
+/**
+ * Returns an array of UIDs for all notes that the current user is authorized
+ * to see.
+ *
+ * @param string $notepad  The notepad to list notes from.
+ *
+ * @return array  An array of UIDs for all notes the user can access.
+ */
+function _mnemo_list($notepad = null)
+{
+    require_once dirname(__FILE__) . '/base.php';
+    global $conf;
+
+    if (!isset($conf['storage']['driver'])) {
+        return PEAR::raiseError('Not configured');
+    }
+
+    /* Make sure we have a valid notepad. */
+    if (empty($notepad)) {
+        $notepad = Mnemo::getDefaultNotepad();
+    }
+
+    if (!array_key_exists($notepad,
+                          Mnemo::listNotepads(false, Horde_Perms::READ))) {
+        return PEAR::raiseError(_("Permission Denied"));
+    }
+
+    /* Set notepad for listMemos. */
+    $GLOBALS['display_notepads'] = array($notepad);
+
+    $memos = Mnemo::listMemos();
+    if (is_a($memos, 'PEAR_Error')) {
+        return $memos;
+    }
+
+    $uids = array();
+    foreach ($memos as $memo) {
+        $uids[] = $memo['uid'];
+    }
+
+    return $uids;
+}
+
+/**
+ * Returns an array of UIDs for notes that have had $action happen since
+ * $timestamp.
+ *
+ * @param string  $action     The action to check for - add, modify, or delete.
+ * @param integer $timestamp  The time to start the search.
+ * @param string  $notepad    The notepad to search in.
+ *
+ * @return array  An array of UIDs matching the action and time criteria.
+ */
+function _mnemo_listBy($action, $timestamp, $notepad = null)
+{
+    require_once dirname(__FILE__) . '/base.php';
+
+    /* Make sure we have a valid notepad. */
+    if (empty($notepad)) {
+        $notepad = Mnemo::getDefaultNotepad();
+    }
+
+    if (!array_key_exists($notepad,
+                          Mnemo::listNotepads(false, Horde_Perms::READ))) {
+        return PEAR::raiseError(_("Permission Denied"));
+    }
+
+    $history = &Horde_History::singleton();
+    $histories = $history->getByTimestamp('>', $timestamp, array(array('op' => '=', 'field' => 'action', 'value' => $action)), 'mnemo:' . $notepad);
+    if (is_a($histories, 'PEAR_Error')) {
+        return $histories;
+    }
+
+    // Strip leading mnemo:username:.
+    return preg_replace('/^([^:]*:){2}/', '', array_keys($histories));
+}
+
+/**
+ * Returns the timestamp of an operation for a given uid an action.
+ *
+ * @param string $uid     The uid to look for.
+ * @param string $action  The action to check for - add, modify, or delete.
+ * @param string $notepad The notepad to search in.
+ *
+ * @return integer  The timestamp for this action.
+ */
+function _mnemo_getActionTimestamp($uid, $action, $notepad = null)
+{
+    require_once dirname(__FILE__) . '/base.php';
+
+    /* Make sure we have a valid notepad. */
+    if (empty($notepad)) {
+        $notepad = Mnemo::getDefaultNotepad();
+    }
+
+    if (!array_key_exists($notepad,
+                          Mnemo::listNotepads(false, Horde_Perms::READ))) {
+        return PEAR::raiseError(_("Permission Denied"));
+    }
+
+    $history = &Horde_History::singleton();
+    return $history->getActionTimestamp('mnemo:' . $notepad . ':' . $uid, $action);
+}
+
+/**
+ * Import a memo represented in the specified contentType.
+ *
+ * @param string $content      The content of the memo.
+ * @param string $contentType  What format is the data in? Currently supports:
+ *                             text/plain
+ *                             text/x-vnote
+ * @param string $notepad      (optional) The notepad to save the memo on.
+ *
+ * @return string  The new UID, or false on failure.
+ */
+function _mnemo_import($content, $contentType, $notepad = null)
+{
+    global $prefs;
+    require_once dirname(__FILE__) . '/base.php';
+
+    /* Make sure we have a valid notepad and permissions to edit
+     * it. */
+    if (empty($notepad)) {
+        $notepad = Mnemo::getDefaultNotepad(Horde_Perms::EDIT);
+    }
+
+    if (!array_key_exists($notepad, Mnemo::listNotepads(false, Horde_Perms::EDIT))) {
+        return PEAR::raiseError(_("Permission Denied"));
+    }
+
+    /* Create a Mnemo_Driver instance. */
+    $storage = Mnemo_Driver::singleton($notepad);
+
+    switch ($contentType) {
+    case 'text/plain':
+        $noteId = $storage->add($storage->getMemoDescription($content), $content);
+        break;
+
+    case 'text/x-vnote':
+        if (!is_a($content, 'Horde_iCalendar_vnote')) {
+            require_once 'Horde/iCalendar.php';
+            $iCal = new Horde_iCalendar();
+            if (!$iCal->parsevCalendar($content)) {
+                return PEAR::raiseError(_("There was an error importing the iCalendar data."));
+            }
+
+            $components = $iCal->getComponents();
+            switch (count($components)) {
+            case 0:
+                return PEAR::raiseError(_("No iCalendar data was found."));
+
+            case 1:
+                $content = $components[0];
+                break;
+
+            default:
+                $ids = array();
+                foreach ($components as $content) {
+                    if (is_a($content, 'Horde_iCalendar_vnote')) {
+                        $note = $storage->fromiCalendar($content);
+                        $noteId = $storage->add($note['desc'],
+                                                $note['body'],
+                                                !empty($note['category']) ? $note['category'] : '');
+                        if (is_a($noteId, 'PEAR_Error')) {
+                            return $noteId;
+                        }
+                        $ids[] = $noteId;
+                    }
+                }
+                return $ids;
+            }
+        }
+
+        $note = $storage->fromiCalendar($content);
+        $noteId = $storage->add($note['desc'],
+                                $note['body'], !empty($note['category']) ? $note['category'] : '');
+        break;
+
+    default:
+        return PEAR::raiseError(sprintf(_("Unsupported Content-Type: %s"),$contentType));
+    }
+
+    if (is_a($noteId, 'PEAR_Error')) {
+        return $noteId;
+    }
+
+    $note = $storage->get($noteId);
+    return $note['uid'];
+}
+
+/**
+ * Export a memo, identified by UID, in the requested contentType.
+ *
+ * @param string $uid          Identify the memo to export.
+ * @param string $contentType  What format should the data be in?
+ *                             A string with one of:
+ *                             <pre>
+ *                               'text/plain'
+ *                               'text/x-vnote'
+ *                             </pre>
+ *
+ * @return string  The requested data or PEAR_Error.
+ */
+function _mnemo_export($uid, $contentType)
+{
+    require_once dirname(__FILE__) . '/base.php';
+
+    $storage = Mnemo_Driver::singleton();
+    $memo = $storage->getByUID($uid);
+    if (is_a($memo, 'PEAR_Error')) {
+        return $memo;
+    }
+
+    if (!array_key_exists($memo['memolist_id'], Mnemo::listNotepads(false, Horde_Perms::READ))) {
+        return PEAR::raiseError(_("Permission Denied"));
+    }
+
+    if (is_a($memo['body'], 'PEAR_Error')) {
+        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'];
+        }
+    }
+
+    switch ($contentType) {
+    case 'text/plain':
+        return $memo['body'];
+
+    case 'text/x-vnote':
+        require_once dirname(__FILE__) . '/version.php';
+        require_once 'Horde/iCalendar.php';
+
+        // 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('METHOD', 'PUBLISH');
+
+        // Create a new vNote.
+        $vNote = $storage->toiCalendar($memo, $iCal);
+        return $vNote->exportvCalendar();
+    }
+
+    return PEAR::raiseError(sprintf(_("Unsupported Content-Type: %s"),$contentType));
+}
+
+/**
+ * Delete a memo identified by UID.
+ *
+ * @param string | array $uid  Identify the note to delete, either a
+ *                             single UID or an array.
+ *
+ * @return boolean  Success or failure.
+ */
+function _mnemo_delete($uid)
+{
+    // Handle an arrray of UIDs for convenience of deleting multiple
+    // notes at once.
+    if (is_array($uid)) {
+        foreach ($uid as $u) {
+            $result = _mnemo_delete($u);
+            if (is_a($result, 'PEAR_Error')) {
+                return $result;
+            }
+        }
+
+        return true;
+    }
+
+    require_once dirname(__FILE__) . '/base.php';
+
+    $storage = Mnemo_Driver::singleton();
+    $memo = $storage->getByUID($uid);
+    if (is_a($memo, 'PEAR_Error')) {
+        return $memo;
+    }
+
+    if (!Horde_Auth::isAdmin() &&
+        !array_key_exists($memo['memolist_id'],
+                          Mnemo::listNotepads(false, Horde_Perms::DELETE))) {
+        return PEAR::raiseError(_("Permission Denied"));
+    }
+
+    return $storage->delete($memo['memo_id']);
+}
+
+/**
+ * Replace the memo identified by UID with the content represented in
+ * the specified contentType.
+ *
+ * @param string $uid         Idenfity the memo to replace.
+ * @param string $content      The content of the memo.
+ * @param string $contentType  What format is the data in? Currently supports:
+ *                             text/plain
+ *                             text/x-vnote
+ *
+ * @return boolean  Success or failure.
+ */
+function _mnemo_replace($uid, $content, $contentType)
+{
+    require_once dirname(__FILE__) . '/base.php';
+
+    $storage = Mnemo_Driver::singleton();
+    $memo = $storage->getByUID($uid);
+    if (is_a($memo, 'PEAR_Error')) {
+        return $memo;
+    }
+
+    if (!array_key_exists($memo['memolist_id'], Mnemo::listNotepads(false, Horde_Perms::EDIT))) {
+        return PEAR::raiseError(_("Permission Denied"));
+    }
+
+    switch ($contentType) {
+    case 'text/plain':
+        return $storage->modify($memo['memo_id'], $storage->getMemoDescription($content), $content, null);
+
+    case 'text/x-vnote':
+        if (!is_a($content, 'Horde_iCalendar_vnote')) {
+            require_once 'Horde/iCalendar.php';
+            $iCal = new Horde_iCalendar();
+            if (!$iCal->parsevCalendar($content)) {
+                return PEAR::raiseError(_("There was an error importing the iCalendar data."));
+            }
+
+            $components = $iCal->getComponents();
+            switch (count($components)) {
+            case 0:
+                return PEAR::raiseError(_("No iCalendar data was found."));
+
+            case 1:
+                $content = $components[0];
+                break;
+
+            default:
+                return PEAR::raiseError(_("Multiple iCalendar components found; only one vNote is supported."));
+            }
+        }
+        $note = $storage->fromiCalendar($content);
+
+        return $storage->modify($memo['memo_id'], $note['desc'],
+                                $note['body'],!empty($note['category']) ? $note['category'] : '');
+
+    default:
+        return PEAR::raiseError(sprintf(_("Unsupported Content-Type: %s"),$contentType));
+    }
+}
diff --git a/mnemo/lib/Application.php b/mnemo/lib/Application.php
new file mode 100644 (file)
index 0000000..6378663
--- /dev/null
@@ -0,0 +1,78 @@
+<?php
+/**
+ * Mnemo application API.
+ *
+ * This file defines Horde's core API interface. Other core Horde libraries
+ * can interact with Mnemo through this API.
+ *
+ * Copyright 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.
+ *
+ * @package Mnemo
+ */
+
+/* Determine the base directories. */
+if (!defined('MNEMO_BASE')) {
+    define('MNEMO_BASE', dirname(__FILE__) . '/..');
+}
+
+if (!defined('HORDE_BASE')) {
+    /* If Horde does not live directly under the app directory, the HORDE_BASE
+     * constant should be defined in config/horde.local.php. */
+    if (file_exists(MNEMO_BASE . '/config/horde.local.php')) {
+        include MNEMO_BASE . '/config/horde.local.php';
+    } else {
+        define('HORDE_BASE', MNEMO_BASE . '/..');
+    }
+}
+
+/* Load the Horde Framework core (needed to autoload
+ * Horde_Registry_Application::). */
+require_once HORDE_BASE . '/lib/core.php';
+
+class Mnemo_Application extends Horde_Registry_Application
+{
+    /**
+     * The application's version.
+     *
+     * @var string
+     */
+    public $version = 'H4 (3.0-git)';
+    
+    /**
+     * Initialization function.
+     * 
+     * Global variables defined:
+     *   $mnemo_shares - TODO
+     */
+    protected function _init()
+    {
+       // Set the timezone variable.
+       Horde_Nls::setTimeZone();
+       
+       // Create a share instance.
+       $GLOBALS['mnemo_shares'] = Horde_Share::singleton($GLOBALS['registry']->getApp());
+       
+       Mnemo::initialize();
+    }
+    
+    /**
+     * Generate the menu to use on the prefs page.
+     *
+     * @return Horde_Menu  A Horde_Menu object.
+     */
+    public function prefsMenu()
+    {
+        return Mnemo::getMenu();
+    }
+
+}
+
+// Mnemo libraries.
+require_once MNEMO_BASE . '/lib/Mnemo.php';
+require_once MNEMO_BASE . '/lib/Driver.php';
+
+// Start compression, if requested.
+Horde::compressOutput();
index cd935fd..1fe33da 100644 (file)
@@ -16,13 +16,17 @@ class Horde_Block_Mnemo_summary extends Horde_Block {
     function _title()
     {
         global $registry;
-        return Horde::link(Horde::url($registry->getInitialPage(), true)) .
-            htmlspecialchars($registry->get('name')) . '</a>';
+       
+       $label = !empty($this->_params['block_title'])
+            ? $this->_params['block_title']
+            : $registry->get('name');
+        return Horde::link(Horde::applicationUrl($registry->getInitialPage(),
+                                                true))
+            . htmlspecialchars($label) . '</a>';
     }
 
     function _params()
     {
-        require_once dirname(__FILE__) . '/../base.php';
         $cManager = new Horde_Prefs_CategoryManager();
         $categories = array();
         foreach ($cManager->get() as $c) {
@@ -46,8 +50,7 @@ class Horde_Block_Mnemo_summary extends Horde_Block {
 
     function _content()
     {
-        require_once dirname(__FILE__) . '/../base.php';
-        global $prefs;
+        global $registry, $prefs;
 
         $cManager = new Horde_Prefs_CategoryManager();
         $colors = $cManager->colors();
index c74b957..eacaac6 100644 (file)
@@ -14,29 +14,34 @@ class Horde_Block_mnemo_tree_menu extends Horde_Block {
 
     function _buildTree(&$tree, $indent = 0, $parent = null)
     {
-        require_once dirname(__FILE__) . '/../base.php';
-
         global $registry;
 
+        $add = Horde::applicationUrl('memo.php')->add('actionID', 'add_memo');
+       $icondir = (string)Horde_Themes::img();
+
         $tree->addNode($parent . '__new',
                        $parent,
                        _("New Note"),
                        $indent + 1,
                        false,
                        array('icon' => 'add.png',
-                             'icondir' => $registry->getImageDir(),
-                             'url' => Horde::applicationUrl('memo.php?actionID=add_memo')));
+                             'icondir' => $icondir,
+                             'url' => $add));
 
         foreach (Mnemo::listNotepads() as $name => $notepad) {
+           if ($notepad->get('owner') != Horde_Auth::getAuth() &&
+               !empty($GLOBALS['conf']['share']['hidden']) &&
+               !in_array($notepad->getName(), $GLOBALS['display_notepads'])) {
+               continue;
+           }
             $tree->addNode($parent . $name . '__new',
                            $parent . '__new',
                            sprintf(_("in %s"), $notepad->get('name')),
                            $indent + 2,
                            false,
                            array('icon' => 'add.png',
-                                 'icondir' => $registry->getImageDir(),
-                                 'url' => Horde_Util::addParameter(Horde::applicationUrl('memo.php?memolist=' . urlencode($name)),
-                                                             'actionID', 'add_memo')));
+                                 'icondir' => $icondir,
+                                 'url' => Horde_Util::addParameter($add, array('memolist' => $name))));
         }
 
         $tree->addNode($parent . '__search',
@@ -45,7 +50,7 @@ class Horde_Block_mnemo_tree_menu extends Horde_Block {
                        $indent + 1,
                        false,
                        array('icon' => 'search.png',
-                             'icondir' => $registry->getImageDir('horde'),
+                             'icondir' => (string)Horde_Themes::img(null, 'horde'),
                              'url' => Horde::applicationUrl('search.php')));
     }
 
index 18ee133..33203a0 100644 (file)
@@ -156,8 +156,7 @@ class Mnemo_Driver_sql extends Mnemo_Driver {
         $values = array($this->_notepad, $noteId);
 
         /* Log the query at a DEBUG log level. */
-        Horde::logMessage(sprintf('Mnemo_Driver_sql::get(): %s', $query),
-                          __FILE__, __LINE__, PEAR_LOG_DEBUG);
+        Horde::logMessage(sprintf('Mnemo_Driver_sql::get(): %s', $query), 'DEBUG');
 
         /* Execute the query. */
         $row = $this->_db->getRow($query, $values, DB_FETCHMODE_ASSOC);
@@ -186,8 +185,7 @@ class Mnemo_Driver_sql extends Mnemo_Driver {
         $values = array($uid);
 
         /* Log the query at a DEBUG log level. */
-        Horde::logMessage(sprintf('Mnemo_Driver_sql::getByUID(): %s', $query),
-                          __FILE__, __LINE__, PEAR_LOG_DEBUG);
+        Horde::logMessage(sprintf('Mnemo_Driver_sql::getByUID(): %s', $query), 'DEBUG');
 
         /* Execute the query. */
         $row = $this->_db->getRow($query, $values, DB_FETCHMODE_ASSOC);
@@ -241,15 +239,14 @@ class Mnemo_Driver_sql extends Mnemo_Driver {
                         Horde_String::convertCharset($uid, Horde_Nls::getCharset(), $this->_params['charset']));
 
         /* Log the query at a DEBUG log level. */
-        Horde::logMessage(sprintf('Mnemo_Driver_sql::add(): %s', $query),
-                          __FILE__, __LINE__, PEAR_LOG_DEBUG);
+        Horde::logMessage(sprintf('Mnemo_Driver_sql::add(): %s', $query), 'DEBUG');
 
         /* Attempt the insertion query. */
         $result = $this->_write_db->query($query, $values);
 
         /* Return an error immediately if the query failed. */
         if (is_a($result, 'PEAR_Error')) {
-            Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
+            Horde::logMessage($result, 'ERR');
             return $result;
         }
 
@@ -293,14 +290,13 @@ class Mnemo_Driver_sql extends Mnemo_Driver {
         array_push($values, $this->_notepad, $noteId);
 
         /* Log the query at a DEBUG log level. */
-        Horde::logMessage(sprintf('Mnemo_Driver_sql::modify(): %s', $query),
-                          __FILE__, __LINE__, PEAR_LOG_DEBUG);
+        Horde::logMessage(sprintf('Mnemo_Driver_sql::modify(): %s', $query), 'DEBUG');
 
         /* Attempt the update query. */
         $result = $this->_write_db->query($query, $values);
 
         if (is_a($result, 'PEAR_Error')) {
-            Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
+            Horde::logMessage($result, 'ERR');
             return $result;
         }
 
@@ -331,13 +327,12 @@ class Mnemo_Driver_sql extends Mnemo_Driver {
         $values = array($newNotepad, $this->_notepad, $noteId);
 
         /* Log the query at a DEBUG log level. */
-        Horde::logMessage(sprintf('Mnemo_Driver_sql::move(): %s', $query),
-                          __FILE__, __LINE__, PEAR_LOG_DEBUG);
+        Horde::logMessage(sprintf('Mnemo_Driver_sql::move(): %s', $query), 'DEBUG');
 
         /* Attempt the move query. */
         $result = $this->_write_db->query($query, $values);
         if (is_a($result, 'PEAR_Error')) {
-            Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
+            Horde::logMessage($result, 'ERR');
             return $result;
         }
 
@@ -361,14 +356,13 @@ class Mnemo_Driver_sql extends Mnemo_Driver {
         $values = array($this->_notepad, $noteId);
 
         /* Log the query at a DEBUG log level. */
-        Horde::logMessage(sprintf('Mnemo_Driver_sql::delete(): %s', $query),
-                          __FILE__, __LINE__, PEAR_LOG_DEBUG);
+        Horde::logMessage(sprintf('Mnemo_Driver_sql::delete(): %s', $query), 'DEBUG');
 
         /* Attempt the delete query. */
         $result = $this->_write_db->query($query, $values);
 
         if (is_a($result, 'PEAR_Error')) {
-            Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
+            Horde::logMessage($result, 'ERR');
             return $result;
         }
 
@@ -383,13 +377,12 @@ class Mnemo_Driver_sql extends Mnemo_Driver {
 
     function deleteAll()
     {
-        $query = 'DELETE FROM ' . $this->_params['table'] .
-                 ' WHERE memo_owner = ?';
+        $query = sprintf('DELETE FROM %s WHERE memo_owner = ?',
+                        $this->_params['table']);
         $values = array($this->_notepad);
 
         /* Log the query at a DEBUG log level. */
-        Horde::logMessage(sprintf('Mnemo_Driver_sql::deleteAll(): %s', $query),
-                          __FILE__, __LINE__, PEAR_LOG_DEBUG);
+        Horde::logMessage(sprintf('Mnemo_Driver_sql::deleteAll(): %s', $query), 'DEBUG');
 
         /* Attempt the delete query. */
         $result = $this->_write_db->query($query, $values);
@@ -406,16 +399,16 @@ class Mnemo_Driver_sql extends Mnemo_Driver {
     function retrieve()
     {
         /* Build the SQL query. */
-        $query = 'SELECT * FROM ' . $this->_params['table'] .
-                 ' WHERE memo_owner = ?';
+        $query = sprintf('SELECT * FROM %s WHERE memo_owner = ?',
+                        $this->_params['table']);
         $values = array($this->_notepad);
 
         /* Log the query at a DEBUG log level. */
-        Horde::logMessage(sprintf('Mnemo_Driver_sql::retrieve(): %s', $query),
-                          __FILE__, __LINE__, PEAR_LOG_DEBUG);
+        Horde::logMessage(sprintf('Mnemo_Driver_sql::retrieve(): %s', $query), 'DEBUG');
 
         /* Execute the query. */
         $result = $this->_db->query($query, $values);
+
         if (is_a($result, 'PEAR_Error')) {
             return $result;
         }
@@ -444,8 +437,7 @@ class Mnemo_Driver_sql extends Mnemo_Driver {
             $values = array($row['memo_uid'], $row['memo_owner'], $row['memo_id']);
 
             /* Log the query at a DEBUG log level. */
-            Horde::logMessage(sprintf('Mnemo_Driver_sql adding missing UID: %s', $query),
-                              __FILE__, __LINE__, PEAR_LOG_DEBUG);
+            Horde::logMessage(sprintf('Mnemo_Driver_sql adding missing UID: %s', $query), 'DEBUG');
             $this->_write_db->query($query, $values);
         }
 
index ac82075..51e9a00 100644 (file)
@@ -67,7 +67,7 @@ class Mnemo {
      *
      * @see Mnemo_Driver::listMemos()
      */
-    function listMemos($sortby = MNEMO_SORT_DESC,
+    public static function listMemos($sortby = MNEMO_SORT_DESC,
                        $sortdir = MNEMO_SORT_ASCEND)
     {
         global $conf, $display_notepads;
@@ -169,17 +169,15 @@ class Mnemo {
      *
      * @return array  The memo lists.
      */
-    function listNotepads($owneronly = false, $permission = Horde_Perms::SHOW)
+    public static function listNotepads($owneronly = false, $permission = Horde_Perms::SHOW)
     {
         if ($owneronly && !Horde_Auth::getAuth()) {
             return array();
         }
-
         $notepads = $GLOBALS['mnemo_shares']->listShares(Horde_Auth::getAuth(), $permission, $owneronly ? Horde_Auth::getAuth() : null, 0, 0, 'name');
         if (is_a($notepads, 'PEAR_Error')) {
-            Horde::logMessage($notepads, __FILE__, __LINE__, PEAR_LOG_ERR);
-            $empty = array();
-            return $empty;
+            Horde::logMessage($notepads, 'ERR');
+            return array();
         }
 
         return $notepads;
@@ -189,7 +187,7 @@ class Mnemo {
      * Returns the default notepad for the current user at the specified
      * permissions level.
      */
-    function getDefaultNotepad($permission = Horde_Perms::SHOW)
+    public static function getDefaultNotepad($permission = Horde_Perms::SHOW)
     {
         global $prefs;
 
@@ -199,8 +197,9 @@ class Mnemo {
         if (isset($notepads[$default_notepad])) {
             return $default_notepad;
         } elseif ($prefs->isLocked('default_notepad')) {
-            return '';
+            return Horde_Auth::getAuth();
         } elseif (count($notepads)) {
+           reset($notepads);
             return key($notepads);
         }
 
@@ -401,7 +400,7 @@ class Mnemo {
     /**
      * Initial app setup code.
      */
-    function initialize()
+    public static function initialize()
     {
         // Update the preference for which notepads to display. If the
         // user doesn't have any selected notepads for view then fall
@@ -467,37 +466,34 @@ class Mnemo {
     /**
      * Builds Mnemo's list of menu items.
      */
-    function getMenu($returnType = 'object')
+    public static function getMenu()
     {
         global $conf, $registry, $print_link;
 
         $menu = new Horde_Menu();
         $menu->add(Horde::applicationUrl('list.php'), _("_List Notes"), 'mnemo.png', null, null, null, basename($_SERVER['PHP_SELF']) == 'index.php' ? 'current' : null);
+
         if (Mnemo::getDefaultNotepad(Horde_Perms::EDIT) &&
             (!empty($conf['hooks']['permsdenied']) ||
-             Mnemo::hasPermission('max_notes') === true ||
-             Mnemo::hasPermission('max_notes') > Mnemo::countMemos())) {
-            $menu->add(Horde::applicationUrl('memo.php?actionID=add_memo'), _("_New Note"), 'add.png', null, null, null, Horde_Util::getFormData('memo') ? '__noselection' : null);
+             $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_notes') === true ||
+             $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_notes') > Mnemo::countMemos())) {
+            $menu->add(Horde::applicationUrl(Horde_Util::addParameter('memo.php', 'actionID', 'add_memo')), _("_New Note"), 'add.png', null, null, null, Horde_Util::getFormData('memo') ? '__noselection' : null);
         }
 
         /* Search. */
-        $menu->add(Horde::applicationUrl('search.php'), _("_Search"), 'search.png', $registry->getImageDir('horde'));
+        $menu->add(Horde::applicationUrl('search.php'), _("_Search"), 'search.png', Horde_Themes::img(null, 'horde'));
 
         /* Import/Export */
         if ($conf['menu']['import_export']) {
-            $menu->add(Horde::applicationUrl('data.php'), _("_Import/Export"), 'data.png', $registry->getImageDir('horde'));
+            $menu->add(Horde::applicationUrl('data.php'), _("_Import/Export"), 'data.png', Horde_Themes::img(null, 'horde'));
         }
 
         /* Print */
         if ($conf['menu']['print'] && isset($print_link)) {
-            $menu->add($print_link, _("_Print"), 'print.png', $registry->getImageDir('horde'), '_blank', 'popup(this.href); return false;');
+            $menu->add(Horde::applicationUrl($print_link), _("_Print"), 'print.png', Horde_Themes::img(null, 'horde'), '_blank', 'popup(this.href); return false;');
         }
 
-        if ($returnType == 'object') {
             return $menu;
-        } else {
-            return $menu->render();
-        }
     }
 
 }
diff --git a/mnemo/lib/api.php b/mnemo/lib/api.php
deleted file mode 100644 (file)
index 413eec4..0000000
+++ /dev/null
@@ -1,535 +0,0 @@
-<?php
-/**
- * Mnemo external API interface.
- *
- * This file defines Mnemo's external API interface.  Other applications can
- * interact with Mnemo through this API.
- *
- * $Horde: mnemo/lib/api.php,v 1.99 2009/11/24 04:13:44 chuck Exp $
- *
- * Copyright 2001-2009 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file LICENSE for license information (ASL). If you
- * did not receive this file, see http://www.horde.org/licenses/asl.php.
- *
- * @since   Mnemo 1.0
- * @package Mnemo
- */
-
-$_services['perms'] = array(
-    'args' => array(),
-    'type' => '{urn:horde}stringArray'
-);
-
-$_services['removeUserData'] = array(
-    'args' => array('user' => 'string'),
-    'type' => 'boolean'
-);
-
-$_services['show'] = array(
-    'link' => '%application%/view.php?memolist=|notepad|&memo=|note|&uid=|uid|',
-);
-
-$_services['listNotepads'] = array(
-    'args' => array('owneronly' => 'boolean', 'permission' => 'int'),
-    'type' => '{urn:horde}stringArray',
-);
-
-$_services['list'] = array(
-    'args' => array(),
-    'type' => '{urn:horde}stringArray'
-);
-
-$_services['listBy'] = array(
-    'args' => array('action' => 'string', 'timestamp' => 'int'),
-    'type' => '{urn:horde}stringArray'
-);
-
-$_services['getActionTimestamp'] = array(
-    'args' => array('uid' => 'string', 'action' => 'string', 'notepad' => 'string'),
-    'type' => 'int',
-);
-
-$_services['import'] = array(
-    'args' => array('content' => 'string', 'contentType' => 'string'),
-    'type' => 'string'
-);
-
-$_services['export'] = array(
-    'args' => array('uid' => 'string', 'contentType' => 'string'),
-    'type' => 'string'
-);
-
-$_services['delete'] = array(
-    'args' => array('uid' => 'string'),
-    'type' => 'boolean'
-);
-
-$_services['replace'] = array(
-    'args' => array('uid' => 'string', 'content' => 'string', 'contentType' => 'string'),
-    'type' => 'boolean'
-);
-
-/**
- * Returns a list of available permissions.
- *
- * @return array  An array describing all available permissions.
- */
-function _mnemo_perms()
-{
-    $perms = array();
-    $perms['tree']['mnemo']['max_notes'] = false;
-    $perms['title']['mnemo:max_notes'] = _("Maximum Number of Notes");
-    $perms['type']['mnemo:max_notes'] = 'int';
-
-    return $perms;
-}
-
-/**
- * Removes user data.
- *
- * @param string $user  Name of user to remove data for.
- *
- * @return mixed  true on success | PEAR_Error on failure
- */
-function _mnemo_removeUserData($user)
-{
-    require_once dirname(__FILE__) . '/base.php';
-
-    if (!Horde_Auth::isAdmin() && $user != Horde_Auth::getAuth()) {
-        return PEAR::raiseError(_("You are not allowed to remove user data."));
-    }
-
-    /* Error flag */
-    $hasError = false;
-
-    /* Get the share object for later deletion */
-    $share = $GLOBALS['mnemo_shares']->getShare($user);
-    if (is_a($share, 'PEAR_Error')) {
-        Horde::logMessage($share->getMessage(), __FILE__, __LINE__, PEAR_LOG_ERR);
-        unset($share);
-    } else {
-        $GLOBALS['display_notepads'] = array($user);
-        $memos = Mnemo::listMemos();
-        if (is_a($memos, 'PEAR_Error')) {
-            $hasError = true;
-            Horde::logMessage($mnemos->getMessage(), __FILE__, __LINE__, PEAR_LOG_ERR);
-        } else {
-            $uids = array();
-            foreach ($memos as $memo) {
-                $uids[] = $memo['uid'];
-            }
-
-            /* ... and delete them. */
-            foreach ($uids as $uid) {
-                _mnemo_delete($uid);
-            }
-        }
-
-        /* Now delete history as well. */
-        $history = &Horde_History::singleton();
-        if (method_exists($history, 'removeByParent')) {
-            $histories = $history->removeByParent('mnemo:' . $user);
-        } else {
-            /* Remove entries 100 at a time. */
-            $all = $history->getByTimestamp('>', 0, array(), 'mnemo:' . $user);
-            if (is_a($all, 'PEAR_Error')) {
-                Horde::logMessage($all, __FILE__, __LINE__, PEAR_LOG_ERR);
-            } else {
-                $all = array_keys($all);
-                while (count($d = array_splice($all, 0, 100)) > 0) {
-                    $history->removebyNames($d);
-                }
-            }
-        }
-
-        /* Remove the share itself */
-        if (!empty($share)) {
-            $result = $GLOBALS['mnemo_shares']->removeShare($share);
-            if (is_a($result, 'PEAR_Error')) {
-                $hasError = true;
-                Horde::logMessage($result->getMessage(), __FILE__, __LINE__, PEAR_LOG_ERR);
-            }
-        }
-
-        /* Get a list of all shares this user has perms to and remove the perms */
-        $shares = $GLOBALS['mnemo_shares']->listShares($user);
-        if (is_a($shares, 'PEAR_Error')) {
-            $hasError = true;
-            Horde::logMessage($shares, __FILE__, __LINE__, PEAR_LOG_ERR);
-        } else {
-            foreach ($shares as $share) {
-                $share->removeUser($user);
-            }
-        }
-    }
-
-    if ($hasError) {
-        return PEAR::raiseError(sprintf(_("There was an error removing notes for %s. Details have been logged."), $user));
-    } else {
-        return true;
-    }
-}
-
-/**
- * @param boolean $owneronly   Only return notepads that this user owns?
- *                             Defaults to false.
- * @param integer $permission  The permission to filter notepads by.
- *
- * @return array  The notepads.
- */
-function _mnemo_listNotepads($owneronly, $permission)
-{
-    require_once dirname(__FILE__) . '/base.php';
-
-    return Mnemo::listNotepads($owneronly, $permission);
-}
-
-/**
- * Returns an array of UIDs for all notes that the current user is authorized
- * to see.
- *
- * @param string $notepad  The notepad to list notes from.
- *
- * @return array  An array of UIDs for all notes the user can access.
- */
-function _mnemo_list($notepad = null)
-{
-    require_once dirname(__FILE__) . '/base.php';
-    global $conf;
-
-    if (!isset($conf['storage']['driver'])) {
-        return PEAR::raiseError('Not configured');
-    }
-
-    /* Make sure we have a valid notepad. */
-    if (empty($notepad)) {
-        $notepad = Mnemo::getDefaultNotepad();
-    }
-
-    if (!array_key_exists($notepad,
-                          Mnemo::listNotepads(false, Horde_Perms::READ))) {
-        return PEAR::raiseError(_("Permission Denied"));
-    }
-
-    /* Set notepad for listMemos. */
-    $GLOBALS['display_notepads'] = array($notepad);
-
-    $memos = Mnemo::listMemos();
-    if (is_a($memos, 'PEAR_Error')) {
-        return $memos;
-    }
-
-    $uids = array();
-    foreach ($memos as $memo) {
-        $uids[] = $memo['uid'];
-    }
-
-    return $uids;
-}
-
-/**
- * Returns an array of UIDs for notes that have had $action happen since
- * $timestamp.
- *
- * @param string  $action     The action to check for - add, modify, or delete.
- * @param integer $timestamp  The time to start the search.
- * @param string  $notepad    The notepad to search in.
- *
- * @return array  An array of UIDs matching the action and time criteria.
- */
-function _mnemo_listBy($action, $timestamp, $notepad = null)
-{
-    require_once dirname(__FILE__) . '/base.php';
-
-    /* Make sure we have a valid notepad. */
-    if (empty($notepad)) {
-        $notepad = Mnemo::getDefaultNotepad();
-    }
-
-    if (!array_key_exists($notepad,
-                          Mnemo::listNotepads(false, Horde_Perms::READ))) {
-        return PEAR::raiseError(_("Permission Denied"));
-    }
-
-    $history = &Horde_History::singleton();
-    $histories = $history->getByTimestamp('>', $timestamp, array(array('op' => '=', 'field' => 'action', 'value' => $action)), 'mnemo:' . $notepad);
-    if (is_a($histories, 'PEAR_Error')) {
-        return $histories;
-    }
-
-    // Strip leading mnemo:username:.
-    return preg_replace('/^([^:]*:){2}/', '', array_keys($histories));
-}
-
-/**
- * Returns the timestamp of an operation for a given uid an action.
- *
- * @param string $uid     The uid to look for.
- * @param string $action  The action to check for - add, modify, or delete.
- * @param string $notepad The notepad to search in.
- *
- * @return integer  The timestamp for this action.
- */
-function _mnemo_getActionTimestamp($uid, $action, $notepad = null)
-{
-    require_once dirname(__FILE__) . '/base.php';
-
-    /* Make sure we have a valid notepad. */
-    if (empty($notepad)) {
-        $notepad = Mnemo::getDefaultNotepad();
-    }
-
-    if (!array_key_exists($notepad,
-                          Mnemo::listNotepads(false, Horde_Perms::READ))) {
-        return PEAR::raiseError(_("Permission Denied"));
-    }
-
-    $history = &Horde_History::singleton();
-    return $history->getActionTimestamp('mnemo:' . $notepad . ':' . $uid, $action);
-}
-
-/**
- * Import a memo represented in the specified contentType.
- *
- * @param string $content      The content of the memo.
- * @param string $contentType  What format is the data in? Currently supports:
- *                             text/plain
- *                             text/x-vnote
- * @param string $notepad      (optional) The notepad to save the memo on.
- *
- * @return string  The new UID, or false on failure.
- */
-function _mnemo_import($content, $contentType, $notepad = null)
-{
-    global $prefs;
-    require_once dirname(__FILE__) . '/base.php';
-
-    /* Make sure we have a valid notepad and permissions to edit
-     * it. */
-    if (empty($notepad)) {
-        $notepad = Mnemo::getDefaultNotepad(Horde_Perms::EDIT);
-    }
-
-    if (!array_key_exists($notepad, Mnemo::listNotepads(false, Horde_Perms::EDIT))) {
-        return PEAR::raiseError(_("Permission Denied"));
-    }
-
-    /* Create a Mnemo_Driver instance. */
-    $storage = Mnemo_Driver::singleton($notepad);
-
-    switch ($contentType) {
-    case 'text/plain':
-        $noteId = $storage->add($storage->getMemoDescription($content), $content);
-        break;
-
-    case 'text/x-vnote':
-        if (!is_a($content, 'Horde_iCalendar_vnote')) {
-            require_once 'Horde/iCalendar.php';
-            $iCal = new Horde_iCalendar();
-            if (!$iCal->parsevCalendar($content)) {
-                return PEAR::raiseError(_("There was an error importing the iCalendar data."));
-            }
-
-            $components = $iCal->getComponents();
-            switch (count($components)) {
-            case 0:
-                return PEAR::raiseError(_("No iCalendar data was found."));
-
-            case 1:
-                $content = $components[0];
-                break;
-
-            default:
-                $ids = array();
-                foreach ($components as $content) {
-                    if (is_a($content, 'Horde_iCalendar_vnote')) {
-                        $note = $storage->fromiCalendar($content);
-                        $noteId = $storage->add($note['desc'],
-                                                $note['body'],
-                                                !empty($note['category']) ? $note['category'] : '');
-                        if (is_a($noteId, 'PEAR_Error')) {
-                            return $noteId;
-                        }
-                        $ids[] = $noteId;
-                    }
-                }
-                return $ids;
-            }
-        }
-
-        $note = $storage->fromiCalendar($content);
-        $noteId = $storage->add($note['desc'],
-                                $note['body'], !empty($note['category']) ? $note['category'] : '');
-        break;
-
-    default:
-        return PEAR::raiseError(sprintf(_("Unsupported Content-Type: %s"),$contentType));
-    }
-
-    if (is_a($noteId, 'PEAR_Error')) {
-        return $noteId;
-    }
-
-    $note = $storage->get($noteId);
-    return $note['uid'];
-}
-
-/**
- * Export a memo, identified by UID, in the requested contentType.
- *
- * @param string $uid          Identify the memo to export.
- * @param string $contentType  What format should the data be in?
- *                             A string with one of:
- *                             <pre>
- *                               'text/plain'
- *                               'text/x-vnote'
- *                             </pre>
- *
- * @return string  The requested data or PEAR_Error.
- */
-function _mnemo_export($uid, $contentType)
-{
-    require_once dirname(__FILE__) . '/base.php';
-
-    $storage = Mnemo_Driver::singleton();
-    $memo = $storage->getByUID($uid);
-    if (is_a($memo, 'PEAR_Error')) {
-        return $memo;
-    }
-
-    if (!array_key_exists($memo['memolist_id'], Mnemo::listNotepads(false, Horde_Perms::READ))) {
-        return PEAR::raiseError(_("Permission Denied"));
-    }
-
-    if (is_a($memo['body'], 'PEAR_Error')) {
-        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'];
-        }
-    }
-
-    switch ($contentType) {
-    case 'text/plain':
-        return $memo['body'];
-
-    case 'text/x-vnote':
-        require_once dirname(__FILE__) . '/version.php';
-        require_once 'Horde/iCalendar.php';
-
-        // 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('METHOD', 'PUBLISH');
-
-        // Create a new vNote.
-        $vNote = $storage->toiCalendar($memo, $iCal);
-        return $vNote->exportvCalendar();
-    }
-
-    return PEAR::raiseError(sprintf(_("Unsupported Content-Type: %s"),$contentType));
-}
-
-/**
- * Delete a memo identified by UID.
- *
- * @param string | array $uid  Identify the note to delete, either a
- *                             single UID or an array.
- *
- * @return boolean  Success or failure.
- */
-function _mnemo_delete($uid)
-{
-    // Handle an arrray of UIDs for convenience of deleting multiple
-    // notes at once.
-    if (is_array($uid)) {
-        foreach ($uid as $u) {
-            $result = _mnemo_delete($u);
-            if (is_a($result, 'PEAR_Error')) {
-                return $result;
-            }
-        }
-
-        return true;
-    }
-
-    require_once dirname(__FILE__) . '/base.php';
-
-    $storage = Mnemo_Driver::singleton();
-    $memo = $storage->getByUID($uid);
-    if (is_a($memo, 'PEAR_Error')) {
-        return $memo;
-    }
-
-    if (!Horde_Auth::isAdmin() &&
-        !array_key_exists($memo['memolist_id'],
-                          Mnemo::listNotepads(false, Horde_Perms::DELETE))) {
-        return PEAR::raiseError(_("Permission Denied"));
-    }
-
-    return $storage->delete($memo['memo_id']);
-}
-
-/**
- * Replace the memo identified by UID with the content represented in
- * the specified contentType.
- *
- * @param string $uid         Idenfity the memo to replace.
- * @param string $content      The content of the memo.
- * @param string $contentType  What format is the data in? Currently supports:
- *                             text/plain
- *                             text/x-vnote
- *
- * @return boolean  Success or failure.
- */
-function _mnemo_replace($uid, $content, $contentType)
-{
-    require_once dirname(__FILE__) . '/base.php';
-
-    $storage = Mnemo_Driver::singleton();
-    $memo = $storage->getByUID($uid);
-    if (is_a($memo, 'PEAR_Error')) {
-        return $memo;
-    }
-
-    if (!array_key_exists($memo['memolist_id'], Mnemo::listNotepads(false, Horde_Perms::EDIT))) {
-        return PEAR::raiseError(_("Permission Denied"));
-    }
-
-    switch ($contentType) {
-    case 'text/plain':
-        return $storage->modify($memo['memo_id'], $storage->getMemoDescription($content), $content, null);
-
-    case 'text/x-vnote':
-        if (!is_a($content, 'Horde_iCalendar_vnote')) {
-            require_once 'Horde/iCalendar.php';
-            $iCal = new Horde_iCalendar();
-            if (!$iCal->parsevCalendar($content)) {
-                return PEAR::raiseError(_("There was an error importing the iCalendar data."));
-            }
-
-            $components = $iCal->getComponents();
-            switch (count($components)) {
-            case 0:
-                return PEAR::raiseError(_("No iCalendar data was found."));
-
-            case 1:
-                $content = $components[0];
-                break;
-
-            default:
-                return PEAR::raiseError(_("Multiple iCalendar components found; only one vNote is supported."));
-            }
-        }
-        $note = $storage->fromiCalendar($content);
-
-        return $storage->modify($memo['memo_id'], $note['desc'],
-                                $note['body'],!empty($note['category']) ? $note['category'] : '');
-
-    default:
-        return PEAR::raiseError(sprintf(_("Unsupported Content-Type: %s"),$contentType));
-    }
-}
diff --git a/mnemo/lib/base.php b/mnemo/lib/base.php
deleted file mode 100644 (file)
index 9d1dfda..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-<?php
-/**
- * Mnemo base inclusion file.
- *
- * This file brings in all of the dependencies that every Mnemo
- * script will need and sets up objects that all scripts use.
- *
- * $Horde: mnemo/lib/base.php,v 1.66 2009/07/13 20:05:53 slusarz Exp $
- *
- * Copyright 2001-2009 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file LICENSE for license information (ASL). If you
- * did not receive this file, see http://www.horde.org/licenses/asl.php.
- *
- * @since   Mnemo 1.0
- * @package Mnemo
- */
-
-// Check for a prior definition of HORDE_BASE (perhaps by an
-// auto_prepend_file definition for site customization).
-if (!defined('HORDE_BASE')) {
-    define('HORDE_BASE', dirname(__FILE__) . '/../..');
-}
-
-// Load the Horde Framework core, and set up inclusion paths.
-require_once HORDE_BASE . '/lib/core.php';
-
-// Registry.
-$registry = Horde_Registry::singleton();
-try {
-    $registry->pushApp('mnemo', !defined('AUTH_HANDLER'));
-} catch (Horde_Exception $e) {
-    if ($e->getCode() == 'permission_denied') {
-        Horde::authenticationFailureRedirect();
-    }
-    Horde::fatal($e, __FILE__, __LINE__, false);
-}
-$conf = &$GLOBALS['conf'];
-define('MNEMO_TEMPLATES', $registry->get('templates'));
-
-// Notification system.
-$notification = &Horde_Notification::singleton();
-$notification->attach('status');
-
-// Find the base file path of Mnemo.
-if (!defined('MNEMO_BASE')) {
-    define('MNEMO_BASE', dirname(__FILE__) . '/..');
-}
-
-// Mnemo libraries.
-require_once MNEMO_BASE . '/lib/Mnemo.php';
-require_once MNEMO_BASE . '/lib/Driver.php';
-
-// Start compression, if requested.
-Horde::compressOutput();
-
-// Create a share instance.
-require_once 'Horde/Share.php';
-$GLOBALS['mnemo_shares'] = &Horde_Share::singleton($registry->getApp());
-
-Mnemo::initialize();
diff --git a/mnemo/lib/prefs.php b/mnemo/lib/prefs.php
deleted file mode 100644 (file)
index 8b8bb67..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?php
-/**
- * $Horde: mnemo/lib/prefs.php,v 1.13 2009/06/10 05:25:02 slusarz Exp $
- *
- * Copyright 2002-2009 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file LICENSE for license information (ASL). If you
- * did not receive this file, see http://www.horde.org/licenses/asl.php.
- *
- * @author  Chuck Hagenbuch <chuck@horde.org>
- * @since   Mnemo 2.0
- * @package Mnemo
- */
-
-function handle_notepadselect($updated)
-{
-    global $prefs;
-
-    $default_notepad = Horde_Util::getFormData('default_notepad');
-    if (!is_null($default_notepad)) {
-        $notepads = Mnemo::listNotepads();
-        if (is_array($notepads) && array_key_exists($default_notepad, $notepads)) {
-            $prefs->setValue('default_notepad', $default_notepad);
-            $updated = true;
-        }
-    }
-    return $updated;
-}
diff --git a/mnemo/lib/version.php b/mnemo/lib/version.php
deleted file mode 100644 (file)
index 5ce0926..0000000
+++ /dev/null
@@ -1 +0,0 @@
-<?php define('MNEMO_VERSION', 'H4 (3.0-cvs)') ?>
index f1ea331..df9a087 100644 (file)
@@ -9,8 +9,8 @@
  */
 
 @define('MNEMO_BASE', dirname(__FILE__));
-require_once MNEMO_BASE . '/lib/base.php';
-
+require_once MNEMO_BASE . '/lib/Application.php';
+Horde_Registry::appInit('mnemo');
 /* Get the current action ID. */
 $actionID = Horde_Util::getFormData('actionID');
 
@@ -61,6 +61,7 @@ Horde::addScriptFile('prototype.js', 'horde', true);
 Horde::addScriptFile('QuickFinder.js', 'horde', true);
 require MNEMO_TEMPLATES . '/common-header.inc';
 require MNEMO_TEMPLATES . '/menu.inc';
+$notification->notify();
 require MNEMO_TEMPLATES . '/list/header.inc';
 
 if (count($memos)) {
@@ -91,7 +92,7 @@ if (count($memos)) {
         $memourl = Horde_Util::addParameter(
             'memo.php', array('memo' => $memo['memo_id'],
                               'memolist' => $memo['memolist_id']));
-        $share = &$GLOBALS['mnemo_shares']->getShare($memo['memolist_id']);
+        $share = $GLOBALS['mnemo_shares']->getShare($memo['memolist_id']);
 
         $notepad = $memo['memolist_id'];
         if (!is_a($share, 'PEAR_Error')) {
index bf9f8e8..7acc94f 100644 (file)
@@ -53,7 +53,8 @@ function showPassphrase($memo)
 }
 
 @define('MNEMO_BASE', dirname(__FILE__));
-require_once MNEMO_BASE . '/lib/base.php';
+require_once MNEMO_BASE . '/lib/Application.php';
+Horde_Registry::appInit('mnemo');
 
 /* Redirect to the notepad view if no action has been requested. */
 $memo_id = Horde_Util::getFormData('memo');
@@ -71,8 +72,8 @@ $cManager = new Horde_Prefs_CategoryManager();
 switch ($actionID) {
 case 'add_memo':
     /* Check permissions. */
-    if (Mnemo::hasPermission('max_notes') !== true &&
-        Mnemo::hasPermission('max_notes') <= Mnemo::countMemos()) {
+    if ($GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_notes') !== true &&
+        $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_notes') <= Mnemo::countMemos()) {
         $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d notes."), Mnemo::hasPermission('max_notes')), ENT_COMPAT, Horde_Nls::getCharset());
         if (!empty($conf['hooks']['permsdenied'])) {
             $message = Horde::callHook('_perms_hook_denied', array('mnemo:max_notes'), 'horde', $message);
@@ -129,7 +130,7 @@ case 'save_memo':
     $memo_passphrase = Horde_Util::getFormData('memo_passphrase');
     $memo_passphrase2 = Horde_Util::getFormData('memo_passphrase2');
 
-    $share = &$GLOBALS['mnemo_shares']->getShare($notepad_target);
+    $share = $GLOBALS['mnemo_shares']->getShare($notepad_target);
     if (is_a($share, 'PEAR_Error')) {
         $notification->push(sprintf(_("Access denied saving note: %s"), $share->getMessage()), 'horde.error');
     } elseif (!$share->hasPermission(Horde_Auth::getAuth(), Horde_Perms::EDIT)) {
@@ -192,13 +193,13 @@ case 'save_memo':
             $result = $storage->modify($memo_id, $memo_desc, $memo_body, $memo_category, $memo_passphrase);
         } else {
             /* Check permissions. */
-            if (Mnemo::hasPermission('max_notes') !== true &&
-                Mnemo::hasPermission('max_notes') <= Mnemo::countMemos()) {
+            if ($GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_notes') !== true &&
+                $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_notes') <= Mnemo::countMemos()) {
                 header('Location: ' . Horde::applicationUrl('list.php', true));
                 exit;
             }
             /* Creating a new note. */
-            $storage = &Mnemo_Driver::singleton($notepad_target);
+            $storage = Mnemo_Driver::singleton($notepad_target);
             $memo_desc = $storage->getMemoDescription($memo_body);
             $result = $memo_id = $storage->add($memo_desc, $memo_body,
                                                $memo_category, null,
@@ -251,5 +252,6 @@ default:
 $notepads = Mnemo::listNotepads(false, Horde_Perms::EDIT);
 require MNEMO_TEMPLATES . '/common-header.inc';
 require MNEMO_TEMPLATES . '/menu.inc';
+$notification->notify();
 require MNEMO_TEMPLATES . '/memo/memo.inc';
 require $registry->get('templates', 'horde') . '/common-footer.inc';
index 9ebc408..9fb8ce9 100644 (file)
@@ -9,7 +9,9 @@
  */
 
 @define('MNEMO_BASE', dirname(dirname(__FILE__)));
-require_once MNEMO_BASE . '/lib/base.php';
+require_once MNEMO_BASE . '/lib/Application.php';
+Horde_Registry::appInit('mnemo');
+
 require_once MNEMO_BASE . '/lib/Forms/CreateNotepad.php';
 
 // Exit if this isn't an authenticated user or if the user can't
@@ -38,5 +40,6 @@ if ($form->validate($vars)) {
 $title = $form->getTitle();
 require MNEMO_TEMPLATES . '/common-header.inc';
 require MNEMO_TEMPLATES . '/menu.inc';
+$notification->notify();
 echo $form->renderActive($form->getRenderer(), $vars, 'create.php', 'post');
 require $registry->get('templates', 'horde') . '/common-footer.inc';
index b733095..08d594d 100644 (file)
@@ -9,7 +9,9 @@
  */
 
 @define('MNEMO_BASE', dirname(dirname(__FILE__)));
-require_once MNEMO_BASE . '/lib/base.php';
+require_once MNEMO_BASE . '/lib/Application.php';
+Horde_Registry::appInit('mnemo');
+
 require_once MNEMO_BASE . '/lib/Forms/DeleteNotepad.php';
 
 // Exit if this isn't an authenticated user.
@@ -56,5 +58,6 @@ if ($form->validate(new Horde_Variables($_POST))) {
 $title = $form->getTitle();
 require MNEMO_TEMPLATES . '/common-header.inc';
 require MNEMO_TEMPLATES . '/menu.inc';
+$notification->notify();
 echo $form->renderActive($form->getRenderer(), $vars, 'delete.php', 'post');
 require $registry->get('templates', 'horde') . '/common-footer.inc';
index d63ce7a..ddf5012 100644 (file)
@@ -9,7 +9,9 @@
  */
 
 @define('MNEMO_BASE', dirname(dirname(__FILE__)));
-require_once MNEMO_BASE . '/lib/base.php';
+require_once MNEMO_BASE . '/lib/Application.php';
+Horde_Registry::appInit('mnemo');
+
 require_once MNEMO_BASE . '/lib/Forms/EditNotepad.php';
 
 // Exit if this isn't an authenticated user.
@@ -55,5 +57,6 @@ $vars->set('description', $notepad->get('desc'));
 $title = $form->getTitle();
 require MNEMO_TEMPLATES . '/common-header.inc';
 require MNEMO_TEMPLATES . '/menu.inc';
+$notification->notify();
 echo $form->renderActive($form->getRenderer(), $vars, 'edit.php', 'post');
 require $registry->get('templates', 'horde') . '/common-footer.inc';
index 22685ac..99bd004 100644 (file)
@@ -9,7 +9,8 @@
  */
 
 @define('MNEMO_BASE', dirname(dirname(__FILE__)));
-require_once MNEMO_BASE . '/lib/base.php';
+require_once MNEMO_BASE . '/lib/Application.php';
+Horde_Registry::appInit('mnemo');
 
 // Exit if this isn't an authenticated user.
 if (!Horde_Auth::getAuth()) {
@@ -21,6 +22,7 @@ $edit_url_base = Horde::applicationUrl('notepads/edit.php');
 $perms_url_base = Horde::url($registry->get('webroot', 'horde') . '/services/shares/edit.php?app=mnemo', true);
 $delete_url_base = Horde::applicationUrl('notepads/delete.php');
 
+
 $notepads = Mnemo::listNotepads(true);
 $sorted_notepads = array();
 foreach ($notepads as $notepad) {
@@ -28,14 +30,15 @@ foreach ($notepads as $notepad) {
 }
 asort($sorted_notepads);
 
-$edit_img = Horde::img('edit.png', _("Edit"), null, $registry->getImageDir('horde'));
-$perms_img = Horde::img('perms.png', _("Change Permissions"), null, $registry->getImageDir('horde'));
-$delete_img = Horde::img('delete.png', _("Delete"), null, $registry->getImageDir('horde'));
+$edit_img = Horde::img('edit.png', _("Edit"), null);
+$perms_img = Horde::img('perms.png', _("Change Permissions"), null);
+$delete_img = Horde::img('delete.png', _("Delete"), null);
 
 Horde::addScriptFile('popup.js', 'horde', true);
 Horde::addScriptFile('tables.js', 'horde', true);
 $title = _("Manage Notepads");
 require MNEMO_TEMPLATES . '/common-header.inc';
 require MNEMO_TEMPLATES . '/menu.inc';
+$notification->notify();
 require MNEMO_TEMPLATES . '/notepad_list.php';
 require $registry->get('templates', 'horde') . '/common-footer.inc';
index a2b122c..1fde830 100644 (file)
  */
 
 @define('MNEMO_BASE', dirname(__FILE__));
-require_once MNEMO_BASE . '/lib/base.php';
+require_once MNEMO_BASE . '/lib/Application.php';
+Horde_Registry::appInit('mnemo');
+
 $title = _("Search");
 $notification->push('document.getElementById(\'search_pattern\').focus();', 'javascript');
 Horde::addScriptFile('prototype.js', 'horde', true);
 require MNEMO_TEMPLATES . '/common-header.inc';
 require MNEMO_TEMPLATES . '/menu.inc';
+$notification->notify();
 require MNEMO_TEMPLATES . '/search/search.inc';
 require MNEMO_TEMPLATES . '/panel.inc';
 require $registry->get('templates', 'horde') . '/common-footer.inc';
index bc39508..ba35a37 100644 (file)
@@ -20,18 +20,14 @@ if (!empty($refresh_time) && ($refresh_time > 0) && !empty($refresh_url)) {
 
 Horde::includeScriptFiles();
 
-$bc = Horde_Util::nonInputVar('bodyClass');
-if ($prefs->getValue('show_panel')) {
-    if ($bc) {
-        $bc .= ' ';
-    }
-    $bc .= 'rightPanel';
-}
+$bc = $prefs->getValue('show_panel')
+    ? 'rightPanel'
+    : '';
 
 ?>
 <title><?php echo htmlspecialchars($page_title) ?></title>
-<link href="<?php echo $GLOBALS['registry']->getImageDir()?>/favicon.ico" rel="SHORTCUT ICON" />
-<?php Horde::includeStylesheetFiles() ?>
+<link href="<?php echo Horde_Themes::img('favicon.ico', array('nohorde' => true)) ?>" rel="SHORTCUT ICON" />
+<?php Horde_Themes::includeStylesheetFiles() ?>
 <link href="<?php echo Horde::applicationUrl('themes/categoryCSS.php') ?>" rel="stylesheet" type="text/css" />
 </head>
 
index 5f4d722..a2bd0c3 100644 (file)
@@ -1,7 +1,7 @@
 <div id="page">
 <div class="header leftAlign">
  <?php echo htmlspecialchars($title) . ' (' . count($memos) . ')' ?>
- <a id="quicksearchL" href="<?php echo Horde::applicationUrl('search.php') ?>" title="<?php echo _("Search") ?>" onclick="$('quicksearchL').hide(); $('quicksearch').show(); $('quicksearchT').focus(); return false;"><?php echo Horde::img('search.png', _("Search"), '', $registry->getImageDir('horde')) ?></a>
+ <a id="quicksearchL" href="<?php echo Horde::applicationUrl('search.php') ?>" title="<?php echo _("Search") ?>" onclick="$('quicksearchL').hide(); $('quicksearch').show(); $('quicksearchT').focus(); return false;"><?php echo Horde::img('search.png', _("Search"), '') ?></a>
  <div id="quicksearch" style="display:none">
   <input type="text" name="quicksearchT" id="quicksearchT" for="notes_body" empty="notes_empty" />
   <small>
index 638d259..e21b811 100644 (file)
@@ -27,7 +27,7 @@ function doPrefsUpdate(column, sortDown)
 <table width="100%" id="memos" cellspacing="0" class="sortable linedRow nowrap">
 <thead>
  <tr class="item leftAlign">
-  <th class="nosort" width="3%"><?php echo Horde::img('edit.png', _("Edit Note"), '', $registry->getImageDir('horde')) ?></th>
+  <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")) ?>&nbsp;
@@ -42,7 +42,7 @@ function doPrefsUpdate(column, sortDown)
     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'));
-        echo ' ' . Horde::link($categoryUrl, _("Edit categories and colors"), '', '_blank', 'popup(this.href); return false;') . Horde::img('colorpicker.png', _("Edit categories and colors"), '', $GLOBALS['registry']->getImageDir('horde')) . '</a>';
+        echo ' ' . Horde::link($categoryUrl, _("Edit categories and colors"), '', '_blank', 'popup(this.href); return false;') . Horde::img('colorpicker.png', _("Edit categories and colors"), '') . '</a>';
     }
     ?>
   </th>
index 27cd0b1..727ec3c 100644 (file)
@@ -4,7 +4,7 @@
 if (!is_a($share, 'PEAR_Error') && $share->hasPermission(Horde_Auth::getAuth(), Horde_Perms::EDIT)) {
     $label = sprintf(_("Edit \"%s\""), $memo['desc']);
     echo Horde::link(Horde::applicationUrl(Horde_Util::addParameter($memourl, 'actionID', 'modify_memo')), $label) .
-        Horde::img('edit.png', $label, '', $registry->getImageDir('horde')) . '</a>';
+        Horde::img('edit.png', $label, '') . '</a>';
 }
 ?>
   </td>
index 0f47960..8d462fd 100644 (file)
@@ -1,4 +1,3 @@
 <div id="menu">
- <?php echo Mnemo::getMenu('string') ?>
+ <?php echo Mnemo::getMenu()->render() ?>
 </div>
-<?php $GLOBALS['notification']->notify(array('listeners' => 'status')) ?>
index a8b62b7..eb7ce90 100644 (file)
@@ -9,14 +9,15 @@
  */
 
 @define('MNEMO_BASE', dirname(__FILE__));
-require_once MNEMO_BASE . '/lib/base.php';
+require_once MNEMO_BASE . '/lib/Application.php';
+Horde_Registry::appInit('mnemo');
 
 /* Check if a passphrase has been sent. */
 $passphrase = Horde_Util::getFormData('memo_passphrase');
 
 /* We can either have a UID or a memo id and a notepad. Check for UID
  * first. */
-$storage = &Mnemo_Driver::singleton();
+$storage = Mnemo_Driver::singleton();
 if ($uid = Horde_Util::getFormData('uid')) {
     $memo = $storage->getByUID($uid, $passphrase);
     if (is_a($memo, 'PEAR_Error')) {
@@ -40,7 +41,7 @@ if ($uid = Horde_Util::getFormData('uid')) {
     $memo = Mnemo::getMemo($memolist_id, $memo_id, $passphrase);
 }
 
-$share = &$GLOBALS['mnemo_shares']->getShare($memolist_id);
+$share = $GLOBALS['mnemo_shares']->getShare($memolist_id);
 if (is_a($share, 'PEAR_Error')) {
     $notification->push(sprintf(_("There was an error viewing this notepad: %s"), $share->getMessage()), 'horde.error');
     header('Location: ' . Horde::applicationUrl('list.php', true));
@@ -63,10 +64,9 @@ $userId = Horde_Auth::getAuth();
 $createdby = '';
 $modifiedby = '';
 if (!empty($memo['uid'])) {
-    $history = &Horde_History::singleton();
-    $log = $history->getHistory('mnemo:' . $memolist_id . ':' . $memo['uid']);
+    $log = Horde_History::singleton()->getHistory('mnemo:' . $memolist_id . ':' . $memo['uid']);
     if ($log && !is_a($log, 'PEAR_Error')) {
-        foreach ($log->getData() as $entry) {
+       foreach ($log as $entry) {
             switch ($entry['action']) {
             case 'add':
                 $created = $entry['ts'];