$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');
$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;
$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.
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"]) {
`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
# 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));
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.
'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,