Index: memo.php =================================================================== --- memo.php (Revision 2544) +++ memo.php (Revision 2549) @@ -113,7 +113,7 @@ $memolist_original = Util::getFormData('memolist_original'); $notepad_target = Util::getFormData('notepad_target'); - $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(Auth::getAuth(), PERMS_EDIT)) { @@ -141,10 +141,10 @@ if (!is_a($result, 'PEAR_Error') && $memolist_original != $notepad_target) { /* Moving the note to another notepad. */ - $share = $GLOBALS['mnemo_shares']->getShare($memolist_original); + $share = &$GLOBALS['mnemo_shares']->getShare($memolist_original); if (!is_a($share, 'PEAR_Error') && $share->hasPermission(Auth::getAuth(), PERMS_DELETE)) { - $share = $GLOBALS['mnemo_shares']->getShare($notepad_target); + $share = &$GLOBALS['mnemo_shares']->getShare($notepad_target); if (!is_a($share, 'PEAR_Error') && $share->hasPermission(Auth::getAuth(), PERMS_EDIT)) { $result = $storage->move($memo_id, $notepad_target); @@ -186,7 +186,7 @@ $memolist_id = Util::getFormData('memolist'); if (!is_null($memo_id) && Mnemo::getMemo($memolist_id, $memo_id)) { - $share = $GLOBALS['mnemo_shares']->getShare($memolist_id); + $share = &$GLOBALS['mnemo_shares']->getShare($memolist_id); if (!is_a($share, 'PEAR_Error') && $share->hasPermission(Auth::getAuth(), PERMS_DELETE)) { $storage = &Mnemo_Driver::singleton($memolist_id); @@ -212,7 +212,7 @@ } $notification->push('document.memo.memo_body.focus()', 'javascript'); -$notepads = Mnemo::listNotepads(false, PERMS_EDIT); +$notepads = &Mnemo::listNotepads(false, PERMS_EDIT); require MNEMO_TEMPLATES . '/common-header.inc'; require MNEMO_TEMPLATES . '/menu.inc'; require MNEMO_TEMPLATES . '/memo/memo.inc'; Index: templates/prefs/notepadselect.inc =================================================================== --- templates/prefs/notepadselect.inc (Revision 2544) +++ templates/prefs/notepadselect.inc (Revision 2549) @@ -1,6 +1,6 @@ <?php if (!$prefs->isLocked('default_notepad')): - $notepads = Mnemo::listNotepads(); + $notepads = &Mnemo::listNotepads(); if (($default_notepad = $prefs->getValue('default_notepad')) == null || !isset($notepads[$default_notepad])) { $default_notepad = Auth::getAuth(); @@ -9,8 +9,8 @@ <?php echo Horde::label('default_notepad', _("Your default notepad:")) ?><br /> <select id="default_notepad" name="default_notepad"> -<?php foreach ($notepads as $id => $notepad): ?> - <option value="<?php echo htmlspecialchars($id) ?>"<?php if ($id == $default_notepad) echo ' selected="selected"' ?>><?php echo htmlspecialchars($notepad->get('name')) ?></option> +<?php foreach (array_keys($notepads) as $id): ?> + <option value="<?php echo htmlspecialchars($id) ?>"<?php if ($id == $default_notepad) echo ' selected="selected"' ?>><?php echo htmlspecialchars($notepads[$id]->get('name')) ?></option> <?php endforeach; ?> </select><br /><br /> <?php endif; ?> Index: templates/panel.inc =================================================================== --- templates/panel.inc (Revision 2544) +++ templates/panel.inc (Revision 2549) @@ -2,13 +2,15 @@ $current_user = Auth::getAuth(); $my_notepads = array(); $shared_notepads = array(); -foreach (Mnemo::listNotepads() as $id => $tl) { - if ($tl->get('owner') == $current_user) { - $my_notepads[$id] = $tl; +$all_notepads = &Mnemo::listNotepads(); +foreach (array_keys($all_notepads) as $id) { + if ($all_notepads[$id]->get('owner') == $current_user) { + $my_notepads[$id] = &$all_notepads[$id]; } else { - $shared_notepads[$id] = $tl; + $shared_notepads[$id] = &$all_notepads[$id]; } } + ?> <div id="pageControls"> @@ -37,8 +39,8 @@ <?php if ($current_user): ?> <h4><?php echo _("My Notepads:") ?></h4> <p> -<?php foreach ($my_notepads as $id => $tl): ?> - <label><input type="checkbox" class="checkbox" name="display_notepad[]" value="<?php echo htmlspecialchars($id) ?>"<?php echo (in_array($id, $display_notepads) ? ' checked="checked"' : '') . ' /> ' . htmlspecialchars($tl->get('name')) ?></label><br /> +<?php foreach (array_keys($my_notepads) as $id): ?> + <label><input type="checkbox" class="checkbox" name="display_notepad[]" value="<?php echo htmlspecialchars($id) ?>"<?php echo (in_array($id, $display_notepads) ? ' checked="checked"' : '') . ' /> ' . htmlspecialchars($my_notepads[$id]->get('name')) ?></label><br /> <?php endforeach; ?> <small><a href="<?php echo Horde::applicationUrl('notepads.php') ?>"><?php echo _("[Manage My Notepads]") ?></a></small><br /> </p> @@ -47,8 +49,8 @@ <?php if (count($shared_notepads)): ?> <h4><?php echo _("Shared Notepads:") ?></h4> <p> -<?php foreach ($shared_notepads as $id => $tl): ?> - <label><input type="checkbox" class="checkbox" name="display_notepad[]" value="<?php echo htmlspecialchars($id) ?>"<?php echo (in_array($id, $display_notepads) ? ' checked="checked"' : '') . ' /> [' . htmlspecialchars($tl->get('owner')) . '] ' . htmlspecialchars($tl->get('name')) ?></label><br /> +<?php foreach (array_keys($shared_notepads) as $id): ?> + <label><input type="checkbox" class="checkbox" name="display_notepad[]" value="<?php echo htmlspecialchars($id) ?>"<?php echo (in_array($id, $display_notepads) ? ' checked="checked"' : '') . ' /> [' . htmlspecialchars($shared_notepads[$id]->get('owner')) . '] ' . htmlspecialchars($shared_notepads[$id]->get('name')) ?></label><br /> <?php endforeach; ?> </p> <?php endif; ?> Index: templates/data/import.inc =================================================================== --- templates/data/import.inc (Revision 2544) +++ templates/data/import.inc (Revision 2549) @@ -12,15 +12,15 @@ <option value="vnote"><?php echo _("vNote") ?></option> </select><br /> -<?php if (!$prefs->isLocked('default_notepad') && count($notepads = Mnemo::listNotepads(false, PERMS_EDIT)) > 1): ?> +<?php if (!$prefs->isLocked('default_notepad') && count($notepads = &Mnemo::listNotepads(false, PERMS_EDIT)) > 1): ?> <br /><?php echo Horde::label('notepad_target', _("Which Notepad should the notes be added to?")) ?><br /> <select id="notepad_target" name="notepad_target"> <?php $default = Mnemo::getDefaultNotepad(PERMS_EDIT); - foreach ($notepads as $id => $notepad) { + foreach (array_keys($notepads) as $id) { $sel = ($id == $default) ? ' selected="selected"' : ''; printf('<option value="%s"%s>%s</option>', - htmlspecialchars($id), $sel, htmlspecialchars($notepad->get('name'))) . "\n"; + htmlspecialchars($id), $sel, htmlspecialchars($notepads[$id]->get('name'))) . "\n"; } ?> </select><br /> <?php else: ?> Index: templates/view/memo.inc =================================================================== --- templates/view/memo.inc (Revision 2544) +++ templates/view/memo.inc (Revision 2549) @@ -2,7 +2,7 @@ $memourl = Util::addParameter('memo.php', array('memo' => $memo_id, 'memolist' => $memolist_id)); -$share = $GLOBALS['mnemo_shares']->getShare($memolist_id); +$share = &$GLOBALS['mnemo_shares']->getShare($memolist_id); ?> <div class="header"> <div class="rightFloat"> Index: templates/memo/memo.inc =================================================================== --- templates/memo/memo.inc (Revision 2544) +++ templates/memo/memo.inc (Revision 2549) @@ -27,7 +27,7 @@ $memourl = Util::addParameter('memo.php', array('memo' => $memo_id, 'memolist' => $memolist_id)); - $share = $GLOBALS['mnemo_shares']->getShare($memolist_id); + $share = &$GLOBALS['mnemo_shares']->getShare($memolist_id); if (!is_a($share, 'PEAR_Error') && $share->hasPermission(Auth::getAuth(), PERMS_DELETE)): ?> <span class="rightFloat"><input type="button" class="button" value="<?php echo _("Delete this note") ?>" onclick="window.location='<?php echo addslashes(Horde::applicationUrl(Util::addParameter($memourl, 'actionID', 'delete_memos'))) ?>';" /></span> <?php endif; endif; ?> @@ -54,10 +54,10 @@ <?php echo Horde::label('notepad_target', _("Note_pad")) ?> <select id="notepad_target" name="notepad_target"> <?php - foreach ($notepads as $id => $notepad) { + foreach (array_keys($notepads) as $id) { $sel = ($id == $memolist_id) ? ' selected="selected"' : ''; printf('<option value="%s"%s>%s</option>', - htmlspecialchars($id), $sel, htmlspecialchars($notepad->get('name'))) . "\n"; + htmlspecialchars($id), $sel, htmlspecialchars($notepads[$id]->get('name'))) . "\n"; } ?> </select> <?php Index: view.php =================================================================== --- view.php (Revision 2544) +++ view.php (Revision 2549) @@ -40,7 +40,7 @@ $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)); Index: list.php =================================================================== --- list.php (Revision 2544) +++ list.php (Revision 2549) @@ -80,7 +80,7 @@ $memourl = 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']); require MNEMO_TEMPLATES . '/list/memo_summaries.inc'; } Index: notepads.php =================================================================== --- notepads.php (Revision 2544) +++ notepads.php (Revision 2549) @@ -37,7 +37,7 @@ $notepad = ''; if (!strlen($to_edit)) { /* Create New Share. */ - $notepad = $GLOBALS['mnemo_shares']->newShare(md5(microtime())); + $notepad = &$GLOBALS['mnemo_shares']->newShare(md5(microtime())); $notepad->set('name', $id); $notepad->set('desc', Util::getFormData('description', '')); $result = $GLOBALS['mnemo_shares']->addShare($notepad); @@ -70,7 +70,7 @@ break; } - $share = $GLOBALS['mnemo_shares']->getShare($to_delete); + $share = &$GLOBALS['mnemo_shares']->getShare($to_delete); if (is_a($share, 'PEAR_Error')) { $notification->push($share, 'horde.error'); break; @@ -99,7 +99,7 @@ if (trim($name) == '') { $name = Auth::removeHook(Auth::getAuth()); } - $share = $GLOBALS['mnemo_shares']->newShare(Auth::getAuth()); + $share = &$GLOBALS['mnemo_shares']->newShare(Auth::getAuth()); $share->set('name', sprintf(_("%s's Notepad"), $name)); $GLOBALS['mnemo_shares']->addShare($share); } @@ -108,7 +108,7 @@ } /* Personal Note Lists */ -$personal_notepads = Mnemo::listNotepads(true); +$personal_notepads = &Mnemo::listNotepads(true); Horde::addScriptFile('popup.js', 'horde', true); $title = _("Note Lists"); Index: note/pdf.php =================================================================== --- note/pdf.php (Revision 2544) +++ note/pdf.php (Revision 2549) @@ -41,7 +41,7 @@ $note = Mnemo::getMemo($notelist_id, $note_id, $passphrase); } -$share = $GLOBALS['mnemo_shares']->getShare($notelist_id); +$share = &$GLOBALS['mnemo_shares']->getShare($notelist_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)); Index: lib/api.php =================================================================== --- lib/api.php (Revision 2544) +++ lib/api.php (Revision 2549) @@ -237,7 +237,7 @@ * * @return array The notepads. */ -function _mnemo_listNotepads($owneronly, $permission) +function &_mnemo_listNotepads($owneronly, $permission) { require_once dirname(__FILE__) . '/base.php'; Index: lib/Mnemo.php =================================================================== --- lib/Mnemo.php (Revision 2544) +++ lib/Mnemo.php (Revision 2549) @@ -106,7 +106,7 @@ return $count; } - $notepads = Mnemo::listNotepads(true, PERMS_ALL); + $notepads = &Mnemo::listNotepads(true, PERMS_ALL); $count = 0; foreach (array_keys($notepads) as $notepad) { @@ -146,12 +146,13 @@ * * @return array The memo lists. */ - function listNotepads($owneronly = false, $permission = PERMS_SHOW) + function &listNotepads($owneronly = false, $permission = PERMS_SHOW) { - $notepads = $GLOBALS['mnemo_shares']->listShares(Auth::getAuth(), $permission, $owneronly ? Auth::getAuth() : null); + $notepads = &$GLOBALS['mnemo_shares']->listShares(Auth::getAuth(), $permission, $owneronly ? Auth::getAuth() : null); if (is_a($notepads, 'PEAR_Error')) { Horde::logMessage($notepads, __FILE__, __LINE__, PEAR_LOG_ERR); - return array(); + $empty = array(); + return $empty; } return $notepads; @@ -166,7 +167,7 @@ global $prefs; $default_notepad = $prefs->getValue('default_notepad'); - $notepads = Mnemo::listNotepads(false, $permission); + $notepads = &Mnemo::listNotepads(false, $permission); if (isset($notepads[$default_notepad])) { return $default_notepad; @@ -319,7 +320,7 @@ // Make sure all notepads exist now, to save on checking later. $_temp = $GLOBALS['display_notepads']; - $_all = Mnemo::listNotepads(); + $_all = &Mnemo::listNotepads(); $GLOBALS['display_notepads'] = array(); foreach ($_temp as $id) { if (isset($_all[$id])) { @@ -328,7 +329,7 @@ } if (count($GLOBALS['display_notepads']) == 0) { - $lists = Mnemo::listNotepads(true); + $lists = &Mnemo::listNotepads(true); if (!Auth::getAuth()) { /* All notepads for guests. */ $GLOBALS['display_notepads'] = array_keys($lists); Index: lib/prefs.php =================================================================== --- lib/prefs.php (Revision 2544) +++ lib/prefs.php (Revision 2549) @@ -18,7 +18,7 @@ $default_notepad = Util::getFormData('default_notepad'); if (!is_null($default_notepad)) { - $notepads = Mnemo::listNotepads(); + $notepads = &Mnemo::listNotepads(); if (is_array($notepads) && array_key_exists($default_notepad, $notepads)) { $prefs->setValue('default_notepad', $default_notepad); $updated = true; Index: lib/Block/summary.php =================================================================== --- lib/Block/summary.php (Revision 2544) +++ lib/Block/summary.php (Revision 2549) @@ -76,7 +76,7 @@ if (!empty($this->_params['show_notepad'])) { $owner = $memo['memolist_id']; - $share = $shares->getShare($owner); + $share = &$shares->getShare($owner); if (!is_a($share, 'PEAR_Error')) { $owner = $share->get('name'); } Index: templates/notepads/notepads.inc =================================================================== RCS file: /repository/mnemo/templates/notepads/notepads.inc,v retrieving revision 1.19 diff -u -B -r1.19 notepads.inc --- templates/notepads/notepads.inc 25 May 2007 02:54:37 -0000 1.19 +++ templates/notepads/notepads.inc 31 May 2007 07:45:50 -0000 @@ -2,10 +2,10 @@ var editURL = decodeURIComponent('<?php echo rawurlencode(Util::addParameter(Horde::url($registry->get('webroot', 'horde') . '/services/shares/edit.php?app=mnemo', true), 'share', '@ID@', false)) ?>'); var fields = []; -<?php foreach ($personal_notepads as $id => $notepads): ?> +<?php foreach (array_keys($personal_notepads) as $id): ?> fields['<?php echo htmlspecialchars($id) ?>'] = [ - "<?php echo rawurlencode(String::convertCharset($notepads->get('name'), NLS::getCharset(), 'UTF-8')) ?>", - "<?php echo rawurlencode(String::convertCharset($notepads->get('desc'), NLS::getCharset(), 'UTF-8')) ?>"]; + "<?php echo rawurlencode(String::convertCharset($personal_notepads[$id]->get('name'), NLS::getCharset(), 'UTF-8')) ?>", + "<?php echo rawurlencode(String::convertCharset($personal_notepads[$id]->get('desc'), NLS::getCharset(), 'UTF-8')) ?>"]; <?php endforeach; ?> function newChoice() @@ -42,8 +42,8 @@ <p><?php echo Horde::label('share', _("Notepads:")) ?><br /> <select id="share" name="share" onchange="javascript:newChoice()"> <option value="-1"><?php echo _("Select a notepad") ?></option> -<?php foreach ($personal_notepads as $id => $notepad): ?> - <option value="<?php echo htmlspecialchars($id) ?>"><?php echo htmlspecialchars($notepad->get('name')) ?></option> +<?php foreach (array_keys($personal_notepads) as $id): ?> + <option value="<?php echo htmlspecialchars($id) ?>"><?php echo htmlspecialchars($personal_notepads[$id]->get('name')) ?></option> <?php endforeach; ?> </select></p>