All pastes #801459 Raw Edit

Untitled

public text v1 · immutable
#801459 ·published 2007-11-29 08:44 UTC
rendered paste body
<?php


include '_common.php';

if (!$objUser->checkLevel(1)) {
    Tzn::redirect('logout.php','ERROR:'.$langMessage['denied']);
}

$pLink = 'users.php';
$pPageIsPublic = false;
$pUserCanEdit = false;

// --- LOAD USERS -----------------------------------------------

/* --- DELETE USER ------------------------------------------------- */

if ($_REQUEST['mode']) {
	$objItem = new User();
	$objItem->setUid($_REQUEST['mode']);
	if ($objItem->id) {
		$objItem->load();
        if ((($objUser->checkLevel(3)) || ($objUser->id == $objItem->author->id)) 
            && ($objUser->id != $objItem->id))
        {
            // user is administrator or creator of user and not himself
            if ($objItem->enabled) {
                $objItem->enabled = 0;
            } else {
                $objItem->enabled = 1;
            }
            $objItem->update('enabled');
            //Tzn::redirect('user_list.php');
        }
	}
}

if ($_REQUEST['delete']) {
	$objItem = new User();
	$objItem->setUid($_REQUEST['delete']);
	if ($objItem->id) {
        if (($objUser->checkLevel(3)) && ($objUser->id != $objItem->id)) {
            // user is administrator and is not himself
            $objItem->delete();
            //Tzn::redirect('user_list.php');
        }
	}
}

/* --- LOAD USERS --------------------------------------------------- */

$objUserList = new User();

// --- search criterions ---

if ($sName = $_REQUEST['keyword']) {
	if (ereg('^".*"$',$sName)) {
		$hParam = str_replace('"','',$sName);
	} else if (ereg('\*',$iName)) {
		$hParam = str_replace('*','%',$sName);
	} else {
		$hParam = '%'.str_replace(' ','%',$sName).'%';
	}
	$objUserList->addWhere("(CONCAT(firstName,' ',middleName,' ',lastName) LIKE '$hParam' "
		."OR  username LIKE '$hParam')");
}

if ($sCountry = Tzn::getReg($_REQUEST['country'],'^[A-Z]+$')) {
	$objUserList->addWhere("user.countryId='".$sCountry."'");
}

if ($sState = Tzn::getReg($_REQUEST['state'],'^[A-Z]+$')) {
	$objUserList->addWhere("user.stateCode='".$sState."'");
}

// --- load ---

$objUserList->addOrder('level DESC,lastName ASC');
$objUserList->loadList();

// --- INIT POSITIONS --------
$objPositionList = new GlobalPositionList();

/* --- HTML ----------------------------------------------------------- */

$pageJScript = 'common.js';




// === HTML ===================================================================

$pJScalendar=true; 
$pJSonLoad='synczy_highlist();';
$pJSonDown='listenClickUsers(event);';
$pJSxajax='user_load_view,user_load_more,user_load_edit,user_update_full' ; 

include PRJ_INCLUDE_PATH.'html/header.php';
// -------------- ACTIVITY LIST (HEADER) ------------------------------------------

?>


<table cellspacing="1" cellpadding="2" border="0" width="100%" class="sheet">
		<thead>
			<tr align="left">
				<th  colspan=5 align="center"><font color="black">Manage Users</font></th>
			</tr>
			<tr align="left">
				<th width="25%"><?php echo $langUser['user']; ?></th>
				<th width="25%"><?php echo $langUser['location']; ?></th>
                <th width="10%"><?php echo $langUser['position']; ?></th>
                <th width="20%"><?php echo $langUser['last_login']; ?></th>
				<th width="10%" style="text-align:center"><?php
                if ($objUser->checkLevel(2)) {
                    ?><a href="javascript:synczy_user_new()"><img src="skins/<?php echo SYNCZY_SKIN_FOLDER; ?>/images/b_new.png" width="55" height="16" border="0" hspace="3" alt="<?php echo $langForm['new']; ?>" /></a><?php
                } else {
                    echo $langUser['action'];
                }
                ?></th>
			</tr>
		</thead>
		<tbody>
		<?php
		while ($objItem = $objUserList->rNext()) {
            if ($objItem->enabled) {
                $rowStyle = '';
                $imgStatus = 'ena';
            } else {
                $rowStyle = ' class="disabled"';
                $imgStatus = 'dis';
            }
		?>
			<tr id="<?php echo $objItem->id; ?>" <?php echo $rowStyle; ?>>
				<td><?php echo $objItem->getName();?></a></td>
				<td><?php echo $objItem->getLocation(); ?></td>
                <td><?php echo $objPositionList->getPosition($objItem->level); ?></td>
                <td><?php echo $objItem->getDtm('lastLoginDate','SHX','user','-'); ?></td>
				<td align="center">
                    <?php
                    if (($objUser->checkLevel(3)) || ($objUser->id == $objItem->id) || ($objUser->id == $objItem->author->id)) {
                        if ($objUser->id != $objItem->id) {
                    ?>
                    <a href="<?php echo Tzn::concatUrl($pLink,'mode='.$objItem->id); ?>" onclick="return confirm('<?php echo ($objItem->enabled)?$langUser['disable_confirm']:$langUser['enable_confirm']; ?>');"><img src="skins/<?php echo SYNCZY_SKIN_FOLDER; ?>/images/b_<?php echo $imgStatus; ?>y.png" width="20" height="16" border="0" Title = "Enable/Disable User"/></a>
                    <?php
                        } else {
                    ?>
                    <img src="skins/<?php echo SYNCZY_SKIN_FOLDER; ?>/images/b_<?php echo $imgStatus; ?>n.png" width="20" height="16" border="0" />
                    <?php
                        }
                    ?>
                    <a href="javascript:synczy_user_edit('<?php echo $objItem->id; ?>')"><img src="skins/<?php echo SYNCZY_SKIN_FOLDER; ?>/images/b_edit.png" width="16" height="16" border="0" title = "Edit User Information"/></a>
                    <?php
                    } else {
                    ?>
                    <img src="skins/<?php echo SYNCZY_SKIN_FOLDER; ?>/images/b_<?php echo $imgStatus; ?>n.png" width="16" height="16" border="0" />
                    <img src="skins/<?php echo SYNCZY_SKIN_FOLDER; ?>/images/b_edin.png" width="20" height="16" border="0" />
                    <?php
                    }
                    if ($objUser->checkLevel(5)) {
                    ?>
					<a href="<?php echo Tzn::concatUrl($pLink,'delete='.$objItem->id); ?>" onclick="return confirm('<?php echo $langUser['delete_confirm']; ?>');"><img src="skins/<?php echo SYNCZY_SKIN_FOLDER; ?>/images/b_dele.png" width="16" height="16" border="0" title = "Delete User"/></a>
                    <?php
                    } else {
                    ?>
                    <img src="skins/<?php echo SYNCZY_SKIN_FOLDER; ?>/images/b_deln.png" width="16" height="16" border="0" />
                    <?php
                    }
                    ?>
				</td>
			</tr>
		<?php
		}
		?>
		</tbody>
	</table>
	
<tr><td height=10 valign=top>
			<?php
include PRJ_INCLUDE_PATH.'html/footer.php';
?>