Show
Ignore:
Timestamp:
05/16/08 16:35:41 (19 months ago)
Author:
bchoate
Message:

Updates to fix signin widget. BugId:79717

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/release-38/default_templates/signin.mtml

    r2052 r2363  
    1 <script type="text/javascript" src="<$mt:Link template="<__trans phrase="JavaScript">"$>"></script> 
     1<mt:IfRegistrationAllowed> 
    22<div class="widget-sign-in widget"> 
    33    <h3 class="widget-header"><__trans phrase="Sign In"></h3> 
    4     <div class="widget-content"> 
     4    <div class="widget-content" id="signin-widget-content"></div> 
     5</div> 
    56<script type="text/javascript"> 
    67/* <![CDATA[ */ 
    7 var name, id, url, blog_ids; 
    8 if (typeof(commenter_name) != 'undefined') 
    9     name = commenter_name 
    10 if (typeof(commenter_id) != 'undefined') 
    11     id = commenter_id; 
    12 if (typeof(commenter_url) != 'undefined') 
    13     url = commenter_url; 
    14 if (typeof(commenter_blog_ids) != 'undefined') 
    15     blog_ids = commenter_blog_ids; 
    16  
    17 if (!name && !id) { 
    18     if ('<$mt:CGIHost exclude_port="1"$>' != '<$mt:BlogHost exclude_port="1"$>') { 
    19         document.write('<scr' + 'ipt src="<$mt:CGIPath$><$mt:CommentScript$>?__mode=cmtr_name_js">'); 
    20         document.write("</scr" + "ipt>"); 
     8function mtUpdateSignInWidget(u) { 
     9    var el = document.getElementById('signin-widget-content'); 
     10    if (!el) return; 
     11    if (u) { 
     12        if (u && u.is_authenticated) { 
     13            user = u; 
     14            mtSaveUser(); 
     15        } else { 
     16            // user really isn't logged in; so let's do this! 
     17            return mtSignIn(); 
     18        } 
    2119    } else { 
    22         name = getCookie('commenter_name'); 
    23         ids = getCookie('commenter_id').split(':'); 
    24         id = ids[0]; 
    25         blog_ids = ids[1]; 
    26         url = getCookie('commenter_url'); 
     20        u = mtGetUser(); 
    2721    } 
    28 } 
    29 showMessage(name, id, url); 
    30  
    31 function showMessage(commenter_name, commenter_id, commenter_url) { 
    32     static = location.href; 
    33     if ( commenter_name && 
    34          ( !commenter_id  
    35         || commenter_blog_ids.indexOf("'<$mt:BlogID$>'") > -1)) 
    36     { 
     22    if (u) { 
    3723        var url; 
    38         if (commenter_id) { 
    39             url = '<$mt:CGIPath$><$mt:CommentScript$>?__mode=edit_profile&commenter=' + commenter_id + '&blog_id=<$mt:BlogID$>'; 
    40             url += '&static=' + static; 
    41         } else if (commenter_url) { 
    42             url = commenter_url; 
     24        if (u.is_authenticated) { 
     25            url = '<$mt:CGIPath$><$mt:CommentScript$>?__mode=edit_profile&blog_id=<$mt:BlogID$>'; 
     26            url += '&static=' + escape( location.href ); 
     27        } else if (u.url) { 
     28            url = u.url; 
    4329        } else { 
    4430            url = null; 
    4531        } 
    4632        var content = '<__trans phrase="You are signed in as " escape="js">'; 
    47         if (url) { 
    48             content += '<a href="' + url + '">' + commenter_name + '</a>'; 
    49         } else { 
    50             content += commenter_name; 
    51         } 
    52         content += '.  (<a href="<$mt:RemoteSignOutLink no_static="1"$>&static=' + static + '"><__trans phrase="sign out" escape="js"></a>)'; 
    53         document.write(content); 
    54     } else if (commenter_name) { 
    55         document.write('<__trans phrase="You do not have permission to sign in to this blog." escape="js"> (<a href="<$mt:RemoteSignOutLink no_static="1"$>&static=' + static + '"><__trans phrase="sign out" escape="js"></a>)'); 
     33        if (url) 
     34            content += '<a href="' + url + '">' + u.name + '</a>'; 
     35        else 
     36            content += u.name; 
     37        content += '.  (<a href="javascript:void(0)" onclick="return mtSignOutOnClick()"><__trans phrase="sign out" escape="js"></a>)'; 
     38    } else if (u && u.is_banned) { 
     39        content = '<__trans phrase="You do not have permission to sign in to this blog." escape="js">'; 
    5640    } else { 
    57     <mt:IfRegistrationAllowed> 
    58         document.write('<a href="<$mt:CGIPath$><$mt:CommentScript$>?__mode=login&blog_id=<$mt:BlogID$>&static=' + static + '"><__trans phrase="Sign In" escape="js"></a>'); 
    59     </mt:IfRegistrationAllowed> 
     41        content = '<a href="javascript:void(0)" onclick="return mtSignInOnClick(\'signin-widget-content\')"><__trans phrase="Sign In" escape="js"></a>'; 
    6042    } 
     43    el.innerHTML = content; 
    6144} 
     45mtAttachEvent('usersignin', mtUpdateSignInWidget); 
     46mtUpdateSignInWidget(); 
    6247/* ]]> */ 
    6348</script> 
    64     </div> 
    65 </div> 
     49</mt:IfRegistrationAllowed>