Changeset 30403


Ignore:
Timestamp:
Nov 9, 2014, 11:00:26 PM (9 years ago)
Author:
ddtddt
Message:
 
Location:
extensions/see_photos_by_user
Files:
13 added
9 edited

Legend:

Unmodified
Added
Removed
  • extensions/see_photos_by_user/admin.php

    r27459 r30403  
    11<?php
    2 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
     2
     3if (!defined('PHPWG_ROOT_PATH'))
     4    die('Hacking attempt!');
    35global $template, $conf, $user;
    4 include_once(PHPWG_ROOT_PATH .'admin/include/tabsheet.class.php');
     6include_once(PHPWG_ROOT_PATH . 'admin/include/tabsheet.class.php');
    57load_language('plugin.lang', SPBA_PATH);
    68$my_base_url = get_admin_plugin_menu_link(__FILE__);
     
    1416
    1517$template->assign(
    16   array(
    17     'SPBU1' => $conf['see_photos_by_user_nbphotos'],
    18         'SPBU2' => $conf['see_photos_by_user_limit'],
    19         'SPBU3' => $conf['see_photos_by_user_order'],
    20         'SPBU4' => $conf['see_photos_by_user_show'],
    21     )
    22   );
    23  
     18        array(
     19            'SPBU1' => $conf['see_photos_by_user_nbphotos'],
     20            'SPBU2' => $conf['see_photos_by_user_limit'],
     21            'SPBU3' => $conf['see_photos_by_user_order'],
     22            'SPBU4' => $conf['see_photos_by_user_show'],
     23            'SPBU5' => $conf['see_photos_by_user_color'],
     24            'SPBA_PATH2'=> get_root_url() . SPBA_PATH,
     25        )
     26);
     27
    2428$SPBU3T = array(
    2529    l10n('users in alphabetical order'),
    2630    l10n('users by reverse alphabetical order'),
    2731    l10n('by increasing number of photos'),
    28         l10n('by decreasing number of photos'),
    29   );
    30  
     32    l10n('by decreasing number of photos'),
     33);
     34
    3135$SPBU3 = array(
    3236    'username ASC',
    3337    'username DESC',
    3438    'PBU ASC',
    35         'PBU DSC',
    36   );
     39    'PBU DESC',
     40);
    3741
    3842$template->assign('spbu', $SPBU3);
    39 $template->assign('spbuT', $SPBU3T); 
     43$template->assign('spbuT', $SPBU3T);
    4044
    4145$SPBU3T2 = array(
    42     l10n('link Specials menu')." - ".l10n('select users box'),
    43     l10n('bloc menu users')." - ".l10n('select users box'),
    44     l10n('link Specials menu')." - ".l10n('select users box')." - ".l10n('bloc menu users'),
    45         l10n('bloc menu users'),
    46         l10n('select users box'),
    47         l10n('nothing'),
    48   );
    49  
     46    l10n('link Specials menu') . " - " . l10n('select users box'),
     47    l10n('bloc menu users') . " - " . l10n('select users box'),
     48    l10n('link Specials menu') . " - " . l10n('select users box') . " - " . l10n('bloc menu users'),
     49    l10n('bloc menu users'),
     50    l10n('select users box'),
     51    l10n('nothing'),
     52);
     53
    5054$SPBU32 = array(
    5155    '1',
    5256    '2',
    5357    '3',
    54         '4',
    55         '5',
    56         '6',
    57   );
     58    '4',
     59    '5',
     60    '6',
     61);
    5862
    5963$template->assign('spbu2', $SPBU32);
    60 $template->assign('spbuT2', $SPBU3T2); 
     64$template->assign('spbuT2', $SPBU3T2);
    6165
    62 if (isset($_POST['submitspbu']))
    63 {
    64 if (is_numeric($_POST['insspbu1']))
    65 {conf_update_param('see_photos_by_user_nbphotos', $_POST['insspbu1']);}
    66 else
    67 {array_push( $page['errors'], l10n('Maximal number users is incorrect !'));}
    68 if (is_numeric($_POST['insspbu2']))
    69 conf_update_param('see_photos_by_user_limit', $_POST['insspbu2']);
    70 else
    71 {array_push( $page['errors'], l10n('Minimal number photos for show users is incorrect !'));}
    72 conf_update_param('see_photos_by_user_order', $_POST['insspbu3']);
    73 conf_update_param('see_photos_by_user_show', $_POST['insspbu4']);
     66if (isset($_POST['submitspbu'])) {
     67    if (is_numeric($_POST['insspbu1'])) {
     68        conf_update_param('see_photos_by_user_nbphotos', $_POST['insspbu1']);
     69    } else {
     70        array_push($page['errors'], l10n('Maximal number users is incorrect !'));
     71    }
     72    if (is_numeric($_POST['insspbu2']))
     73        conf_update_param('see_photos_by_user_limit', $_POST['insspbu2']);
     74    else {
     75        array_push($page['errors'], l10n('Minimal number photos for show users is incorrect !'));
     76    }
     77    conf_update_param('see_photos_by_user_order', $_POST['insspbu3']);
     78    conf_update_param('see_photos_by_user_show', $_POST['insspbu4']);
     79    conf_update_param('see_photos_by_user_color', $_POST['insspbu5']);
    7480
    75 if (!$page['errors'])
    76 {array_push( $page['infos'], l10n('Update Complete') );}
    77  
    78 $template->assign(
    79     array(
    80       'SPBU1' => stripslashes($_POST['insspbu1']),
    81           'SPBU2' => stripslashes($_POST['insspbu2']),
    82           'SPBU3' => stripslashes($_POST['insspbu3']),
    83           'SPBU4' => stripslashes($_POST['insspbu4']),
    84       )
     81    if (!$page['errors']) {
     82        array_push($page['infos'], l10n('Update Complete'));
     83    }
     84
     85    $template->assign(
     86            array(
     87                'SPBU1' => stripslashes($_POST['insspbu1']),
     88                'SPBU2' => stripslashes($_POST['insspbu2']),
     89                'SPBU3' => stripslashes($_POST['insspbu3']),
     90                'SPBU4' => stripslashes($_POST['insspbu4']),
     91                'SPBU5' => stripslashes($_POST['insspbu5']),
     92            )
    8593    );
    86 
    8794}
    8895
    89 $template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/admin.tpl')); 
     96$template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/admin.tpl'));
    9097$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
    9198?>
  • extensions/see_photos_by_user/admin.tpl

    r27428 r30403  
     1{combine_script id="farbtastic" load='footer' require="jquery" path=$SPBA_PATH2|@cat:"js/farbtastic/farbtastic.js"}
     2{combine_css path=$SPBA_PATH2|@cat:"js/farbtastic/farbtastic.css"}
     3{footer_script}
     4// init colorpicker
     5jQuery('#colorpicker').farbtastic('#hexval');
     6{/footer_script}
     7
    18<div class="titrePage">
    2   <h2>{'See photos by user'|@translate}</h2>
     9    <h2>{'See photos by user'|@translate}</h2>
    310</div>
    411
    512<form method="post">
    6  <p>
    7   <strong>{'Minimal number photos for show users'|@translate}</strong>
    8   <input type="text" name="insspbu1" value="{$SPBU1}" size="10" maxlength="10">
    9  </p>
    10  <p>
    11   <strong>{'Maximal number users'|@translate}</strong>
    12   <input type="text" name="insspbu2" value="{$SPBU2}" size="10" maxlength="10">
    13  </p>
    14  <p>
    15   <strong>{'Users order'|@translate}</strong>
    16   {html_options name="insspbu3" values=$spbu output=$spbuT selected="{$SPBU3}"}
    17  </p>
    18  <p>
    19   <strong>{'Show'|@translate}</strong>
    20   {html_options name="insspbu4" values=$spbu2 output=$spbuT2 selected="{$SPBU4}"}
    21  </p>
    22   <p>
    23     <input class="submit" type="submit" name="submitspbu" value="{'Submit'|@translate}">
    24   </p>
     13    <p>
     14        <strong>{'Minimal number photos for show users'|@translate}</strong>
     15        <input type="text" name="insspbu1" value="{$SPBU1}" size="10" maxlength="10">
     16    </p>
     17    <p>
     18        <strong>{'Maximal number users'|@translate}</strong>
     19        <input type="text" name="insspbu2" value="{$SPBU2}" size="10" maxlength="10">
     20    </p>
     21    <p>
     22        <strong>{'Users order'|@translate}</strong>
     23        {html_options name="insspbu3" values=$spbu output=$spbuT selected="{$SPBU3}"}
     24    </p>
     25    <p>
     26        <strong>{'Show'|@translate}</strong>
     27        {html_options name="insspbu4" values=$spbu2 output=$spbuT2 selected="{$SPBU4}"}
     28    </p>
     29    <p>
     30        <span id="colorpicker"></span>
     31        <input type="text" id="hexval" readonly title='{'You must use colorpicker'|@translate}' name="insspbu5" value="{$SPBU5}" size="7" maxlength="7">
     32    </p>
     33   
     34    <p>
     35        <input class="submit" type="submit" name="submitspbu" value="{'Submit'|@translate}">
     36    </p>
    2537</form>
     38   
     39
     40
  • extensions/see_photos_by_user/language/en_UK/plugin.lang.php

    r27457 r30403  
    1818$lang['Show'] = 'Show';
    1919$lang['Photos by user'] = 'Photos by user';
     20$lang['You must use colorpicker'] = 'You must use colorpicker';
    2021?>
  • extensions/see_photos_by_user/language/fr_FR/plugin.lang.php

    r27457 r30403  
    1818$lang['Show'] = 'Montrer';
    1919$lang['Photos by user'] = 'Photos par utilisateur';
     20$lang['You must use colorpicker'] = 'Vous devez utiliser le colorpicker';
    2021?>
  • extensions/see_photos_by_user/main.inc.php

    r27457 r30403  
    11<?php
     2
    23/*
    3 Plugin Name: See photos by user
    4 Version: auto
    5 Description: See photos by user
    6 Plugin URI: http://piwigo.org/ext/extension_view.php?eid=723
    7 Author: ddtddt
    8 Author URI:
    9 */
     4  Plugin Name: See photos by user
     5  Version: auto
     6  Description: See photos by user
     7  Plugin URI: http://piwigo.org/ext/extension_view.php?eid=723
     8  Author: ddtddt
     9  Author URI:
     10 */
    1011
    11 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
     12if (!defined('PHPWG_ROOT_PATH'))
     13    die('Hacking attempt!');
    1214
    13 define('SPBA_DIR' , basename(dirname(__FILE__)));
    14 define('SPBA_PATH' , PHPWG_PLUGINS_PATH . SPBA_DIR . '/');
     15define('SPBA_DIR', basename(dirname(__FILE__)));
     16define('SPBA_PATH', PHPWG_PLUGINS_PATH . SPBA_DIR . '/');
    1517load_language('plugin.lang', SPBA_PATH);
     18
     19include_once(SPBA_PATH . 'include/function.see.inc.php');
    1620
    1721global $conf;
    1822$showSPBU = $conf['see_photos_by_user_show'];
    1923
    20 if (in_array($showSPBU, array(1,3)))
    21 {
    22 add_event_handler('blockmanager_apply' , 'add_link_SPBA');
     24/*init plugin - filter http*/
     25add_event_handler('loc_end_section_init', 'section_init_SPBA');
     26
     27function section_init_SPBA() {
     28    /*init plugin lang*/
     29    load_language('plugin.lang', SPBA_PATH);
     30    load_language('lang', PHPWG_ROOT_PATH . 'local/', array('no_fallback' => true, 'local' => true));
     31   
     32    global $tokens, $conf, $template;
     33  if(strpbrk('user-', $_SERVER['REQUEST_URI'])!=false){
     34    $testa = explode('user-', $_SERVER['REQUEST_URI']);
     35    if(!empty($testa[1])){
     36        $testd = explode('-', $testa[1]);
     37            if(is_numeric($testd[0])){
     38                $username= see_username($testd[0]);
     39                $result=see_userlist_nb_photo();
     40                $userok = array();
     41                while ($row = pwg_db_fetch_assoc($result)) {
     42                    $userok[] = $row['id'];
     43                }
     44                if (in_array($testd[0], $userok)) {
     45                    $me = 'user-' . $testd[0].'-'.$username;
     46                    $page['section_title'] = '<a href="' . get_absolute_root_url() . '">' . l10n('Home') . '</a>' . $conf['level_separator'] . '<a href="' . get_absolute_root_url() . 'index.php?/user-">' . l10n('Users').'</a>'. $conf['level_separator'] . '<a href="' . get_absolute_root_url() . 'index.php?/' . $me . '">'.$row['username'] . '</a>';
     47                } else {
     48                    $me = 'user-';
     49                    $page['section_title'] = '<a href="' . get_absolute_root_url() . '">' . l10n('Home') . '</a>' . $conf['level_separator'] . '<a href="' . get_absolute_root_url() . 'index.php?/user-">' . l10n('Users').'</a>';
     50                }
     51            }else{
     52                $me = 'user-';
     53            }
     54    }else{
     55        $me = 'user-';
     56    }
     57    if(isset($me)){
     58        if (in_array($me, $tokens))
     59            include(SPBA_PATH . 'pagespba.php');
     60    }
     61  }
     62 
     63  //$template->assign('SPBA2', 'toto');
     64  $template->set_filename('SPBA', realpath(SPBA_PATH . 'pagespba.tpl'));
     65  $template->assign_var_from_handle('CONTENT', 'SPBA'); //2.6
     66 
    2367}
    24 function add_link_SPBA($menu_ref_arr)
    25  {
    26   global $conf, $user;
    27   $menu = & $menu_ref_arr[0];
    28   if (($block = $menu->get_block('mbSpecials')) != null)
    29    {
    30    load_language('plugin.lang', SPBA_PATH);
    31    $position = (isset($conf['SPBA_position']) and is_numeric($conf['SPBA_position'])) ? $conf['SPBA_position'] : count($block->data)+1;
    32    array_splice
    33          ($block->data, $position-1, 0, array
    34           ('user-' =>
    35       array
    36                          (
    37                          'URL' => make_index_url(array('section' => 'user-')),
    38                          'TITLE' => l10n('See photos by user'),
    39                          'NAME' => l10n('See photos by user')
    40        )
    41     )
    42    );
    43    }
    44  }
    45 
    46 add_event_handler('loc_end_section_init', 'section_init_SPBA');
    47 function section_init_SPBA()
    48 {
    49  global $tokens, $conf;
    50 $testa = explode('user-', $_SERVER['REQUEST_URI']);
    51 if (!empty ($testa[1]))
    52 {
    53 $testd= explode('/', $testa[1]);
    54 $query = '
    55 SELECT UT.id, UT.username, COUNT(DISTINCT(IT.id)) AS PBU, IT.id
    56  FROM ' . USERS_TABLE . ' as UT
    57  INNER JOIN '.IMAGES_TABLE.' AS IT ON IT.added_by = UT.id
    58  INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON IT.id = ic.image_id
    59   '.get_sql_condition_FandF
    60   (
    61     array
    62       (
    63         'forbidden_categories' => 'category_id',
    64         'visible_categories' => 'category_id',
    65         'visible_images' => 'id'
    66       ),
    67     'WHERE'
    68   ).'
    69  GROUP BY IT.added_by
    70  HAVING PBU >'.$conf['see_photos_by_user_nbphotos'].'
    71  ORDER BY '.$conf['see_photos_by_user_order'].'
    72  LIMIT '.$conf['see_photos_by_user_limit'].';';
    73 
    74 $result = pwg_query($query);
    75 $userok = array();
    76 while ($row = pwg_db_fetch_assoc($result))
    77  {
    78   $userok[] = $row['username'];
     68/*Schow link in menu*/
     69if (in_array($showSPBU, array(1, 3))) {
     70    add_event_handler('blockmanager_apply', 'add_link_SPBA');
    7971}
    8072
    81 if (in_array($testd[0], $userok))
    82 {
    83 $me = 'user-'.$testd[0];
    84 }
    85 else
    86 {
    87  $redirect_url = get_root_url().'index.php?/categories';
    88  redirect($redirect_url);
    89 }
    90 }
    91 else
    92 {$me = 'user-';}
    93 
    94 if (in_array($me, $tokens))
    95  include(SPBA_PATH . 'pagespba.php');
     73function add_link_SPBA($menu_ref_arr) {
     74    global $conf, $user;
     75    $menu = & $menu_ref_arr[0];
     76    if (($block = $menu->get_block('mbSpecials')) != null) {
     77        load_language('plugin.lang', SPBA_PATH);
     78        $position = (isset($conf['SPBA_position']) and is_numeric($conf['SPBA_position'])) ? $conf['SPBA_position'] : count($block->data) + 1;
     79        array_splice
     80                ($block->data, $position - 1, 0, array
     81            ('user-' =>
     82            array
     83                (
     84                'URL' => make_index_url(array('section' => 'user-')),
     85                'TITLE' => l10n('See photos by user'),
     86                'NAME' => l10n('See photos by user')
     87            )
     88                )
     89        );
     90    }
    9691}
    9792
    98 if (in_array($showSPBU, array(2,3,4)))
    99 {
    100 add_event_handler('blockmanager_register_blocks', 'register_users_menubar_blocks');
    101 add_event_handler('blockmanager_apply', 'users_apply');
    102 }
    103 function register_users_menubar_blocks( $menu_ref_arr )
    104 {
    105   $menu = & $menu_ref_arr[0];
    106   if ($menu->get_id() != 'menubar')
    107     return;
    108   $menu->register_block( new RegisteredBlock( 'mbUsers','Users',('See photos by user')));
     93
     94/*schow users menu*/
     95if (in_array($showSPBU, array(2, 3, 4))) {
     96    add_event_handler('blockmanager_register_blocks', 'register_users_menubar_blocks');
     97    add_event_handler('blockmanager_apply', 'users_apply');
    10998}
    11099
    111 function users_apply($menu_ref_arr)
    112 {
    113 global $template, $conf, $user;
    114 $menu = & $menu_ref_arr[0];
    115 load_language('plugin.lang', SPBA_PATH);
    116 load_language('lang', PHPWG_ROOT_PATH.'local/', array('no_fallback'=>true, 'local'=>true));
    117 
    118 $userslistemenu1 = pwg_query('
    119 SELECT UT.id, UT.username, COUNT(DISTINCT(IT.id)) AS PBU, IT.id
    120  FROM ' . USERS_TABLE . ' as UT
    121  INNER JOIN '.IMAGES_TABLE.' AS IT ON IT.added_by = UT.id
    122  INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON IT.id = ic.image_id
    123   '.get_sql_condition_FandF
    124   (
    125     array
    126       (
    127         'forbidden_categories' => 'category_id',
    128         'visible_categories' => 'category_id',
    129         'visible_images' => 'id'
    130       ),
    131     'WHERE'
    132   ).'
    133  GROUP BY IT.added_by
    134  HAVING PBU >'.$conf['see_photos_by_user_nbphotos'].'
    135  ORDER BY '.$conf['see_photos_by_user_order'].'
    136  LIMIT '.$conf['see_photos_by_user_limit'].';');
    137 
    138 if (pwg_db_num_rows($userslistemenu1)) {       
    139  while ($userslistemenu = pwg_db_fetch_assoc($userslistemenu1))
    140         {
    141     $items = array(
    142       'USERSSPBYL' => $userslistemenu['username'],
    143           'USERSSPBYLC' => $userslistemenu['PBU'],
    144                 );
    145                
    146         $template->append('userslistemenu1', $items);
    147         }
    148 }
    149 $linkusersliste = get_root_url().'index.php?/user-';
    150 $template->assign('USERSSPBY', $linkusersliste);
    151    
    152  if (($block = $menu->get_block( 'mbUsers' )) != null) {
    153  $template->set_template_dir(SPBA_PATH);
    154  $block->template = 'menubar_users.tpl';}
     100function register_users_menubar_blocks($menu_ref_arr) {
     101    $menu = & $menu_ref_arr[0];
     102    if ($menu->get_id() != 'menubar')
     103        return;
     104    $menu->register_block(new RegisteredBlock('mbUsers', 'Users', ('See photos by user')));
    155105}
    156106
     107function users_apply($menu_ref_arr) {
     108    global $template, $conf, $user;
     109    $menu = & $menu_ref_arr[0];
     110
     111    $userslistemenu1 = see_userlist_nb_photo();
     112
     113    if (pwg_db_num_rows($userslistemenu1)) {
     114        while ($userslistemenu = pwg_db_fetch_assoc($userslistemenu1)) {
     115            $items = array(
     116                'USERSSPBYLID' => $userslistemenu['id'],
     117                'USERSSPBYL' => $userslistemenu['username'],
     118                'USERSSPBYLC' => $userslistemenu['PBU'],
     119            );
     120
     121            $template->append('userslistemenu1', $items);
     122        }
     123    }
     124    $linkusersliste = get_root_url() . 'index.php?/user-';
     125    $template->assign('USERSSPBY', $linkusersliste);
     126
     127    if (($block = $menu->get_block('mbUsers')) != null) {
     128        $template->set_template_dir(SPBA_PATH);
     129        $block->template = 'menubar_users.tpl';
     130    }
     131}
     132
     133/*Add admin menu*/
    157134add_event_handler('get_admin_plugin_menu_links', 'SPBA_admin_menu');
    158 function SPBA_admin_menu($menu)
    159 {
    160 load_language('plugin.lang', SPBA_PATH);
    161   array_push(
    162     $menu,
    163     array(
    164       'NAME' => l10n('Photos by user'),
    165       'URL' => get_admin_plugin_menu_link(SPBA_PATH . 'admin.php')
    166       )
     135
     136function SPBA_admin_menu($menu) {
     137    load_language('plugin.lang', SPBA_PATH);
     138    array_push(
     139            $menu, array(
     140        'NAME' => l10n('Photos by user'),
     141        'URL' => get_admin_plugin_menu_link(SPBA_PATH . 'admin.php')
     142            )
    167143    );
    168  
    169   return $menu;
     144
     145    return $menu;
    170146}
    171147
  • extensions/see_photos_by_user/maintain.inc.php

    r27442 r30403  
    11<?php
    22
    3 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
     3if (!defined('PHPWG_ROOT_PATH'))
     4    die('Hacking attempt!');
    45
    5 function plugin_activate()
    6 {
     6function plugin_activate() {
    77
    8 global $conf;
     8    global $conf;
    99
    10 if (!isset($conf['see_photos_by_user_nbphotos']))
    11  {
    12  conf_update_param('see_photos_by_user_nbphotos', '0');
    13  }
    14 if (!isset($conf['see_photos_by_user_limit']))
    15  {
    16  conf_update_param('see_photos_by_user_limit', '1000');
    17  }
    18 if (!isset($conf['see_photos_by_user_order']))
    19  {
    20  conf_update_param('see_photos_by_user_order', 'username ASC');
    21  }
    22 if (!isset($conf['see_photos_by_user_show']))
    23  {
    24  conf_update_param('see_photos_by_user_show', '1');
    25  }
     10    if (!isset($conf['see_photos_by_user_nbphotos'])) {
     11        conf_update_param('see_photos_by_user_nbphotos', '0');
     12    }
     13    if (!isset($conf['see_photos_by_user_limit'])) {
     14        conf_update_param('see_photos_by_user_limit', '1000');
     15    }
     16    if (!isset($conf['see_photos_by_user_order'])) {
     17        conf_update_param('see_photos_by_user_order', 'username ASC');
     18    }
     19    if (!isset($conf['see_photos_by_user_show'])) {
     20        conf_update_param('see_photos_by_user_show', '1');
     21    }
     22    if (!isset($conf['see_photos_by_user_color'])) {
     23        conf_update_param('see_photos_by_user_color', '#ffffff');
     24    }
    2625}
    2726
    28 function plugin_install()
    29 {       
     27function plugin_install() {
    3028}
    3129
    32 function plugin_uninstall()
    33 {       
    34 conf_delete_param('see_photos_by_user_nbphotos');
    35 conf_delete_param('see_photos_by_user_limit');
    36 conf_delete_param('see_photos_by_user_order');
    37 conf_delete_param('see_photos_by_user_show');
     30function plugin_uninstall() {
     31    conf_delete_param('see_photos_by_user_nbphotos');
     32    conf_delete_param('see_photos_by_user_limit');
     33    conf_delete_param('see_photos_by_user_order');
     34    conf_delete_param('see_photos_by_user_show');
     35    conf_delete_param('see_photos_by_user_color');
    3836}
    39 
    40 
    4137?>
  • extensions/see_photos_by_user/menubar_users.tpl

    r27443 r30403  
    1 <dt>{'Users'|@translate}</dt>
     1<dt><a href = "{$USERSSPBY}">{'Users'|@translate}</a></dt>
    22<dd>
    33 <ul>
    44  {foreach from=$userslistemenu1 item=userslistemenu}
    55  <li>
    6   <a href = "{$USERSSPBY}{$userslistemenu.USERSSPBYL}">{$userslistemenu.USERSSPBYL} <span class="menuInfoCat">[{$userslistemenu.USERSSPBYLC}]</span></a><br>
     6  <a href = "{$USERSSPBY}{$userslistemenu.USERSSPBYLID}-{$userslistemenu.USERSSPBYL}">{$userslistemenu.USERSSPBYL} <span class="menuInfoCat">[{$userslistemenu.USERSSPBYLC}]</span></a><br>
    77  </li>
    88  {/foreach}
  • extensions/see_photos_by_user/pagespba.php

    r27474 r30403  
    11<?php
    2 load_language('plugin.lang', SPBA_PATH);
    3 
    42global $page, $conf, $user, $template;
    53
    6 $testa = explode('user-', $_SERVER['REQUEST_URI']);
    7 if (!empty ($testa[1]))
    8 {
    9 $testd= explode('/', $testa[1]);
    10 $me = 'user-'.$testd[0];
    11 $page['section'] = $me;
    12 $page['section_title'] =  '<a href="'.get_absolute_root_url().'">'.l10n('Home').'</a>'.$conf['level_separator']. '<a href="'.get_absolute_root_url().'index.php?/'.$me.'">'.l10n('Users').'-'.$testd[0].'</a>';
     4 /*test URL*/
    135
    14 $query = '
    15 SELECT id, username
    16  FROM ' . USERS_TABLE . '
    17  WHERE username = \''.$testd[0].'\'
    18 ;';
    19 $result = pwg_query($query);
    20 $row = pwg_db_fetch_assoc($result);
    21 $coutantuser = $row['id'];
    22   $template->assign(
    23     'gestionB',
    24     array(
    25       'USERUSBU' => $testd[0],
    26       ));
     6$testa = explode('user-', $_SERVER['REQUEST_URI']);
     7if(!empty($testa[1])){
     8    $testd = explode('-', $testa[1]);
     9    if(is_numeric($testd[0])){
     10       
     11        $username= see_username($testd[0]);
     12       
     13       
     14        $me = 'user-' . $testd[0].'-'.$username;
     15       
     16        $page['section'] = $me;
     17        $page['section_title'] = '<a href="' . get_absolute_root_url() . '">' . l10n('Home') . '</a>' . $conf['level_separator'] . '<a href="' . get_absolute_root_url() . 'index.php?/user-">' . l10n('Users').'</a>'. $conf['level_separator'] . '<a href="' . get_absolute_root_url() . 'index.php?/' . $me . '">'.$username. '</a>';
    2718
    28 $query = '
    29 SELECT DISTINCT(id)
    30  FROM '.IMAGES_TABLE.'
    31  INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
    32  '.get_sql_condition_FandF
    33   (
    34     array
    35       (
    36         'forbidden_categories' => 'category_id',
    37         'visible_categories' => 'category_id',
    38         'visible_images' => 'id'
    39       ),
    40     'WHERE'
    41   ).'
    42  AND added_by = \''.$row['id'].'\'
    43  '.$conf['order_by'].'
    44 ;';
    45 $page = array_merge
    46 (
    47  $page,
    48  array
    49  (
    50 'title' => '<a href="'.duplicate_index_url(array('start'=>0)).'">'.$me.'</a>',
    51 'items' => array_from_query($query, 'id'),
    52  )
    53 );
    54 }
    55 else
    56 {
    57 $me = 'user-';
    58 $page['section'] = $me;
    59 $page['section_title'] =  '<a href="'.get_absolute_root_url().'">'.l10n('Home').'</a>'.$conf['level_separator']. '<a href="'.get_absolute_root_url().'index.php?/'.$me.'">'.l10n('Users').'</a>';
     19        $template->assign(
     20          'gestionB', array(
     21          'USERUSBU' => $username,
     22        ));
     23
     24        $query = '
     25        SELECT 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                        ), 'WHERE'
     36                ) . '
     37        AND added_by = \'' . $testd[0] . '\'
     38        ' . $conf['order_by'] . '
     39        ;';
     40        $page = array_merge
     41                (
     42                $page, array
     43            (
     44            'title' => '<a href="' . duplicate_index_url(array('start' => 0)) . '">' . $me . '</a>',
     45            'items' => array_from_query($query, 'id'),
     46                )
     47        );
     48    }else{
     49        show_users_cloud();
     50    }
     51}else{
     52    show_users_cloud();
    6053}
    6154$showSPBU = $conf['see_photos_by_user_show'];
     55/*fin gestion URL*/
    6256
    63 if (in_array($showSPBU, array(1,2,3,5)))
    64 {
     57function show_users_cloud(){
     58    /*users cloud*/
     59// template vars
     60    global $page, $conf, $user, $template;
     61   
     62     $me = 'user-';
     63    $page['section'] = $me;
     64    $page['section_title'] = '<a href="' . get_absolute_root_url() . '">' . l10n('Home') . '</a>' . $conf['level_separator'] . '<a href="' . get_absolute_root_url() . 'index.php?/' . $me . '">' . l10n('Users') . '</a>';       
     65   
     66$template->assign(
     67   'gestionC', array(
     68    'SPBA_PATH'=> get_root_url() . SPBA_PATH,
     69  ));
     70
     71 $userslistecloud1 = pwg_query('
     72SELECT UT.id, UT.username, COUNT(DISTINCT(IT.id)) AS PBU
     73 FROM ' . USERS_TABLE . ' as UT
     74 INNER JOIN ' . IMAGES_TABLE . ' AS IT ON IT.added_by = UT.id
     75 INNER JOIN ' . IMAGE_CATEGORY_TABLE . ' AS ic ON IT.id = ic.image_id
     76  ' . get_sql_condition_FandF
     77                    (
     78                    array
     79                (
     80                'forbidden_categories' => 'category_id',
     81                'visible_categories' => 'category_id',
     82                'visible_images' => 'id'
     83                    ), 'WHERE'
     84            ) . '
     85 GROUP BY IT.added_by
     86 HAVING PBU >' . $conf['see_photos_by_user_nbphotos'] . '
     87 ORDER BY ' . $conf['see_photos_by_user_order'] . '
     88 LIMIT ' . $conf['see_photos_by_user_limit'] . ';');
     89
     90    if (pwg_db_num_rows($userslistecloud1)) {
     91        while ($userslistecloud = pwg_db_fetch_assoc($userslistecloud1)) {
     92            $items = array(
     93                'USERSSPBYLID' => $userslistecloud['id'],
     94                'USERSSPBYL' => $userslistecloud['username'],
     95                'USERSSPBYLC' => $userslistecloud['PBU'],
     96                'USERSSPBYCOLOR' => $conf['see_photos_by_user_color'],
     97            );
     98
     99            $template->append('userslistecloud1', $items);
     100        }
     101    }
     102    $linkusersliste = get_root_url() . 'index.php?/user-';
     103    $template->assign('USERSSPBY', $linkusersliste);
     104
     105}
     106
     107
     108/*select box*/
     109if (in_array($showSPBU, array(1, 2, 3, 5))) {
    65110//read auteur list
    66 $groups = array();
     111    $groups = array();
     112    $result = see_userlist_nb_photo();
    67113
    68 $query = '
    69 SELECT UT.id, UT.username, COUNT(DISTINCT(IT.id)) AS PBU, IT.id
    70  FROM ' . USERS_TABLE . ' as UT
    71  INNER JOIN '.IMAGES_TABLE.' AS IT ON IT.added_by = UT.id
    72  INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON IT.id = ic.image_id
    73   '.get_sql_condition_FandF
    74   (
    75     array
    76       (
    77         'forbidden_categories' => 'category_id',
    78         'visible_categories' => 'category_id',
    79         'visible_images' => 'id'
    80       ),
    81     'WHERE'
    82   ).'
    83  GROUP BY IT.added_by
    84  HAVING PBU >'.$conf['see_photos_by_user_nbphotos'].'
    85  ORDER BY '.$conf['see_photos_by_user_order'].'
    86  LIMIT '.$conf['see_photos_by_user_limit'].';';
     114    while ($row = pwg_db_fetch_assoc($result)) {
     115        $groups[$row['id']] = $row['username'] . ' (' . $row['PBU'] . ')';
     116    }
     117    $selected = 0;
     118    if (empty($testd[0])) {
     119        $options['b'] = l10n('select user');
     120    } else {
     121        $options['b'] = l10n('select other user');
     122    }
     123    $options['a'] = '----------------------';
    87124
    88 $result = pwg_query($query);
     125    foreach ($groups as $metalist => $metalist2) {
     126        $options[$metalist] = $metalist2;
     127    }
     128    $template->assign(
     129            'gestionA', array(
     130        'OPTIONS' => $options,
     131        'SELECTED' => $selected
     132    ));
    89133
    90 while ($row = pwg_db_fetch_assoc($result))
    91  {
    92   $groups[$row['username']] = $row['username'].' ('.$row['PBU'].')';
    93 }
    94   $selected = 0;
    95   if (empty ($testd[0]))
    96         {$options[] = l10n('select user');}
    97  else
    98   {$options[] = l10n('select other user');}
    99         $options['a'] = '----------------------';
    100 
    101   foreach ($groups as $metalist => $metalist2)
    102         {
    103    $options[$metalist] = $metalist2;
    104         }
    105   $template->assign(
    106     'gestionA',
    107     array(
    108       'OPTIONS' => $options,
    109       'SELECTED' => $selected
    110       ));
    111        
    112 if (isset($_POST['submitchoixauteur']))
    113  {
    114  $redirect_url = get_root_url().'index.php?/user-'.($_POST['metalist']);
    115  redirect($redirect_url);
    116  }
    117 
    118 $template->assign('SPBA2', 'toto');
    119 $template->set_filename('SPBA', realpath(SPBA_PATH.'pagespba.tpl'));
    120 $template->assign_var_from_handle('CONTENT', 'SPBA'); //2.6
    121 //$template->assign_var_from_handle('PLUGIN_INDEX_CONTENT_BEGIN', 'SPBA'); //2.5
     134    if (isset($_POST['submitchoixauteur'])) {
     135        $redirect_url = get_root_url() . 'index.php?/user-';
     136        if(is_numeric($_POST['metalist'])){
     137         $query = '
     138    SELECT id, username
     139    FROM ' . USERS_TABLE . '
     140    WHERE id = \'' . $_POST['metalist'] . '\'
     141    ;';
     142        $result = pwg_query($query);
     143        $row = pwg_db_fetch_assoc($result);
     144        $username = $row['username'];
     145       
     146        $redirect_url .=($_POST['metalist']).'-'.$username;
     147             }
     148        redirect($redirect_url);
     149    }
     150   
    122151}
    123152?>
  • extensions/see_photos_by_user/pagespba.tpl

    r27422 r30403  
    11{if isset ($gestionA)}
    2  <form method="post" >
    3   {html_options name="metalist" options=$gestionA.OPTIONS selected=$gestionA.SELECTED}<input class="submit" name="submitchoixauteur" type="submit" value="{'submit'|@translate}"/>
    4  </form>
     2    <form method="post" >
     3        {html_options name="metalist" options=$gestionA.OPTIONS selected=$gestionA.SELECTED}<input class="submit" name="submitchoixauteur" type="submit" value="{'submit'|@translate}"/>
     4    </form>
    55{/if}
     6
    67{if isset ($gestionB)}
    7 <h1>{'User'|@translate} {$gestionB.USERUSBU}</h1>
     8    <h1>{'User'|@translate} {$gestionB.USERUSBU}</h1>
    89{/if}
     10
     11{if isset ($gestionC)}
     12    {combine_script id='jquery.tagcanvas' require="jquery" load='footer' path=$gestionC.SPBA_PATH|@cat:"js/jquery.tagcanvas.min.js"}
     13    {combine_script id='jquery.see' load='footer' path=$gestionC.SPBA_PATH|@cat:"js/see.js"}
     14    <h1>{'select user'|@translate}</h1>
     15<div id="myCanvasContainer">
     16     
     17 <canvas width="600" height="300" id="myCanvas">
     18   <ul>
     19    {foreach from=$userslistecloud1 item=userslistecloud}
     20        <li>
     21            <a href = "{$USERSSPBY}{$userslistecloud.USERSSPBYLID}-{$userslistecloud.USERSSPBYL}">{$userslistecloud.USERSSPBYL} <span data-color="{$userslistecloud.USERSSPBYCOLOR}" data-weight="{$userslistecloud.USERSSPBYLC}" class="menuInfoCat seepbu">[{$userslistecloud.USERSSPBYLC}]</span></a><br>
     22        </li>
     23     {/foreach}
     24  </ul>
     25 </canvas>
     26</div>
     27{/if}
Note: See TracChangeset for help on using the changeset viewer.