From d0f1eaa050c1e1fa9035c93b5d0b37c35d0885dc Mon Sep 17 00:00:00 2001 From: "tristan.champomier" Date: Tue, 6 Apr 2021 19:15:16 +0200 Subject: [PATCH] Fixed addUser method --- .../adminuser/changeuseradmin.mxt | 4 +- .../adminuser/adminuser.php | 70 ++++++++----------- 2 files changed, 30 insertions(+), 44 deletions(-) diff --git a/data/template/lcube6/object_coordination/adminuser/changeuseradmin.mxt b/data/template/lcube6/object_coordination/adminuser/changeuseradmin.mxt index c42abaf..73ddc53 100755 --- a/data/template/lcube6/object_coordination/adminuser/changeuseradmin.mxt +++ b/data/template/lcube6/object_coordination/adminuser/changeuseradmin.mxt @@ -4,10 +4,10 @@
-
+

-
+
" data-offstyle="danger font-weight-bold" data-off="" data-size="mini" type="checkbox" name="user_account_active">
diff --git a/lib/object_coordination/adminuser/adminuser.php b/lib/object_coordination/adminuser/adminuser.php index 244c0fe..0be3bfe 100755 --- a/lib/object_coordination/adminuser/adminuser.php +++ b/lib/object_coordination/adminuser/adminuser.php @@ -400,29 +400,6 @@ function exportAdmin() $MyUser->setPassword(""); $MyUser->setMail(""); - /*MxSelect(string $path, string $name, string | array $selectedValue, array $Value, [string $defaultValue], [int $multipleSize], [string $javascriptAttribut]);*/ -// $titre = array(getMessage("mr"),getMessage("mrs"), getMessage("miss")); -// $GLOBALS["SYSTEM_TEMPLATE"]->MxSelect("user_title", "user_title", $MyUser->getTitle(), $titre,"", "", "", "class=\"form\""); -// -// /*MxFormField(string $path, string $type, $string name, string $value, [string $attribut]); */ -// $GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_first_name", "text", "user_first_name", $MyUser->getFirstName(), "class=\"form\""); -// $GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_last_name", "text", "user_last_name", $MyUser->getLastName(), "class=\"form\""); -// $GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_login", "text", "user_login", $MyUser->getLogin(), "class=\"form\""); -// $GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_password", "password", "user_password", $MyUser->getPassword(), "class=\"form\""); -// $GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_password2", "password", "user_password2", $MyUser->getPassword(), "class=\"form\""); -// $GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_mail", "text", "user_mail", $MyUser->getMail(), "class=\"form\""); -// $GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_birthdate", "text", "user_birthdate", $MyUser->getBirthDate(), "class=\"form\""); -// $GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_postal_code", "text", "user_postal_code", $MyUser->getPostalCode(), "class=\"form\""); -// $GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_postal_adress", "textarea", "user_postal_adress", $MyUser->getPostalAddress(), "class=\"form\""); -// $GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_organisation", "text", "user_organisation", $MyUser->getOrganisation(), "class=\"form\""); -// $tabcom = $MyUser->getComment(); -// $GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_coment", "text", "user_coment", (isset($tabcom[0])?$tabcom[0]:""), "class=\"form\""); -// $GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_city", "text", "user_city", $MyUser->getCity(), "class=\"form\""); -// $GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_state", "text", "user_state", $MyUser->getState(), "class=\"form\""); -// $GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_country", "text", "user_country", $MyUser->getCountry(), "class=\"form\""); -// $GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_tel", "text", "user_tel", $MyUser->getTel(), "class=\"form\""); -// $GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_fax", "text", "user_fax", $MyUser->getFax(), "class=\"form\""); - $titre = array(getMessage("mr"),getMessage("mrs"), getMessage("miss")); $GLOBALS["SYSTEM_TEMPLATE"]->MxSelect("user_title", "user_title", $MyUser->getTitle(), $titre, "", "", "", "class=\"form\" title=\"".htmlspecialchars(getMessage("tipSelectTitle"), ENT_QUOTES)."\""); $GLOBALS["SYSTEM_TEMPLATE"]->MxFormField("user_first_name", "text", "user_first_name", $MyUser->getFirstName(), "class=\"form\" required=\"true\" title=\"".htmlspecialchars(getMessage("tipFirstName"), ENT_QUOTES)."\"", getMessage("user_first_name")); @@ -471,6 +448,9 @@ function exportAdmin() $groupId=($this->getData("groupId")!="")?$this->getData("groupId"):1; $group_id=(isset($_POST["group_id"]) && is_numeric($_POST["group_id"]))?$_POST["group_id"]:$groupId; + /* Vérification du statut du compte */ + $user_account_active=(isset($_POST["user_account_active"]))?$_POST["user_account_active"]:"off"; + /* gestion du lib en fonction de la langue courante */ $currentCode=$GLOBALS["SYSTEM_USER_SESSION"]->langue->getCode(); $defaultCode=$GLOBALS["SYSTEM_DEFAULT_LANGUAGE_CODE"]; @@ -498,7 +478,7 @@ function exportAdmin() foreach($_POST as $cle=>$val) { // echo "cle = ".$cle." val =".$val."
"; - if($val=="" && ($cle !="user_comment" && $cle !="user_fax" && $cle !="user_organisation" && $cle !="user_country" && $cle !="user_id" && $cle !="user_birthdate")) + if($val=="" && ($cle !="user_comment" && $cle !="user_fax" && $cle !="user_organisation" && $cle !="user_country" && $cle !="user_id" && $cle !="user_birthdate" && $cle !="user_mastodon" && $cle !="user_jabber" && $cle !="user_facebook" && $cle !="user_website" )) { $chaine .= getMessage($cle).", "; } @@ -536,14 +516,17 @@ function exportAdmin() } else { - //On enregistre les modifications de l'objet User ??????????????????????????????????????? + $d = DateTime::createFromFormat('d/m/Y', $_POST['user_birthdate']); + + //On enregistre les modifications de l'objet User + $MyUser->setAccountActive($user_account_active); $MyUser->setTitle($_POST['user_title']); $MyUser->setFirstName($_POST['user_first_name']); $MyUser->setLastName($_POST['user_last_name']); $MyUser->setLogin($_POST['user_login']); $MyUser->setPassword($_POST['user_password']); $MyUser->setMail($_POST['user_mail']); - $MyUser->setBirthDate($_POST['user_birthdate']); + $MyUser->setBirthDate($d->getTimestamp()); $MyUser->setPostalAddress($_POST['user_postal_address']); $MyUser->setPostalCode($_POST['user_postal_code']); $MyUser->setCity($_POST['user_city']); @@ -551,7 +534,11 @@ function exportAdmin() $MyUser->setCountry($_POST['user_country']); $MyUser->setOrganisation($_POST['user_organisation']); $MyUser->setTel($_POST['user_tel']); - $MyUser->setFax($_POST['user_fax']); + $MyUser->setMastodon($_POST['user_mastodon']); + $MyUser->setFacebook($_POST['user_facebook']); + $MyUser->setJabber($_POST['user_jabber']); + $MyUser->setTel($_POST['user_tel']); + $MyUser->setWebsite($_POST['user_website']); $MyUser->setComment(array($_POST['user_comment'])); //On enregistre les paramà res @@ -844,8 +831,6 @@ function exportAdmin() } else { - $d = DateTime::createFromFormat('d/m/Y', $_POST['user_birthdate']); - //On enregistre les modifications de l'objet User $MyUser->setAccountActive($user_account_active); $MyUser->setTitle($_POST['user_title']); @@ -854,20 +839,21 @@ function exportAdmin() $MyUser->setLogin($_POST['user_login']); $MyUser->setPassword($_POST['user_password']); $MyUser->setMail($_POST['user_mail']); + $d = DateTime::createFromFormat('d/m/Y', $_POST['user_birthdate']); $MyUser->setBirthDate($d->getTimestamp()); - $MyUser->setPostalAddress($_POST['user_postal_address']); - $MyUser->setPostalCode($_POST['user_postal_code']); - $MyUser->setCity($_POST['user_city']); - $MyUser->setState($_POST['user_state']); - $MyUser->setCountry($_POST['user_country']); - $MyUser->setOrganisation($_POST['user_organisation']); - $MyUser->setTel($_POST['user_tel']); - $MyUser->setMastodon($_POST['user_mastodon']); - $MyUser->setFacebook($_POST['user_facebook']); - $MyUser->setJabber($_POST['user_jabber']); - $MyUser->setTel($_POST['user_tel']); - $MyUser->setWebsite($_POST['user_website']); - $MyUser->setComment(array($_POST['user_comment'])); +// $MyUser->setPostalAddress($_POST['user_postal_address']); +// $MyUser->setPostalCode($_POST['user_postal_code']); +// $MyUser->setCity($_POST['user_city']); +// $MyUser->setState($_POST['user_state']); +// $MyUser->setCountry($_POST['user_country']); +// $MyUser->setOrganisation($_POST['user_organisation']); +// $MyUser->setTel($_POST['user_tel']); +// $MyUser->setMastodon($_POST['user_mastodon']); +// $MyUser->setFacebook($_POST['user_facebook']); +// $MyUser->setJabber($_POST['user_jabber']); +// $MyUser->setTel($_POST['user_tel']); +// $MyUser->setWebsite($_POST['user_website']); +// $MyUser->setComment(array($_POST['user_comment'])); //On enregistre les paramètres $ObjUsersave = $GLOBALS["SYSTEM_MANAGER"]["USER"]->saveInstance($MyUser);