source: extensions/see_photos_by_user/main.inc.php @ 32937

Last change on this file since 32937 was 32937, checked in by ddtddt, 17 months ago

[see_photos_by_user] check php8

File size: 6.2 KB
Line 
1<?php
2/*
3Plugin Name: See photos by user
4Version: auto
5Description: See photos by user
6Plugin URI: http://piwigo.org/ext/extension_view.php?eid=723
7Author: ddtddt
8Author URI: http://temmii.com/piwigo/
9Has Settings: webmaster
10*/
11// +-----------------------------------------------------------------------+
12// | See photos by user plugin for piwigo  by TEMMII                       |
13// +-----------------------------------------------------------------------+
14// | Copyright(C) 2014 - 2023 ddtddt             http://temmii.com/piwigo/ |
15// +-----------------------------------------------------------------------+
16// | This program is free software; you can redistribute it and/or modify  |
17// | it under the terms of the GNU General Public License as published by  |
18// | the Free Software Foundation                                          |
19// |                                                                       |
20// | This program is distributed in the hope that it will be useful, but   |
21// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
22// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
23// | General Public License for more details.                              |
24// |                                                                       |
25// | You should have received a copy of the GNU General Public License     |
26// | along with this program; if not, write to the Free Software           |
27// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
28// | USA.                                                                  |
29// +-----------------------------------------------------------------------+
30
31if (!defined('PHPWG_ROOT_PATH'))
32    die('Hacking attempt!');
33
34define('SPBA_DIR', basename(dirname(__FILE__)));
35define('SPBA_PATH', PHPWG_PLUGINS_PATH . SPBA_DIR . '/');
36define('SPBA_ADMIN',get_root_url().'admin.php?page=plugin-'.SPBA_DIR);
37
38include_once(SPBA_PATH . 'include/function.see.inc.php');
39
40add_event_handler('loading_lang', 'see_photos_by_user_loading_lang');     
41function see_photos_by_user_loading_lang(){
42  load_language('plugin.lang', SPBA_PATH);
43  load_language('lang', PHPWG_ROOT_PATH . 'local/', array('no_fallback' => true, 'local' => true));
44}
45
46
47global $conf;
48
49/*init plugin - filter http*/
50add_event_handler('loc_end_section_init', 'section_init_SPBA');
51function section_init_SPBA(){
52  global $tokens, $conf, $template;
53  if(strpbrk('user-', $_SERVER['REQUEST_URI'])!=false){
54    $testa = explode('user-', $_SERVER['REQUEST_URI']);
55    if(!empty($testa[1])){
56        $testd = explode('-', $testa[1]);
57            if(is_numeric($testd[0])){
58                $username= see_username($testd[0]);
59                $result=see_userlist_nb_photo();
60                $userok = array();
61                while ($row = pwg_db_fetch_assoc($result)) {
62                    $userok[] = $row['id'];
63                }
64                if (in_array($testd[0], $userok)) {
65                    $me = 'user-' . $testd[0].'-'.$username;
66                    $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>';
67                } else {
68                    $me = 'user-';
69                    $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>';
70                }
71            }else{
72                $me = 'user-';
73            }
74    }else{
75        $me = 'user-';
76    }
77    if(isset($me)){
78        if (in_array($me, $tokens))
79            include(SPBA_PATH . 'pagespba.php');
80    }
81  }
82  $template->set_filename('SPBA', realpath(SPBA_PATH . 'pagespba.tpl'));
83  $template->assign_var_from_handle('CONTENT', 'SPBA'); //2.6
84}
85
86/*Schow link in menu*/
87if ($conf['see_photos_by_user_show']==1) {
88    add_event_handler('blockmanager_apply', 'add_link_SPBA');
89}
90
91function add_link_SPBA($menu_ref_arr){
92    global $conf, $user;
93    $menu = & $menu_ref_arr[0];
94    if (($block = $menu->get_block('mbSpecials')) != null) {
95        $position = (isset($conf['SPBA_position']) and is_numeric($conf['SPBA_position'])) ? $conf['SPBA_position'] : count($block->data) + 1;
96        array_splice
97                ($block->data, $position - 1, 0, array
98            ('user-' =>
99            array
100                (
101                'URL' => make_index_url(array('section' => 'user-')),
102                'TITLE' => l10n('See photos by user'),
103                'NAME' => l10n('See photos by user')
104            )
105                )
106        );
107    }
108}
109
110/*schow users menu*/
111if ($conf['see_photos_by_user_show']==2) {
112    add_event_handler('blockmanager_register_blocks', 'register_users_menubar_blocks');
113    add_event_handler('blockmanager_apply', 'users_apply');
114}
115
116function register_users_menubar_blocks($menu_ref_arr) {
117    $menu = & $menu_ref_arr[0];
118    if ($menu->get_id() != 'menubar')
119        return;
120    $menu->register_block(new RegisteredBlock('mbUsers', 'Users', ('See photos by user')));
121}
122
123function users_apply($menu_ref_arr) {
124    global $template, $conf, $user;
125    $menu = & $menu_ref_arr[0];
126
127    $userslistemenu1 = see_userlist_nb_photo();
128
129    if (pwg_db_num_rows($userslistemenu1)) {
130        while ($userslistemenu = pwg_db_fetch_assoc($userslistemenu1)) {
131            $items = array(
132                'USERSSPBYLID' => $userslistemenu['id'],
133                'USERSSPBYL' => $userslistemenu['username'],
134                'USERSSPBYLC' => $userslistemenu['PBU'],
135            );
136
137            $template->append('userslistemenu1', $items);
138        }
139    }
140    $linkusersliste = get_root_url() . 'index.php?/user-';
141    $template->assign('USERSSPBY', $linkusersliste);
142
143    if (($block = $menu->get_block('mbUsers')) != null) {
144        $template->set_template_dir(SPBA_PATH);
145        $block->template = 'menubar_users.tpl';
146    }
147}
148
149/*Add admin menu*/
150/*
151add_event_handler('get_admin_plugin_menu_links', 'SPBA_admin_menu');
152
153function SPBA_admin_menu($menu) {
154  $menu[] = array(
155    'NAME' => l10n('Photos by user'),
156    'URL' => SPBA_ADMIN,
157    );
158  return $menu;
159}
160*/
161?>
Note: See TracBrowser for help on using the repository browser.