Changeset 27391


Ignore:
Timestamp:
02/16/14 22:40:14 (6 years ago)
Author:
ddtddt
Message:

[extensions] - see_photos_by_user - new options

Location:
extensions/see_photos_by_user
Files:
3 added
5 edited

Legend:

Unmodified
Added
Removed
  • extensions/see_photos_by_user/language/en_UK/plugin.lang.php

    r26643 r27391  
    22$lang['See photos by user'] = 'See photos by user'; 
    33$lang['select user'] = 'select user'; 
    4 $lang['sumit']= 'sumit'; 
     4$lang['select other user'] = 'select other user'; 
     5$lang['sumit'] = 'sumit'; 
     6$lang['users in alphabetical order'] = 'users in alphabetical order'; 
     7$lang['users by reverse alphabetical order'] = 'users by reverse alphabetical order'; 
     8$lang['by increasing number of photos'] = 'by increasing number of photos'; 
     9$lang['by decreasing number of photos'] = 'by decreasing number of photos'; 
     10$lang['Minimal number photos for show users'] = 'Minimal number photos for show users'; 
     11$lang['Maximal number users'] = 'Maximal number users'; 
     12$lang['users order'] = 'users order'; 
     13 
    514?> 
  • extensions/see_photos_by_user/language/fr_FR/plugin.lang.php

    r26635 r27391  
    11<?php 
    22$lang['See photos by user'] = 'Voir photos par utilisateur'; 
    3 $lang['select user'] = 'selectionne un utilisateur'; 
    4 $lang['sumit']= 'Valider'; 
     3$lang['select user'] = 'selectionner un utilisateur'; 
     4$lang['select other user'] = 'selectionner un autre utilisateur'; 
     5$lang['sumit'] = 'Valider'; 
     6$lang['users in alphabetical order'] = 'utilisateurs par ordre alphabètique'; 
     7$lang['users by reverse alphabetical order'] = 'utilisateurs par ordre inversement alphabètique'; 
     8$lang['by increasing number of photos'] = 'par nombre de photos croissant'; 
     9$lang['by decreasing number of photos'] = 'par nombre de photos décroissant'; 
     10$lang['Minimal number photos for show users'] = 'Mombre minimal de photos pour montrer les utilisateurs'; 
     11$lang['Maximal number users'] = 'nombre maximal d\utilisateurs'; 
     12$lang['users order'] = 'ordre des utilisateurs'; 
    513?> 
  • extensions/see_photos_by_user/main.inc.php

    r26643 r27391  
    1313define('SPBA_DIR' , basename(dirname(__FILE__))); 
    1414define('SPBA_PATH' , PHPWG_PLUGINS_PATH . SPBA_DIR . '/'); 
     15load_language('plugin.lang', SPBA_PATH); 
    1516 
     17add_event_handler('blockmanager_apply' , 'add_link_SPBA'); 
    1618function add_link_SPBA($menu_ref_arr) 
    1719 { 
     
    2426   array_splice 
    2527         ($block->data, $position-1, 0, array 
    26           ('See_photos_by_user' => 
     28          ('user-' => 
    2729      array 
    2830                         ( 
    29                          'URL' => make_index_url(array('section' => 'See_photos_by_user')), 
     31                         'URL' => make_index_url(array('section' => 'user-')), 
    3032                         'TITLE' => l10n('See photos by user'), 
    3133                         'NAME' => l10n('See photos by user') 
     
    3638 } 
    3739 
     40add_event_handler('loc_end_section_init', 'section_init_SPBA'); 
    3841function section_init_SPBA() 
    3942{ 
    40   global $tokens; 
    41   if (in_array('See_photos_by_user', $tokens)) 
    42   include(SPBA_PATH . 'pagespba.php'); 
     43 global $tokens; 
     44$testd = explode('user-', $_SERVER['REQUEST_URI']);  
     45if (!empty ($testd[1])) 
     46{$me = 'user-'.$testd[1];} 
     47else 
     48{$me = 'user-';} 
     49 
     50 if (in_array($me, $tokens)) 
     51 include(SPBA_PATH . 'pagespba.php'); 
    4352} 
    4453 
    45 add_event_handler('blockmanager_apply' , 'add_link_SPBA'); 
    46 add_event_handler('loc_end_section_init', 'section_init_SPBA'); 
    4754 
     55add_event_handler('get_admin_plugin_menu_links', 'SPBA_admin_menu'); 
     56function SPBA_admin_menu($menu) 
     57{ 
     58  array_push( 
     59    $menu, 
     60    array( 
     61      'NAME' => l10n('See photos by user'), 
     62      'URL' => get_admin_plugin_menu_link(SPBA_PATH . 'admin.php') 
     63          //'URL' => get_root_url().'admin.php?page=plugin-See_photos_by_user' 
     64      ) 
     65    ); 
     66   
     67  return $menu; 
     68} 
    4869 
    4970?> 
  • extensions/see_photos_by_user/pagespba.php

    r26643 r27391  
    11<?php 
    2  
    32load_language('plugin.lang', SPBA_PATH); 
    43 
    54global $page, $conf, $user, $template; 
    6 $page['section'] = 'See_photos_by_author'; 
    7    
     5 
     6$testd = explode('user-', $_SERVER['REQUEST_URI']);  
     7if (!empty ($testd[1])) 
     8{$me = 'user-'.$testd[1]; 
     9$page['section'] = $me; 
     10 
     11$query = ' 
     12SELECT id, username 
     13 FROM ' . USERS_TABLE . ' 
     14 WHERE username = \''.$testd[1].'\' 
     15;'; 
     16$result = pwg_query($query); 
     17$row = pwg_db_fetch_assoc($result); 
     18  $template->assign( 
     19    'gestionB', 
     20    array( 
     21      'USERUSBU' => $testd[1], 
     22      )); 
     23 
     24$query = ' 
     25SELECT DISTINCT(id) 
     26 FROM '.IMAGES_TABLE.' 
     27 INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id 
     28 '.get_sql_condition_FandF 
     29  ( 
     30    array 
     31      ( 
     32        'forbidden_categories' => 'category_id', 
     33        'visible_categories' => 'category_id', 
     34        'visible_images' => 'id' 
     35      ), 
     36    'WHERE' 
     37  ).' 
     38 AND added_by = \''.$row['id'].'\' 
     39 '.$conf['order_by'].' 
     40;'; 
     41$page = array_merge 
     42( 
     43 $page, 
     44 array 
     45 ( 
     46'title' => '<a href="'.duplicate_index_url(array('start'=>0)).'">'.$me.'</a>', 
     47'items' => array_from_query($query, 'id'), 
     48 ) 
     49); 
     50} 
     51else 
     52{ 
     53$me = 'user-'; 
     54$page['section'] = $me; 
     55} 
    856//read auteur list 
    957$groups = array(); 
     58 
    1059$query = ' 
    11 select id,username 
    12   FROM ' . USERS_TABLE . ' 
    13   WHERE id<>2  
    14   ORDER BY username ASC;'; 
     60SELECT UT.id, UT.username, COUNT(IT.id) AS PBU, IT.id 
     61 FROM ' . USERS_TABLE . ' as UT 
     62 INNER JOIN '.IMAGES_TABLE.' AS IT ON IT.added_by = UT.id 
     63 INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON IT.id = ic.image_id 
     64  '.get_sql_condition_FandF 
     65  ( 
     66    array 
     67      ( 
     68        'forbidden_categories' => 'category_id', 
     69        'visible_categories' => 'category_id', 
     70        'visible_images' => 'id' 
     71      ), 
     72    'WHERE' 
     73  ).' 
     74 GROUP BY IT.added_by 
     75 HAVING PBU >'.$conf['see_photos_by_user_nbphotos'].' 
     76 ORDER BY '.$conf['see_photos_by_user_order'].' 
     77 LIMIT '.$conf['see_photos_by_user_limit'].';'; 
     78 
    1579$result = pwg_query($query); 
    1680 
    1781while ($row = pwg_db_fetch_assoc($result)) 
    1882 { 
    19   $groups[$row['id']] = $row['username']; 
     83  $groups[$row['username']] = $row['username'].' ('.$row['PBU'].')'; 
    2084} 
    2185  $selected = 0; 
    22         $options[] = l10n('select user'); 
     86  if (empty ($testd[1])) 
     87        {$options[] = l10n('select user');} 
     88 else 
     89  {$options[] = l10n('select other user');} 
    2390        $options['a'] = '----------------------'; 
    2491 
     
    36103if (isset($_POST['submitchoixauteur'])) 
    37104 { 
    38      $forbidden = get_sql_condition_FandF( 
    39      array( 'visible_images' => 'id' ), 
    40     'AND' 
    41           ); 
    42            
    43   $page['section'] = 'See_photos_by_author'; 
     105 $redirect_url = get_root_url().'index.php?/user-'.($_POST['metalist']); 
     106 redirect($redirect_url); 
     107 } 
    44108 
    45     $query = ' 
    46   SELECT DISTINCT(id) 
    47   FROM '.IMAGES_TABLE.' 
    48   INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id 
    49   WHERE added_by = \''.$_POST['metalist'].'\' 
    50     '.$forbidden.' 
    51     '.$conf['order_by'].' 
    52   ;'; 
    53  
    54    $page = array_merge( 
    55   $page, 
    56   array( 
    57     'title' => '<a href="'.duplicate_index_url(array('start'=>0)).'">'.l10n('See photos by author').'</a>', 
    58     'items' => array_from_query($query, 'id'), 
    59       ) 
    60      ); 
    61            
    62 //read auteur list 
    63 $groups = array(); 
    64 $query = ' 
    65  select id,username 
    66   FROM ' . USERS_TABLE . ' 
    67   WHERE id<>2  
    68   ORDER BY username ASC;'; 
    69 $result = pwg_query($query); 
    70  
    71 while ($row = pwg_db_fetch_assoc($result)) 
    72         { 
    73   $groups[$row['id']] = $row['username']; 
    74         } 
    75   $selected = $_POST['metalist']; 
    76  
    77   foreach ($groups as $metalist => $metalist2) 
    78         { 
    79     $options[$metalist] = $metalist2; 
    80         } 
    81   $template->assign( 
    82     'gestionA', 
    83     array( 
    84      'OPTIONS' => $options, 
    85      'SELECTED' => $selected 
    86      )); 
    87  } 
    88109$template->assign('SPBA2', 'toto'); 
    89110$template->set_filename('SPBA', realpath(SPBA_PATH.'pagespba.tpl')); 
    90111$template->assign_var_from_handle('CONTENT', 'SPBA'); 
    91  
    92112?> 
  • extensions/see_photos_by_user/pagespba.tpl

    r26643 r27391  
    44 </form> 
    55{/if} 
     6{if isset ($gestionB)} 
     7<h1>{'User'|@translate} {$gestionB.USERUSBU}</h1> 
     8{/if} 
Note: See TracChangeset for help on using the changeset viewer.