"Image Viewed:" only seen by admin

tyman00
tyman00's picture

Joined: 2002-08-02
Posts: 107
Posted: Wed, 2003-07-16 21:48

See my reply first

Hello,

I am looking to keep the "Viewed:" portion visible in the Sub Albums, but only to those members that are logged in.

In view_album.php I am looking to make this portion only visible to the logged in members. This is for the images themselves. I did not copy the complete code in, but here is the section that I am working on.

---------Comments surrounded by dashes are notes I put in the coding to quide you guys along----------

<?php
			} else {
				echo($gallery->album->getCaption($i));
				// indicate with * if we have a comment for a given photo
				if ((!strcmp($gallery->album->fields["public_comments"], "yes")) && 
				   ($gallery->album->numComments($i) > 0)) {
					echo("<span class=error>*</span>");
					$displayCommentLegend = 1;
				
------------- This is where the actual "Viewed" portion begins----------------

					
					}
				echo("<br>");
							 
					if (!(strcmp($gallery->album->fields["display_clicks"] , "yes")) && !$gallery->session->offline && ($gallery->album->getItemClicks($i) > 0)) {
					echo("Viewed: ".pluralize($gallery->album->getItemClicks($i), "time", "0").".<br>");
								}	
			}
			echo "</span></td></tr></table>";

As I said this is for the actual images them selves, I got the Child Albums to convert over. Here is what I got out of that:

<br>
		 					

		----Here is where I changed the code to do as I wish----	

<?php if ($gallery->user->isLoggedIn()) { >     -------end-------				<span class="fineprint">
				   Changed: <?php echo $myAlbum->getLastModificationDate()?>.  <br>
				   Contains: <?php echo pluralize($myAlbum->numPhotos($gallery->user->canWriteToAlbum($myAlbum)), "item", "no")?>.<br>
				   <?php if (!(strcmp($gallery->album->fields["display_clicks"] , "yes")) &&  !$gallery->session->offline && ($myAlbum->getClicks() > 0)) { ?>
				   	Viewed: <?php echo pluralize($myAlbum->getClicks(), "time", "0")?>.<br>
				   	------begin----- <?php } ?>   -----end-----				   	<?php } ?>

I hope that makes sense, thanks for your help.

 
tyman00
tyman00's picture

Joined: 2002-08-02
Posts: 107
Posted: Fri, 2003-07-18 23:09

I figured it out now, I guess I just need to learn more PHP. I really have never programmed it before. All the PHP I have done has been guess work for me. I was trying to put an <?php if ($gallery->user->isLoggedIn()) { > statement inside an already opened statement. All I needed to do was just type in

if ($gallery->user->isLoggedIn()) {

then close it off.

Just thought I would share, it makes me feel good that I figured it out, not having a bit of knowledge with PHP.

 
r.stelz

Joined: 2003-08-02
Posts: 7
Posted: Sat, 2003-08-02 22:24

this seems to be quite a cool hack.
but i have got one problem:
if i turn off the "show clicks-dialogue" in the properties dialog, than the clicks aren´t counted anymore even if i hacked my gallery with this wonderful patch. admin can see all the hit´s and klicks (implemented it also in the view-album.php and album.php) but this seems to be useless when the hits arn´t counted anymore. if i turn on the "show clicks-dialogue" than all my visitors can see my clicks and hits and the patch is useless.

who can help me? :cry: :cry:

 
BorgKing
BorgKing's picture

Joined: 2002-09-12
Posts: 314
Posted: Sun, 2003-08-03 01:02

r.stelz, I don't understand what you're asking here.

First off, you're right that "Show clicks" has to be on for Gallery to count the number of clicks in an album. The default setting is that everyone can see this, and tyman00's patch made sure that only logged in users can see it.

 
tyman00
tyman00's picture

Joined: 2002-08-02
Posts: 107
Posted: Wed, 2003-08-06 14:48

I am using gallery to show inventory on our website.

I personally was interested in how many hits there were to each item, but I was sure that our customers could care less. So I went in and added the "if logged in ---> show" clause before the scripts where it calls in the number of hits.

What it does is this... if you are logged in then you can see it, if you did not log in then you cannot see it. You still need to have the "Show clicks" activated for your album defaults.

Hope that helps, if not let us know. I will try to answer... and if it gets to technical for me I am sure BorgKing can answer the question.... he is good at this kind of stuff!

 
tyman00
tyman00's picture

Joined: 2002-08-02
Posts: 107
Posted: Wed, 2003-08-06 14:52

If you want you can go to the website to see it in action. When not logged in.

www.BTandF.com/inventory

Unfortunately I cannot allow you to log in. I will tell you this, once you log in... it looks exactly the same as if you were to log into gallery without the patch.

 
nukestud
nukestud's picture

Joined: 2003-03-25
Posts: 114
Posted: Sun, 2003-08-31 00:23

I am lost, I added this code but I just get a parse error?

	<br>
				<?php if ($gallery->user->isLoggedIn()) { >
				<span class="fineprint">
				   Changed: <?php echo $myAlbum->getLastModificationDate()?>.  <br>
				   Contains: <?php echo pluralize($myAlbum->numPhotos($gallery->user->canWriteToAlbum($myAlbum)), "item", "no")?>.<br>
				   <?php if (!(strcmp($gallery->album->fields["display_clicks"] , "yes")) &&  !$gallery->session->offline && ($myAlbum->getClicks() > 0)) { ?>
				   	Viewed: <?php echo pluralize($myAlbum->getClicks(), "time", "0")?>.<br><?php } ?>
				   <?php } ?>
				</span>

How to close it off?

 
joan
joan's picture

Joined: 2002-10-21
Posts: 3473
Posted: Sun, 2003-08-31 07:01

what line is the parse error?

 
nukestud
nukestud's picture

Joined: 2003-03-25
Posts: 114
Posted: Sun, 2003-08-31 07:10

The same line I try and close it off! How do you close it off I wouldn't have a clue :-( With a "}" or a "<?" and where?

Quote:
All I needed to do was just type in

if ($gallery->user->isLoggedIn()) {

then close it off.

But how to close it off??

Thanks...

 
joan
joan's picture

Joined: 2002-10-21
Posts: 3473
Posted: Sun, 2003-08-31 07:23

I'm not reading the actual code above, but what you need to do is add a "}".

If you don't know where to add it, then you'll have to wait for someone who's implemented this to help you.

 
nukestud
nukestud's picture

Joined: 2003-03-25
Posts: 114
Posted: Sun, 2003-08-31 07:28

yeah I tried that on all the logical lines considering I don't know php nor what would be a logical place to put it. Tried about 10 diff spots just came back with parse errors or the line "if ($gallery->user->isLoggedIn()) {" would show up in on the page under album title :(

 
BorgKing
BorgKing's picture

Joined: 2002-09-12
Posts: 314
Posted: Sun, 2003-08-31 11:29

nukestud, first of all: when you want to make these kinds of changes to Gallery, learn (at least a bit of) PHP! Because if you know a bit of PHP this is really a simple question. And I'm saying this from experience. When I started to use Gallery I didn't know squad about PHP, but I learned it while _reading_ the forums and making changes.

Anyway, since I'm in a good work-avoiding mood today, here are the changes you need to make :)
Find <?php if (!(strcmp($gallery->album->fields["display_clicks"] , "yes")) && !$gallery->session->offline && ($myAlbum->getClicks() > 0)) { ?>and replace by<?php if (!(strcmp($gallery->album->fields["display_clicks"] , "yes")) && $gallery->user->isLoggedIn() && !$gallery->session->offline && ($myAlbum->getClicks() > 0)) { ?>
And find:if (!(strcmp($gallery->album->fields["display_clicks"] , "yes")) && !$gallery->session->offline && ($gallery->album->getItemClicks($i) > 0)) {and replace byif (!(strcmp($gallery->album->fields["display_clicks"] , "yes")) && $gallery->user->isLoggedIn() && !$gallery->session->offline && ($gallery->album->getItemClicks($i) > 0)) {

 
nukestud
nukestud's picture

Joined: 2003-03-25
Posts: 114
Posted: Sun, 2003-08-31 21:31

Thanks Borgking, I have been playing around with gallery/nuke for a few months now but for the life of me I can't seem to grasp the concept!

Looking at the code you sent I see where that extra code is supposed to go but I don't get it, if you know what I mean. I don't understand why it needed to go where it did :-(

Who knows maybe in a year or 2 I'll start understanding actually what I am hacking into lol

Thanks again for the help!