/[dolibarr]/dolibarr/htdocs/user/fiche.php
ViewVC logotype

Diff of /dolibarr/htdocs/user/fiche.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.76 by eldy, Mon Sep 26 01:01:53 2005 UTC revision 1.77 by eldy, Sat Oct 22 13:48:47 2005 UTC
# Line 34  require("./pre.inc.php"); Line 34  require("./pre.inc.php");
34  require_once(DOL_DOCUMENT_ROOT."/contact.class.php");  require_once(DOL_DOCUMENT_ROOT."/contact.class.php");
35    
36    
37    // Defini si peux lire/modifier utilisateurs et permisssions
38    $canreadperms=($user->admin || $user->rights->user->user->lire);
39    $caneditperms=($user->admin || $user->rights->user->user->creer);
40    $candisableperms=($user->admin || $user->rights->user->user->supprimer);
41    
42  if ($user->id <> $_GET["id"])  if ($user->id <> $_GET["id"])
43  {  {
44    if (! $user->rights->user->user->lire && ! $user->admin)      if (! $canreadperms)
45      {      {
46        accessforbidden();          accessforbidden();
47      }      }
48  }  }
49    
# Line 54  $action=isset($_GET["action"])?$_GET["ac Line 59  $action=isset($_GET["action"])?$_GET["ac
59  /**  /**
60   * Actions   * Actions
61   */   */
62  if ($_GET["subaction"] == 'addrights' && $user->admin)  if ($_GET["subaction"] == 'addrights' && $caneditperms)
63  {  {
64      $edituser = new User($db,$_GET["id"]);      $edituser = new User($db,$_GET["id"]);
65      $edituser->addrights($_GET["rights"]);      $edituser->addrights($_GET["rights"]);
66  }  }
67    
68  if ($_GET["subaction"] == 'delrights' && $user->admin)  if ($_GET["subaction"] == 'delrights' && $caneditperms)
69  {  {
70      $edituser = new User($db,$_GET["id"]);      $edituser = new User($db,$_GET["id"]);
71      $edituser->delrights($_GET["rights"]);      $edituser->delrights($_GET["rights"]);
# Line 74  if ($_POST["action"] == 'confirm_disable Line 79  if ($_POST["action"] == 'confirm_disable
79          $edituser->fetch($_GET["id"]);          $edituser->fetch($_GET["id"]);
80          $edituser->disable();          $edituser->disable();
81          Header("Location: ".DOL_URL_ROOT.'/user/fiche.php?id='.$_GET["id"]);          Header("Location: ".DOL_URL_ROOT.'/user/fiche.php?id='.$_GET["id"]);
82            exit;
83      }      }
84  }  }
85    
# Line 85  if ($_POST["action"] == 'confirm_delete' Line 91  if ($_POST["action"] == 'confirm_delete'
91          $edituser->fetch($_GET["id"]);          $edituser->fetch($_GET["id"]);
92          $edituser->delete();          $edituser->delete();
93          Header("Location: index.php");          Header("Location: index.php");
94            exit;
95      }      }
96  }  }
97    
98  // Action ajout user  // Action ajout user
99  if ($_POST["action"] == 'add' && $user->admin)  if ($_POST["action"] == 'add' && $caneditperms)
100  {  {
101      $message="";      $message="";
102      if (! $_POST["nom"]) {      if (! $_POST["nom"]) {
# Line 130  if ($_POST["action"] == 'add' && $user-> Line 137  if ($_POST["action"] == 'add' && $user->
137              $db->commit();              $db->commit();
138    
139              Header("Location: fiche.php?id=$id");              Header("Location: fiche.php?id=$id");
140                exit;
141          }          }
142          else          else
143          {          {
# Line 143  if ($_POST["action"] == 'add' && $user-> Line 151  if ($_POST["action"] == 'add' && $user->
151  }  }
152    
153  // Action ajout groupe utilisateur  // Action ajout groupe utilisateur
154  if ($_POST["action"] == 'addgroup' && $user->admin)  if ($_POST["action"] == 'addgroup' && $caneditperms)
155  {  {
156      if ($_POST["group"])      if ($_POST["group"])
157      {      {
# Line 151  if ($_POST["action"] == 'addgroup' && $u Line 159  if ($_POST["action"] == 'addgroup' && $u
159          $edituser->SetInGroup($_POST["group"]);          $edituser->SetInGroup($_POST["group"]);
160    
161          Header("Location: fiche.php?id=".$_GET["id"]);          Header("Location: fiche.php?id=".$_GET["id"]);
162            exit;
163      }      }
164  }  }
165    
166  if ($_GET["action"] == 'removegroup' && $user->admin)  if ($_GET["action"] == 'removegroup' && $caneditperms)
167  {  {
168      if ($_GET["group"])      if ($_GET["group"])
169      {      {
# Line 162  if ($_GET["action"] == 'removegroup' && Line 171  if ($_GET["action"] == 'removegroup' &&
171          $edituser->RemoveFromGroup($_GET["group"]);          $edituser->RemoveFromGroup($_GET["group"]);
172    
173          Header("Location: fiche.php?id=".$_GET["id"]);          Header("Location: fiche.php?id=".$_GET["id"]);
174            exit;
175      }      }
176  }  }
177    
178  if ($_POST["action"] == 'update' && $user->admin)  if ($_POST["action"] == 'update' && $caneditperms)
179  {  {
180      $message="";      $message="";
181    
# Line 201  if ($_POST["action"] == 'update' && $use Line 211  if ($_POST["action"] == 'update' && $use
211      if ($ret >= 0 && isset($_POST["password"]) && $_POST["password"] !='' )      if ($ret >= 0 && isset($_POST["password"]) && $_POST["password"] !='' )
212      {      {
213          $ret=$edituser->password($user,$password,$conf->password_encrypted);          $ret=$edituser->password($user,$password,$conf->password_encrypted);
214          if ($ret < 0) {          if ($ret < 0)
215            {
216              $message.='<div class="error">'.$edituser->error.'</div>';              $message.='<div class="error">'.$edituser->error.'</div>';
217          }          }
218      }      }
219    
220      if ($_FILES['photo']['tmp_name']) {      if (isset($_FILES['photo']['tmp_name']) && trim($_FILES['photo']['tmp_name']))
221        {
222          // Si une photo est fournie avec le formulaire          // Si une photo est fournie avec le formulaire
223          if (! is_dir($conf->users->dir_output))          if (! is_dir($conf->users->dir_output))
224          {          {
225              create_exdir($conf->users->dir_output);              create_exdir($conf->users->dir_output);
226          }          }
227          if (is_dir($conf->users->dir_output)) {          if (is_dir($conf->users->dir_output))
228            {
229              $newfile=$conf->users->dir_output . "/" . $edituser->id . ".jpg";              $newfile=$conf->users->dir_output . "/" . $edituser->id . ".jpg";
230              if (! doliMoveFileUpload($_FILES['photo']['tmp_name'],$newfile))              if (! doliMoveFileUpload($_FILES['photo']['tmp_name'],$newfile))
231              {              {
# Line 221  if ($_POST["action"] == 'update' && $use Line 234  if ($_POST["action"] == 'update' && $use
234          }          }
235      }      }
236    
237      if ($ret >= 0) {      if ($ret >= 0)
238        {
239          $message.='<div class="ok">'.$langs->trans("UserModified").'</div>';          $message.='<div class="ok">'.$langs->trans("UserModified").'</div>';
240          $db->commit();          $db->commit();
241      } else {      } else
242        {
243          $db->rollback;          $db->rollback;
244      }      }
245    
# Line 232  if ($_POST["action"] == 'update' && $use Line 247  if ($_POST["action"] == 'update' && $use
247    
248  // Action modif mot de passe  // Action modif mot de passe
249  if ((($_POST["action"] == 'confirm_password' && $_POST["confirm"] == 'yes')  if ((($_POST["action"] == 'confirm_password' && $_POST["confirm"] == 'yes')
250        || $_GET["action"] == 'confirm_passwordsend') && $user->admin)        || $_GET["action"] == 'confirm_passwordsend') && $caneditperms)
251  {  {
252      $edituser = new User($db, $_GET["id"]);      $edituser = new User($db, $_GET["id"]);
253      $edituser->fetch();      $edituser->fetch();
# Line 346  else Line 361  else
361          $fuser->fetch();          $fuser->fetch();
362          $fuser->getrights();          $fuser->getrights();
363    
364            $caneditpassword=( (($user->id == $fuser->id) && $user->rights->user->self->password)
365                            || (($user->id != $fuser->id) && $user->rights->user->user->password) );
366    
367          /*          /*
368           * Affichage onglets           * Affichage onglets
369           */           */
# Line 432  else Line 450  else
450    
451              print '<tr><td width="25%" valign="top">'.$langs->trans("Lastname").'</td>';              print '<tr><td width="25%" valign="top">'.$langs->trans("Lastname").'</td>';
452              print '<td width="50%" class="valeur">'.$fuser->nom.'</td>';              print '<td width="50%" class="valeur">'.$fuser->nom.'</td>';
453              print '<td align="center" valign="middle" width="25%" rowspan="13">';              print '<td align="center" valign="middle" width="25%" rowspan="14">';
454              if (file_exists($conf->users->dir_output."/".$fuser->id.".jpg"))              if (file_exists($conf->users->dir_output."/".$fuser->id.".jpg"))
455              {              {
456                  print '<img width="100" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=userphoto&file='.$fuser->id.'.jpg">';                  print '<img width="100" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=userphoto&file='.$fuser->id.'.jpg">';
# Line 525  else Line 543  else
543              print "</tr>\n";              print "</tr>\n";
544    
545              print "<tr>".'<td width="25%" valign="top">'.$langs->trans("Note").'</td>';              print "<tr>".'<td width="25%" valign="top">'.$langs->trans("Note").'</td>';
546              print '<td colspan="2" class="valeur">'.nl2br($fuser->note).'&nbsp;</td>';              print '<td class="valeur">'.nl2br($fuser->note).'&nbsp;</td>';
547              print "</tr>\n";              print "</tr>\n";
548    
549              // Autres caractéristiques issus des autres modules              // Autres caractéristiques issus des autres modules
# Line 548  else Line 566  else
566               */               */
567              print '<div class="tabsAction">';              print '<div class="tabsAction">';
568    
569              if ($user->admin || ($user->id == $fuser->id))              if ($caneditperms || ($user->id == $fuser->id))
570              {              {
571                  print '<a class="butAction" href="fiche.php?id='.$fuser->id.'&amp;action=edit">'.$langs->trans("Edit").'</a>';                  print '<a class="butAction" href="fiche.php?id='.$fuser->id.'&amp;action=edit">'.$langs->trans("Edit").'</a>';
572              }              }
573    
574              if (($user->id != $_GET["id"] && $user->admin) && $fuser->login)              if (($user->id != $_GET["id"] && $caneditpassword) && $fuser->login)
575              {              {
576                  print '<a class="butAction" href="fiche.php?id='.$fuser->id.'&amp;action=password">'.$langs->trans("ReinitPassword").'</a>';                  print '<a class="butAction" href="fiche.php?id='.$fuser->id.'&amp;action=password">'.$langs->trans("ReinitPassword").'</a>';
577              }              }
578    
579              if (($user->id != $_GET["id"] && $user->admin) && $fuser->email && $fuser->login)              if (($user->id != $_GET["id"] && $caneditpassword) && $fuser->email && $fuser->login)
580              {              {
581                  print '<a class="butAction" href="fiche.php?id='.$fuser->id.'&amp;action=passwordsend">'.$langs->trans("SendNewPassword").'</a>';                  print '<a class="butAction" href="fiche.php?id='.$fuser->id.'&amp;action=passwordsend">'.$langs->trans("SendNewPassword").'</a>';
582              }              }
583    
584              if ($user->id <> $_GET["id"] && $user->admin && $fuser->login)              if ($user->id <> $_GET["id"] && $candisableperms && $fuser->login)
585              {              {
586                  print '<a class="butActionDelete" href="fiche.php?action=disable&amp;id='.$fuser->id.'">'.$langs->trans("DisableUser").'</a>';                  print '<a class="butActionDelete" href="fiche.php?action=disable&amp;id='.$fuser->id.'">'.$langs->trans("DisableUser").'</a>';
587              }              }
588    
589              if ($user->id <> $_GET["id"] && $user->admin)              if ($user->id <> $_GET["id"] && $candisableperms)
590              {              {
591                  print '<a class="butActionDelete" href="fiche.php?action=delete&amp;id='.$fuser->id.'">'.$langs->trans("DeleteUser").'</a>';                  print '<a class="butActionDelete" href="fiche.php?action=delete&amp;id='.$fuser->id.'">'.$langs->trans("DeleteUser").'</a>';
592              }              }
# Line 611  else Line 629  else
629                  dolibarr_print_error($db);                  dolibarr_print_error($db);
630              }              }
631    
632              if ($user->admin)              if ($caneditperms)
633              {              {
634                  $form = new Form($db);                  $form = new Form($db);
635                  print '<form action="fiche.php?id='.$_GET["id"].'" method="post">'."\n";                  print '<form action="fiche.php?id='.$_GET["id"].'" method="post">'."\n";
# Line 663  else Line 681  else
681                          print '</td>';                          print '</td>';
682                          print '<td>';                          print '<td>';
683    
684                          if ($user->admin)                          if ($caneditperms)
685                          {                          {
686    
687                              print '<a href="fiche.php?id='.$_GET["id"].'&amp;action=removegroup&amp;group='.$obj->rowid.'">';                              print '<a href="fiche.php?id='.$_GET["id"].'&amp;action=removegroup&amp;group='.$obj->rowid.'">';
# Line 694  else Line 712  else
712          /*          /*
713           * Fiche en mode edition           * Fiche en mode edition
714           */           */
715          if ($_GET["action"] == 'edit' && ($user->admin || ($user->id == $fuser->id)))          if ($_GET["action"] == 'edit' && ($caneditperms || ($user->id == $fuser->id)))
716          {          {
717    
718              print '<form action="fiche.php?id='.$fuser->id.'" method="post" name="updateuser" enctype="multipart/form-data">';              print '<form action="fiche.php?id='.$fuser->id.'" method="post" name="updateuser" enctype="multipart/form-data">';
719              print '<input type="hidden" name="action" value="update">';              print '<input type="hidden" name="action" value="update">';
720              print '<table width="100%" class="border">';              print '<table width="100%" class="border">';
721                
722              $rowspan=11;              $rowspan=12;
             if ($conf->global->USER_ALLOW_PASSWORD_CHANGE) $rowspan++;  
723    
724              print '<tr><td width="25%" valign="top">'.$langs->trans("Lastname").'</td>';              print '<tr><td width="25%" valign="top">'.$langs->trans("Lastname").'</td>';
725              print '<td width="50%" class="valeur"><input class="flat" size="30" type="text" name="nom" value="'.$fuser->nom.'"></td>';              print '<td width="50%" class="valeur"><input class="flat" size="30" type="text" name="nom" value="'.$fuser->nom.'"></td>';
# Line 729  else Line 746  else
746              print '</td></tr>';              print '</td></tr>';
747    
748              // Pass              // Pass
749              if ($conf->global->USER_ALLOW_PASSWORD_CHANGE)              if ($caneditpassword)
750              {              {
751                  print "<tr>".'<td valign="top">'.$langs->trans("Password").'</td>';                  print "<tr>".'<td valign="top">'.$langs->trans("Password").'</td>';
752                  print '<td><input size="12" maxlength="8" type="password" class="flat" name="pass" value="'.$fuser->pass.'"></td></tr>';                  print '<td><input size="12" maxlength="8" type="password" class="flat" name="pass" value="'.$fuser->pass.'"></td></tr>';
753              }              }
754                else
755                {
756                    print '<tr><td width="25%" valign="top">'.$langs->trans("Password").'</td>';
757                    print '<td width="50%" class="valeur">'.eregi_replace('.','*',$fuser->pass).'</td>';
758                    print "</tr>\n";
759                }
760                            
761              // Administrateur              // Administrateur
762              print "<tr>".'<td valign="top">'.$langs->trans("Administrator").'</td>';              print "<tr>".'<td valign="top">'.$langs->trans("Administrator").'</td>';
# Line 799  else Line 822  else
822              print '<td><input size="40" type="text" name="email" class="flat" value="'.$fuser->email.'"></td></tr>';              print '<td><input size="40" type="text" name="email" class="flat" value="'.$fuser->email.'"></td></tr>';
823    
824              print "<tr>".'<td valign="top">'.$langs->trans("Note").'</td><td>';              print "<tr>".'<td valign="top">'.$langs->trans("Note").'</td><td>';
825              print '<textarea class="flat" name="note" rows="4" cols="40">';              print '<textarea class="flat" name="note" rows="'.ROWS_3.'" cols="70">';
826              print $fuser->note;              print $fuser->note;
827              print "</textarea></td></tr>";              print "</textarea></td></tr>";
828    

Legend:
Removed from v.1.76  
changed lines
  Added in v.1.77

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26