aboutsummaryrefslogtreecommitdiffstats
path: root/picture.php
diff options
context:
space:
mode:
authorgweltas <gweltas@piwigo.org>2004-01-18 23:46:57 +0000
committergweltas <gweltas@piwigo.org>2004-01-18 23:46:57 +0000
commitb81a4dbc62f9746b5861fd2d472b79f8a410c8dd (patch)
tree86f088a2a28db9500f8ba616287716a81feec50e /picture.php
parent5a7f683bd4f827f5d0a488888df4e41c6ce25077 (diff)
Favorite management
git-svn-id: http://piwigo.org/svn/branches/release-1_3@300 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'picture.php')
-rw-r--r--picture.php12
1 files changed, 10 insertions, 2 deletions
diff --git a/picture.php b/picture.php
index 067a271ea..de4adb2a3 100644
--- a/picture.php
+++ b/picture.php
@@ -492,7 +492,14 @@ $vtp->setVar( $handle, 'info_line.name', $lang['visited'].' : ' );
$vtp->setVar( $handle, 'info_line.content', $page['hit'].' '.$lang['times'] );
$vtp->closeSession( $handle, 'info_line' );
//------------------------------------------------------- favorite manipulation
-if ( $page['cat'] != 'fav' and !$user['is_the_guest'] )
+if ( !$user['is_the_guest'] )
+{
+ // verify if the picture is already in the favorite of the user
+ $query = 'SELECT COUNT(*) AS nb_fav FROM '.PREFIX_TABLE.'favorites WHERE image_id = '.$page['id'];
+ $query.= ' AND user_id = '.$user['id'].';';
+ $result = mysql_query( $query );
+ $row = mysql_fetch_array( $result );
+ if (!$row['nb_fav'])
{
$url = './picture.php?cat='.$page['cat'].'&amp;image_id='.$page['id'];
if (isset($_GET['expand']))
@@ -510,7 +517,7 @@ if ( $page['cat'] != 'fav' and !$user['is_the_guest'] )
$vtp->setVar( $handle, 'favorite.alt','[ '.$lang['add_favorites_alt'].' ]' );
$vtp->closeSession( $handle, 'favorite' );
}
-if ( $page['cat'] == 'fav' )
+else
{
$url = './picture.php?cat='.$page['cat'].'&amp;image_id='.$page['id'];
$url.= '&amp;expand='.$_GET['expand'].'&amp;add_fav=0';
@@ -522,6 +529,7 @@ if ( $page['cat'] == 'fav' )
$vtp->setVar( $handle, 'favorite.alt','[ '.$lang['del_favorites_alt'].' ]' );
$vtp->closeSession( $handle, 'favorite' );
}
+}
//------------------------------------ admin link for information modifications
if ( $user['status'] == 'admin' )
{