1<?php
2/**
3 * Imple for performing Ajax note editing.
4 *
5 * Copyright 2008-2017 Horde LLC (http://www.horde.org/)
6 *
7 * @author   Michael J Rubinsky <mrubinsk@horde.org>
8 * @category Horde
9 * @package  Mnemo
10 */
11class Mnemo_Ajax_Imple_EditNote extends Horde_Core_Ajax_Imple_InPlaceEditor
12{
13    /**
14     */
15    protected function _handleEdit(Horde_Variables $vars)
16    {
17        $storage = $GLOBALS['injector']->getInstance('Mnemo_Factory_Driver')->create();
18        $memo = $storage->getByUID($vars->id);
19
20        /* Are we requesting the unformatted text? */
21        if ($vars->action == 'load') {
22            return $memo['body'];
23        }
24
25        $share = $GLOBALS['mnemo_shares']->getShare($memo['memolist_id']);
26        if (!$share->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) {
27            throw new Horde_Exception_PermissionDenied(_("You do not have permission to edit this note."));
28        }
29
30        $storage->modify($memo['memo_id'], $memo['desc'], $vars->{$vars->input});
31
32        return $GLOBALS['injector']->getInstance('Horde_Core_Factory_TextFilter')->filter(
33            $vars->{$vars->input},
34            'text2html',
35            array('parselevel' => Horde_Text_Filter_Text2html::MICRO)
36        );
37    }
38
39}
40