diff --git a/htdocs/langs/en_US/users.lang b/htdocs/langs/en_US/users.lang index fb1b2a3367b..f7478a3a57e 100755 --- a/htdocs/langs/en_US/users.lang +++ b/htdocs/langs/en_US/users.lang @@ -50,6 +50,10 @@ ShowGroup=Show group ShowUser=Show user NonAffectedUsers=Non affected users UserModified=User modified successfully +GroupModified=Group modified successfully PhotoFile=Fichier photo UserWithDolibarrAccess=User with Dolibarr access -ListOfUsersInGroup=List of users in group \ No newline at end of file +ListOfUsersInGroup=List of users in this group +ListOfGroupsForUser=List of groups for this user +UsersToAdd=Users to add to this group +GroupsToAdd=Groups to add to this user \ No newline at end of file diff --git a/htdocs/langs/fr_FR/users.lang b/htdocs/langs/fr_FR/users.lang index 66982e99f90..8f6a3a9e22b 100755 --- a/htdocs/langs/fr_FR/users.lang +++ b/htdocs/langs/fr_FR/users.lang @@ -50,6 +50,10 @@ ShowGroup=Afficher groupe ShowUser=Afficher utilisateur NonAffectedUsers=Utilisateurs non affectés au groupe UserModified=Utilisateur modifié avec succès +GroupModified=Groupe modifié avec succès PhotoFile=Fichier photo UserWithDolibarrAccess=Utilisateur avec accès Dolibarr -ListOfUsersInGroup=Liste des utilisateurs dans le groupe \ No newline at end of file +ListOfUsersInGroup=Liste des utilisateurs dans ce groupe +ListOfGroupsForUser=Liste des groupes pour cet utilisateur +UsersToAdd=Utilisateur à ajouter à ce groupe +GroupsToAdd=Groupes à ajouter pour cet utilisateur \ No newline at end of file diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php index 4282d3bb15e..9469fab8c1b 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -22,7 +22,8 @@ * $Source$ */ -/** \file htdocs/user/fiche.php +/** + \file htdocs/user/fiche.php \brief Onglet user et permissions de la fiche utilisateur \version $Revision$ */ @@ -43,89 +44,110 @@ $action=isset($_GET["action"])?$_GET["action"]:$_POST["action"]; */ if ($_GET["subaction"] == 'addrights' && $user->admin) { - $edituser = new User($db,$_GET["id"]); - $edituser->addrights($_GET["rights"]); + $edituser = new User($db,$_GET["id"]); + $edituser->addrights($_GET["rights"]); } if ($_GET["subaction"] == 'delrights' && $user->admin) { - $edituser = new User($db,$_GET["id"]); - $edituser->delrights($_GET["rights"]); + $edituser = new User($db,$_GET["id"]); + $edituser->delrights($_GET["rights"]); } if ($_POST["action"] == 'confirm_disable' && $_POST["confirm"] == "yes") { - if ($_GET["id"] <> $user->id) + if ($_GET["id"] <> $user->id) { - $edituser = new User($db, $_GET["id"]); - $edituser->fetch($_GET["id"]); - $edituser->disable(); - Header("Location: index.php"); + $edituser = new User($db, $_GET["id"]); + $edituser->fetch($_GET["id"]); + $edituser->disable(); + Header("Location: index.php"); } } if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes") { - if ($_GET["id"] <> $user->id) + if ($_GET["id"] <> $user->id) { - $edituser = new User($db, $_GET["id"]); - $edituser->fetch($_GET["id"]); - $edituser->delete(); - Header("Location: index.php"); + $edituser = new User($db, $_GET["id"]); + $edituser->fetch($_GET["id"]); + $edituser->delete(); + Header("Location: index.php"); } } - /** * Action ajout user */ if ($_POST["action"] == 'add' && $user->admin) { - $message=""; - if (! $_POST["nom"]) { - $message='
'.$langs->trans("NameNotDefined").'
'; - $action="create"; // Go back to create page - } - if (! $_POST["login"]) { - $message='
'.$langs->trans("LoginNotDefined").'
'; - $action="create"; // Go back to create page - } - - if (! $message) { - $edituser = new User($db,0); - - $edituser->nom = trim($_POST["nom"]); - $edituser->note = trim($_POST["note"]); - $edituser->prenom = trim($_POST["prenom"]); - $edituser->login = trim($_POST["login"]); - $edituser->email = trim($_POST["email"]); - $edituser->admin = trim($_POST["admin"]); - $edituser->webcal_login = trim($_POST["webcal_login"]); - - $db->begin(); - - $id = $edituser->create(); - - if ($id > 0) - { - if (isset($_POST['password']) && trim($_POST['password'])) - { - $edituser->password($user,trim($_POST['password']),$conf->password_encrypted); - } - - $db->commit(); - - Header("Location: fiche.php?id=$id"); - } - else - { - $db->rollback(); - - $message='
'.$langs->trans("ErrorLoginAlreadyExists",$edituser->login).'
'; + $message=""; + if (! $_POST["nom"]) { + $message='
'.$langs->trans("NameNotDefined").'
'; + $action="create"; // Go back to create page + } + if (! $_POST["login"]) { + $message='
'.$langs->trans("LoginNotDefined").'
'; $action="create"; // Go back to create page } - } + if (! $message) { + $edituser = new User($db,0); + + $edituser->nom = trim($_POST["nom"]); + $edituser->note = trim($_POST["note"]); + $edituser->prenom = trim($_POST["prenom"]); + $edituser->login = trim($_POST["login"]); + $edituser->email = trim($_POST["email"]); + $edituser->admin = trim($_POST["admin"]); + $edituser->webcal_login = trim($_POST["webcal_login"]); + + $db->begin(); + + $id = $edituser->create(); + + if ($id > 0) + { + if (isset($_POST['password']) && trim($_POST['password'])) + { + $edituser->password($user,trim($_POST['password']),$conf->password_encrypted); + } + + $db->commit(); + + Header("Location: fiche.php?id=$id"); + } + else + { + $db->rollback(); + + $message='
'.$langs->trans("ErrorLoginAlreadyExists",$edituser->login).'
'; + $action="create"; // Go back to create page + } + + } +} + +if ($_POST["action"] == 'addgroup' && $user->admin) +{ + if ($_POST["group"]) + { + $edituser = new User($db, $_GET["id"]); + $edituser->SetInGroup($_POST["group"]); + + Header("Location: fiche.php?id=".$_GET["id"]); + } +} + +if ($_GET["action"] == 'removegroup' && $user->admin) +{ + if ($_GET["group"]) + { + $edituser = new User($db, $_GET["id"]); + $edituser->RemoveFromGroup($_GET["group"]); + + Header("Location: fiche.php?id=".$_GET["id"]); + } } if ($_POST["action"] == 'update' && $user->admin) @@ -133,7 +155,7 @@ if ($_POST["action"] == 'update' && $user->admin) $message=""; $db->begin(); - + $edituser = new User($db, $_GET["id"]); $edituser->fetch(); @@ -168,7 +190,7 @@ if ($_POST["action"] == 'update' && $user->admin) $newfile=$conf->users->dir_output . "/" . $edituser->id . ".jpg"; if (! doliMoveFileUpload($_FILES['photo']['tmp_name'],$newfile)) { - $message .= '
'.$langs->trans("ErrorFailedToSaveFile").'
'; + $message .= '
'.$langs->trans("ErrorFailedToSaveFile").'
'; } } } @@ -184,310 +206,422 @@ if ($_POST["action"] == 'update' && $user->admin) if ($_GET["action"] == 'password' && $user->admin) { - $edituser = new User($db, $_GET["id"]); - $edituser->fetch(); + $edituser = new User($db, $_GET["id"]); + $edituser->fetch(); - if ($edituser->password($user,'',$conf->password_encrypted)) + if ($edituser->password($user,'',$conf->password_encrypted)) { - $message = '
'.$langs->trans("PasswordChangedAndSentTo",$edituser->email).'
'; + $message = '
'.$langs->trans("PasswordChangedAndSentTo",$edituser->email).'
'; } } -llxHeader('','Fiche Utilisateur'); +llxHeader('',$langs->trans("UserCard")); if ($action == 'create') { - /* ************************************************************************** */ - /* */ - /* Affichage fiche en mode création */ - /* */ - /* ************************************************************************** */ + /* ************************************************************************** */ + /* */ + /* Affichage fiche en mode création */ + /* */ + /* ************************************************************************** */ - print_titre($langs->trans("NewUser")); + print_titre($langs->trans("NewUser")); - print "
"; - if ($message) { print $message."
"; } + print "
"; + if ($message) { print $message."
"; } - print '
'; - print ''; + print ''; + print ''; - print ''; + print '
'; - print "".''; - print ''; + print "".''; + print ''; - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; - print ''; - print ''; + print ''; + print ''; - print ''; - print '\n"; + print ''; + print '\n"; - print '\n"; + print '\n"; - // Autres caractéristiques issus des autres modules - if ($conf->webcal->enabled) + // Autres caractéristiques issus des autres modules + if ($conf->webcal->enabled) { - print "".''; - print ''; + print "".''; + print ''; } - print "".''; - print ""; - print "
'.$langs->trans("Lastname").'
'.$langs->trans("Lastname").'
'.$langs->trans("Firstname").'
'.$langs->trans("Firstname").'
'.$langs->trans("Login").'
'.$langs->trans("Login").'
'.$langs->trans("Password").'
'.$langs->trans("Password").'
'.$langs->trans("EMail").'
'.$langs->trans("EMail").'
'.$langs->trans("Administrator").''; - $form->selectyesnonum('admin',0); - print "
'.$langs->trans("Administrator").''; + $form->selectyesnonum('admin',0); + print "
'.$langs->trans("Note").''; - print "
'.$langs->trans("Note").''; + print "
'.$langs->trans("LoginWebcal").'
'.$langs->trans("LoginWebcal").'
\n"; + print "".''; + print ""; + print "\n"; } else { - /* ************************************************************************** */ - /* */ - /* Visu et edition */ - /* */ - /* ************************************************************************** */ - - if ($_GET["id"]) + /* ************************************************************************** */ + /* */ + /* Visu et edition */ + /* */ + /* ************************************************************************** */ + + if ($_GET["id"]) { - $fuser = new User($db, $_GET["id"]); - $fuser->fetch(); - $fuser->getrights(); + $fuser = new User($db, $_GET["id"]); + $fuser->fetch(); + $fuser->getrights(); - /* - * Affichage onglets - */ - - $h = 0; - - $head[$h][0] = DOL_URL_ROOT.'/user/fiche.php?id='.$fuser->id; - $head[$h][1] = $langs->trans("UserCard"); - $hselected=$h; - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/user/perms.php?id='.$fuser->id; - $head[$h][1] = $langs->trans("UserRights"); - $h++; - - if ($conf->bookmark4u->enabled) + /* + * Affichage onglets + */ + + $h = 0; + + $head[$h][0] = DOL_URL_ROOT.'/user/fiche.php?id='.$fuser->id; + $head[$h][1] = $langs->trans("UserCard"); + $hselected=$h; + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/user/perms.php?id='.$fuser->id; + $head[$h][1] = $langs->trans("UserRights"); + $h++; + + if ($conf->bookmark4u->enabled) { - $head[$h][0] = DOL_URL_ROOT.'/user/addon.php?id='.$fuser->id; - $head[$h][1] = $langs->trans("Bookmark4u"); - $h++; - } - - dolibarr_fiche_head($head, $hselected, $langs->trans("User").": ".$fuser->fullname); - - - /* - * Confirmation désactivation - */ - if ($action == 'disable') - { - $html = new Form($db); - $html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("DisableAUser"),$langs->trans("ConfirmDisableUser",$fuser->login),"confirm_disable"); + $head[$h][0] = DOL_URL_ROOT.'/user/addon.php?id='.$fuser->id; + $head[$h][1] = $langs->trans("Bookmark4u"); + $h++; } - /* - * Confirmation suppression - */ - if ($action == 'delete') + dolibarr_fiche_head($head, $hselected, $langs->trans("User").": ".$fuser->fullname); + + + /* + * Confirmation désactivation + */ + if ($action == 'disable') { - $html = new Form($db); - $html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("DeleteAUser"),$langs->trans("ConfirmDeleteUser",$fuser->login),"confirm_delete"); + $html = new Form($db); + $html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("DisableAUser"),$langs->trans("ConfirmDisableUser",$fuser->login),"confirm_disable"); } - if ($_GET["action"] != 'edit') - { - /* - * Fiche en mode visu - */ - - print ''; - - print ''; - print ''; - print ''; + /* + * Confirmation suppression + */ + if ($action == 'delete') + { + $html = new Form($db); + $html->form_confirm("fiche.php?id=$fuser->id",$langs->trans("DeleteAUser"),$langs->trans("ConfirmDeleteUser",$fuser->login),"confirm_delete"); + } - print ''; - print ''; - print "\n"; - - print ''; - print ''; - print ''; - print ''; - print "\n"; - - print ''; - print ''; - print "\n"; + /* + * Fiche en mode visu + */ + if ($_GET["action"] != 'edit') + { + print '
'.$langs->trans("Lastname").''.$fuser->nom.''; - if (file_exists($conf->users->dir_output."/".$fuser->id.".jpg")) - { - print ''; - } - else - { - print ''; - } - print '
'.$langs->trans("Firstname").''.$fuser->prenom.'
'.$langs->trans("Login").''.$fuser->login.'
'.$langs->trans("EMail").''.$fuser->email.'
'.$langs->trans("Administrator").''.yn($fuser->admin).'
'; - print ''; - print ''; - print "\n"; - - print ''; - print ''; - print "\n"; - - print "".''; - print ''; + print ''; + print ''; - print "\n"; - - if ($fuser->societe_id > 0) - { - $societe = new Societe($db); - $societe->fetch($fuser->societe_id); - print "".''; - print ''; - print "\n"; - } + print ''; - print "".''; - print ''; - print "\n"; + print ''; + print ''; + print "\n"; - // Autres caractéristiques issus des autres modules - if ($conf->webcal->enabled) + print ''; + print ''; + + print ''; + print ''; + print "\n"; + + print ''; + print ''; + print "\n"; + + print ''; + print ''; + print "\n"; + + print ''; + print ''; + print "\n"; + + print "".''; + print ''; - print ''; - print "\n"; + print ''.$langs->trans("ContactCard").''; + } + else + { + print $langs->trans("NoContactCard"); + } + print ''; + print "\n"; + + if ($fuser->societe_id > 0) + { + $societe = new Societe($db); + $societe->fetch($fuser->societe_id); + print "".''; + print ''; + print "\n"; } - print "
'.$langs->trans("DateCreation").''.dolibarr_print_date($fuser->datec).'
'.$langs->trans("DateModification").''.dolibarr_print_date($fuser->datem).'
'.$langs->trans("ContactCard").''; - if ($fuser->contact_id) + print '
'.$langs->trans("Lastname").''.$fuser->nom.''; + if (file_exists($conf->users->dir_output."/".$fuser->id.".jpg")) { - print ''.$langs->trans("ContactCard").''; + print ''; } - else + else { - print $langs->trans("NoContactCard"); + print ''; } - print '
'.$langs->trans("Company").''.$societe->nom.' 
'.$langs->trans("Note").''.nl2br($fuser->note).' 
'.$langs->trans("Firstname").''.$fuser->prenom.'
'.$langs->trans("Login").''.$fuser->login.'
'.$langs->trans("EMail").''.$fuser->email.'
'.$langs->trans("Administrator").''.yn($fuser->admin).'
'.$langs->trans("DateCreation").''.dolibarr_print_date($fuser->datec).'
'.$langs->trans("DateModification").''.dolibarr_print_date($fuser->datem).'
'.$langs->trans("ContactCard").''; + if ($fuser->contact_id) { - $langs->load("other"); - print '
'.$langs->trans("LoginWebcal").''.$fuser->webcal_login.' 
'.$langs->trans("Company").''.$societe->nom.' 
\n"; - print "
\n"; - - print "\n"; + print "".''.$langs->trans("Note").''; + print ''.nl2br($fuser->note).' '; + print "\n"; - if ($message) { print $message; } - - /* - * Barre d'actions - * - */ - print '
'; - - if ($user->admin) + // Autres caractéristiques issus des autres modules + if ($conf->webcal->enabled) { - print ''.$langs->trans("Edit").''; + $langs->load("other"); + print ''.$langs->trans("LoginWebcal").''; + print ''.$fuser->webcal_login.' '; + print "\n"; } - if ($user->id == $_GET["id"] or $user->admin) + print "\n"; + print "
\n"; + + print "
\n"; + + if ($message) { print $message; } + + /* + * Barre d'actions + */ + print '
'; + + if ($user->admin) { - print ''.$langs->trans("SendNewPassword").''; + print ''.$langs->trans("Edit").''; } - if ($user->id <> $_GET["id"] && $user->admin) + if ($user->id == $_GET["id"] or $user->admin) { - print ''.$langs->trans("DisableUser").''; + print ''.$langs->trans("SendNewPassword").''; } - if ($user->id <> $_GET["id"] && $user->admin) + if ($user->id <> $_GET["id"] && $user->admin) { - print ''.$langs->trans("DeleteUser").''; + print ''.$langs->trans("DisableUser").''; } - print "
\n"; - print "
\n"; - - } - - /* - * Fiche en mode edition - */ - if ($_GET["action"] == 'edit' && $user->admin) + if ($user->id <> $_GET["id"] && $user->admin) + { + print ''.$langs->trans("DeleteUser").''; + } + + print "\n"; + print "
\n"; + + + + /* + * Liste des groupes dans lequel est l'utilisateur + */ + + print_titre($langs->trans("ListOfGroupsForUser")); + print "
\n"; + + // On sélectionne les groups + $uss = array(); + + $sql = "SELECT ug.rowid, ug.nom "; + $sql .= " FROM ".MAIN_DB_PREFIX."usergroup as ug "; + # $sql .= " LEFT JOIN llx_usergroup_user ug ON u.rowid = ug.fk_user"; + # $sql .= " WHERE ug.fk_usergroup IS NULL"; + $sql .= " ORDER BY ug.nom"; + + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows(); + $i = 0; + + while ($i < $num) + { + $obj = $db->fetch_object(); + + $uss[$obj->rowid] = $obj->nom; + $i++; + } + } + else { + dolibarr_print_error($db); + } + + if ($user->admin) + { + $form = new Form($db); + print '
'."\n"; + print ''; + print ''."\n"; + // print ''."\n"; + print ''."\n"; + print ''."\n"; + print '
'.$langs->trans("NonAffectedUsers").'
'.$langs->trans("GroupsToAdd").''; + print $form->select_array("group",$uss); + print '   '; + print ''; + print '
'."\n"; + } + + /* + * Groupes affectés + */ + $sql = "SELECT g.rowid, g.nom "; + $sql .= " FROM ".MAIN_DB_PREFIX."usergroup as g"; + $sql .= ",".MAIN_DB_PREFIX."usergroup_user as ug"; + $sql .= " WHERE ug.fk_usergroup = g.rowid"; + $sql .= " AND ug.fk_user = ".$_GET["id"]; + $sql .= " ORDER BY g.nom"; + + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + $i = 0; + + print '
'; + + print ''; + print ''; + print ''; + print "\n"; + + if ($num) { + $var=True; + while ($i < $num) + { + $obj = $db->fetch_object($result); + $var=!$var; + + print ""; + print ''; + print '\n"; + $i++; + } + } + else + { + print ''; + } + print "
'.$langs->trans("Group").' 
'; + print ''.img_object($langs->trans("ShowGroup"),"group").' '.$obj->nom.''; + print ''; + + if ($user->admin) + { + + print 'rowid.'">'; + print img_delete($langs->trans("RemoveFromGroup")); + } + else + { + print "-"; + } + print "
'.$langs->trans("None").'
"; + print "
"; + $db->free($result); + } + else { + dolibarr_print_error($db); + } + + } + + /* + * Fiche en mode edition + */ + if ($_GET["action"] == 'edit' && $user->admin) { - print '
'; - print ''; - print ''; + print ''; + print ''; + print '
'; - print ''; - print ''; - print ''; - - print "".''; - print ''; + print ''; + print ''; + print ''; - print "".''; - print ''; + print "".''; + print ''; - print "".''; - print ''; + print "".''; + print ''; - print "".''; - if ($fuser->societe_id > 0) - { - print ''; - } - else - { - print ''; - } + print "".''; + print ''; - print "".'"; + print "".''; + if ($fuser->societe_id > 0) + { + print ''; + } + else + { + print ''; + } - // Autres caractéristiques issus des autres modules - $langs->load("other"); - print "".''; - print ''; + print "".'"; - print ''; + // Autres caractéristiques issus des autres modules + $langs->load("other"); + print "".''; + print ''; - print '
'.$langs->trans("Lastname").''; - if (file_exists($conf->users->dir_output."/".$fuser->id.".jpg")) - { - print ''; - } - else - { - print ''; - } - print '

'.$langs->trans("PhotoFile").'
'; - print '
'.$langs->trans("Firstname").'
'.$langs->trans("Lastname").''; + if (file_exists($conf->users->dir_output."/".$fuser->id.".jpg")) + { + print ''; + } + else + { + print ''; + } + print '

'.$langs->trans("PhotoFile").'
'; + print '
'.$langs->trans("Login").'
'.$langs->trans("Firstname").'
'.$langs->trans("EMail").'
'.$langs->trans("Login").'
'.$langs->trans("Administrator").''; - print ''.$langs->trans("No"); - print '
'; - $form->selectyesnonum('admin',$fuser->admin); - print '
'.$langs->trans("EMail").'
'.$langs->trans("Note").''; - print '
'.$langs->trans("Administrator").''; + print ''.$langs->trans("No"); + print '
'; + $form->selectyesnonum('admin',$fuser->admin); + print '
'.$langs->trans("LoginWebcal").'
'.$langs->trans("Note").''; + print '
'.$langs->trans("LoginWebcal").'

'; - print '
'; - + print ''; + + print '
'; + print ''; } + } - } $db->close(); diff --git a/htdocs/user/group/fiche.php b/htdocs/user/group/fiche.php index 7fc95139df6..66e1b5238a6 100644 --- a/htdocs/user/group/fiche.php +++ b/htdocs/user/group/fiche.php @@ -104,7 +104,32 @@ if ($_GET["action"] == 'removeuser' && $user->admin) } } -llxHeader(); +if ($_POST["action"] == 'update' && $user->admin) +{ + $message=""; + + $db->begin(); + + $editgroup = new Usergroup($db, $_GET["id"]); + $editgroup->fetch($_GET["id"]); + + $editgroup->nom = $_POST["group"]; + $editgroup->note = $_POST["note"]; + + $ret=$editgroup->update(); + + if ($ret >= 0) { + $message.='
'.$langs->trans("GroupModified").'
'; + $db->commit(); + } else { + $message.='
'.$editgroup->error.'
'; + $db->rollback; + } + +} + + +llxHeader('',$langs->trans("GroupCard")); /* ************************************************************************** */ @@ -145,7 +170,7 @@ if ($action == 'create') /* ************************************************************************** */ else { - if ($_GET["id"]) + if ($_GET["id"] ) { $group = new UserGroup($db); $group->fetch($_GET["id"]); @@ -182,141 +207,182 @@ else * Fiche en mode visu */ - print ''; - print ''; - print ''; - print "\n"; - print ''; - print ''; - print "\n"; - print "
'.$langs->trans("Name").''.$group->nom.'
'.$langs->trans("Note").''.nl2br($group->note).' 
\n"; - print "
\n"; + if ($_GET["action"] != 'edit') { - - print ''; - - if ($message) { print $message; } - - /* - * Barre d'actions - * - */ - print '
'; - - if ($user->admin) - { - print ''.$langs->trans("Edit").''; - } - - if ($user->id <> $_GET["id"] && $user->admin) - { - print ''.$langs->trans("DeleteGroup").''; - } - - print "
\n"; - print "
\n"; - - print_titre($langs->trans("ListOfUsersInGroup")); - print "
\n"; - - // On sélectionne les users qui ne sont pas déjà dans le groupe - $uss = array(); - - $sql = "SELECT u.rowid, u.name, u.firstname, u.code "; - $sql .= " FROM ".MAIN_DB_PREFIX."user as u "; - # $sql .= " LEFT JOIN llx_usergroup_user ug ON u.rowid = ug.fk_user"; - # $sql .= " WHERE ug.fk_usergroup IS NULL"; - $sql .= " ORDER BY u.name"; - - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows(); - $i = 0; - - while ($i < $num) + print ''; + print ''; + print ''; + print "\n"; + print ''; + print ''; + print "\n"; + print "
'.$langs->trans("Name").''.$group->nom.'
'.$langs->trans("Note").''.nl2br($group->note).' 
\n"; + print "
\n"; + + print ''; + + if ($message) { print $message; } + + /* + * Barre d'actions + * + */ + print '
'; + + if ($user->admin) { - $obj = $db->fetch_object(); - - $uss[$obj->rowid] = ucfirst(stripslashes($obj->firstname)) . " ".ucfirst(stripslashes($obj->name)); - $i++; + print ''.$langs->trans("Edit").''; } - } - else { - dolibarr_print_error($db); - } - - if ($user->admin) - { - $form = new Form($db); - print '
'."\n"; - print ''; - print ''."\n"; - // print ''."\n"; - print ''."\n"; - print ''."\n"; - print '
'.$langs->trans("NonAffectedUsers").'
'.$langs->trans("Users").''; - print $form->select_array("user",$uss); - print '   '; - print ''; - print '
'."\n"; - } - - /* - * Membres du groupe - */ - $sql = "SELECT u.rowid, u.login, u.name, u.firstname, u.code "; - $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; - $sql .= ",".MAIN_DB_PREFIX."usergroup_user as ug"; - $sql .= " WHERE ug.fk_user = u.rowid"; - $sql .= " AND ug.fk_usergroup = ".$group->id; - $sql .= " ORDER BY u.name"; - - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows($result); - $i = 0; - - print '
'; - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - $var=True; - while ($i < $num) + + if ($user->id <> $_GET["id"] && $user->admin) { - $obj = $db->fetch_object($result); - $var=!$var; - - print ""; - print ''; - print ''; - print ''; - print '
'.$langs->trans("Login").''.$langs->trans("Lastname").''.$langs->trans("Firstname").''.$langs->trans("Code").' 
'; - print ''.img_object($langs->trans("ShowUser"),"user").' '.$obj->login.''; - print ''.ucfirst(stripslashes($obj->name)).''.ucfirst(stripslashes($obj->firstname)).''.$obj->code.''; - - if ($user->admin) + print ''.$langs->trans("DeleteGroup").''; + } + + print "\n"; + print "
\n"; + + + /* + * Liste des utilisateurs dans le groupe + */ + + print_titre($langs->trans("ListOfUsersInGroup")); + print "
\n"; + + // On sélectionne les users qui ne sont pas déjà dans le groupe + $uss = array(); + + $sql = "SELECT u.rowid, u.login, u.name, u.firstname, u.code "; + $sql .= " FROM ".MAIN_DB_PREFIX."user as u "; + # $sql .= " LEFT JOIN llx_usergroup_user ug ON u.rowid = ug.fk_user"; + # $sql .= " WHERE ug.fk_usergroup IS NULL"; + $sql .= " ORDER BY u.name"; + + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows(); + $i = 0; + + while ($i < $num) { - - print ''; - print img_delete($langs->trans("RemoveFromGroup")); + $obj = $db->fetch_object(); + + $uss[$obj->rowid] = ucfirst(stripslashes($obj->name)).' '.ucfirst(stripslashes($obj->firstname).' ('.$obj->login.')'); + $i++; + } + } + else { + dolibarr_print_error($db); + } + + if ($user->admin) + { + $form = new Form($db); + print '
'."\n"; + print ''; + print ''."\n"; + // print ''."\n"; + print ''."\n"; + print ''."\n"; + print '
'.$langs->trans("NonAffectedUsers").'
'.$langs->trans("UsersToAdd").''; + print $form->select_array("user",$uss); + print '   '; + print ''; + print '
'."\n"; + } + + /* + * Membres du groupe + */ + $sql = "SELECT u.rowid, u.login, u.name, u.firstname, u.code "; + $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; + $sql .= ",".MAIN_DB_PREFIX."usergroup_user as ug"; + $sql .= " WHERE ug.fk_user = u.rowid"; + $sql .= " AND ug.fk_usergroup = ".$group->id; + $sql .= " ORDER BY u.name"; + + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + $i = 0; + + print '
'; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + if ($num) { + $var=True; + while ($i < $num) + { + $obj = $db->fetch_object($result); + $var=!$var; + + print ""; + print ''; + print ''; + print ''; + print '\n"; + $i++; + } } else { - print "-"; + print ''; } - print "\n"; - $i++; + print "
'.$langs->trans("Login").''.$langs->trans("Lastname").''.$langs->trans("Firstname").''.$langs->trans("Code").' 
'; + print ''.img_object($langs->trans("ShowUser"),"user").' '.$obj->login.''; + print ''.ucfirst(stripslashes($obj->name)).''.ucfirst(stripslashes($obj->firstname)).''.$obj->code.''; + + if ($user->admin) + { + + print ''; + print img_delete($langs->trans("RemoveFromGroup")); + } + else + { + print "-"; + } + print "
'.$langs->trans("None").'
"; + print "
"; + $db->free($result); } - print "
"; - print "
"; - $db->free($result); + else { + dolibarr_print_error($db); + } + } + + /* + * Fiche en mode edition + */ + if ($_GET["action"] == 'edit' && $user->admin) + { + print '
'; + print ''; + + print ''; + print ''; + print ''; + print "\n"; + print ''; + print ''; + print "\n"; + print ''; + print "
'.$langs->trans("Name").'
'.$langs->trans("Note").'
\n"; + print "
\n"; + print '
'; + + print '
'; + + } } diff --git a/htdocs/usergroup.class.php b/htdocs/usergroup.class.php index c33012dc66b..a3cc1ae499d 100644 --- a/htdocs/usergroup.class.php +++ b/htdocs/usergroup.class.php @@ -37,7 +37,10 @@ class UserGroup var $db; var $id; - var $label; + var $nom; + var $note; + var $datec; + var $datem; /** @@ -64,7 +67,7 @@ class UserGroup { $this->id = $id; - $sql = "SELECT g.rowid, g.nom, g.note"; + $sql = "SELECT g.rowid, g.nom, g.note, g.datec, tms as datem"; $sql .= " FROM ".MAIN_DB_PREFIX."usergroup as g"; $sql .= " WHERE g.rowid = ".$this->id; @@ -79,7 +82,8 @@ class UserGroup $this->id = $obj->rowid; $this->nom = $obj->nom; $this->note = $obj->note; - + $this->datec = $obj->datec; + $this->datem = $obj->datem; } $this->db->free($result); @@ -344,6 +348,7 @@ class UserGroup function update() { $sql = "UPDATE ".MAIN_DB_PREFIX."usergroup SET "; + $sql .= " nom = '$this->nom',"; $sql .= " note = '$this->note'"; $sql .= " WHERE rowid = ".$this->id;