source: trunk/include/no_photo_yet.inc.php @ 5509

Last change on this file since 5509 was 5509, checked in by rvelices, 14 years ago

move no_photo_yet feature to a new php file included by common.inc.php only if required (avoid parsing this code that will be rarely executed)

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 3.5 KB
Line 
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
28if (
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 !isset($_SESSION['no_photo_yet'])     // temporary hide
33  )
34{
35  $query = '
36SELECT
37    COUNT(*)
38  FROM '.IMAGES_TABLE.'
39;';
40  list($nb_photos) = pwg_db_fetch_row(pwg_query($query));
41  if (0 == $nb_photos)
42  {
43    if (isset($_GET['no_photo_yet']))
44    {
45      if ('browse' == $_GET['no_photo_yet'])
46      {
47        $_SESSION['no_photo_yet'] = 'browse';
48        redirect(make_index_url());
49        exit();
50      }
51
52      if ('deactivate' == $_GET['no_photo_yet'])
53      {
54        conf_update_param('no_photo_yet', 'false');
55        redirect(make_index_url());
56        exit();
57      }
58    }
59
60    $template->set_filenames(array('no_photo_yet'=>'no_photo_yet.tpl'));
61
62    if (is_admin())
63    {
64      $url = $conf['no_photo_yet_url'];
65      if (substr($url, 0, 4) != 'http')
66      {
67        $url = get_root_url().$url;
68      }
69
70      $template->assign(
71        array(
72          'step' => 2,
73          'intro' => sprintf(
74            l10n('Hello %s, your Piwigo photo gallery is empty!'),
75            $user['username']
76            ),
77          'next_step_url' => $url,
78          'deactivate_url' => get_root_url().'?no_photo_yet=deactivate',
79          )
80        );
81    }
82    else
83    {
84
85      $template->assign(
86        array(
87          'step' => 1,
88          'U_LOGIN' => 'identification.php',
89          'deactivate_url' => get_root_url().'?no_photo_yet=browse',
90          )
91        );
92    }
93
94    $template->pparse('no_photo_yet');
95    exit();
96  }
97  else
98  {
99    conf_update_param('no_photo_yet', 'false');
100  }
101}
102
103?>
Note: See TracBrowser for help on using the repository browser.