Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Session Integration: Code Help

edited September 2010 in Vanilla 2.0 - 2.8
I'm using a chat-bar called Skysa, and I needed help integrating it with Vanilla. The code (in a js file) is embedded in my theme. Here it is:

var _SKYAUTH = {
loginUrl:'http://mysite.com/entry',
memberNick:'{$GDN_User->Name}',
memberId:'{$GDN_User->UserID}',
profileUrl:'//need help here',
photoUrl:'{$GDN_User->Photo}',
};

It's seems like this should work fine, but it signs the user in with the name "{$GDN_User->Name}" and everything else has the same problem. Could someone PLEASE help me out here? It would be greatly appreciated.
Thanks in advance,
Matt.

EDIT: Just to be clear, "GDN_" is my table prefix in mySQL
«1

Comments

  • edited September 2010
    Nobody? I could really use some help here from anyone who understands this thing...
    I've tried adding parentheses, and making other odd changes but I can't seem to figure this out...
  • Can you post the whole file where that JS is embedded? Maybe to pastebin or something? Those variables just aren't being interpolated, it's probably a simple fix but I need to see more context.
  • edited September 2010
    Read 2 posts down.
  • ithcyithcy New
    edited September 2010
    you've got to either put that within <code></code> tags or upload it somewhere as plain text.
  • edited September 2010
    Haha just realized that, sorry. I had to leave really fast and didn't notice. Here:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-ca"> <head> {asset name="Head"} </head> <body id="{$BodyID}" class="{$BodyClass}"> <div class="Banner"> <div class="BannerWrapper"> <h1><a href="{link path="/"}"><span>{logo}</span></a></h1> <div class="Buttons"> <div class="UserOptions"> <div> {if $User.SignedIn} <a href="{link path="profile"}"> {$User.Name} {if $User.CountNotifications} <span>{$User.CountNotifications}</span> {/if} </a> <a href="{link path="messages/inbox"}">Inbox {if $User.CountUnreadConversations} <span>{$User.CountUnreadConversations}</span> {/if} </a> {if CheckPermission('Garden.Settings.Manage')} <a href="{link path="dashboard/settings"}">Dashboard</a> {/if} {/if} {link path="signinout"} {if !$User.SignedIn} <a href="{link path="register"}">Apply for Membership</a> {/if} </div> </div> <ul> <li class="Donate"><a href="mysite.com/hw/community/plugin/page/donate">Donate</a></li> <li class="Home"><a href="http://mysite.com/hw/community/profile/invitations">Invite Someone</a></li> <li class="Home"><a href="mysite.com">Home</a></li> </ul> </div> </div> </div> <div id="Frame"> <div id="Body"> <div id="Content">{asset name="Content"}</div> <div id="Panel">{asset name="Panel"}</div> </div> <div id="Foot"> <div> Copyright &copy; <a href="mysite.com/hw/community/profile/1/matt531320"><span>matt531320</span></a>, <a href="http://bit.ly/hwhelper"><span>Homework Helper</span></a>, and <a href="http://vanillaforums.org"><span>Vanilla Forums</span></a>. </div> </div> <script type="text/javascript" src="mysite.com/hw/community/chat/login.js" async="true"></script> <script type="text/javascript" src="http://static2.skysa.com?i=MYCODE" async="true"></script> </body> </html>
    That would be "default.master.tpl"
    A link to the full file here:
    http://bit.ly/aMLHBW
  • That JS isn't in that file... and your dyndns is down :)
  • Damn it ;)... My server crashed but it's back online. And the code is in there, it's in a separate file under the name of "login.js". See here:
    <script type="text/javascript" src="mysite.com/hw/community/chat/login.js" async="true"></script>
  • Would using Proxy Connect SSO do anything? (just asking)
  • OK.. sorry, that's not really what I meant. Since login.js is sourced from another file and not actually inline in the .tpl, it won't pass through the template engine, so those variables($GDN_User->Name etc.) will not be replaced with their real values.

    Try putting the actual source of login.js (it at least the part you pasted) inside a script block in the head of that template file and see if that does anything.
  • edited September 2010
    When I put it direclty in the theme I get the infamous "Bonk" error - culd u help me fix that? ;)

    Edit: gtg for the nite.
  • if you can paste the template with the added js as it is on your server, I'll look for problems.

    I don't really know the causes of the Bonk! error, the only time it happened to me (when i deleted cache/*) I had to rename conf/config.php, run setup again and copy the renamed file over the new one to get the forum running again. that may not be necessary in this case. it may just be a broken template.
  • Seen Bonk with missing smarty folder in the cache folder.
  • I doubt it's a broken template - It's a slightly edited version of the VanillaForums.org (old blue) 1.0.4 theme. And it's worked for me quite well (2 weeks) without any issues - until I decided to add a chat bar and the integration.
    Could we try doing this from a plugin? One that would just insert the bar code and the integration code on every page? How would I go about doing that? (I have no knowledge of writing plugins - but I could learn ;)
  • ...but you just edited the template and it went bonk. right?
  • edited September 2010
    ....When I moved the code from the JS to the head of the file. But when I remove that one block of code - the whole thing goes back to normal without any issues. I repeat though: Is it possible to try doing this from a plugin?
  • that's what i meant by 'broken template' - it breaks when you add that code :) that's why i wanted to see the template with the inline code.

    this could probably be done with a plugin, but if i can't see the entire code i can't tell if there's anything that needs to be in a theme instead.
  • Entire code - specify what you mean and I'll show it to you gladly ;). BTW - thx SO much for the help ;).
  • This is as far as I've gotten with the code for my plugin:
    <?php if (!defined('APPLICATION')) die(); $PluginInfo['Skysa'] = array ( 'Name' => 'Skysa', 'Description' => 'Adds Skysa with Intergration Code', 'Version' => '1.0', 'Author' => 'matt531320', 'AuthorEmail' => '', 'AuthorUrl' => '', ); class skysaPlugin extends Gdn_Plugin { public function Base_Render_Before(&$Sender) { $Sender->Head->AddString ( "<script type='text/javascript'> var _SKYAUTH = { loginUrl:'http://mysite.com/entry', memberNick:'$GDN_User->Name', memberId:'$GDN_User->UserID', profileUrl:'', photoUrl:'$GDN_User->Photo', }; </script> <script type='text/javascript' src='http://static2.skysa.com?i=6CCE1C4F-6F19-46E8-BABC-9F98386FC1D6' async='true'></script>" ); } public function Setup() { } }
    The bar shows up fine, but it keeps sending me to the login page of my site when I try to use it (basically meaning that it thinks the user isn't logged in). Could you help me with this?
  • where is this $GDN_User variable coming from?
Sign In or Register to comment.