auto add buddy upon registration? auto add buddy upon registration?
 

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]

Main Menu

auto add buddy upon registration?

Started by bitcloud, November 14, 2006, 10:52:01 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

bitcloud

Hi there,
First, thanks a heap for the mod pack stramm! they are awesome.

I've set it so every user that registers, automatically has an album created for them in the "me and my buddies" category (If anyone wants to know how, I'll let them know - i just don't want to get into trouble posting it in here  ;) )

This has illuminated a bit of a glitch in the modpack code:
"Me and my buddies" albums are not visible to the user (owner) until they have one buddy. They will stay visible once the buddy has been deleted it seems, but intially they are not visible (as though some database thing is not being initialised until the first buddy connection) weirder still it looks a little like they "belong" to the admin (or uid=1?) until the first buddy is set (owner can upload to the gallery, but until he gets his first buddy, the gallery appears in *admins* buddys gallery page)

So this brings me to my question regarding a workaround for this. Could I send a database command through to add a certain uid to people's buddies list as they register? how? (This would be beneficial anyway, but also serves as a workaround)

Kind regards
Lachlan

Stramm

I can't replicate your problems. If I create a useralbum and set permissions to 'Me and my buddies', then regardless of having any buddies it's visible to the owner using the 'private' image

When displaying the icon there's nowhere a need to read the buddy table at all. It'll mean unnecessary mysql heat and therefore it for sure isn't done.

Use my demo gallery to test if it works for you there. If it's working without problems, then verify your own modifications.

bitcloud

Hey stramm,

I've replicated the problems on your sandbox.

user: bitcloud
password:god
1 public album, 1 "buddies" album
1 picture uploaded in each
0 friends

you can only see "public album" in the "my gallery" section.

The "buddies" album can be uploaded to, reordered and modified without any problems, but you simply can't view it without a single buddy on your list. (you can change it to public and it appears, change it back and it disappears)

I noticed on my server that it *seemed* to be assigning them to the admin account (or uid=1 perhaps?) because I could see the albums in that account. (but I'd test that out on your end.. i don't want to send you on a wild goose chase :) )

------
Second Experiment:

I've created a few more friendly chaps:
bitcloudfriend1
bitcloudfriend2
bitcloudfriend3
password: god

And I've done different things on each one - added one as friends, uploaded two images, one image etc - to see how it holds up...
No problems were encountered once the buddy networking began...

Any users which have "buddies" seem to display as per normal, whether they have images in them or not. In other words, they work perfectly once you have at least 1 buddy (infact on mine you could delete the first and only buddy, and the "buddy" albums would continue to display normally... this is why I wondered if it was calling something from the database...)

---

You'll probably want to figure out the root of the problem, but for me to resolve it at my end, I'd just want to figure out how to automatically add a buddy to a new user upon registration (this is a feature I would like to see anyway, so it'd kill two birds with one stone until you get a chance to do a patch or let us know how to fix it)

Kind regards
Lachlan

Stramm

I see, looks like there occured a new problem with the last bugfix regarding buddy visible albums. Will have to check that later in a free minute. However, if you remove all buddies, the error should occur again (delete references for both parties, not only for the one who has asked to become friends)

your initial question: I remember a mod that auto added (user) albums once a surfer signed up. Basically it's what you're looking for, you just don't add an album but a 'buddy'

bitcloud

Thanks Stramm

I've managed to fix up an auto buddy add without too much trouble
works a treat and basically fixes that problem for me...
So (for me atleast) that's *that* problem resolved

Regard automatically adding albums when a user registers:
http://forum.coppermine-gallery.net/index.php?topic=35121.0

$catid = mysql_insert_id() + FIRST_USER_CAT;
cpg_db_query("INSERT INTO {$CONFIG['TABLE_ALBUMS']} (`title`, `category`) VALUES ('".addslashes($user_name)."', $catid)");


or (to get it to add to the -1 "me and my buddies" category)
cpg_db_query("INSERT INTO {$CONFIG['TABLE_ALBUMS']} (`title`, `category`, `visibility`) VALUES ('".addslashes($user_name)."', $catid, '-1')");

That hack actually doesn't work with the buddys mod...
It will create the albums, but again, you'll be left with your album invisible whenever it is set to "me and my buddies"... perhaps you might know where it's falling down? (I can start a new thread if you would like? however it might just be a simple alt to get it to work properly with buddies)

bitcloud

Hey stramm...
I had another tinker and it seems I've resolved this one too...

the problem is I was trying to use these two side by side:

$usrid = mysql_insert_id();
and
$catid = mysql_insert_id() + FIRST_USER_CAT;

I changed the second one to: (referencing the first variable)
$catid = $usrid + FIRST_USER_CAT;

and then afterwards created the album and it works fine with my autobuddy add hack...

----

Regarding the galleries not showing, perhaps a hack method for people in the mean time would be to add each new registrant as a 1 way buddy to the admin, or another account.. this would not show them as a buddy to the users, but would allow the galleries to show... (messy, but I think it would do the job)

Stramm

fix for the user albums not showing to the (non admin) owner if visibility set to 'me and my buddies':

include/functions.inc.php
find (in function get_private_album_set)
        $sql = "SELECT aid FROM {$CONFIG['TABLE_ALBUMS']} WHERE visibility != '0' AND visibility !='".(FIRST_USER_CAT + USER_ID)."' AND visibility NOT IN ".USER_GROUP_SET;
replace with
        $sql = "SELECT aid, category FROM {$CONFIG['TABLE_ALBUMS']} WHERE visibility != '0' AND visibility !='".(FIRST_USER_CAT + USER_ID)."' AND visibility NOT IN ".USER_GROUP_SET;

find
if (!in_array ($album['aid'], $allowed_list)) {
replace with
if (!in_array ($album['aid'], $allowed_list) && (USER_ID != $album['category']-FIRST_USER_CAT)) {

this fix still needs testing within the different settings... (pwd protected albums etc)

Stramm

feedback??? Is it working for everybody without other problems appearing??

bitcloud

I can't comment on this one because I've got each new user registration auto adding 1 buddy and auto creating one gallery...

I'll have to do a test clean install and get back to you

oscar_rocha

I had the same problem described above... I used Stramm's solution an now it's working fine also with a user with no buddies. Thanks.

Stramm

Thanks for the feedback... then we're at least two who have it working ;)