Add album only for administrators?

picaron

Joined: 2011-10-13
Posts: 3
Posted: Thu, 2011-10-13 21:34

Hello all, I wanted to make a query.
Is it possible to configure gallery3 Only administrators can add album?

We appreciate your help in this regard.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Fri, 2011-10-14 23:38

I wrote a module so that the admin is the only one to chnage permissions so I guess you culd use it as an example of how to override the add album link.
http://gallery.menalto.com/node/103795#comment-382315

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
picaron

Joined: 2011-10-13
Posts: 3
Posted: Sat, 2011-10-15 02:35

floridave, thank you very much for your help and your quick response.

My level of php is very low, but I made the following changes and I managed to limit so that only administrators can add album...

Quote:
if (identity::active_user()->admin) {
if ($item->is_album()) {
$add_menu->append(Menu::factory("dialog")
->id("add_album_item")
->label(t("Add an album"))
->url(url::site("form/add/albums/$item->id?type=album")));
}
}

... and I've disabled this part of the code ...

Quote:
} else {
$options_menu
->append(Menu::factory("dialog")
->id("add_item")
->label(t("Add a photo"))
->css_class("ui-icon-plus")
->url(url::site("uploader/index/$item->id")));
// ->append(Menu::factory("dialog")
// ->id("add_album")
// ->label(t("Add an album"))
// ->css_class("ui-icon-note")
// ->url(url::site("form/add/albums/$item->id?type=album")));

}

Initially everything works perfectly. Only admins can add album, but...

Can you tell me if they are correct?
Or maybe I did something crazy?

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sat, 2011-10-15 04:05

Looks OK to me.
If you manually edited core files you will have to continue to do a patch. Writing a simple module like the one I made, will allow you to just enable/disable/install/uninstall your module during an upgrade.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
picaron

Joined: 2011-10-13
Posts: 3
Posted: Sat, 2011-10-15 18:01

Ok, floridave, thank you very much for your help and for your time.