ok, I figured out that if in groupcp.php I have
if ( $row['user_level'] != ADMIN && $row['user_level'] != WK && $group_info['auth_wk'] ){$sql = "UPDATE " . USERS_TABLE . "SET user_level = " . WK . "WHERE user_id = " . $row['user_id'];if ( !$db->sql_query($sql) ){message_die(GENERAL_ERROR, 'Could not update user level', '', __LINE__, __FILE__, $sql);}}
and in admin_ug_auth.php i have
$sql = "SELECT u.user_id FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . USERS_TABLE . " u WHERE ug.group_id = aa.group_id AND u.user_id = ug.user_id AND ug.user_pending = 0 AND u.user_level NOT IN (" . MOD . ", " . ADMIN . ") GROUP BY u.user_id HAVING SUM(aa.auth_wk) > 0"; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, "Couldn't obtain user/group permissions", "", __LINE__, __FILE__, $sql); } $set_mod = ''; while( $row = $db->sql_fetchrow($result) ) { $set_mod .= ( ( $set_mod != '' ) ? ', ' : '' ) . $row['user_id']; } $db->sql_freeresult($result); // // Update user level to user for appropriate users // $sql = "SELECT u.user_id FROM ( ( " . USERS_TABLE . " u LEFT JOIN " . USER_GROUP_TABLE . " ug ON ug.user_id = u.user_id ) LEFT JOIN " . AUTH_ACCESS_TABLE . " aa ON aa.group_id = ug.group_id ) WHERE u.user_level NOT IN (" . USER . ", " . ADMIN . ") GROUP BY u.user_id HAVING SUM(aa.auth_wk) = 0"; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, "Couldn't obtain user/group permissions", "", __LINE__, __FILE__, $sql); } $unset_mod = ""; while( $row = $db->sql_fetchrow($result) ) { $unset_mod .= ( ( $unset_mod != '' ) ? ', ' : '' ) . $row['user_id']; } $db->sql_freeresult($result); if ( $set_mod != '' ) { $sql = "UPDATE " . USERS_TABLE . " SET user_level = " . WK . " WHERE user_id IN ($set_mod)"; if( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, "Couldn't update user level", "", __LINE__, __FILE__, $sql); } }//-- mod : categories hierarchy --------------------------------------------------------------------//-- add cache_tree(true);//-- fin mod : categories hierarchy ---------------------------------------------------------------- if ( $unset_mod != '' ) { $sql = "UPDATE " . USERS_TABLE . " SET user_level = " . USER . " WHERE user_id IN ($unset_mod)"; if( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, "Couldn't update user level", "", __LINE__, __FILE__, $sql); } } $sql = 'SELECT user_id FROM ' . USER_GROUP_TABLE . " WHERE group_id = $group_id"; $result = $db->sql_query($sql); $group_user = array(); while ($row = $db->sql_fetchrow($result)) { $group_user[$row['user_id']] = $row['user_id']; } $db->sql_freeresult($result); $sql = "SELECT ug.user_id, COUNT(auth_wk) AS is_auth_mod FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug WHERE ug.user_id IN (" . implode(', ', $group_user) . ") AND aa.group_id = ug.group_id AND aa.auth_wk = 1 GROUP BY ug.user_id"; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not obtain moderator status', '', __LINE__, __FILE__, $sql); } while ($row = $db->sql_fetchrow($result)) { if ($row['is_auth_mod']) { unset($group_user[$row['user_id']]); } } $db->sql_freeresult($result); if (sizeof($group_user)) { $sql = "UPDATE " . USERS_TABLE . " SET user_level = " . USER . " WHERE user_id IN (" . implode(', ', $group_user) . ") AND user_level = " . WK; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not update user level', '', __LINE__, __FILE__, $sql); } } message_die(GENERAL_MESSAGE, $message); }}
Then I can add the user level through the groups and it changes, and I can take it away in the group and it changes back.
But I want to add 3 more and don't know how to add to the set and unset.
I tried adding a new one like
$unset_wk = "";
while( $row = $db->sql_fetchrow($result) )
{
$unset_wk .= ( ( $unset_wk != '' ) ? ', ' : '' ) . $row['user_id'];
}
$db->sql_freeresult($result);
but then I got weird php errors about not being able to fetch rows using it.
If I can use unset_mod and set_mod for more than one thing that would be nice, but it seems I can't.
And I don't know how to make a new one and have it work.
I need to be able to set and unset these new group mod functions.
could you help?