aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--admin.php1
-rw-r--r--admin/include/functions.php25
-rw-r--r--admin/rating.php260
-rw-r--r--include/functions_category.inc.php2
-rw-r--r--language/en_UK.iso-8859-1/admin.lang.php5
-rw-r--r--language/en_UK.iso-8859-1/common.lang.php2
-rw-r--r--language/fr_FR.iso-8859-1/admin.lang.php5
-rw-r--r--language/fr_FR.iso-8859-1/common.lang.php2
-rw-r--r--picture.php4
-rw-r--r--template/yoga/admin.tpl1
-rw-r--r--template/yoga/admin/rating.tpl76
11 files changed, 373 insertions, 10 deletions
diff --git a/admin.php b/admin.php
index 7b2ae8c70..2752fb0d9 100644
--- a/admin.php
+++ b/admin.php
@@ -83,6 +83,7 @@ $template->assign_vars(
'U_CAT_UPDATE'=> $link_start.'update',
'U_WAITING'=> $link_start.'waiting',
'U_COMMENTS'=> $link_start.'comments',
+ 'U_RATING'=> $link_start.'rating',
'U_CADDIE'=> $link_start.'element_set&cat=caddie',
'U_THUMBNAILS'=> $link_start.'thumbnail',
'U_USERS'=> $link_start.'user_list',
diff --git a/admin/include/functions.php b/admin/include/functions.php
index 7a82ae3ec..25bbadf84 100644
--- a/admin/include/functions.php
+++ b/admin/include/functions.php
@@ -1311,19 +1311,23 @@ UPDATE '.IMAGES_TABLE.'
/**
* update images.average_rate field
- *
+ * param int $element_id optional, otherwise applies to all
* @return void
*/
-function update_average_rate()
+function update_average_rate( $element_id=-1 )
{
$average_rates = array();
$query = '
SELECT element_id,
ROUND(AVG(rate),2) AS average_rate
- FROM '.RATE_TABLE.'
- GROUP BY element_id
-;';
+ FROM '.RATE_TABLE;
+ if ( $element_id != -1 )
+ {
+ $query .= ' WHERE element_id=' . $element_id;
+ }
+ $query .= ' GROUP BY element_id;';
+
$result = pwg_query($query);
while ($row = mysql_fetch_array($result))
{
@@ -1343,6 +1347,17 @@ SELECT element_id,
}
$fields = array('primary' => array('id'), 'update' => array('average_rate'));
mass_updates(IMAGES_TABLE, $fields, $datas);
+
+ $query='
+UPDATE '.IMAGES_TABLE .'
+ LEFT JOIN '.RATE_TABLE.' ON id=element_id
+ SET average_rate=NULL
+ WHERE element_id IS NULL';
+ if ( $element_id != -1 )
+ {
+ $query .= ' AND id=' . $element_id;
+ }
+ pwg_query($query);
}
/**
diff --git a/admin/rating.php b/admin/rating.php
new file mode 100644
index 000000000..a28eaba50
--- /dev/null
+++ b/admin/rating.php
@@ -0,0 +1,260 @@
+<?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-01-15 08:45:42 -0500 (Sun, 15 Jan 2006) $
+// | last modifier : $Author: nikrou $
+// | revision : $Revision: 1004 $
+// +-----------------------------------------------------------------------+
+// | 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. |
+// +-----------------------------------------------------------------------+
+
+if (!defined('PHPWG_ROOT_PATH'))
+{
+ die ("Hacking attempt!");
+}
+include_once(PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php');
+
+
+// +-----------------------------------------------------------------------+
+// | initialization |
+// +-----------------------------------------------------------------------+
+if (isset($_GET['start']) and is_numeric($_GET['start']))
+{
+ $start = $_GET['start'];
+}
+else
+{
+ $start = 0;
+}
+
+$elements_per_page=10;
+if (isset($_GET['display']) and is_numeric($_GET['display']))
+{
+ $elements_per_page = $_GET['display'];
+}
+
+$order_by_index=0;
+if (isset($_GET['order_by']) and is_numeric($_GET['order_by']))
+{
+ $order_by_index = $_GET['order_by'];
+}
+
+$display_filter= '';
+if (isset($_GET['display_filter']))
+{
+ if ( $_GET['display_filter']=='user' )
+ {
+ $display_filter= ' AND r.user_id <> ' . $conf['guest_id'];
+ $template->assign_vars( array(
+ 'DISPLAY_FILTER_USER_CHECKED'=>'checked="checked"'
+ )
+ );
+ }
+ elseif ( $_GET['display_filter']=='guest' )
+ {
+ $display_filter= ' AND r.user_id =' . $conf['guest_id'];
+ $template->assign_vars( array(
+ 'DISPLAY_FILTER_GUEST_CHECKED'=>'checked="checked"'
+ )
+ );
+ }
+}
+if ($display_filter=='')
+{
+ $template->assign_vars( array(
+ 'DISPLAY_FILTER_ALL_CHECKED'=>'checked="checked"'
+ )
+ );
+}
+
+if (isset($_GET['del']))
+{
+ $del_params = urldecode( $_GET['del'] );
+ parse_str($del_params, $vars);
+ if ( !is_numeric($vars['e']) or !is_numeric($vars['u']) )
+ {
+ die('Hacking attempt');
+ }
+ $query = '
+DELETE FROM '. RATE_TABLE .'
+WHERE element_id=' . $vars['e'] . '
+AND user_id=' . $vars['u'] . '
+AND anonymous_id=\'' . $vars['a'] . '\'
+;';
+ pwg_query($query);
+ update_average_rate( $vars['e'] );
+}
+
+$users = array();
+$query = '
+SELECT '.$conf['user_fields']['username'].' as username, '.$conf['user_fields']['id'].' as id
+ FROM '.USERS_TABLE.'
+;';
+$result = pwg_query($query);
+while ($row = mysql_fetch_array($result))
+{
+ $users[$row['id']]=$row['username'];
+}
+
+
+$query = 'SELECT COUNT(DISTINCT(i.id))
+FROM '.RATE_TABLE.' AS r, '.IMAGES_TABLE.' AS i
+WHERE r.element_id=i.id'. $display_filter .
+';';
+list($nb_images) = mysql_fetch_row(pwg_query($query));
+
+
+// +-----------------------------------------------------------------------+
+// | template init |
+// +-----------------------------------------------------------------------+
+
+$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(
+ 'F_ACTION' => PHPWG_ROOT_PATH.'admin.php',
+ 'DISPLAY' => $elements_per_page,
+ 'NB_ELEMENTS' => $nb_images
+ )
+ );
+
+$available_order_by= array(
+ array(l10n('Rate date'), 'recently_rated DESC'),
+ array(l10n('Average rate'), 'average_rate DESC'),
+ array(l10n('Number of rates'), 'nb_rates DESC'),
+ array(l10n('Sum of rates'), 'sum_rates DESC'),
+ array(l10n('Controversy'), 'std_rates DESC'),
+ array(l10n('File name'), 'file DESC'),
+ array(l10n('Creation date'), 'date_creation DESC'),
+ array(l10n('Availability date'), 'date_available DESC'),
+
+ );
+
+for ($i=0; $i<count($available_order_by); $i++)
+{
+ $template->assign_block_vars(
+ 'order_by',
+ array(
+ 'VALUE' => $i,
+ 'CONTENT' => $available_order_by[$i][0],
+ 'SELECTED' => $i==$order_by_index ? 'SELECTED' : ''
+ )
+ );
+}
+
+$query = 'SELECT i.id, i.path, i.file, i.tn_ext, i.average_rate, i.storage_category_id,
+ MAX(r.date) as recently_rated, COUNT(r.rate) as nb_rates,
+ SUM(r.rate) as sum_rates, ROUND(STD(r.rate),2) as std_rates
+FROM '.RATE_TABLE.' AS r LEFT JOIN '.IMAGES_TABLE.' AS i
+ON r.element_id=i.id
+WHERE 1=1 ' . $display_filter . '
+GROUP BY r.element_id
+ORDER BY ' . $available_order_by[$order_by_index][1] .'
+LIMIT '.$start.','.$elements_per_page .
+';';
+
+$images = array();
+$result = pwg_query($query);
+while ($row = mysql_fetch_array($result))
+{
+ array_push($images, $row);
+}
+
+foreach ($images as $image)
+{
+ $thumbnail_src = get_thumbnail_src(
+ $image['path'], $image['tn_ext']
+ );
+
+ $image_url = PHPWG_ROOT_PATH.'picture.php?'.
+ 'cat=' . $image['storage_category_id'].
+ '&amp;image_id=' . $image['id'];
+
+ $query = 'SELECT *
+FROM '.RATE_TABLE.' AS r
+WHERE r.element_id='.$image['id'] . '
+ORDER BY date DESC;';
+ $result = pwg_query($query);
+ $nb_rates = mysql_num_rows($result);
+
+ $template->assign_block_vars('image',
+ array(
+ 'U_THUMB' => $thumbnail_src,
+ 'U_URL' => $image_url,
+ 'AVG_RATE' => $image['average_rate'],
+ 'STD_RATE' => $image['std_rates'],
+ 'SUM_RATE' => $image['sum_rates'],
+ 'NB_RATES' => $image['nb_rates'],
+ 'NB_RATES_TOTAL' => $nb_rates,
+ 'FILE' => $image['file'],
+ 'NB_RATES_PLUS1' => $nb_rates+1,
+ )
+ );
+
+ while ($row = mysql_fetch_array($result))
+ {
+
+ $url_del = PHPWG_ROOT_PATH.'admin.php'.
+ get_query_string_diff(array('del'));
+
+ $del_param = 'e='.$image[id].
+ '&u='.$row['user_id'].
+ '&a='.$row['anonymous_id'];
+
+ $url_del .= '&amp;del='.urlencode(urlencode($del_param));
+
+ if ( isset($users[$row['user_id']]) )
+ {
+ $user = $users[$row['user_id']];
+ }
+ else
+ {
+ $user = '? '. $row['user_id'];
+ }
+ if ( strlen($row['anonymous_id'])>0 )
+ {
+ $user .= '('.$row['anonymous_id'].')';
+ }
+
+ $template->assign_block_vars('image.rate',
+ array(
+ 'DATE' => format_date($row['date']),
+ 'RATE' => $row['rate'],
+ 'USER' => $user,
+ 'U_DELETE' => $url_del
+ )
+ );
+ }
+}
+//print_r($template->_tpldata);
+// +-----------------------------------------------------------------------+
+// | sending html code |
+// +-----------------------------------------------------------------------+
+$template->assign_var_from_handle('ADMIN_CONTENT', 'rating');
+?> \ No newline at end of file
diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php
index 30f91dd65..548e5fe35 100644
--- a/include/functions_category.inc.php
+++ b/include/functions_category.inc.php
@@ -259,7 +259,7 @@ function get_category_preferred_image_orders()
global $conf;
return array(
array('Default', '', true),
- array(l10n('best_rated_cat'), 'average_rate DESC', $conf['rate']),
+ array(l10n('Average rate'), 'average_rate DESC', $conf['rate']),
array(l10n('most_visited_cat'), 'hit DESC', true),
array(l10n('Creation date'), 'date_creation DESC', true),
array(l10n('Availability date'), 'date_available DESC', true),
diff --git a/language/en_UK.iso-8859-1/admin.lang.php b/language/en_UK.iso-8859-1/admin.lang.php
index abced94ae..375695195 100644
--- a/language/en_UK.iso-8859-1/admin.lang.php
+++ b/language/en_UK.iso-8859-1/admin.lang.php
@@ -53,6 +53,7 @@ $lang['Categories authorized thanks to group associations'] = 'Categories author
$lang['Check for upgrade failed for unknown reasons.'] = 'Check for upgrade failed for unknown reasons.';
$lang['Check for upgrade'] = 'Check for upgrade';
$lang['Comments for all'] = 'Comments for all';
+$lang['Controversy'] = 'Controversy';
$lang['Creation date'] = 'Creation date';
$lang['Database'] = 'Database';
$lang['Delete Representant'] = 'Delete Representant';
@@ -97,6 +98,7 @@ $lang['New parent category'] = 'New parent category';
$lang['No'] = 'No';
$lang['Number of comments per page'] = 'Number of comments per page';
$lang['Number of images per row'] = 'Number of images per row';
+$lang['Number of rates'] = 'Number of rates';
$lang['Number of rows per page'] = 'Number of rows per page';
$lang['Number of thumbnails to create'] = 'Number of thumbnails to create';
$lang['Only private categories are listed'] = 'Only private categories are listed';
@@ -116,6 +118,8 @@ $lang['Position'] = 'Position';
$lang['Preferences'] = 'Preferences';
$lang['Properties'] = 'Properties';
$lang['Random picture'] = 'Random picture';
+$lang['Rate date'] = 'Rate date';
+$lang['Rating'] = 'Rating';
$lang['Recent period'] = 'Recent period';
$lang['Registration date'] = 'Registration date';
$lang['Reject All'] = 'Reject All';
@@ -133,6 +137,7 @@ $lang['Show number of comments'] = 'Show number of comments';
$lang['Status'] = 'Status';
$lang['Storage category'] = 'Storage category';
$lang['Submit'] = 'Submit';
+$lang['Sum of rates'] = 'Sum of rates';
$lang['Take selected elements out of caddie'] = 'Take selected elements out of caddie';
$lang['Unable to check for upgrade since allow_url_fopen is disabled.'] = 'Unable to check for upgrade since allow_url_fopen is disabled.';
$lang['User comments validation'] = 'User comments validation';
diff --git a/language/en_UK.iso-8859-1/common.lang.php b/language/en_UK.iso-8859-1/common.lang.php
index ccc53e24d..39dbf5ad4 100644
--- a/language/en_UK.iso-8859-1/common.lang.php
+++ b/language/en_UK.iso-8859-1/common.lang.php
@@ -90,6 +90,7 @@ $lang['Password'] = 'Password';
$lang['PhpWebGallery Help'] = 'PhpWebGallery Help';
$lang['Profile'] = 'Profile';
$lang['Quick connect'] = 'Quick connect';
+$lang['Rate'] = 'Rate';
$lang['RSS feed'] = 'RSS feed';
$lang['Register'] = 'Register';
$lang['Registered on'] = 'Registered on';
@@ -296,7 +297,6 @@ $lang['thumbnails'] = 'Thumbnails';
$lang['title_comments'] = 'Users comments';
$lang['title_menu'] = 'Menu';
$lang['title_send_mail'] = 'A comment on your site';
-$lang['to_rate'] = 'Rate';
$lang['today'] = 'today';
$lang['total'] = 'images';
$lang['update_rate'] = 'Update your rating';
diff --git a/language/fr_FR.iso-8859-1/admin.lang.php b/language/fr_FR.iso-8859-1/admin.lang.php
index 012184528..c369d727f 100644
--- a/language/fr_FR.iso-8859-1/admin.lang.php
+++ b/language/fr_FR.iso-8859-1/admin.lang.php
@@ -53,6 +53,7 @@ $lang['Categories authorized thanks to group associations'] = 'Catégories access
$lang['Check for upgrade failed for unknown reasons.'] = 'La vérification de la dernière version sur le serveur a échouée pour une raison inconnue.';
$lang['Check for upgrade'] = 'Dernière version ?';
$lang['Comments for all'] = 'Commentaires utilisateur pour tous';
+$lang['Controversy'] = 'Controverse';
$lang['Creation date'] = 'Date de création';
$lang['Database'] = 'Base de données';
$lang['Delete Representant'] = 'Supprimer le représentant';
@@ -97,6 +98,7 @@ $lang['New parent category'] = 'Nouvelle catégorie parente';
$lang['No'] = 'Non';
$lang['Number of comments per page'] = 'Nombre de commentaires utilisateur par page';
$lang['Number of images per row'] = 'Nombre de miniatures par ligne';
+$lang['Number of rates'] = 'Nombre de notes';
$lang['Number of rows per page'] = 'Nombre de lignes par page';
$lang['Number of thumbnails to create'] = 'Nombre de miniatures à créer';
$lang['Only private categories are listed'] = 'Seules les catégories privées sont listées';
@@ -116,6 +118,8 @@ $lang['Position'] = 'Position';
$lang['Preferences'] = 'Préférences';
$lang['Properties'] = 'Propriétés';
$lang['Random picture'] = 'Au hasard';
+$lang['Rate date'] = 'Date de notation';
+$lang['Rating'] = 'Notation';
$lang['Recent period'] = 'Période récente';
$lang['Registration date'] = 'Date d\'enregistrement';
$lang['Reject All'] = 'Tout rejeter';
@@ -133,6 +137,7 @@ $lang['Show number of comments'] = 'Montrer le nombre de commentaires';
$lang['Status'] = 'Statut';
$lang['Storage category'] = 'Catégorie de stockage';
$lang['Submit'] = 'Valider';
+$lang['Sum of rates'] = 'Somme des notes';
$lang['Take selected elements out of caddie'] = 'Sortir les éléments sélectionnés du panier';
$lang['Unable to check for upgrade since allow_url_fopen is disabled.'] = 'Impossible de connaître la dernière version cat la fonction allow_url_fopen est désactivée.';
$lang['User comments validation'] = 'Validation des commentaires utilisateur';
diff --git a/language/fr_FR.iso-8859-1/common.lang.php b/language/fr_FR.iso-8859-1/common.lang.php
index d6782367a..4227b2598 100644
--- a/language/fr_FR.iso-8859-1/common.lang.php
+++ b/language/fr_FR.iso-8859-1/common.lang.php
@@ -89,6 +89,7 @@ $lang['Password'] = 'Mot de passe';
$lang['PhpWebGallery Help'] = 'Aide de PhpWebGallery';
$lang['Profile'] = 'Profil';
$lang['Quick connect'] = 'Connexion rapide';
+$lang['Rate'] = 'Note';
$lang['RSS feed'] = 'flux RSS';
$lang['Register'] = 'S\'enregistrer';
$lang['Registered on'] = 'Enregistrée le';
@@ -295,7 +296,6 @@ $lang['thumbnails'] = 'Miniatures';
$lang['title_comments'] = 'Commentaires utilisateurs';
$lang['title_menu'] = 'Menu';
$lang['title_send_mail'] = 'Un commentaire sur le site';
-$lang['to_rate'] = 'Note';
$lang['today'] = 'aujourd\'hui';
$lang['total'] = 'images';
$lang['update_rate'] = 'Mettre à jour votre note';
diff --git a/picture.php b/picture.php
index 772428e71..23716e4c5 100644
--- a/picture.php
+++ b/picture.php
@@ -1042,12 +1042,12 @@ SELECT COUNT(rate) AS count
}
else
{
- $sentence = $lang['never_rated'].'. '.$lang['to_rate'];
+ $sentence = $lang['never_rated'].'. '.$lang['Rate'];
}
}
else
{
- $sentence = $lang['never_rated'].'. '.$lang['to_rate'];
+ $sentence = $lang['never_rated'].'. '.$lang['Rate'];
}
$template->assign_block_vars(
'rate',
diff --git a/template/yoga/admin.tpl b/template/yoga/admin.tpl
index c5b8e7e03..9c37ae52c 100644
--- a/template/yoga/admin.tpl
+++ b/template/yoga/admin.tpl
@@ -52,6 +52,7 @@
<li><a href="{U_WAITING}">{lang:waiting}</a></li>
<li><a href="{U_THUMBNAILS}">{lang:thumbnails}</a></li>
<li><a href="{U_COMMENTS}">{lang:comments}</a></li>
+ <li><a href="{U_RATING}">{lang:Rating}</a></li>
<li><a href="{U_CADDIE}">{lang:Caddie}</a></li>
</ul>
</dd>
diff --git a/template/yoga/admin/rating.tpl b/template/yoga/admin/rating.tpl
new file mode 100644
index 000000000..7bc688deb
--- /dev/null
+++ b/template/yoga/admin/rating.tpl
@@ -0,0 +1,76 @@
+<h2>{lang:Rating} [{NB_ELEMENTS} {lang:elements}]</h2>
+
+<form action="" method="GET" id="update">
+<input type="hidden" name="page" value="rating" />
+<fieldset>
+
+<ul>
+
+<li><label>{lang:elements per page}: <input type="text" name="display" size="2" value="{DISPLAY}"></label></li>
+
+<li>
+<label>{lang:Sort by}:
+<select name="order_by">
+<!-- BEGIN order_by -->
+<option value="{order_by.VALUE}" {order_by.SELECTED}>{order_by.CONTENT}</option>
+<!-- END order_by -->
+</select>
+</label></li>
+
+<li>{lang:Filter}:
+<label>
+ <input type="radio" class="radio" name="display_filter" {DISPLAY_FILTER_ALL_CHECKED} value="all"/>
+ {lang:users} & {lang:guest}
+</label>
+<label>
+ <input type="radio" class="radio" name="display_filter" {DISPLAY_FILTER_USER_CHECKED} value="user"/>
+ {lang:users}
+</label>
+<label>
+ <input type="radio" class="radio" name="display_filter" {DISPLAY_FILTER_GUEST_CHECKED} value="guest"/>
+ {lang:guest}
+</label>
+</li>
+
+</ul>
+
+</fieldset>
+<p class="bottomButtons">
+<input type="submit" value="{lang:Submit}" />
+</p>
+</form>
+
+<div class="navigationBar">{NAVBAR}</div>
+
+<table width="100%">
+<tr class="throw">
+ <td>{lang:File}</td>
+ <td>{lang:Number of rates}</td>
+ <td>{lang:Average rate}</td>
+ <td>{lang:Controversy}</td>
+ <td>{lang:Sum of rates}</td>
+ <td>{lang:Rate}</td>
+ <td>{lang:Username}</td>
+ <td>{lang:Rate date}</td>
+ <td></td>
+</tr>
+<!-- BEGIN image -->
+<tr valign="bottom">
+ <td rowspan="{image.NB_RATES_PLUS1}"><a href="{image.U_URL}"><img src="{image.U_THUMB}" alt="{image.FILE}" title="{image.FILE}"></a></td>
+ <td rowspan="{image.NB_RATES_PLUS1}"><strong>{image.NB_RATES}/{image.NB_RATES_TOTAL}</strong></td>
+ <td rowspan="{image.NB_RATES_PLUS1}"><strong>{image.AVG_RATE}</strong></td>
+ <td rowspan="{image.NB_RATES_PLUS1}"><strong>{image.STD_RATE}</strong></td>
+ <td rowspan="{image.NB_RATES_PLUS1}" style="border-right: 1px solid;" ><strong>{image.SUM_RATE}</strong></td>
+</tr>
+<!-- BEGIN rate -->
+<tr>
+ <td>{image.rate.RATE}</td>
+ <td><b>{image.rate.USER}</b></td>
+ <td><span class="date">{image.rate.DATE}</span></td>
+ <td><a href="{image.rate.U_DELETE}"><img src="{themeconf:icon_dir}/delete.png" class="button" style="border:none;vertical-align:middle; margin-left:5px;" alt="[{lang:delete}]"/></a></td>
+</tr>
+<!-- END rate -->
+<!-- END image -->
+</table>
+
+<div class="navigationBar">{NAVBAR}</div>