Location: PHPKode > projects > Netautor Professional > netautor/napro4/admin/user/usermanager.php
<?php
/* +----------------------------------------------------------------------+
   | Netautor Professional Application Server                             |
   +----------------------------------------------------------------------+
   | Copyright (C) 1998-2005 digiconcept GmbH. <www.digiconcept.net>      |
   +----------------------------------------------------------------------+
   | This file is subject to license, that is bundled with this package   |
   | in the file LICENSE.TXT, and is available at through the             |
   | world-wide-web at http://www.netautor.com/license/                   |
   |                                                                      |
   | If you did not receive a copy of the license and are unable to       |
   | obtain it through the world-wide-web, please send a note to          |
   | hide@address.com so we can mail you a copy.                      |
   +----------------------------------------------------------------------+
   | Authors: Stefan Rottensteiner <hide@address.com>    |
   |          Marek  Kadziela      <hide@address.com>	      |
   |          Gregor Wollner                                              |
   |          Christian Unger                                             |
   |          Helli  Kleinhans  									      |
   +----------------------------------------------------------------------+
   | @version	$Revision: 1.20 $										  |
   +----------------------------------------------------------------------+*/

/**
 * User manager - executiv part.
 *
 * @author Helmut Kleinhans
 * @author Stefan Rottensteiner
 * @author Gregor Wollner
 */

require_once('../../include/init.inc');
if(!$GLOBALS['USER']->check_feature('Admin') && !$GLOBALS['USER']->check_feature('ac_user'))
{
	$GLOBALS['USER']->login_call();
}

includeNaPro('form');

$GLOBALS['LOCALE']->textdomain('user');

function makeFeatureInput(&$workUser,$area)
{

	global $LOCALE;
	global $user;

	$booleanSelection = array(
							''	=>$LOCALE->gettext('inherit') ,
							'0'	=>$LOCALE->gettext('unset') ,
							'1'	=>$LOCALE->gettext('set')
						);

	$features = feature::getFeatureList($GLOBALS['sql_world'],$area);

	foreach($features as $ft_id=>$ft_data)
	{
		if($ft_data['ft_type']==5) //BOOLEAN
		{
			?>
			<tr class="bglistgrey">
				<td align="left" valign="top" class="text">
					<?php echo($ft_data['ft_name']);?><br>
				</td>
				<td align="left" valign="top" class="text">
					<select class="select66" name="user[fto][<?php echo($ft_id);?>][0]">
						<?php echo( makeOptions($booleanSelection,$user['fto'][$ft_id][0]) ); ?>
					</select><br>
				</td>
				<td align="left" valign="top" class="text">
					<img src="../../grafik/pixel.gif" width="1" height="2"><br>
					<?php if (!empty($ft_data['ft_remark'])) echo("({$ft_data['ft_remark']})");?>
					<br>
				</td>
			</tr>
			<?php
		}
		else
		{
			?>
			<tr class="bglistgrey">
				<td align="left" valign="top" class="text">
					<?php echo($ft_data['ft_name']);?><br>
				</td>
				<td colspan="2" align="left" valign="top" class="text">
			<?php
				if(empty($user['fto'][$ft_id])) $user['fto'][$ft_id][0]='';
				foreach($user['fto'][$ft_id] as $idx=>$ft_value)
				{
					?>
					<input type="text" name="<?php echo("user[fto][$ft_id][$idx]"); ?>" class="input252" value="<?php echo($user['fto'][$ft_id][$idx]); ?>">
					<?php 
						if($ft_data['ft_multiple'])
						{
							if($idx < 1)
								echo('<a href="javascript:addFeature('.$ft_id.')"><img src="../../grafik/na_plus.gif"  border="0"></a>'."\n");

							if($idx > 0 && $idx == count($user['fto'][$ft_id])-1 ) 
								echo('<a href="javascript:delFeature('.$ft_id.')"><img src="../../grafik/na_minus.gif" border="0"></a>'."\n");
						}	?>
					<br>
			<?php	
				}
				if (!empty($ft_data['ft_remark']))	echo("({$ft_data['ft_remark']})");
			?><br>
				</td>
			</tr>
			<?php
		}
	}

}

//init
function init()
{
	$user = array(
					'name'		=>'',
					'passwd'	=>'',
					'passwd2'	=>'',
					'email'		=>'',
					'member'	=>array(),
					'remark'	=>'',
					'id'		=>'',
					'login'		=>'1',
					'group'		=>'0'
					);
	return $user;
}

if(empty($user))
{
	$user = init();
}

@$adminSessionData = & $_SESSION['adminSessionData'];

if(!empty($user_id))
{
	$adminSessionData = array();

	$workUser = new users($sql_world,$user_id);
	$workUser->users_load();

	$data = $workUser->user_to_array();

	$user['id'] = $user_id;
	$user['name'] = $data['user_name'	];
	$user['email'] = $data['user_email'	];
	$user['remark'] = $data['user_remark'];
	$user['group'] = $data['user_group'	];
	$user['login'] = $data['user_login'	];
	$user['member'] = $data['user_member'];
	$user['fto'] = $workUser->users_feature_load();

	$adminSessionData = $user;
}

// Ein Feature hinzufügen.
if(!empty($addFeature))
{
	$user['fto'][$addFeature][]='';
}

// Ein Feature wegnehmen.
if(!empty($delFeature))
{
	array_pop($user['fto'][$delFeature]);
}

// Werte der Features setzten.
if(!empty($user['fto']))
{
	foreach($user['fto'] as $ft_id => $fto_value)
	{
		$adminSessionData['fto'][$ft_id] = $fto_value;
	}
}

// Werte der Features übernehmen?
if(!empty($adminSessionData['fto']))
{
	foreach($adminSessionData['fto'] as $ft_id=>$fto_value)
	{
		if(empty($user['fto'][$ft_id]))
		{
			$user['fto'][$ft_id] = $fto_value;
		}
	}
}

//*********************************************************************** CREATE / UPDATE Account
if(!empty($save))
{
	if(empty($user['group']) && $user['passwd']!=$user['passwd2'])
	{
		$message=$GLOBALS['LOCALE']->gettext('passwdNotMatch');
	}
	else if(empty($user['name']))
	{
		$message = $GLOBALS['LOCALE']->gettext('nameEmpty');
	}
	else if(empty($user['group']) && empty($user['passwd']) && empty($user['id']))
	{
		$message = $GLOBALS['LOCALE']->gettext('passwdEmpty');
	}
	else 
	{
		if(empty($user['member']) || !empty($user['group'])) 
		{
			$user['member']=array();
		}

		$workUser = new users(	$sql_world,
								$user['id'],
								$user['name'],
								$user['passwd'],
								$user['login'],
								$user['group'],
								$user['email'],
								$user['remark'],
								$user['member']
							);

		$success = $workUser->user_save();

		if ($success)
		{
			if(!empty($user['fto']))
			{
				$workUser->users_feature_save($user['fto']);

				includeNaPro('write_pool',true);
				write_pool($sql_world,$DC_ENV);
			}
			$message = $GLOBALS['LOCALE']->gettext('user'.(empty($user['id'])?'Create':'Update').'Ok');
		}
		else
		{
			$message = $GLOBALS['LOCALE']->gettext('user'.(empty($user['id'])?'Create':'Update').'Failed');
		}

		if(empty($user['id']))	$user['id'] = $workUser->user_get_id();
	}
}

//*********************************************************************** DELETE Account
if (!empty($delete) && !empty($user['id']) )
{
	$workUser = new users($sql_world,$user['id']);

	if( $workUser->user_kill() )
	{
		$user 		= init();
		$message 	= $GLOBALS['LOCALE']->gettext('userDeleteOk');
	}
	else
	{
		$message 	= $GLOBALS['LOCALE']->gettext('userDeleteFaild');
	}
}

//*********************************************************************** CLEAR form
if(!empty($new))
{
	$user = init();
	$adminSessionData = $user;
}

include 'usermanager.msk';

?>
Return current item: Netautor Professional