make gallery tree only show when logged in as administrator.

pbyjp
pbyjp's picture

Joined: 2002-11-12
Posts: 260
Posted: Wed, 2002-11-27 10:05

he he, another hard one...
would there be any way to pull that one off?
(and how)
I have a feeling that it s not that hard...
peace.
p

 
PuCK
PuCK's picture

Joined: 2002-11-20
Posts: 23
Posted: Wed, 2002-11-27 11:12

I think you have to place the If logged in function (found in almost every file :wink: ) in the breadcrumb.php on the right place? Like on the top, and close it below. Haven't tested it but I think it will look something like this (if this doesn't work try to place the if statement before the include of breadcrumb on each page) HAVEN'T TESTED THIS!!!!
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE>
if ($gallery->user->canWriteToAlbum($gallery->album)) {

--- breadcrumb.php code ---

}
</TD></TR></TABLE><!-- BBCode End -->

 
pbyjp
pbyjp's picture

Joined: 2002-11-12
Posts: 260
Posted: Wed, 2002-11-27 12:58

all right, I have no former knowledge of php and didn t really understand what you mean...
but you gave me an idea, I had a look around the forums and decided to find the function that displays the tree in the albums.php... it s close to the very bottom of the file.
and after some try outs, i replaced
(!strcmp($gallery->app->showAlbumTree, "yes"))
by
($gallery->user->isAdmin($gallery->album))
and providing that you put "yes" for show tree in your config pages, it worked like a charm....
yeepee... and under 30 minutes too.
now I wonder if there are hidden implecations but so far it works.
yupee.
cheers
p

 
PuCK
PuCK's picture

Joined: 2002-11-20
Posts: 23
Posted: Wed, 2002-11-27 13:26

Cool...I didn't really looked in the code if that was a function, but then again, you can set the gallery tree on or off, so you just changed the if statement from "yes" to "isadmin" A very good solution!

 
BorgKing
BorgKing's picture

Joined: 2002-09-12
Posts: 313
Posted: Thu, 2002-11-28 22:36

A good solution indeed, just one remark: when you replace
(!strcmp($gallery->app->showAlbumTree, "yes"))
by
($gallery->user->isAdmin($gallery->album))
it doesn't really matter what you set the value in the configuration to, it will always display the tree when you're logged in as admin. If you want it to matter, you should use both lines (an if within an if construction would work).

 
pbyjp
pbyjp's picture

Joined: 2002-11-12
Posts: 260
Posted: Fri, 2002-11-29 07:08

Thank you BorgKing.
I ll leave it like that. it works fine. and I don t know enough of php to be able to do that kind of code manipulation. :razz:
cheers.
p