X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=user_add.php;h=28baa2cf5065783684f9acafee80fc2a2bd3077a;hb=54bb71ed8e6b7f79e3b26bc1c8a70a95793950c8;hp=b235cbd17eb81817da85f686b63af2dfbd380319;hpb=11bfec0ff88b649a934556e8b4812d65715c7509;p=timetracker.git diff --git a/user_add.php b/user_add.php index b235cbd1..28baa2cf 100644 --- a/user_add.php +++ b/user_add.php @@ -29,6 +29,7 @@ require_once('initialize.php'); import('form.Form'); import('ttTeamHelper'); +import('ttGroupHelper'); import('ttUserHelper'); import('form.Table'); import('form.TableColumn'); @@ -42,11 +43,11 @@ if (!ttAccessAllowed('manage_users')) { // End of access checks. // Use the "limit" plugin if we have one. Ignore include errors. -// The "limit" plugin is not required for normal operation of the Time Tracker. +// The "limit" plugin is not required for normal operation of Time Tracker. @include('plugins/limit/user_add.php'); if ($user->isPluginEnabled('cl')) - $clients = ttTeamHelper::getActiveClients($user->team_id); + $clients = ttGroupHelper::getActiveClients(); $assigned_projects = array(); if ($request->isPost()) { @@ -90,7 +91,7 @@ if ($user->isPluginEnabled('cl')) $form->addInput(array('type'=>'floatfield','maxlength'=>'10','name'=>'rate','format'=>'.2','value'=>$cl_rate)); -$projects = ttTeamHelper::getActiveProjects($user->team_id); +$projects = ttGroupHelper::getActiveProjects(); // Define classes for the projects table. class NameCellRenderer extends DefaultCellRenderer { @@ -150,12 +151,19 @@ if ($request->isPost()) { 'login' => $cl_login, 'password' => $cl_password1, 'rate' => $cl_rate, - 'team_id' => $user->team_id, + 'group_id' => $user->getGroup(), + 'org_id' => $user->org_id, 'role_id' => $cl_role_id, 'client_id' => $cl_client_id, 'projects' => $assigned_projects, 'email' => $cl_email); - if (ttUserHelper::insert($fields)) { + $user_id = ttUserHelper::insert($fields); + if ($user_id) { + if (!$user->exists()) { + // We added a user to an empty subgroup. Set new user as on behalf user. + // Needed for user-based things to work (such as notifications config). + $user->setOnBehalfUser($user_id); + } header('Location: users.php'); exit(); } else @@ -168,6 +176,7 @@ if ($request->isPost()) { $smarty->assign('auth_external', $auth->isPasswordExternal()); $smarty->assign('active_roles', $active_roles); $smarty->assign('forms', array($form->getName()=>$form->toArray())); +$smarty->assign('show_projects', count($projects) > 0); $smarty->assign('onload', 'onLoad="document.userForm.name.focus();handleClientControl();"'); $smarty->assign('title', $i18n->get('title.add_user')); $smarty->assign('content_page_name', 'user_add.tpl');