Changeset 18995


Ignore:
Timestamp:
Nov 11, 2012, 4:01:09 PM (11 years ago)
Author:
mistic100
Message:

feature:2786 Allow to edit website url in user comments + improve "user experience" on comment edition

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/comments.php

    r18164 r18995  
    234234      {
    235235        check_pwg_token();
    236         update_user_comment(
     236        $comment_action = update_user_comment(
    237237          array(
    238238            'comment_id' => $_GET['edit'],
    239239            'image_id' => $_POST['image_id'],
    240             'content' => $_POST['content']
     240            'content' => $_POST['content'],
     241            'website_url' => @$_POST['website_url'],
    241242            ),
    242243          $_POST['key']
    243244          );
    244 
    245         $perform_redirect = true;
     245       
     246        switch ($comment_action)
     247        {
     248          case 'moderate':
     249            $_SESSION['page_infos'][] = l10n('An administrator must authorize your comment before it is visible.');
     250          case 'validate':
     251            $_SESSION['page_infos'][] = l10n('Your comment has been registered');
     252            $perform_redirect = true;
     253            break;
     254          case 'reject':
     255            $_SESSION['page_errors'][] = l10n('Your comment has NOT been registered because it did not pass the validation rules');
     256            break;
     257          default:
     258            trigger_error('Invalid comment action '.$comment_action, E_USER_WARNING);
     259        }
    246260      }
    247       else
    248       {
    249         $edit_comment = $_GET['edit'];
    250       }
     261     
     262      $edit_comment = $_GET['edit'];
    251263    }
    252264
  • trunk/include/functions_comment.inc.php

    r18164 r18995  
    310310function update_user_comment($comment, $post_key)
    311311{
    312   global $conf;
     312  global $conf, $page;
    313313
    314314  $comment_action = 'validate';
     
    336336                  );
    337337
     338  // website
     339  if (!empty($comment['website_url']))
     340  {
     341    if (!preg_match('/^https?/i', $comment['website_url']))
     342    {
     343      $comment['website_url'] = 'http://'.$comment['website_url'];
     344    }
     345    if (!url_check_format($comment['website_url']))
     346    {
     347      array_push($page['errors'], l10n('Your website URL is invalid'));
     348      $comment_action='reject';
     349    }
     350  }
     351
    338352  if ( $comment_action!='reject' )
    339353  {
     
    348362UPDATE '.COMMENTS_TABLE.'
    349363  SET content = \''.$comment['content'].'\',
     364      website_url = '.(!empty($comment['website_url']) ? '\''.$comment['website_url'].'\'' : 'NULL').',
    350365      validated = \''.($comment_action=='validate' ? 'true':'false').'\',
    351366      validation_date = '.($comment_action=='validate' ? 'NOW()':'NULL').'
  • trunk/language/en_UK/common.lang.php

    r18164 r18995  
    393393$lang['Visits, high → low'] = 'Visits, high → low';
    394394$lang['Visits, low → high'] = 'Visits, low → high';
     395$lang['Website'] = 'Website';
    395396$lang['Webmaster'] = "Webmaster";
    396397$lang['Week %d'] = "Week %d";
     
    410411$lang['Your password has been reset'] = 'Your password has been reset';
    411412$lang['Your username has been successfully changed to : %s'] = 'Your username has been successfully changed to : %s';
     413$lang['Your website URL is invalid'] = 'Your website URL is invalid';
    412414$lang['mandatory'] = 'mandatory';
    413415?>
  • trunk/language/fr_FR/common.lang.php

    r18164 r18995  
    411411$lang['Email address is mandatory'] = 'Adresse email obligatoire';
    412412$lang['mandatory'] = 'obligatoire';
     413$lang['Website'] = 'Site web';
     414$lang['Your website URL is invalid'] = 'L\'adresse de votre site web est invalide';
    413415?>
  • trunk/picture.php

    r18760 r18995  
    350350              'comment_id' => $_GET['comment_to_edit'],
    351351              'image_id' => $page['image_id'],
    352               'content' => $_POST['content']
     352              'content' => $_POST['content'],
     353              'website_url' => @$_POST['website_url'],
    353354              ),
    354355            $_POST['key']
     
    366367            case 'reject':
    367368              $_SESSION['page_errors'][] = l10n('Your comment has NOT been registered because it did not pass the validation rules');
    368               $perform_redirect = true;
    369369              break;
    370370            default:
     
    378378          unset($_POST['content']);
    379379        }
    380         else
    381         {
    382           $edit_comment = $_GET['comment_to_edit'];
    383         }
     380       
     381        $edit_comment = $_GET['comment_to_edit'];
    384382      }
    385383      break;
  • trunk/themes/default/template/comment_list.tpl

    r18748 r18995  
    66
    77.content .commentElement .description{ldelim}
    8         height: {$comment_derivative_params->max_height()+5}px
     8        min-height: {$comment_derivative_params->max_height()+5}px
    99}
    1010{/html_style}{/strip}
     
    2929        </div>
    3030        {/if}
    31         <div class="description"{if isset($comment.IN_EDIT)} style="height:200px"{/if}>
     31        <div class="description">
    3232                {if isset($comment.U_DELETE) or isset($comment.U_VALIDATE) or isset($comment.U_EDIT)}
    3333                <div class="actions" style="float:right;font-size:90%">
     
    4040                        <a href="{$comment.U_CANCEL}">
    4141                                {'Cancel'|@translate}
    42                         </a>{if isset($comment.U_VALIDATE) or isset($comment.U_EDIT)} | {/if}
     42                        </a>{if isset($comment.U_VALIDATE)} | {/if}
    4343                {/if}
    4444                {if isset($comment.U_EDIT) and !isset($comment.IN_EDIT)}
     
    6161                <a name="edit_comment"></a>
    6262                <form method="post" action="{$comment.U_EDIT}" id="editComment">
    63                         <p><label>{'Edit a comment'|@translate} :</label></p>
     63                        <p><label for="contenteditid">{'Edit a comment'|@translate} :</label></p>
    6464                        <p><textarea name="content" id="contenteditid" rows="5" cols="80">{$comment.CONTENT|@escape}</textarea></p>
     65                        <p><label for="website_url">{'Website'|@translate} :</label></p>
     66                        <p><input type="text" name="website_url" id="website_url" value="{$comment.WEBSITE_URL}" size="40"></p>
    6567                        <p><input type="hidden" name="key" value="{$comment.KEY}">
    6668                                <input type="hidden" name="pwg_token" value="{$comment.PWG_TOKEN}">
Note: See TracChangeset for help on using the changeset viewer.