32 function add_user($User, $Desc, $Hash, $Perm, $Email, $Email_notify, $Upload_visibility,
33 $agentList, $Folder, $default_bucketpool_fk=
'')
36 $dbManager = $container->get(
'db.manager');
38 if (empty($default_bucketpool_fk)) {
39 $default_bucketpool_fk =
null;
42 $dbManager->prepare($stmt=
'users.insert',$sql=
"INSERT INTO users
43 (user_name,user_desc,user_seed,user_pass,user_perm,user_email,
44 email_notify,upload_visibility,user_agent_list,root_folder_fk,default_folder_fk) VALUES ($1,$2,$3,$4,$5,$6, $7,$8,$9,$10,$11)");
45 $dbManager->execute($stmt,array ($User,$Desc,
'Seed',$Hash,$Perm,$Email, $Email_notify,$Upload_visibility,$agentList,$Folder,$Folder));
48 $row = $dbManager->getSingleRow(
"SELECT * FROM users WHERE user_name = $1",array($User),$stmt=
'users.get');
49 if (empty($row[
'user_name'])) {
50 $text = _(
"Failed to insert user.");
55 $user_name = $row[
'user_name'];
56 $user_pk = $row[
'user_pk'];
58 $dbManager->prepare($stmt=
'group.get', $sql =
"select group_pk from groups where LOWER(group_name)=LOWER($1)");
59 $verg = $dbManager->execute(
'group.get',array($user_name));
60 $GroupRow = $dbManager->fetchArray($verg);
61 if (
false === $GroupRow) {
62 $dbManager->getSingleRow(
'insert into groups(group_name) values ($1)',
64 $GroupRow = $dbManager->fetchArray(
65 $dbManager->execute(
'group.get', array($user_name)));
68 $group_pk = $GroupRow[
'group_pk'];
70 $dbManager->getSingleRow($sql=
"insert into group_user_member (group_fk, user_fk, group_perm) values ($1,$2,$3)",
71 $param=array($group_pk, $user_pk, 1),$stmt=
'groupmember.insert');
73 $dbManager->prepare($stmt=
'users.update', $sql =
"update users SET group_fk=$1, default_bucketpool_fk=$3 WHERE user_pk=$2");
74 $dbManager->execute($stmt,array($group_pk,$user_pk,$default_bucketpool_fk));
89 $dbManager = $container->get(
'db.manager');
92 $row = $dbManager->getSingleRow(
"SELECT * FROM users WHERE user_name = $1",array($User),$stmt=
'users.get');
93 if (empty($row[
'user_name'])) {
94 $text = _(
"User does not exist.");
98 $dbManager->prepare($stmt =
'users.update_hash', $sql =
"UPDATE users SET user_seed = $1, user_pass = $2 WHERE user_name = $3");
99 $dbManager->execute($stmt,array (
'Seed', $Hash, $User));
update_password_hash($User, $Hash)
Update user password hash.
add_user($User, $Desc, $Hash, $Perm, $Email, $Email_notify, $Upload_visibility, $agentList, $Folder, $default_bucketpool_fk='')
Add a user.