/** */ protected function _content() { global $registry, $prefs; if (!empty($this->_params['show_notepad'])) { $shares = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Share')->create(); } $html = ''; $memos = Mnemo::listMemos($prefs->getValue('sortby'), $prefs->getValue('sortdir')); foreach ($memos as $id => $memo) { $html .= '<tr>'; if (!empty($this->_params['show_actions'])) { $editImg = Horde_Themes::img('edit.png'); $editurl = Horde::url('memo.php')->add(array('memo' => $memo['memo_id'], 'memolist' => $memo['memolist_id'])); $html .= '<td width="1%">' . Horde::link(htmlspecialchars(Horde::url($editurl, true)->add('actionID', 'modify_memo')), _("Edit Note")) . Horde::img($editImg, _("Edit Note")) . '</a></td>'; } if (!empty($this->_params['show_notepad'])) { $html .= '<td>' . htmlspecialchars(Mnemo::getLabel($shares->getShare($memo['memolist_id']))) . '</td>'; } $viewurl = Horde::url('view.php')->add(array('memo' => $memo['memo_id'], 'memolist' => $memo['memolist_id'])); $html .= '<td>' . Horde::linkTooltip(htmlspecialchars(Horde::url($viewurl, true)), '', '', '', '', $memo['body'] != $memo['desc'] ? Mnemo::getNotePreview($memo) : '') . (strlen($memo['desc']) ? htmlspecialchars($memo['desc']) : '<em>' . _("Empty Note") . '</em>') . '</a> <ul class="horde-tags">'; foreach ($memo['tags'] as $tag) { $html .= '<li>' . htmlspecialchars($tag) . '</li>'; } $html .= '</ul></td></tr>'; } if (!$memos) { return '<p><em>' . _("No notes to display") . '</em></p>'; } return '<table cellspacing="0" width="100%" class="linedRow">' . $html . '</table>'; }
$view->url = Horde::url('memo.php'); if (!$view->modify || !$view->passphrase) { $injector->getInstance('Horde_Core_Factory_Imple')->create('Mnemo_Ajax_Imple_TagAutoCompleter', array('id' => 'memo_tags')); $view->body = $memo_body; $view->count = sprintf(_("%s characters"), '<span id="mnemo-count">' . Horde_String::length(str_replace(array("\r", "\n"), '', $memo_body)) . '</span>'); $view->encrypted = $memo_encrypted; $view->encryption = $storage->encryptionSupported(); try { $view->help = Horde::callHook('description_help', array(), 'mnemo', ''); } catch (Horde_Exception_HookNotSet $e) { } $view->loadingImg = Horde::img('loading.gif', _("Loading...")); $view->notepads = array(); if (!$prefs->isLocked('default_notepad')) { foreach (Mnemo::listNotepads(false, Horde_Perms::SHOW) as $id => $notepad) { if (!$notepad->hasPermission($user, Horde_Perms::EDIT)) { continue; } $view->notepads[] = array('id' => $id, 'selected' => $id == $memolist_id, 'label' => Mnemo::getLabel($notepad)); } } $view->tags = implode(', ', $memo_tags); if ($memo_id && $mnemo_shares->getShare($memolist_id)->hasPermission($user, Horde_Perms::DELETE)) { $view->delete = Horde::url('memo.php')->add(array('memo' => $memo_id, 'memolist' => $memolist_id, 'actionID' => 'delete_memos')); } } $page_output->addScriptFile('memo.js'); $page_output->header(array('title' => $title)); $notification->notify(); echo $view->render('memo/memo'); $page_output->footer();
$view->sortdirclass = $sortdir ? 'sortup' : 'sortdown'; $view->headers = array(); if ($view->showNotepad) { $view->headers[] = array('id' => 's' . Mnemo::SORT_NOTEPAD, 'sorted' => $sortby == Mnemo::SORT_NOTEPAD, 'width' => '2%', 'label' => Horde::widget(array('url' => $baseurl->add('sortby', Mnemo::SORT_NOTEPAD), 'class' => 'sortlink', 'title' => _("Notepad")))); } $view->headers[] = array('id' => 's' . MNEMO::SORT_DESC, 'sorted' => $sortby == MNEMO::SORT_DESC, 'width' => '80%', 'label' => Horde::widget(array('url' => $baseurl->add('sortby', Mnemo::SORT_DESC), 'class' => 'sortlink', 'title' => _("No_te")))); $view->headers[] = array('id' => 's' . MNEMO::SORT_MOD_DATE, 'sorted' => $sortby == Mnemo::SORT_MOD_DATE, 'width' => '2%', 'label' => Horde::widget(array('url' => $baseurl->add('sortby', MNEMO::SORT_MOD_DATE), 'class' => 'sortlink', 'title' => _("Date")))); foreach ($memos as $memo_id => &$memo) { try { $share = $mnemo_shares->getShare($memo['memolist_id']); } catch (Horde_Share_Exception $e) { $notification->push($e); continue; } if ($view->showNotepad) { $memo['notepad'] = Mnemo::getLabel($share); } if ($share->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) { $label = sprintf(_("Edit \"%s\""), $memo['desc']); $memo['edit'] = Horde::url('memo.php')->add(array('memo' => $memo['memo_id'], 'memolist' => $memo['memolist_id'], 'actionID' => 'modify_memo'))->link(array('title' => $label)) . Horde::img('edit.png', $label, '') . '</a>'; } $memo['link'] = Horde::linkTooltip(Horde::url('view.php')->add(array('memo' => $memo['memo_id'], 'memolist' => $memo['memolist_id'])), '', '', '', '', $memo['body'] != $memo['desc'] ? Mnemo::getNotePreview($memo) : '') . (strlen($memo['desc']) ? htmlspecialchars($memo['desc']) : '<em>' . _("Empty Note") . '</em>') . '</a>'; // Get memo's most recent modification date or, if nonexistent, // the creation (add) date if (isset($memo['modified'])) { $modified = $memo['modified']; } elseif (isset($memo['created'])) { $modified = $memo['created']; } else { $modified = null; }
} if (!$haveDefault) { $sync[] = $default; $GLOBALS['prefs']->setValue('sync_notepads', serialize($sync)); } }); // Sync $_prefs['sync_notepads'] = array('value' => 'a:0:{}', 'type' => 'multienum', 'enum' => array(), 'desc' => _("Select the notepads that, in addition to the default, should be used for synchronization with external devices:"), 'on_init' => function ($ui) { $enum = array(); $sync = @unserialize($GLOBALS['prefs']->getValue('sync_notepads')); if (empty($sync)) { $GLOBALS['prefs']->setValue('sync_notepads', serialize(array(Mnemo::getDefaultNotepad(Horde_Perms::DELETE)))); } foreach (Mnemo::listNotepads(false, Horde_Perms::DELETE) as $key => $list) { if ($list->getName() != Mnemo::getDefaultNotepad(Horde_Perms::DELETE)) { $enum[$key] = Mnemo::getLabel($list); } } $ui->prefs['sync_notepads']['enum'] = $enum; }, 'on_change' => function () { $sync = @unserialize($GLOBALS['prefs']->getValue('sync_notepads')); $haveDefault = false; $default = Mnemo::getDefaultNotepad(Horde_Perms::DELETE); foreach ($sync as $cid) { if ($cid == $default) { $haveDefault = true; break; } } if (!$haveDefault) { $sync[] = $default;
/** * Renders the view. * * @param Horde_PageOutput $output The output object. * * @return string The HTML needed to render the view. */ public function render(Horde_PageOutput $output) { global $prefs, $injector, $registry, $mnemo_shares; $output->addScriptFile('tables.js', 'horde'); $output->addScriptFile('quickfinder.js', 'horde'); $output->addScriptFile('list.js'); $output->header(array('title' => $this->_title)); $view = $injector->createInstance('Horde_View'); $view->count = count($this->_notes); $view->searchImg = Horde::img('search.png', _("Search"), ''); $view->searchUrl = Horde::url('search.php'); $view->title = $this->_title; $view->browser = $this->_showTagBrowser ? $this->_getRelatedTags() . $this->_getTagTrail() : ''; if (count($this->_notes)) { $sortby = $prefs->getValue('sortby'); $sortdir = $prefs->getValue('sortdir'); $output->addInlineJsVars(array('Mnemo_List.ajaxUrl' => $registry->getServiceLink('ajax', 'mnemo')->url . 'setPrefValue')); $view->editImg = Horde::img('edit.png', _("Edit Note"), ''); $view->showNotepad = $prefs->getValue('show_notepad'); $view->sortdirclass = $sortdir ? 'sortup' : 'sortdown'; $view->headers = array(); if ($view->showNotepad) { $view->headers[] = array('id' => 's' . Mnemo::SORT_NOTEPAD, 'sorted' => $sortby == Mnemo::SORT_NOTEPAD, 'width' => '2%', 'label' => Horde::widget(array('url' => $this->_baseurl->add('sortby', Mnemo::SORT_NOTEPAD), 'class' => 'sortlink', 'title' => _("Notepad")))); } $view->headers[] = array('id' => 's' . MNEMO::SORT_DESC, 'sorted' => $sortby == MNEMO::SORT_DESC, 'width' => '80%', 'label' => Horde::widget(array('url' => $this->_baseurl->add('sortby', Mnemo::SORT_DESC), 'class' => 'sortlink', 'title' => _("No_te")))); $view->headers[] = array('id' => 's' . MNEMO::SORT_MOD_DATE, 'sorted' => $sortby == Mnemo::SORT_MOD_DATE, 'width' => '2%', 'label' => Horde::widget(array('url' => $this->_baseurl->add('sortby', MNEMO::SORT_MOD_DATE), 'class' => 'sortlink', 'title' => _("Date")))); foreach ($this->_notes as $memo_id => &$memo) { try { $share = $mnemo_shares->getShare($memo['memolist_id']); } catch (Horde_Share_Exception $e) { $notification->push($e); continue; } if ($view->showNotepad) { $memo['notepad'] = Mnemo::getLabel($share); } if ($share->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) { $label = sprintf(_("Edit \"%s\""), $memo['desc']); $memo['edit'] = Horde::url('memo.php')->add(array('memo' => $memo['memo_id'], 'memolist' => $memo['memolist_id'], 'actionID' => 'modify_memo'))->link(array('title' => $label)) . Horde::img('edit.png', $label, '') . '</a>'; } $memo['link'] = Horde::linkTooltip(Horde::url('view.php')->add(array('memo' => $memo['memo_id'], 'memolist' => $memo['memolist_id'])), '', '', '', '', $memo['body'] != $memo['desc'] ? Mnemo::getNotePreview($memo) : '') . (strlen($memo['desc']) ? htmlspecialchars($memo['desc']) : '<em>' . _("Empty Note") . '</em>') . '</a>'; // Get memo's most recent modification date or, if nonexistent, // the creation (add) date if (isset($memo['modified'])) { $modified = $memo['modified']; } elseif (isset($memo['created'])) { $modified = $memo['created']; } else { $modified = null; } if ($modified) { $memo['modifiedStamp'] = $modified->timestamp(); $memo['modifiedString'] = $modified->strftime($prefs->getValue('date_format')); } else { $memo['modifiedStamp'] = $memo['modifiedString'] = ''; } } } Horde::startBuffer(); echo $view->render('list/header'); if (count($this->_notes)) { echo $view->render('list/memo_headers'); echo $view->renderPartial('list/summary', array('collection' => array_values($this->_notes))); echo $view->render('list/memo_footers'); } else { echo $view->render('list/empty'); } $output->footer(); return Horde::endBuffer(); }
if (count($search_results) == 1) { $note = array_shift($search_results); Horde::url('view.php', true)->add(array('memo' => $note['memo_id'], 'memolist' => $note['memolist_id']))->redirect(); } $memos = $search_results; $page_output->addScriptFile('tables.js', 'horde'); $page_output->addScriptFile('quickfinder.js', 'horde'); $page_output->header(array('title' => _("Search Results"))); require MNEMO_TEMPLATES . '/list/header.inc'; if (count($memos)) { $sortby = $prefs->getValue('sortby'); $sortdir = $prefs->getValue('sortdir'); $showNotepad = $prefs->getValue('show_notepad'); $baseurl = 'list.php'; require MNEMO_TEMPLATES . '/list/memo_headers.inc'; foreach ($memos as $memo_id => $memo) { $viewurl = Horde::url('view.php')->add(array('memo' => $memo['memo_id'], 'memolist' => $memo['memolist_id'])); $memourl = Horde::url('memo.php')->add(array('memo' => $memo['memo_id'], 'memolist' => $memo['memolist_id'])); try { $share = $GLOBALS['mnemo_shares']->getShare($memo['memolist_id']); $notepad = Mnemo::getLabel($share); } catch (Horde_Share_Exception $e) { $notepad = $memo['memolist_id']; } require MNEMO_TEMPLATES . '/list/memo_summaries.inc'; } require MNEMO_TEMPLATES . '/list/memo_footers.inc'; } else { require MNEMO_TEMPLATES . '/list/empty.inc'; } $page_output->footer();
/** */ public function topbarCreate(Horde_Tree_Renderer_Base $tree, $parent = null, array $params = array()) { global $registry; $add = Horde::url('memo.php', true)->add('actionID', 'add_memo'); $tree->addNode(array('id' => $parent . '__new', 'parent' => $parent, 'label' => _("New Note"), 'expanded' => false, 'params' => array('icon' => Horde_Themes::img('add.png'), 'url' => $add))); $user = $registry->getAuth(); foreach (Mnemo::listNotepads(false, Horde_Perms::SHOW) as $name => $notepad) { if (!$notepad->hasPermission($user, Horde_Perms::EDIT)) { continue; } $tree->addNode(array('id' => $parent . $name . '__new', 'parent' => $parent . '__new', 'label' => sprintf(_("in %s"), Mnemo::getLabel($notepad)), 'expanded' => false, 'params' => array('icon' => Horde_Themes::img('add.png'), 'url' => $add->copy()->add('memolist', $name)))); } $tree->addNode(array('id' => $parent . '__search', 'parent' => $parent, 'label' => _("Search"), 'expanded' => false, 'params' => array('icon' => Horde_Themes::img('search.png'), 'url' => Horde::url('search.php')))); }
/** * Browse through Mnemo's object tree. * * @param string $path The level of the tree to browse. * @param array $properties The item properties to return. Defaults to * 'name', 'icon', and 'browseable'. * * @return array The contents of $path */ public function browse($path = '', $properties = array()) { global $injector, $mnemo_shares, $registry; // Default properties. if (!$properties) { $properties = array('name', 'icon', 'browseable'); } if (substr($path, 0, 5) == 'mnemo') { $path = substr($path, 5); } $path = trim($path, '/'); $parts = explode('/', $path); $currentUser = $registry->getAuth(); if (empty($path)) { // This request is for a list of all users who have notepads // visible to the requesting user. $notepads = Mnemo::listNotepads(false, Horde_Perms::READ); $owners = array(); foreach ($notepads as $notepad) { $owners[$notepad->get('owner') ? $notepad->get('owner') : '-system-'] = true; } $results = array(); foreach (array_keys($owners) as $owner) { $path = 'mnemo/' . $registry->convertUsername($owner, false); if (in_array('name', $properties)) { $results[$path]['name'] = $injector->getInstance('Horde_Core_Factory_Identity')->create($owner)->getName(); } if (in_array('icon', $properties)) { $results[$path]['icon'] = Horde_Themes::img('user.png'); } if (in_array('browseable', $properties)) { $results[$path]['browseable'] = true; } if (in_array('read-only', $properties)) { $results[$path]['read-only'] = true; } } return $results; } elseif (count($parts) == 1) { // This request is for all notepads owned by the requested user $owner = $parts[0] == '-system-' ? '' : $registry->convertUsername($parts[0], true); $notepads = $mnemo_shares->listShares($currentUser, array('perm' => Horde_Perms::SHOW, 'attributes' => $owner)); $results = array(); foreach ($notepads as $notepadId => $notepad) { if ($parts[0] == '-system-' && $notepad->get('owner')) { continue; } $retpath = 'mnemo/' . $parts[0] . '/' . $notepadId; if (in_array('name', $properties)) { $results[$retpath]['name'] = sprintf(_("Notes from %s"), Mnemo::getLabel($notepad)); } if (in_array('displayname', $properties)) { $results[$retpath]['displayname'] = Mnemo::getLabel($notepad); } if (in_array('owner', $properties)) { $results[$retpath]['owner'] = $notepad->get('owner') ? $registry->convertUsername($notepad->get('owner'), false) : '-system-'; } if (in_array('icon', $properties)) { $results[$retpath]['icon'] = Horde_Themes::img('mnemo.png'); } if (in_array('browseable', $properties)) { $results[$retpath]['browseable'] = $notepad->hasPermission($currentUser, Horde_Perms::READ); } if (in_array('read-only', $properties)) { $results[$retpath]['read-only'] = !$notepad->hasPermission($currentUser, Horde_Perms::EDIT); } } return $results; } elseif (count($parts) == 2) { // // This request is browsing into a specific notepad. Generate the // list of items and represent them as files within the directory. // try { $notepad = $mnemo_shares->getShare($parts[1]); } catch (Horde_Exception_NotFound $e) { throw new Mnemo_Exception(_("Invalid notepad requested."), 404); } catch (Horde_Share_Exception $e) { throw new Mnemo_Exception($e->getMessage, 500); } if (!$notepad->hasPermission($currentUser, Horde_Perms::READ)) { throw new Mnemo_Exception(_("Invalid notepad requested."), 404); } $storage = $injector->getInstance('Mnemo_Factory_Driver')->create($parts[1]); try { $storage->retrieve(); } catch (Mnemo_Exception $e) { throw new Mnemo_Exception($e->getMessage, 500); } $icon = Horde_Themes::img('mnemo.png'); $owner = $notepad->get('owner') ? $registry->convertUsername($notepad->get('owner'), false) : '-system-'; $dav = $injector->getInstance('Horde_Dav_Storage'); $results = array(); foreach ($storage->listMemos() as $memo) { $body = $memo['body'] instanceof Mnemo_Exception ? $memo['body']->getMessage() : $memo['body']; $id = $memo['memo_id']; try { $id = $dav->getExternalObjectId($id, $parts[1]) ?: $id; } catch (Horde_Dav_Exception $e) { } $key = 'mnemo/' . $parts[0] . '/' . $parts[1] . '/' . $id; if (in_array('name', $properties)) { $results[$key]['name'] = $memo['desc']; } if (in_array('owner', $properties)) { $results[$key]['owner'] = $owner; } if (in_array('icon', $properties)) { $results[$key]['icon'] = $icon; } if (in_array('browseable', $properties)) { $results[$key]['browseable'] = false; } if (in_array('read-only', $properties)) { $results[$key]['read-only'] = !$notepad->hasPermission($currentUser, Horde_Perms::EDIT); } if (in_array('contenttype', $properties)) { $results[$key]['contenttype'] = 'text/plain'; } if (in_array('contentlength', $properties)) { $results[$key]['contentlength'] = strlen($body); } if (in_array('modified', $properties)) { $results[$key]['modified'] = $this->_modified($memo); } if (in_array('created', $properties)) { $results[$key]['created'] = isset($memo['created']) ? $memo['created'] : 0; } if (in_array('etag', $properties)) { $results[$key]['etag'] = '"' . md5($memo['memo_id'] . '|' . $this->_modified($memo)) . '"'; } } return $results; } else { // // The only valid request left is for a specific note. // if (count($parts) == 3 && Mnemo::hasPermission($parts[1], Horde_Perms::READ)) { // // This request is for a specific item within a given notepad. // /* Create a Mnemo storage instance. */ $storage = $injector->getInstance('Mnemo_Factory_Driver')->create($parts[1]); $storage->retrieve(); $dav = $injector->getInstance('Horde_Dav_Storage'); $object = $parts[2]; try { $object = $dav->getInternalObjectId($object, $parts[1]) ?: $object; } catch (Horde_Dav_Exception $e) { } try { $memo = $storage->get($object); } catch (Mnemo_Exception $e) { throw new Mnemo_Exception($e->getMessage(), 500); } $result = array('data' => $memo['body'] instanceof Mnemo_Exception ? $memo['body']->getMessage() : $memo['body'], 'mimetype' => 'text/plain'); $modified = $this->_modified($memo); if (!empty($modified)) { $result['mtime'] = $modified; } return $result; } else { // // All other requests are a 404: Not Found // return false; } } }
/** * Browse through Mnemo's object tree. * * @param string $path The level of the tree to browse. * @param array $properties The item properties to return. Defaults to * 'name', 'icon', and 'browseable'. * * @return array The contents of $path */ public function browse($path = '', $properties = array()) { global $registry; // Default properties. if (!$properties) { $properties = array('name', 'icon', 'browseable'); } if (substr($path, 0, 5) == 'mnemo') { $path = substr($path, 5); } $path = trim($path, '/'); $parts = explode('/', $path); if (empty($path)) { // This request is for a list of all users who have notepads // visible to the requesting user. $notepads = Mnemo::listNotepads(false, Horde_Perms::READ); $owners = array(); foreach ($notepads as $notepad) { $owners[$notepad->get('owner') ? $notepad->get('owner') : '-system-'] = true; } $results = array(); foreach (array_keys($owners) as $owner) { if (in_array('name', $properties)) { $results['mnemo/' . $owner]['name'] = $owner; } if (in_array('icon', $properties)) { $results['mnemo/' . $owner]['icon'] = Horde_Themes::img('user.png'); } if (in_array('browseable', $properties)) { $results['mnemo/' . $owner]['browseable'] = true; } if (in_array('contenttype', $properties)) { $results['mnemo/' . $owner]['contenttype'] = 'httpd/unix-directory'; } if (in_array('contentlength', $properties)) { $results['mnemo/' . $owner]['contentlength'] = 0; } if (in_array('modified', $properties)) { $results['mnemo/' . $owner]['modified'] = $_SERVER['REQUEST_TIME']; } if (in_array('created', $properties)) { $results['mnemo/' . $owner]['created'] = 0; } } return $results; } elseif (count($parts) == 1) { // This request is for all notepads owned by the requested user $owner = $parts[0] == '-system-' ? '' : $parts[0]; $notepads = $GLOBALS['mnemo_shares']->listShares($GLOBALS['registry']->getAuth(), array('perm' => Horde_Perms::SHOW, 'attributes' => $owner)); $results = array(); foreach ($notepads as $notepadId => $notepad) { if ($parts[0] == '-system-' && $notepad->get('owner')) { continue; } $retpath = 'mnemo/' . $parts[0] . '/' . $notepadId; if (in_array('name', $properties)) { $results[$retpath]['name'] = sprintf(_("Notes from %s"), Mnemo::getLabel($notepad)); } if (in_array('icon', $properties)) { $results[$retpath]['icon'] = Horde_Themes::img('mnemo.png'); } if (in_array('browseable', $properties)) { $results[$retpath]['browseable'] = $notepad->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ); } if (in_array('contenttype', $properties)) { $results[$retpath]['contenttype'] = 'httpd/unix-directory'; } if (in_array('contentlength', $properties)) { $results[$retpath]['contentlength'] = 0; } if (in_array('modified', $properties)) { // @TODO Find a way to get the actual modification times $results[$retpath]['modified'] = $_SERVER['REQUEST_TIME']; } if (in_array('created', $properties)) { // @TODO Find a way to get the actual creation times $results[$retpath]['created'] = 0; } } return $results; } elseif (count($parts) == 2) { // // This request is browsing into a specific notepad. Generate the // list of items and represent them as files within the directory. // if (!Mnemo::hasPermission($parts[1], Horde_Perms::READ)) { throw new Mnemo_Exception(_("Invalid notepad requested."), 404); } $storage = $GLOBALS['injector']->getInstance('Mnemo_Factory_Driver')->create($parts[1]); try { $storage->retrieve(); } catch (Mnemo_Exception $e) { throw new Mnemo_Exception($e->getMessage, 500); } $icon = Horde_Themes::img('mnemo.png'); $results = array(); foreach ($storage->listMemos() as $memo) { $body = $memo['body'] instanceof Mnemo_Exception ? $memo['body']->getMessage() : $memo['body']; $key = 'mnemo/' . $parts[0] . '/' . $parts[1] . '/' . $memo['memo_id']; if (in_array('name', $properties)) { $results[$key]['name'] = $memo['desc']; } if (in_array('icon', $properties)) { $results[$key]['icon'] = $icon; } if (in_array('browseable', $properties)) { $results[$key]['browseable'] = false; } if (in_array('contenttype', $properties)) { $results[$key]['contenttype'] = 'text/plain'; } if (in_array('contentlength', $properties)) { $results[$key]['contentlength'] = strlen($body); } if (in_array('modified', $properties)) { $results[$key]['modified'] = $this->_modified($memo); } if (in_array('created', $properties)) { $results[$key]['created'] = isset($memo['created']) ? $memo['created'] : 0; } if (in_array('etag', $properties)) { $results[$key]['etag'] = '"' . md5($memo['memo_id'] . '|' . $this->_modified($memo)) . '"'; } } return $results; } else { // // The only valid request left is for a specific note. // if (count($parts) == 3 && Mnemo::hasPermission($parts[1], Horde_Perms::READ)) { // // This request is for a specific item within a given notepad. // /* Create a Mnemo storage instance. */ $storage = $GLOBALS['injector']->getInstance('Mnemo_Factory_Driver')->create($parts[1]); $storage->retrieve(); try { $memo = $storage->get($parts[2]); } catch (Mnemo_Exception $e) { throw new Mnemo_Exception($e->getMessage(), 500); } $result = array('data' => $memo['body'] instanceof Mnemo_Exception ? $memo['body']->getMessage() : $memo['body'], 'mimetype' => 'text/plain'); $modified = $this->_modified($memo); if (!empty($modified)) { $result['mtime'] = $modified; } return $result; } elseif (count($parts) == 2 && substr($parts[1], -4) == '.txt' && Mnemo::hasPermission(substr($parts[1], 0, -4), Horde_Perms::READ)) { // ?? } else { // // All other requests are a 404: Not Found // return false; } } }