From d22a07cee30b96f703ab2fa295a4c5f4407d0e00 Mon Sep 17 00:00:00 2001
From: rvelices
Date: Thu, 16 Feb 2006 00:45:18 +0000
Subject: [PATCH] feature 264: gallery_url, rate and rate_anonymous from config
file to database
git-svn-id: http://piwigo.org/svn/trunk@1044 68402e56-0260-453c-a942-63ccdbb3a9ee
---
admin/configuration.php | 12 ++-
include/config_default.inc.php | 10 ---
install/config.sql | 3 +
install/db/8-database.php | 88 +++++++++++++++++++
language/en_UK.iso-8859-1/admin.lang.php | 6 +-
.../en_UK.iso-8859-1/help/configuration.html | 7 ++
language/fr_FR.iso-8859-1/admin.lang.php | 5 +-
.../fr_FR.iso-8859-1/help/configuration.html | 7 ++
template/yoga/admin/configuration.tpl | 19 ++++
9 files changed, 143 insertions(+), 14 deletions(-)
create mode 100644 install/db/8-database.php
diff --git a/admin/configuration.php b/admin/configuration.php
index 0d0ee4476..1a7850368 100644
--- a/admin/configuration.php
+++ b/admin/configuration.php
@@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | PhpWebGallery - a PHP based picture gallery |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
-// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
+// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
// +-----------------------------------------------------------------------+
// | branch : BSF (Best So Far)
// | file : $RCSfile$
@@ -60,6 +60,10 @@ if (isset($_POST['submit']))
{
case 'general' :
{
+ if ( !url_is_remote($_POST['gallery_url']) )
+ {
+ array_push($page['errors'], $lang['conf_gallery_url_error']);
+ }
break;
}
case 'comments' :
@@ -156,6 +160,8 @@ switch ($page['section'])
{
case 'general' :
{
+ $html_check='checked="checked"';
+
$history_yes = ($conf['log']=='true')?'checked="checked"':'';
$history_no = ($conf['log']=='false')?'checked="checked"':'';
$lock_yes = ($conf['gallery_locked']=='true')?'checked="checked"':'';
@@ -168,8 +174,12 @@ switch ($page['section'])
'HISTORY_NO'=>$history_no,
'GALLERY_LOCKED_YES'=>$lock_yes,
'GALLERY_LOCKED_NO'=>$lock_no,
+ ($conf['rate']=='true'?'RATE_YES':'RATE_NO')=>$html_check,
+ ($conf['rate_anonymous']=='true'
+ ? 'RATE_ANONYMOUS_YES' : 'RATE_ANONYMOUS_NO')=>$html_check,
'CONF_GALLERY_TITLE' => $conf['gallery_title'],
'CONF_GALLERY_DESCRIPTION' => $conf['gallery_description'],
+ 'CONF_GALLERY_URL' => $conf['gallery_url'],
));
break;
}
diff --git a/include/config_default.inc.php b/include/config_default.inc.php
index 641cc190b..78121af0f 100644
--- a/include/config_default.inc.php
+++ b/include/config_default.inc.php
@@ -90,13 +90,6 @@ $conf['anti-flood_time'] = 60;
// catgory
$conf['calendar_datefield'] = 'date_creation';
-// rate : enable feature for rating elements
-$conf['rate'] = true;
-
-// rate_anonymous : visitors are able to rate pictures (requires
-// $conf['rate'] set to true)
-$conf['rate_anonymous'] = true;
-
// newcat_default_commentable : at creation, must a category be commentable
// or not ?
$conf['newcat_default_commentable'] = 'true';
@@ -171,9 +164,6 @@ $conf['allow_random_representative'] = false;
// category and element description.
$conf['allow_html_descriptions'] = true;
-// galery_url : URL given in RSS feed
-$conf['gallery_url'] = 'http://demo.phpwebgallery.net';
-
// prefix_thumbnail : string before filename. Thumbnail's prefix must only
// contain characters among : a to z (case insensitive), "-" or "_".
$conf['prefix_thumbnail'] = 'TN-';
diff --git a/install/config.sql b/install/config.sql
index 59ff1de28..4371d9fb2 100644
--- a/install/config.sql
+++ b/install/config.sql
@@ -16,4 +16,7 @@ INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('show_nb_comments
INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('gallery_locked','false','Lock your gallery temporary for non admin users');
INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('gallery_title','PhpWebGallery demonstration site','Title at top of each page and for RSS feed');
INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('gallery_description','My photos web site','Short description displayed with gallery title');
+INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('gallery_url','http://demo.phpwebgallery.net','URL given in RSS feed');
+INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('rate','true','Rating pictures feature is enabled');
+INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('rate_anonymous','true','Rating pictures feature is also enabled for visitors');
diff --git a/install/db/8-database.php b/install/db/8-database.php
new file mode 100644
index 000000000..ecbc8bf5e
--- /dev/null
+++ b/install/db/8-database.php
@@ -0,0 +1,88 @@
+ array('http://demo.phpwebgallery.net','URL given in RSS feed'),
+ 'rate' => array('true','Rating pictures feature is enabled') ,
+ 'rate_anonymous' => array('true','Rating pictures feature is also enabled for visitors')
+ );
+
+
+
+// +-Get real values from config file--------------------------------------+
+
+$conf_save = $conf;
+unset($conf);
+@include(PHPWG_ROOT_PATH. 'include/config_local.inc.php');
+if ( isset($conf['gallery_url']) )
+{
+ $params['gallery_url'][0] = $conf['gallery_url'];
+}
+if ( isset($conf['rate']) and is_bool($conf['rate']) )
+{
+ $params['rate'][0] = $conf['rate'] ? 'true' : 'false';
+}
+if ( isset($conf['rate_anonymous']) and is_bool($conf['rate_anonymous']) )
+{
+ $params['rate_anonymous'][0] = $conf['rate_anonymous'] ? 'true' : 'false';
+}
+$conf = $conf_save;
+
+
+
+// +-Do I already have them in DB ?----------------------------------------+
+$query = 'SELECT param FROM '.PREFIX_TABLE.'config';
+$result = pwg_query($query);
+while ($row = mysql_fetch_array($result))
+{
+ unset( $params[ $row['param'] ] );
+}
+
+// +-Perform the insert query----------------------------------------------+
+foreach ($params as $param_key => $param_values)
+{
+ $query = '
+INSERT INTO '.PREFIX_TABLE.'config (param,value,comment) VALUES (' .
+"'$param_key','$param_values[0]','$param_values[1]');";
+ pwg_query($query);
+}
+
+
+echo
+"\n"
+.'Table '.PREFIX_TABLE.'config upgraded'
+."\n"
+;
+?>
diff --git a/language/en_UK.iso-8859-1/admin.lang.php b/language/en_UK.iso-8859-1/admin.lang.php
index 375695195..ed4a4d70d 100644
--- a/language/en_UK.iso-8859-1/admin.lang.php
+++ b/language/en_UK.iso-8859-1/admin.lang.php
@@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | PhpWebGallery - a PHP based picture gallery |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
-// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
+// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
// +-----------------------------------------------------------------------+
// | branch : BSF (Best So Far)
// | file : $RCSfile$
@@ -71,6 +71,7 @@ $lang['Empty caddie'] = 'Empty caddie';
$lang['Environment'] = 'Environment';
$lang['Expand all categories'] = 'Expand all categories';
$lang['Form'] = 'Form';
+$lang['Gallery URL'] = 'Gallery URL';
$lang['Gallery description'] = 'Gallery description';
$lang['Gallery title'] = 'Gallery title';
$lang['Grant selected groups'] = 'Grant selected groups';
@@ -120,6 +121,7 @@ $lang['Properties'] = 'Properties';
$lang['Random picture'] = 'Random picture';
$lang['Rate date'] = 'Rate date';
$lang['Rating'] = 'Rating';
+$lang['Rating by guests'] = 'Rating by guests';
$lang['Recent period'] = 'Recent period';
$lang['Registration date'] = 'Registration date';
$lang['Reject All'] = 'Reject All';
@@ -162,7 +164,6 @@ $lang['authorized'] = 'Authorized';
$lang['cat_add'] = 'Add a virtual category';
$lang['cat_comments_title'] = 'Authorize users to add comments on selected categories';
$lang['cat_error_name'] = 'The name of a category should not be empty';
-$lang['cat_image_info'] = 'Images info';
$lang['cat_lock_title'] = 'Lock categories';
$lang['cat_private'] = 'Private category';
$lang['cat_public'] = 'Public category';
@@ -178,6 +179,7 @@ $lang['conf_comments_title'] = 'Users comments';
$lang['conf_confirmation'] = 'Information data registered in database';
$lang['conf_default'] = 'Default display';
$lang['conf_default_title'] = 'Default display';
+$lang['conf_gallery_url_error'] = 'The gallery URL is not valid.';
$lang['conf_general_title'] = 'Main configuration';
$lang['conf_nb_comment_page_error'] = 'The number of comments a page must be between 5 and 50 included.';
$lang['config'] = 'Configuration';
diff --git a/language/en_UK.iso-8859-1/help/configuration.html b/language/en_UK.iso-8859-1/help/configuration.html
index 59da41881..4e6a73b5d 100644
--- a/language/en_UK.iso-8859-1/help/configuration.html
+++ b/language/en_UK.iso-8859-1/help/configuration.html
@@ -19,6 +19,8 @@ parameters by theme.
Gallery description: displayed under gallery
title.
+
Gallery URL: used for the RSS feed.
+
History: visits on pages category.php and picture.php will be registered in
@@ -29,6 +31,11 @@ parameters by theme.
maintenance. Only administrator users will be able to reach the
gallery.
+
Rating: Picture rating feature is enabled.
+
+
Rating by guests: Even non registered users can
+rate images.
+
diff --git a/language/fr_FR.iso-8859-1/admin.lang.php b/language/fr_FR.iso-8859-1/admin.lang.php
index c369d727f..a90bbdc11 100644
--- a/language/fr_FR.iso-8859-1/admin.lang.php
+++ b/language/fr_FR.iso-8859-1/admin.lang.php
@@ -2,7 +2,7 @@
// +-----------------------------------------------------------------------+
// | PhpWebGallery - a PHP based picture gallery |
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
-// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
+// | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net |
// +-----------------------------------------------------------------------+
// | branch : BSF (Best So Far)
// | file : $RCSfile$
@@ -71,6 +71,7 @@ $lang['Empty caddie'] = 'Vider le panier';
$lang['Environment'] = 'Environnement';
$lang['Expand all categories'] = 'Développer toutes les catégories';
$lang['Form'] = 'Formulaire';
+$lang['Gallery URL'] = 'URL de la galerie';
$lang['Gallery description'] = 'Description de la galerie';
$lang['Gallery title'] = 'Titre de la galerie';
$lang['Grant selected groups'] = 'Donner l\'accès aux groupes sélectionnés';
@@ -120,6 +121,7 @@ $lang['Properties'] = 'Propri
$lang['Random picture'] = 'Au hasard';
$lang['Rate date'] = 'Date de notation';
$lang['Rating'] = 'Notation';
+$lang['Rating by guests'] = 'Notation par les visiteurs';
$lang['Recent period'] = 'Période récente';
$lang['Registration date'] = 'Date d\'enregistrement';
$lang['Reject All'] = 'Tout rejeter';
@@ -177,6 +179,7 @@ $lang['conf_comments_title'] = 'Commentaires utilisateur';
$lang['conf_confirmation'] = 'Informations enregistrées dans la base de données';
$lang['conf_default'] = 'Affichage par défaut';
$lang['conf_default_title'] = 'Affichage par défaut';
+$lang['conf_gallery_url_error'] = 'L\'adresse de la galerie n\'est pas valide.';
$lang['conf_general_title'] = 'Configuration principale';
$lang['conf_nb_comment_page_error'] = 'Le nombre de commentaires utilisateurs par page doit être compris entre 5 et 50.';
$lang['config'] = 'Configuration';
diff --git a/language/fr_FR.iso-8859-1/help/configuration.html b/language/fr_FR.iso-8859-1/help/configuration.html
index 5b35abd17..55b453e83 100644
--- a/language/fr_FR.iso-8859-1/help/configuration.html
+++ b/language/fr_FR.iso-8859-1/help/configuration.html
@@ -19,6 +19,8 @@ de la partie publique.
Description de la galerie: affiché en dessous du
titre de la galerie.
+
URL de la galerie: utilisé pour le flux RSS.
+
Historique: visites des pages category.php et picture.php sont enregistrées dans la table
@@ -29,6 +31,11 @@ class="pwgScreen">Administration, G
galerie pour maintenance. Seul les administrateurs pourront accéder à la
galerie.
+
Notation: La notation des photos est possible.
+
+
Notation par les visiteurs: Même les utilisateurs
+non enregistrés peuvent noter les images.