source: branches/2.1/admin/configuration.php @ 20321

Last change on this file since 20321 was 9545, checked in by patdenice, 13 years ago

merge r9544 form trunk to branch 2.1
bug:2212
Update header message when gallery is locked or unlocked.

  • Property svn:eol-style set to LF
File size: 10.4 KB
RevLine 
[362]1<?php
2// +-----------------------------------------------------------------------+
[2297]3// | Piwigo - a PHP based picture gallery                                  |
4// +-----------------------------------------------------------------------+
[5196]5// | Copyright(C) 2008-2010 Piwigo Team                  http://piwigo.org |
[2297]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// +-----------------------------------------------------------------------+
[2]23
[527]24if( !defined("PHPWG_ROOT_PATH") )
[393]25{
[1072]26  die ("Hacking attempt!");
[393]27}
[527]28
[1072]29include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
[2226]30include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
[1072]31
32// +-----------------------------------------------------------------------+
33// | Check Access and exit when user status is not ok                      |
34// +-----------------------------------------------------------------------+
35check_status(ACCESS_ADMINISTRATOR);
36
[512]37//-------------------------------------------------------- sections definitions
38if (!isset($_GET['section']))
39{
[1894]40  $page['section'] = 'main';
[512]41}
42else
43{
44  $page['section'] = $_GET['section'];
45}
[1617]46
[1894]47$main_checkboxes = array(
[2249]48    'gallery_locked',
[2032]49    'allow_user_registration',
50    'obligatory_user_mail_address',
[1920]51    'rate',
52    'rate_anonymous',
[1652]53    'email_admin_on_new_user',
[5328]54    'allow_user_customization',
[1617]55   );
56
[1884]57$history_checkboxes = array(
58    'log',
59    'history_admin',
60    'history_guest'
61   );
62
[2325]63$upload_checkboxes = array(
64    'upload_link_everytime',
65    'email_admin_on_picture_uploaded',
66   );
67
[1617]68$comments_checkboxes = array(
69    'comments_forall',
70    'comments_validation',
71    'email_admin_on_comment',
72    'email_admin_on_comment_validation',
[3445]73    'user_can_delete_comment',
74    'user_can_edit_comment',
75    'email_admin_on_comment_edition',
76    'email_admin_on_comment_deletion'
[1617]77  );
78
[5293]79$display_checkboxes = array(
80    'menubar_filter_icon',
81    'index_sort_order_input',
82    'index_flat_icon',
83    'index_posted_date_icon',
84    'index_created_date_icon',
85    'index_slideshow_icon',
86    'picture_metadata_icon',
87    'picture_slideshow_icon',
88    'picture_favorite_icon',
[5618]89    'picture_download_icon',
[5293]90    'picture_navigation_icons',
91    'picture_navigation_thumb',
92  );
93
[5304]94$display_info_checkboxes = array(
95    'author',
96    'created_on',
97    'posted_on',
98    'dimensions',
99    'file',
100    'filesize',
101    'tags',
102    'categories',
103    'visits',
104    'average_rate',
[5723]105    'privacy_level',
[5304]106  );
107
[2]108//------------------------------ verification and registration of modifications
[1571]109if (isset($_POST['submit']) and !is_adviser())
[2]110{
[21]111  $int_pattern = '/^\d+$/';
[1926]112
[512]113  switch ($page['section'])
[2]114  {
[1894]115    case 'main' :
[130]116    {
[9545]117      if (empty($_POST['gallery_locked']) and $conf['gallery_locked'])
118      {
119        $tpl_var = & $template->get_template_vars('header_msgs');
120        $msg_key = array_search(l10n('The gallery is locked for maintenance. Please, come back later.'), $tpl_var);
121        unset($tpl_var[$msg_key]);
122      }
123      elseif (!empty($_POST['gallery_locked']) and !$conf['gallery_locked'])
124      {
125        $template->append('header_msgs', l10n('The gallery is locked for maintenance. Please, come back later.'));
126      }
[1894]127      foreach( $main_checkboxes as $checkbox)
[1617]128      {
129        $_POST[$checkbox] = empty($_POST[$checkbox])?'false':'true';
130      }
[512]131      break;
[130]132    }
[1884]133    case 'history' :
134    {
135      foreach( $history_checkboxes as $checkbox)
136      {
137        $_POST[$checkbox] = empty($_POST[$checkbox])?'false':'true';
138      }
139      break;
140    }
[512]141    case 'comments' :
142    {
143      // the number of comments per page must be an integer between 5 and 50
144      // included
145      if (!preg_match($int_pattern, $_POST['nb_comment_page'])
146           or $_POST['nb_comment_page'] < 5
147           or $_POST['nb_comment_page'] > 50)
148      {
[5021]149        array_push($page['errors'], l10n('The number of comments a page must be between 5 and 50 included.'));
[512]150      }
[1617]151      foreach( $comments_checkboxes as $checkbox)
152      {
153        $_POST[$checkbox] = empty($_POST[$checkbox])?'false':'true';
154      }
[512]155      break;
156    }
[2325]157    case 'upload' :
158    {
159      foreach( $upload_checkboxes as $checkbox)
160      {
161        $_POST[$checkbox] = empty($_POST[$checkbox])?'false':'true';
162      }
163      break;
164    }
[512]165    case 'default' :
166    {
[1926]167      // Never go here
[512]168      break;
169    }
[5293]170    case 'display' :
171    {
172      foreach( $display_checkboxes as $checkbox)
173      {
174        $_POST[$checkbox] = empty($_POST[$checkbox])?'false':'true';
175      }
[5304]176      foreach( $display_info_checkboxes as $checkbox)
177      {
178        $_POST['picture_informations'][$checkbox] =
179          empty($_POST['picture_informations'][$checkbox])? false : true;
180      }
181      $_POST['picture_informations'] = addslashes(serialize($_POST['picture_informations']));
[5293]182      break;
183    }
[2]184  }
[1071]185
[528]186  // updating configuration if no error found
[792]187  if (count($page['errors']) == 0)
[345]188  {
[1565]189    //echo '<pre>'; print_r($_POST); echo '</pre>';
[1748]190    $result = pwg_query('SELECT param FROM '.CONFIG_TABLE);
[4325]191    while ($row = pwg_db_fetch_assoc($result))
[512]192    {
193      if (isset($_POST[$row['param']]))
194      {
[882]195        $value = $_POST[$row['param']];
[1071]196
197        if ('gallery_title' == $row['param'])
[882]198        {
199          if (!$conf['allow_html_descriptions'])
200          {
201            $value = strip_tags($value);
202          }
203        }
[1071]204
[528]205        $query = '
206UPDATE '.CONFIG_TABLE.'
[1926]207SET value = \''. str_replace("\'", "''", $value).'\'
208WHERE param = \''.$row['param'].'\'
[528]209;';
[587]210        pwg_query($query);
[512]211      }
212    }
[5021]213    array_push($page['infos'], l10n('Information data registered in database'));
[345]214  }
[527]215
[1748]216  //------------------------------------------------------ $conf reinitialization
217  load_conf_from_db();
[1565]218}
219
[512]220//----------------------------------------------------- template initialization
[2530]221$template->set_filename('config', 'configuration.tpl');
[512]222
[2226]223// TabSheet
224$tabsheet = new tabsheet();
[1881]225// TabSheet initialization
[5021]226$tabsheet->add('main', l10n('Main'), $conf_link.'main');
[5293]227$tabsheet->add('display', l10n('Display'), $conf_link.'display');
[5021]228$tabsheet->add('history', l10n('History'), $conf_link.'history');
229$tabsheet->add('comments', l10n('Comments'), $conf_link.'comments');
[6361]230if ($conf['enable_synchronization'])
231{
232  $tabsheet->add('upload', l10n('Upload'), $conf_link.'upload');
233}
[5293]234$tabsheet->add('default', l10n('Guest Settings'), $conf_link.'default');
[2226]235// TabSheet selection
236$tabsheet->select($page['section']);
[1881]237// Assign tabsheet to template
[2226]238$tabsheet->assign();
[1881]239
[2249]240$action = get_root_url().'admin.php?page=configuration';
[528]241$action.= '&amp;section='.$page['section'];
[21]242
[2288]243$template->assign(
[528]244  array(
[5920]245    'U_HELP' => get_root_url().'admin/popuphelp.php?page=configuration',
[1004]246    'F_ACTION'=>$action
[528]247    ));
248
[527]249switch ($page['section'])
[528]250{
[1894]251  case 'main' :
[2]252  {
[2249]253    $template->assign(
[1894]254      'main',
[528]255      array(
[2021]256        'CONF_GALLERY_TITLE' => htmlspecialchars($conf['gallery_title']),
257        'CONF_PAGE_BANNER' => htmlspecialchars($conf['page_banner']),
[1044]258        'CONF_GALLERY_URL' => $conf['gallery_url'],
[528]259        ));
[1617]260
[2325]261    foreach ($main_checkboxes as $checkbox)
[1617]262    {
[2249]263      $template->append(
[1894]264          'main',
[1617]265          array(
[2249]266            $checkbox => $conf[$checkbox]
267            ),
268          true
[1617]269        );
270    }
[528]271    break;
272  }
[1884]273  case 'history' :
274  {
275    //Necessary for merge_block_vars
[2325]276    foreach ($history_checkboxes as $checkbox)
[1884]277    {
[2249]278      $template->append(
[1884]279          'history',
280          array(
[2249]281            $checkbox => $conf[$checkbox]
282            ),
283          true
[1884]284        );
285    }
286    break;
287  }
[528]288  case 'comments' :
289  {
[2249]290    $template->assign(
[528]291      'comments',
292      array(
293        'NB_COMMENTS_PAGE'=>$conf['nb_comment_page'],
294        ));
[1617]295
[2325]296    foreach ($comments_checkboxes as $checkbox)
[1617]297    {
[2249]298      $template->append(
[1617]299          'comments',
300          array(
[2249]301            $checkbox => $conf[$checkbox]
302            ),
303          true
[1617]304        );
305    }
[528]306    break;
307  }
[2325]308  case 'upload' :
309  {
310    $template->assign(
311      'upload',
312      array(
313        'upload_user_access_options'=> get_user_access_level_html_options(ACCESS_GUEST),
314        'upload_user_access_options_selected' => array($conf['upload_user_access'])
315        )
316      );
317    //Necessary for merge_block_vars
318    foreach ($upload_checkboxes as $checkbox)
319    {
320      $template->append(
321          'upload',
322          array(
323            $checkbox => $conf[$checkbox]
324            ),
325          true
326        );
327    }
328    break;
329  }
[528]330  case 'default' :
331  {
[5994]332    $edit_user = build_user($conf['guest_id'], false);
[1926]333    include_once(PHPWG_ROOT_PATH.'profile.php');
[1071]334
[1926]335    $errors = array();
336    if ( !is_adviser() )
[858]337    {
[1926]338      if (save_profile_from_post($edit_user, $errors))
[858]339      {
[1926]340        // Reload user
[5995]341        $edit_user = build_user($conf['guest_id'], false);
[5021]342        array_push($page['infos'], l10n('Information data registered in database'));
[858]343      }
344    }
[1926]345    $page['errors'] = array_merge($page['errors'], $errors);
[541]346
[1926]347    load_profile_in_template(
348      $action,
349      '',
350      $edit_user
351      );
[2249]352    $template->assign('default', array());
[528]353    break;
354  }
[5293]355  case 'display' :
356  {
357    foreach ($display_checkboxes as $checkbox)
358    {
359      $template->append(
360          'display',
361          array(
362            $checkbox => $conf[$checkbox]
363            ),
364          true
365        );
366    }
[5304]367    $template->append(
368        'display',
369        array(
370          'picture_informations' => unserialize($conf['picture_informations'])
371          ),
372        true
373      );
[5293]374    break;
375  }
[528]376}
[1926]377
[2]378//----------------------------------------------------------- sending html code
[393]379$template->assign_var_from_handle('ADMIN_CONTENT', 'config');
[362]380?>
Note: See TracBrowser for help on using the repository browser.