Can someone tell me how to use $authToken in theme?

nonamer

Joined: 2007-03-28
Posts: 63
Posted: Sat, 2012-06-02 16:19

I know I can use these in the theme. {$child.pathComponent} {$child.summary} {$child.title} {$child.id} etc...

but how can I call authToken? I've tried {$authToken.session.id} and many other variations, but I'm just lost on it. Please help me. I sure hope floridave will see this thread. ;)

 
Dayo

Joined: 2005-11-04
Posts: 1642
Posted: Sat, 2012-06-02 16:21

You shouldn't need $authToken for theme issues.

What exactly are you trying to do? I.E., why do you think you need access to authToken in your theme?

--
dakanji.com

 
nonamer

Joined: 2007-03-28
Posts: 63
Posted: Sat, 2012-06-02 16:55

I'm trying to hard code something that results in database error with lightbox(fancybox) closes it causes errors. I originally built the theme for 2.2.3, and now upgrading to gallery 2.3.2 it causes a database error and I've come up with a solution to avoid the lightbox for deleting files. Its pretty complicated to explain, but if I could just get an answer on how to call authToken in the theme it will make it much easier.

here is an example of the link I'm trying to make.

<a href="main.php?g2_view=core.ItemAdmin&g2_subView=core.ItemDelete&g2_itemId={$theme.item.id}&g2_selectedId={$child.id}&g2_return=/gallery2/main.php&g2_anchorId={$child.id}" onclick="core_confirmDelete('main.php?g2_controller=core.ItemDeleteSingle&amp;g2_itemId={$child.id}&amp;g2_pageId={$theme.item.id}&amp;g2_authToken={$authToken.id}', '', '');return false" class="gbAdminLink gbLink-core_ItemAdmin-core_ItemDelete-album gbLink-core_ItemAdmin-core_ItemDelete"><img src="images/delete_off.png" width="180" height="51" onmouseover="javascript:this.src='images/delete_on.png';" onmouseout="javascript:this.src='images/delete_off.png';"/></a>

this link works, but when I try to use it I get...

Authentication Failure
Your change cannot be completed due to a loss of session data. Please try again. If it still doesn't work, try logging out and logging back in.

I know it will work once I get that authToken called right. HELP ME

 
Dayo

Joined: 2005-11-04
Posts: 1642
Posted: Sat, 2012-06-02 18:14

Sorry, but this looks like it may be an example of the XY Problem.

You can, after a bit of work in your theme.inc file, get to pass the authToken to your tpl file to add to a link but it seems like a strange thing to be trying to do and there is probably a more suitable solution to get to whatever the desired end result is.

Anyway, to get the authToken, in your theme.inc, you need somewhere in the processing flow in your theme.inc, put it into a variable that you can access in the tpl file.

In Theme.inc

$session = &$gallery->getSession();
$SomeVar = $session->getAuthToken();
... code to make $SomeVar available to the tpl file ... 

In TPL

... code to access $SomeVar ...
... code to add to link ...

--
dakanji.com

 
nonamer

Joined: 2007-03-28
Posts: 63
Posted: Sun, 2012-06-03 02:49

I found another way of solving it by getting rid of the authToken check altogether.

I removed this code from main.php


	/* Verify the genuineness of the request */
	if (!$controller->omitAuthTokenCheck()) {
	    $ret = GalleryController::assertIsGenuineRequest();
	    if ($ret) {
		return array($ret, null);
	    }
	}

Everything seems to be working great now. I know its there for security reasons, but I'm not sure its that important of a feature. Thanks for your help though.

 
Dayo

Joined: 2005-11-04
Posts: 1642
Posted: Sun, 2012-06-03 05:48

For anyone finding this after a Google search, do not in any instance whatsoever, remove the piece of code above from your main.php. Instead, describe exactly what it is you are trying to do so that the correct way to do this can be suggested.

--
dakanji.com