Changeset 21347


Ignore:
Timestamp:
Mar 8, 2013, 1:41:19 AM (7 years ago)
Author:
mistic100
Message:

update PWG Stuffs module, use UNIX eol

Location:
extensions/Comments_on_Albums/trunk
Files:
2 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • extensions/Comments_on_Albums/trunk/main.inc.php

    r19991 r21347  
    1010
    1111if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
     12
     13if (mobile_theme())
     14{
     15  return;
     16}
    1217
    1318global $prefixeTable;
  • extensions/Comments_on_Albums/trunk/stuffs_module/config.inc.php

    r12381 r21347  
    1313  else
    1414  {
     15    if (!isset($_POST['show_admin_buttons']))
     16    {
     17      $_POST['show_admin_buttons'] = 'off';
     18    }
    1519    $datas = array(
    1620      $_POST['nb_comments'],
    17       isset($_POST['show_admin_buttons']),
     21      $_POST['show_admin_buttons'],
    1822      $_POST['nb_cadres'],
    1923      $_POST['width'],
     
    3337  'HEIGHT'      => $datas[4]
    3438));
    35 if ($datas[1])
     39if ($datas[1] == 'on')
    3640{
    3741  $template->assign(array('SHOW_ADMIN_BUTTONS' => 'checked="checked"'));
  • extensions/Comments_on_Albums/trunk/stuffs_module/config.tpl

    r18927 r21347  
    11<table>
     2        <tr>
     3                <td align="right"><br>{'lastcoms_nb_comments'|@translate} &nbsp;&nbsp;</td>
     4                <td><br>
     5                <input type="text" size="3" maxlength="2" value="{$NB_COMMENTS}" name="nb_comments"/></td>
     6        </tr>
     7        <tr>
     8                <td align="right"><br>{'lastcoms_show_buttons'|@translate} &nbsp;&nbsp;</td>
     9                <td><br>
     10                <input type="checkbox" name="show_admin_buttons" value="on" {$SHOW_ADMIN_BUTTONS}/></td>
     11        </tr>
    212  <tr>
    3     <td align="right"><br>{'lastcoms_nb_comments'|@translate} &nbsp;&nbsp;</td>
    4     <td><br>
    5     <input type="text" size="3" maxlength="2" value="{$NB_COMMENTS}" name="nb_comments"/></td>
    6   </tr>
    7   <tr>
    8     <td align="right"><br>{'lastcoms_show_buttons'|@translate} &nbsp;&nbsp;</td>
    9     <td><br>
    10     <input type="checkbox" name="show_admin_buttons" value="on" {$SHOW_ADMIN_BUTTONS}/></td>
    11   </tr>
    12   <tr>
    13     <td align="right"><br>{'lastcoms_nb_cadres'|@translate} &nbsp;&nbsp;</td>
    14     <td><br>
     13                <td align="right"><br>{'lastcoms_nb_cadres'|@translate} &nbsp;&nbsp;</td>
     14                <td><br>
    1515    {html_options name=nb_cadres options=$nb_cadres.OPTIONS selected=$nb_cadres.SELECTED}
    1616    </td>
    17   </tr>
     17        </tr>
    1818  <tr>
    19     <td align="right"><br>{'lastcoms_dim'|@translate} : &nbsp;&nbsp; {'lastcoms_width'|@translate} &nbsp;&nbsp;</td>
    20     <td><br>
    21     <input type="text" size="3" maxlength="3" value="{$WIDTH}" name="width"/>&nbsp;px</td>
    22   </tr>
    23   <tr>
    24     <td align="right">{'lastcoms_height'|@translate} &nbsp;&nbsp;</td>
    25     <td>
    26     <input type="text" size="3" maxlength="3" value="{$HEIGHT}" name="height"/>&nbsp;px</td>
    27   </tr>
     19                <td align="right"><br>{'lastcoms_dim'|@translate} : &nbsp;&nbsp; {'lastcoms_width'|@translate} &nbsp;&nbsp;</td>
     20                <td><br>
     21                <input type="text" size="3" maxlength="3" value="{$WIDTH}" name="width"/>&nbsp;px</td>
     22        </tr>
     23        <tr>
     24                <td align="right">{'lastcoms_height'|@translate} &nbsp;&nbsp;</td>
     25                <td>
     26                <input type="text" size="3" maxlength="3" value="{$HEIGHT}" name="height"/>&nbsp;px</td>
     27        </tr>
    2828</table>
    2929<br>
  • extensions/Comments_on_Albums/trunk/stuffs_module/main.inc.php

    r12562 r21347  
    22
    33if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
     4include_once(COA_PATH.'include/functions_comment.inc.php');
     5
    46global $user, $conf;
    57
     
    79// |                         comments management                           |
    810// +-----------------------------------------------------------------------+
    9 // comments deletion
    10 if (isset($_GET['delete_album']) and is_numeric($_GET['delete_album']) and is_admin())
    11 {
    12     check_status(ACCESS_ADMINISTRATOR);
    13     check_pwg_token();
    14     $query = '
    15 DELETE FROM ' . COA_TABLE . '
    16   WHERE id=' . $_GET['delete_album'] . '
    17 ;';
    18     pwg_query($query);
    19 }
    20 
    21 // comments validation
    22 if (isset($_GET['validate_album']) and is_numeric($_GET['validate_album']) and is_admin())
    23 {
    24     check_status(ACCESS_ADMINISTRATOR);
    25     check_pwg_token();
    26     $query = '
    27 UPDATE ' . COA_TABLE . '
    28   SET validated = \'true\'
    29   , validation_date = NOW()
    30   WHERE id=' . $_GET['validate_album'] . '
    31 ;';
    32     pwg_query($query);
     11
     12$comment_id = null;
     13$action = null;
     14
     15$actions = array('delete_comment_album', 'validate_comment_album', 'edit_comment_album');
     16foreach ($actions as $loop_action)
     17{
     18  if (isset($_GET[$loop_action]))
     19  {
     20    $action = $loop_action;
     21    check_input_parameter($action, $_GET, false, PATTERN_ID);
     22    $comment_id = $_GET[$action];
     23    break;
     24  }
     25}
     26
     27if (isset($action))
     28{
     29  check_pwg_token();
     30
     31  $comment_author_id = get_comment_author_id_albums($comment_id);
     32  $action = str_replace('_comment_album', '', $action);
     33
     34  if (can_manage_comment($action, $comment_author_id))
     35  {
     36    $perform_redirect = false;
     37
     38    if ('delete' == $action)
     39    {
     40      delete_user_comment_albums($comment_id);
     41      $perform_redirect = true;
     42    }
     43
     44    if ('validate' == $action)
     45    {
     46      validate_user_comment_albums($comment_id);
     47      $perform_redirect = true;
     48    }
     49
     50    if ('edit' == $action)
     51    {
     52      if (!empty($_POST['content']))
     53      {
     54        update_user_comment_albums(
     55          array(
     56            'comment_id' => $_GET['edit_comment_album'],
     57            'category_id' => $_POST['image_id'],
     58            'content' => $_POST['content']
     59            ),
     60          $_POST['key']
     61          );
     62
     63        $perform_redirect = true;
     64      }
     65      else
     66      {
     67        $edit_comment = $_GET['edit_comment_album'];
     68      }
     69    }
     70
     71    if ($perform_redirect)
     72    {
     73      $redirect_url =
     74        PHPWG_ROOT_PATH
     75        .'index.php'
     76        .get_query_string_diff(array('delete_comment_album','validate_comment_album','edit_comment_album','pwg_token'));
     77
     78      redirect(rtrim($redirect_url, '='));
     79    }
     80  }
    3381}
    3482
     
    3684// |                        last comments display                          |
    3785// +-----------------------------------------------------------------------+
     86if ( !is_admin() )
     87{
     88  $page['where_clauses'][] = 'validated=\'true\'';
     89}
     90
     91$page['where_clauses'][] = get_sql_condition_FandF
     92  (
     93    array
     94      (
     95        'forbidden_categories' => 'category_id',
     96        'visible_categories' => 'category_id',
     97      ),
     98    '', true
     99  );
     100
    38101$comments = array();
    39102$element_ids = array();
    40103$category_ids = array();
    41 $max_width = 0;
    42 if (!is_admin())
    43 {
    44   $clauses[] = 'validated="true"';
    45 }
    46 $clauses[] = get_sql_condition_FandF (
    47     array ('forbidden_categories' => 'category_id',
    48         'visible_categories' => 'category_id'), '', true);
    49104
    50105$query = '
    51 SELECT
    52     com.id AS comment_id,
    53     com.category_id,
    54     com.author,
    55     com.author_id,
    56     '.$conf['user_fields']['username'].' AS username,
    57     com.date,
    58     com.content,
    59     com.validated
     106SELECT com.id AS comment_id,
     107       com.category_id,
     108       com.author,
     109       com.author_id,
     110       com.date,
     111       com.content,
     112       com.validated
    60113  FROM '.COA_TABLE.' AS com
    61     LEFT JOIN '.USERS_TABLE.' As u
    62       ON u.'.$conf['user_fields']['id'].' = com.author_id
     114    LEFT JOIN '.USERS_TABLE.' AS u
     115    ON u.'.$conf['user_fields']['id'].' = com.author_id
    63116  WHERE '.implode('
    64     AND ', $clauses).'
    65   GROUP BY
    66     comment_id
     117    AND ', $page['where_clauses']).'
     118  GROUP BY comment_id,
     119       com.category_id,
     120       com.author,
     121       com.author_id,
     122       com.date,
     123       com.content,
     124       com.validated
    67125  ORDER BY date DESC
    68   LIMIT 0, ' . $datas[0] . '
     126  LIMIT 0, ' . $datas[0] . ';';
     127
     128$query.= '
    69129;';
    70 
    71130$result = pwg_query($query);
    72 while ($row = mysql_fetch_assoc($result))
     131while ($row = pwg_db_fetch_assoc($result))
    73132{
    74133  array_push($comments, $row);
     
    78137if (count($comments) > 0)
    79138{
     139  $block['TEMPLATE'] = 'stuffs_lastcoms.tpl';
    80140  $block['TITLE_URL'] = 'comments.php?display_mode=albums';
    81141  $block['comments'] = array();
    82 
     142  $block['MAX_WIDTH'] = $datas[3];
     143  $block['MAX_HEIGHT'] = $datas[4];
     144  switch ($datas[2])
     145  {
     146    case 1 :
     147      $block['NB_COMMENTS_LINE'] = '99%';
     148      break;
     149    case 2 :
     150      $block['NB_COMMENTS_LINE'] = '49%';
     151      break;
     152    case 3 :
     153      $block['NB_COMMENTS_LINE'] = '32.4%';
     154      break;
     155  }
     156 
    83157  // retrieving category informations
    84158  $query = '
     
    90164    com.id as comment_id,
    91165    img.id AS image_id,
    92     img.path,
    93     img.tn_ext
     166    img.path
    94167  FROM '.CATEGORIES_TABLE.' AS cat
    95168    LEFT JOIN '.COA_TABLE.' AS com
     
    115188    $comment['cat_url'] = duplicate_index_url(
    116189      array(
    117         'category' => array(
    118           'id' => $categories[$comment['comment_id']]['id'],
    119           'name' => $categories[$comment['comment_id']]['name'],
    120           'permalink' => $categories[$comment['comment_id']]['permalink'],
    121           ),
     190        'category' => $categories[$comment['comment_id']],
    122191        array('start')
    123192        )
    124193      );
    125      
    126     // category thumbnail
    127     $comment['thumb'] = get_thumbnail_url(
    128       array(
    129         'id' => $categories[$comment['comment_id']]['image_id'],
    130         'path' => $categories[$comment['comment_id']]['path'],
    131         'tn_ext' => @$categories[$comment['comment_id']]['tn_ext'],
    132         )
    133      );
     194
     195    // source of the thumbnail picture
     196    $src_image = new SrcImage(array(
     197      'id' => $categories[$comment['comment_id']]['image_id'],
     198      'path' => $categories[$comment['comment_id']]['path'],
     199      ));
    134200
    135201    // author
    136     $author = $comment['author'];
    137202    if (empty($comment['author']))
    138203    {
    139       $author = l10n('guest');
    140     }
    141    
    142     // comment content
     204      $comment['author'] = l10n('guest');
     205    }
     206
    143207    $tpl_comment = array(
    144208      'ID' => $comment['comment_id'],
    145209      'U_PICTURE' => $comment['cat_url'],
     210      'src_image' => $src_image,
    146211      'ALT' => trigger_event('render_category_name', $categories[$comment['comment_id']]['name']),
    147       'TN_SRC' => $comment['thumb'],
    148       'AUTHOR' => trigger_event('render_comment_author', $author),
    149       'DATE' => format_date($comment['date'], true),
    150       'CONTENT' => trigger_event('render_comment_content', $comment['content'], 'album'),
     212      'AUTHOR' => trigger_event('render_comment_author', $comment['author']),
     213      'DATE'=>format_date($comment['date'], true),
     214      'CONTENT'=>trigger_event('render_comment_content',$comment['content']),
    151215      'WIDTH' => $datas[3],
    152216      'HEIGHT' => $datas[4],
    153217      );
    154 
    155     switch ($datas[2])
    156     {
    157       case 1 :
    158         $tpl_comment['CLASS'] = 'one_comment';
    159         break;
    160       case 2 :
    161         $tpl_comment['CLASS'] = 'two_comment';
    162         break;
    163       case 3 :
    164         $tpl_comment['CLASS'] = 'three_comment';
    165         break;
    166     }
    167 
    168     // actions
    169     if ( is_admin() and $datas[1])
    170     {
    171       $url = get_root_url().'index.php'.get_query_string_diff(array('delete_album','validate_album'));
    172       $tpl_comment['U_DELETE'] = add_url_params($url, array(
    173             'delete_album' => $comment['comment_id'],
    174             'pwg_token' => get_pwg_token()));
    175 
    176       if ($comment['validated'] != 'true')
    177       {
    178         $tpl_comment['U_VALIDATE'] = add_url_params($url, array(
    179             'validate_album' => $comment['comment_id'],
    180             'pwg_token' => get_pwg_token()));
     218   
     219    if ($datas[1] == 'on')
     220    {
     221      $url =
     222        get_root_url()
     223        .'index.php'
     224        .get_query_string_diff(array('edit_comment_album', 'delete_comment_album','validate_comment_album', 'pwg_token'));
     225
     226      if (can_manage_comment('delete', $comment['author_id']))
     227      {
     228        $tpl_comment['U_DELETE'] = add_url_params(
     229          $url,
     230          array(
     231            'delete_comment_album' => $comment['comment_id'],
     232            'pwg_token' => get_pwg_token(),
     233            )
     234          );
     235      }
     236
     237      if (can_manage_comment('edit', $comment['author_id']))
     238      {
     239        $tpl_comment['U_EDIT'] = add_url_params(
     240          $url,
     241          array(
     242            'edit_comment_album' => $comment['comment_id'],
     243            'pwg_token' => get_pwg_token(),
     244            )
     245          );
     246
     247        if (isset($edit_comment) and ($comment['comment_id'] == $edit_comment))
     248        {
     249          $tpl_comment['IN_EDIT'] = true;
     250          $key = get_ephemeral_key(2, $comment['category_id']);
     251          $tpl_comment['KEY'] = $key;
     252          $tpl_comment['IMAGE_ID'] = $comment['category_id'];
     253          $tpl_comment['CONTENT'] = $comment['content'];
     254          $tpl_comment['PWG_TOKEN'] = get_pwg_token();
     255        }
     256      }
     257
     258      if (can_manage_comment('validate', $comment['author_id']))
     259      {
     260        if ('true' != $comment['validated'])
     261        {
     262          $tpl_comment['U_VALIDATE'] = add_url_params(
     263            $url,
     264            array(
     265              'validate_comment_album'=> $comment['comment_id'],
     266              'pwg_token' => get_pwg_token(),
     267              )
     268            );
     269        }
    181270      }
    182271    }
     
    184273    array_push($block['comments'], $tpl_comment);
    185274  }
    186   $block['TEMPLATE'] = dirname(__FILE__).'/stuffs_lastcoms.tpl';
     275  $block['derivative_params'] = ImageStdParams::get_by_type(IMG_THUMB);
    187276}
    188277
Note: See TracChangeset for help on using the changeset viewer.