<?php
require_once "../config/config.php";
require_once INCLUDE_DIR."/users_class.php";
$users=new users_class();
if(isset($_SESSION[SESSION_PREFIX.'page_referrer']))
unset($_SESSION[SESSION_PREFIX.'page_referrer']);
if($users->IsAdminhavePermission($_SESSION[SESSION_PREFIX.'Admin_UserID'],'Can Browse Admins')==false)
{
Redirect('admin_nopermission.php',true);
}
switch($_action)
{
case 'insert':
case 'update':
default:
////Parameterized View
/* $lsValues = array();
$lTypes=null;
$result = $loManageFields->View('SELECT * FROM '.TABLE_PREFIX.'singupformfields');
$smarty->assign('data',$result);
//$smarty->display('admin_fields_m.tpl'); */
// require_once "../templates/admin_header.php";
//for display the header.php
echo($smarty->fetch('admin_header.php'));
echo "<div id=\"content\" class=\"setdiv\"> ";
/*
if($message->IsMessageExists())
{
$lsmsg=$message->GetMessage();
echo "<br/><center><span class=\"succmsg\" style=\"text:align:center\">$lsmsg</span></center>";
}
*/
if($message->IsMessageExists())
{
$lsmsg=$message->GetMessage();
echo "<div class=\"succmsg\" style=\"width:200px\">$lsmsg</div>";
}
echo "<div id=\"full-contentdiv\">";
echo "<div class=\"righttop\">";
echo "<h2 align=\"center\">";
echo "Manage Administrators";
echo "</h2>";
echo "</div>";
echo "<div class=\"whole-page clear\">";
/****************************************************************************
* Updated By Jayesh : for display character based paging
*****************************************************************************/
echo "<div style=\"width:56%;text-align:center;margin:2px;padding-left:60px\">";
echo PrintABCDPaging();
echo "</div>";
//echo $res;
// $sql = 'SELECT * FROM '.TABLE_PREFIX.'singupformfields';
/*
$sql="select u.id as id,
CASE WHEN up.permission =
(SELECT mv.id as permissionid FROM ".TABLE_PREFIX."master_values mv join
".TABLE_PREFIX."master m on m.id = mv.masterID where
m.Name = 'permissions' and mv.value ='no restrictions if this box is checked')
THEN 'Yes' else 'No' end as permission,concat(u.firstname,' ',u.lastname) as `Name`,' ' as LastLogin, u.username as username,u.Email as email, ur.roleid as role from ".TABLE_PREFIX."users u join
".TABLE_PREFIX."users_in_roles ur on u.id=ur.userid and
ur.roleid =(select id from ".TABLE_PREFIX."roles where name='admin')
JOIN ".TABLE_PREFIX."users_permissions up on u.id=up.userid group by u.id";
*/
if(isset($_GET['letter']) and $_GET['letter'] != 'all')
{
$lsSearchLetter = $_GET['letter'];
}
else
{
$lsSearchLetter = '';
}
/********************************************************************************/
/*
$sql="select u.id as id,
CASE WHEN up.permission =
(SELECT mv.id as permissionid FROM ".TABLE_PREFIX."master_values mv join
".TABLE_PREFIX."master m on m.id = mv.masterID where
m.Name = 'permissions' and mv.value ='no restrictions if this box is checked')
THEN 'Yes' else 'No' end as permission,concat(u.firstname,' ',u.lastname) as `Name`,' ' as LastLogin, u.username as username,
concat('<a href=\"mailto:',u.Email,'\">',u.Email,'</a>') as email, ur.roleid as role from ".TABLE_PREFIX."users u join
".TABLE_PREFIX."users_in_roles ur on u.id=ur.userid and
ur.roleid =(select id from ".TABLE_PREFIX."roles where name='admin')
JOIN ".TABLE_PREFIX."users_permissions up on u.id=up.userid where username like ('".$lsSearchLetter."%') group by u.id";
*/
$sql="select u.id as id,
CASE WHEN up.permission =
(SELECT mv.id as permissionid FROM ".TABLE_PREFIX."master_values mv join
".TABLE_PREFIX."master m on m.id = mv.masterID where
m.Name = 'permissions' and mv.value ='Super Admin')
THEN concat('<table width=\"100%\"><tr><td align=\"left\">','Yes','</td></tr></table>') else concat('<table width=\"100%\"><tr><td align=\"left\">','No','</td></tr></table>') end as permission,concat(u.firstname,' ',u.lastname) as `Name`,' ' as LastLogin, u.username as username,
concat('<a href=\"mailto:',u.Email,'\">',u.Email,'</a>') as email, ur.roleid as role from ".TABLE_PREFIX."users u join
".TABLE_PREFIX."users_in_roles ur on u.id=ur.userid and
ur.roleid =(select id from ".TABLE_PREFIX."roles where name='admin')
left join ".TABLE_PREFIX."users_permissions up on u.id=up.userid where username like ('".$lsSearchLetter."%') group by u.id";
// execute the sql query
// echo $sql;
$db->execute($sql);
// creates a new phpSortColumn object for ID´s
//$col_0 = new phpSortColumn("id", "ID");
//creates a new phpSortcolunm objects for name
$col_0 = new phpSortColumn("username", "Admin");
// $col_1 = new phpSortColumn("Name", "Name");
// creates a new phpSortColumn object for Tile
$col_2 = new phpSortColumn("email", "Email");
// creates a new phpSortColumn object for Field Type
// $col_3 = new phpSortColumn("LastLogin", "Last Login");
// creates a new phpSortColumn object for Desplay Type
$col_3 = new phpSortColumn("permission", "Super User");
// creates a new phpSortColumn object for validation function
// add the columns to an array
$columns = array(0=>$col_0, 2=>$col_2, 3=>$col_3);
// create a new phpSortable object with the abstracted db object
// and the array of column object
$sortable = new phpSortable($db, $columns);
$sortable->sortby = 'username';
$sortable->sortdir = 'asc';
// define the table format: cellpadding, cellspacing, border
$sortable->setTableFormat ("2", "2", "0");
// define the table title
$sortable->tableTitle = "";
// define the link for edit of entries
$sortable->editLink = "admin_admin_m.php?action=edit";
// Encrypt Edit and Delete Link
$sortable->encryptlink = false;
// open the edit page in a new window
//$sortable->editTarget = "_blank";
// window format for the edit page
// $sortable->editWindowFormat = "'width=300,height=400'";
// define the link for delete of entries
$quest="&";
if(isset($_GET) && !empty($_GET))
{
foreach($_GET as $keyname => $value) {
$quest.=$keyname."=".$value."&";
}
}
$sortable->deleteLink = "admin_admin_m.php?action=delete$quest";
// define the link for add new entries
$sortable->addLink = "admin_admin_m.php";
// set visibility of add,edit,delete link of the grid
if($users->IsAdminhavePermission($_SESSION[SESSION_PREFIX.'Admin_UserID'],'Can add admins')==false)
{
$sortable->showaddLink=false;
}
if($users->IsAdminhavePermission($_SESSION[SESSION_PREFIX.'Admin_UserID'],'Can edit admins')==false)
{
$sortable->showeditLink=false;
}
if($users->IsAdminhavePermission($_SESSION[SESSION_PREFIX.'Admin_UserID'],'Can delete admins')==false)
{
$sortable->showdeleteLink=false;
}
// define the hint to be displyed over the add button
$sortable->addText = "Add New Admin";
// define the key name to be attached to links
$sortable->urlKeyName = "id";
// define the column name of to be attached to links as key value
$sortable->tableKeyName = "id";
// define the prompt message to be diplayed on clicking the edit button
//$sortable->editPromptMsg = "Are you sure you want to edit this affiliate?";
// define the prompt message to be diplayed on clicking the delete button
$sortable->deletePromptMsg = "Are you sure you want to delete this Admin?";
// define the message to be diplayed if there are no results found
$sortable->emptyMsg = "No Admin found.";
//define the deafult row number to be displayed
$sortable->defaultRowsNum = "10";
//define the path for the css file
$sortable->cssFilePath = ADMIN_CSS_DIR."/phpSortable.css";
//define the path for of the images directory
$sortable->imgFilePath = ADMIN_IMAGE_DIR."/phpgrid/";
// print the table
$sortable->printTable();
echo '
<script language="javascript" type="text/javascript">
var $rn = jQuery.noConflict();
var obj =$rn(" table tr:contains(\'admin\')");
$rn(obj).find("td").eq(5).html("");
/*
------------- or loop through tr and find administrator td ---------------
$rn(".contentTable tr").each(function() {
var value=trim($rn(this).find("td").eq(0).html().toUpperCase());
if(value=="ADMINISTRATOR")
$rn(this).find("td").eq(5).html("")
}); */
</script>
';
echo "</div>";
echo "</div>";
echo "</div>";
//For display footer.php
echo($smarty->fetch('admin_footer.php'));
}
?>