Skip to content

Commit

Permalink
Add Mnemo_Api::addNotepad and ::updateNotepad
Browse files Browse the repository at this point in the history
  • Loading branch information
mrubinsk committed Nov 10, 2013
1 parent 4be1eeb commit 619ae02
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions mnemo/lib/Api.php
Expand Up @@ -485,4 +485,46 @@ public function getDefaultShare()
return Mnemo::getDefaultNotepad(Horde_Perms::EDIT);
}

/**
* Create a new notepad.
*
* @param string $name The notepad display name.
* @param array $params Any additional parameters needed.
*
* @return string The new notepad's id.
* @since 4.2.0
*/
public function addNotpad($name, array $params = array())
{
$notepad = $GLOBALS['mnemo_shares']->newShare(
$GLOBALS['registry']->getAuth(),
strval(new Horde_Support_Uuid()),
$name);

return $notepad->getName();
}

/**
* Update a notepad's title and/or description.
*
* @param string $id The notepad id
* @param array $info The data to change:
* - name: The display name.
* - desc: The description.
*
* @since 4.2.0
*/
public function updateNotepad($id, array $info)
{
$notepad = $GLOBALS['mnemo_shares']->getShare($id);
if (!empty($info['name'])) {
$notepad->set('name', $info['name']);
}
if (!empty($info['desc'])) {
$notepad->set('desc', $info['desc']);
}

$notepad->save();
}

}

0 comments on commit 619ae02

Please sign in to comment.