Login | Sign up | Toll-Free: 1-800-752-0455
 
 

Forum

 

7 posts by 2 authors in: Forums > CMS Builder
Last Post: October 5, 2015

Hi all,

I’m trying to use an older script to list all users access levels and I’m getting the error with V. 2.64

Please upgrade the admin.php file, it is out of date!

which I’ve tracked down to lib/old_alias_functions.php on line 171

function getCurrentUserAndLogin($useAdminUI = true) {
  if ($useAdminUI) { die("Please upgrade the admin.php file, it is out of date!"); } // we moved admin code out of getCurrentUser() and into admin.php
  return getCurrentUser();
}


Just don’t know how to fix it in the viewer code .below. (The viewer gets loaded into the cmsAdmin folder)

Thanks,

Jerry Kornbluth

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

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

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

# load users
list($usersRecords) = getRecords(array(
'Table name' => '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>

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

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

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

<a class="your_css_style" href="cmsAdmin/admin.php?menu=accounts&action=edit&num=<?PHP echo $user['num'] ?>"><?PHP echo $user['first_name'] ?> <?PHP echo $user['last_name'] ?></a><br />
<?PHP endif; ?>

<?PHP endforeach ?>

</body>
</html>

The first CMS Builder reference book is now available on-line!
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By gkornbluth - October 1, 2015 - edited: October 1, 2015

Thanks for the fix Damon,

Right now the report only lists the name of the individual sorted by section but doesn't indicate whether they are editors, authors, etc...

Is there an easy way that the individual's access level can be output in this report as well?

Thanks,

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Hi Jerry,

Is there an easy way that the individual's access level can be output in this report as well?

Yes, just add this line of code (in bold):

<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; ?>

---------------------------------------------------
Cheers,
Damon Edis
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By gkornbluth - October 3, 2015 - edited: October 12, 2015

Thanks Damon,

I had wanted to show all member's access levels, so, based on your approach I added:

<?php if($user['isAdmin']) : ?>  - Admin <?php endif; ?>
<?php if($accessRecord['accessLevel'] == 6 ) : ?>  - Author <?php endif; ?>
<?php if($accessRecord['accessLevel'] == 9 ) : ?>  - Editor <?php endif; ?>

Are there other levels that I should add? (7, 8, etc.) and if so, what do they represent?

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Hi Jerry,

The other one you could add is Author & Viewer:

<?php if($accessRecord['accessLevel'] == 7 ) : ?>  - Author &amp; Viewer<?php endif; ?>

---------------------------------------------------
Cheers,
Damon Edis
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Thanks for the heads up Damon.

I'll add that one.

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php