Skip to content

Commit

Permalink
Don't show icons for these if we don't have perms.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrubinsk committed Jan 19, 2017
1 parent 6269b7e commit c7ccb67
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 10 deletions.
49 changes: 42 additions & 7 deletions ansel/js/ansel.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,17 +449,52 @@ AnselCore =
this.galleryLayout.reset();
// @todo - real breadcrumb, display either "info" or "edit" depending
// on permissions?
$('anselGalleriesTitle').update(r.n).insert(
new Element('div', { 'class': 'ansel-gallery-desc' }).update(r.d)).insert(
new Element('div', { 'class': 'ansel-gallery-actions' }).insert(
new Element('img', { title: Ansel.text['slideshow_play'], src: Ansel.conf.images['slideshow_play'], 'class': 'ansel-gallery-slideshowplay' }).store('gid', r.id)).insert(
new Element('img', { title: Ansel.text['edit'], src: Ansel.conf.images['edit'], 'class': 'ansel-gallery-edit' }).store('gid', r.id)).insert(
new Element('img', { title: Ansel.text['download'], src: Ansel.conf.images['download'], 'class': 'ansel-gallery-download' })).insert(
new Element('img', { title: Ansel.text['upload'], src: Ansel.conf.images['upload'], 'class': 'ansel-gallery-upload' }).store('gid', r.id))
var actionDiv = new Element('div', {
'class': 'ansel-gallery-actions' }
).insert(
new Element('img', {
title: Ansel.text['slideshow_play'],
src: Ansel.conf.images['slideshow_play'],
'class': 'ansel-gallery-slideshowplay' }
).store('gid', r.id)
);

if (r.he) {
actionDiv.insert(
new Element('img', {
title: Ansel.text['edit'],
src: Ansel.conf.images['edit'],
'class': 'ansel-gallery-edit' }
).store('gid', r.id)
).insert(
new Element('img', {
title: Ansel.text['upload'],
src: Ansel.conf.images['upload'],
'class': 'ansel-gallery-upload' }
).store('gid', r.id)
);
}

if (r.dl) {
actionDiv.insert(
new Element('img', {
title: Ansel.text['download'],
src: Ansel.conf.images['download'],
'class': 'ansel-gallery-download' }
)
);
}

$('anselGalleriesTitle')
.update(r.n)
.insert(new Element('div', {
'class': 'ansel-gallery-desc' }).update(r.d)
).insert(actionDiv);

if (r.sg) {
this.galleryLayout.galleries = r.sg;
}

this.galleryLayout.addImages(r.imgs);
this.updateOtherGalleries(r);
},
Expand Down
16 changes: 13 additions & 3 deletions ansel/lib/Gallery.php
Original file line number Diff line number Diff line change
Expand Up @@ -1213,19 +1213,24 @@ public function unserialize($data)
* 'vm' - View mode
* 'sl' - gallery slug
* 't' - gallery tags
* 'hd' - current user has delete permission
* 'he' - current user has edit permission
* 'dl' - current user can download
* 'imgs' - an array of image objects with the following properties:
* 'id' - the image id
* 'url' - the image url
* </pre>
*/
public function toJson($level = 0, $mini = false)
{
global $registry;

// @TODO: Support date grouped galleries
$vMode = $this->get('view_mode');
if ($vMode != 'Normal') {
$this->_setModeHelper('Normal');
}
$horde_view = $GLOBALS['registry']->getView();
$horde_view = $registry->getView();

$style = Ansel::getStyleDefinition($horde_view == Horde_Registry::VIEW_DYNAMIC ? 'ansel_dynamic' : 'ansel_mobile');

Expand All @@ -1250,7 +1255,7 @@ public function toJson($level = 0, $mini = false)
$json->kid = $this->getKeyImage($style);
$json->imgs = array();
$json->ct = $this->countImages(true);
$json->cs = $this->countChildren($GLOBALS['registry']->getAuth(), Horde_Perms::SHOW, false);
$json->cs = $this->countChildren($registry->getAuth(), Horde_Perms::SHOW, false);
$json->o = $this->get('owner');
$json->on = $this->getIdentity()->getValue('fullname');

Expand All @@ -1265,14 +1270,19 @@ public function toJson($level = 0, $mini = false)
$json->pn = $p->get('name');
}

// Perms
$json->hd = $this->hasPermission($registry->getAuth(), Horde_Perms::DELETE);
$json->he = $this->hasPermission($registry->getAuth(), Horde_Perms::EDIT);
$json->dl = $this->canDownload();

if ($level & self::TO_JSON_SUBGALLERIES) {
$json->tiny =
($GLOBALS['conf']['image']['tiny'] &&
($GLOBALS['conf']['vfs']['src'] == 'direct' || $this->_share->hasPermission('', Horde_Perms::READ)));
$json->sg = array();
if ($this->hasSubGalleries()) {
$sgs = $this->getChildren(
$GLOBALS['registry']->getAuth(),
$registry->getAuth(),
Horde_Perms::READ,
false);
foreach ($sgs as $g) {
Expand Down

0 comments on commit c7ccb67

Please sign in to comment.