X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=user_delete.php;h=38d4f5424bc8f30efe151ad34da43ca62204a2ae;hb=c75f863a12ab28d8f828c0cc367b581b396ee951;hp=97b255725298e6b8e65a7df26e31b21160cc923b;hpb=6c7a98f61e74aeae700b523729abb49ff19d3704;p=timetracker.git diff --git a/user_delete.php b/user_delete.php index 97b25572..38d4f542 100644 --- a/user_delete.php +++ b/user_delete.php @@ -28,41 +28,32 @@ require_once('initialize.php'); import('form.Form'); -import('ttUserHelper'); +import('ttUser'); -// Access check. +// Access checks. if (!ttAccessAllowed('manage_users')) { header('Location: access_denied.php'); exit(); } - -// Get user id we are deleting from the request. -// A cast to int is for safety against manipulation of request parameter (sql injection). -$user_id = (int) $request->getParameter('id'); -// We need user name and login to display. -$user_details = ttUserHelper::getUserDetails($user_id); - -// Security checks. -if (!$user_details || // No details. - $user_details['team_id'] <> $user->team_id || // User not in team. - $user_details['rank'] > $user->rank || // User has a bigger rank. - ($user_details['rank'] == $user->rank && $user_details['id'] <> $user->id) // Same rank but not us. - ) { +$user_id = (int)$request->getParameter('id'); +$user_details = $user->getUserDetails($user_id); +if (!$user_details) { header('Location: access_denied.php'); exit(); } +// End of access checks. $smarty->assign('user_to_delete', $user_details['name']." (".$user_details['login'].")"); // Create confirmation form. $form = new Form('userDeleteForm'); $form->addInput(array('type'=>'hidden','name'=>'id','value'=>$user_id)); -$form->addInput(array('type'=>'submit','name'=>'btn_delete','value'=>$i18n->getKey('label.delete'))); -$form->addInput(array('type'=>'submit','name'=>'btn_cancel','value'=>$i18n->getKey('button.cancel'))); +$form->addInput(array('type'=>'submit','name'=>'btn_delete','value'=>$i18n->get('label.delete'))); +$form->addInput(array('type'=>'submit','name'=>'btn_cancel','value'=>$i18n->get('button.cancel'))); if ($request->isPost()) { if ($request->getParameter('btn_delete')) { - if (ttUserHelper::markDeleted($user_id)) { + if ($user->markUserDeleted($user_id)) { // If we deleted the "on behalf" user reset its info in session. if ($user_id == $user->behalf_id) { unset($_SESSION['behalf_id']); @@ -81,7 +72,7 @@ if ($request->isPost()) { } exit(); } else { - $err->add($i18n->getKey('error.db')); + $err->add($i18n->get('error.db')); } } if ($request->getParameter('btn_cancel')) { @@ -91,6 +82,6 @@ if ($request->isPost()) { } // isPost $smarty->assign('forms', array($form->getName()=>$form->toArray())); -$smarty->assign('title', $i18n->getKey('title.delete_user')); +$smarty->assign('title', $i18n->get('title.delete_user')); $smarty->assign('content_page_name', 'user_delete.tpl'); $smarty->display('index.tpl');