diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 871821293b6..086d76f841b 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -4788,11 +4788,12 @@ class Form
* @param string $modulepart Key to define module concerned ('societe', 'userphoto', 'memberphoto')
* @param object $object Object containing data to retrieve file name
* @param int $width Width of photo
+ * @param int $caneditfield Add edit fields
* @return string HTML code to output photo
*/
- static function showphoto($modulepart,$object,$width=100)
+ static function showphoto($modulepart,$object,$width=100,$caneditfield=0)
{
- global $conf;
+ global $conf,$langs;
$entity = (! empty($object->entity) ? $object->entity : $conf->entity);
$id = (! empty($object->id) ? $object->id : $object->rowid);
@@ -4819,7 +4820,7 @@ class Form
if ($object->photo) $file=get_exdir($id, 2, 0, 0, $object, 'invoice_supplier').'photos/'.$object->photo;
if (! empty($conf->global->MAIN_OLD_IMAGE_LINKS)) $altfile=$object->id.".jpg"; // For backward compatibility
$email=$object->email;
- }else {
+ } else {
$dir=$conf->$modulepart->dir_output;
if ($object->photo) $file=get_exdir($id, 2, 0, 0, $adherent, 'member').'photos/'.$object->photo;
if (! empty($conf->global->MAIN_OLD_IMAGE_LINKS)) $altfile=$object->id.".jpg"; // For backward compatibility
@@ -4833,13 +4834,13 @@ class Form
{
// TODO Link to large image
$ret.='';
- $ret.='
';
+ $ret.='
';
$ret.='';
}
else if ($altfile && file_exists($dir."/".$altfile))
{
$ret.='';
- $ret.='
';
+ $ret.='
';
$ret.='';
}
else
@@ -4848,13 +4849,24 @@ class Form
{
global $dolibarr_main_url_root;
$ret.='';
- $ret.='
'; // gravatar need md5 hash
+ $ret.='
'; // gravatar need md5 hash
}
else
{
- $ret.='
';
+ $ret.='
';
}
}
+
+ if ($caneditfield)
+ {
+ if ($object->photo) $ret.="
\n";
+ $ret.='
';
+ }
+
}
else dol_print_error('','Call of showphoto with wrong parameters');
diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang
index 0d7377b89e4..503f65f5cc5 100644
--- a/htdocs/langs/en_US/main.lang
+++ b/htdocs/langs/en_US/main.lang
@@ -704,6 +704,8 @@ GoIntoSetupToChangeLogo=Go into Home - Setup - Company to change logo or go into
Deny=Deny
Denied=Denied
ListOfTemplates=List of templates
+Genderman=Man
+Genderwoman=Woman
# Week day
Monday=Monday
Tuesday=Tuesday
diff --git a/htdocs/user/card.php b/htdocs/user/card.php
index 3a561ce8ebb..ec3ad28cb7e 100644
--- a/htdocs/user/card.php
+++ b/htdocs/user/card.php
@@ -184,10 +184,12 @@ if ($action == 'add' && $canadduser)
}
}
- if (!$error) {
+ if (!$error)
+ {
$object->lastname = GETPOST("lastname",'alpha');
$object->firstname = GETPOST("firstname",'alpha');
$object->login = GETPOST("login",'alpha');
+ $object->gender = GETPOST("gender",'alpha');
$object->admin = GETPOST("admin",'alpha');
$object->office_phone = GETPOST("office_phone",'alpha');
$object->office_fax = GETPOST("office_fax",'alpha');
@@ -339,6 +341,7 @@ if ($action == 'update' && ! $_POST["cancel"])
$object->lastname = GETPOST("lastname",'alpha');
$object->firstname = GETPOST("firstname",'alpha');
$object->login = GETPOST("login",'alpha');
+ $object->gender = GETPOST("gender",'alpha');
$object->pass = GETPOST("password");
$object->admin = empty($user->admin)?0:GETPOST("admin"); // A user can only be set admin by an admin
$object->office_phone=GETPOST("office_phone",'alpha');
@@ -449,7 +452,7 @@ if ($action == 'update' && ! $_POST["cancel"])
$dir= $conf->user->dir_output . '/' . get_exdir($object->id,2,0,1,$object,'user');
dol_mkdir($dir);
-
+
if (@is_dir($dir))
{
$newfile=$dir.'/'.dol_sanitizeFileName($_FILES['photo']['name']);
@@ -470,6 +473,12 @@ if ($action == 'update' && ! $_POST["cancel"])
$imgThumbMini = vignette($newfile, $maxwidthmini, $maxheightmini, '_mini', $quality);
}
}
+ else
+ {
+ $error++;
+ $langs->load("errors");
+ setEventMessages($langs->trans("ErrorFailedToCreateDir", $dir), $mesgs, 'errors');
+ }
}
}
@@ -756,6 +765,13 @@ if (($action == 'create') || ($action == 'adduserldap'))
print '';
print '';
+ // Gender
+ print '| '.$langs->trans("Gender").' | ';
+ print '';
+ $arraygender=array('man'=>$langs->trans("Genderman"),'woman'=>$langs->trans("Genderwoman"));
+ print $form->selectarray('gender', $arraygender, GETPOST('gender'), 1);
+ print ' |
';
+
// Login
print '| '.$langs->trans("Login").' | ';
print '';
@@ -1030,8 +1046,12 @@ if (($action == 'create') || ($action == 'adduserldap'))
dol_fiche_end();
- print '';
-
+ print ' ';
+ print '';
+ //print ' ';
+ //print '';
+ print ' ';
+
print "";
}
else
@@ -1183,6 +1203,12 @@ else
print ' | '.$object->job.' | ';
print '
'."\n";
+ // Gender
+ print '| '.$langs->trans("Gender").' | ';
+ print '';
+ if ($object->gender) print $langs->trans("Gender".$object->gender);
+ print ' |
';
+
// Login
print '| '.$langs->trans("Login").' | ';
if (! empty($object->ldap_sid) && $object->statut==0)
@@ -1681,7 +1707,7 @@ else
dol_fiche_head($head, 'user', $title, 0, 'user');
- $rowspan=16;
+ $rowspan=17;
if (isset($conf->file->main_authentication) && preg_match('/openid/',$conf->file->main_authentication) && ! empty($conf->global->MAIN_OPENIDURL_PERUSER)) $rowspan++;
if (! empty($conf->societe->enabled)) $rowspan++;
if (! empty($conf->adherent->enabled)) $rowspan++;
@@ -1711,18 +1737,10 @@ else
print $object->lastname;
}
print '';
+
// Photo
print '';
- print $form->showphoto('userphoto',$object);
- if ($caneditfield)
- {
- if ($object->photo) print " \n";
- print '';
- }
+ print $form->showphoto('userphoto',$object,0,$caneditfield);
print ' | ';
print '
';
@@ -1755,6 +1773,13 @@ else
}
print '';
+ // Gender
+ print '| '.$langs->trans("Gender").' | ';
+ print '';
+ $arraygender=array('man'=>$langs->trans("Genderman"),'woman'=>$langs->trans("Genderwoman"));
+ print $form->selectarray('gender', $arraygender, GETPOST('gender')?GETPOST('gender'):$object->gender, 1);
+ print ' |
';
+
// Login
print "".'| '.$langs->trans("Login").' | ';
print '';
diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php
index b1836ef8cde..7d006c1a7f7 100644
--- a/htdocs/user/class/user.class.php
+++ b/htdocs/user/class/user.class.php
@@ -50,6 +50,7 @@ class User extends CommonObject
var $search_sid;
var $lastname;
var $firstname;
+ var $gender;
var $note;
var $email;
var $skype;
@@ -151,7 +152,7 @@ class User extends CommonObject
$login=trim($login);
// Get user
- $sql = "SELECT u.rowid, u.lastname, u.firstname, u.email, u.job, u.skype, u.signature, u.office_phone, u.office_fax, u.user_mobile,";
+ $sql = "SELECT u.rowid, u.lastname, u.firstname, u.gender, u.email, u.job, u.skype, u.signature, u.office_phone, u.office_fax, u.user_mobile,";
$sql.= " u.admin, u.login, u.note,";
$sql.= " u.pass, u.pass_crypted, u.pass_temp,";
$sql.= " u.fk_soc, u.fk_socpeople, u.fk_member, u.fk_user, u.ldap_sid,";
@@ -212,6 +213,7 @@ class User extends CommonObject
$this->firstname = $obj->firstname;
$this->login = $obj->login;
+ $this->gender = $obj->gender;
$this->pass_indatabase = $obj->pass;
$this->pass_indatabase_crypted = $obj->pass_crypted;
$this->pass = $obj->pass;
@@ -936,6 +938,7 @@ class User extends CommonObject
$this->admin = 0;
$this->lastname = $contact->lastname;
$this->firstname = $contact->firstname;
+ $this->gender = $contact->gender;
$this->email = $contact->email;
$this->skype = $contact->skype;
$this->office_phone = $contact->phone_pro;
@@ -1007,6 +1010,7 @@ class User extends CommonObject
$this->admin = 0;
$this->lastname = $member->lastname;
$this->firstname = $member->firstname;
+ $this->gender = $member->gender;
$this->email = $member->email;
$this->fk_member = $member->id;
$this->pass = $member->pass;
@@ -1129,6 +1133,7 @@ class User extends CommonObject
$this->lastname = trim($this->lastname);
$this->firstname = trim($this->firstname);
$this->login = trim($this->login);
+ $this->gender = trim($this->gender);
$this->pass = trim($this->pass);
$this->office_phone = trim($this->office_phone);
$this->office_fax = trim($this->office_fax);
@@ -1156,11 +1161,12 @@ class User extends CommonObject
$this->db->begin();
- // Mise a jour autres infos
+ // Update datas
$sql = "UPDATE ".MAIN_DB_PREFIX."user SET";
$sql.= " lastname = '".$this->db->escape($this->lastname)."'";
$sql.= ", firstname = '".$this->db->escape($this->firstname)."'";
$sql.= ", login = '".$this->db->escape($this->login)."'";
+ $sql.= ", gender = ".($this->gender != -1 ? "'".$this->db->escape($this->gender)."'" : "null"); // 'man' or 'woman'
$sql.= ", admin = ".$this->admin;
$sql.= ", address = '".$this->db->escape($this->address)."'";
$sql.= ", zip = '".$this->db->escape($this->zip)."'";
@@ -1235,6 +1241,7 @@ class User extends CommonObject
$adh->firstname=$this->firstname;
$adh->lastname=$this->lastname;
$adh->login=$this->login;
+ $adh->gender=$this->gender;
$adh->pass=$this->pass;
$adh->societe=(empty($adh->societe) && $this->societe_id ? $this->societe_id : $adh->societe);
@@ -2047,6 +2054,7 @@ class User extends CommonObject
$this->lastname='DOLIBARR';
$this->firstname='SPECIMEN';
+ $this->gender='man';
$this->note='This is a note';
$this->email='email@specimen.com';
$this->skype='tom.hanson';
|