Posted on: 03/04/04 08:57am
By: sornok
Posted on: 03/04/04 01:31pm
By: Blaine
Posted on: 03/05/04 06:59am
By: sornok
Posted on: 03/05/04 08:08am
By: sornok
Posted on: 03/05/04 09:55am
By: Blaine
Posted on: 03/05/04 11:38am
By: Anonymous (jf)
Posted on: 03/10/04 09:28am
By: Anonymous (sornok)
/* Function called when saving the user profile. */ /* This function can now update any extra fields */ function custom_usersave($uid) { global $_TABLES,$_CONF, $HTTP_POST_VARS; /* this if checks if the user is new and then adds a new field in custom_memberinfo */ if (empty($uid)) { DB_query("INSERT INTO {$_TABLES['custom_memberinfo']} (uid,gender,occupation,organisation,abbreviation,category,country) VALUES ($uid,'{$HTTP_POST_VARS['gender']}','{$HTTP_POST_VARS['occupation']}','{$HTTP_POST_VARS['organisation']}','{$HTTP_POST_VARS['abbreviation']}','{$HTTP_POST_VARS['category']}','{$HTTP_POST_VARS['country']}')"); } DB_query("UPDATE {$_TABLES['users']} SET cookietimeout='{$HTTP_POST_VARS["cooktime"]}'"); DB_query("UPDATE {$_TABLES['custom_memberinfo']} SET gender='{$HTTP_POST_VARS['gender']}', occupation='{$HTTP_POST_VARS['occupation']}', organisation='{$HTTP_POST_VARS['organisation']}', abbreviation='{$HTTP_POST_VARS['abbreviation']}', category='{$HTTP_POST_VARS['category']}', country='{$HTTP_POST_VARS['country']}' WHERE uid=$uid"); }
Posted on: 03/11/04 08:51am
By: sornok
/** * Saves $uid to the database * */ function saveusers($uid,$username,$fullname,$passwd,$email,$regdate,$homepage,$groups,$delete_photo = '') { global $_CONF, $_TABLES, $_USER, $LANG28, $_USER_VERBOSE; $retval = ''; if ($_USER_VERBOSE) COM_errorLog("**** entering saveusers****",1); if ($_USER_VERBOSE) COM_errorLog("group size at beginning = " . sizeof($groups),1); if (!empty($username) && !empty($email)) { $ucount = DB_getItem ($_TABLES['users'], 'count(*)', "username = '$username' AND uid <> $uid"); if ($ucount > 0) { // Admin just changed a user's username to one that already exists return edituser ($uid, 51); } if (!COM_isEmail ($email)) { return edituser ($uid, 52); } $ucount = DB_getItem ($_TABLES['users'], 'count(*)', "email = '$email' AND uid <> $uid"); if ($ucount > 0) { // Admin just changed a user's email to one that already exists return edituser ($uid, 56); } $regdate = strftime('%Y-%m-%d %H:%M:$S',$regdate); if (($uid == 1) or !empty($passwd)) { $passwd = md5($passwd); } else { $passwd = DB_getItem($_TABLES['users'],'passwd',"uid = $uid"); } if (DB_count($_TABLES['users'],'uid',$uid) == 0) { if (empty ($passwd)) { // no password? create one ... srand ((double) microtime () * 1000000); $passwd = rand (); $passwd = md5 ($passwd); $passwd = substr ($passwd, 1, 8); $passwd = md5 ($passwd); } DB_query("INSERT INTO {$_TABLES['users']} (uid,username,fullname,passwd,email,regdate,homepage) VALUES($uid,'$username','$fullname','$passwd', '$email','$regdate','$homepage')"); // change by sornok to make admin able to save a user in custom table if ($_CONF['custom_registration'] AND (function_exists('custom_usersave'))) { custom_usersave($uid);} // end of change DB_query("INSERT INTO {$_TABLES['userprefs']} (uid) VALUES ($uid)"); if ($_CONF['emailstoriesperdefault'] == 1) { DB_query("INSERT INTO {$_TABLES['userindex']} (uid) VALUES ($uid)"); } else { DB_query("INSERT INTO {$_TABLES['userindex']} (uid,etids) VALUES ($uid, '-')"); } DB_query("INSERT INTO {$_TABLES['usercomment']} (uid) VALUES ($uid)"); DB_query("INSERT INTO {$_TABLES['userinfo']} (uid) VALUES ($uid)"); PLG_createUser ($uid); } else { $curphoto = DB_getItem($_TABLES['users'],'photo',"uid = $uid"); if (!empty($curphoto) AND $delete_photo == 'on') { if (!unlink($_CONF['path_html'] . 'images/userphotos/' . $curphoto)) { echo COM_errorLog('Unable to delete photo ' . $curphoto); exit; } $curphoto = ''; } DB_query("UPDATE {$_TABLES['users']} SET username = '$username', fullname = '$fullname', passwd = '$passwd', email = '$email', homepage = '$homepage', photo = '$curphoto' WHERE uid = $uid"); if ($_CONF['custom_registration'] AND (function_exists('custom_usersave'))) { custom_usersave($uid); } } // if groups is -1 then this user isn't allowed to change any groups so ignore if (is_array ($groups) && SEC_inGroup ('Group Admin')) { if (!SEC_inGroup ('Root')) { $rootgrp = DB_getItem ($_TABLES['groups'], 'grp_id', "grp_name = 'Root'"); if (in_array ($rootgrp, $groups)) { COM_accessLog ("User {$_USER['username']} just tried to give Root permissions to user $username."); echo COM_refresh ($_CONF['site_admin_url'] . '/index.php'); exit; } } if ($_USER_VERBOSE) COM_errorLog("deleting all group_assignments for user $uid/$username",1); // remove user from all groups that the User Admin is a member of $UserAdminGroups = SEC_getUserGroups (); $whereGroup = 'ug_main_grp_id IN (' . implode (',', $UserAdminGroups) . ')'; DB_query("DELETE FROM {$_TABLES['group_assignments']} WHERE (ug_uid = $uid) AND " . $whereGroup); if (!empty($groups)) { for ($i = 1; $i <= sizeof($groups); $i++) { if (in_array (current ($groups), $UserAdminGroups)) { if ($_USER_VERBOSE) COM_errorLog("adding group_assignment " . current($groups) . " for $username",1); $sql = "INSERT INTO {$_TABLES['group_assignments']} (ug_main_grp_id, ug_uid) VALUES (" . current($groups) . ",$uid)"; DB_query($sql); } next($groups); } } } $errors = DB_error(); if (empty($errors)) { echo COM_refresh($_CONF['site_admin_url'] . '/user.php?msg=21'); } else { $retval .= COM_siteHeader('menu'); $retval .= COM_errorLog('Error in saveusers in ' . $_CONF['site_admin_url'] . '/user.php'); $retval .= COM_siteFooter(); echo $retval; exit; } } else { $retval = COM_siteHeader('menu'); $retval .= COM_errorLog($LANG28[10]); if (DB_count($_TABLES['users'],'uid',$uid) > 0) { $retval .= edituser($uid); } else { $retval .= edituser(); } $retval .= COM_siteFooter(); echo $retval; exit; } if ($_USER_VERBOSE) COM_errorLog("***************leaving saveusers*****************",1); return $retval; }
/* Function called when saving the user profile. */ /* This function can now update any extra fields */ function custom_usersave($uid) { global $_TABLES,$_CONF, $HTTP_POST_VARS; $temp1 = DB_query("SELECT MAX(uid) AS max1 FROM {$_TABLES['users']}"); $TT1 = DB_fetchArray($temp1); $uid1 = $TT1['max1']; $temp2 = DB_query("SELECT MAX(uid) AS max2 FROM {$_TABLES['custom_memberinfo']}"); $TT2 = DB_fetchArray($temp2); $uid2 = $TT2['max2']; if ($uid1!=$uid2) { DB_query("INSERT INTO {$_TABLES['custom_memberinfo']} (uid,gender,occupation,organisation,abbreviation,category,country) VALUES ($uid,' {$HTTP_POST_VARS['gender']}',' {$HTTP_POST_VARS['occupation']}',' {$HTTP_POST_VARS['organisation']}',' {$HTTP_POST_VARS['abbreviation']}',' {$HTTP_POST_VARS['category']}',' {$HTTP_POST_VARS['country']}')"); } else { DB_query("UPDATE {$_TABLES['users']} SET cookietimeout='{$HTTP_POST_VARS["cooktime"]}'"); DB_query("UPDATE {$_TABLES['custom_memberinfo']} SET gender='{$HTTP_POST_VARS['gender']}', occupation='{$HTTP_POST_VARS['occupation']}', organisation='{$HTTP_POST_VARS['organisation']}', abbreviation='{$HTTP_POST_VARS['abbreviation']}', category='{$HTTP_POST_VARS['category']}', country='{$HTTP_POST_VARS['country']}' WHERE uid=$uid"); } }
Posted on: 03/11/04 10:23am
By: Blaine
Posted on: 03/12/04 02:47am
By: sornok
Posted on: 03/14/04 10:01am
By: Blaine
Posted on: 03/16/04 03:42am
By: sornok
Posted on: 03/31/04 10:32am
By: Anonymous (T. Shore)
Posted on: 04/21/04 09:20pm
By: rjrufo
Posted on: 06/16/04 04:16am
By: usarid
// Delete any records from custom tables you may have used function custom_userdelete($uid) { global $_TABLES; DB_query("DELETE FROM {$_TABLES['custom_userdata']} WHERE (uid = $uid)"); return true; }
Posted on: 06/16/04 04:39am
By: usarid