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: [SOLVED] Selective default album view, based on Group  (Read 4326 times)

0 Members and 1 Guest are viewing this topic.

shaddy

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 23
[SOLVED] Selective default album view, based on Group
« on: August 13, 2004, 06:22:39 am »

I received help making the default view for making new albums Me Only
http://forum.coppermine-gallery.net/index.php?topic=8525.0
and I took away their option to change who the album can be viewed by.

I'd like to be a bit more selective now.  I want it to stay the same for the default Registered User, but I now have a group designated as "Friends".  I'd like their default album to be "Members of the 'Friends' Group".  If there's too much to it, I can, as admin, go in and do it manually ('cause that's kinda what I get for asking to have control over what group gets to see what), but I thought it would be nice to have it done automatically.  

I'm trying to maintain controll over what the groups get to see, and not allow them to overlap.  But made it difficult on myself in the process.  This would simplify things, and allow other friends to immediately see it, instead of waiting for me to change it.  Plus it would still keep them from setting it to "Everyone can see", and having embarrasing alcohol related pics shown to the world.

Thanks
Shaddy
« Last Edit: August 20, 2004, 03:34:10 am by shaddy »
Logged

shaddy

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 23
Re: Selective default album view, based on Group
« Reply #1 on: August 17, 2004, 03:04:08 pm »

It seems like this might be the place to do it, but I don't know PHP so well.
in delete.php, I have

Code: [Select]
$query = "INSERT INTO {$CONFIG['TABLE_ALBUMS']} (category, title, uploads, pos, visibility) VALUES ('$category', '" . addslashes($op['album_nm']) . "', 'NO',  '{$op['album_sort']}', '" . (FIRST_USER_CAT + USER_ID) . "')";
Would I be able to have something like

If user.group = Friend then
     $query = "INSERT INTO {$CONFIG['TABLE_ALBUMS']} (category, title, uploads, pos, visibility) VALUES ('$category', '" . addslashes($op['album_nm']) . "', 'NO',  '{$op['album_sort']}', '" . (Something here Designating Friend Album) . "')";
     else
        $query = "INSERT INTO {$CONFIG['TABLE_ALBUMS']} (category, title, uploads, pos, visibility) VALUES ('$category', '" . addslashes($op['album_nm']) . "', 'NO',  '{$op['album_sort']}', '" . (FIRST_USER_CAT + USER_ID) . "')";


I've been trying to puzzle it out, but to no avail.  Am I even in te right area?  I obviously don't know the right commands or variables to use, but i didn't want to spend more time piecing things together looking through the other files if I'm not even in the right place, and have it not do what I want anyway.  Any hints would be appreciated.  
Thanks.
Logged

shaddy

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 23
Re: Selective default album view, based on Group
« Reply #2 on: August 19, 2004, 08:51:47 pm »

OK, I'm a tad closer, but it's still not working right...
I used PHPMyAdmin and figured out that my "Friends" group number is 5.  But I can't seem to find the variable where the group number is placed.  USER_GROUP always returns 0, so I think that's not the right thing to use (although it seems like it should be), I just don't know where to look to find the right one.


Code: [Select]
   if (USER_GROUP == 5) {
                    echo "<tr><td colspan=\"6\" class=\"tableb\">" . sprintf($lang_delete_php['create_alb'], $op['album_nm']) . "</td></tr>\n";
                    $query = "INSERT INTO {$CONFIG['TABLE_ALBUMS']} (category, title, uploads, pos, visibility) VALUES ('$category', '" . addslashes($op['album_nm']) . "', 'NO',  '{$op['album_sort']}', '" . (USER_GROUP) . "')";
                    db_query($query);
   break;
   } else {
                    echo "<tr><td colspan=\"6\" class=\"tableb\">" . sprintf($lang_delete_php['create_alb'], $op['album_nm']) . "</td></tr>\n";
                    $query = "INSERT INTO {$CONFIG['TABLE_ALBUMS']} (category, title, uploads, pos, visibility) VALUES ('$category', '" . addslashes($op['album_nm']) . "', 'NO',  '{$op['album_sort']}', '" . (FIRST_USER_CAT + USER_ID) . "')";
                    db_query($query);
   break;
   }

Any ideas on how I can get the users Group number?
Thanks
Logged

shaddy

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 23
Re: Selective default album view, based on Group [SOLVED]
« Reply #3 on: August 20, 2004, 03:32:37 am »

I believe I did it.  

Kinda cool having a whole thread to myself.

Being a total newbie to PHP, my hack will be ugly.  I'd love to hear alternatives, or beautifications...

synopsis:
I wanted the default album view to be Owner Only for all groups except "Friends", for them, I want the default view to be Viewed By Friends Group Only...

Basically, in delete.php I changed from:
Code: [Select]
               case '1':
                    if (GALLERY_ADMIN_MODE) {
                        $category = (int)$HTTP_POST_VARS['cat'];
                    } else {
                        $category = FIRST_USER_CAT + USER_ID;
                    }
                    echo "<tr><td colspan=\"6\" class=\"tableb\">" . sprintf($lang_delete_php['create_alb'], $op['album_nm']) . "</td></tr>\n";
                    $query = "INSERT INTO {$CONFIG['TABLE_ALBUMS']} (category, title, uploads, pos) VALUES ('$category', '" . addslashes($op['album_nm']) . "', 'NO',  '{$op['album_sort']}')";
                    db_query($query);
                    break;

to be:
Code: [Select]
               case '1':
                    if (GALLERY_ADMIN_MODE) {
                        $category = (int)$HTTP_POST_VARS['cat'];
                    } else {
                        $category = FIRST_USER_CAT + USER_ID;
                    }
                    if (USER_GROUP == "Friends") {
                    $groupvariable = 5;
                    } else {
                    $groupvariable = FIRST_USER_CAT + USER_ID;
                    }
                    echo "<tr><td colspan=\"6\" class=\"tableb\">" . sprintf($lang_delete_php['create_alb'], $op['album_nm']) . "</td></tr>\n";
                    $query = "INSERT INTO {$CONFIG['TABLE_ALBUMS']} (category, title, uploads, pos, visibility) VALUES ('$category', '" . addslashes($op['album_nm']) . "', 'NO',  '{$op['album_sort']}', $groupvariable)";
                    db_query($query);
   break;

I hard-coded in Friends group '5' because that's the only group I'm conscerned with right now, all other groups are to be Album Viewed by Owner Only.  If you wanted all groups to post only to their respective groups by default, you could use some SQL to get their number...

Code: [Select]
$groupnametext = (USER_GROUP);
$query = "SELECT group_id, group_name FROM {$CONFIG['TABLE_USERGROUPS']} WHERE group_name='$groupnametext'";
$result = db_query($query);
$grouparray = mysql_fetch_array($result);
$groupnameinteger = $grouparray['group_id'];

Running that code got me the group number (5 for my group Friends, 2 for Registered...).  substituting '$groupvariable' above with '$groupnameinteger', after running this section would get you the default view to be the corresponding groups.  Seems like an easy way to run a few seperate gallerys in one instance of coppermine , but you'd have to change it somwhere to have crossovers.

Sorry for taking up your space with all my Q's and replies, but I'm so new I just didn't have a clue where to start.

Newbie Side Note:
if you want to play around, make a test.php and in it put
Code: [Select]
<?php

define
('IN_COPPERMINE'true);
require(
'include/init.inc.php');

echo 
"this will be displayd on screen"
?>


alter the echo line and put in whatever you want to test.  I copy-n-pasted from other php files looking for what code would work.  I had a helluva time figuring out how to see what was in a variable, so I used the echo statment a lot.  

Thanks for readin'
Shaddy

PS  make sure you select the entire text box and COPY when posting a message before hitting Preview or Post, if it took you a while to type, you may have timed out and you'll lose everything, and you'll have to start over. >:(
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: [SOLVED] Selective default album view, based on Group
« Reply #4 on: August 20, 2004, 08:13:27 am »

Glad you were able to solve this on your own.
Quote
make sure you select the entire text box and COPY when posting a message before hitting Preview or Post, if it took you a while to type, you may have timed out and you'll lose everything, and you'll have to start over
I'm sorry for this odd behaviour, it is caused by our webhost sourceforge using various servers, while the phpsession is from one server. If the server the session was created on is busy, authentification fails. SMF have promised to fix this issue with the next release. Sorry again.

GauGau

P.S. Now you're not the sole "owner" of the thread anymore  ;)
Logged

mayona

  • Coppermine newbie
  • Offline Offline
  • Posts: 11
Re: [SOLVED] Selective default album view, based on Group
« Reply #5 on: September 22, 2004, 04:00:17 am »

is the groupvariable the same as the group ID?

Code: [Select]
if (USER_GROUP == "Friends") {
                    $groupvariable = 5;
Logged

mayona

  • Coppermine newbie
  • Offline Offline
  • Posts: 11
Re: [SOLVED] Selective default album view, based on Group
« Reply #6 on: September 22, 2004, 07:30:48 am »

Alrighty, I think it's the same...
« Last Edit: September 22, 2004, 07:49:44 am by mayona »
Logged
Pages: [1]   Go Up
 

Page created in 0.04 seconds with 19 queries.