44 function add_user($User, $Desc, $Seed, $Hash, $Perm, $Email, $Email_notify,
45 $agentList, $Folder, $default_bucketpool_fk=
'')
48 $dbManager = $container->get(
'db.manager');
50 if (empty($default_bucketpool_fk)) {
51 $default_bucketpool_fk = null;
54 $dbManager->prepare($stmt=
'users.insert',$sql=
"INSERT INTO users 55 (user_name,user_desc,user_seed,user_pass,user_perm,user_email, 56 email_notify,user_agent_list,root_folder_fk) VALUES ($1,$2,$3,$4,$5,$6, $7,$8,$9)");
57 $dbManager->execute($stmt,array ($User,$Desc,$Seed,$Hash,$Perm,$Email, $Email_notify,$agentList,$Folder));
60 $row = $dbManager->getSingleRow(
"SELECT * FROM users WHERE user_name = $1",array($User),$stmt=
'users.get');
61 if (empty($row[
'user_name'])) {
62 $text = _(
"Failed to insert user.");
67 $user_name = $row[
'user_name'];
68 $user_pk = $row[
'user_pk'];
70 $dbManager->prepare($stmt=
'group.get', $sql =
"select group_pk from groups where LOWER(group_name)=LOWER($1)");
71 $verg = $dbManager->execute(
'group.get',array($user_name));
72 $GroupRow = $dbManager->fetchArray($verg);
73 if (
false === $GroupRow) {
74 $dbManager->getSingleRow(
'insert into groups(group_name) values ($1)',
76 $GroupRow = $dbManager->fetchArray(
77 $dbManager->execute(
'group.get', array($user_name)));
80 $group_pk = $GroupRow[
'group_pk'];
82 $dbManager->getSingleRow($sql=
"insert into group_user_member (group_fk, user_fk, group_perm) values ($1,$2,$3)",
83 $param=array($group_pk, $user_pk, 1),$stmt=
'groupmember.insert');
85 $dbManager->prepare($stmt=
'users.update', $sql =
"update users SET group_fk=$1, default_bucketpool_fk=$3 WHERE user_pk=$2");
86 $dbManager->execute($stmt,array($group_pk,$user_pk,$default_bucketpool_fk));
add_user($User, $Desc, $Seed, $Hash, $Perm, $Email, $Email_notify, $agentList, $Folder, $default_bucketpool_fk='')
Add a user.