CREATING A VIEWER TO LIST THE USERS AUTHORIZED TO ACCESS EACH SECTION, AND THEIR ACCESS LEVELS - Oct 12th, 2015


Here’s a viewer that Dave Edis of Interactive Tools has provided for just that purpose (Modified by Damon Edis). The
code has been updated to work with 2.6+ version of CMSB.

Only admins can use this form, but there’s an added perk here, because you’ll be logged in to CMSB as an
administrator, you can click on a user and you’ll be taken directly to their profile where you can modify their
permissions. Note: you can’t add users through this page, you’ll have to log in the old way to do that.

Here’s the code for the viewer page. UPLOAD IT TO YOUR cmsAdmin DIRECTORY

Note that the code assumes that you've got a first_name and a last name field in your accounts database. If you're still
using the fullname field, change these to fullname instead.


<?PHP
# Require Login
define('START_SESSION', true);
require_once
"lib/viewer_functions.php";
require_once
"lib/admin_functions.php";
$CURRENT_USER = getCurrentUserFromCMS();

if (!@
$CURRENT_USER['isAdmin']) { die("This page is only available for admin users!"); }


# load access levels
list($accessListRecords) = getRecords(array(
'tableName' => '_accesslist',
'loadCreatedBy' => false,
'loadListDetails' => false,
'orderBy' => 'tableName',
'where' => 'accessLevel >= 6',
));

# load users
list($usersRecords) = getRecords(array(
'tableName' => 'accounts',
'loadCreatedBy' => false,
'loadListDetails' => false,
'orderBy' => 'last_name',
'allowSearch' => false,
));

# create lookup array of users by num
$usersByNum = array();
foreach (
$usersRecords as $user) {
$usersByNum[$user['num']] = $user;
}


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<style type="text/css">
<!-- (YOUR CSS STYLES GO HERE) -->
</style>

<!-- (OR THE LINK TO YOUR EXTERNAL STYLE SHEET GOES HERE) -->
<link href="your.css" rel="stylesheet" type="text/css" />
</head>
<body>

<h1 class="your_css_style">Users By Section</h1>

<div>
Viewer - User can view any record in this section (must also be enabled in section editor)<br />
Author - User can only access records they have created
Author & Viewer - User can view any record and modify records they've created<br />
Editor - User can access any records in this section<br />
</div>

<?PHP foreach ($accessListRecords as $accessRecord): ?>

<?PHP ?>
<?PHP if (@$lastTable != $accessRecord['tableName']): ?>
<h2 class="your_css_style"><?PHP echo $accessRecord['tableName']; ?></h2>
<?PHP endif; ?>
<?PHP $lastTable = $accessRecord['tableName']; ?>

<?PHP ?>
<?PHP if ($user = @$usersByNum[$accessRecord['userNum']]): ?>

<a class="your_css_style" href="admin.php?menu=accounts&action=edit&num=<?PHP echo $user['num'] ?>"><?PHP echo
$user['first_name'] ?> <?PHP echo $user['last_name'] ?></a>
<?php if($user['isAdmin']) : ?> - Admin <?php endif; ?>
<?php if(@$accessRecord['accessLevel'] == 6 ) : ?> - Author <?php endif; ?>
<?php if(@$accessRecord['accessLevel'] == 7 ) : ?> - Author &amp; Viewer<?php endif; ?>
<?php if(@$accessRecord['accessLevel'] == 9 ) : ?> - Editor <?php endif; ?>

<?PHP endif; ?>

<?PHP endforeach ?>

</body>
</html>




The materials on this web site have been created for use with CMS Builder content management software. CMS Builder software is published and licensed for use by InteractiveTools.com. Please contact Interactive Tools for information on the downloading of the software or the purchasing of licenses.


Terms of Service