[16859] | 1 | <?php |
---|
| 2 | |
---|
| 3 | //Ajout du prefiltre |
---|
| 4 | add_event_handler('loc_begin_picture', 'pabI', 55 ); |
---|
| 5 | |
---|
| 6 | function pabI() |
---|
| 7 | { |
---|
| 8 | global $template; |
---|
| 9 | $template->set_prefilter('picture', 'pabIT'); |
---|
| 10 | } |
---|
| 11 | |
---|
[21222] | 12 | |
---|
[16859] | 13 | function pabIT($content, &$smarty) |
---|
| 14 | { |
---|
[21222] | 15 | |
---|
| 16 | global $conf; |
---|
| 17 | |
---|
| 18 | $search = '#<div id="'.$conf['Photo_add_by'].'" class="imageInfo">#'; |
---|
[27458] | 19 | |
---|
[16859] | 20 | $replacement = ' |
---|
| 21 | {if $PAB} |
---|
| 22 | <div id="pab1" class="imageInfo"> |
---|
[16897] | 23 | <dt>{\'Photo added by\'|@translate}</dt> |
---|
[16859] | 24 | <dd>{$PAB}</dd> |
---|
| 25 | </div> |
---|
| 26 | {/if} |
---|
[21222] | 27 | <div id="'.$conf['Photo_add_by'].'" class="imageInfo">'; |
---|
[16859] | 28 | |
---|
| 29 | return preg_replace($search, $replacement, $content); |
---|
| 30 | } |
---|
| 31 | |
---|
| 32 | add_event_handler('loc_begin_picture', 'pab'); |
---|
| 33 | |
---|
| 34 | function pab() |
---|
| 35 | { |
---|
| 36 | global $conf, $page, $template; |
---|
| 37 | load_language('plugin.lang', PAB_PATH); |
---|
| 38 | load_language('lang', PHPWG_ROOT_PATH.PWG_LOCAL_DIR, array('no_fallback'=>true, 'local'=>true) ); |
---|
| 39 | |
---|
| 40 | if ( !empty($page['image_id']) ) |
---|
| 41 | { |
---|
| 42 | |
---|
| 43 | $query = ' |
---|
| 44 | select added_by |
---|
| 45 | FROM ' . IMAGES_TABLE . ' |
---|
| 46 | WHERE id = \''.$page['image_id'].'\' |
---|
| 47 | ;'; |
---|
| 48 | $result = pwg_query($query); |
---|
[21162] | 49 | $row = pwg_db_fetch_assoc($result); |
---|
[16859] | 50 | $userab=$row['added_by']; |
---|
[27458] | 51 | |
---|
[16859] | 52 | $query = ' |
---|
[26560] | 53 | select '.$conf['user_fields']['username'].' AS username |
---|
[16859] | 54 | FROM ' . USERS_TABLE . ' |
---|
[26560] | 55 | WHERE '.$conf['user_fields']['id'].' = \''.$userab.'\' |
---|
[16859] | 56 | ;'; |
---|
| 57 | $result = pwg_query($query); |
---|
[21162] | 58 | $row = pwg_db_fetch_assoc($result); |
---|
[16859] | 59 | $pab=$row['username']; |
---|
| 60 | |
---|
[27458] | 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']; |
---|
| 63 | if($showpab == 1 and $PASPBY['state'] == 'active') |
---|
| 64 | { |
---|
| 65 | $query2 = ' |
---|
[30404] | 66 | SELECT UT.id, UT.username, COUNT(DISTINCT(IT.id)) AS PBU |
---|
[27458] | 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'].';'; |
---|
[16859] | 84 | |
---|
[27458] | 85 | $result2 = pwg_query($query2); |
---|
| 86 | |
---|
| 87 | $userok = array(); |
---|
| 88 | while ($row2 = pwg_db_fetch_assoc($result2)) |
---|
| 89 | { |
---|
| 90 | $userok[] = $row2['username']; |
---|
| 91 | } |
---|
| 92 | if(in_array($pab, $userok) and $showpab == 1 and $PASPBY['state'] == 'active') |
---|
| 93 | { |
---|
[30404] | 94 | $urlpab = get_root_url().'index.php?/user-'.$userab.'-'.$pab; |
---|
[27458] | 95 | $pab2 ='<a href="'.$urlpab.'">'.$pab.'</a>'; |
---|
| 96 | } |
---|
| 97 | else |
---|
| 98 | { |
---|
| 99 | $pab2=$pab; |
---|
| 100 | } |
---|
| 101 | } |
---|
| 102 | else |
---|
| 103 | { |
---|
| 104 | $pab2=$pab; |
---|
| 105 | } |
---|
| 106 | $template->assign(array('PAB' => $pab2,)); |
---|
| 107 | |
---|
[16859] | 108 | } |
---|
| 109 | } |
---|
| 110 | |
---|
[26560] | 111 | ?> |
---|