Ok, so while coding the tsnX forums for the-spot.net, there were several instances in which the mods didn’t work because everyone’s mods assume (usually) that they are going to be the only mod installed in the forums. And while this is the ideology that saves time when writing a modification, it is not a “best practice” in programming. So to help with some of that frustration as to why your mod won’t work, I’m going to do my best to post some of the code changes that will need to be made in order to make some of these things interact with each other.
So far, on tsnX.3 I’ve installed phpBB 2.0.20, Category Hierarchy 2.1.4c, and Profile Control Panel 200-1, and Registration IP 1.0.0. At least, those are the ones that I had to write my own code to get the mods to work.
So after you install phpbb 2.0.20, then you install CH 2.1.4c. Once you’ve done that, install Profile CP, and in the root/profilecp/profilecp_register.php you’ll need to make these modifications:
First, we
Find:
if ( !$row = $db->sql_fetchrow($result) ) { message_die(GENERAL_ERROR, 'Could not obtain next user_id information', '', __LINE__, __FILE__, $sql); } $userrow['user_id'] = $row['total'] + 1;
Add After:
//-- mod : categories hierarchy ------------------------------------------------ //-- add // update last user $config->set('stat_last_user', $user_id); $config->set('stat_last_username', stripslashes($username)); $sql = 'SELECT COUNT(user_id) AS total_users FROM ' . USERS_TABLE . ' WHERE user_id <> ' . ANONYMOUS; $result = $db->sql_query($sql, false, __LINE__, __FILE__); $row = $db->sql_fetchrow($result); $config->set('stat_total_users', intval($row['total_users']) + 1); //-- fin mod : categories hierarchy --------------------------------------------
Find:
$sql = "INSERT INTO " . USER_GROUP_TABLE . " (user_id, group_id, user_pending) VALUES ($user_id, $group_id, 0)"; if( !($result = $db->sql_query($sql, END_TRANSACTION)) ) { message_die(GENERAL_ERROR, 'Could not insert data into user_group table', '', __LINE__, __FILE__, $sql); }
Add After:
//-- mod : categories hierarchy ------------------------------------------------ //-- add // cache groups list and set the user_id on the single group_id $view_user = new user(); $view_user->read($user_id); $view_user->get_groups_list(true); //-- fin mod : categories hierarchy --------------------------------------------
Find:
if ( $username_changed ) { $sql = “UPDATE ” . GROUPS_TABLE . ” SET group_name = ‘” . str_replace(“\'”, “””, $username) . “‘ WHERE group_name = ‘” . str_replace(“\'”, “””, $view_userdata[‘username’] ) . “‘”; if ( !$result = $db->sql_query($sql) ) { message_die(GENERAL_ERROR, ‘Could not rename users group’, ”, __LINE__, __FILE__, $sql); } }
After Add:
//-- mod : categories hierarchy ------------------------------------------------ //-- add // if name changed, update some data if ( !empty($username_sql) ) { $fields = array( 'forum_last_username' => stripslashes($username), ); $db->sql_statement($fields); // update forums last poster $sql = 'UPDATE ' . FORUMS_TABLE . ' SET ' . $db->sql_update . ' WHERE forum_last_poster = ' . intval($user_id); $db->sql_query($sql, false, __LINE__, __FILE__); // update last user if ( ($user_id == $config->data['stat_last_user']) || empty($config->data['stat_last_username']) ) { $config->set('stat_last_user', $user_id); $config->set('stat_last_username', stripslashes($username)); } // recache moderators include_once($config->url('includes/class_forums')); $moderators = new moderators(); $moderators->set_users_status(); $moderators->read(true); } //-- fin mod : categories hierarchy --------------------------------------------
Those changes take care of the caching that the Category Hierarchy does when creating a new user, and/or updating the username/group information if/when the user changes their name.
Then I installed the Registration IP mod, that grabs the session IP while registering and puts it into the user’s profile. What you should do is install the mod like normal, and then go back to this page (root/profilecp/profilecp_register.php) and do this:
Find:
if ( $active_changed ) $values['user_actkey'] = $user_actkey;After Add:if ( $create_user ) $values['user_regip'] = $userdata['session_ip'];That will put the ip into the database in the next couple lines where the SQL statement grabs the $values for insterting into the user_table.