Skip to content

Commit

Permalink
- feature 599: option to forbid user registration
Browse files Browse the repository at this point in the history
- 1 language cleanup
- added page_forbidden function (sends 403)

git-svn-id: http://piwigo.org/svn/trunk@1652 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
rvelices committed Dec 13, 2006
1 parent 5046b3c commit 74e5d80
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 12 deletions.
3 changes: 2 additions & 1 deletion admin/configuration.php
Expand Up @@ -52,7 +52,8 @@
'history_admin',
'history_guest',
'login_history',
'email_admin_on_new_user'
'email_admin_on_new_user',
'allow_user_registration',
);

$comments_checkboxes = array(
Expand Down
9 changes: 6 additions & 3 deletions identification.php
Expand Up @@ -57,8 +57,7 @@
if ($row['password'] == $conf['pass_convert']($_POST['password']))
{
$remember_me = false;
if ($conf['authorize_remembering']
and isset($_POST['remember_me'])
if (isset($_POST['remember_me'])
and $_POST['remember_me'] == 1)
{
$remember_me = true;
Expand All @@ -85,7 +84,6 @@

$template->assign_vars(
array(

'U_REGISTER' => PHPWG_ROOT_PATH.'register.php',
'U_LOST_PASSWORD' => PHPWG_ROOT_PATH.'password.php',
'U_HOME' => make_index_url(),
Expand All @@ -98,6 +96,11 @@
{
$template->assign_block_vars('remember_me',array());
}
if ($conf['allow_user_registration'])
{
$template->assign_block_vars('register',array());
}

//-------------------------------------------------------------- errors display
if ( sizeof( $errors ) != 0 )
{
Expand Down
17 changes: 17 additions & 0 deletions include/functions_html.inc.php
Expand Up @@ -613,6 +613,23 @@ function access_denied()
}
}

/**
* exits the current script with 403 code
* @param string msg a message to display
* @param string alternate_url redirect to this url
*/
function page_forbidden($msg, $alternate_url=null)
{
set_status_header(403);
if ($alternate_url==null)
$alternate_url = make_index_url();
redirect_html( $alternate_url,
'<div style="text-align:left; margin-left:5em;margin-bottom:5em;">
<h1 style="text-align:left; font-size:36px;">Forbidden</h1><br/>'
.$msg.'</div>',
5 );
}

/**
* exits the current script with 404 code when a page cannot be found
* @param string msg a message to display
Expand Down
6 changes: 5 additions & 1 deletion include/menubar.inc.php
Expand Up @@ -206,14 +206,18 @@

if ($user['is_the_guest'])
{
$template->assign_block_vars('register', array());
$template->assign_block_vars('login', array());

$template->assign_block_vars('quickconnect', array());
if ($conf['authorize_remembering'])
{
$template->assign_block_vars('quickconnect.remember_me', array());
}
if ($conf['allow_user_registration'])
{
$template->assign_block_vars('register', array());
$template->assign_block_vars('quickconnect.register', array());
}
}
else
{
Expand Down
1 change: 1 addition & 0 deletions install/config.sql
Expand Up @@ -22,6 +22,7 @@ INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('page_banner','<h
INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('history_admin','false','keep a history of administrator visits on your website');
INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('history_guest','true','keep a history of guest visits on your website');
INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('login_history','true','keep a history of user logins on your website');
INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('allow_user_registration','true','allow visitors to register?');
-- Notification by mail
INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('nbm_send_mail_as','','Send mail as param value for notification by mail');
INSERT INTO phpwebgallery_config (param,value,comment) VALUES ('nbm_send_detailed_content','true','Send detailed content for notification by mail');
Expand Down
2 changes: 1 addition & 1 deletion language/en_UK.iso-8859-1/admin.lang.php
Expand Up @@ -48,6 +48,7 @@
$lang['Add group'] = 'Add group';
$lang['Add selected elements to caddie'] = 'Add selected elements to caddie';
$lang['Add'] = 'Add';
$lang['Allow user registration'] = 'Allow user registration';
$lang['Apply to subcategories'] = 'Apply to subcategories';
$lang['Are you sure?'] = 'Are you sure?';
$lang['Associated'] = 'Associated';
Expand Down Expand Up @@ -152,7 +153,6 @@
$lang['Rating by guests'] = 'Rating by guests';
$lang['Rating'] = 'Rating';
$lang['Recent period'] = 'Recent period';
$lang['Registration date'] = 'Registration date';
$lang['Reject All'] = 'Reject All';
$lang['Reject'] = 'Reject';
$lang['Representant'] = 'Representant';
Expand Down
2 changes: 1 addition & 1 deletion language/fr_FR.iso-8859-1/admin.lang.php
Expand Up @@ -48,6 +48,7 @@
$lang['Add group'] = 'Ajouter un groupe';
$lang['Add selected elements to caddie'] = 'Ajouter les éléments sélectionnés au panier';
$lang['Add'] = 'Ajouter';
$lang['Allow user registration'] = 'Permettre l\'enregistrement des utilisateurs';
$lang['Apply to subcategories'] = 'Appliquer au sous-catégories';
$lang['Are you sure?'] = 'Etes-vous sur?';
$lang['Associated'] = 'Associée à';
Expand Down Expand Up @@ -152,7 +153,6 @@
$lang['Rating by guests'] = 'Notation par les visiteurs';
$lang['Rating'] = 'Notation';
$lang['Recent period'] = 'Période récente';
$lang['Registration date'] = 'Date d\'enregistrement';
$lang['Reject All'] = 'Tout rejeter';
$lang['Reject'] = 'Rejeter';
$lang['Representant'] = 'Représentant';
Expand Down
6 changes: 6 additions & 0 deletions register.php
Expand Up @@ -29,6 +29,12 @@
define('PHPWG_ROOT_PATH','./');
include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
//----------------------------------------------------------- user registration

if (!$conf['allow_user_registration'])
{
page_forbidden('User registration closed');
}

$errors = array();
if (isset($_POST['submit']))
{
Expand Down
7 changes: 7 additions & 0 deletions template/yoga/admin/configuration.tpl
Expand Up @@ -59,6 +59,13 @@
</label>
</li>

<li>
<label for="allow_user_registration">
<span class="property">{lang:Allow user registration}</span>
<input type="checkbox" name="allow_user_registration" id="allow_user_registration" {general.ALLOW_USER_REGISTRATION} />
</label>
</li>

<br/>
<li>
<fieldset>
Expand Down
4 changes: 2 additions & 2 deletions template/yoga/admin/picture_modify.tpl
Expand Up @@ -23,7 +23,7 @@
</tr>

<tr>
<td><strong>{lang:Registration date}</strong></td>
<td><strong>{lang:Post date}</strong></td>
<td>{REGISTRATION_DATE}</td>
</tr>

Expand Down Expand Up @@ -103,7 +103,7 @@
<td>{TAG_SELECTION}</td>
</tr>


<tr>
<td><strong>{lang:Description}</strong></td>
<td><textarea name="description" class="description">{DESCRIPTION}</textarea></td>
Expand Down
1 change: 1 addition & 0 deletions template/yoga/default-layout.css
Expand Up @@ -181,6 +181,7 @@ FORM.properties LI, FORM#update UL {
margin-bottom: 0.5em;
padding: 0;
line-height: 1.8em;
clear: left;
}

FORM.properties SPAN.property {
Expand Down
8 changes: 6 additions & 2 deletions template/yoga/identification.tpl
Expand Up @@ -4,7 +4,9 @@
<div class="titrePage">
<ul class="categoryActions">
<li><a href="{U_LOST_PASSWORD}" title="{lang:Forgot your password?}"><img src="{themeconf:icon_dir}/lost_password.png" class="button" alt="{lang:Forgot your password?}"></a></li>
<!-- BEGIN register -->
<li><a href="{U_REGISTER}" title="{lang:Create a new account}"><img src="{themeconf:icon_dir}/register.png" class="button" alt="{lang:register}"/></a></li>
<!-- END register -->
<li><a href="{U_HOME}" title="{lang:Go through the gallery as a visitor}"><img src="{themeconf:icon_dir}/home.png" class="button" alt="{lang:home}"/></a></li>
</ul>
<h2>{lang:Identification}</h2>
Expand Down Expand Up @@ -60,8 +62,10 @@ document.login_form.username.focus();
//--></script>

<p>
<a href="{U_REGISTER}"><img src="{themeconf:icon_dir}/register.png" class="button" alt=""> {lang:Register}</a>
<a href="{U_LOST_PASSWORD}"><img src="{themeconf:icon_dir}/lost_password.png" class="button" alt=""> {lang:Forgot your password?}</a>
<!-- BEGIN register -->
<a href="{U_REGISTER}" title="{lang:Create a new account}"><img src="{themeconf:icon_dir}/register.png" class="button" alt=""> {lang:Register}</a>
<!-- END register -->
<a href="{U_LOST_PASSWORD}" title="{lang:Forgot your password?}"><img src="{themeconf:icon_dir}/lost_password.png" class="button" alt=""> {lang:Forgot your password?}</a>
</p>

</div> <!-- content -->
4 changes: 3 additions & 1 deletion template/yoga/menubar.tpl
Expand Up @@ -79,7 +79,7 @@
<!-- END hello -->
<ul>
<!-- BEGIN register -->
<li><a href="{U_REGISTER}" rel="nofollow">{lang:Register}</a></li>
<li><a href="{U_REGISTER}" title="{lang:Create a new account}" rel="nofollow">{lang:Register}</a></li>
<!-- END register -->
<!-- BEGIN login -->
<li><a href="{F_IDENTIFY}" rel="nofollow">{lang:Connection}</a></li>
Expand Down Expand Up @@ -121,7 +121,9 @@
</p>
<ul class="actions">
<li><a href="{U_LOST_PASSWORD}" title="{lang:Forgot your password?}" rel="nofollow"><img src="{pwg_root}{themeconf:icon_dir}/lost_password.png" class="button" alt="{lang:Forgot your password?}"></a></li>
<!-- BEGIN register -->
<li><a href="{U_REGISTER}" title="{lang:Create a new account}" rel="nofollow"><img src="{pwg_root}{themeconf:icon_dir}/register.png" class="button" alt="{lang:register}"/></a></li>
<!-- END register -->
</ul>

</fieldset>
Expand Down

0 comments on commit 74e5d80

Please sign in to comment.