1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | Piwigo - a PHP based picture gallery | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // | Copyright(C) 2008-2010 Piwigo Team http://piwigo.org | |
---|
6 | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | |
---|
7 | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | |
---|
8 | // +-----------------------------------------------------------------------+ |
---|
9 | // | This program is free software; you can redistribute it and/or modify | |
---|
10 | // | it under the terms of the GNU General Public License as published by | |
---|
11 | // | the Free Software Foundation | |
---|
12 | // | | |
---|
13 | // | This program is distributed in the hope that it will be useful, but | |
---|
14 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
15 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
16 | // | General Public License for more details. | |
---|
17 | // | | |
---|
18 | // | You should have received a copy of the GNU General Public License | |
---|
19 | // | along with this program; if not, write to the Free Software | |
---|
20 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
21 | // | USA. | |
---|
22 | // +-----------------------------------------------------------------------+ |
---|
23 | |
---|
24 | |
---|
25 | // The "No Photo Yet" feature: if you have no photo yet in your gallery, the |
---|
26 | // gallery displays only a big box to show you the way for adding your first |
---|
27 | // photos |
---|
28 | if ( |
---|
29 | !(defined('IN_ADMIN') and IN_ADMIN) // no message inside administration |
---|
30 | and script_basename() != 'identification' // keep the ability to login |
---|
31 | and script_basename() != 'ws' // keep the ability to discuss with web API |
---|
32 | and script_basename() != 'popuphelp' // keep the ability to display help popups |
---|
33 | and !isset($_SESSION['no_photo_yet']) // temporary hide |
---|
34 | ) |
---|
35 | { |
---|
36 | $query = ' |
---|
37 | SELECT |
---|
38 | COUNT(*) |
---|
39 | FROM '.IMAGES_TABLE.' |
---|
40 | ;'; |
---|
41 | list($nb_photos) = pwg_db_fetch_row(pwg_query($query)); |
---|
42 | if (0 == $nb_photos) |
---|
43 | { |
---|
44 | if (isset($_GET['no_photo_yet'])) |
---|
45 | { |
---|
46 | if ('browse' == $_GET['no_photo_yet']) |
---|
47 | { |
---|
48 | $_SESSION['no_photo_yet'] = 'browse'; |
---|
49 | redirect(make_index_url()); |
---|
50 | exit(); |
---|
51 | } |
---|
52 | |
---|
53 | if ('deactivate' == $_GET['no_photo_yet']) |
---|
54 | { |
---|
55 | conf_update_param('no_photo_yet', 'false'); |
---|
56 | redirect(make_index_url()); |
---|
57 | exit(); |
---|
58 | } |
---|
59 | } |
---|
60 | |
---|
61 | header('Content-Type: text/html; charset='.get_pwg_charset()); |
---|
62 | $template->set_filenames(array('no_photo_yet'=>'no_photo_yet.tpl')); |
---|
63 | |
---|
64 | if (is_admin()) |
---|
65 | { |
---|
66 | $url = $conf['no_photo_yet_url']; |
---|
67 | if (substr($url, 0, 4) != 'http') |
---|
68 | { |
---|
69 | $url = get_root_url().$url; |
---|
70 | } |
---|
71 | |
---|
72 | $template->assign( |
---|
73 | array( |
---|
74 | 'step' => 2, |
---|
75 | 'intro' => sprintf( |
---|
76 | l10n('Hello %s, your Piwigo photo gallery is empty!'), |
---|
77 | $user['username'] |
---|
78 | ), |
---|
79 | 'next_step_url' => $url, |
---|
80 | 'deactivate_url' => get_root_url().'?no_photo_yet=deactivate', |
---|
81 | ) |
---|
82 | ); |
---|
83 | } |
---|
84 | else |
---|
85 | { |
---|
86 | |
---|
87 | $template->assign( |
---|
88 | array( |
---|
89 | 'step' => 1, |
---|
90 | 'U_LOGIN' => 'identification.php', |
---|
91 | 'deactivate_url' => get_root_url().'?no_photo_yet=browse', |
---|
92 | ) |
---|
93 | ); |
---|
94 | } |
---|
95 | |
---|
96 | $template->pparse('no_photo_yet'); |
---|
97 | exit(); |
---|
98 | } |
---|
99 | else |
---|
100 | { |
---|
101 | conf_update_param('no_photo_yet', 'false'); |
---|
102 | } |
---|
103 | } |
---|
104 | |
---|
105 | ?> |
---|