Changeset 5509


Ignore:
Timestamp:
Mar 31, 2010, 10:36:32 PM (10 years ago)
Author:
rvelices
Message:

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)

Location:
trunk/include
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/common.inc.php

    r5251 r5509  
    112112catch (Exception $e)
    113113{
    114   my_error(l10n($e->getMessage(), true)); 
     114  my_error(l10n($e->getMessage(), true));
    115115}
    116116
     
    163163}
    164164
    165 // The "No Photo Yet" feature: if you have no photo yet in your gallery, the
    166 // gallery displays only a big box to show you the way for adding your first
    167 // photos
    168 if (
    169   !isset($conf['no_photo_yet'])             // the message disappears at first photo
    170   and !(defined('IN_ADMIN') and IN_ADMIN)   // no message inside administration
    171   and script_basename() != 'identification' // keep the ability to login
    172   and script_basename() != 'ws'             // keep the ability to discuss with web API
    173   and !isset($_SESSION['no_photo_yet'])     // temporary hide
    174   )
    175 {
    176   $query = '
    177 SELECT
    178     COUNT(*)
    179   FROM '.IMAGES_TABLE.'
    180 ;';
    181   list($nb_photos) = pwg_db_fetch_row(pwg_query($query));
    182   if (0 == $nb_photos)
    183   {
    184     if (isset($_GET['no_photo_yet']))
    185     {
    186       if ('browse' == $_GET['no_photo_yet'])
    187       {
    188         $_SESSION['no_photo_yet'] = 'browse';
    189         redirect(make_index_url());
    190         exit();
    191       }
    192 
    193       if ('deactivate' == $_GET['no_photo_yet'])
    194       {
    195         conf_update_param('no_photo_yet', 'false');
    196         redirect(make_index_url());
    197         exit();
    198       }
    199     }
    200    
    201     $template->set_filenames(array('no_photo_yet'=>'no_photo_yet.tpl'));
    202    
    203     if (is_admin())
    204     {     
    205       $url = $conf['no_photo_yet_url'];
    206       if (substr($url, 0, 4) != 'http')
    207       {
    208         $url = get_root_url().$url;
    209       }
    210      
    211       $template->assign(
    212         array(
    213           'step' => 2,
    214           'intro' => sprintf(
    215             l10n('Hello %s, your Piwigo photo gallery is empty!'),
    216             $user['username']
    217             ),
    218           'next_step_url' => $url,
    219           'deactivate_url' => get_root_url().'?no_photo_yet=deactivate',
    220           )
    221         );
    222     }
    223     else
    224     {
    225      
    226       $template->assign(
    227         array(
    228           'step' => 1,
    229           'U_LOGIN' => 'identification.php',
    230           'deactivate_url' => get_root_url().'?no_photo_yet=browse',
    231           )
    232         );
    233     }
    234    
    235     $template->pparse('no_photo_yet');
    236     exit();
    237   }
    238   else
    239   {
    240     conf_update_param('no_photo_yet', 'false');
    241   }
     165if ( !isset($conf['no_photo_yet']) )
     166{
     167  include(PHPWG_ROOT_PATH.'include/no_photo_yet.inc.php');
    242168}
    243169
Note: See TracChangeset for help on using the changeset viewer.