mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-05-18 07:16:11 +02:00
bug fixed: create_navigation_bar take into account clean URL if requested.
deletion: argument link_class (HTML class of links) in function create_navigation_bar was removed, useless since branch 1.5. bug fixed: rate_items are now a configuration parameter (set in config file) modification: new functions library functions_rate.inc.php to reduce picture.php length. bug fixed: categories were never expanded in the menu since clean URLs. bug fixed: changing pictures sorting order in main page was always rederecting to root category. git-svn-id: http://piwigo.org/svn/trunk@1084 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
@@ -457,8 +457,8 @@ if (count($page['cat_elements_id']) > 0)
|
||||
$base_url.get_query_string_diff(array('start')),
|
||||
count($page['cat_elements_id']),
|
||||
$page['start'],
|
||||
$page['nb_images'],
|
||||
'');
|
||||
$page['nb_images']
|
||||
);
|
||||
$template->assign_vars(array('NAV_BAR' => $nav_bar));
|
||||
|
||||
$query = '
|
||||
|
||||
@@ -188,8 +188,8 @@ if (count($page['cat_elements_id']) > 0)
|
||||
$base_url.get_query_string_diff(array('start')),
|
||||
count($page['cat_elements_id']),
|
||||
$page['start'],
|
||||
$page['nb_images'],
|
||||
'');
|
||||
$page['nb_images']
|
||||
);
|
||||
$template->assign_vars(array('NAV_BAR' => $nav_bar));
|
||||
|
||||
|
||||
|
||||
+10
-7
@@ -132,13 +132,16 @@ list($nb_images) = mysql_fetch_row(pwg_query($query));
|
||||
|
||||
$template->set_filenames(array('rating'=>'admin/rating.tpl'));
|
||||
|
||||
$navbar = create_navigation_bar(
|
||||
PHPWG_ROOT_PATH.'admin.php'.get_query_string_diff(array('start','del')),
|
||||
$nb_images,
|
||||
$start,
|
||||
$elements_per_page,
|
||||
'');
|
||||
$template->assign_vars(array('NAVBAR' => $navbar));
|
||||
$template->assign_vars(
|
||||
array(
|
||||
'NAVBAR' => create_navigation_bar(
|
||||
PHPWG_ROOT_PATH.'admin.php'.get_query_string_diff(array('start','del')),
|
||||
$nb_images,
|
||||
$start,
|
||||
$elements_per_page,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
$template->assign_vars(
|
||||
|
||||
+1
-2
@@ -302,8 +302,7 @@ create_navigation_bar(
|
||||
$url,
|
||||
$page['nb_logs'],
|
||||
$page['start'],
|
||||
$conf['nb_logs_page'],
|
||||
'admin'
|
||||
$conf['nb_logs_page']
|
||||
);
|
||||
|
||||
$template->assign_block_vars(
|
||||
|
||||
+1
-2
@@ -747,8 +747,7 @@ $navbar = create_navigation_bar(
|
||||
$url,
|
||||
count($page['filtered_users']),
|
||||
$start,
|
||||
$conf['users_page'],
|
||||
''
|
||||
$conf['users_page']
|
||||
);
|
||||
|
||||
$template->assign_vars(array('NAVBAR' => $navbar));
|
||||
|
||||
+6
-5
@@ -28,6 +28,7 @@
|
||||
//--------------------------------------------------------------------- include
|
||||
define('PHPWG_ROOT_PATH','./');
|
||||
include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
|
||||
include(PHPWG_ROOT_PATH.'include/section_init.inc.php');
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Check Access and exit when user status is not ok |
|
||||
@@ -47,6 +48,7 @@ if ( isset( $_GET['act'] )
|
||||
$url = 'category.php';
|
||||
redirect( $url );
|
||||
}
|
||||
|
||||
//---------------------------------------------- change of image display order
|
||||
if (isset($_GET['image_order']))
|
||||
{
|
||||
@@ -57,14 +59,13 @@ if (isset($_GET['image_order']))
|
||||
);
|
||||
|
||||
redirect(
|
||||
make_index_URL(
|
||||
array(),
|
||||
array('image_order')
|
||||
duplicate_index_URL(
|
||||
array(), // nothing to redefine
|
||||
array('start') // changing display order goes back to section first page
|
||||
)
|
||||
);
|
||||
}
|
||||
//-------------------------------------------------------------- initialization
|
||||
include(PHPWG_ROOT_PATH.'include/section_init.inc.php');
|
||||
// detection of the start picture to display
|
||||
if (!isset($page['start']))
|
||||
{
|
||||
@@ -85,7 +86,7 @@ if (isset($page['cat_nb_images'])
|
||||
$page['cat_nb_images'],
|
||||
$page['start'],
|
||||
$user['nb_image_page'],
|
||||
'back'
|
||||
true
|
||||
);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -209,6 +209,9 @@ $conf['send_bcc_mail_webmaster'] = false;
|
||||
// elsewhere.
|
||||
$conf['check_upgrade_feed'] = true;
|
||||
|
||||
// rate_items: available rates for a picture
|
||||
$conf['rate_items'] = array(0,1,2,3,4,5);
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | metadata |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
@@ -1137,7 +1137,7 @@ function make_section_in_URL($params)
|
||||
|
||||
if (!isset($params['section']))
|
||||
{
|
||||
if (isset($params['section']))
|
||||
if (isset($params['category']))
|
||||
{
|
||||
$params['section'] = 'categories';
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ SELECT name,id,date_last,nb_images,global_rank
|
||||
{
|
||||
$query.= '
|
||||
AND (id_uppercat is NULL';
|
||||
if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) )
|
||||
if (isset($page['category']))
|
||||
{
|
||||
$query.= ' OR id_uppercat IN ('.$page['uppercats'].')';
|
||||
}
|
||||
|
||||
@@ -75,12 +75,14 @@ function get_icon($date)
|
||||
return $page['get_icon_cache'][$date];
|
||||
}
|
||||
|
||||
function create_navigation_bar($url, $nb_element, $start,
|
||||
$nb_element_page, $link_class)
|
||||
function create_navigation_bar(
|
||||
$url, $nb_element, $start, $nb_element_page, $clean_url = false
|
||||
)
|
||||
{
|
||||
global $lang, $conf;
|
||||
|
||||
$pages_around = $conf['paginate_pages_around'];
|
||||
$start_str = $clean_url ? '/start-' : '&start=';
|
||||
|
||||
$navbar = '';
|
||||
|
||||
@@ -102,10 +104,10 @@ function create_navigation_bar($url, $nb_element, $start,
|
||||
// link to first page ?
|
||||
if ($cur_page != 1)
|
||||
{
|
||||
$navbar.= '<a href="';
|
||||
$navbar.= $url;
|
||||
$navbar.= '" class="'.$link_class.'" rel="start">'.$lang['first_page'];
|
||||
$navbar.= '</a>';
|
||||
$navbar.=
|
||||
'<a href="'.$url.'" rel="start">'
|
||||
.$lang['first_page']
|
||||
.'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -113,17 +115,16 @@ function create_navigation_bar($url, $nb_element, $start,
|
||||
}
|
||||
$navbar.= ' | ';
|
||||
// link on previous page ?
|
||||
if ( $start != 0 )
|
||||
if ($start != 0)
|
||||
{
|
||||
$previous = $start - $nb_element_page;
|
||||
$navbar.= '<a href="';
|
||||
$navbar.= $url;
|
||||
if ($previous>0)
|
||||
{
|
||||
$navbar.= '&start='.$previous;
|
||||
}
|
||||
$navbar.= '" class="'.$link_class.'" rel="prev">'.$lang['previous_page'];
|
||||
$navbar.= '</a>';
|
||||
|
||||
$navbar.=
|
||||
'<a href="'
|
||||
.$url.($previous > 0 ? $start_str.$previous : '')
|
||||
.'" rel="prev">'
|
||||
.$lang['previous_page']
|
||||
.'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -133,9 +134,8 @@ function create_navigation_bar($url, $nb_element, $start,
|
||||
|
||||
if ($cur_page > $pages_around + 1)
|
||||
{
|
||||
$navbar.= ' <a href="';
|
||||
$navbar.= $url;
|
||||
$navbar.= '" class="'.$link_class.'">1</a>';
|
||||
$navbar.= ' <a href="'.$url.'">1</a>';
|
||||
|
||||
if ($cur_page > $pages_around + 2)
|
||||
{
|
||||
$navbar.= ' ...';
|
||||
@@ -154,43 +154,48 @@ function create_navigation_bar($url, $nb_element, $start,
|
||||
else if ($i != $cur_page)
|
||||
{
|
||||
$temp_start = ($i - 1) * $nb_element_page;
|
||||
$navbar.= ' <a href="';
|
||||
$navbar.= $url;
|
||||
if ($temp_start>0)
|
||||
{
|
||||
$navbar.= '&start='.$temp_start;
|
||||
}
|
||||
$navbar.= '" class="'.$link_class.'"';
|
||||
$navbar.='>'.$i.'</a>';
|
||||
|
||||
$navbar.=
|
||||
' '
|
||||
.'<a href="'.$url
|
||||
.($temp_start > 0 ? $start_str.$temp_start : '')
|
||||
.'">'
|
||||
.$i
|
||||
.'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$navbar.= ' <span class="pageNumberSelected">';
|
||||
$navbar.= $i.'</span>';
|
||||
$navbar.=
|
||||
' '
|
||||
.'<span class="pageNumberSelected">'
|
||||
.$i
|
||||
.'</span>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($cur_page < ($maximum - $pages_around))
|
||||
{
|
||||
$temp_start = ($maximum - 1) * $nb_element_page;
|
||||
|
||||
if ($cur_page < ($maximum - $pages_around - 1))
|
||||
{
|
||||
$navbar.= ' ...';
|
||||
}
|
||||
$navbar.= ' <a href="';
|
||||
$navbar.= $url.'&start='.$temp_start;
|
||||
$navbar.= '" class="'.$link_class.'">'.$maximum.'</a>';
|
||||
|
||||
$navbar.= ' <a href="'.$url.$start_str.$temp_start.'">'.$maximum.'</a>';
|
||||
}
|
||||
|
||||
$navbar.= ' | ';
|
||||
// link on next page ?
|
||||
if ( $nb_element > $nb_element_page
|
||||
&& $start + $nb_element_page < $nb_element )
|
||||
if ($nb_element > $nb_element_page
|
||||
and $start + $nb_element_page < $nb_element)
|
||||
{
|
||||
$next = $start + $nb_element_page;
|
||||
$navbar.= '<a href="';
|
||||
$navbar.= $url.'&start='.$next;
|
||||
$navbar.= '" class="'.$link_class.'" rel="next">'.$lang['next_page'].'</a>';
|
||||
|
||||
$navbar.=
|
||||
'<a href="'.$url.$start_str.$next.'" rel="next">'
|
||||
.$lang['next_page']
|
||||
.'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -202,10 +207,11 @@ function create_navigation_bar($url, $nb_element, $start,
|
||||
if ($cur_page != $maximum)
|
||||
{
|
||||
$temp_start = ($maximum - 1) * $nb_element_page;
|
||||
$navbar.= '<a href="';
|
||||
$navbar.= $url.'&start='.$temp_start;
|
||||
$navbar.= '" class="'.$link_class.'" rel="last">'.$lang['last_page'];
|
||||
$navbar.= '</a>';
|
||||
|
||||
$navbar.=
|
||||
'<a href="'.$url.$start_str.$temp_start.'" rel="last">'
|
||||
.$lang['last_page']
|
||||
.'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
<?php
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | PhpWebGallery - a PHP based picture gallery |
|
||||
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
|
||||
// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | branch : BSF (Best So Far)
|
||||
// | file : $RCSfile$
|
||||
// | last update : $Date: 2006-03-15 03:26:25 +0100 (mer, 15 mar 2006) $
|
||||
// | last modifier : $Author: rvelices $
|
||||
// | revision : $Revision: 1081 $
|
||||
// | revision : $Revision: 1081 $
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | This program is free software; you can redistribute it and/or modify |
|
||||
// | it under the terms of the GNU General Public License as published by |
|
||||
// | the Free Software Foundation |
|
||||
// | |
|
||||
// | This program is distributed in the hope that it will be useful, but |
|
||||
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
||||
// | General Public License for more details. |
|
||||
// | |
|
||||
// | You should have received a copy of the GNU General Public License |
|
||||
// | along with this program; if not, write to the Free Software |
|
||||
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
||||
// | USA. |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
/**
|
||||
* rate a picture by a user
|
||||
*
|
||||
* @param int user identifier
|
||||
* @param int image identifier
|
||||
* @param int rate
|
||||
* @return void
|
||||
*/
|
||||
function rate_picture($user_id, $image_id, $rate)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$query = '
|
||||
SELECT status
|
||||
FROM '.USER_INFOS_TABLE.'
|
||||
WHERE user_id = '.$user_id.'
|
||||
;';
|
||||
list($user_status) = mysql_fetch_array(pwg_query($query));
|
||||
|
||||
if ('guest' == $user_status
|
||||
or 'generic' == $user_status)
|
||||
{
|
||||
$user_anonymous = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$user_anonymous = false;
|
||||
}
|
||||
|
||||
if (isset($rate)
|
||||
and $conf['rate']
|
||||
and (!$user_anonymous or $conf['rate_anonymous'])
|
||||
and in_array($rate, $conf['rate_items']))
|
||||
{
|
||||
if ($user_anonymous)
|
||||
{
|
||||
$ip_components = explode('.', $_SERVER["REMOTE_ADDR"]);
|
||||
if (count($ip_components) > 3)
|
||||
{
|
||||
array_pop($ip_components);
|
||||
}
|
||||
$anonymous_id = implode ('.', $ip_components);
|
||||
|
||||
if (isset($_COOKIE['pwg_anonymous_rater']))
|
||||
{
|
||||
if ($anonymous_id != $_COOKIE['pwg_anonymous_rater'])
|
||||
{ // client has changed his IP adress or he's trying to fool us
|
||||
$query = '
|
||||
SELECT element_id
|
||||
FROM '.RATE_TABLE.'
|
||||
WHERE user_id = '.$user['id'].'
|
||||
AND anonymous_id = \''.$anonymous_id.'\'
|
||||
;';
|
||||
$already_there = array_from_query($query, 'element_id');
|
||||
|
||||
if (count($already_there) > 0)
|
||||
{
|
||||
$query = '
|
||||
DELETE
|
||||
FROM '.RATE_TABLE.'
|
||||
WHERE user_id = '.$user['id'].'
|
||||
AND anonymous_id = \''.$_COOKIE['pwg_anonymous_rater'].'\'
|
||||
AND element_id NOT IN ('.implode(',', $already_there).')
|
||||
;';
|
||||
pwg_query($query);
|
||||
}
|
||||
|
||||
$query = '
|
||||
UPDATE
|
||||
'.RATE_TABLE.'
|
||||
SET anonymous_id = \'' .$anonymous_id.'\'
|
||||
WHERE user_id = '.$user['id'].'
|
||||
AND anonymous_id = \'' . $_COOKIE['pwg_anonymous_rater'].'\'
|
||||
;';
|
||||
pwg_query($query);
|
||||
|
||||
setcookie(
|
||||
'pwg_anonymous_rater',
|
||||
$anonymous_id,
|
||||
strtotime('+10 years'),
|
||||
cookie_path()
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setcookie(
|
||||
'pwg_anonymous_rater',
|
||||
$anonymous_id,
|
||||
strtotime('+10 years'),
|
||||
cookie_path()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$query = '
|
||||
DELETE
|
||||
FROM '.RATE_TABLE.'
|
||||
WHERE element_id = '.$image_id.'
|
||||
AND user_id = '.$user_id.'
|
||||
';
|
||||
if (isset($anonymous_id))
|
||||
{
|
||||
$query.= ' AND anonymous_id = \''.$anonymous_id.'\'';
|
||||
}
|
||||
pwg_query($query);
|
||||
$query = '
|
||||
INSERT
|
||||
INTO '.RATE_TABLE.'
|
||||
(user_id,anonymous_id,element_id,rate,date)
|
||||
VALUES
|
||||
('
|
||||
.$user_id.','
|
||||
.(isset($anonymous_id) ? '\''.$anonymous_id.'\'' : "''").','
|
||||
.$image_id.','
|
||||
.$rate
|
||||
.',NOW())
|
||||
;';
|
||||
pwg_query($query);
|
||||
|
||||
// update of images.average_rate field
|
||||
$query = '
|
||||
SELECT ROUND(AVG(rate),2) AS average_rate
|
||||
FROM '.RATE_TABLE.'
|
||||
WHERE element_id = '.$image_id.'
|
||||
;';
|
||||
$row = mysql_fetch_array(pwg_query($query));
|
||||
$query = '
|
||||
UPDATE '.IMAGES_TABLE.'
|
||||
SET average_rate = '.$row['average_rate'].'
|
||||
WHERE id = '.$image_id.'
|
||||
;';
|
||||
pwg_query($query);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -129,30 +129,17 @@ if ($page['show_comments'])
|
||||
$row = mysql_fetch_array( pwg_query( $query ) );
|
||||
|
||||
// navigation bar creation
|
||||
$url = PHPWG_ROOT_PATH.'picture.php';
|
||||
$url.= get_query_string_diff(array('add_fav','start'));
|
||||
|
||||
// $url = duplicate_picture_URL(
|
||||
// array(),
|
||||
// array('start')
|
||||
// );
|
||||
|
||||
if (!isset($_GET['start'])
|
||||
or !is_numeric($_GET['start'])
|
||||
or (is_numeric($_GET['start']) and $_GET['start'] < 0))
|
||||
if (!isset($page['start']))
|
||||
{
|
||||
$page['start'] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$page['start'] = $_GET['start'];
|
||||
}
|
||||
|
||||
$page['navigation_bar'] = create_navigation_bar(
|
||||
$url,
|
||||
duplicate_picture_URL(array(), array('start')),
|
||||
$row['nb_comments'],
|
||||
$page['start'],
|
||||
$conf['nb_comment_page'],
|
||||
''
|
||||
true // We want a clean URL
|
||||
);
|
||||
|
||||
$template->assign_block_vars(
|
||||
@@ -198,7 +185,10 @@ SELECT id,author,date,image_id,content
|
||||
$template->assign_block_vars(
|
||||
'comments.comment.delete',
|
||||
array(
|
||||
'U_COMMENT_DELETE' => $url.'&del='.$row['id']
|
||||
'U_COMMENT_DELETE' =>
|
||||
$url_self
|
||||
.'&action=delete_comment'
|
||||
.'&comment_to_delete='.$row['id']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -30,8 +30,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
$rate_items = array(0,1,2,3,4,5);
|
||||
|
||||
if ($conf['rate'])
|
||||
{
|
||||
$query = '
|
||||
@@ -109,7 +107,7 @@ SELECT COUNT(rate) AS count
|
||||
)
|
||||
);
|
||||
|
||||
foreach ($rate_items as $num => $mark)
|
||||
foreach ($conf['rate_items'] as $num => $mark)
|
||||
{
|
||||
$template->assign_block_vars(
|
||||
'rate.rate_option',
|
||||
|
||||
+2
-109
@@ -27,6 +27,7 @@
|
||||
|
||||
define('PHPWG_ROOT_PATH','./');
|
||||
include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
|
||||
include_once(PHPWG_ROOT_PATH.'include/functions_rate.inc.php');
|
||||
include(PHPWG_ROOT_PATH.'include/section_init.inc.php');
|
||||
|
||||
// Check Access and exit when user status is not ok
|
||||
@@ -194,115 +195,7 @@ UPDATE '.CATEGORIES_TABLE.'
|
||||
}
|
||||
case 'rate' :
|
||||
{
|
||||
if (isset($_GET['rate'])
|
||||
and $conf['rate']
|
||||
and (!$user['is_the_guest'] or $conf['rate_anonymous'])
|
||||
and in_array($_GET['rate'], $rate_items))
|
||||
{
|
||||
if ($user['is_the_guest'])
|
||||
{
|
||||
$ip_components = explode('.', $_SERVER["REMOTE_ADDR"]);
|
||||
if (count($ip_components) > 3)
|
||||
{
|
||||
array_pop($ip_components);
|
||||
}
|
||||
$anonymous_id = implode ('.', $ip_components);
|
||||
|
||||
if (isset($_COOKIE['pwg_anonymous_rater']))
|
||||
{
|
||||
if ($anonymous_id != $_COOKIE['pwg_anonymous_rater'])
|
||||
{ // client has changed his IP adress or he's trying to fool us
|
||||
$query = '
|
||||
SELECT element_id FROM '. RATE_TABLE . '
|
||||
WHERE user_id=' . $user['id'] . '
|
||||
AND anonymous_id=\'' . $anonymous_id . '\'';
|
||||
$result = pwg_query($query);
|
||||
$already_there = array();
|
||||
while ($row = mysql_fetch_array($result))
|
||||
{
|
||||
array_push($already_there, $row['element_id']);
|
||||
}
|
||||
|
||||
if (count($already_there) > 0)
|
||||
{
|
||||
$query = '
|
||||
DELETE
|
||||
FROM '.RATE_TABLE.'
|
||||
WHERE user_id = '.$user['id'].'
|
||||
AND anonymous_id = \''.$_COOKIE['pwg_anonymous_rater'].'\'
|
||||
AND element_id NOT IN ('.implode(',', $already_there).')
|
||||
;';
|
||||
pwg_query($query);
|
||||
}
|
||||
|
||||
$query = '
|
||||
UPDATE
|
||||
'.RATE_TABLE.'
|
||||
SET anonymous_id = \'' .$anonymous_id.'\'
|
||||
WHERE user_id = '.$user['id'].'
|
||||
AND anonymous_id = \'' . $_COOKIE['pwg_anonymous_rater'].'\'
|
||||
;';
|
||||
pwg_query($query);
|
||||
|
||||
setcookie(
|
||||
'pwg_anonymous_rater',
|
||||
$anonymous_id,
|
||||
strtotime('+10 years'),
|
||||
cookie_path()
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setcookie(
|
||||
'pwg_anonymous_rater',
|
||||
$anonymous_id,
|
||||
strtotime('+10 years'),
|
||||
cookie_path()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$query = '
|
||||
DELETE
|
||||
FROM '.RATE_TABLE.'
|
||||
WHERE element_id = '.$page['image_id'] . '
|
||||
AND user_id = '.$user['id'].'
|
||||
';
|
||||
if (isset($anonymous_id))
|
||||
{
|
||||
$query.= ' AND anonymous_id = \''.$anonymous_id.'\'';
|
||||
}
|
||||
pwg_query($query);
|
||||
$query = '
|
||||
INSERT
|
||||
INTO '.RATE_TABLE.'
|
||||
(user_id,anonymous_id,element_id,rate,date)
|
||||
VALUES
|
||||
('
|
||||
.$user['id'].','
|
||||
.(isset($anonymous_id) ? '\''.$anonymous_id.'\'' : "''").','
|
||||
.$page['image_id'].','
|
||||
.$_GET['rate']
|
||||
.',NOW())
|
||||
;';
|
||||
pwg_query($query);
|
||||
|
||||
// update of images.average_rate field
|
||||
$query = '
|
||||
SELECT ROUND(AVG(rate),2) AS average_rate
|
||||
FROM '.RATE_TABLE.'
|
||||
WHERE element_id = '.$page['image_id'].'
|
||||
;';
|
||||
$row = mysql_fetch_array(pwg_query($query));
|
||||
$query = '
|
||||
UPDATE '.IMAGES_TABLE.'
|
||||
SET average_rate = '.$row['average_rate'].'
|
||||
WHERE id = '.$page['image_id'].'
|
||||
;';
|
||||
pwg_query($query);
|
||||
}
|
||||
|
||||
rate_picture($user['id'], $page['image_id'], $_GET['rate']);
|
||||
redirect($url_self);
|
||||
}
|
||||
case 'delete_comment' :
|
||||
|
||||
Reference in New Issue
Block a user