diff options
author | z0rglub <z0rglub@piwigo.org> | 2003-10-04 16:08:53 +0000 |
---|---|---|
committer | z0rglub <z0rglub@piwigo.org> | 2003-10-04 16:08:53 +0000 |
commit | 151dc433708d67dad6e8e4b78a30dd52642394af (patch) | |
tree | d1db5e513af93d4cab01b7a271b942d93acd3dba | |
parent | 0a79e271552854aa920384fe45eec2359b95b8df (diff) |
Adding a page for non admin to see last users comments
git-svn-id: http://piwigo.org/svn/trunk@166 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r-- | category.php | 6 | ||||
-rw-r--r-- | comments.php | 174 | ||||
-rw-r--r-- | language/english.php | 5 | ||||
-rw-r--r-- | language/francais.php | 5 | ||||
-rw-r--r-- | template/default/comments.vtp | 119 |
5 files changed, 305 insertions, 4 deletions
diff --git a/category.php b/category.php index 8df696134..686a7508b 100644 --- a/category.php +++ b/category.php @@ -187,6 +187,12 @@ $vtp->setVar( $handle, 'summary.url', add_session_id( './search.php' ) ); $vtp->setVar( $handle, 'summary.title', $lang['hint_search'] ); $vtp->setVar( $handle, 'summary.name', replace_space( $lang['search'] ) ); $vtp->closeSession( $handle, 'summary' ); +// comments link +$vtp->addSession( $handle, 'summary' ); +$vtp->setVar( $handle, 'summary.url', add_session_id( './comments.php' ) ); +$vtp->setVar( $handle, 'summary.title', $lang['hint_comments'] ); +$vtp->setVar( $handle, 'summary.name', replace_space( $lang['comments'] ) ); +$vtp->closeSession( $handle, 'summary' ); // about link $vtp->addSession( $handle, 'summary' ); $vtp->setVar( $handle, 'summary.url', './about.php?'. diff --git a/comments.php b/comments.php new file mode 100644 index 000000000..b4802ace0 --- /dev/null +++ b/comments.php @@ -0,0 +1,174 @@ +<?php +/*************************************************************************** + * comments.php * + * ------------------- * + * application : PhpWebGallery 1.3 <http://phpwebgallery.net> * + * author : Pierrick LE GALL <pierrick@z0rglub.com> * + * * + * $Id$ + * * + ***************************************************************************/ + +/*************************************************************************** + * * + * 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; * + * * + ***************************************************************************/ + +include_once( './include/init.inc.php' ); +//------------------------------------------------------------------- functions +function display_pictures( $mysql_result, $maxtime, $forbidden_cat_ids ) +{ + global $vtp,$handle,$lang,$conf, + $array_cat_directories,$array_cat_site_id,$array_cat_names; + + while ( $row = mysql_fetch_array( $mysql_result ) ) + { + $vtp->addSession( $handle, 'picture' ); + // 1. find a category wich is authorized for the user to display a + // category name. + $query = 'SELECT category_id'; + $query.= ' FROM '.PREFIX_TABLE.'image_category'; + $query.= ' WHERE image_id = '.$row['image_id']; + if ( count( $forbidden_cat_ids ) > 0 ) + { + $query.= ' AND category_id NOT IN ('; + foreach ( $forbidden_cat_ids as $i => $restricted_cat ) { + if ( $i > 0 ) $query.= ','; + $query.= $restricted_cat; + } + $query.= ')'; + } + $query.= ' ORDER BY RAND()'; + $query.= ';'; + $subrow = mysql_fetch_array( mysql_query( $query ) ); + $category_id = $subrow['category_id']; + + if ( $array_cat_directories[$category_id] == '' ) + { + $array_cat_directories[$category_id] = + get_complete_dir( $category_id ); + $cat_result = get_cat_info( $category_id ); + $array_cat_site_id[$category_id] = $cat_result['site_id']; + $array_cat_names[$category_id] = + get_cat_display_name( $cat_result['name'], ' > ', '' ); + } + + // 2. for each picture, getting informations for displaying thumbnail and + // link to the full size picture + $query = 'SELECT name,file,storage_category_id as cat_id,tn_ext'; + $query.= ' FROM '.PREFIX_TABLE.'images'; + $query.= ' WHERE id = '.$row['image_id']; + $query.= ';'; + $subresult = mysql_query( $query ); + $subrow = mysql_fetch_array( $subresult ); + + if ( $array_cat_directories[$subrow['cat_id']] == '' ) + { + $array_cat_directories[$subrow['cat_id']] = + get_complete_dir( $subrow['cat_id'] ); + $cat_result = get_cat_info( $subrow['cat_id'] ); + $array_cat_site_id[$subrow['cat_id']] = $cat_result['site_id']; + $array_cat_names[$subrow['cat_id']] = + get_cat_display_name( $cat_result['name'], ' > ', '' ); + } + + $file = get_filename_wo_extension( $subrow['file'] ); + // name of the picture + $name = $array_cat_names[$category_id].' > '; + if ( $subrow['name'] != '' ) $name.= $subrow['name']; + else $name.= str_replace( '_', ' ', $file ); + $name.= ' [ '.$subrow['file'].' ]'; + $vtp->setVar( $handle, 'picture.title', $name ); + // source of the thumbnail picture + $src = $array_cat_directories[$subrow['cat_id']]; + $src.= 'thumbnail/'.$conf['prefix_thumbnail']; + $src.= $file.'.'.$subrow['tn_ext']; + $vtp->setVar( $handle, 'picture.thumb_src', $src ); + // link to the full size picture + $url = './picture.php?cat='.$category_id; + $url.= '&image_id='.$row['image_id']; + $vtp->setVar( $handle, 'picture.thumb_url', add_session_id( $url ) ); + // 3. for each picture, retrieving all comments + $query = 'SELECT id,date,author,content'; + $query.= ' FROM '.PREFIX_TABLE.'comments'; + $query.= ' WHERE image_id = '.$row['image_id']; + $query.= ' AND date > '.$maxtime; + $query.= " AND validated = 'true'"; + $query.= ' ORDER BY date DESC'; + $query.= ';'; + $handleresult = mysql_query( $query ); + while ( $subrow = mysql_fetch_array( $handleresult ) ) + { + $vtp->addSession( $handle, 'comment' ); + $author = $subrow['author']; + if ( $subrow['author'] == '' ) $author = $lang['guest']; + $vtp->setVar( $handle, 'comment.author', $author ); + $displayed_date = format_date( $subrow['date'], 'unix', true ); + $vtp->setVar( $handle, 'comment.date', $displayed_date ); + $vtp->setVar( $handle, 'comment.content', nl2br( $subrow['content'] ) ); + $vtp->closeSession( $handle, 'comment' ); + } + $vtp->closeSession( $handle, 'picture' ); + } +} +//----------------------------------------------------- template initialization +$vtp = new VTemplate; +$handle = $vtp->Open( './template/'.$user['template'].'/comments.vtp' ); +initialize_template(); +$tpl = array( 'title_comments','stats_last_days','search_return_main_page' ); +templatize_array( $tpl, 'lang', $handle ); +$vtp->setGlobalVar( $handle, 'text_color', $user['couleur_text'] ); +//--------------------------------------------------- number of days to display +if ( isset( $_GET['last_days'] ) ) define( MAX_DAYS, $_GET['last_days'] ); +else define( MAX_DAYS, 0 ); +//----------------------------------------- non specific section initialization +$array_cat_directories = array(); +$array_cat_names = array(); +$array_cat_site_id = array(); +//------------------------------------------------------- last comments display +foreach ( $conf['last_days'] as $option ) { + $vtp->addSession( $handle, 'last_day_option' ); + $vtp->setVar( $handle, 'last_day_option.option', $option ); + $url = './comments.php'; + $url.= '?last_days='.($option - 1); + $vtp->setVar( $handle, 'last_day_option.link', add_session_id( $url ) ); + $style = ''; + if ( $option == MAX_DAYS + 1 ) $style = 'text-decoration:underline;'; + $vtp->setVar( $handle, 'last_day_option.style', $style ); + $vtp->closeSession( $handle, 'last_day_option' ); +} +$vtp->setVar( $handle, 'back_url', add_session_id( './category.php' ) ); +if ( isset( $_GET['last_days'] ) ) +{ + // 1. retrieving picture ids which have comments recently added + $date = date( 'Y-m-d', time() - ( MAX_DAYS*24*60*60 ) ); + list($year,$month,$day) = explode( '-', $date); + $maxtime = mktime( 0,0,0,$month,$day,$year ); + $query = 'SELECT DISTINCT(ic.image_id) as image_id'; + $query.= ' FROM '.PREFIX_TABLE.'comments AS c'; + $query.= ', '.PREFIX_TABLE.'image_category AS ic'; + $query.= ' WHERE c.image_id = ic.image_id'; + $query.= ' AND date > '.$maxtime; + // we must not show pictures of a forbidden category + $restricted_cats = get_all_restrictions( $user['id'],$user['status'] ); + if ( count( $restricted_cats ) > 0 ) + { + $query.= ' AND category_id NOT IN ('; + foreach ( $restricted_cats as $i => $restricted_cat ) { + if ( $i > 0 ) $query.= ','; + $query.= $restricted_cat; + } + $query.= ')'; + } + $query.= ' ORDER BY ic.image_id DESC'; + $query.= ';'; + $result = mysql_query( $query ); + display_pictures( $result, $maxtime, $restricted_cats ); +} +//----------------------------------------------------------- html code display +$code = $vtp->Display( $handle, 0 ); +echo $code; +?>
\ No newline at end of file diff --git a/language/english.php b/language/english.php index 713580839..fa0fb8300 100644 --- a/language/english.php +++ b/language/english.php @@ -221,6 +221,9 @@ $lang['mail_new_upload_content'] = 'A new picture has been uploaded on the galle $lang['mail_new_comment_subject'] = 'New comment on website'; $lang['mail_new_comment_content'] = 'A new comment has been registered on the gallery. If you chose to validate each comment, you first have to validate this comment in the administration panel to make it visible in the gallery.'."\n\n".'You can see last comments in the administration panel'; $lang['connected_user'] = 'connected user'; +$lang['title_comments'] = 'Users comments'; +$lang['stats_last_days'] = 'last days'; +$lang['hint_comments'] = 'See last users comments'; //-------------------------------------------------------------- administration if ( $isadmin ) @@ -514,7 +517,6 @@ Once this file deleted , follow this instructions : $lang['title_user_perm'] = 'Modify permission for user'; $lang['title_cat_perm'] = 'Modify permissions for category'; $lang['title_group_perm'] = 'Modify permissions for group'; - $lang['title_comments'] = 'Users comments'; $lang['title_picmod'] = 'Modify informations about a picture'; $lang['menu_groups'] = 'Groups'; $lang['menu_comments'] = 'Comments'; @@ -559,7 +561,6 @@ Once this file deleted , follow this instructions : $lang['infoimage_removefromall'] = 'remove from all'; $lang['infoimage_associate'] = 'Associate to the category'; $lang['update_wrong_dirname'] = 'The name of directories and files must be composed of letters, figures, "-", "_" or "."'; - $lang['stats_last_days'] = 'last days'; $lang['stats_pages_seen'] = 'pages seen'; $lang['stats_visitors'] = 'guests'; $lang['stats_empty'] = 'empty history'; diff --git a/language/francais.php b/language/francais.php index c73de77e6..8157e528d 100644 --- a/language/francais.php +++ b/language/francais.php @@ -34,6 +34,8 @@ $lang['infos_title'] = 'Informations'; $lang['default'] = 'défaut'; $lang['comments'] = 'commentaires'; $lang['category_representative'] = 'représentant'; +$lang['title_comments'] = 'Commentaires des visiteurs'; +$lang['stats_last_days'] = 'derniers jours'; // end version 1.3 // page diapo @@ -64,6 +66,7 @@ $lang['nb_image_category'] = 'nombre d\'images dans la catégorie'; // start version 1.3 //$lang['connected_user_female'] = 'utilisatrice connectée'; $lang['connected_user'] = 'utilisateur connecté'; +$lang['hint_comments'] = 'Voir les derniers commentaires des visiteurs'; // end version 1.3 $lang['recent_image'] = 'image datant de moins de'; $lang['days'] = 'jours'; @@ -278,7 +281,6 @@ if ( $isadmin ) $lang['title_user_perm'] = 'Modifier les permissions pour l\'utilisateur'; $lang['title_cat_perm'] = 'Modifier les permissions pour la catégorie'; $lang['title_group_perm'] = 'Modifier les permissions pour le groupe'; - $lang['title_comments'] = 'Commentaires des visiteurs'; $lang['title_picmod'] = 'Modifier les informations d\'une image'; // end version 1.3 $lang['title_categories'] = 'Gestion des catégories'; @@ -609,7 +611,6 @@ if ( $isadmin ) $lang['tn_dirs_alone'] = 'images sans miniatures'; // start version 1.3 - $lang['stats_last_days'] = 'derniers jours'; $lang['stats_pages_seen'] = 'pages vues'; $lang['stats_visitors'] = 'visiteurs'; $lang['stats_empty'] = 'vider l\'historique'; diff --git a/template/default/comments.vtp b/template/default/comments.vtp new file mode 100644 index 000000000..133f9578c --- /dev/null +++ b/template/default/comments.vtp @@ -0,0 +1,119 @@ +<html> + <head> + {#style} + <title>{#title_comments}</title> + <meta http-equiv="Content-Type" content="text/html; {#charset}"> + <!-- Specific style to comments.php--> + <style type="text/css"> + .commentsAuthor,.commentsTitle,.commentsInfos,.commentsContent,.commentsNavigationBar { + color:{#text_color}; + font-family:arial,sans-Serif; + font-size:12px; + } + .commentsTitle,.commentsAuthor { + text-align:center; + font-weight:bold; + } + .commentsInfos { + margin:3px 3px 3px 10px; + font-size:11px; + text-align:right; + } + .commentsContent { + margin:10px; + } + .commentsTitle { + margin-top:15px; + } + .commentsAuthor { + margin:5px; + } + .commentsNavigationBar { + margin:10px; + } + .tableComment { + width:100%; + border:2px solid {#text_color}; + margin:10px; + } + .cellAuthor { + border-right:1px solid {#text_color}; + width:100px; + } + .cellInfo { + border-bottom:1px solid {#text_color}; + } + </style> + </head> + <body> + {#header} + <table style="width:100%;"> + <tr align="center" valign="middle"> + <td> + {#frame_start}1px{#frame_begin} + <div class="titrePage">{#title_comments}</div> + {#frame_end} + <div style="margin-bottom:20px"></div> + {#frame_start}90%{#frame_begin} +<table style="width:100%;"> + <tr> + <th> + [ + <!--VTP_last_day_option--> + <a href="{#link}" style="{#style}">{#option}</a>{#separation} + <!--/VTP_last_day_option--> + {#stats_last_days} + ] + [ <a href="{#back_url}">{#search_return_main_page}</a> ] + </th> + </tr> +</table> +<!--VTP_picture--> +<div style="border:2px solid gray;margin:2px;padding:2px;"> + <table style="width:100%;"> + <tr> + <td valign="top" width="1px"> + <!-- the thumbnail of the picture, linked to the full size page --> + <a href="{#thumb_url}" title="{#thumb_title}"> + <img src="{#thumb_src}" class="imgLink" alt="{#thumb_alt}"/> + </a> + </td> + <td style="padding:2px;"> + <div style="font-weight:bold;padding-left:10px;">{#title}</div> + <!--VTP_comment--> + <table style="width:100%;"> + <tr> + <td> + <table class="tableComment"> + <tr> + <td rowspan="2" valign="top" class="cellAuthor"> + <div class="commentsAuthor">{#author}</div> + </td> + <td class="cellInfo"> + <div class="commentsInfos"> + {#date}<!--VTP_delete--><a href="{#link}" title="{#comments_del}"><img src="../template/{#user_template}/admin/images/delete.gif" style="border:none;margin-left:5px;" alt="[{#delete}]"/></a><!--/VTP_delete--> + </div> + </td> + </tr> + <tr> + <td> + <div class="commentsContent">{#content}</div> + </td> + </tr> + </table> + </td> + </tr> + </table> + <!--/VTP_comment--> + </td> + </tr> + </table> +</div> +<!--/VTP_picture--> + {#frame_end} + </td> + </tr> + </table> + {#footer} + </body> +</html>
\ No newline at end of file |