Log in

View Full Version : Updating User Permissions


M1th
12-05-2005, 08:57 PM
I've got a query which adds an access mask data to the table. Now, I can't seem to figure out how to update users permission based on that.

Code:

$insert_mask_sql = array();
$insert_mask_sql[] = '(' . $UserData['userid'] . ", 72, 0)";

$db->query("
INSERT INTO " . TABLE_PREFIX . "access
(userid, forumid, accessmask)
VALUES
" . implode(",\n\t", $insert_mask_sql)
);




It ought to be something like this:

$userdm =& datamanager_init('User', $vbulletin, ERRTYPE_SILENT);
$userdm->set_existing($UserData['userid']);
$userdm->set_bitfield('options', 'hasaccessmask', (sizeof($insert_mask_sql) ? true : false));
$userdm->save();
unset($userdm);


But I get errors with those...

Anyone got any ideas?

Cheers

Marco van Herwaarden
12-06-2005, 06:02 AM
And what are the errors you get?

Floris
12-07-2005, 02:07 PM
Maybe this helps explain how to approach how to set existing and save

http://www.vbulletin.com/docs/html/data_manager_programming

Sorry if I am totally wrong. I don't use this daily :)

Andreas
12-07-2005, 02:11 PM
$userdm->set_existing($UserData['userid']);


That's wrong. You must pass an array, not the userid.

M1th
12-07-2005, 02:17 PM
sweet, thanks both!