Ignore:
Timestamp:
Feb 23, 2014, 9:08:38 AM (10 years ago)
Author:
ddtddt
Message:

[extensions] - Photo_add_by - if plugin see photo by user is actif - can show link on user on picture page with parameter plugin see photo by user

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/Photo_add_by/initpicture.php

    r26560 r27458  
    1717 
    1818  $search = '#<div id="'.$conf['Photo_add_by'].'" class="imageInfo">#';
    19  
     19
    2020  $replacement = '
    2121  {if $PAB}
     
    4949$row = pwg_db_fetch_assoc($result);
    5050$userab=$row['added_by'];
    51  
     51
    5252  $query = '
    5353select '.$conf['user_fields']['username'].' AS username
     
    5959$pab=$row['username'];
    6060
     61$PASPBY = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'see_photos_by_user';"));
     62$showpab = $conf['Photo_add_by_show'];
     63if($showpab == 1 and $PASPBY['state'] == 'active')
     64{
     65$query2 = '
     66SELECT UT.id, UT.username, COUNT(DISTINCT(IT.id)) AS PBU, IT.id
     67 FROM ' . USERS_TABLE . ' as UT
     68 INNER JOIN '.IMAGES_TABLE.' AS IT ON IT.added_by = UT.id
     69 INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON IT.id = ic.image_id
     70  '.get_sql_condition_FandF
     71  (
     72    array
     73      (
     74        'forbidden_categories' => 'category_id',
     75        'visible_categories' => 'category_id',
     76        'visible_images' => 'id'
     77      ),
     78    'WHERE'
     79  ).'
     80 GROUP BY IT.added_by
     81 HAVING PBU >'.$conf['see_photos_by_user_nbphotos'].'
     82 ORDER BY '.$conf['see_photos_by_user_order'].'
     83 LIMIT '.$conf['see_photos_by_user_limit'].';';
    6184
    62     // Envoi des données au template
    63             $template->assign   (
    64                 array   (
    65                 'PAB' => $pab,
    66                                 )                       );
     85$result2 = pwg_query($query2);
     86
     87$userok = array();
     88while ($row2 = pwg_db_fetch_assoc($result2))
     89 {
     90  $userok[] = $row2['username'];
     91}
     92if(in_array($pab, $userok) and $showpab == 1 and $PASPBY['state'] == 'active')
     93{
     94$urlpab = get_root_url().'index.php?/user-'.($pab);
     95$pab2 ='<a href="'.$urlpab.'">'.$pab.'</a>';
     96}
     97else
     98{
     99$pab2=$pab;
     100}
     101}
     102else
     103{
     104$pab2=$pab;
     105}
     106$template->assign(array('PAB' => $pab2,));
     107
    67108  }
    68109}
Note: See TracChangeset for help on using the changeset viewer.