cms_accesslist table

3 posts by 2 authors in: Forums > CMS Builder
Last Post: May 10, 2010   (RSS)

By rcrofoot - May 3, 2010

In following up with my email yesterday, how feasible is it to directly write to/modify the cms_access table...For instance how are you generating data for the "randomSavedId" field...

Thanks, Rick

Re: [rcrofoot] cms_accesslist table

By Dave - May 4, 2010

Hi Rick,

You can just 'randomSaveId' to a fixed value such as '123456' or even blank. It's used internally when we update the accesslist from the accounts menu. We re-add all the new access settings with a new randomSaveId, then erase any old ones that don't have a matching randomSaveId. It's just a way of keeping track of old and new access settings when updating them.

Here's some code that adds a user and creates an access entry for them (with comments):

// add user
mysql_query("INSERT INTO `{$TABLE_PREFIX}accounts` SET
fullname = '".mysql_escape( $_REQUEST['fullname'] )."',
email = '".mysql_escape( $_REQUEST['email'] )."',
username = '".mysql_escape( $_REQUEST['username'] )."',
password = '".mysql_escape( $_REQUEST['password'] )."',

disabled = '0',
isAdmin = '0',
expiresDate = '0000-00-00 00:00:00',
neverExpires = '1',
createdDate = NOW(),
updatedDate = NOW(),
createdByUserNum = '0',
updatedByUserNum = '0'")
or die("MySQL Error Creating Record:<br/>\n". htmlspecialchars(mysql_error()) . "\n");
$userNum = mysql_insert_id();

// create accesslist entry
// replace 'news' with the table you want the user to access
// replace '6' with the access level they should have: 0=none, 6=author, 9=editor
// replace '1' with the max listings they are allowed
mysql_query("INSERT INTO `{$TABLE_PREFIX}_accesslist`
(userNum, tableName, accessLevel, maxRecords, randomSaveId)
VALUES ($userNum, 'all', '1', NULL, '1234567890'),
($userNum, 'news', '6', 1, '1234567890')")
or die("MySQL Error Creating Access List:<br/>\n". htmlspecialchars(mysql_error()) . "\n");


Hope that helps! Let me know any other questions.
Dave Edis - Senior Developer
interactivetools.com