From: Nik Okuntseff Date: Fri, 2 Nov 2018 21:47:41 +0000 (+0000) Subject: More work in progress on subgroups. X-Git-Tag: timetracker_1.19-1~726 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=b4be5795ddbcef63b4b6fffb200c3dfc3ffcb530;p=timetracker.git More work in progress on subgroups. --- diff --git a/WEB-INF/lib/ttRegistrator.class.php b/WEB-INF/lib/ttRegistrator.class.php index 48f4b0aa..b3551dad 100644 --- a/WEB-INF/lib/ttRegistrator.class.php +++ b/WEB-INF/lib/ttRegistrator.class.php @@ -159,9 +159,9 @@ class ttRegistrator { $email = $mdb2->quote($this->email); $created = 'now()'; $created_ip = $mdb2->quote($_SERVER['REMOTE_ADDR']); - $values = "values($login, $password, $name, $this->group_id, $this->role_id, $email, $created, $created_ip)"; + $values = "values($login, $password, $name, $this->group_id, $this->group_id, $this->role_id, $email, $created, $created_ip)"; - $sql = 'insert into tt_users (login, password, name, group_id, role_id, email, created, created_ip) '.$values; + $sql = 'insert into tt_users (login, password, name, group_id, org_id, role_id, email, created, created_ip) '.$values; $affected = $mdb2->exec($sql); if (!is_a($affected, 'PEAR_Error')) { $user_id = $mdb2->lastInsertID('tt_users', 'id'); diff --git a/WEB-INF/lib/ttUserHelper.class.php b/WEB-INF/lib/ttUserHelper.class.php index 521bc8b7..28175080 100644 --- a/WEB-INF/lib/ttUserHelper.class.php +++ b/WEB-INF/lib/ttUserHelper.class.php @@ -102,6 +102,7 @@ class ttUserHelper { $password = 'md5('.$password.')'; $email = isset($fields['email']) ? $fields['email'] : ''; $group_id = (int) $fields['group_id']; + $org_id = (int) $fields['org_id']; $rate = str_replace(',', '.', isset($fields['rate']) ? $fields['rate'] : 0); if($rate == '') $rate = 0; @@ -112,9 +113,9 @@ class ttUserHelper { $created_ip_v = ', '.$mdb2->quote($_SERVER['REMOTE_ADDR']); $created_by_v = ', '.$mdb2->quote($user->id); - $sql = "insert into tt_users (name, login, password, group_id, role_id, client_id, rate, email, created, created_ip, created_by $status_f) values (". + $sql = "insert into tt_users (name, login, password, group_id, org_id, role_id, client_id, rate, email, created, created_ip, created_by $status_f) values (". $mdb2->quote($fields['name']).", ".$mdb2->quote($fields['login']). - ", $password, $group_id, ".$mdb2->quote($fields['role_id']).", ".$mdb2->quote($fields['client_id']).", $rate, ".$mdb2->quote($email).", now() $created_ip_v $created_by_v $status_v)"; + ", $password, $group_id, $org_id, ".$mdb2->quote($fields['role_id']).", ".$mdb2->quote($fields['client_id']).", $rate, ".$mdb2->quote($email).", now() $created_ip_v $created_by_v $status_v)"; $affected = $mdb2->exec($sql); // Now deal with project assignment. diff --git a/dbinstall.php b/dbinstall.php index 9e71651e..5baff57e 100644 --- a/dbinstall.php +++ b/dbinstall.php @@ -963,8 +963,11 @@ if ($_POST) { setChange("UPDATE `tt_site_config` SET param_value = '1.18.00', modified = now() where param_name = 'version_db' and param_value = '1.17.97'"); setChange("create index log_idx on tt_custom_field_log(log_id)"); setChange("UPDATE `tt_site_config` SET param_value = '1.18.05', modified = now() where param_name = 'version_db' and param_value = '1.18.00'"); - setChange("update `tt_groups` inner join `tt_site_config` sc on (sc.param_name = 'version_db' and sc.param_value = '1.18.05') set org_id = id where org_id is null"); + setChange("UPDATE `tt_groups` inner join `tt_site_config` sc on (sc.param_name = 'version_db' and sc.param_value = '1.18.05') set org_id = id where org_id is null"); setChange("UPDATE `tt_site_config` SET param_value = '1.18.06', modified = now() where param_name = 'version_db' and param_value = '1.18.05'"); + setChange("ALTER TABLE `tt_users` ADD `org_id` int(11) default NULL AFTER `group_id`"); + setChange("UPDATE `tt_users` inner join `tt_site_config` sc on (sc.param_name = 'version_db' and sc.param_value = '1.18.06') set org_id = group_id where org_id is null"); + setChange("UPDATE `tt_site_config` SET param_value = '1.18.07', modified = now() where param_name = 'version_db' and param_value = '1.18.06'"); } if ($_POST["cleanup"]) { diff --git a/mysql.sql b/mysql.sql index 3c2b786a..bfa26a0d 100644 --- a/mysql.sql +++ b/mysql.sql @@ -85,6 +85,7 @@ CREATE TABLE `tt_users` ( `password` varchar(50) default NULL, # password hash `name` varchar(100) default NULL, # user name `group_id` int(11) NOT NULL, # group id + `org_id` int(11) default NULL, # organization id `role_id` int(11) default NULL, # role id `client_id` int(11) default NULL, # client id for "client" user role `rate` float(6,2) NOT NULL default '0.00', # default hourly rate @@ -104,7 +105,7 @@ CREATE TABLE `tt_users` ( # Create an index that guarantees unique active and inactive logins. create unique index login_idx on tt_users(login, status); -# Create admin account with password 'secret'. Admin is a superuser, who can create groupd. +# Create admin account with password 'secret'. Admin is a superuser who can create groups. DELETE from `tt_users` WHERE login = 'admin'; INSERT INTO `tt_users` (`login`, `password`, `name`, `group_id`, `role_id`) VALUES ('admin', md5('secret'), 'Admin', '0', (select id from tt_roles where rank = 1024)); @@ -458,4 +459,4 @@ CREATE TABLE `tt_site_config` ( PRIMARY KEY (`param_name`) ); -INSERT INTO `tt_site_config` (`param_name`, `param_value`, `created`) VALUES ('version_db', '1.18.06', now()); # TODO: change when structure changes. +INSERT INTO `tt_site_config` (`param_name`, `param_value`, `created`) VALUES ('version_db', '1.18.07', now()); # TODO: change when structure changes. diff --git a/user_add.php b/user_add.php index 1ed0cb72..ac2d8c4e 100644 --- a/user_add.php +++ b/user_add.php @@ -150,7 +150,8 @@ if ($request->isPost()) { 'login' => $cl_login, 'password' => $cl_password1, 'rate' => $cl_rate, - 'group_id' => $user->group_id, + 'group_id' => $user->group_id, // TODO: this needs to be fixed for on-behalf group work. + 'org_id' => $user->org_id, 'role_id' => $cl_role_id, 'client_id' => $cl_client_id, 'projects' => $assigned_projects,