Skip to content

Commit

Permalink
Fix DAV URLs when using authusername hooks.
Browse files Browse the repository at this point in the history
  • Loading branch information
yunosh committed Mar 5, 2015
1 parent 83d4582 commit 05e9e51
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions mnemo/lib/Api.php
Expand Up @@ -90,27 +90,28 @@ public function browse($path = '', $properties = array())

$results = array();
foreach (array_keys($owners) as $owner) {
$path = 'mnemo/' . $registry->convertUsername($owner, false);
if (in_array('name', $properties)) {
$results['mnemo/' . $owner]['name'] = $injector
$results[$path]['name'] = $injector
->getInstance('Horde_Core_Factory_Identity')
->create($owner)
->getName();
}
if (in_array('icon', $properties)) {
$results['mnemo/' . $owner]['icon'] = Horde_Themes::img('user.png');
$results[$path]['icon'] = Horde_Themes::img('user.png');
}
if (in_array('browseable', $properties)) {
$results['mnemo/' . $owner]['browseable'] = true;
$results[$path]['browseable'] = true;
}
if (in_array('read-only', $properties)) {
$results['mnemo/' . $owner]['read-only'] = true;
$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-' ? '' : $parts[0];
$owner = $parts[0] == '-system-' ? '' : $registry->convertUsername($parts[0], true);
$notepads = $mnemo_shares->listShares(
$currentUser,
array('perm' => Horde_Perms::SHOW,
Expand All @@ -130,7 +131,9 @@ public function browse($path = '', $properties = array())
$results[$retpath]['displayname'] = Mnemo::getLabel($notepad);
}
if (in_array('owner', $properties)) {
$results[$retpath]['owner'] = $notepad->get('owner') ?: '-system-';
$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');
Expand Down Expand Up @@ -166,6 +169,9 @@ public function browse($path = '', $properties = array())
throw new Mnemo_Exception($e->getMessage, 500);
}
$icon = Horde_Themes::img('mnemo.png');
$owner = $notepad->get('owner')
? $registry->convertUsername($notepad->get('owner'), false)
: '-system-';
$results = array();
foreach ($storage->listMemos() as $memo) {
$body = $memo['body'] instanceof Mnemo_Exception
Expand All @@ -176,7 +182,7 @@ public function browse($path = '', $properties = array())
$results[$key]['name'] = $memo['desc'];
}
if (in_array('owner', $properties)) {
$results[$key]['owner'] = $notepad->get('owner') ?: '-system-';
$results[$key]['owner'] = $owner;
}
if (in_array('icon', $properties)) {
$results[$key]['icon'] = $icon;
Expand Down

0 comments on commit 05e9e51

Please sign in to comment.