source: extensions/see_photos_by_user/main.inc.php

Last change on this file was 33008, checked in by ddtddt, 3 months ago

[see_photos_by_user] section user- / updae history and enum

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
65                                $page['section'] = 'user-';
66                if (in_array($testd[0], $userok)) {
67                    $me = 'user-' . $testd[0].'-'.$username;
68                    $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>';
69                } else {
70                    $me = 'user-';
71                    $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>';
72                }
73            }else{
74                $me = 'user-';
75            }
76    }else{
77        $me = 'user-';
78    }
79    if(isset($me)){
80        if (in_array($me, $tokens))
81            include(SPBA_PATH . 'pagespba.php');
82    }
83  }
84  $template->set_filename('SPBA', realpath(SPBA_PATH . 'pagespba.tpl'));
85  $template->assign_var_from_handle('CONTENT', 'SPBA'); //2.6
86}
87
88/*Schow link in menu*/
89if ($conf['see_photos_by_user_show']==1) {
90    add_event_handler('blockmanager_apply', 'add_link_SPBA');
91}
92
93function add_link_SPBA($menu_ref_arr){
94    global $conf, $user;
95    $menu = & $menu_ref_arr[0];
96    if (($block = $menu->get_block('mbSpecials')) != null) {
97        $position = (isset($conf['SPBA_position']) and is_numeric($conf['SPBA_position'])) ? $conf['SPBA_position'] : count($block->data) + 1;
98        array_splice
99                ($block->data, $position - 1, 0, array
100            ('user-' =>
101            array
102                (
103                'URL' => make_index_url(array('section' => 'user-')),
104                'TITLE' => l10n('See photos by user'),
105                'NAME' => l10n('See photos by user')
106            )
107                )
108        );
109    }
110}
111
112/*schow users menu*/
113if ($conf['see_photos_by_user_show']==2) {
114    add_event_handler('blockmanager_register_blocks', 'register_users_menubar_blocks');
115    add_event_handler('blockmanager_apply', 'users_apply');
116}
117
118function register_users_menubar_blocks($menu_ref_arr) {
119    $menu = & $menu_ref_arr[0];
120    if ($menu->get_id() != 'menubar')
121        return;
122    $menu->register_block(new RegisteredBlock('mbUsers', 'Users', ('See photos by user')));
123}
124
125function users_apply($menu_ref_arr) {
126    global $template, $conf, $user;
127    $menu = & $menu_ref_arr[0];
128
129    $userslistemenu1 = see_userlist_nb_photo();
130
131    if (pwg_db_num_rows($userslistemenu1)) {
132        while ($userslistemenu = pwg_db_fetch_assoc($userslistemenu1)) {
133            $items = array(
134                'USERSSPBYLID' => $userslistemenu['id'],
135                'USERSSPBYL' => $userslistemenu['username'],
136                'USERSSPBYLC' => $userslistemenu['PBU'],
137            );
138
139            $template->append('userslistemenu1', $items);
140        }
141    }
142    $linkusersliste = get_root_url() . 'index.php?/user-';
143    $template->assign('USERSSPBY', $linkusersliste);
144
145    if (($block = $menu->get_block('mbUsers')) != null) {
146        $template->set_template_dir(SPBA_PATH);
147        $block->template = 'menubar_users.tpl';
148    }
149}
150
151/*Add admin menu*/
152/*
153add_event_handler('get_admin_plugin_menu_links', 'SPBA_admin_menu');
154
155function SPBA_admin_menu($menu) {
156  $menu[] = array(
157    'NAME' => l10n('Photos by user'),
158    'URL' => SPBA_ADMIN,
159    );
160  return $menu;
161}
162*/
163?>
Note: See TracBrowser for help on using the repository browser.