/usr/share/horde/trean/lib/Trean.php is in php-horde-trean 1.1.4-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | <?php
/**
* Trean Base Class.
*
* Copyright 2002-2016 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (BSD). If you did not
* did not receive this file, see http://www.horde.org/licenses/bsdl.php.
*
* @author Mike Cochrane <mike@graftonhall.co.nz>
* @package Trean
*/
class Trean
{
/**
* Returns the specified permission for the current user.
*
* @param string $permission A permission, currently only 'max_folders'
* and 'max_bookmarks'.
*
* @return mixed The value of the specified permission.
*/
static function hasPermission($permission)
{
$perms = $GLOBALS['injector']->getInstance('Horde_Perms');
if (!$perms->exists('trean:' . $permission)) {
return true;
}
$allowed = $perms->getPermissions(
'trean:' . $permission, $GLOBALS['registry']->getAuth());
if (is_array($allowed)) {
switch ($permission) {
case 'max_folders':
case 'max_bookmarks':
$allowed = max($allowed);
break;
}
}
return $allowed;
}
/**
* Returns an apropriate icon for the given bookmark.
*
* @param Trean_Bookmark $bookmark The bookmark object.
*
* @return Horde_Url The URL for the image.
*/
static function getFavicon($bookmark)
{
if ($bookmark->favicon_url) {
return Horde::url('favicon.php')->add('bookmark_id', $bookmark->id);
} else {
// Default to the protocol icon.
$protocol = substr($bookmark->url, 0, strpos($bookmark->url, '://'));
return Horde_Themes::img('protocol/' . (empty($protocol) ? 'http' : $protocol) . '.png');
}
}
static public function addFeedLink()
{
$rss = Horde::url('rss.php', true, -1);
if ($label = Horde_Util::getFormData('label')) {
$rss->add('label', $label);
}
$GLOBALS['page_output']->addLinkTag(array(
'href' => $rss,
'title' => _("Bookmarks Feed")
));
}
static public function bookmarkletLink()
{
$view = $GLOBALS['injector']->createInstance('Horde_View');
$view->url = Horde::url('add.php', true, array('append_session' => -1))
->add('popup', 1);
$view->image = Horde::img('add.png');
return $view->render('bookmarklet');
}
}
|