Changeset 393 for trunk/comments.php


Ignore:
Timestamp:
Mar 20, 2004, 1:52:37 AM (20 years ago)
Author:
gweltas
Message:
  • Template migration
  • Admin Control Panel migration
  • Language migration
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/comments.php

    r369 r393  
    2727
    2828//----------------------------------------------------------- include
    29 define('PHPWG_ROOT_PATH','./');
    30 include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
     29if (!defined('IN_ADMIN'))
     30{
     31  define('PHPWG_ROOT_PATH','./');
     32  include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
     33}
    3134
    3235//--------------------------------------------------- number of days to display
     
    3740$array_cat_names       = array();
    3841$array_cat_site_id     = array();
     42
     43// comment deletion
     44if ( isset( $_POST['delete'] ) )
     45{
     46  $mod_sql='';
     47  while( list($id, $row_id) = @each($_POST['comment_id']) )
     48  {
     49        $mod_sql .= ( ( $mod_sql != '' ) ? ', ' : '' ) . $row_id;
     50  }
     51  $query = 'DELETE FROM '.COMMENTS_TABLE.' WHERE id IN ('.$mod_sql.');';
     52  mysql_query( $query );
     53}
     54
     55//--------------------------------------------------------- comments validation
     56if ( isset( $_POST['validate'] ) )
     57{
     58  $mod_sql='';
     59  while( list($id, $row_id) = @each($_POST['comment_id']) )
     60  {
     61        $mod_sql .= ( ( $mod_sql != '' ) ? ', ' : '' ) . $row_id;
     62  }
     63  $query = 'UPDATE '.COMMENTS_TABLE;
     64  $query.= " SET validated = 'true'";
     65  $query.=' WHERE id IN ('.$mod_sql.');';
     66  mysql_query( $query );
     67}
    3968//------------------------------------------------------- last comments display
    4069
     
    4271// Start output of page
    4372//
    44 $title= $lang['title_comments'];
    45 include(PHPWG_ROOT_PATH.'include/page_header.php');
     73if (!defined('IN_ADMIN'))
     74{
     75  $title= $lang['title_comments'];
     76  include(PHPWG_ROOT_PATH.'include/page_header.php');
     77}
    4678
    4779$template->set_filenames( array('comments'=>'comments.tpl') );
    48 initialize_template();
    49 
    5080$template->assign_vars(array(
    51   'L_TITLE' => $lang['title_comments'],
    52   'L_STATS' => $lang['stats_last_days'],
    53   'L_RETURN' => $lang['search_return_main_page'],
     81  'L_COMMENT_TITLE' => $title,
     82  'L_COMMENT_STATS' => $lang['stats_last_days'],
     83  'L_COMMENT_RETURN' => $lang['search_return_main_page'],
     84  'L_DELETE' =>$lang['delete'],
     85  'L_VALIDATE'=>$lang['submit'],
    5486 
    55   'U_HOME' => add_session_id( 'category.php' )
     87  'T_DEL_IMG' =>PHPWG_ROOT_PATH.'template/'.$user['template'].'/theme/delete.gif',
     88 
     89  'U_HOME' => add_session_id( PHPWG_ROOT_PATH.'category.php' )
    5690  )
    5791);
    5892
    5993foreach ( $conf['last_days'] as $option ) {
    60   $url = './comments.php?last_days='.($option - 1);
     94  $url = $PHP_SELF.'?last_days='.($option - 1);
     95  if (defined('IN_ADMIN')) $url.= '&page=comments';
    6196  $template->assign_block_vars('last_day_option', array (
    6297    'OPTION'=>$option,
     
    71106$maxtime = mktime( 0,0,0,$month,$day,$year );
    72107$query = 'SELECT DISTINCT(ic.image_id) as image_id,';
    73 $query .= '(ic.category_id) as category_id';
    74 $query.= ' FROM '.PREFIX_TABLE.'comments AS c';
    75 $query.=     ', '.PREFIX_TABLE.'image_category AS ic';
     108$query.= '(ic.category_id) as category_id';
     109$query.= ' FROM '.COMMENTS_TABLE.' AS c';
     110$query.= ', '.IMAGE_CATEGORY_TABLE.' AS ic';
    76111$query.= ' WHERE c.image_id = ic.image_id';
    77112$query.= ' AND date > '.$maxtime;
    78 $query.= " AND validated = 'true'";
    79 // we must not show pictures of a forbidden category
    80 if ( $user['forbidden_categories'] != '' )
    81 {
    82   $query.= ' AND category_id NOT IN ';
    83   $query.= '('.$user['forbidden_categories'].')';
     113if ( $user['status'] != 'admin' )
     114{
     115  $query.= " AND validated = 'true'";
     116  // we must not show pictures of a forbidden category
     117  if ( $user['forbidden_categories'] != '' )
     118  {
     119    $query.= ' AND category_id NOT IN ';
     120    $query.= '('.$user['forbidden_categories'].')';
     121  }
    84122}
    85123$query.= ' ORDER BY ic.image_id DESC';
    86124$query.= ';';
    87125$result = mysql_query( $query );
    88 
     126if ( $user['status'] == 'admin' )
     127{
     128  $template->assign_block_vars('validation', array());
     129}
    89130while ( $row = mysql_fetch_array( $result ) )
    90131  {
     
    113154    // name of the picture
    114155    $name = $array_cat_names[$category_id].' > ';
    115     if ( $subrow['name'] != '' ) $name.= $subrow['name'];
     156    if (!empty($subrow['name'])) $name.= $subrow['name'];
    116157    else                         $name.= str_replace( '_', ' ', $file );
    117158    $name.= ' [ '.$subrow['file'].' ]';
     
    121162    $src.= $file.'.'.$subrow['tn_ext'];
    122163        // link to the full size picture
    123     $url = './picture.php?cat='.$category_id;
     164    $url = PHPWG_ROOT_PATH.'picture.php?cat='.$category_id;
    124165    $url.= '&image_id='.$row['image_id'];
    125166       
     
    131172
    132173    // for each picture, retrieving all comments
    133     $query = 'SELECT id,date,author,content';
    134     $query.= ' FROM '.COMMENTS_TABLE;
     174    $query = 'SELECT * FROM '.COMMENTS_TABLE;
    135175    $query.= ' WHERE image_id = '.$row['image_id'];
    136176    $query.= ' AND date > '.$maxtime;
    137     $query.= " AND validated = 'true'";
     177        if ( $user['status'] != 'admin' )
     178    {
     179      $query.= " AND validated = 'true'";
     180        }
    138181    $query.= ' ORDER BY date DESC';
    139182    $query.= ';';
     
    142185    {
    143186      $author = $subrow['author'];
    144       if ( $subrow['author'] == '' ) $author = $lang['guest'];
     187      if ( empty($subrow['author'] )) $author = $lang['guest'];
    145188      $content = nl2br( $subrow['content'] );
    146189     
     
    160203      $content = preg_replace( $pattern, $replacement, $content );
    161204      $template->assign_block_vars('picture.comment',array(
    162             'AUTHOR'=>$author,
    163                 'DATE'=>format_date( $subrow['date'], 'unix', true ),
    164                 'CONTENT'=>$content,
     205            'COMMENT_AUTHOR'=>$author,
     206                'COMMENT_DATE'=>format_date( $subrow['date'], 'unix', true ),
     207                'COMMENT'=>$content,
    165208                ));
     209                if ( $user['status'] == 'admin' )
     210                {
     211                  $template->assign_block_vars('picture.comment.validation', array(
     212                    'ID'=> $subrow['id'],
     213                        'CHECKED'=>($subrow['validated']=='false')?'checked="checked"': ''
     214                        ));
     215                }
    166216    }
    167217  }
    168218//----------------------------------------------------------- html code display
    169 $template->pparse('comments');
    170 include(PHPWG_ROOT_PATH.'include/page_tail.php');
     219if (defined('IN_ADMIN'))
     220{
     221  $template->assign_var_from_handle('ADMIN_CONTENT', 'comments');
     222}
     223else
     224{
     225  $template->assign_block_vars('title',array());
     226  $template->pparse('comments');
     227  include(PHPWG_ROOT_PATH.'include/page_tail.php');
     228}
    171229?>
Note: See TracChangeset for help on using the changeset viewer.