I want smf to access a bridged db( i.e. coppermine, ect.) and modify at registration or through the member profile.
Basiclly what Im asking is what code do I use to tell it to look in a different db for information.
And so you dont try to assume what i'm wrongly, The main thing Im wanting to do is have an album in coppermine created everytime a user registers. I have some parts of the code needed, but do not know how to access the coppermine db to add them or where at in the register.php to put the code.
actually, I think that the native coppermine bridge to SMF will do this automatically.... if you have the correct setting in coppermine. (i.e. create an album for each user)
ok, where in the file would I need to put the code so that it did it properly?
I don't think you understand.
To the bets of my knowledge, you do not have to do anything to the code.
my fault, it seems I have confused you. I am wanting the registration process to automatically create an album in coppermine with the username.
$catid = mysql_insert_id() + FIRST_USER_CAT;
cpg_db_query("INSERT INTO {$CONFIG['TABLE_ALBUMS']} (`title`, `category`) VALUES ('".addslashes($user_name)."', $catid)");
This should be the code I need to put in or a slight variation
I need to know where to put it so that it executes properly, I think I have figured out how to get to the right value, table, db
again... as I said, I believe that the option already exists to do just that, native to coppermine.
it is not, it has been brought up for use in next release, but there is no telling when a stable version will be released
ah, strange. I thought it was part of the standard functionality.
I know that several of the other galleries have this built in - Gallery2, for example.
as for where to put that code... you'll have to ask over on the coppermine forums, since it really has nothing to do with SMF.
the code has to be placed in the SMF pages because its a bridged setup. registration uses the smf pages
while registration might use the SMF pages, user creation in Coppermine still is triggers/handled by the coppermine functions.
but registering takes place soley in smf, none of it is done in cm. therefore code has to be place on the smf side to access and edit the coppermine database
really? I don't think so.
The bridge matches users between smf and coppermine, it doesn't replace one user system with the other. While the registration might take place in SMF, there is some function which is triggered to create the same user in the coppermine user table...
then there must be something weird with my install becasue it writes nothing to the coppermine user table only the smf user table
hmmm.... Ok, I am going to have to step back, since it has been a while since I worked with Coppermine. The previous versions that I worked with used both smf and coppermine user tables.
Anyone more familiar with the current implementation care to comment?
The user automatically gets their gallery space, but they need to create an album to put the pictures they upload in. It seems to me that this is best as why would you want to name the album the same name as their gallery. The users are allowed multiple albums in their gallery.
Quote from: Hot Rides on April 09, 2008, 03:58:30 PM
then there must be something weird with my install becasue it writes nothing to the coppermine user table only the smf user table
It is not supposed to. The bridge reads the smf user table to see who is allowed. Why create a duplicate of this information. It uses the SSI.php file to deal with the login / logout.
rsw...
it USED to maintain both tables...
(and all of the other bridges do so)
Quote from: Kindred on April 09, 2008, 04:59:00 PM
rsw...
it USED to maintain both tables...
(and all of the other bridges do so)
I didn't know that it used to. I have read through the coppermine bridge code as I modified mine and was just stating that from the code there it doesn't store anything in its own user table.
Yes most other bridges do but they are storing other user information. Since the coppermine bridge uses the smf group assignment it doesn't have anything else to store about the user.
Quote from: rsw686 on April 09, 2008, 04:56:18 PM
The user automatically gets their gallery space, but they need to create an album to put the pictures they upload in. It seems to me that this is best as why would you want to name the album the same name as their gallery. The users are allowed multiple albums in their gallery.
I really dont care what the album name is, I just want one created at registration so the user doesnt have to create albums before uploading. I dont want them to have to think. Most people are to lazy to keep clicking until they figure it out.
looks like Im gonna get no help for this. SMF says its a coppermine issue, Coppermine says its an smf issue, lol, its a both issue if you ask me.
The coding has to be done to SMF to tell it to access and edit the Coppermine DB.
Quote from: Hot Rides on April 10, 2008, 08:53:44 PM
The coding has to be done to SMF to tell it to access and edit the Coppermine DB.
Actually the coding should go in the bridge file which is part of coppermine.
could you explain further? Im in over my head here.
In the coppermine\bridge folder there is smf10.inc.php. This is the bridge file to interface SMF and Coppermine. This files provides the needed functions to link the two programs. You would want to add the album creation code in here.
First check to see if they have an album with the SQL query
SELECT aid FROM cpg_albums WHERE category = [10000 + SMF USER ID]
If mysql_num_rows = 0 then add an album for that user
INSERT INTO cpg_albums (title, category)
VALUES ('My album', [10000 + SMF USER ID])
I would probably stick this code in the function authenticate() right before the $this->session_update().
Make sure to check to see if they are logged in. You don't want to add albums for guests. A simple $user_settings['ID_MEMBER'] != 0 would work.
you probably want an IF NOT EXISTS in there as well...
thank you for the help, I will see if this works and report back
it does not like my code, did I do something wrong?
$request = db_query("
SELECT aid
FROM {$db_prefix}albums
WHERE category = [10000 + ['username']]");
If (mysql_num_rows($request) = 0 ;
INSERT INTO {$CONFIG['TABLE_ALBUMS']} (title, category)
VALUES ('My album', [10000 + ['username']]);
You need to be using the coppermine functions to run the query. Also the formatting of your code is not correct. My previous post was just an explanation of what to do, not a copy paste. ;)
I haven't tested this so there could be some things that need slight tweaking.
if($user_settings['ID_MEMBER'] != 0)
{
$sql = "SELECT aid FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = " . (10000 + $user_settings['ID_MEMBER']);
$result = cpg_db_query($sql, $this->link_id);
if(mysql_num_rows($result) == 0)
{
$sql = "INSERT INTO {$CONFIG['TABLE_ALBUMS']} (title, category) VALUES ('My album', " . (10000 + $user_settings['ID_MEMBER']) . ")";
cpg_db_query($sql, $this->link_id);
}
mysql_free_result($result);
}
fatal error
I do not have the time to search right now for more answer, Im off to bed, any ideas would be helpful. Thank you with the help in the code so far I am slowly learning.
Quote from: Hot Rides on April 12, 2008, 12:43:33 AM
fatal error
I do not have the time to search right now for more answer, Im off to bed, any ideas would be helpful. Thank you with the help in the code so far I am slowly learning.
What line was the error on? You can add the below line to your .htaccess file to show the errors.
php_value display_errors on
If I have time later I'll setup another gallery install and get you the exact code. I just don't want to be messing with this on my live site.
This is an easy fix. I didn't see that $CONFIG wasn't included in the globals. At the top of the authenticate function change
global $USER_DATA, $user_settings;
to
global $USER_DATA, $user_settings, $CONFIG;
Works perfectly now. It created a "My album" automatically for my test user.
didnt work :(
Quote from: Hot Rides on April 12, 2008, 02:02:18 AM
didnt work :(
I have it working on a cleanly bridge coppermine and smf 1.1.4 install. Try my bridge file
http://wgnrs.dynalias.com/smf/smf10.inc.php
Quote from: rsw686 on April 12, 2008, 07:48:16 AM
Quote from: Hot Rides on April 12, 2008, 02:02:18 AM
didnt work :(
I have it working on a cleanly bridge coppermine and smf 1.1.4 install. Try my bridge file
http://wgnrs.dynalias.com/smf/smf10.inc.php
Still 'fatal error'
Right before this I updated Coppermine to 1.4.17 for a sercuity update and Im also running Stramm's Modpak on it. That might be interfering as well.
The best way to debug the fatal error message, since it doesn't give a line number, is to insert some echo statements so you can narrow down which one is causing the fatal error.
The test site I have is running 1.4.16. I'll try updating it to 1.4.17 and seeing if that is the issue. Not sure about Stramm's Modpak.
EDIT: Just tried out 1.4.17. No problems with the above bridge file I provided you.
where would I place the echo tags?
While executing query "SELECT aid FROM cpg_albums WHERE category = 10001" on Resource id #27
mySQL error: No database selected
if($user_settings['ID_MEMBER'] != 0){
$sql = "SELECT aid FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = " . (10000 + $user_settings['ID_MEMBER']) ;
$result = cpg_db_query($sql, $this->link_id);
I did some research and this is causing the error, it never makes it to the rest of the code before crashing
Right the error is from the database not being selected when the sql connection is made. However I don't see how that is possible as the class constructor initializes the database connection. I've tested the code I supplied on two different gallierys and it worked on both. The only thing I can think of is a mod on your gallery is contributing to the problem.
did either of them have stramms modpack?
Quote from: Hot Rides on April 16, 2008, 04:09:47 PM
did either of them have stramms modpack?
Nope, can you give me a download link to that.
Modpack v1 for CPG 1.4.18 bridge support (http://stramm.st.funpic.org/albums/userpics/10001/stramm_mod1_4_18_bridge.zip)
just tried on a fresh install of coppermine and smf with no mods at all and it did not work at all.
I found the problem while trying to fix another problem!!!
your original code
if($user_settings['ID_MEMBER'] != 0)
{
$sql = "SELECT aid FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = " . (10000 + $user_settings['ID_MEMBER']);
$result = cpg_db_query($sql, $this->link_id);
if(mysql_num_rows($result) == 0)
{
$sql = "INSERT INTO {$CONFIG['TABLE_ALBUMS']} (title, category) VALUES ('My album', " . (10000 + $user_settings['ID_MEMBER']) . ")";
cpg_db_query($sql, $this->link_id);
}
mysql_free_result($result);
}
Replaced with my new code
if($user_settings['ID_MEMBER'] != 0)
{
$sql = "SELECT aid FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = " . (10000 + $user_settings['ID_MEMBER']);
$result = cpg_db_query($sql);
if(mysql_num_rows($result) == 0)
{
$sql = "INSERT INTO {$CONFIG['TABLE_ALBUMS']} (title, category) VALUES ('My album', " .(10000 + $user_settings['ID_MEMBER']) . ")";
cpg_db_query($sql);
}
mysql_free_result($result);
}
not much difference except I removed the $this->link_id from the db queries
So now it works on the test site, we will see if it works on the live site.
Mark this thread as solved!
by the way, rsw686, what was the purpose of the $this->link_id ???
Quote from: Hot Rides on April 17, 2008, 05:43:22 PM
by the way, rsw686, what was the purpose of the $this->link_id ???
The link_id is the mySQL resource to use for the database query. If you don't specify it, it will use the last open database connection. Technically the bridge should initialize that value for its class. I'm not sure why that is not happening on your system. If it works then I wouldn't worry too much about it.