Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: Add Menu Button to Appear Only When Logged In  (Read 7930 times)

0 Members and 1 Guest are viewing this topic.

scohen125

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 100
    • Retina Gallery
Add Menu Button to Appear Only When Logged In
« on: November 04, 2010, 12:05:06 am »

I added the menu button "create new album" to my menu.  I would like it to only appear when people are logged in.  I am using the theme curves and I added it to the 'theme.php' file as follows along with an 'about us' link:

Code: [Select]
<!-- BEGIN about us -->

                <li>

   <a href="aboutus.php" title="About Us" class="firstlevel"><span class="firstlevel">  About Us</span></a>

                </li>

<!-- END about us -->



<!-- BEGIN add_album -->

                <li>

   <a href="albmgr.php" title="Create New Album" class="firstlevel"><span class="firstlevel">  Create Album</span></a>

                </li>

<!-- END add_album -->


<!-- BEGIN upload_pic -->

                <li>

                   <a href="{UPL_PIC_TGT}" title="{UPL_PIC_TITLE}" class="firstlevel"><span class="firstlevel">{UPL_PIC_ICO}{UPL_PIC_LNK}</span></a>

                </li>

<!-- END upload_pic -->
Is there a way to have the 'create new album' only appear for people who are logged in?  I found a thread that sounded like it was about to explain that and then the thread just stopped, like it was truncated.

my website is: www.retinagallery.com

Thank you very much.
« Last Edit: November 04, 2010, 12:15:34 am by Jeff Bailey »
Logged

Joe Carver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1545
  • aka 'i-imagine'
    • Home Page
Re: Add Menu Button to Appear Only When Logged In
« Reply #1 on: November 04, 2010, 01:45:53 am »

Is there a way to have the 'create new album' only appear for people who are logged in?  

Yes, Coppermine does that via the Groups manager page.
You have gone too far, too fast without reading your document set.

Try adjusting the settings there to see if the result suits your needs. You should also use a clean copy of a theme, without your mods. when you make the changes.

scohen125

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 100
    • Retina Gallery
Re: Add Menu Button to Appear Only When Logged In
« Reply #2 on: November 04, 2010, 02:00:12 am »

I have used the group manager to set permission for various users and also to allow for personal galleries.  I don't see anything in the group manager panel that allows me to add menu buttons visible only to logged in users (registered users and admin).  I have a backup of my theme file that is unmodified, so I can upload that to the site if you will help me with using the group manager to add the button I'd like to add on the top menu.

I appreciate the help.
Logged

scohen125

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 100
    • Retina Gallery
Re: Add Menu Button to Appear Only When Logged In
« Reply #3 on: November 04, 2010, 02:25:43 am »

In PHP I often use the if(isset($_SESSION(variable))){echo 'button';} to show things only when users are logged in.

Are there session variables that are set when users are logged into a coppermine site that I could use to guide the display of the code?  It would have to be a variable that is different for registered users and admin from non-registered users.

I appreciate any help!
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Add Menu Button to Appear Only When Logged In
« Reply #4 on: November 04, 2010, 10:41:59 am »

I don't see anything in the group manager panel that allows me to add menu buttons visible only to logged in users (registered users and admin).
Coppermine already has the button you added. It will be removed for users who aren't allowed to create new albums.

Try to replace
Code: [Select]
<!-- BEGIN add_album -->with
Code: [Select]
<!-- BEGIN albmgr -->
and

Code: [Select]
<!-- END add_album -->with
Code: [Select]
<!-- END albmgr -->



Are there session variables that are set when users are logged into a coppermine site that I could use to guide the display of the code?
The constant USER_ID is '0' for guests and > 0 for visitors who are currently logged in.
Logged

scohen125

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 100
    • Retina Gallery
Re: Add Menu Button to Appear Only When Logged In
« Reply #5 on: November 04, 2010, 02:25:35 pm »

Still not working:

I wanted to make the 'create album' option on the top menu because ... one of the only things I do not like about the coppermine package is that you need to create an album BEFORE uploading files but the option to create an album does not show up on the 'upload file' page.  So when a user goes to upload a file, they can only choose an existing album.  My new users have all asked about this.  If there is a way to make the option to 'create an album' appear on the 'upload file' page that would be great.  The option 'choose an album' is present on the page but not 'create an album' or 'create a new album'.  I know that this is not Facebook, but Facebook is what everyone is getting used to.  On Facebook, when you go to upload files, it asks you to create an album.

So, I would love it if there is a way to make the 'create an album' or 'create a new album' appear on the upload file page. 

Second to that, I wanted to put the 'create album' button on the top menu.  I tried the suggestions.  A replaced the code with the 'albmgr' code but that did not remove the button for non-logged in people.  I tried creating an if statement with php and I cannot get it to work, I think because of the surrounding code or because of how coppermine works with its files.  I tried if(user_id > 0) { the code }, if(constant("user_id) > 0){the code},  I tried both of those with {echo 'the code';} and I tried putting <?php before and ?> after my code block.  They all just showed the statements in the menu bar, but did not execute them.

I really appreciate the help and hope that this isn't too wordy.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Add Menu Button to Appear Only When Logged In
« Reply #6 on: November 04, 2010, 02:36:23 pm »

As you only posted a snippet it's very hard to decide what's the easiest approach. The constant's name is USER_ID (upper case) and you cannot use PHP where I guess you try to use it. Instead you have to perform the check before the variable definition of that code
Code: [Select]
<!-- BEGIN about us -->

                <li>

   <a href="aboutus.php" title="About Us" class="firstlevel"><span class="firstlevel">  About Us</span></a>

                </li>

<!-- END about us -->


<!-- BEGIN add_album -->

                <li>

   <a href="albmgr.php" title="Create New Album" class="firstlevel"><span class="firstlevel">  Create Album</span></a>

                </li>

<!-- END add_album -->


<!-- BEGIN upload_pic -->

                <li>

                   <a href="{UPL_PIC_TGT}" title="{UPL_PIC_TITLE}" class="firstlevel"><span class="firstlevel">{UPL_PIC_ICO}{UPL_PIC_LNK}</span></a>

                </li>

<!-- END upload_pic -->

I.e. change it to something like
Code: [Select]
if (USER_ID) {
    $add_album = '<!-- BEGIN add_album -->

                <li>

   <a href="albmgr.php" title="Create New Album" class="firstlevel"><span class="firstlevel">  Create Album</span></a>

                </li>

<!-- END add_album -->';
}


<!-- BEGIN about us -->

                <li>

   <a href="aboutus.php" title="About Us" class="firstlevel"><span class="firstlevel">  About Us</span></a>

                </li>

<!-- END about us -->


$add_album


<!-- BEGIN upload_pic -->

                <li>

                   <a href="{UPL_PIC_TGT}" title="{UPL_PIC_TITLE}" class="firstlevel"><span class="firstlevel">{UPL_PIC_ICO}{UPL_PIC_LNK}</span></a>

                </li>

<!-- END upload_pic -->



I would love it if there is a way to make the 'create an album' or 'create a new album' appear on the upload file page.  
A button that links to the album manager should be a quite easy change.
« Last Edit: November 05, 2010, 01:36:07 pm by Αndré »
Logged

scohen125

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 100
    • Retina Gallery
Re: Add Menu Button to Appear Only When Logged In
« Reply #7 on: November 04, 2010, 04:03:44 pm »

I tried putting this code in.  I'm sure I'm doing it wrong.  Here is the link to my homepage:
www.retinagallery.com
I renamed theme.php to theme.txt so I could attach it:

Here is some of the code, I could not embed all of it because it is too big for the board.

Code: [Select]
$template_sys_menu_button = $template_sub_menu_button = <<<EOT

<!-- BEGIN {BLOCK_ID} -->

    <li>

        <a href="{HREF_TGT}" title="{HREF_TITLE}" class="firstlevel"><span class="firstlevel">{HREF_LNK}</span></a>

    </li>

<!-- END {BLOCK_ID} -->

EOT;



// HTML template for sys menu

$template_sys_menu = <<<EOT



<ul class="dropmenu">
<!-- BEGIN home -->

                <li>

                    <a href="{HOME_TGT}" title="{HOME_TITLE}" class="firstlevel"><span class="firstlevel">{HOME_ICO}{HOME_LNK}</span></a>

                    <ul>

                    <!-- BEGIN contact -->

                                <li>

                                    <a href="{CONTACT_TGT}" title="{CONTACT_TITLE}"><span>{CONTACT_ICO}{CONTACT_LNK}</span></a>

                                </li>

                    <!-- END contact -->

                    <!-- BEGIN sidebar -->

                                    <li>

                                        <a href="{SIDEBAR_TGT}" title="{SIDEBAR_TITLE}"><span>{SIDEBAR_ICO}{SIDEBAR_LNK}</span></a>

                                    </li>

                    <!-- END sidebar -->
                    <!-- BEGIN my_profile -->
                                    <li>
                                        <a href="{MY_PROF_TGT}" title="{MY_PROF_LNK}"><span>{MY_PROF_ICO}{MY_PROF_LNK}</span></a>
                                    </li>
                    <!-- END my_profile -->

                    </ul>

                </li>

<!-- BEGIN allow_memberlist -->

                                    <!--

                                    <li>

                                        <a href="{MEMBERLIST_TGT}" title="{MEMBERLIST_TITLE}"><span>{MEMBERLIST_ICO}{MEMBERLIST_LNK}</span></a>

                                    </li>

                                    -->

<!-- END allow_memberlist -->



<!-- END home -->

<!-- BEGIN my_gallery -->

                <li>

                    <a href="{MY_GAL_TGT}" title="{MY_GAL_TITLE}" class="firstlevel"><span class="firstlevel">{MY_GAL_ICO}{MY_GAL_LNK}</span></a>

                    <ul>

                    <!-- BEGIN allow_memberlist -->

                                    <li>

                                        <a href="{MEMBERLIST_TGT}" title="{MEMBERLIST_TITLE}"><span>{MEMBERLIST_ICO}{MEMBERLIST_LNK}</span></a>

                                    </li>

                    <!-- END allow_memberlist -->

                    <!-- BEGIN enter_admin_mode -->

                                    <li>

                                    <a href="{ADM_MODE_TGT}" title="{ADM_MODE_TITLE}"><span>{ADM_MODE_ICO}{ADM_MODE_LNK}</span></a>

                                    </li>

                    <!-- END enter_admin_mode -->

                    <!-- BEGIN leave_admin_mode -->

                                    <li>

                                        <a href="{USR_MODE_TGT}" title="{USR_MODE_TITLE}"><span>{USR_MODE_ICO}{USR_MODE_LNK}</span></a>

                                    </li>

                    <!-- END leave_admin_mode -->

                    </ul>

                </li>

<!-- END my_gallery -->

<!-- BEGIN about us -->

                <li>

   <a href="aboutus.php" title="About Us" class="firstlevel"><span class="firstlevel">  About Us</span></a>

                </li>

<!-- END about us -->

if (USER_ID) {
    $add_album = '<!-- BEGIN add_album -->

                <li>

   <a href="albmgr.php" title="Create New Album" class="firstlevel"><span class="firstlevel">  Create Album</span></a>

                </li>

<!-- END add_album -->';
}





<!-- BEGIN upload_pic -->

                <li>

                   <a href="{UPL_PIC_TGT}" title="{UPL_PIC_TITLE}" class="firstlevel"><span class="firstlevel">{UPL_PIC_ICO}{UPL_PIC_LNK}</span></a>

                </li>

<!-- END upload_pic -->

<!-- BEGIN register -->

                <li>

                    <a href="{REGISTER_TGT}" title="{REGISTER_TITLE}" class="firstlevel"><span class="firstlevel">{REGISTER_ICO}{REGISTER_LNK}</span></a>

                </li>

<!-- END register -->

<!-- BEGIN login -->

                <li>

                    <a href="{LOGIN_TGT}" title="{LOGIN_LNK}" class="firstlevel"><span class="firstlevel">{LOGIN_ICO}{LOGIN_LNK}</span></a>

                </li>

<!-- END login -->

<!-- BEGIN logout -->

                <li>

                    <a href="{LOGOUT_TGT}" title="{LOGOUT_LNK}" class="firstlevel"><span class="firstlevel">{LOGOUT_ICO}{LOGOUT_LNK}</span></a>

                </li>

<!-- END logout -->

</ul>



EOT;





// HTML template for sub menu
if ($CONFIG['browse_by_date'] != 0) {
    $browsebydatebutton = <<< EOT
                        <li>
                            <a href="{BROWSEBYDATE_TGT}" title="{BROWSEBYDATE_TITLE}" rel="nofollow" class="greybox"><span>{BROWSEBYDATE_ICO}{BROWSEBYDATE_LNK}</span></a>
                        </li>
EOT;
} else {
    $browsebydatebutton = '';
}

$template_sub_menu = <<<EOT



<ul class="dropmenu">

<!-- BEGIN custom_link -->

                <li>

                    <a href="{CUSTOM_LNK_TGT}" title="{CUSTOM_LNK_TITLE}" class="firstlevel"><span class="firstlevel">{CUSTOM_LNK_LNK}</span></a>

                </li>

<!-- END custom_link -->

<!-- BEGIN album_list -->

                <li>

                    <a href="{ALB_LIST_TGT}" title="{ALB_LIST_TITLE}" class="firstlevel"><span class="firstlevel">{ALB_LIST_ICO}{ALB_LIST_LNK}</span></a>

                    <ul>

<!-- BEGIN lastup -->

                        <li>

                            <a href="{LASTUP_TGT}" title="{LASTUP_LNK}" rel="nofollow"><span>{LASTUP_ICO}{LASTUP_LNK}</span></a>

                        </li>

<!-- END lastup -->

<!-- BEGIN lastcom -->

                        <li>

                            <a href="{LASTCOM_TGT}" title="{LASTCOM_LNK}" rel="nofollow" ><span>{LASTCOM_ICO}{LASTCOM_LNK}</span></a>

                        </li>

<!-- END lastcom -->

<!-- BEGIN topn -->

                        <li>

                            <a href="{TOPN_TGT}" title="{TOPN_LNK}" rel="nofollow"><span>{TOPN_ICO}{TOPN_LNK}</span></a>

                        </li>

<!-- END topn -->

<!-- BEGIN toprated -->

                        <li>

                            <a href="{TOPRATED_TGT}" title="{TOPRATED_LNK}" rel="nofollow"><span>{TOPRATED_ICO}{TOPRATED_LNK}</span></a>

                        </li>

<!-- END toprated -->

<!-- BEGIN favpics -->

                        <li>

                            <a href="{FAV_TGT}" title="{FAV_LNK}" rel="nofollow"><span>{FAV_ICO}{FAV_LNK}</span></a>

                        </li>

<!-- END favpics -->

<!-- BEGIN browse_by_date -->

                        $browsebydatebutton

<!-- END browse_by_date -->

                    </ul>

                </li>

<!-- END album_list -->

<!-- BEGIN search -->

                <li>

                    <a href="{SEARCH_TGT}" title="{SEARCH_LNK}" class="firstlevel"><span class="firstlevel">{SEARCH_ICO}{SEARCH_LNK}</span></a>

                </li>

<!-- END search -->

<!-- BEGIN FAQ -->

                <li>

   <a href="faq.php" title="Frequently Asked Questions - Help" class="firstlevel"><span class="firstlevel">  FAQ</span></a>

                </li>

<!-- END FAQ -->



</ul>

                

EOT;



« Last Edit: November 05, 2010, 02:47:27 am by Jeff Bailey »
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Add Menu Button to Appear Only When Logged In
« Reply #8 on: November 05, 2010, 01:38:30 pm »

Try the attached file. Next time you ask for support please don't post just snippets.


PS: Thanks Jeff for adding the code tags :)
Logged

scohen125

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 100
    • Retina Gallery
Re: Add Menu Button to Appear Only When Logged In
« Reply #9 on: November 05, 2010, 04:11:46 pm »

Andre-
Thank you for the solution.  It works perfectly.  You are amazing. Can you look at my other posts on this board?  I am trying to adjust a few other things on the site.  Some of these may be more appropriate for a paid developer.  If you think that is the case, is there a way I can contact a specific developer?

Thank you very very much again.

Steve
Logged

Jeff Bailey

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1322
  • Fishing relaxes me.
    • Bailey Family Co.
Re: Add Menu Button to Appear Only When Logged In
« Reply #10 on: November 05, 2010, 07:13:18 pm »

You can post requests on the Freelancers board after reading => http://forum.coppermine-gallery.net/index.php/topic,8170.0.html

Though the other thread that I see you have open
http://forum.coppermine-gallery.net/index.php/topic,67900.msg336777.html#msg336777
shouldn't be that difficult to get done. Just involves editing your theme.php

ot: No problem, Αndré


Logged
Thinking is the hardest work there is, which is probably the reason why so few engage in it. - Henry Ford
Pages: [1]   Go Up
 

Page created in 0.029 seconds with 21 queries.