feature:2786 Allow to edit website url in user comments + improve "user experience" on comment edition
git-svn-id: http://piwigo.org/svn/trunk@18995 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
c81093b0e9
commit
2fa1013ace
6 changed files with 50 additions and 19 deletions
24
comments.php
24
comments.php
|
@ -233,23 +233,35 @@ if (isset($action))
|
||||||
if (!empty($_POST['content']))
|
if (!empty($_POST['content']))
|
||||||
{
|
{
|
||||||
check_pwg_token();
|
check_pwg_token();
|
||||||
update_user_comment(
|
$comment_action = update_user_comment(
|
||||||
array(
|
array(
|
||||||
'comment_id' => $_GET['edit'],
|
'comment_id' => $_GET['edit'],
|
||||||
'image_id' => $_POST['image_id'],
|
'image_id' => $_POST['image_id'],
|
||||||
'content' => $_POST['content']
|
'content' => $_POST['content'],
|
||||||
|
'website_url' => @$_POST['website_url'],
|
||||||
),
|
),
|
||||||
$_POST['key']
|
$_POST['key']
|
||||||
);
|
);
|
||||||
|
|
||||||
$perform_redirect = true;
|
switch ($comment_action)
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
$edit_comment = $_GET['edit'];
|
case 'moderate':
|
||||||
|
$_SESSION['page_infos'][] = l10n('An administrator must authorize your comment before it is visible.');
|
||||||
|
case 'validate':
|
||||||
|
$_SESSION['page_infos'][] = l10n('Your comment has been registered');
|
||||||
|
$perform_redirect = true;
|
||||||
|
break;
|
||||||
|
case 'reject':
|
||||||
|
$_SESSION['page_errors'][] = l10n('Your comment has NOT been registered because it did not pass the validation rules');
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
trigger_error('Invalid comment action '.$comment_action, E_USER_WARNING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$edit_comment = $_GET['edit'];
|
||||||
|
}
|
||||||
|
|
||||||
if ($perform_redirect)
|
if ($perform_redirect)
|
||||||
{
|
{
|
||||||
$redirect_url =
|
$redirect_url =
|
||||||
|
|
|
@ -309,7 +309,7 @@ $user_where_clause.'
|
||||||
|
|
||||||
function update_user_comment($comment, $post_key)
|
function update_user_comment($comment, $post_key)
|
||||||
{
|
{
|
||||||
global $conf;
|
global $conf, $page;
|
||||||
|
|
||||||
$comment_action = 'validate';
|
$comment_action = 'validate';
|
||||||
|
|
||||||
|
@ -335,6 +335,20 @@ function update_user_comment($comment, $post_key)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// website
|
||||||
|
if (!empty($comment['website_url']))
|
||||||
|
{
|
||||||
|
if (!preg_match('/^https?/i', $comment['website_url']))
|
||||||
|
{
|
||||||
|
$comment['website_url'] = 'http://'.$comment['website_url'];
|
||||||
|
}
|
||||||
|
if (!url_check_format($comment['website_url']))
|
||||||
|
{
|
||||||
|
array_push($page['errors'], l10n('Your website URL is invalid'));
|
||||||
|
$comment_action='reject';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( $comment_action!='reject' )
|
if ( $comment_action!='reject' )
|
||||||
{
|
{
|
||||||
$user_where_clause = '';
|
$user_where_clause = '';
|
||||||
|
@ -347,6 +361,7 @@ function update_user_comment($comment, $post_key)
|
||||||
$query = '
|
$query = '
|
||||||
UPDATE '.COMMENTS_TABLE.'
|
UPDATE '.COMMENTS_TABLE.'
|
||||||
SET content = \''.$comment['content'].'\',
|
SET content = \''.$comment['content'].'\',
|
||||||
|
website_url = '.(!empty($comment['website_url']) ? '\''.$comment['website_url'].'\'' : 'NULL').',
|
||||||
validated = \''.($comment_action=='validate' ? 'true':'false').'\',
|
validated = \''.($comment_action=='validate' ? 'true':'false').'\',
|
||||||
validation_date = '.($comment_action=='validate' ? 'NOW()':'NULL').'
|
validation_date = '.($comment_action=='validate' ? 'NOW()':'NULL').'
|
||||||
WHERE id = '.$comment['comment_id'].
|
WHERE id = '.$comment['comment_id'].
|
||||||
|
|
|
@ -392,6 +392,7 @@ $lang['View'] = "View";
|
||||||
$lang['Visits'] = "Visits";
|
$lang['Visits'] = "Visits";
|
||||||
$lang['Visits, high → low'] = 'Visits, high → low';
|
$lang['Visits, high → low'] = 'Visits, high → low';
|
||||||
$lang['Visits, low → high'] = 'Visits, low → high';
|
$lang['Visits, low → high'] = 'Visits, low → high';
|
||||||
|
$lang['Website'] = 'Website';
|
||||||
$lang['Webmaster'] = "Webmaster";
|
$lang['Webmaster'] = "Webmaster";
|
||||||
$lang['Week %d'] = "Week %d";
|
$lang['Week %d'] = "Week %d";
|
||||||
$lang['Welcome to your Piwigo photo gallery!'] = 'Welcome to your Piwigo photo gallery!';
|
$lang['Welcome to your Piwigo photo gallery!'] = 'Welcome to your Piwigo photo gallery!';
|
||||||
|
@ -409,5 +410,6 @@ $lang['Your favorites'] = "Your favorites";
|
||||||
$lang['Your Gallery Customization'] = "Your gallery customization";
|
$lang['Your Gallery Customization'] = "Your gallery customization";
|
||||||
$lang['Your password has been reset'] = 'Your password has been reset';
|
$lang['Your password has been reset'] = 'Your password has been reset';
|
||||||
$lang['Your username has been successfully changed to : %s'] = 'Your username has been successfully changed to : %s';
|
$lang['Your username has been successfully changed to : %s'] = 'Your username has been successfully changed to : %s';
|
||||||
|
$lang['Your website URL is invalid'] = 'Your website URL is invalid';
|
||||||
$lang['mandatory'] = 'mandatory';
|
$lang['mandatory'] = 'mandatory';
|
||||||
?>
|
?>
|
|
@ -410,4 +410,6 @@ $lang['Requested tag does not exist'] = 'Le tag demandée n\'existe pas';
|
||||||
$lang['Username is mandatory'] = 'Nom d\'utilisateur obligatoire';
|
$lang['Username is mandatory'] = 'Nom d\'utilisateur obligatoire';
|
||||||
$lang['Email address is mandatory'] = 'Adresse email obligatoire';
|
$lang['Email address is mandatory'] = 'Adresse email obligatoire';
|
||||||
$lang['mandatory'] = 'obligatoire';
|
$lang['mandatory'] = 'obligatoire';
|
||||||
|
$lang['Website'] = 'Site web';
|
||||||
|
$lang['Your website URL is invalid'] = 'L\'adresse de votre site web est invalide';
|
||||||
?>
|
?>
|
|
@ -349,7 +349,8 @@ UPDATE '.USER_CACHE_CATEGORIES_TABLE.'
|
||||||
array(
|
array(
|
||||||
'comment_id' => $_GET['comment_to_edit'],
|
'comment_id' => $_GET['comment_to_edit'],
|
||||||
'image_id' => $page['image_id'],
|
'image_id' => $page['image_id'],
|
||||||
'content' => $_POST['content']
|
'content' => $_POST['content'],
|
||||||
|
'website_url' => @$_POST['website_url'],
|
||||||
),
|
),
|
||||||
$_POST['key']
|
$_POST['key']
|
||||||
);
|
);
|
||||||
|
@ -365,7 +366,6 @@ UPDATE '.USER_CACHE_CATEGORIES_TABLE.'
|
||||||
break;
|
break;
|
||||||
case 'reject':
|
case 'reject':
|
||||||
$_SESSION['page_errors'][] = l10n('Your comment has NOT been registered because it did not pass the validation rules');
|
$_SESSION['page_errors'][] = l10n('Your comment has NOT been registered because it did not pass the validation rules');
|
||||||
$perform_redirect = true;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
trigger_error('Invalid comment action '.$comment_action, E_USER_WARNING);
|
trigger_error('Invalid comment action '.$comment_action, E_USER_WARNING);
|
||||||
|
@ -377,11 +377,9 @@ UPDATE '.USER_CACHE_CATEGORIES_TABLE.'
|
||||||
}
|
}
|
||||||
unset($_POST['content']);
|
unset($_POST['content']);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
$edit_comment = $_GET['comment_to_edit'];
|
$edit_comment = $_GET['comment_to_edit'];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'delete_comment' :
|
case 'delete_comment' :
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.content .commentElement .description{ldelim}
|
.content .commentElement .description{ldelim}
|
||||||
height: {$comment_derivative_params->max_height()+5}px
|
min-height: {$comment_derivative_params->max_height()+5}px
|
||||||
}
|
}
|
||||||
{/html_style}{/strip}
|
{/html_style}{/strip}
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -28,7 +28,7 @@
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<div class="description"{if isset($comment.IN_EDIT)} style="height:200px"{/if}>
|
<div class="description">
|
||||||
{if isset($comment.U_DELETE) or isset($comment.U_VALIDATE) or isset($comment.U_EDIT)}
|
{if isset($comment.U_DELETE) or isset($comment.U_VALIDATE) or isset($comment.U_EDIT)}
|
||||||
<div class="actions" style="float:right;font-size:90%">
|
<div class="actions" style="float:right;font-size:90%">
|
||||||
{if isset($comment.U_DELETE)}
|
{if isset($comment.U_DELETE)}
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
{if isset($comment.U_CANCEL)}
|
{if isset($comment.U_CANCEL)}
|
||||||
<a href="{$comment.U_CANCEL}">
|
<a href="{$comment.U_CANCEL}">
|
||||||
{'Cancel'|@translate}
|
{'Cancel'|@translate}
|
||||||
</a>{if isset($comment.U_VALIDATE) or isset($comment.U_EDIT)} | {/if}
|
</a>{if isset($comment.U_VALIDATE)} | {/if}
|
||||||
{/if}
|
{/if}
|
||||||
{if isset($comment.U_EDIT) and !isset($comment.IN_EDIT)}
|
{if isset($comment.U_EDIT) and !isset($comment.IN_EDIT)}
|
||||||
<a class="editComment" href="{$comment.U_EDIT}#edit_comment">
|
<a class="editComment" href="{$comment.U_EDIT}#edit_comment">
|
||||||
|
@ -60,8 +60,10 @@
|
||||||
{if isset($comment.IN_EDIT)}
|
{if isset($comment.IN_EDIT)}
|
||||||
<a name="edit_comment"></a>
|
<a name="edit_comment"></a>
|
||||||
<form method="post" action="{$comment.U_EDIT}" id="editComment">
|
<form method="post" action="{$comment.U_EDIT}" id="editComment">
|
||||||
<p><label>{'Edit a comment'|@translate} :</label></p>
|
<p><label for="contenteditid">{'Edit a comment'|@translate} :</label></p>
|
||||||
<p><textarea name="content" id="contenteditid" rows="5" cols="80">{$comment.CONTENT|@escape}</textarea></p>
|
<p><textarea name="content" id="contenteditid" rows="5" cols="80">{$comment.CONTENT|@escape}</textarea></p>
|
||||||
|
<p><label for="website_url">{'Website'|@translate} :</label></p>
|
||||||
|
<p><input type="text" name="website_url" id="website_url" value="{$comment.WEBSITE_URL}" size="40"></p>
|
||||||
<p><input type="hidden" name="key" value="{$comment.KEY}">
|
<p><input type="hidden" name="key" value="{$comment.KEY}">
|
||||||
<input type="hidden" name="pwg_token" value="{$comment.PWG_TOKEN}">
|
<input type="hidden" name="pwg_token" value="{$comment.PWG_TOKEN}">
|
||||||
<input type="hidden" name="image_id" value="{$comment.IMAGE_ID|@default:$current.id}">
|
<input type="hidden" name="image_id" value="{$comment.IMAGE_ID|@default:$current.id}">
|
||||||
|
|
Loading…
Add table
Reference in a new issue