root/branches/release-38/default_templates/javascript.mtml @ 2341

Revision 2341, 21.7 kB (checked in by bchoate, 19 months ago)

Added trans block for 'Signing in' phrase. BugId:79753

  • Property svn:keywords set to Id Revision
Line 
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. */
7function hideDocumentElement(id) { return mtHide(id) }
8function showDocumentElement(id) { return mtShow(id) }
9function individualArchivesOnLoad() { return mtEntryOnLoad() }
10function writeCommenterGreeting() { return mtShowGreeting() }
11function rememberMe(f) { return mtRememberMe(f) }
12function forgetMe(f) { return mtForgetMe(f) }
13</mt:Ignore>
14
15// The cookie name to use for storing the blog-side comment session cookie.
16var mtCookieName = "<$mt:UserSessionCookieName$>";
17var mtCookieDomain = "<$mt:UserSessionCookieDomain$>";
18var mtCookiePath = "<$mt:UserSessionCookiePath$>";
19var mtCookieTimeout = <$mt:UserSessionCookieTimeout$>;
20
21<mt:Ignore>
22/***
23 * Simple routine for showing a DOM element (applying a CSS display
24 * attribute of 'none').
25 */
26</mt:Ignore>
27function mtHide(id) {
28    var el = (typeof id == "string") ? document.getElementById(id) : id;
29    if (el) el.style.display = 'none';
30}
31
32<mt:Ignore>
33/***
34 * Simple routine for showing a DOM element (applying a CSS display
35 * attribute of 'block').
36 */
37</mt:Ignore>
38function mtShow(id) {
39    var el = (typeof id == "string") ? document.getElementById(id) : id;
40    if (el) el.style.display = 'block';
41}
42
43<mt:Ignore>
44/***
45 * Displays a relative date.
46 * 'ts' is a Date object, 'fds' is a string of the date which
47 * will be displayed if the given date is older than 1 week.
48 */
49</mt:Ignore>
50function mtRelativeDate(ts, fds) {
51    var now = new Date();
52    var ref = ts;
53    var delta = Math.floor((now.getTime() - ref.getTime()) / 1000);
54
55    var str;
56    if (delta < 60) {
57        str = '<__trans phrase="moments ago">';
58    } else if (delta <= 86400) {
59        // less than 1 day
60        var hours = Math.floor(delta / 3600);
61        var min = Math.floor((delta % 3600) / 60);
62        if (hours == 1)
63            str = '<__trans phrase="[quant,_1,hour,hours] ago" params="1">';
64        else if (hours > 1)
65            str = '<__trans phrase="[quant,_1,hour,hours] ago" params="2">'.replace(/2/, hours);
66        else if (min == 1)
67            str = '<__trans phrase="[quant,_1,minute,minutes] ago" params="1">';
68        else
69            str = '<__trans phrase="[quant,_1,minute,minutes] ago" params="2">'.replace(/2/, min);
70    } else if (delta <= 604800) {
71        // less than 1 week
72        var days = Math.floor(delta / 86400);
73        var hours = Math.floor((delta % 86400) / 3600);
74        if (days == 1)
75            str = '<__trans phrase="[quant,_1,day,days] ago" params="1">';
76        else if (days > 1)
77            str = '<__trans phrase="[quant,_1,day,days] ago" params="2">'.replace(/2/, days);
78        else if (hours == 1)
79            str = '<__trans phrase="[quant,_1,hour,hours] ago" params="1">';
80        else
81            str = '<__trans phrase="[quant,_1,hour,hours] ago" params="2">'.replace(/2/, hours);
82    }
83    return str ? str : fds;
84}
85
86<mt:Ignore>
87/***
88 * Used to display an edit link for the given entry.
89 */
90</mt:Ignore>
91function mtEditLink(entry_id, author_id) {
92    var u = mtGetUser();
93    if (! u) return;
94    if (! entry_id) return;
95    if (! author_id) return;
96    if (u.id != author_id) return;
97    var link = '<__trans phrase='<a href="[_1]">Edit</a>' params="<$mt:AdminScript$>?__mode=view&amp;_type=entry&amp;id=' + entry_id + '">';
98    document.write(link);
99}
100
101<mt:Ignore>
102/***
103 * Displays a captcha field for anonymous commenters.
104 */
105</mt:Ignore>
106var mtCaptchaVisible = false;
107function mtShowCaptcha() {
108    var u = mtGetUser();
109    if ( u && u.is_authenticated ) return;
110    if (mtCaptchaVisible) return;
111    var div = document.getElementById('comments-open-captcha');
112    if (div) {
113        div.innerHTML = '<$mt:CaptchaFields$>';
114        mtCaptchaVisible = true;
115    }
116}
117
118<mt:Ignore>
119/* user object
120    -- saved in user cookie --
121    u.name (display name)
122    u.url (link to home page)
123    u.email (for anonymous only)
124    u.userpic (url for commenter/author)
125    u.profile (link to profile)
126    u.is_trusted (boolean)
127    u.is_author (user has posting rights)
128    u.is_banned (banned status; neither post/comment perms)
129    u.can_post (has permission to post)
130    u.can_comment (has permission to comment)
131
132    -- status fields --
133    u.is_authenticated (boolean)
134    u.is_anonymous (user is anonymous)
135*/
136</mt:Ignore>
137
138var is_preview;
139var user;
140<mt:Ignore>
141/***
142 * Assigns a user object as the actively logged in user; also saves the
143 * user information in a browser cookie.
144 */
145</mt:Ignore>
146function mtSetUser(u) {
147    if (u) {
148        // persist this
149        user = u;
150        mtSaveUser();
151        // sync up user greeting
152        mtUserOnLoad();
153    }
154}
155
156<mt:Ignore>
157/***
158 * Simple function that escapes single quote characters for storing
159 * in a cookie.
160 */
161</mt:Ignore>
162function mtEscapeJS(s) {
163    s = s.replace(/'/g, "&apos;");
164    return s;
165}
166
167<mt:Ignore>
168/***
169 * Simple function that unescapes single quote characters that were
170 * stored in a cookie.
171 */
172</mt:Ignore>
173function mtUnescapeJS(s) {
174    s = s.replace(/&apos;/g, "'");
175    return s;
176}
177
178<mt:Ignore>
179/***
180 * Serializes a user object into a string, suitable for storing as a cookie.
181 */
182</mt:Ignore>
183function mtBakeUserCookie(u) {
184    var str = "";
185    if (u.name) str += "name:'" + mtEscapeJS(u.name) + "';";
186    if (u.url) str += "url:'" + mtEscapeJS(u.url) + "';";
187    if (u.email) str += "email:'" + mtEscapeJS(u.email) + "';";
188    if (u.is_authenticated) str += "is_authenticated:'1';";
189    if (u.profile) str += "profile:'" + mtEscapeJS(u.profile) + "';";
190    if (u.userpic) str += "userpic:'" + mtEscapeJS(u.userpic) + "';";
191    str += "is_trusted:'" + (u.is_trusted ? "1" : "0") + "';";
192    str += "is_author:'" + (u.is_author ? "1" : "0") + "';";
193    str += "is_banned:'" + (u.is_banned ? "1" : "0") + "';";
194    str += "can_post:'" + (u.can_post ? "1" : "0") + "';";
195    str += "can_comment:'" + (u.can_comment ? "1" : "0") + "';";
196    str = str.replace(/;$/, '');
197    return str;
198}
199
200<mt:Ignore>
201/***
202 * Unserializes a user cookie and returns a user object with the restored
203 * state.
204 */
205</mt:Ignore>
206function mtUnbakeUserCookie(s) {
207    if (!s) return;
208
209    var u = {};
210    var m;
211    while (m = s.match(/^((name|url|email|is_authenticated|profile|userpic|is_trusted|is_author|is_banned|can_post|can_comment):'([^']+?)';?)/)) {
212        s = s.substring(m[1].length);
213        if (m[2].match(/^(is|can)_/)) // boolean fields
214            u[m[2]] = m[3] == '1' ? true : false;
215        else
216            u[m[2]] = mtUnescapeJS(m[3]);
217    }
218    if (u.is_authenticated) {
219        u.is_anonymous = false;
220    } else {
221        u.is_anonymous = true;
222        u.can_post = false;
223        u.is_author = false;
224        u.is_banned = false;
225        u.is_trusted = false;
226    }
227    return u;
228}
229
230<mt:Ignore>
231/***
232 * Retrieves an object of the currently logged in user's state.
233 * If no user is logged in or cookied, this will return null.
234 */
235</mt:Ignore>
236function mtGetUser() {
237    if (!user) {
238        var cookie = mtGetCookie(mtCookieName);
239        if (!cookie) return;
240        user = mtUnbakeUserCookie(cookie);
241        if (! user) {
242            user = {};
243            user.is_anonymous = true;
244            user.can_post = false;
245            user.is_author = false;
246            user.is_banned = false;
247            user.is_trusted = false;
248        }
249    }
250    return user;
251}
252
253<mt:Ignore>
254/***
255 * Issues a request to the MT comment script to retrieve the currently
256 * logged-in user (if any).
257 */
258</mt:Ignore>
259function mtFetchUser(cb) {
260    if (!cb) cb = 'mtSetUser';
261    if ( ( cb == 'mtSetUser' ) && mtGetUser() ) {
262        var url = document.URL;
263        url = url.replace(/#.+$/, '');
264        url += '#comments-open';
265        location.href = url;
266    } else {
267        // we aren't using AJAX for this, since we may have to request
268        // from a different domain. JSONP to the rescue.
269        var script = document.createElement('script');
270        script.src = '<$mt:CGIPath$><$mt:CommentScript$>?__mode=session_js&blog_id=<$mt:BlogID$>&jsonp=' + cb;
271        (document.getElementsByTagName('head'))[0].appendChild(script);
272    }
273}
274
275<mt:Ignore>
276/***
277 * Called when the 'Remember me' checkbox is changed. If the checkbox
278 * is cleared, the cached user cookie is immediately cleared.
279 */
280</mt:Ignore>
281function mtRememberMeOnClick(b) {
282    if (!b.checked)
283        mtClearUser(b.form);
284    return true;
285}
286
287<mt:Ignore>
288/***
289 * Called when comment form is sent.
290 * Required parameter: Form DOM object of comment form.
291 * If form has a 'bakecookie' member, it will be used to signal
292 * storing the anonymous commenter information to a cookie.
293 * If form has a 'armor' member, it will be used to store
294 * a token that is checked by the comment script.
295 */
296</mt:Ignore>
297var mtRequestSubmitted = false;
298function mtCommentOnSubmit(f) {
299    if (!mtRequestSubmitted) {
300        mtRequestSubmitted = true;
301
302        if (f.armor)
303            f.armor.value = '<$mt:BlogSitePath encode_sha1="1"$>';
304        if (f.bakecookie && f.bakecookie.checked)
305            mtSaveUser(f);
306
307        // disable submit buttons
308        if (f.preview_button) f.preview_button.disabled = true;
309        if (f.post) f.post.disabled = true;
310        return true;
311    }
312    return false;
313}
314
315function mtUserOnLoad() {
316    var u = mtGetUser();
317
318    // if the user is authenticated, hide the 'anonymous' fields
319    // and any captcha input if already shown
320    if ( u && u.is_authenticated ) {
321        mtShow('comments-form');
322        mtHide('comments-open-data');
323        if (mtCaptchaVisible)
324            mtHide('comments-open-captcha');
325    } else {
326<mt:IfRegistrationRequired>
327        mtHide('comments-form');
328</mt:IfRegistrationRequired>
329    }
330    if ( u && u.is_banned ) {
331        mtHide('comments-form');
332    }
333
334    // if we're previewing a comment, make sure the captcha
335    // field is visible
336    if (is_preview) {
337        mtShowCaptcha();
338    } else {
339        // display greeting appropriate to the current user
340        mtShowGreeting();
341    }
342
343    // populate anonymous comment fields if user is cookied as anonymous
344    var cf = document['comments_form'];
345    if (cf) {
346        if (u && u.is_anonymous) {
347            if (u.email) cf.email.value = u.email;
348            if (u.name) cf.author.value = u.name;
349            if (u.url) cf.url.value = u.url;
350            if (cf.bakecookie)
351                cf.bakecookie.checked = u.name || u.email;
352        }
353        if (cf.post.disabled) {
354            cf.post.disabled = false;
355            cf.post.value = '<__trans phrase="Submit">';
356        }
357        if (cf.preview_button.disabled) {
358            cf.preview_button.disabled = false;
359            cf.preview_button.value = '<__trans phrase="Preview">';
360        }
361    }
362}
363
364<mt:Ignore>
365/***
366 * Called when an entry archive page is loaded.
367 * This routine controls which elements of the comment form are shown
368 * or hidden, depending on commenter type and blog configuration.
369 */
370</mt:Ignore>
371function mtEntryOnLoad() {
372<mt:Unless tag="IfPingsAccepted">
373    mtHide('trackbacks-info');
374</mt:Unless>
375
376<mt:Unless tag="IfCommentsAccepted">
377    mtHide('comments-open');
378</mt:Unless>
379
380    mtUserOnLoad();
381}
382
383<mt:Ignore>
384/***
385 * Handles the action of the "Sign in" link. First clears any existing
386 * user cookie, then directs to the MT comment script to sign the user in.
387 */
388</mt:Ignore>
389function mtSignIn() {
390    var doc_url = document.URL;
391    doc_url = doc_url.replace(/#.+/, '');
392    var url = '<$mt:SignInLink$>';
393    url += '&return_url=' + encodeURIComponent(doc_url);
394    mtClearUser();
395    location.href = url;
396}
397
398function mtSignInOnClick() {
399    // display throbber
400    var el = document.getElementById('comment-greeting');
401    if (!el)  // legacy MT 4.x element id
402        el = document.getElementById('comment-form-external-auth');
403    if (el)
404        el.innerHTML = '<__trans phrase="Signing in..."> <img src="<$mt:StaticWebPath$>images/indicator.white.gif" height="16" width="16" alt="" />';
405
406    mtClearUser(); // clear any 'anonymous' user cookie to allow sign in
407    mtFetchUser('mtSetUserOrLogin');
408    return false;
409}
410
411function mtSetUserOrLogin(u) {
412    if (u && u.is_authenticated) {
413        mtSetUser(u);
414    } else {
415        // user really isn't logged in; so let's do this!
416        mtSignIn();
417    }
418}
419
420<mt:Ignore>
421/***
422 * Handles the action of the "Sign out" link. First clears any existing
423 * user cookie, then direts to the MT comment script to sign the user out.
424 */
425</mt:Ignore>
426function mtSignOut(entry_id) {
427    var url = '<$mt:SignOutLink$>&entry_id=' + entry_id;
428    mtClearUser();
429    location.href = url;
430}
431
432<mt:Ignore>
433/***
434 * Handles the display of the greeting message, depending on what kind of
435 * user is logged in and blog comment policy.
436 */
437</mt:Ignore>
438function mtShowGreeting() {
439<mt:IfRegistrationAllowed>
440    var reg_reqd = <mt:IfRegistrationRequired>true<mt:Else>false</mt:IfRegistrationRequired>;
441
442    var cf = document.comments_form;
443    if (!cf) return;
444
445    var el = document.getElementById('comment-greeting');
446    if (!el)  // legacy MT 4.x element id
447        el = document.getElementById('comment-form-external-auth');
448    if (!el) return;
449
450    var eid = cf.entry_id;
451    var entry_id;
452    if (eid) entry_id = eid.value;
453
454    var phrase;
455    var u = mtGetUser();
456
457    if ( u && u.is_authenticated ) {
458        if ( u.is_banned ) {
459            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 + ');return false;">%%</a>">';
460        } else {
461            var user_link;
462            if ( u.is_author ) {
463                user_link = '<a href="<$mt:CGIPath$><$mt:CommentScript$>?__mode=edit_profile&blog_id=<$mt:BlogID$>';
464                if (entry_id)
465                    user_link += '&entry_id=' + entry_id;
466                user_link += '">' + u.name + '</a>';
467            } else {
468                // registered user, but not a user with posting rights
469                if (u.url)
470                    user_link = '<a href="' + u.url + '">' + u.name + '</a>';
471                else
472                    user_link = u.name;
473            }
474            // TBD: supplement phrase with userpic if one is available.
475            phrase = '<__trans phrase="Thanks for signing in, [_1]. ([_2]sign out[_3])" params="' + user_link + '%%<a href="javascript:void(0)" onclick="mtSignOut(' + entry_id + ');return false;">%%</a>">';
476        }
477    } else {
478        if (reg_reqd) {
479            phrase = '<__trans phrase="[_1]Sign in[_2] to comment." params="<a href="javascript:void(0)" onclick="return mtSignInOnClick()">%%</a>">';
480        } else {
481            phrase = '<__trans phrase="[_1]Sign in[_2] to comment, or comment anonymously." params="<a href="javascript:void(0)" onclick="return mtSignInOnClick()">%%</a>">';
482        }
483    }
484    el.innerHTML = phrase;
485<mt:Else>
486    mtShowCaptcha();
487</mt:IfRegistrationAllowed>
488}
489
490<mt:Ignore>
491/***
492 * Handles the action of the 'Reply' links.
493 */
494</mt:Ignore>
495function mtReplyCommentOnClick(parent_id, author) {
496    mtShow('comment-form-reply');
497
498    var checkbox = document.getElementById('comment-reply');
499    var label = document.getElementById('comment-reply-label');
500    var text = document.getElementById('comment-text');
501
502    // Populate label with new values
503    var reply_text = '<__trans phrase="Replying to <a href="[_1]" onclick="[_2]">comment from [_3]</a>" params="#comment-'+ parent_id +'%%location.href=this.href; return false%%'+ author +'">';
504    label.innerHTML = reply_text;
505
506    checkbox.value = parent_id;
507    checkbox.checked = true;
508    text.focus();
509
510    mtSetCommentParentID();
511}
512
513<mt:Ignore>
514/***
515 * Sets the parent comment ID when replying to a comment.
516 */
517</mt:Ignore>
518function mtSetCommentParentID() {
519    var checkbox = document.getElementById('comment-reply');
520    var parent_id_field = document.getElementById('comment-parent-id');
521    if (!checkbox || !parent_id_field) return;
522
523    var pid = 0;
524    if (checkbox.checked == true)
525        pid = checkbox.value;
526    parent_id_field.value = pid;
527}
528
529<mt:Ignore>
530/***
531 * Persists a copy of the current user cookie into the browser cookie stash.
532 */
533</mt:Ignore>
534function mtSaveUser(f) {
535    // We can't reliably store the user cookie during a preview.
536    if (is_preview) return;
537
538    var u = mtGetUser();
539
540    if (f && (!u || u.is_anonymous)) {
541        if ( !u ) {
542            u = {};
543            u.is_authenticated = false;
544            u.can_comment = true;
545            u.is_author = false;
546            u.is_banned = false;
547            u.is_anonymous = true;
548            u.is_trusted = false;
549        }
550        if (f.author != undefined) u.name = f.author.value;
551        if (f.email != undefined) u.email = f.email.value;
552        if (f.url != undefined) u.url = f.url.value;
553    }
554
555    if (!u) return;
556
557    var cache_period = mtCookieTimeout * 1000;
558
559    // cache anonymous user info for a long period if the
560    // user has requested to be remembered
561    if (u.is_anonymous && f && f.bakecookie && f.bakecookie.checked)
562        cache_period = 365 * 24 * 60 * 60 * 1000;
563
564    var now = new Date();
565    mtFixDate(now);
566    now.setTime(now.getTime() + cache_period);
567
568    var cmtcookie = mtBakeUserCookie(u);
569    mtSetCookie(mtCookieName, cmtcookie, now, mtCookiePath, mtCookieDomain,
570        location.protocol == 'https:');
571}
572
573<mt:Ignore>
574/***
575 * Clears the blog-side user cookie.
576 */
577</mt:Ignore>
578function mtClearUser() {
579    mtDeleteCookie(mtCookieName, mtCookiePath, mtCookieDomain,
580        location.protocol == 'https:');
581}
582
583<mt:Ignore>
584/***
585 * Sets a browser cookie.
586 */
587</mt:Ignore>
588function mtSetCookie(name, value, expires, path, domain, secure) {
589    var curCookie = name + "=" + escape(value) +
590        (expires ? "; expires=" + expires.toGMTString() : "") +
591        (path ? "; path=" + path : "") +
592        (domain ? "; domain=" + domain : "") +
593        (secure ? "; secure" : "");
594    document.cookie = curCookie;
595}
596
597<mt:Ignore>
598/***
599 * Retrieves a browser cookie.
600 */
601</mt:Ignore>
602function mtGetCookie(name) {
603    var prefix = name + '=';
604    var c = document.cookie;
605    var cookieStartIndex = c.indexOf(prefix);
606    if (cookieStartIndex == -1)
607        return '';
608    var cookieEndIndex = c.indexOf(";", cookieStartIndex + prefix.length);
609    if (cookieEndIndex == -1)
610        cookieEndIndex = c.length;
611    return unescape(c.substring(cookieStartIndex + prefix.length, cookieEndIndex));
612}
613
614<mt:Ignore>
615/***
616 * Deletes a browser cookie.
617 */
618</mt:Ignore>
619function mtDeleteCookie(name, path, domain, secure) {
620    if (mtGetCookie(name))
621        document.cookie = name + "=" +
622            (path ? "; path=" + path : "") +
623            (domain ? "; domain=" + domain : "") +
624            (secure ? "; secure" : "") +
625            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
626}
627
628function mtFixDate(date) {
629    var skew = (new Date(0)).getTime();
630    if (skew > 0)
631        date.setTime(date.getTime() - skew);
632}
633
634<mt:Ignore>
635/***
636 * Returns a XMLHttpRequest object (for Ajax operations).
637 */
638</mt:Ignore>
639function mtGetXmlHttp() {
640    if ( !window.XMLHttpRequest ) {
641        window.XMLHttpRequest = function() {
642            var types = [
643                "Microsoft.XMLHTTP",
644                "MSXML2.XMLHTTP.5.0",
645                "MSXML2.XMLHTTP.4.0",
646                "MSXML2.XMLHTTP.3.0",
647                "MSXML2.XMLHTTP"
648            ];
649
650            for ( var i = 0; i < types.length; i++ ) {
651                try {
652                    return new ActiveXObject( types[ i ] );
653                } catch( e ) {}
654            }
655
656            return undefined;
657        };
658    }
659    if ( window.XMLHttpRequest )
660        return new XMLHttpRequest();
661}
662
663// BEGIN: fast browser onload init
664// Modifications by David Davis, DWD
665// Dean Edwards/Matthias Miller/John Resig
666// http://dean.edwards.name/weblog/2006/06/again/?full#comment5338
667
668function mtInit() {
669    // quit if this function has already been called
670    if (arguments.callee.done) return;
671
672    // flag this function so we don't do the same thing twice
673    arguments.callee.done = true;
674
675    // kill the timer
676    // DWD - check against window
677    if ( window._timer ) clearInterval(window._timer);
678
679    // DWD - fire the window onload now, and replace it
680    if ( window.onload && ( window.onload !== window.mtInit ) ) {
681        window.onload();
682        window.onload = function() {};
683    }
684}
685
686/* for Mozilla/Opera9 */
687if (document.addEventListener) {
688    document.addEventListener("DOMContentLoaded", mtInit, false);
689}
690
691/* for Internet Explorer */
692/*@cc_on @*/
693/*@if (@_win32)
694document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
695var script = document.getElementById("__ie_onload");
696script.onreadystatechange = function() {
697    if (this.readyState == "complete") {
698        mtInit(); // call the onload handler
699    }
700};
701/*@end @*/
702
703/* for Safari */
704if (/WebKit/i.test(navigator.userAgent)) { // sniff
705    _timer = setInterval(function() {
706        if (/loaded|complete/.test(document.readyState)) {
707            mtInit(); // call the onload handler
708        }
709    }, 10);
710}
711
712/* for other browsers */
713window.onload = mtInit;
714
715// END: fast browser onload init
716
717<mt:IfRegistrationAllowed>
718/***
719 * If request contains a '#_login' or '#_logout' hash, use this to
720 * also delete the blog-side user cookie, since we're coming back from
721 * a login, logout or edit profile operation.
722 */
723var clearCookie = ( window.location.hash && window.location.hash.match( /^#_log(in|out)/ ) ) ? true : false;
724if (clearCookie) {
725    // clear any logged in state
726    mtClearUser();
727    if (RegExp.$1 == 'in')
728        mtFetchUser();
729} else {
730    <mt:Ignore>
731    /***
732     * Uncondition this call to fetch the current user state (if available)
733     * from MT upon page load if no user cookie is already present.
734     * This is okay if you have a private install, such as an Intranet;
735     * not recommended for public web sites!
736     */
737    </mt:Ignore>
738    if ( is_preview )
739        mtFetchUser();
740}
741</mt:IfRegistrationAllowed>
Note: See TracBrowser for help on using the browser.