Jump to content

gallery2 main.php user variable (check if user logged in)?


smile

Recommended Posts

Hi, I'm using gallery2 v2.3.

I want to use miniCMS module to be able to write articles in my gallery site. I have installed the miniCMS module and it works fine.

 

The problem I'm having is that front page is assigned a default article from miniCMS.

This frontpage article is shown by changing main.php file. By adding this code:

 

$rewritePath = (isset($_GET[GALLERY_FORM_VARIABLE_PREFIX . 'path']) ?
$_GET[GALLERY_FORM_VARIABLE_PREFIX . 'path'] : null);
$itemId = (int)(isset($_GET[GALLERY_FORM_VARIABLE_PREFIX . 'itemId']) ?
$_GET[GALLERY_FORM_VARIABLE_PREFIX . 'itemId'] : null);
$page = (int)(isset($_GET[GALLERY_FORM_VARIABLE_PREFIX . 'page']) ?
$_GET[GALLERY_FORM_VARIABLE_PREFIX . 'page'] : null);

if (empty($viewName) && !$gallery->isEmbedded() && empty($itemId) && empty($rewritePath) && empty($page)) {
$viewName = 'minicms.Show';
GalleryUtilities::putRequestVariable('view', $viewName);

 

While this code works fine as expected it disables the administrator from seeing root gallery, that means user created albums and permissions.

So I thought that I can use if statement to solve this.

 

if ( $user.isGuest == 1 ) {
$rewritePath = (isset($_GET[GALLERY_FORM_VARIABLE_PREFIX . 'path']) ?
$_GET[GALLERY_FORM_VARIABLE_PREFIX . 'path'] : null);
$itemId = (int)(isset($_GET[GALLERY_FORM_VARIABLE_PREFIX . 'itemId']) ?
$_GET[GALLERY_FORM_VARIABLE_PREFIX . 'itemId'] : null);
$page = (int)(isset($_GET[GALLERY_FORM_VARIABLE_PREFIX . 'page']) ?
$_GET[GALLERY_FORM_VARIABLE_PREFIX . 'page'] : null);

if (empty($viewName) && !$gallery->isEmbedded() && empty($itemId) && empty($rewritePath) && empty($page)) {
$viewName = 'minicms.Show';
GalleryUtilities::putRequestVariable('view', $viewName);
}
} else {
}

 

 

if ( $user.isGuest == 1 ) {

true part

}

} else {

}

 

If I reverse like this if ( $user.isGuest == 0 ) then the true part fires, if if ( $user.isGuest == 1 ) it does not. But the problem is if I login that makes no difference. So I think this means the problem is "$user.isGuest" the gallery2 can't understand this, the other part "== 0" or "== 1" just reverses the if-statement.

 

The only variable explanation I found is http://codex.gallery2.org/Gallery2:Themes:Reference:Variables

but it is for templates not php file.

 

debug shows

"Use of undefined constant isGuest - assumed 'isGuest' in"

 

 

 

 

 

I'm trying to exclude or include part of code into main.php depending if user is logged in or not.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.