Changeset 2062
- Timestamp:
- 04/24/08 21:16:21 (19 months ago)
- Location:
- branches/release-36
- Files:
-
- 2 added
- 19 modified
-
default_templates/comment_preview.mtml (modified) (7 diffs)
-
default_templates/comments.mtml (modified) (5 diffs)
-
default_templates/entry.mtml (modified) (2 diffs)
-
default_templates/entry_summary.mtml (modified) (1 diff)
-
default_templates/javascript.mtml (modified) (4 diffs)
-
default_templates/main_index.mtml (modified) (1 diff)
-
default_templates/page.mtml (modified) (1 diff)
-
default_templates/search_results.mtml (modified) (2 diffs)
-
default_templates/trackbacks.mtml (modified) (2 diffs)
-
extras/examples/plugins/CommentByGoogleAccount/lib/CommentByGoogleAccount.pm (modified) (1 diff)
-
lib/MT/App.pm (modified) (10 diffs)
-
lib/MT/App/Comments.pm (modified) (29 diffs)
-
lib/MT/Auth/MT.pm (modified) (3 diffs)
-
lib/MT/Auth/OpenID.pm (modified) (1 diff)
-
lib/MT/Auth/TypeKey.pm (modified) (1 diff)
-
lib/MT/Template/ContextHandlers.pm (modified) (48 diffs)
-
php/lib/MTViewer.php (modified) (1 diff)
-
php/lib/function.mtcommentreplylink.php (modified) (1 diff)
-
php/lib/function.mtsigninlink.php (added)
-
php/lib/function.mtsignoutlink.php (added)
-
tmpl/comment/profile.tmpl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/release-36/default_templates/comment_preview.mtml
r1923 r2062 5 5 <title><$MTBlogName encode_html="1"$>: <__trans phrase="Previewing your Comment"></title> 6 6 <$mt:include module="<__trans phrase="HTML Head">"$> 7 <script type="text/javascript"> 8 /* <![CDATA[ */ 9 var is_preview = true; 10 /* ]]> */ 11 </script> 7 12 <script type="text/javascript" src="<$MTLink template="javascript"$>"></script> 8 13 </head> 9 <body id="<$mt:BlogTemplateSetID$>" class="mt-comment-preview <$MTVar name="page_layout"$>" onload=" individualArchivesOnLoad(commenter_name)">14 <body id="<$mt:BlogTemplateSetID$>" class="mt-comment-preview <$MTVar name="page_layout"$>" onload="mtEntryOnLoad()"> 10 15 <div id="container"> 11 16 <div id="container-inner"> … … 27 32 28 33 <mt:ignore><!-- Comment Preview --></mt:ignore> 29 <div class="comment" <MTIfArchiveTypeEnabled archive_type="Individual"> id="comment-<$MTCommentID$>"</MTIfArchiveTypeEnabled>>34 <div class="comment" id="comment-<$MTCommentID$>"> 30 35 <div class="inner"> 31 36 <div class="comment-header"> … … 33 38 <span class="byline"> 34 39 <mt:IfCommentParent> 35 <__trans phrase="[_1] replied to <a href="[_2]">comment from [_3]</a>" params="< MTIfNonEmpty tag="CommentAuthorIdentity"><$MTCommentAuthorIdentity$></MTIfNonEmpty> <span class="vcard author"><$MTCommentAuthorLink default_name="Anonymous" show_email="0"$></span>%%<mt:CommentParent>#comment-<$MTCommentID$></mt:CommentParent>%%<mt:CommentParent><$MTCommentAuthor$></mt:CommentParent>">40 <__trans phrase="[_1] replied to <a href="[_2]">comment from [_3]</a>" params="<$MTCommentAuthorIdentity$> <span class="vcard author"><$MTCommentAuthorLink$></span>%%<mt:CommentParent>#comment-<$MTCommentID$></mt:CommentParent>%%<mt:CommentParent><$MTCommentAuthor$></mt:CommentParent>"> 36 41 <mt:else> 37 <MTIfNonEmpty tag="CommentAuthorIdentity"><$MTCommentAuthorIdentity$></MTIfNonEmpty> <span class="vcard author"><$MTCommentAuthorLink default_name="Anonymous" show_email="0"$></span> 42 <$MTCommentAuthorIdentity$> 43 <span class="vcard author"><$MTCommentAuthorLink$></span> 38 44 </mt:IfCommentParent> 39 45 | <a href="#comment-<$MTCommentID$>"><abbr class="published" title="<$MTCommentDate format_name="iso8601"$>"><$MTCommentDate$></abbr></a> 40 <MTIfCommentsAccepted> | <$MTCommentReplyLink$></MTIfCommentsAccepted>41 46 </span> 42 47 </div> … … 50 55 51 56 <mt:ignore><!-- Comment Form --></mt:ignore> 52 <MTIfCommentsAccepted>53 57 <div class="comments-open" id="comments-open"> 54 58 <h2 class="comments-open-header"><__trans phrase="Leave a comment"></h2> 55 59 <div class="comments-open-content"> 56 <MTIfRegistrationAllowed> 57 <div id="comment-form-external-auth"> 58 <script type="text/javascript"> 59 /* <![CDATA[ */ 60 is_preview = true; 61 writeCommenterGreeting(commenter_name, <$MTEntryID$>, <$MTEntryBlogID$>, commenter_id, commenter_url); 62 /* ]]> */ 63 </script> 64 </div> 65 </MTIfRegistrationAllowed> 66 <form method="post" action="<$MTCGIPath$><$MTCommentScript$>" name="comments_form" id="comments-form" onsubmit="if (this.bakecookie.checked) rememberMe(this)"> 60 <div id="comment-greeting"></div> 61 <form method="post" action="<$MTCGIPath$><$MTCommentScript$>" name="comments_form" id="comments-form" onsubmit="mtCommentOnSubmit(this)"> 67 62 <input type="hidden" name="static" value="1" /> 63 <input type="hidden" name="armor" value="1" /> 64 <input type="hidden" name="preview" value="" /> 68 65 <input type="hidden" name="entry_id" value="<$MTEntryID$>" /> 69 66 <input type="hidden" name="__lang" value="<$MTBlogLanguage$>" /> … … 81 78 <input id="comment-url" name="url" size="30" value="<$MTCommentURL encode_html="1"$>" /> 82 79 </div> 83 <div id="comment-form-remember-me">84 <label for="comment-bake-cookie"><input type="checkbox" id="comment-bake-cookie" name="bakecookie" onclick="if (!this.checked) forgetMe(document.comments_form)" value="1" />85 <__trans phrase="Remember personal info?"></label>86 </div>87 80 </div> 88 81 <div id="comments-open-text"> … … 90 83 <textarea id="comment-text" name="text" rows="15" cols="50"><$MTCommentBody autolink="0" sanitize="0" convert_breaks="0" encode_html="1"$></textarea> 91 84 </div> 92 <MTIfNonEmpty tag="MTCaptchaFields"> 93 <MTIfCommentsAccepted><MTIfRegistrationAllowed><MTElse><$MTCaptchaFields$></MTIfRegistrationAllowed></MTIfCommentsAccepted> 94 <div id="comments-open-captcha"> 95 </div> 96 </MTIfNonEmpty> 85 <div id="comments-open-captcha"></div> 97 86 <div id="comments-open-footer"> 98 <input type="submit" accesskey="v" name="preview " id="comment-preview" value="<__trans phrase="Preview">" />87 <input type="submit" accesskey="v" name="preview_button" id="comment-preview" value="<__trans phrase="Preview">" onclick="this.form.preview.value='1';" /> 99 88 <input type="submit" accesskey="s" name="post" id="comment-submit" value="<__trans phrase="Submit">" /> 100 89 <input type="button" name="cancel" id="comment-cancel" value="<__trans phrase="Cancel">" onclick="window.location='<$MTEntryPermalink$>'" /> … … 103 92 </div> 104 93 </div> 105 </MTIfCommentsAccepted>106 94 </div> 107 95 </div> -
branches/release-36/default_templates/comments.mtml
r1976 r2062 1 <mt:ignore><!-- Display comments for the entry/page or commenting form if entry/page is accepting comments --></mt:ignore> 1 <mt:ignore> 2 <!-- Display comments for the entry/page or commenting form if entry/page is accepting comments --> 3 </mt:ignore> 2 4 <MTIfCommentsActive> 3 5 <div id="comments" class="comments"> 4 6 5 7 6 <mt:ignore><!-- Display comments --></mt:ignore> 8 <mt:ignore> 9 <!-- Display comments --> 10 </mt:ignore> 7 11 <MTComments> 8 12 <MTCommentsHeader> 9 <h2 class="comments-header"><$MTEntryCommentCount singular="<__trans phrase="1 Comment">" plural="<__trans phrase="# Comments">" $></h2>13 <h2 class="comments-header"><$MTEntryCommentCount singular="<__trans phrase="1 Comment">" plural="<__trans phrase="# Comments">" none="<__trans phrase="No Comments">"$></h2> 10 14 <div class="comments-content"> 11 15 </MTCommentsHeader> 12 <div class="comment<mt:IfCommentParent> comment-reply</mt:IfCommentParent>" <MTIfArchiveTypeEnabled archive_type="Individual"> id="comment-<$MTCommentID$>"</MTIfArchiveTypeEnabled>>16 <div class="comment<mt:IfCommentParent> comment-reply</mt:IfCommentParent>" id="comment-<$MTCommentID$>"> 13 17 <div class="inner"> 14 18 <div class="comment-header"> … … 16 20 <span class="byline"> 17 21 <mt:IfCommentParent> 18 <__trans phrase="[_1] replied to <a href="[_2]">comment from [_3]</a>" params="<MTIf NonEmpty tag="CommentAuthorIdentity"><$MTCommentAuthorIdentity$></MTIfNonEmpty> <span class="vcard author"><$MTCommentAuthorLink default_name="Anonymous" show_email="0"$></span>%%<mt:CommentParent>#comment-<$MTCommentID$></mt:CommentParent>%%<mt:CommentParent><$MTCommentAuthor$></mt:CommentParent>">22 <__trans phrase="[_1] replied to <a href="[_2]">comment from [_3]</a>" params="<MTIf tag="CommentAuthorIdentity"><$MTCommentAuthorIdentity$></MTIf> <span class="vcard author"><$MTCommentAuthorLink$></span>%%<mt:CommentParent>#comment-<$MTCommentID$></mt:CommentParent>%%<mt:CommentParent><$MTCommentAuthor$></mt:CommentParent>"> 19 23 <mt:else> 20 <MTIfNonEmpty tag="CommentAuthorIdentity"><$MTCommentAuthorIdentity$></MTIfNonEmpty> <span class="vcard author"><$MTCommentAuthorLink default_name="Anonymous" show_email="0"$></span> 24 <$MTCommentAuthorIdentity$> 25 <span class="vcard author"><$MTCommentAuthorLink$></span> 21 26 </mt:IfCommentParent> 22 | <a href="#comment-<$MTCommentID$>"><abbr class="published" title="<$MTCommentDate format_name="iso8601"$>"><$MTCommentDate $></abbr></a>27 | <a href="#comment-<$MTCommentID$>"><abbr class="published" title="<$MTCommentDate format_name="iso8601"$>"><$MTCommentDate relative="js"$></abbr></a> 23 28 <MTIfCommentsAccepted> | <$MTCommentReplyLink$></MTIfCommentsAccepted> 24 29 </span> … … 36 41 37 42 38 <mt:ignore><!-- Display commenting form if entry/page is accepting comments --></mt:ignore> 43 <mt:ignore> 44 <!-- Display commenting form if entry/page is accepting comments --> 45 </mt:ignore> 39 46 <MTIfCommentsAccepted> 40 47 <div class="comments-open" id="comments-open"> … … 42 49 <div class="comments-open-content"> 43 50 51 <mt:ignore> 52 <!-- Display greeting for users if blog allows users to register locally --> 53 </mt:ignore> 54 <div id="comment-greeting"></div> 44 55 45 <mt:ignore><!-- Display greeting for users if blog allows users to register locally --></mt:ignore> 46 <MTIfRegistrationAllowed> 47 <div id="comment-form-external-auth"> 48 <script type="text/javascript"> 49 /* <![CDATA[ */ 50 writeCommenterGreeting(commenter_name, <$MTEntryID$>, <$MTEntryBlogID$>, commenter_id, commenter_url); 51 /* ]]> */ 52 </script> 53 </div> 54 </MTIfRegistrationAllowed> 55 56 57 <form method="post" action="<$MTCGIPath$><$MTCommentScript$>" name="comments_form" id="comments-form" onsubmit="if (this.bakecookie.checked) rememberMe(this)"> 56 <form method="post" action="<$MTCGIPath$><$MTCommentScript$>" name="comments_form" id="comments-form" onsubmit="return mtCommentOnSubmit(this)"> 58 57 <input type="hidden" name="static" value="1" /> 59 58 <input type="hidden" name="entry_id" value="<$MTEntryID$>" /> 60 59 <input type="hidden" name="__lang" value="<$MTBlogLanguage$>" /> 61 <input type="hidden" name="parent_id" value="<MTIf name="comment_preview_template"><$MTCommentParentID$></MTIf>" id="comment-parent-id" /> 60 <input type="hidden" name="parent_id" value="<$MTCommentParentID$>" id="comment-parent-id" /> 61 <input type="hidden" name="armor" value="1" /> 62 <input type="hidden" name="preview" value="" /> 62 63 <div id="comments-open-data"> 63 64 <div id="comment-form-name"> … … 74 75 </div> 75 76 <div id="comment-form-remember-me"> 76 <input type="checkbox" id="comment-bake-cookie" name="bakecookie" onclick=" if (!this.checked) forgetMe(document.comments_form)" value="1" />77 <input type="checkbox" id="comment-bake-cookie" name="bakecookie" onclick="mtRememberMeOnClick(this)" value="1" accesskey="r" /> 77 78 <label for="comment-bake-cookie"><__trans phrase="Remember personal info?"></label> 78 79 </div> 79 <div id="comment-form-reply">80 <input type="checkbox" id="comment-reply" name="comment_reply" value="" onclick="setCommentParentID();" />81 <label for="comment-reply" id="comment-reply-label"></label>82 < /div>80 </div> 81 <div id="comment-form-reply" style="display:none"> 82 <input type="checkbox" id="comment-reply" name="comment_reply" value="" onclick="mtSetCommentParentID()" /> 83 <label for="comment-reply" id="comment-reply-label"></label> 83 84 </div> 84 85 <div id="comments-open-text"> 85 <label for="comment-text"><__trans phrase="Comments"> <MTIfAllowCommentHTML><__trans phrase="(You may use HTML tags for style)"></MTIfAllowCommentHTML></label> 86 <label for="comment-text"><__trans phrase="Comments"> 87 <MTIfAllowCommentHTML><__trans phrase="(You may use HTML tags for style)"></MTIfAllowCommentHTML></label> 86 88 <textarea id="comment-text" name="text" rows="15" cols="50"></textarea> 87 89 </div> 88 <MTIfNonEmpty tag="MTCaptchaFields"> 89 <MTIfCommentsAccepted><MTIfRegistrationAllowed><MTElse><$MTCaptchaFields$></MTIfRegistrationAllowed></MTIfCommentsAccepted> 90 <div id="comments-open-captcha"> 91 </div> 92 </MTIfNonEmpty> 90 <div id="comments-open-captcha"></div> 93 91 <div id="comments-open-footer"> 94 <input type="submit" accesskey="v" name="preview " id="comment-preview" value="<__trans phrase="Preview">" />92 <input type="submit" accesskey="v" name="preview_button" id="comment-preview" value="<__trans phrase="Preview">" onclick="this.form.preview.value='1';" /> 95 93 <input type="submit" accesskey="s" name="post" id="comment-submit" value="<__trans phrase="Submit">" /> 96 94 </div> -
branches/release-36/default_templates/entry.mtml
r1983 r2062 10 10 <script type="text/javascript" src="<$MTLink template="javascript"$>"></script> 11 11 </head> 12 <body id="<$mt:BlogTemplateSetID$>" class="mt-entry-archive <$MTVar name="page_layout"$>" onload=" individualArchivesOnLoad(commenter_name)">12 <body id="<$mt:BlogTemplateSetID$>" class="mt-entry-archive <$MTVar name="page_layout"$>" onload="mtEntryOnLoad()"> 13 13 <div id="container"> 14 14 <div id="container-inner"> … … 32 32 <span class="byline"> 33 33 <MTIfNonEmpty tag="EntryAuthorDisplayName"> 34 <__trans phrase="By [_1] on [_2]" params="<span class="vcard author"><$MTEntryAuthorLink show_hcard="1"$></span>%%<abbr class="published" title="<$MTEntryDate format_name="iso8601"$>"><$MTEntryDate format="%x %X" $></abbr>">34 <__trans phrase="By [_1] on [_2]" params="<span class="vcard author"><$MTEntryAuthorLink show_hcard="1"$></span>%%<abbr class="published" title="<$MTEntryDate format_name="iso8601"$>"><$MTEntryDate format="%x %X" relative="js"$></abbr>"> 35 35 <MTElse> 36 <abbr class="published" title="<$MTEntryDate format_name="iso8601"$>"><$MTEntryDate format="%x %X" $></abbr>36 <abbr class="published" title="<$MTEntryDate format_name="iso8601"$>"><$MTEntryDate format="%x %X" relative="js"$></abbr> 37 37 </MTIfNonEmpty> 38 38 </span> -
branches/release-36/default_templates/entry_summary.mtml
r1979 r2062 6 6 <span class="byline"> 7 7 <MTIfNonEmpty tag="EntryAuthorDisplayName"> 8 <__trans phrase="By [_1] on [_2]" params="<span class="vcard author"><$MTEntryAuthorLink show_hcard="1"$></span>%%<abbr class="published" title="<$MTEntryDate format_name="iso8601"$>"><$MTEntryDate format="%x %X" $></abbr>">8 <__trans phrase="By [_1] on [_2]" params="<span class="vcard author"><$MTEntryAuthorLink show_hcard="1"$></span>%%<abbr class="published" title="<$MTEntryDate format_name="iso8601"$>"><$MTEntryDate format="%x %X" relative="js"$></abbr>"> 9 9 <MTElse> 10 <abbr class="published" title="<$MTEntryDate format_name="iso8601"$>"><$MTEntryDate format="%x %X" $></abbr>10 <abbr class="published" title="<$MTEntryDate format_name="iso8601"$>"><$MTEntryDate format="%x %X" relative="js"$></abbr> 11 11 </MTIfNonEmpty> 12 12 </span> -
branches/release-36/default_templates/javascript.mtml
r1964 r2062 1 function hideDocumentElement(id) { 2 var el = document.getElementById(id); 3 if (el) 4 el.style.display = 'none'; 5 } 6 7 function showDocumentElement(id) { 8 var el = document.getElementById(id); 9 if (el) 10 el.style.display = 'block'; 1 <mt:ignore> 2 /* The following functions are here to support legacy MT templates. 3 If you have refreshed your JavaScript template but still use older 4 MT comment templates, you may need to uncomment this block in order 5 for those templates to work properly. Simply remove the wrapping 6 'mt:ignore' tag to do so. */ 7 function hideDocumentElement(id) { return mtHide(id) } 8 function showDocumentElement(id) { return mtShow(id) } 9 function individualArchivesOnLoad() { return mtEntryOnLoad() } 10 function writeCommenterGreeting() { return mtShowGreeting() } 11 function rememberMe(f) { return mtRememberMe(f) } 12 function forgetMe(f) { return mtForgetMe(f) } 13 </mt:ignore> 14 15 // The cookie name to use for storing the blog-side comment session cookie. 16 var cookie_name = "mt_blog<$MTBlogID$>_user"; 17 // The cookie path to use for storing the blog-side comment session cookie. 18 var blog_path = "<$MTBlogURL$>".replace(/^.*?\/\/[^\/]+?\//, '/'); 19 20 <mt:ignore> 21 /*** 22 * Simple routine for showing a DOM element (applying a CSS display 23 * attribute of 'none'). 24 */ 25 </mt:ignore> 26 function mtHide(id) { 27 var el = (typeof id == "string") ? document.getElementById(id) : id; 28 if (el) el.style.display = 'none'; 29 } 30 31 <mt:ignore> 32 /*** 33 * Simple routine for showing a DOM element (applying a CSS display 34 * attribute of 'block'). 35 */ 36 </mt:ignore> 37 function mtShow(id) { 38 var el = (typeof id == "string") ? document.getElementById(id) : id; 39 if (el) el.style.display = 'block'; 11 40 } 12 41 13 42 var captcha_timer; 14 function showAnonymousForm() { 15 showDocumentElement('comments-form'); 16 <MTIfNonEmpty tag="MTCaptchaFields"> 17 captcha_timer = setInterval('delayShowCaptcha()', 1000); 18 </MTIfNonEmpty> 19 } 20 <MTIfNonEmpty tag="MTCaptchaFields"> 21 function delayShowCaptcha() { 22 clearInterval(captcha_timer); 43 <mt:ignore> 44 /*** 45 * Used to display the comment form and captcha field. 46 */ 47 </mt:ignore> 48 function mtShowAnonymousForm() { 49 mtShow('comments-form'); 50 captcha_timer = setInterval('mtShowCaptcha()', 1000); 51 } 52 53 <mt:ignore> 54 /*** 55 * Displays a relative date. 56 * 'ts' is a Date object, 'fds' is a string of the date which 57 * will be displayed if the given date is older than 1 week. 58 */ 59 </mt:ignore> 60 function mtRelativeDate(ts, fds) { 61 var now = new Date(); 62 var ref = ts; 63 var delta = Math.floor((now.getTime() - ref.getTime()) / 1000); 64 65 var str; 66 if (delta < 60) { 67 str = '<__trans phrase="moments ago">'; 68 } else if (delta <= 86400) { 69 // less than 1 day 70 var hours = Math.floor(delta / 3600); 71 var min = Math.floor((delta % 3600) / 60); 72 if (hours == 1) 73 str = '<__trans phrase="[quant,_1,hour,hours] ago" params="1">'; 74 else if (hours > 1) 75 str = '<__trans phrase="[quant,_1,hour,hours] ago" params="2">'.replace(/2/, hours); 76 else if (min == 1) 77 str = '<__trans phrase="[quant,_1,minute,minutes] ago" params="1">'; 78 else 79 str = '<__trans phrase="[quant,_1,minute,minutes] ago" params="2">'.replace(/2/, min); 80 } else if (delta <= 604800) { 81 // less than 1 week 82 var days = Math.floor(delta / 86400); 83 var hours = Math.floor((delta % 86400) / 3600); 84 if (days == 1) 85 str = '<__trans phrase="[quant,_1,day,days] ago" params="1">'; 86 else if (days > 1) 87 str = '<__trans phrase="[quant,_1,day,days] ago" params="2">'.replace(/2/, days); 88 else if (hours == 1) 89 str = '<__trans phrase="[quant,_1,hour,hours] ago" params="1">'; 90 else 91 str = '<__trans phrase="[quant,_1,hour,hours] ago" params="2">'.replace(/2/, hours); 92 } 93 return str ? str : fds; 94 } 95 96 <mt:ignore> 97 /*** 98 * Used to display an edit link for the given entry. 99 */ 100 </mt:ignore> 101 function mtEditLink(entry_id, author_id) { 102 var u = mtGetUser(); 103 if (! u) return; 104 if (! entry_id) return; 105 if (! author_id) return; 106 if (u.id != author_id) return; 107 var link = '<__trans phrase='<a href="[_1]">Edit</a>' params="<$MTAdminScript$>?__mode=view&_type=entry&id=' + entry_id + '">'; 108 document.write(link); 109 } 110 111 <mt:ignore> 112 /*** 113 * Displays a captcha field for anonymous commenters. 114 */ 115 </mt:ignore> 116 function mtShowCaptcha() { 117 if (captcha_timer) clearInterval(captcha_timer); 23 118 var div = document.getElementById('comments-open-captcha'); 24 119 if (div) 25 120 div.innerHTML = '<$MTCaptchaFields$>'; 26 121 } 27 </MTIfNonEmpty> 28 29 var AUTHOR = 1; 30 var COMMENTER = 2; 31 var commenter_name; 32 var commenter_status; 33 var commenter_id; 34 var commenter_url 122 123 <mt:ignore> 124 /* user object 125 -- saved in user cookie -- 126 u.name (display name) 127 u.url (link to home page) 128 u.email (for anonymous only) 129 u.userpic (url for commenter/author) 130 u.profile (link to profile) 131 u.is_trusted (boolean) 132 u.is_author (user has posting rights) 133 u.is_banned (banned status; neither post/comment perms) 134 u.can_post (has permission to post) 135 u.can_comment (has permission to comment) 136 137 -- status fields -- 138 u.is_authenticated (boolean) 139 u.is_anonymous (user is anonymous) 140 */ 141 </mt:ignore> 142 35 143 var is_preview; 36 var mtcmtmail; 37 var mtcmtauth; 38 var mtcmthome; 39 40 function individualArchivesOnLoad(commenter_name) { 41 hideDocumentElement('comment-form-reply'); 42 <MTIfCommentsAccepted> 43 <MTElse> 44 hideDocumentElement('comments-open'); 45 </MTIfCommentsAccepted> 46 <MTIfPingsAccepted> 47 <MTElse> 48 hideDocumentElement('trackbacks-info'); 49 </MTIfPingsAccepted> 50 <MTIfRegistrationAllowed> 51 <MTIfRegistrationRequired> 52 if ( commenter_status > 0 ) { 53 hideDocumentElement('comment-form-name'); 54 hideDocumentElement('comment-form-email'); 55 hideDocumentElement('comment-form-url'); 56 hideDocumentElement('comment-form-remember-me'); 57 showDocumentElement('comments-open-text'); 58 showDocumentElement('comments-open-footer'); 144 var user; 145 <mt:ignore> 146 /*** 147 * Assigns a user object as the actively logged in user; also saves the 148 * user information in a browser cookie. 149 */ 150 </mt:ignore> 151 function mtSetUser(u) { 152 if (u) { 153 // persist this 154 user = u; 155 mtSaveUser(); 156 } 157 } 158 159 <mt:ignore> 160 /*** 161 * Simple function that escapes single quote characters for storing 162 * in a cookie. 163 */ 164 </mt:ignore> 165 function mtEscapeJS(s) { 166 s = s.replace(/'/g, "'"); 167 return s; 168 } 169 170 <mt:ignore> 171 /*** 172 * Simple function that unescapes single quote characters that were 173 * stored in a cookie. 174 */ 175 </mt:ignore> 176 function mtUnescapeJS(s) { 177 s = s.replace(/'/g, "'"); 178 return s; 179 } 180 181 <mt:ignore> 182 /*** 183 * Serializes a user object into a string, suitable for storing as a cookie. 184 */ 185 </mt:ignore> 186 function mtBakeUserCookie(u) { 187 var str = ""; 188 if (u.name) str += "name:'" + mtEscapeJS(u.name) + "';"; 189 if (u.url) str += "url:'" + mtEscapeJS(u.url) + "';"; 190 if (u.email) str += "email:'" + mtEscapeJS(u.email) + "';"; 191 if (u.is_authenticated) str += "is_authenticated:'1';"; 192 if (u.profile) str += "profile:'" + mtEscapeJS(u.profile) + "';"; 193 if (u.userpic) str += "userpic:'" + mtEscapeJS(u.userpic) + "';"; 194 str += "is_trusted:'" + (u.is_trusted ? "1" : "0") + "';"; 195 str += "is_author:'" + (u.is_author ? "1" : "0") + "';"; 196 str += "is_banned:'" + (u.is_banned ? "1" : "0") + "';"; 197 str += "can_post:'" + (u.can_post ? "1" : "0") + "';"; 198 str += "can_comment:'" + (u.can_comment ? "1" : "0") + "';"; 199 str = str.replace(/;$/, ''); 200 return str; 201 } 202 203 <mt:ignore> 204 /*** 205 * Unserializes a user cookie and returns a user object with the restored 206 * state. 207 */ 208 </mt:ignore> 209 function mtUnbakeUserCookie(s) { 210 if (!s) return; 211 212 var u = {}; 213 var m; 214 while (m = s.match(/^((name|url|email|is_authenticated|profile|userpic|is_trusted|is_author|is_banned|can_post|can_comment):'([^']+?)';?)/)) { 215 s = s.substring(m[1].length); 216 if (m[2].match(/^(is|can)_/)) // boolean fields 217 u[m[2]] = m[3] == '1' ? true : false; 218 else 219 u[m[2]] = mtUnescapeJS(m[3]); 220 } 221 if (u.is_authenticated) { 222 u.is_anonymous = false; 59 223 } else { 60 hideDocumentElement('comments-open-data'); 61 hideDocumentElement('comments-open-text'); 62 hideDocumentElement('comments-open-footer'); 63 } 64 <MTElse> 65 // comments are allowed but registration not required 66 if ( commenter_status > 0 ) { 67 hideDocumentElement('comment-form-name'); 68 hideDocumentElement('comment-form-email'); 69 } else if (is_preview) { 70 <MTIfNonEmpty tag="MTCaptchaFields"> 71 delayShowCaptcha(); 72 </MTIfNonEmpty> 224 u.is_anonymous = true; 225 u.can_post = false; 226 u.is_author = false; 227 u.is_banned = false; 228 u.is_trusted = false; 229 } 230 return u; 231 } 232 233 <mt:ignore> 234 /*** 235 * Retrieves an object of the currently logged in user's state. 236 * If no user is logged in or cookied, this will return null. 237 */ 238 </mt:ignore> 239 function mtGetUser() { 240 if (!user) { 241 var cookie = mtGetCookie(cookie_name); 242 if (!cookie) return; 243 user = mtUnbakeUserCookie(cookie); 244 if (! user) { 245 user = {}; 246 user.is_anonymous = true; 247 user.can_post = false; 248 user.is_author = false; 249 user.is_banned = false; 250 user.is_trusted = false; 251 } 252 } 253 return user; 254 } 255 256 <mt:ignore> 257 /*** 258 * Issues a request to the MT comment script to retrieve the currently 259 * logged-in user (if any). 260 */ 261 </mt:ignore> 262 function mtFetchUser() { 263 document.write('<scr' + 'ipt src="<$MTCGIPath$><$MTCommentScript$>?__mode=session_js&blog_id=<$MTBlogID$>&jsonp=mtSetUser"></scr' + 'ipt>'); 264 } 265 266 <mt:ignore> 267 /*** 268 * Called when the 'Remember me' checkbox is changed. If the checkbox 269 * is cleared, the cached user cookie is immediately cleared. 270 */ 271 </mt:ignore> 272 function mtRememberMeOnClick(b) { 273 if (!b.checked) 274 mtClearUser(b.form); 275 return true; 276 } 277 278 <mt:ignore> 279 /*** 280 * Called when comment form is sent. 281 * Required parameter: Form DOM object of comment form. 282 * If form has a 'bakecookie' member, it will be used to signal 283 * storing the anonymous commenter information to a cookie. 284 * If form has a 'armor' member, it will be used to store 285 * a token that is checked by the comment script. 286 */ 287 </mt:ignore> 288 var mtRequestSubmitted = false; 289 function mtCommentOnSubmit(f) { 290 if (!mtRequestSubmitted) { 291 mtRequestSubmitted = true; 292 293 if (f.armor) 294 f.armor.value = '<$MTBlogSitePath encode_sha1="1"$>'; 295 if (f.bakecookie && f.bakecookie.checked) 296 mtSaveUser(f); 297 298 // disable submit buttons 299 if (f.preview_button) f.preview_button.disabled = true; 300 if (f.post) f.post.disabled = true; 301 if (f.preview.value == '1') 302 f.preview_button.value = '<__trans phrase="Posting...">'; 303 else 304 f.post.value = '<__trans phrase="Posting...">'; 305 306 return true; 307 } 308 return false; 309 } 310 311 <mt:ignore> 312 /*** 313 * Called when an entry archive page is loaded. 314 * This routine controls which elements of the comment form are shown 315 * or hidden, depending on commenter type and blog configuration. 316 */ 317 </mt:ignore> 318 function mtEntryOnLoad() { 319 var u = mtGetUser(); 320 321 <mt:unless tag="IfCommentsAccepted"> 322 mtHide('comments-open'); 323 </mt:unless> 324 <mt:unless tag="IfPingsAccepted"> 325 mtHide('trackbacks-info'); 326 </mt:unless> 327 328 <mt:IfRegistrationRequired> 329 if ( !u || u.is_anonymous ) { 330 mtHide('comments-open-data'); 331 mtHide('comments-open-text'); 332 mtHide('comments-open-footer'); 73 333 } else { 74 hideDocumentElement('comments-form'); 75 } 76 </MTIfRegistrationRequired> 77 </MTIfRegistrationAllowed> 78 334 mtHide('comments-open-data'); 335 mtShow('comments-open-text'); 336 mtShow('comments-open-footer'); 337 } 338 <mt:else> 339 <mt:IfRegistrationAllowed> 340 if (is_preview && u && u.is_anonymous) { 341 mtShowAnonymousForm(); 342 } else { 343 // comments are allowed but registration not required 344 if ( !u || u.is_anonymous ) 345 mtHide('comments-form'); 346 else 347 mtHide('comments-open-data'); 348 } 349 <mt:else> 350 mtShowAnonymousForm(); 351 </mt:IfRegistrationAllowed> 352 </mt:IfRegistrationRequired> 353 354 mtShowGreeting(); 355 356 // populate anonymous comment fields if 357 // user is cookied as anonymous 79 358 var cf = document.comments_form; 80 359 if (cf) { 81 if (!commenter_name && (cf.email != undefined) && 82 (mtcmtmail = getCookie("mtcmtmail"))) 83 cf.email.value = mtcmtmail; 84 if (!commenter_name && (cf.author != undefined) && 85 (mtcmtauth = getCookie("mtcmtauth"))) 86 cf.author.value = mtcmtauth; 87 if (cf.url != undefined && 88 (mtcmthome = getCookie("mtcmthome"))) 89 cf.url.value = mtcmthome; 90 if (cf["bakecookie"]) { 91 if (mtcmtauth || mtcmthome) { 92 cf.bakecookie.checked = true; 360 if (u && u.is_anonymous) { 361 if (u.email) cf.email.value = u.email; 362 if (u.name) cf.author.value = u.name; 363 if (u.url) cf.url.value = u.url; 364 if (cf.bakecookie) 365 cf.bakecookie.checked = u.name || u.email; 366 } 367 if (cf.post.disabled) { 368 cf.post.disabled = false; 369 cf.post.value = '<__trans phrase="Submit">'; 370 } 371 if (cf.preview_button.disabled) { 372 cf.preview_button.disabled = false; 373 cf.preview_button.value = '<__trans phrase="Preview">'; 374 } 375 } 376 } 377 378 <mt:ignore> 379 /*** 380 * Handles the action of the "Sign in" link. First clears any existing 381 * user cookie, then directs to the MT comment script to sign the user in. 382 */ 383 </mt:ignore> 384 function mtSignIn(entry_id) { 385 var doc_url = document.URL; 386 doc_url = doc_url.replace(/#.+/, ''); 387 var url = '<$MTSignInLink$>&entry_id=' + entry_id + 388 '&return_to=' + encodeURIComponent(doc_url); 389 mtClearUser(); 390 location.href = url; 391 } 392 393 <mt:ignore> 394 /*** 395 * Handles the action of the "Sign out" link. First clears any existing 396 * user cookie, then direts to the MT comment script to sign the user out. 397 */ 398 </mt:ignore> 399 function mtSignOut(entry_id) { 400 var url = '<$MTSignOutLink$>&entry_id=' + entry_id; 401 mtClearUser(); 402 location.href = url; 403 } 404 405 <mt:ignore> 406 /*** 407 * Handles the display of the greeting message, depending on what kind of 408 * user is logged in and blog comment policy. 409 */ 410 </mt:ignore> 411 function mtShowGreeting() { 412 <mt:IfRegistrationAllowed> 413 var reg_reqd = <mt:IfRegistrationRequired>true<mt:else>false</mt:IfRegistrationRequired>; 414 415 var cf = document.comments_form; 416 if (!cf) return; 417 418 var el = document.getElementById('comment-greeting'); 419 if (!el) // legacy MT 4.x element id 420 el = document.getElementById('comment-form-external-auth'); 421 if (!el) return; 422 423 var eid = cf.entry_id; 424 var entry_id; 425 if (eid) entry_id = eid.value; 426 427 var phrase; 428 var u = mtGetUser(); 429 430 if ( u && u.is_authenticated ) { 431 if ( u.is_banned ) { 432 phrase = '<__trans phrase="You do not have permission to comment on this blog. ([_1]sign out[_2])" params="<a href="javascript:void(0);" onclick="mtSignOut(' + entry_id + ')">%%</a>">'; 433 } else { 434 var user_link; 435 if ( u.is_author ) { 436 user_link = '<a href="<$MTCGIPath$><$MTCommentScript$>?__mode=edit_profile&blog_id=<$MTBlogID$>'; 437 if (entry_id) 438 user_link += '&entry_id=' + entry_id; 439 user_link += '">' + u.name + '</a>'; 93 440 } else { 94 cf.bakecookie.checked = false; 441 // registered user, but not a user with posting rights 442 if (u.url) 443 user_link = '<a href="' + u.url + '">' + u.name + '</a>'; 444 else 445 user_link = u.name; 95 446 } 447 // TBD: supplement phrase with userpic if one is available. 448 phrase = '<__trans phrase="Thanks for signing in, [_1]. ([_2]sign out[_3])" params="' + user_link + '%%<a href="javascript:void(0)" onclick="mtSignOut(' + entry_id + ')">%%</a>">'; 96 449 } 97 } 98 } 99 100 function writeCommenterGreeting(commenter_name, entry_id, blog_id, commenter_id, commenter_url) { 101 <MTIfRegistrationAllowed> 102 if ( commenter_status > 0 ) { 103 var commenter_link; 104 if ( commenter_status == COMMENTER ) { 105 if (commenter_url) { 106 commenter_link = '<a href="' + commenter_url + '">' + commenter_name + '</a>'; 107 } else { 108 commenter_link = commenter_name; 109 } 110 } else if ( commenter_status == AUTHOR ) { 111 if (commenter_id) { 112 commenter_link = '<a href="<$MTCGIPath$><$MTCommentScript$>?__mode=edit_profile&commenter=' + commenter_id + '&blog_id=' + blog_id; 113 if (entry_id) { 114 commenter_link += '&entry_id=' + entry_id; 115 } else { 116 commenter_link += '&static=1'; 117 } 118 commenter_link += '">' + commenter_name + '</a>'; 119 } 120 450 } else { 451 if (reg_reqd) { 452 phrase = '<__trans phrase="[_1]Sign in[_2] to comment." params="<a href="javascript:void(0)" onclick="mtSignIn()">%%</a>">'; 453 } else { 454 phrase = '<__trans phrase="[_1]Sign in[_2] to comment, or [_3]comment anonymously[_2]." params="<a href="javascript:void(0)" onclick="mtSignIn(' + entry_id + ')">%%</a>%%<a href="javascript:void(0);" onclick="mtShowAnonymousForm();">">'; 121 455 } 122 document.write( 123 '<__trans phrase="Thanks for signing in, [_1]. Now you can comment. ([_2]sign out[_3])" params="' + commenter_link + '%%<a href="<$MTRemoteSignOutLink static="1"$>&entry_id=' + entry_id + '">%%</a>">' 124 ); 125 } else if (commenter_name) { 126 document.write('<__trans phrase="You do not have permission to comment on this blog. ([_1]sign out[_2])" params="<a href="<$MTRemoteSignOutLink static="1"$>&entry_id=' + entry_id + '">%%</a>">'); 127 } else { 128 <MTIfRegistrationRequired> 129 var phrase = '<__trans phrase="[_1]Sign in[_2] to comment on this entry." params="<a href="<$MTCGIPath$><$MTCommentScript$>?__mode=login&entry_id=' + entry_id + '&blog_id=' + blog_id + '&static=1&return_to=' + encodeURIComponent(document.URL) + '">%%</a>">'; 130 <MTElse> 131 var phrase = '<__trans phrase="[_1]Sign in[_2] to comment on this entry, or [_3]comment anonymously[_2]." params="<a href="<$MTCGIPath$><$MTCommentScript$>?__mode=login&entry_id=' + entry_id + '&blog_id=' + blog_id + '&static=1&return_to=' + encodeURIComponent(document.URL) + '">%%</a>%%<a href="javascript:void(0);" onclick="showAnonymousForm();">">'; 132 </MTIfRegistrationRequired> 133 document.write(phrase); 134 } 135 </MTIfRegistrationAllowed> 136 } 137 138 <MTIfRegistrationAllowed> 139 <$MTCGIHost exclude_port="1" setvar="cgi_host"$><$MTBlogHost exclude_port="1" setvar="blog_host"$> 140 <MTIf name="cgi_host" eq="$blog_host"> 141 commenter_name = getCookie('commenter_name'); 142 commenter_url = getCookie('commenter_url'); 143 ids = getCookie('commenter_id').split(':'); 144 commenter_id = ids[0]; 145 if ( ids[1] == 'S' ) { 146 commenter_status = AUTHOR; 147 } 148 else if ( ids[1] == 'N' ) { 149 document.write('<script src="<$MTCGIPath$><$MTCommentScript$>?__mode=cmtr_status_js&blog_id=<$MTBlogID$>"></script>'); 150 } 151 else if ( commenter_name && !commenter_id ) { 152 commenter_status = COMMENTER; 153 } 154 else if ( commenter_name 155 && commenter_id 156 && ( ids[1].indexOf("'<$MTBlogID$>'") > -1 ) ) { 157 commenter_status = AUTHOR; 158 } 159 else { 160 commenter_status = 0; 161 } 162 <MTElse> 163 document.write('<script src="<$MTCGIPath$><$MTCommentScript$>?__mode=cmtr_name_js&blog_id=<$MTBlogID$>"></script>'); 164 </MTIf> 165 </MTIfRegistrationAllowed> 166 167 function replyComment(parent_id, author) { 168 showDocumentElement('comment-form-reply'); 169 456 } 457 el.innerHTML = phrase; 458 <mt:else> 459 mtShowCaptcha(); 460 </mt:IfRegistrationAllowed> 461 } 462 463 <mt:ignore> 464 /*** 465 * Handles the action of the 'Reply' links. 466 */ 467 </mt:ignore> 468 function mtReplyCommentOnClick(parent_id, author) { 469 mtShow('comment-form-reply'); 470 170 471 var checkbox = document.getElementById('comment-reply'); 171 472 var label = document.getElementById('comment-reply-label'); … … 180 481 text.focus(); 181 482 182 setCommentParentID(); 183 } 184 185 function setCommentParentID() { 483 mtSetCommentParentID(); 484 } 485 486 <mt:ignore> 487 /*** 488 * Sets the parent comment ID when replying to a comment. 489 */ 490 </mt:ignore> 491 function mtSetCommentParentID() { 186 492 var checkbox = document.getElementById('comment-reply'); 187 493 var parent_id_field = document.getElementById('comment-parent-id'); 494 if (!checkbox || !parent_id_field) return; 495 188 496 var pid = 0; 189 190 if(checkbox.checked == true) 497 if (checkbox.checked == true) 191 498 pid = checkbox.value; 192 193 499 parent_id_field.value = pid; 194 500 } 195 501 196 197 // Copyright (c) 1996-1997 Athenia Associates. 198 // http://www.webreference.com/js/ 199 // License is granted if and only if this entire 200 // copyright notice is included. By Tomer Shiran. 201 202 function setCookie (name, value, expires, path, domain, secure) { 203 var curCookie = name + "=" + escape(value) + (expires ? "; expires=" + expires.toGMTString() : "") + 204 (path ? "; path=" + path : "") + (domain ? "; domain=" + domain : "") + (secure ? "secure" : ""); 205 document.cookie = curCookie; 206 } 207 208 function getCookie (name) { 209 var prefix = name + '='; 210 var c = document.cookie; 211 var nullstring = ''; 212 var cookieStartIndex = c.indexOf(prefix); 213 if (cookieStartIndex == -1) 214 return nullstring; 215 var cookieEndIndex = c.indexOf(";", cookieStartIndex + prefix.length); 216 if (cookieEndIndex == -1) 217 cookieEndIndex = c.length; 218 return unescape(c.substring(cookieStartIndex + prefix.length, cookieEndIndex)); 219 } 220 221 function deleteCookie (name, path, domain) { 222 if (getCookie(name)) 223 document.cookie = name + "=" + ((path) ? "; path=" + path : "") + 224 ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT"; 225 } 226 227 function fixDate (date) { 228 var base = new Date(0); 229 var skew = base.getTime(); 230 if (skew > 0) 231 date.setTime(date.getTime() - skew); 232 } 233 234 function rememberMe (f) { 235 var now = new Date(); 236 fixDate(now); 237 now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000); 238 if (f.author != undefined) 239 setCookie('mtcmtauth', f.author.value, now, '/', '', ''); 240 if (f.email != undefined) 241 setCookie('mtcmtmail', f.email.value, now, '/', '', ''); 242 if (f.url != undefined) 243 setCookie('mtcmthome', f.url.value, now, '/', '', ''); 244 } 245 246 function forgetMe (f) { 247 deleteCookie('mtcmtmail', '/', ''); 248 deleteCookie('mtcmthome', '/', ''); 249 deleteCookie('mtcmtauth', '/', ''); 250 } 251 502 <mt:ignore> 503 /*** 504 * Persists a copy of the current user cookie into the browser cookie stash. 505 */ 506 </mt:ignore> 507 function mtSaveUser(f) { 508 // We can't reliably store the user cookie during a preview. 509 if (is_preview) return; 510 511 var u = mtGetUser(); 512 513 if (f && (!u || u.is_anonymous)) { 514 if ( !u ) { 515 u = {}; 516 u.is_authenticated = false; 517 u.can_comment = true; 518 u.is_author = false; 519 u.is_banned = false; 520 u.is_anonymous = true; 521 u.is_trusted = false; 522 } 523 if (f.author != undefined) u.name = f.author.value; 524 if (f.email != undefined) u.email = f.email.value; 525 if (f.url != undefined) u.url = f.url.value; 526 } 527 528 if (!u) return; 529 530 var cache_period = 60 * 60 * 1000; // 1 hour 531 532 // cache anonymous user info for a long period if the 533 // user has requested to be remembered 534 if (u.is_anonymous && f && f.bakecookie && f.bakecookie.checked) 535 cache_period = 365 * 24 * 60 * 60 * 1000; 536 537 var now = new Date(); 538 mtFixDate(now); 539 now.setTime(now.getTime() + cache_period); 540 541 var cmtcookie = mtBakeUserCookie(u); 542 mtSetCookie(cookie_name, cmtcookie, now, blog_path, null, 543 location.protocol == 'https:'); 544 } 545 546 <mt:ignore> 547 /*** 548 * Clears the blog-side user cookie. 549 */ 550 </mt:ignore> 551 function mtClearUser() { 552 mtDeleteCookie(cookie_name, blog_path); 553 } 554 555 <mt:ignore> 556 /*** 557 * Sets a browser cookie. 558 */ 559 </mt:ignore> 560 function mtSetCookie(name, value, expires, path, domain, secure) { 561 var curCookie = name + "=" + escape(value) + 562 (expires ? "; expires=" + expires.toGMTString() : "") + 563 (path ? "; path=" + path : "") + 564 (domain ? "; domain=" + domain : "") + 565 (secure ? "; secure" : ""); 566 document.cookie = curCookie; 567 } 568 569 <mt:ignore> 570 /*** 571 * Retrieves a browser cookie. 572 */ 573 </mt:ignore> 574 function mtGetCookie (name) { 575 var prefix = name + '='; 576 var c = document.cookie; 577 var cookieStartIndex = c.indexOf(prefix); 578 if (cookieStartIndex == -1) 579 return ''; 580 var cookieEndIndex = c.indexOf(";", cookieStartIndex + prefix.length); 581 if (cookieEndIndex == -1) 582 cookieEndIndex = c.length; 583 return unescape(c.substring(cookieStartIndex + prefix.length, cookieEndIndex)); 584 } 585 586 <mt:ignore> 587 /*** 588 * Deletes a browser cookie. 589 */ 590 </mt:ignore> 591 function mtDeleteCookie (name, path, domain, secure) { 592 if (mtGetCookie(name)) 593 document.cookie = name + "=" + 594 (path ? "; path=" + path : "") + 595 (domain ? "; domain=" + domain : "") + 596 (secure ? "; secure" : "") + 597 "; expires=Thu, 01-Jan-70 00:00:01 GMT"; 598 } 599 600 function mtFixDate(date) { 601 var skew = (new Date(0)).getTime(); 602 if (skew > 0) 603 date.setTime(date.getTime() - skew); 604 } 605 606 <mt:ignore> 607 /*** 608 * Returns a XMLHttpRequest object (for Ajax operations). 609 */ 610 </mt:ignore> 611 function mtGetXmlHttp() { 612 if ( !window.XMLHttpRequest ) { 613 window.XMLHttpRequest = function() { 614 var types = [ 615 "Microsoft.XMLHTTP", 616 "MSXML2.XMLHTTP.5.0", 617 "MSXML2.XMLHTTP.4.0", 618 "MSXML2.XMLHTTP.3.0", 619 "MSXML2.XMLHTTP" 620 ]; 621 622 for ( var i = 0; i < types.length; i++ ) { 623 try { 624 return new ActiveXObject( types[ i ] ); 625 } catch( e ) {} 626 } 627 628 return undefined; 629 }; 630 } 631 if ( window.XMLHttpRequest ) 632 return new XMLHttpRequest(); 633 } 252 634 253 635 // BEGIN: fast browser onload init … … 256 638 // http://dean.edwards.name/weblog/2006/06/again/?full#comment5338 257 639 258 function init() {259 // quit if this function has already been called260 if (arguments.callee.done) return;261 262 // flag this function so we don't do the same thing twice263 arguments.callee.done = true;264 265 // kill the timer266 // DWD - check against window267 if ( window._timer ) clearInterval(window._timer);268 269 // DWD - fire the window onload now, and replace it270 if ( window.onload && ( window.onload !== window.init ) ) {271 window.onload();272 window.onload = function() {};273 }274 } ;640 function mtInit() { 641 // quit if this function has already been called 642 if (arguments.callee.done) return; 643 644 // flag this function so we don't do the same thing twice 645 arguments.callee.done = true; 646 647 // kill the timer 648 // DWD - check against window 649 if ( window._timer ) clearInterval(window._timer); 650 651 // DWD - fire the window onload now, and replace it 652 if ( window.onload && ( window.onload !== window.mtInit ) ) { 653 window.onload(); 654 window.onload = function() {}; 655 } 656 } 275 657 276 658 /* for Mozilla/Opera9 */ 277 659 if (document.addEventListener) { 278 document.addEventListener("DOMContentLoaded", init, false);660 document.addEventListener("DOMContentLoaded", mtInit, false); 279 661 } 280 662 … … 282 664 /*@cc_on @*/ 283 665 /*@if (@_win32) 284 document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");285 var script = document.getElementById("__ie_onload");286 script.onreadystatechange = function() {666 document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>"); 667 var script = document.getElementById("__ie_onload"); 668 script.onreadystatechange = function() { 287 669 if (this.readyState == "complete") { 288 init(); // call the onload handler289 } 290 };670 mtInit(); // call the onload handler 671 } 672 }; 291 673 /*@end @*/ 292 674 293 675 /* for Safari */ 294 676 if (/WebKit/i.test(navigator.userAgent)) { // sniff 295 _timer = setInterval(function() {296 if (/loaded|complete/.test(document.readyState)) {297 init(); // call the onload handler298 }299 }, 10);677 _timer = setInterval(function() { 678 if (/loaded|complete/.test(document.readyState)) { 679 mtInit(); // call the onload handler 680 } 681 }, 10); 300 682 } 301 683 302 684 /* for other browsers */ 303 window.onload = init;685 window.onload = mtInit; 304 686 305 687 // END: fast browser onload init 306 688 689 <mt:IfRegistrationAllowed> 690 /*** 691 * If request contains a '#_login' or '#_logout' hash, use this to 692 * also delete the blog-side user cookie, since we're coming back from 693 * a login, logout or edit profile operation. 694 */ 695 var clearCookie = ( window.location.hash && window.location.hash.match( /^#_log(in|out)/ ) ) ? true : false; 696 if (clearCookie) { 697 // clear any logged in state 698 mtClearUser(); 699 if (RegExp.$1 == 'in') 700 mtFetchUser(); 701 } else if (! mtGetUser()) { 702 // gather user info 703 mtFetchUser(); 704 } 705 </mt:IfRegistrationAllowed> -
branches/release-36/default_templates/main_index.mtml
r1923 r2062 6 6 <$mt:include module="<__trans phrase="HTML Head">"$> 7 7 <link rel="EditURI" type="application/rsd+xml" title="RSD" href="<$MTLink template="rsd"$>" /> 8 <script type="text/javascript" src="<$MTLink template="javascript"$>"></script> 8 9 </head> 9 10 <body id="<$mt:BlogTemplateSetID$>" class="mt-main-index <$MTVar name="page_layout"$>"> -
branches/release-36/default_templates/page.mtml
r1964 r2062 8 8 <script type="text/javascript" src="<$MTLink template="javascript"$>"></script> 9 9 </head> 10 <body id="<$mt:BlogTemplateSetID$>" class="mt-page-archive <$MTVar name="page_layout"$>" onload=" individualArchivesOnLoad(commenter_name)">10 <body id="<$mt:BlogTemplateSetID$>" class="mt-page-archive <$MTVar name="page_layout"$>" onload="mtEntryOnLoad()"> 11 11 <div id="container"> 12 12 <div id="container-inner"> -
branches/release-36/default_templates/search_results.mtml
r1961 r2062 7 7 <MTIgnore>Below Javascript adds ajax search capability</MTIgnore> 8 8 <script type="text/javascript"> 9 <!--9 /* <![CDATA[ */ 10 10 <MTIfMoreResults> 11 function getXmlHttp() {12 if ( !window.XMLHttpRequest ) {13 window.XMLHttpRequest = function() {14 var types = [15 "Microsoft.XMLHTTP",16 "MSXML2.XMLHTTP.5.0",17 "MSXML2.XMLHTTP.4.0",18 "MSXML2.XMLHTTP.3.0",19 "MSXML2.XMLHTTP"20 ];21 22 for ( var i = 0; i < types.length; i++ ) {23 try {24 return new ActiveXObject( types[ i ] );25 } catch( e ) {}26 }27 28 return undefined;29 };30 }31 if ( window.XMLHttpRequest )32 return new XMLHttpRequest();33 }34 35 11 function getResults(page) { 36 12 page = parseInt(page); 37 13 if (timer) window.clearTimeout(timer); 38 var xh = getXmlHttp();14 var xh = mtGetXmlHttp(); 39 15 if (!xh) return false; 40 16 var res = results[page]; … … 82 58 }</MTIfPreviousResults> 83 59 </MTIfMoreResults> 84 / /-->60 /* ]]> */ 85 61 </script> 62 <script type="text/javascript" src="<$MTLink template="javascript"$>"></script> 86 63 </head> 87 64 <body id="<$mt:BlogTemplateSetID$>" class="mt-search-results <$MTVar name="page_layout"$>"> -
branches/release-36/default_templates/trackbacks.mtml
r1976 r2062 2 2 <MTIfPingsActive> 3 3 <div id="trackbacks" class="trackbacks"> 4 <h2 class="trackbacks-header"><$MTEntryTrackbackCount singular="<__trans phrase="1 TrackBack">" plural="<__trans phrase="# TrackBacks">" $></h2>4 <h2 class="trackbacks-header"><$MTEntryTrackbackCount singular="<__trans phrase="1 TrackBack">" plural="<__trans phrase="# TrackBacks">" none="<__trans phrase="No TrackBacks">"$></h2> 5 5 6 6 <mt:ignore><!-- Display TrackBack details if TrackBacks are being accepted --></mt:ignore> … … 21 21 <div class="trackback-header"> 22 22 <div class="asset-meta"> 23 <__trans phrase="<a href="[_1]">[_2]</a> from [_3] on <a href="[_4]">[_5]</a>" params="<$MTPingURL$>%%<$MTPingTitle$>%%<$MTPingBlogName$>%%#ping-<$MTPingID$>%%<$MTPingDate $>">23 <__trans phrase="<a href="[_1]">[_2]</a> from [_3] on <a href="[_4]">[_5]</a>" params="<$MTPingURL$>%%<$MTPingTitle$>%%<$MTPingBlogName$>%%#ping-<$MTPingID$>%%<$MTPingDate relative="js"$>"> 24 24 </div> 25 25 </div> -
branches/release-36/extras/examples/plugins/CommentByGoogleAccount/lib/CommentByGoogleAccount.pm
r1174 r2062 39 39 my $nick_escaped = escape_unicode($nick); 40 40 $nick = encode_text($nick, 'utf-8', undef); 41 $session = $app-> _make_commenter_session($app->make_magic_token, $email,41 $session = $app->make_commenter_session($app->make_magic_token, $email, 42 42 $name, $nick_escaped); 43 43 unless ($session) { -
branches/release-36/lib/MT/App.pm
r2024 r2062 277 277 278 278 my $class = $app->model($type) or return; 279 my $list_pref = $app->list_pref($type) ;279 my $list_pref = $app->list_pref($type) if $app->can('list_pref'); 280 280 $param->{$_} = $list_pref->{$_} for keys %$list_pref; 281 281 my $limit = $list_pref->{rows}; … … 938 938 sub is_authorized { 1 } 939 939 940 sub commenter_cookie { COMMENTER_COOKIE_NAME() } 941 940 942 sub user_cookie { $COOKIE_NAME } 941 943 942 944 sub user { 943 945 my $app = shift; 944 $app->{author} = $app->{ $COOKIE_NAME} = $_[0] if @_;946 $app->{author} = $app->{ $app->user_cookie } = $_[0] if @_; 945 947 return $app->{author}; 946 948 } … … 1013 1015 } 1014 1016 1015 sub _make_commenter_session {1017 sub make_commenter_session { 1016 1018 my $app = shift; 1017 1019 my ($session_key, $email, $name, $nick, $id, $url, $timeout, $blog_id) = @_; … … 1021 1023 my $nick_escaped = MT::Util::escape_unicode( $nick ); 1022 1024 1023 $timeout = '+' . $app-> {cfg}->CommentSessionTimeout . 's' unless defined $timeout;1025 $timeout = '+' . $app->config->CommentSessionTimeout . 's' unless defined $timeout; 1024 1026 my %kookee = (-name => COMMENTER_COOKIE_NAME(), 1025 1027 -value => $session_key, … … 1033 1035 $app->bake_cookie(%name_kookee); 1034 1036 if (defined $id) { 1035 my $blog_ids; 1036 if ($app->user && $app->user->is_superuser) { 1037 # Do not send blog ids in cookie because it may become huge. 1038 $blog_ids = 'S'; 1039 } 1040 else { 1041 my @blogs = $app->model('blog')->load(undef, 1042 { 1043 fetchonly => [ 'id' ], 1044 join => MT::Permission->join_on('blog_id', 1045 { 1046 permissions => "\%'comment'\%", 1047 author_id => $id 1048 }, 1049 { 'like' => { 'permissions' => 1 } } 1050 ) 1051 } 1052 ); 1053 1054 # Has permissions to 20+ blogs - do not send these ids in cookie. 1055 $blog_ids = 20 < scalar(@blogs) 1056 ? 'N' 1057 : @blogs 1058 ? "'" . join("','", map { $_->id } @blogs) . "'" 1059 : ''; 1060 } 1061 1062 if ( $blog_ids ne 'S' && $blog_ids ne 'N' ) { 1063 my $perm = MT::Permission->load({ blog_id => $blog_id, author_id => $id }); 1064 if ($perm) { 1065 # double-check to see if this user hasn't been denied commenting 1066 # permission. user has 'comment' permission through a role, 1067 # but check for a restriction to comment on this blog 1068 if ($perm->is_restricted('comment')) { 1069 $blog_ids =~ s/(,|^)'$blog_id'(,|$)//; 1070 } 1071 1072 # But if the permission carries a 'can administer' permission 1073 # they should be allowed 1074 if ($blog_id && ($blog_ids !~ m/(,|^)'$blog_id'(,|$)/)) { 1075 if ($perm->can_administer_blog()) { 1076 # user is a blog administrator, so yes, they can comment too 1077 $blog_ids .= ($blog_ids ne '' ? ',' : '') 1078 . "'" . $blog_id . "'"; 1079 } 1080 } 1081 } 1082 else { 1083 if ($blog_id && ($blog_ids !~ m/(,|^)'$blog_id'(,|$)/)) { 1084 # extra check to see if this user can comment on requested 1085 # blog; this is specific to the Comment application, so 1086 # only do this if we're running the comments app. 1087 if ( $app->isa( 'MT::App::Comments' )) { 1088 if ( $app->_check_commenter_author($app->user, $blog_id) ) { 1089 # is this blog open to commenting from registered users? 1090 # if so, this user really can comment, even though they 1091 # don't have explicit permissions for it 1092 $blog_ids .= ($blog_ids ne '' ? ',' : '') 1093 . "'" . $blog_id . "'"; 1094 } 1095 } 1096 } 1097 } 1098 } 1099 1100 my %id_kookee = (-name => "commenter_id", 1101 -value => $id . ':' . $blog_ids, 1102 -path => '/', 1103 ($timeout ? (-expires => $timeout) : ())); 1104 $app->bake_cookie(%id_kookee); 1105 } 1106 if (defined($url) && $url) { 1107 my %id_kookee = (-name => "commenter_url", 1108 -value => $url, 1109 -path => '/', 1110 ($timeout ? (-expires => $timeout) : ())); 1111 $app->bake_cookie(%id_kookee); 1112 } 1037 my $banned = 0; 1038 my $perm = MT::Permission->load({ blog_id => $blog_id, author_id => $id }); 1039 if ($perm) { 1040 if (!$perm->can_administer_blog && $perm->is_restricted('comment')) { 1041 $banned = 1; 1042 } 1043 } 1044 1045 # my %id_kookee = (-name => "commenter_id", 1046 # -value => $id . ':' . $blog_ids, 1047 # -path => '/', 1048 # ($timeout ? (-expires => $timeout) : ())); 1049 # $app->bake_cookie(%id_kookee); 1050 } 1051 # if (defined($url) && $url) { 1052 # my %id_kookee = (-name => "commenter_url", 1053 # -value => $url, 1054 # -path => '/', 1055 # ($timeout ? (-expires => $timeout) : ())); 1056 # $app->bake_cookie(%id_kookee); 1057 # } 1113 1058 1114 1059 require MT::Session; … … 1135 1080 my $sess_obj = MT::Session->load({id => $session }); 1136 1081 $sess_obj->remove() if ($sess_obj); 1137 1138 my $timeout = $app->{cfg}->CommentSessionTimeout; 1139 1140 my %kookee = (-name => COMMENTER_COOKIE_NAME(), 1141 -value => '', 1142 -path => '/', 1143 -expires => "+${timeout}s"); 1144 $app->bake_cookie(%kookee); 1145 my %url_kookee = (-name => 'commenter_url', 1146 -value => '', 1147 -path => '/', 1148 -expires => "+${timeout}s"); 1149 $app->bake_cookie(%url_kookee); 1150 my %name_kookee = (-name => 'commenter_name', 1151 -value => '', 1152 -path => '/', 1153 -expires => "+${timeout}s"); 1154 $app->bake_cookie(%name_kookee); 1155 my %id_kookee = (-name => 'commenter_id', 1156 -value => '', 1157 -path => '/', 1158 -expires => "+${timeout}s"); 1159 $app->bake_cookie(%id_kookee); 1082 1083 $app->logout(); 1084 1085 # my $timeout = $app->config->CommentSessionTimeout; 1086 # my %kookee = (-name => COMMENTER_COOKIE_NAME(), 1087 # -value => '', 1088 # -path => '/', 1089 # -expires => "+${timeout}s"); 1090 # $app->bake_cookie(%kookee); 1091 # my %url_kookee = (-name => 'commenter_url', 1092 # -value => '', 1093 # -path => '/', 1094 # -expires => "+${timeout}s"); 1095 # $app->bake_cookie(%url_kookee); 1096 # my %name_kookee = (-name => 'commenter_name', 1097 # -value => '', 1098 # -path => '/', 1099 # -expires => "+${timeout}s"); 1100 # $app->bake_cookie(%name_kookee); 1101 # my %id_kookee = (-name => 'commenter_id', 1102 # -value => '', 1103 # -path => '/', 1104 # -expires => "+${timeout}s"); 1105 # $app->bake_cookie(%id_kookee); 1160 1106 } 1161 1107 … … 1169 1115 } 1170 1116 my $session = make_session($author, $remember); 1171 my %arg = (-name => $ COOKIE_NAME,1117 my %arg = (-name => $app->user_cookie, 1172 1118 -value => join('::', 1173 1119 $author->name, … … 1501 1447 # Presence of 'password' indicates this is a login request; 1502 1448 # do session/cookie management. 1503 $app-> _make_commenter_session(1449 $app->make_commenter_session( 1504 1450 $app->make_magic_token, 1505 1451 $author->email, … … 1579 1525 1580 1526 MT::Auth->invalidate_credentials({ app => $app }); 1581 my %cookies = $app->cookies();1582 $app->_invalidate_commenter_session(\%cookies);1527 # my %cookies = $app->cookies(); 1528 # $app->_invalidate_commenter_session(\%cookies); 1583 1529 1584 1530 # The login box should only be displayed in the event of non-delegated auth … … 1884 1830 sub clear_login_cookie { 1885 1831 my $app = shift; 1886 $app->bake_cookie(-name => $ COOKIE_NAME, -value => '', -expires => '-1y',1832 $app->bake_cookie(-name => $app->user_cookie, -value => '', -expires => '-1y', 1887 1833 -path => $app->config->CookiePath || $app->mt_path); 1888 1834 } -
branches/release-36/lib/MT/App/Comments.pm
r1924 r2062 34 34 post => \&post, 35 35 handle_sign_in => \&handle_sign_in, 36 cmtr_name_js => \&commenter_name_js, 37 cmtr_status_js => \&commenter_status_js, 36 session_js => \&session_js, 38 37 edit_profile => \&edit_commenter_profile, 39 38 save_profile => \&save_commenter_profile, 40 39 red => \&do_red, 41 40 generate_captcha => \&generate_captcha, 41 42 # deprecated 43 cmtr_name_js => \&commenter_name_js, 44 cmtr_status_js => \&commenter_status_js, 42 45 ); 43 46 $app->{template_dir} = 'comment'; … … 88 91 89 92 # 90 # $app->_get_commenter_session() #93 # $app->_get_commenter_session() 91 94 # Creates a commenter record based on the cookies in the $app, if 92 95 # one already exists corresponding to the browser's session. … … 103 106 my $session_key; 104 107 108 # First, check for a real MT user login. If one exists, 109 # return that as the commenter identity 110 my ($user, $first_time) = $app->SUPER::login(); 111 if ( $user ) { 112 my $sess = $app->session; 113 return ( $sess->id, $user ); 114 } 115 105 116 my %cookies = $app->cookies(); 106 my $cookie_name = MT::App::COMMENTER_COOKIE_NAME();117 my $cookie_name = $app->commenter_cookie; 107 118 if ( !$cookies{$cookie_name} ) { 108 119 return ( undef, undef ); … … 115 126 my $timeout = $cfg->CommentSessionTimeout; 116 127 my $user; 117 128 118 129 if ( $sess_obj 119 130 && ( $user = MT::Author->load( { name => $sess_obj->name } ) ) ) … … 123 134 if ( !$sess_obj 124 135 || ( $sess_obj->start() + $timeout < time ) 125 || ( $q->param('email') && ( $sess_obj->email ne $q->param('email') ) )126 || ( $q->param('author') && ( $user->nickname ne $q->param('author') ) )127 136 ) 128 137 { … … 131 140 } 132 141 else { 133 134 142 # session is valid! 135 143 return ( $session_key, $user ); … … 283 291 MT::Auth->new_login( $app, $commenter ); 284 292 if ( $app->_check_commenter_author( $commenter, $blog_id ) ) { 285 $app-> _make_commenter_session( $app->make_magic_token,293 $app->make_commenter_session( $app->make_magic_token, 286 294 $commenter->email, $commenter->name, 287 295 ($commenter->nickname || $app->translate('(Display Name not set)')), 288 296 $commenter->id, undef, $ctx->{permanent} ? '+10y' : 0, $blog_id ); 289 #$app->start_session( $commenter, $ctx->{permanent} ? 1 : 0 );290 297 return $app->redirect_to_target; 291 298 } … … 766 773 if $app->request_method() ne 'POST'; 767 774 768 my $entry_id = $q->param('entry_id')775 my $entry_id = int($q->param('entry_id')) 769 776 or return $app->error( $app->translate("No entry_id") ); 770 777 require MT::Entry; … … 787 794 if ( $app->remote_ip =~ /$banned_ip/ ) { 788 795 return $app->handle_error( 789 $app->translate("You are not allowed to add comments.") ); 796 $app->translate("Invalid request") ); 797 } 798 } 799 800 my $blog = $app->model('blog')->load( $entry->blog_id ) 801 or return $app->error($app->translate('Can\'t load blog #[_1].', $entry->blog_id)); 802 803 my $armor = $q->param('armor'); 804 if (defined $armor) { 805 # For this to work, we must create a site path exactly like 806 # <MTBlogSitePath> does. 807 my $path = $blog->site_path; 808 $path .= '/' unless $path =~ m!/$!; 809 my $site_path_sha1 = MT::Util::perl_sha1_digest_hex($path); 810 if ($armor ne $site_path_sha1) { 811 return $app->handle_error($app->translate("Invalid request; $armor != $site_path_sha1")); 790 812 } 791 813 } … … 813 835 $app->translate("Comments are not allowed on this entry.") ); 814 836 } 815 816 my $blog = $app->model('blog')->load( $entry->blog_id )817 or return $app->error($app->translate('Can\'t load blog #[_1].', $entry->blog_id));818 837 819 838 my $text = $q->param('text') || ''; … … 923 942 ); 924 943 } 925 if ($commenter) {926 $commenter->url( $comment->url )927 if $comment->url && $commenter->type != MT::Author::COMMENTER();928 $commenter->save929 or $app->log(930 {931 message => $app->translate(932 "Commenter save failed with [_1]",933 $commenter->errstr934 ),935 class => 'system',936 blog_id => $blog->id,937 level => MT::Log::ERROR()938 }939 );940 }941 942 # return $app->handle_error($app->errstr()) unless $comment;943 944 944 945 # Form a link to the comment … … 947 948 my $url = $app->base . $app->uri; 948 949 $url .= '?entry_id=' . $q->param('entry_id'); 949 $url .= '&static=0&arch=1' if ( $q->param('arch') );950 950 $comment_link = $url; 951 951 } … … 953 953 my $static = $q->param('static'); 954 954 if ( $static eq '1' ) { 955 956 955 # I think what we really want is the individual archive. 957 956 $comment_link = $entry->permalink; … … 959 958 else { 960 959 $static =~ s/[\r\n].*$//s; 961 $comment_link = $static . '# ' . $comment->id;960 $comment_link = $static . '#comment-' . $comment->id; 962 961 } 963 962 } … … 968 967 # redirected to the indiv. page it will be up-to-date. 969 968 $app->rebuild_entry( Entry => $entry->id ) 970 or return $app-> error(969 or return $app->handle_error( 971 970 $app->translate( "Publish failed: [_1]", $app->errstr ) ); 972 971 } … … 1001 1000 require MT::DefaultTemplates; 1002 1001 $tmpl = MT::DefaultTemplates->load({ type => 'comment_response' }) 1003 or return $app-> error($app->translate("Can\'t load template"));1002 or return $app->handle_error($app->translate("Can\'t load template")); 1004 1003 $tmpl->text( $app->translate_templatized( $tmpl->text ) ); 1005 1004 } … … 1097 1096 my %param = @_; 1098 1097 my %cookies = $app->cookies(); 1099 my $cookie_name = MT::App::COMMENTER_COOKIE_NAME();1098 my $cookie_name = $app->commenter_cookie_name; 1100 1099 my $session_key = $cookies{$cookie_name}->value() || ""; 1101 1100 $session_key =~ y/+/ /; … … 1141 1140 # INACTIVE == BANNED 1142 1141 return 0 if $status == MT::Author::BANNED(); 1142 return 0 if $commenter->status == MT::Author::BANNED(); 1143 1143 1144 1144 # NOT using $status for this test, since $status may be … … 1168 1168 or return $app->error($app->translate('Can\'t load blog #[_1].', $blog_id)); 1169 1169 if ( $registration->{Allow} && $blog->allow_commenter_regist ) { 1170 my $perm = $commenter->blog_perm($blog_id); 1171 return 0 unless $perm->is_empty; 1172 require MT::Role; 1173 require MT::Association; 1174 my $role = MT::Role->load_same( undef, undef, 1, 'comment' ); 1175 if ( $role && $blog ) { 1176 MT::Association->link( $commenter => $role => $blog ); 1177 } 1178 else { 1179 # FIXME: In this case, we should probably return 0 1180 # here, since no permission was actually granted. 1181 $app->log( 1182 { 1183 message => MT->translate( 1184 "Error assigning commenting rights to user '[_1] (ID: [_2])' for weblog '[_3] (ID: [_4])'. No suitable commenting role was found.", 1185 $commenter->name, $commenter->id, 1186 $blog->name, $blog->id, 1187 ), 1188 level => MT::Log::ERROR(), 1189 class => 'system', 1190 category => 'new' 1191 } 1192 ); 1193 } 1170 # By policy, this blog permits this type of user 1171 # and they are not banned (as they have no blog perms/ 1172 # restrictions, so permit this comment) 1194 1173 return 1; 1195 1174 } … … 1368 1347 if ( $q->param('logout') ) { 1369 1348 my ( $s, $commenter ) = $app->_get_commenter_session(); 1370 #if ($commenter) { 1371 # require MT::Auth; 1372 # my $ctx = MT::Auth->fetch_credentials( { app => $app } ); 1373 # my $cmntr_sess = 1374 # $app->session_user( $commenter, $ctx->{session_id}, 1375 # permanent => $ctx->{permanent} ); 1376 # if ($cmntr_sess) { 1377 # $app->user($commenter); 1378 # MT::Auth->invalidate_credentials( { app => $app } ); 1379 # } 1380 #} 1349 1350 # invalidate credentials in auth layer 1351 if ($commenter) { 1352 require MT::Auth; 1353 my $ctx = MT::Auth->fetch_credentials( { app => $app } ); 1354 my $cmntr_sess = 1355 $app->session_user( $commenter, $ctx->{session_id}, 1356 permanent => $ctx->{permanent} ); 1357 if ($cmntr_sess) { 1358 $app->user($commenter); 1359 MT::Auth->invalidate_credentials( { app => $app } ); 1360 } 1361 } 1381 1362 1382 1363 my %cookies = $app->cookies(); 1383 1364 $app->_invalidate_commenter_session( \%cookies ); 1384 if ( $commenter && ( 'TypeKey' ne $commenter->auth_type ) ) { 1385 # Remove logout parameter so MT does not go to TypeKey 1386 # when unnecessary. 1387 $app->param( 'logout', 0 ); 1388 } 1365 $app->user($commenter) if $commenter; 1389 1366 $result = 1; 1390 1367 } … … 1415 1392 my $target; 1416 1393 require MT::Util; 1417 if ( $q->param('static') ) { 1418 if ( $q->param('static') eq 1 ) { 1419 require MT::Entry; 1420 my $entry = MT::Entry->load( $q->param('entry_id') ) 1421 or return $app->error($app->translate('Can\'t load entry #[_1].', $q->param('entry_id'))); 1422 $target = $entry->archive_url; 1423 my $blog = MT::Blog->load( $entry->blog_id ); 1424 $target = MT::Util::strip_index( $target, $blog ); 1425 } 1426 else { 1427 $target = $q->param('static'); 1428 } 1429 } 1430 else { 1431 $target = 1432 ( $cfg->CGIPath 1433 . $cfg->CommentScript 1434 . "?entry_id=" 1435 . $q->param('entry_id') 1436 . ( $q->param('arch') ? '&static=0&arch=1' : '' ) ); 1394 my $static = $q->param('static') || ''; 1395 1396 if ( ($static eq '') || ($static eq 1) ) { 1397 require MT::Entry; 1398 my $entry = MT::Entry->load( $q->param('entry_id') || 0 ) 1399 or return $app->error($app->translate('Can\'t load entry #[_1].', $q->param('entry_id'))); 1400 $target = $entry->archive_url; 1401 my $blog = MT::Blog->load( $entry->blog_id ); 1402 $target = MT::Util::strip_index( $target, $blog ); 1403 } 1404 elsif ($static ne '') { 1405 $target = $static; 1437 1406 } 1438 1407 if ( $q->param('logout') ) { 1439 return $app->redirect( 1440 $cfg->SignOffURL . "&_return=" . MT::Util::encode_url($target), 1441 UseMeta => 1 ); 1442 } 1443 else { 1444 return $app->redirect( $target, UseMeta => 1 ); 1445 } 1408 if ( $app->user && 1409 ( 'TypeKey' eq $app->user->auth_type ) ) { 1410 return $app->redirect( 1411 $cfg->SignOffURL . "&_return=" . 1412 MT::Util::encode_url($target . '#_logout'), 1413 UseMeta => 1 ); 1414 } 1415 } 1416 return $app->redirect( $target . '#_' . 1417 ($q->param('logout') ? 'logout' : 'login'), UseMeta => 1 ); 1446 1418 } 1447 1419 … … 1485 1457 } 1486 1458 1459 sub session_js { 1460 my $app = shift; 1461 my $blog_id = int($app->param('blog_id')); 1462 my $blog = MT::Blog->load( $blog_id ) if $blog_id; 1463 my $jsonp = $app->param('jsonp'); 1464 $jsonp = undef if $jsonp !~ m/^\w+$/; 1465 1466 my $c; 1467 if ( $jsonp && $blog_id && $blog ) { 1468 my ( $session, $commenter ) = $app->_get_commenter_session(); 1469 if ( $session && $commenter ) { 1470 my $blog_perms = $commenter->blog_perm($blog_id); 1471 my $banned = $commenter->is_banned($blog_id) ? "1" : "0"; 1472 $banned = 0 if $blog_perms && $blog_perms->can_administer; 1473 $banned ||= 1 if $commenter->status == MT::Author::BANNED(); 1474 1475 my $sessobj = MT::Session->load($session); 1476 if ($banned) { 1477 $sessobj->remove; 1478 } else { 1479 $sessobj->start( time + 1480 $app->config->CommentSessionTimeout); # extend by timeou 1481 $sessobj->save(); 1482 } 1483 1484 my $can_comment = $banned ? 0 : 1; 1485 $can_comment = 0 unless $blog->allow_unreg_comments || $blog->allow_reg_comments; 1486 my $can_post = ($blog_perms && $blog_perms->can_create_post) ? "1" : "0"; 1487 $c = { 1488 name => $commenter->nickname, 1489 url => $commenter->url, 1490 email => $commenter->email, 1491 userpic => scalar $commenter->userpic_url, 1492 profile => "", # profile link url 1493 is_authenticated => "1", 1494 is_trusted => ($commenter->is_trusted() ? "1" : "0"), 1495 is_author => ($commenter->type == MT::Author::AUTHOR() ? "1" : "0"), 1496 is_anonymous => "0", 1497 is_banned => $banned, 1498 can_comment => $can_comment, 1499 can_post => $can_post, 1500 }; 1501 } 1502 } 1503 1504 unless ($c) { 1505 my $can_comment = $blog->allow_anon_comments ? "1" : "0"; 1506 $c = { 1507 is_authenticated => "0", 1508 is_trusted => "0", 1509 is_anonymous => "1", 1510 can_post => "0", # no anonymous posts 1511 can_comment => $can_comment, 1512 is_banned => "0", 1513 }; 1514 } 1515 1516 require JSON; 1517 $app->{no_print_body} = 1; 1518 $app->send_http_header("text/javascript"); 1519 my $json = JSON::objToJson($c); 1520 $app->print("$jsonp(" . $json . ");\n"); 1521 return undef; 1522 } 1523 1524 # deprecated 1487 1525 sub commenter_status_js { 1488 1526 local $SIG{__WARN__} = sub { }; … … 1506 1544 } 1507 1545 1546 # deprecated 1508 1547 sub commenter_name_js { 1509 1548 local $SIG{__WARN__} = sub { }; … … 1656 1695 my $app = shift; 1657 1696 1658 my $id = $app->param('commenter');1659 return $app->handle_error( $app->translate('Invalid commenter ID') )1660 unless $id =~ /\d+/;1661 1662 my $url;1663 my $entry_id = $app->param('entry_id');1664 if ($entry_id) {1665 my $entry = MT::Entry->load($entry_id);1666 return $app->handle_error( $app->translate("No entry ID provided") )1667 unless $entry;1668 $url = $entry->permalink;1669 }1670 else {1671 $url = is_valid_url( $app->param('static') );1672 }1673 1674 1697 my ( $session, $commenter ) = $app->_get_commenter_session(); 1675 1698 if ($commenter) { 1699 my $url; 1700 my $entry_id = $app->param('entry_id'); 1701 if ($entry_id) { 1702 my $entry = MT::Entry->load($entry_id); 1703 return $app->handle_error( $app->translate("Invalid entry ID provided") ) 1704 unless $entry; 1705 $url = $entry->permalink; 1706 } 1707 else { 1708 $url = is_valid_url( $app->param('static') ); 1709 } 1710 1676 1711 #require MT::Auth; 1677 1712 #my $ctx = MT::Auth->fetch_credentials( { app => $app } ); … … 1683 1718 1684 1719 my $blog_id = $app->param('blog_id'); 1685 return $app->handle_error( $app->translate('Permission denied') )1686 unless $commenter->blog_perm($blog_id)->can_comment;1687 1688 1720 $app->user($commenter); 1689 1721 my $param = { … … 1696 1728 $entry_id ? ( entry_url => $url ) : ( return_url => $url ), 1697 1729 }; 1698 $param->{ 'auth_mode_' . $ app->config->AuthenticationModule } = 1;1730 $param->{ 'auth_mode_' . $commenter->auth_type } = 1; 1699 1731 require MT::Auth; 1700 1732 $param->{'email_required'} = MT::Auth->can_recover_password ? 1 : 0; … … 1711 1743 map { $_ => scalar( $q->param($_) ) } 1712 1744 qw( id name nickname email password pass_verify hint url entry_url return_url external_auth); 1713 $param{ 'auth_mode_' . $app->config->AuthenticationModule } = 1;1714 1745 1715 1746 unless ( $param{id} =~ /\d+/ ) { … … 1724 1755 } 1725 1756 1726 #require MT::Auth; 1727 #my $ctx = MT::Auth->fetch_credentials( { app => $app } ); 1728 #my $cmntr_sess = 1757 $param{ 'auth_mode_' . $cmntr->auth_type } = 1; 1758 1759 # require MT::Auth; 1760 # my $ctx = MT::Auth->fetch_credentials( { app => $app } ); 1761 # my $cmntr_sess = 1729 1762 # $app->session_user( $cmntr, $ctx->{session_id}, 1730 1763 # permanent => $ctx->{permanent} ); 1731 # return $app->handle_error( $app->translate('Invalid login') )1764 # return $app->handle_error( $app->translate('Invalid login') ) 1732 1765 # unless $cmntr_sess; 1733 1766 … … 1774 1807 } 1775 1808 if ($renew_session) { 1776 $app-> _make_commenter_session( $app->make_magic_token, $cmntr->email,1809 $app->make_commenter_session( $app->make_magic_token, $cmntr->email, 1777 1810 $cmntr->name, 1778 1811 ($cmntr->nickname || $app->translate('(Display Name not set)')), 1779 1812 $cmntr->id ); 1780 # $app->start_session( $cmntr, $ctx->{permanent} ); 1781 } 1782 $param{ 'auth_mode_' . $app->config->AuthenticationModule } = 1; 1813 } 1814 1783 1815 return $app->build_page( 'profile.tmpl', \%param ); 1784 1816 } -
branches/release-36/lib/MT/Auth/MT.pm
r1823 r2062 66 66 $pass = $app->param('password'); 67 67 $remember = $app->param('remember') ? 1 : 0; 68 return { %$ctx, username => $user, password => $pass, permanent => $remember };68 return { %$ctx, username => $user, password => $pass, permanent => $remember, auth_type => 'MT' }; 69 69 } 70 70 return undef; … … 79 79 if ($cookies->{$app->user_cookie}) { 80 80 my ($user, $session_id, $remember) = split /::/, $cookies->{$app->user_cookie}->value; 81 return { %$ctx, username => $user, session_id => $session_id, permanent => $remember };81 return { %$ctx, username => $user, session_id => $session_id, permanent => $remember, auth_type => 'MT' }; 82 82 } 83 83 return undef; … … 108 108 # load author from db 109 109 my $user_class = $app->user_class; 110 my ($author) = $user_class->search({ name => $username, type => AUTHOR });110 my ($author) = $user_class->search({ name => $username, type => AUTHOR, auth_type => 'MT' }); 111 111 112 112 if ($author) { -
branches/release-36/lib/MT/Auth/OpenID.pm
r1914 r2062 117 117 my $nick_escaped = escape_unicode($nick); 118 118 $nick = encode_text($nick, 'utf-8', undef); 119 $session = $app-> _make_commenter_session($app->make_magic_token, q(),119 $session = $app->make_commenter_session($app->make_magic_token, q(), 120 120 $name, $nick_escaped, undef, $name); 121 121 unless ($session) { -
branches/release-36/lib/MT/Auth/TypeKey.pm
r1823 r2062 62 62 my $nick_escaped = escape_unicode($nick); 63 63 $nick = encode_text($nick, 'utf-8', undef); 64 $session = $app-> _make_commenter_session($sig_str, $email,64 $session = $app->make_commenter_session($sig_str, $email, 65 65 $name, $nick_escaped, undef, $url); 66 66 unless ($session) { -
branches/release-36/lib/MT/Template/ContextHandlers.pm
r2052 r2062 82 82 Loop => \&_hdlr_loop, 83 83 Section => \&_hdlr_section, 84 IfNonEmpty=> \&_hdlr_if_nonempty,85 IfNonZero=> \&_hdlr_if_nonzero,86 87 IfCommenterTrusted=> \&_hdlr_commenter_trusted,88 CommenterIfTrusted=> \&_hdlr_commenter_trusted,89 IfCommenterIsAuthor=> \&_hdlr_commenter_isauthor,90 IfCommenterIsEntryAuthor=> \&_hdlr_commenter_isauthor,84 'IfNonEmpty?' => \&_hdlr_if_nonempty, 85 'IfNonZero?' => \&_hdlr_if_nonzero, 86 87 'IfCommenterTrusted?' => \&_hdlr_commenter_trusted, 88 'CommenterIfTrusted?' => \&_hdlr_commenter_trusted, 89 'IfCommenterIsAuthor?' => \&_hdlr_commenter_isauthor, 90 'IfCommenterIsEntryAuthor?' => \&_hdlr_commenter_isauthor, 91 91 92 92 'IfBlog?' => \&_hdlr_blog_id, … … 105 105 EntryCategories => \&_hdlr_entry_categories, 106 106 EntryAdditionalCategories => \&_hdlr_entry_additional_categories, 107 BlogIfCommentsOpen=> \&_hdlr_blog_if_comments_open,107 'BlogIfCommentsOpen?' => \&_hdlr_blog_if_comments_open, 108 108 EntryPrevious => \&_hdlr_entry_previous, 109 109 EntryNext => \&_hdlr_entry_next, … … 124 124 SetHashVar => \&_hdlr_set_hashvar, 125 125 126 IfCommentsModerated=> \&_hdlr_comments_moderated,127 IfRegistrationRequired=> \&_hdlr_reg_required,128 IfRegistrationNotRequired=> \&_hdlr_reg_not_required,129 IfRegistrationAllowed=> \&_hdlr_reg_allowed,130 131 IfTypeKeyToken=> \&_hdlr_if_typekey_token,126 'IfCommentsModerated?' => \&_hdlr_comments_moderated, 127 'IfRegistrationRequired?' => \&_hdlr_reg_required, 128 'IfRegistrationNotRequired?' => \&_hdlr_reg_not_required, 129 'IfRegistrationAllowed?' => \&_hdlr_reg_allowed, 130 131 'IfTypeKeyToken?' => \&_hdlr_if_typekey_token, 132 132 133 133 Comments => \&_hdlr_comments, … … 135 135 CommentsFooter => \&_hdlr_pass_tokens, 136 136 CommentEntry => \&_hdlr_comment_entry, 137 CommentIfModerated=> \&_hdlr_comment_if_moderated,137 'CommentIfModerated?' => \&_hdlr_comment_if_moderated, 138 138 139 139 CommentParent => \&_hdlr_comment_parent, … … 159 159 160 160 Categories => \&_hdlr_categories, 161 CategoryIfAllowPings=> \&_hdlr_category_allow_pings,161 'CategoryIfAllowPings?' => \&_hdlr_category_allow_pings, 162 162 CategoryPrevious => \&_hdlr_category_prevnext, 163 163 CategoryNext => \&_hdlr_category_prevnext, … … 167 167 PingEntry => \&_hdlr_ping_entry, 168 168 169 IfAllowCommentHTML=> \&_hdlr_if_allow_comment_html,170 IfCommentsAllowed=> \&_hdlr_if_comments_allowed,171 IfCommentsAccepted=> \&_hdlr_if_comments_accepted,172 IfCommentsActive=> \&_hdlr_if_comments_active,173 IfPingsAllowed=> \&_hdlr_if_pings_allowed,174 IfPingsAccepted=> \&_hdlr_if_pings_accepted,175 IfPingsActive=> \&_hdlr_if_pings_active,176 IfPingsModerated=> \&_hdlr_if_pings_moderated,177 IfNeedEmail=> \&_hdlr_if_need_email,178 IfRequireCommentEmails=> \&_hdlr_if_need_email,179 EntryIfAllowComments => \&_hdlr_if_comments_active,180 EntryIfCommentsOpen=> \&_hdlr_entry_if_comments_open,181 EntryIfAllowPings=> \&_hdlr_entry_if_allow_pings,182 EntryIfExtended=> \&_hdlr_entry_if_extended,169 'IfAllowCommentHTML?' => \&_hdlr_if_allow_comment_html, 170 'IfCommentsAllowed?' => \&_hdlr_if_comments_allowed, 171 'IfCommentsAccepted?' => \&_hdlr_if_comments_accepted, 172 'IfCommentsActive?' => \&_hdlr_if_comments_active, 173 'IfPingsAllowed?' => \&_hdlr_if_pings_allowed, 174 'IfPingsAccepted?' => \&_hdlr_if_pings_accepted, 175 'IfPingsActive?' => \&_hdlr_if_pings_active, 176 'IfPingsModerated?' => \&_hdlr_if_pings_moderated, 177 'IfNeedEmail?' => \&_hdlr_if_need_email, 178 'IfRequireCommentEmails?' => \&_hdlr_if_need_email, 179 'EntryIfAllowComments?' => \&_hdlr_entry_if_allow_comments, 180 'EntryIfCommentsOpen?' => \&_hdlr_entry_if_comments_open, 181 'EntryIfAllowPings?' => \&_hdlr_entry_if_allow_pings, 182 'EntryIfExtended?' => \&_hdlr_entry_if_extended, 183 183 184 184 SubCategories => \&_hdlr_sub_categories, … … 373 373 RemoteSignOutLink => \&_hdlr_remote_sign_out_link, 374 374 RemoteSignInLink => \&_hdlr_remote_sign_in_link, 375 SignOutLink => \&_hdlr_sign_out_link, 376 SignInLink => \&_hdlr_sign_in_link, 375 377 376 378 CommentID => \&_hdlr_comment_id, … … 1423 1425 elsif (defined(my $tag = $args->{tag})) { 1424 1426 $tag =~ s/^MT:?//i; 1425 my ($handler ) = $ctx->handler_for($tag);1427 my ($handler, $type) = $ctx->handler_for($tag); 1426 1428 if (defined($handler)) { 1427 1429 local $ctx->{__stash}{tag} = $args->{tag}; 1428 1430 $value = $handler->($ctx, { %$args }); 1429 if (my $ph = $ctx->post_process_handler) { 1430 $value = $ph->($ctx, $args, $value); 1431 if ($type == 2) { # conditional tag; just use boolean 1432 $value = $value ? 1 : 0; 1433 } else { 1434 if (my $ph = $ctx->post_process_handler) { 1435 $value = $ph->($ctx, $args, $value); 1436 } 1431 1437 } 1432 1438 $ctx->{__stash}{vars}{__cond_tag__} = $args->{tag}; … … 2186 2192 my $blog = $_[0]->stash('blog'); 2187 2193 if ($blog->remote_auth_token) { 2188 _hdlr_pass_tokens(@_);2194 return 1; 2189 2195 } else { 2190 _hdlr_pass_tokens_else(@_);2196 return 0; 2191 2197 } 2192 2198 } … … 2195 2201 my $blog = $_[0]->stash('blog'); 2196 2202 if ($blog->moderate_unreg_comments || $blog->manual_approve_commenters) { 2197 _hdlr_pass_tokens(@_);2203 return 1; 2198 2204 } else { 2199 _hdlr_pass_tokens_else(@_);2205 return 0; 2200 2206 } 2201 2207 } … … 2204 2210 my $blog = $_[0]->stash('blog'); 2205 2211 if ($blog->allow_reg_comments && $blog->commenter_authenticators) { 2206 _hdlr_pass_tokens(@_);2212 return 1; 2207 2213 } else { 2208 _hdlr_pass_tokens_else(@_);2214 return 0; 2209 2215 } 2210 2216 } … … 2214 2220 if ( $blog->allow_reg_comments && $blog->commenter_authenticators 2215 2221 && ! $blog->allow_unreg_comments ) { 2216 _hdlr_pass_tokens(@_);2222 return 1; 2217 2223 } else { 2218 _hdlr_pass_tokens_else(@_);2224 return 0; 2219 2225 } 2220 2226 } … … 2224 2230 if ($blog->allow_reg_comments && $blog->commenter_authenticators 2225 2231 && $blog->allow_unreg_comments) { 2226 _hdlr_pass_tokens(@_);2232 return 1; 2227 2233 } else { 2228 _hdlr_pass_tokens_else(@_);2234 return 0; 2229 2235 } 2230 2236 } … … 2241 2247 (($blog->allow_reg_comments && $blog->effective_remote_auth_token) 2242 2248 || $blog->allow_unreg_comments)) { 2243 _hdlr_pass_tokens(@_);2249 return 1; 2244 2250 } else { 2245 _hdlr_pass_tokens_else(@_);2251 return 0; 2246 2252 } 2247 2253 } … … 2384 2390 2385 2391 # Try to read from cache 2392 my $cache_expire_type = $tmpl->cache_expire_type || 0; 2386 2393 my $cache_enabled = 2387 2394 $blog … … 2391 2398 || $arg->{key} 2392 2399 || ( exists $arg->{ttl} ) 2393 || ( $ tmpl->cache_expire_type != 0 ) ) ? 1 : 0;2400 || ( $cache_expire_type != 0 ) ) ? 1 : 0; 2394 2401 my $cache_key = 2395 2402 ($arg->{cache_key} || $arg->{key}) … … 2398 2405 my $ttl = 2399 2406 exists $arg->{ttl} ? $arg->{ttl} 2400 : ( $ tmpl->cache_expire_type == 1 ) ? $tmpl->cache_expire_interval2401 : ( $ tmpl->cache_expire_type == 2 ) ? 02407 : ( $cache_expire_type == 1 ) ? $tmpl->cache_expire_interval 2408 : ( $cache_expire_type == 2 ) ? 0 2402 2409 : 60 * 60; # default 60 min. 2403 2410 2404 if ( $ tmpl->cache_expire_type == 2 ) {2411 if ( $cache_expire_type == 2 ) { 2405 2412 my @types = split /,/, ($tmpl->cache_expire_event || ''); 2406 2413 if (@types) { … … 2736 2743 } 2737 2744 if (defined($value) && $value ne '') { # want to include "0" here 2738 _hdlr_pass_tokens($ctx, $args, $cond);2745 return 1; 2739 2746 } else { 2740 _hdlr_pass_tokens_else($ctx, undef, $cond);2747 return 0; 2741 2748 } 2742 2749 } … … 2761 2768 } 2762 2769 if (defined($value) && $value) { 2763 _hdlr_pass_tokens($ctx, $args, $cond);2770 return 1; 2764 2771 } else { 2765 _hdlr_pass_tokens_else($ctx, undef, $cond);2772 return 0; 2766 2773 } 2767 2774 } … … 4049 4056 } 4050 4057 $no_resort = 0; 4058 } elsif ($class->is_meta_column($args->{sort_by})) { 4059 $no_resort = 0; 4051 4060 } 4052 4061 } … … 4107 4116 if (my $def = $class->column_def($col)) { 4108 4117 if ($def->{type} =~ m/^integer|float$/) { 4118 @$entries = $so eq 'ascend' ? 4119 sort { $a->$col() <=> $b->$col() } @$entries : 4120 sort { $b->$col() <=> $a->$col() } @$entries; 4121 } else { 4122 @$entries = $so eq 'ascend' ? 4123 sort { $a->$col() cmp $b->$col() } @$entries : 4124 sort { $b->$col() cmp $a->$col() } @$entries; 4125 } 4126 $no_resort = 1; 4127 } elsif ($class->is_meta_column($col)) { 4128 my $type = MT::Meta->metadata_by_name($class, $col); 4129 no warnings; 4130 if ($type->{type} =~ m/integer|float/) { 4109 4131 @$entries = $so eq 'ascend' ? 4110 4132 sort { $a->$col() <=> $b->$col() } @$entries : … … 4226 4248 if (my $def = $class->column_def($col)) { 4227 4249 if ($def->{type} =~ m/^integer|float$/) { 4250 @entries = $so eq 'ascend' ? 4251 sort { $a->$col() <=> $b->$col() } @entries : 4252 sort { $b->$col() <=> $a->$col() } @entries; 4253 } else { 4254 @entries = $so eq 'ascend' ? 4255 sort { $a->$col() cmp $b->$col() } @entries : 4256 sort { $b->$col() cmp $a->$col() } @entries; 4257 } 4258 } elsif ($class->is_meta_column($col)) { 4259 my $type = MT::Meta->metadata_by_name($class, $col); 4260 no warnings; 4261 if ($type->{type} =~ m/integer|float/) { 4228 4262 @entries = $so eq 'ascend' ? 4229 4263 sort { $a->$col() <=> $b->$col() } @entries : … … 4788 4822 my $builder = $ctx->stash('builder'); 4789 4823 my $tokens = $ctx->stash('tokens'); 4790 my $res ;4824 my $res = ''; 4791 4825 my $glue = $args->{glue}; 4792 4826 for my $cat (@$cats) { … … 4808 4842 my $tp_token = $blog->effective_remote_auth_token(); 4809 4843 return $tp_token; 4844 } 4845 4846 sub _hdlr_sign_in_link { 4847 my ($ctx, $args) = @_; 4848 my $cfg = $ctx->{config}; 4849 my $blog = $ctx->stash('blog'); 4850 my $path = _hdlr_cgi_path($ctx); 4851 $path .= '/' unless $path =~ m!/$!; 4852 my $comment_script = $cfg->CommentScript; 4853 my $static_arg = $args->{static} ? "&static=" . $args->{static} : "&static=0"; 4854 my $e = $ctx->stash('entry'); 4855 return "$path$comment_script?__mode=login$static_arg" . 4856 ($blog ? '&blog_id=' . $blog->id : '') . 4857 ($e ? '&entry_id=' . $e->id : ''); 4858 } 4859 4860 sub _hdlr_sign_out_link { 4861 my ($ctx, $args) = @_; 4862 my $cfg = $ctx->{config}; 4863 my $path = _hdlr_cgi_path($ctx); 4864 $path .= '/' unless $path =~ m!/$!; 4865 my $comment_script = $cfg->CommentScript; 4866 my $static_arg; 4867 if ($args->{no_static}) { 4868 $static_arg = q(); 4869 } else { 4870 my $url = $args->{static}; 4871 if ($url && ($url ne '1')) { 4872 $static_arg = "&static=" . MT::Util::encode_url($url); 4873 } elsif ($url) { 4874 $static_arg = "&static=1"; 4875 } else { 4876 $static_arg = "&static=0"; 4877 } 4878 } 4879 my $e = $_[0]->stash('entry'); 4880 return "$path$comment_script?__mode=handle_sign_in$static_arg&logout=1" . 4881 ($e ? "&entry_id=" . $e->id : ''); 4810 4882 } 4811 4883 … … 4997 5069 if ($r eq 'js') { 4998 5070 # output javascript here to render relative date 5071 my($y, $mo, $d, $h, $m, $s) = $ts =~ /(\d\d\d\d)[^\d]?(\d\d)[^\d]?(\d\d)[^\d]?(\d\d)[^\d]?(\d\d)[^\d]?(\d\d)/; 5072 $mo--; 5073 my $fds = format_ts($args->{'format'}, $ts, $blog, $lang); 5074 my $js = <<EOT; 5075 <script type="text/javascript"> 5076 /* <![CDATA[ */ 5077 document.write(mtRelativeDate(new Date($y,$mo,$d,$h,$m,$s), '$fds')); 5078 /* ]]> */ 5079 </script><noscript>$fds</noscript> 5080 EOT 5081 return $js; 4999 5082 } else { 5000 5083 my $old_lang = MT->current_language; … … 5346 5429 or return $_[0]->_no_comment_error('MTCommentIfModerated'); 5347 5430 if ($c->visible) { 5348 return _hdlr_pass_tokens(@_);5431 return 1; 5349 5432 } else { 5350 return _hdlr_pass_tokens_else(@_);5433 return 0; 5351 5434 } 5352 5435 } … … 5528 5611 my $label = $args->{label} || $args->{text} || MT->translate('Reply'); 5529 5612 my $comment_author = MT::Util::encode_js($comment->author); 5530 5531 return sprintf(qq(<a title="%s" href="javascript:void(0);" onclick="replyComment(%d, '%s')">%s</a>), 5613 my $onclick = $args->{onclick} || 'mtReplyCommentOnClick'; 5614 5615 return sprintf(qq(<a title="%s" href="javascript:void(0);" onclick="$onclick(%d, '%s')">%s</a>), 5532 5616 $label, $comment->id, $comment_author, $label); 5533 5617 } … … 5535 5619 sub _hdlr_comment_parent_id { 5536 5620 my $args = $_[1]; 5537 my $c = $_[0]->stash('comment') 5538 or return $_[0]->_no_comment_error('MTCommentParentID'); 5621 my $c = $_[0]->stash('comment') or return ''; 5539 5622 my $id = $c->parent_id || 0; 5540 5623 $args && $args->{pad} ? (sprintf "%06d", $id) : ($id ? $id : ''); … … 5745 5828 return '' unless $a; 5746 5829 if ($a->is_trusted($ctx->stash('blog_id'))) { 5747 return _hdlr_pass_tokens(@_);5830 return 1; 5748 5831 } else { 5749 return _hdlr_pass_tokens_else(@_);5832 return 0; 5750 5833 } 5751 5834 } … … 5754 5837 my ($ctx, $args, $cond) = @_; 5755 5838 my $a = $ctx->stash('commenter'); 5756 return _hdlr_pass_tokens_else(@_) 5757 unless $a; 5839 return 0 unless $a; 5758 5840 if ($a->type == MT::Author::AUTHOR()) { 5759 5841 my $tag = lc $ctx->stash('tag'); … … 5763 5845 if ($e) { 5764 5846 if ($e->author_id == $a->id) { 5765 return _hdlr_pass_tokens(@_);5847 return 1; 5766 5848 } 5767 5849 } 5768 5850 } else { 5769 return _hdlr_pass_tokens(@_);5770 } 5771 } 5772 return _hdlr_pass_tokens_else(@_);5851 return 1; 5852 } 5853 } 5854 return 0; 5773 5855 } 5774 5856 … … 6378 6460 my $entry_class = MT->model( 6379 6461 $class_type eq 'category' ? 'entry' : 'page'); 6380 6462 6381 6463 my $iter = $class->load_iter(\%terms, \%args); 6382 6464 my $res = ''; … … 6578 6660 my $cat = $_[0]->stash('category') || $_[0]->stash('archive_category'); 6579 6661 if ($cat->allow_pings) { 6580 _hdlr_pass_tokens(@_);6662 return 1; 6581 6663 } else { 6582 _hdlr_pass_tokens_else(@_);6583 } 6664 return 0; 6665 } 6584 6666 } 6585 6667 … … 6706 6788 my $builder = $ctx->stash('builder'); 6707 6789 my $tokens = $ctx->stash('tokens'); 6708 my $res ;6790 my $res = ''; 6709 6791 my $glue = $args->{glue}; 6710 6792 for my $cat (@$cats) { … … 6858 6940 return '' unless $blog; 6859 6941 if ($blog->allow_comment_html) { 6860 return _hdlr_pass_tokens(@_);6942 return 1; 6861 6943 } else { 6862 return _hdlr_pass_tokens_else(@_);6944 return 0; 6863 6945 } 6864 6946 } … … 6872 6954 && $blog->effective_remote_auth_token)))) 6873 6955 && $cfg->AllowComments) { 6874 return _hdlr_pass_tokens(@_);6956 return 1; 6875 6957 } else { 6876 return _hdlr_pass_tokens_else(@_);6958 return 0; 6877 6959 } 6878 6960 } … … 6892 6974 } 6893 6975 if ($active) { 6894 return _hdlr_pass_tokens(@_);6976 return 1; 6895 6977 } else { 6896 return _hdlr_pass_tokens_else(@_);6978 return 0; 6897 6979 } 6898 6980 } … … 6907 6989 $accepted = 0 if $entry && !$entry->allow_comments; 6908 6990 if ($accepted) { 6909 return _hdlr_pass_tokens(@_);6991 return 1; 6910 6992 } else { 6911 return _hdlr_pass_tokens_else(@_);6993 return 0; 6912 6994 } 6913 6995 } … … 6923 7005 $active = 1 if !$active && $entry && $entry->ping_count; 6924 7006 if ($active) { 6925 return _hdlr_pass_tokens(@_);7007 return 1; 6926 7008 } else { 6927 return _hdlr_pass_tokens_else(@_);7009 return 0; 6928 7010 } 6929 7011 } … … 6933 7015 my $blog = $ctx->stash('blog'); 6934 7016 if ($blog->moderate_pings) { 6935 return _hdlr_pass_tokens(@_);7017 return 1; 6936 7018 } else { 6937 return _hdlr_pass_tokens_else(@_);7019 return 0; 6938 7020 } 6939 7021 } … … 6948 7030 $accepted = 0 if $entry && !$entry->allow_pings; 6949 7031 if ($a
