aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormistic100 <mistic@piwigo.org>2012-11-11 15:01:09 +0000
committermistic100 <mistic@piwigo.org>2012-11-11 15:01:09 +0000
commit2fa1013ace21fe6df7beb9c8505a256244fa637e (patch)
tree47546c1d28894f816779758385e53f5c31c2f66e
parentc81093b0e943d3625554c808ecb072ef20615d6f (diff)
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
Diffstat (limited to '')
-rw-r--r--comments.php28
-rw-r--r--include/functions_comment.inc.php17
-rw-r--r--language/en_UK/common.lang.php2
-rw-r--r--language/fr_FR/common.lang.php2
-rw-r--r--picture.php10
-rw-r--r--themes/default/template/comment_list.tpl10
6 files changed, 50 insertions, 19 deletions
diff --git a/comments.php b/comments.php
index 1cd19890d..5eff03e90 100644
--- a/comments.php
+++ b/comments.php
@@ -233,21 +233,33 @@ if (isset($action))
if (!empty($_POST['content']))
{
check_pwg_token();
- update_user_comment(
+ $comment_action = update_user_comment(
array(
'comment_id' => $_GET['edit'],
'image_id' => $_POST['image_id'],
- 'content' => $_POST['content']
+ 'content' => $_POST['content'],
+ 'website_url' => @$_POST['website_url'],
),
$_POST['key']
);
-
- $perform_redirect = true;
- }
- else
- {
- $edit_comment = $_GET['edit'];
+
+ switch ($comment_action)
+ {
+ 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)
diff --git a/include/functions_comment.inc.php b/include/functions_comment.inc.php
index 67716216c..b388439f5 100644
--- a/include/functions_comment.inc.php
+++ b/include/functions_comment.inc.php
@@ -309,7 +309,7 @@ $user_where_clause.'
function update_user_comment($comment, $post_key)
{
- global $conf;
+ global $conf, $page;
$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' )
{
$user_where_clause = '';
@@ -347,6 +361,7 @@ function update_user_comment($comment, $post_key)
$query = '
UPDATE '.COMMENTS_TABLE.'
SET content = \''.$comment['content'].'\',
+ website_url = '.(!empty($comment['website_url']) ? '\''.$comment['website_url'].'\'' : 'NULL').',
validated = \''.($comment_action=='validate' ? 'true':'false').'\',
validation_date = '.($comment_action=='validate' ? 'NOW()':'NULL').'
WHERE id = '.$comment['comment_id'].
diff --git a/language/en_UK/common.lang.php b/language/en_UK/common.lang.php
index 54b221e4b..cef1111d1 100644
--- a/language/en_UK/common.lang.php
+++ b/language/en_UK/common.lang.php
@@ -392,6 +392,7 @@ $lang['View'] = "View";
$lang['Visits'] = "Visits";
$lang['Visits, high &rarr; low'] = 'Visits, high &rarr; low';
$lang['Visits, low &rarr; high'] = 'Visits, low &rarr; high';
+$lang['Website'] = 'Website';
$lang['Webmaster'] = "Webmaster";
$lang['Week %d'] = "Week %d";
$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 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 website URL is invalid'] = 'Your website URL is invalid';
$lang['mandatory'] = 'mandatory';
?> \ No newline at end of file
diff --git a/language/fr_FR/common.lang.php b/language/fr_FR/common.lang.php
index bd278d927..6934b675f 100644
--- a/language/fr_FR/common.lang.php
+++ b/language/fr_FR/common.lang.php
@@ -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['Email address is mandatory'] = 'Adresse email obligatoire';
$lang['mandatory'] = 'obligatoire';
+$lang['Website'] = 'Site web';
+$lang['Your website URL is invalid'] = 'L\'adresse de votre site web est invalide';
?> \ No newline at end of file
diff --git a/picture.php b/picture.php
index 4d89edc77..663a192b3 100644
--- a/picture.php
+++ b/picture.php
@@ -349,7 +349,8 @@ UPDATE '.USER_CACHE_CATEGORIES_TABLE.'
array(
'comment_id' => $_GET['comment_to_edit'],
'image_id' => $page['image_id'],
- 'content' => $_POST['content']
+ 'content' => $_POST['content'],
+ 'website_url' => @$_POST['website_url'],
),
$_POST['key']
);
@@ -365,7 +366,6 @@ UPDATE '.USER_CACHE_CATEGORIES_TABLE.'
break;
case 'reject':
$_SESSION['page_errors'][] = l10n('Your comment has NOT been registered because it did not pass the validation rules');
- $perform_redirect = true;
break;
default:
trigger_error('Invalid comment action '.$comment_action, E_USER_WARNING);
@@ -377,10 +377,8 @@ UPDATE '.USER_CACHE_CATEGORIES_TABLE.'
}
unset($_POST['content']);
}
- else
- {
- $edit_comment = $_GET['comment_to_edit'];
- }
+
+ $edit_comment = $_GET['comment_to_edit'];
}
break;
}
diff --git a/themes/default/template/comment_list.tpl b/themes/default/template/comment_list.tpl
index 05ee28f75..df60a453a 100644
--- a/themes/default/template/comment_list.tpl
+++ b/themes/default/template/comment_list.tpl
@@ -5,7 +5,7 @@
}
.content .commentElement .description{ldelim}
- height: {$comment_derivative_params->max_height()+5}px
+ min-height: {$comment_derivative_params->max_height()+5}px
}
{/html_style}{/strip}
{/if}
@@ -28,7 +28,7 @@
</a>
</div>
{/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)}
<div class="actions" style="float:right;font-size:90%">
{if isset($comment.U_DELETE)}
@@ -39,7 +39,7 @@
{if isset($comment.U_CANCEL)}
<a href="{$comment.U_CANCEL}">
{'Cancel'|@translate}
- </a>{if isset($comment.U_VALIDATE) or isset($comment.U_EDIT)} | {/if}
+ </a>{if isset($comment.U_VALIDATE)} | {/if}
{/if}
{if isset($comment.U_EDIT) and !isset($comment.IN_EDIT)}
<a class="editComment" href="{$comment.U_EDIT}#edit_comment">
@@ -60,8 +60,10 @@
{if isset($comment.IN_EDIT)}
<a name="edit_comment"></a>
<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><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}">
<input type="hidden" name="pwg_token" value="{$comment.PWG_TOKEN}">
<input type="hidden" name="image_id" value="{$comment.IMAGE_ID|@default:$current.id}">