Changeset 2393
- Timestamp:
- 05/19/08 19:10:48 (21 months ago)
- Location:
- branches/release-38
- Files:
-
- 4 modified
-
default_templates/comment_response.mtml (modified) (1 diff)
-
default_templates/comments.mtml (modified) (2 diffs)
-
default_templates/javascript.mtml (modified) (9 diffs)
-
lib/MT/App/Comments.pm (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/release-38/default_templates/comment_response.mtml
r2191 r2393 16 16 <mt:ignore><!-- Error message when comment submission fails --></mt:ignore> 17 17 <MTSetVar name="page_title" value="<__trans phrase="Comment Submission Error">"> 18 <MTSetVarBlock name="message">< __trans phrase="Your comment submission failed for the following reasons: [_1]" params="<$MTErrorMessage$>"></MTSetVarBlock>18 <MTSetVarBlock name="message"><p><__trans phrase="Your comment submission failed for the following reasons: [_1]" params="<$MTErrorMessage$>"></p></MTSetVarBlock> 19 19 </MTIf> 20 20 -
branches/release-38/default_templates/comments.mtml
r2376 r2393 61 61 <input type="hidden" name="armor" value="1" /> 62 62 <input type="hidden" name="preview" value="" /> 63 <input type="hidden" name="sid" value="" /> 63 64 <div id="comments-open-data"> 64 65 <div id="comment-form-name"> 65 66 <label for="comment-author"><__trans phrase="Name"></label> 66 <input id="comment-author" name="author" size="30" value="" onfocus="mt ShowCaptcha()" />67 <input id="comment-author" name="author" size="30" value="" onfocus="mtCommentFormOnFocus()" /> 67 68 </div> 68 69 <div id="comment-form-email"> 69 70 <label for="comment-email"><__trans phrase="Email Address"></label> 70 <input id="comment-email" name="email" size="30" value="" onfocus="mt ShowCaptcha()" />71 <input id="comment-email" name="email" size="30" value="" onfocus="mtCommentFormOnFocus()" /> 71 72 </div> 72 73 <div id="comment-form-url"> 73 74 <label for="comment-url"><__trans phrase="URL"></label> 74 <input id="comment-url" name="url" size="30" value="" onfocus="mt ShowCaptcha()" />75 <input id="comment-url" name="url" size="30" value="" onfocus="mtCommentFormOnFocus()" /> 75 76 </div> 76 77 <div id="comment-form-remember-me"> … … 86 87 <label for="comment-text"><__trans phrase="Comments"> 87 88 <MTIfAllowCommentHTML><__trans phrase="(You may use HTML tags for style)"></MTIfAllowCommentHTML></label> 88 <textarea id="comment-text" name="text" rows="15" cols="50" onfocus="mt ShowCaptcha()"></textarea>89 <textarea id="comment-text" name="text" rows="15" cols="50" onfocus="mtCommentFormOnFocus()"></textarea> 89 90 </div> 90 91 <div id="comments-open-captcha"></div> -
branches/release-38/default_templates/javascript.mtml
r2377 r2393 130 130 <mt:Ignore> 131 131 /*** 132 * Called when an input field on the comment form receives focus. 133 */ 134 </mt:Ignore> 135 function mtCommentFormOnFocus() { 136 // if CAPTCHA is enabled, this causes the captcha image to be 137 // displayed if it hasn't been already. 138 mtShowCaptcha(); 139 } 140 141 <mt:Ignore> 142 /*** 132 143 * Displays a captcha field for anonymous commenters. 133 144 */ … … 218 229 if (u.profile) str += "profile:'" + mtEscapeJS(u.profile) + "';"; 219 230 if (u.userpic) str += "userpic:'" + mtEscapeJS(u.userpic) + "';"; 231 if (u.sid) str += "sid:'" + mtEscapeJS(u.sid) + "';"; 220 232 str += "is_trusted:'" + (u.is_trusted ? "1" : "0") + "';"; 221 233 str += "is_author:'" + (u.is_author ? "1" : "0") + "';"; … … 238 250 var u = {}; 239 251 var m; 240 while (m = s.match(/^((name|url|email|is_authenticated|profile|userpic| is_trusted|is_author|is_banned|can_post|can_comment):'([^']+?)';?)/)) {252 while (m = s.match(/^((name|url|email|is_authenticated|profile|userpic|sid|is_trusted|is_author|is_banned|can_post|can_comment):'([^']+?)';?)/)) { 241 253 s = s.substring(m[1].length); 242 254 if (m[2].match(/^(is|can)_/)) // boolean fields … … 286 298 */ 287 299 </mt:Ignore> 300 var mtFetchedUser = false; 288 301 function mtFetchUser(cb) { 289 302 if (!cb) cb = 'mtSetUser'; … … 296 309 // we aren't using AJAX for this, since we may have to request 297 310 // from a different domain. JSONP to the rescue. 311 mtFetchedUser = true; 298 312 var script = document.createElement('script'); 299 313 script.src = '<$mt:CGIPath$><$mt:CommentScript$>?__mode=session_js&blog_id=<$mt:BlogID$>&jsonp=' + cb; … … 337 351 if (f.preview_button) f.preview_button.disabled = true; 338 352 if (f.post) f.post.disabled = true; 353 354 var u = mtGetUser(); 355 if ( !is_preview && ( u && u.is_authenticated ) ) { 356 // validate session; then submit 357 mtFetchedUser = false; 358 mtFetchUser('mtCommentSessionVerify'); 359 return false; 360 } 361 339 362 return true; 340 363 } 341 364 return false; 365 } 366 367 function mtCommentSessionVerify(app_user) { 368 var u = mtGetUser(); 369 var f = document['comments_form']; 370 if ( u && app_user && app_user.sid && ( u.sid == app_user.sid ) ) { 371 f.submit(); 372 } else { 373 alert('<__trans phrase="Your session has expired. Please sign in again to comment." escape="js">'); 374 mtClearUser(); 375 mtFireEvent('usersignin'); 376 <mt:IfRegistrationRequired> 377 mtShow('comments-form'); 378 mtHide('comments-open-footer'); 379 </mt:IfRegistrationRequired> 380 } 342 381 } 343 382 … … 377 416 if (cf.bakecookie) 378 417 cf.bakecookie.checked = u.name || u.email; 418 } else { 419 if (u && u.sid && cf.sid) 420 cf.sid.value = u.sid; 379 421 } 380 if (cf.post.disabled) {422 if (cf.post.disabled) 381 423 cf.post.disabled = false; 382 cf.post.value = '<__trans phrase="Submit">'; 383 } 384 if (cf.preview_button.disabled) { 424 if (cf.preview_button.disabled) 385 425 cf.preview_button.disabled = false; 386 cf.preview_button.value = '<__trans phrase="Preview">'; 387 } 426 mtRequestSubmitted = false; 388 427 } 389 428 } … … 478 517 var reg_reqd = <mt:IfRegistrationRequired>true<mt:Else>false</mt:IfRegistrationRequired>; 479 518 480 var cf = document .comments_form;519 var cf = document['comments_form']; 481 520 if (!cf) return; 482 521 … … 615 654 </mt:Ignore> 616 655 function mtClearUser() { 656 user = null; 617 657 mtDeleteCookie(mtCookieName, mtCookiePath, mtCookieDomain, 618 658 location.protocol == 'https:'); -
branches/release-38/lib/MT/App/Comments.pm
r2377 r2393 114 114 my $session_key; 115 115 116 if (my $blog_id = $q->param('blog_id')) { 117 if (my $blog = MT::Blog->load($blog_id)) { 118 my $auths = $blog->commenter_authenticators || ''; 119 if ( $auths =~ /MovableType/ ) { 120 # First, check for a real MT user login. If one exists, 121 # return that as the commenter identity 122 my ($user, $first_time) = $app->SUPER::login(); 123 if ( $user ) { 124 my $sess = $app->session; 125 return ( $sess->id, $user ); 126 } 116 my $blog = $app->blog; 117 if ($blog) { 118 my $auths = $blog->commenter_authenticators || ''; 119 if ( $auths =~ /MovableType/ ) { 120 # First, check for a real MT user login. If one exists, 121 # return that as the commenter identity 122 my ($user, $first_time) = $app->SUPER::login(); 123 if ( $user ) { 124 my $sess = $app->session; 125 return ( $sess->id, $user ); 127 126 } 128 127 } … … 149 148 ) 150 149 { 151 $app->log("session is invalid; sess_obj = $sess_obj; key = $session_key; user_id = $user_id; user = $user");152 150 $app->_invalidate_commenter_session( \%cookies ); 153 151 return ( undef, undef ); … … 858 856 return $app->handle_error( 859 857 $app->translate("Comment text is required.") ); 858 } 859 860 # validate session parameter 861 if ( my $sid = $q->param('sid') ) { 862 my ( $session, $commenter ) = $app->_get_commenter_session(); 863 if ( $session && $commenter && ( $session eq $sid ) ) { 864 # well, everything is okay 865 } else { 866 return $app->handle_error( 867 $app->translate("Your session has expired. Please sign in again to comment.") 868 ); 869 } 860 870 } 861 871 … … 1446 1456 if ( $blog_id && $blog ) { 1447 1457 my ( $session, $commenter ) = $app->_get_commenter_session(); 1448 use Data::Dumper;1449 1458 if ( $session && $commenter ) { 1450 1459 my $blog_perms = $commenter->blog_perm($blog_id); … … 1467 1476 my $can_post = ($blog_perms && $blog_perms->can_create_post) ? "1" : "0"; 1468 1477 $c = { 1478 sid => $sessobj->id, 1469 1479 name => $commenter->nickname, 1470 1480 url => $commenter->url,
