From 54d66cd7daccbdbc3acb91ea1ac68765aab52e64 Mon Sep 17 00:00:00 2001 From: Kevin Date: Thu, 8 Aug 2024 12:13:49 +0200 Subject: [PATCH] v 0.7.0 - Add github actions. - Update dependencies. - New module : change email. - Fix behavior when empty avatar. --- .github/.htaccess | 1 + .github/workflows/php.yml | 19 +++++ .gitignore | 1 + LICENSE | 2 +- README.md | 2 + inc/index.php | 1 + inc/modules/change-email.php | 142 +++++++++++++++++++++++++++++++ inc/modules/change-password.php | 1 + inc/modules/edit-metas.php | 5 ++ inc/modules/lost-password.php | 1 + inc/modules/register.php | 1 + inc/notifications.php | 1 + inc/pages.php | 1 + inc/permissions.php | 1 + inc/user.php | 1 + index.php | 1 + lang/.htaccess | 1 + lang/index.php | 1 + lang/wpu_extranet-fr_FR.l10n.php | 2 + lang/wpu_extranet-fr_FR.mo | Bin 2824 -> 3492 bytes lang/wpu_extranet-fr_FR.po | 56 +++++++++--- wpu_extranet.php | 28 +++--- 22 files changed, 248 insertions(+), 21 deletions(-) create mode 100644 .github/.htaccess create mode 100644 .github/workflows/php.yml create mode 100644 .gitignore create mode 100644 inc/index.php create mode 100644 inc/modules/change-email.php create mode 100644 index.php create mode 100644 lang/.htaccess create mode 100644 lang/index.php create mode 100644 lang/wpu_extranet-fr_FR.l10n.php diff --git a/.github/.htaccess b/.github/.htaccess new file mode 100644 index 0000000..8d2f256 --- /dev/null +++ b/.github/.htaccess @@ -0,0 +1 @@ +deny from all diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml new file mode 100644 index 0000000..c55b4e3 --- /dev/null +++ b/.github/workflows/php.yml @@ -0,0 +1,19 @@ +name: PHP Lint + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + phplint: + + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: PHP Lint + uses: michaelw90/PHP-Lint@2.1.0 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..78568eb --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.mo.php diff --git a/LICENSE b/LICENSE index 8519e70..f144cd3 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2021 WPUtilities +Copyright (c) 2024 WPUtilities Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 9a3d2c8..2bf64fd 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # WPU Extranet +[![PHP workflow](https://github.com/WordPressUtilities/wpu_extranet/actions/workflows/php.yml/badge.svg 'PHP workflow')](https://github.com/WordPressUtilities/wpu_extranet/actions) + Simple toolbox to create an extranet or a customer account. ## Todo diff --git a/inc/index.php b/inc/index.php new file mode 100644 index 0000000..194cdb1 --- /dev/null +++ b/inc/index.php @@ -0,0 +1 @@ + $user_id, + 'user_email' => $new_email + )); + $html_return = '

' . __('Email successfully updated!', 'wpu_extranet') . '

'; + } else { + $html_return = '

' . implode('
', $errors) . '

'; + } + + return $html_return; +} + +/* HTML Form +-------------------------- */ + + +function wpu_extranet_change_email__form($args = array()) { + if (!is_array($args)) { + $args = array(); + } + if (!isset($args['before_fields'])) { + $args['before_fields'] = ''; + } + $html = ''; + + $userdata = get_userdata(get_current_user_id()); + + $settings = wpu_extranet_get_skin_settings(); + + $html .= '
'; + $html .= '

' . __('Change email', 'wpu_extranet') . '

'; + $html .= '
'; + $html .= $args['before_fields']; + $html .= '
    '; + $html .= wpu_extranet__display_field('current_email', array( + 'type' => 'email', + 'attributes' => 'readonly minlength="6" autocomplete="off" required="required"', + 'label' => __('Your current email', 'wpu_extranet'), + 'value' => $userdata->user_email + )); + $html .= wpu_extranet__display_field('new_email', array( + 'type' => 'email', + 'attributes' => 'minlength="6" autocomplete="off" required="required"', + 'label' => __('New email', 'wpu_extranet') + )); + $html .= wpu_extranet__display_field('confirm_new_email', array( + 'type' => 'email', + 'attributes' => 'minlength="6" autocomplete="off" required="required"', + 'label' => __('Confirm new email', 'wpu_extranet') + )); + $html .= '
  • '; + $html .= wp_nonce_field('wpuextranet_changeemail_action', 'wpuextranet_changeemail', true, false); + $html .= ''; + $html .= '
  • '; + $html .= '
'; + $html .= '
'; + $html .= '
'; + + return $html; +} + +/* ---------------------------------------------------------- + Example code +---------------------------------------------------------- */ + +/* +$html_return_email = wpu_extranet_change_email__action(); +get_header(); +echo '

' . get_the_title() . '

'; +echo wpu_extranet_change_email__form(array( + 'before_fields' => $html_return_email +)); +get_footer(); +*/ diff --git a/inc/modules/change-password.php b/inc/modules/change-password.php index 6a3e379..d5ae31e 100644 --- a/inc/modules/change-password.php +++ b/inc/modules/change-password.php @@ -1,4 +1,5 @@ NULL,'plural-forms'=>NULL,'messages'=>['All fields are required.'=>'Tous les champs sont requis.','Invalid email.'=>'E-mail invalide.','New email is the same as the current email.'=>'Le nouvel e-mail est le même que l’e-mail actuel.','Emails do not match.'=>'Les e-mails ne sont pas identiques.','Email is already in use.'=>'L’e-mail est déjà utilisé.','Email successfully updated!'=>'L’e-mail a été mis à jour avec succès !','Change email'=>'Changer d\'adresse e-mail','Your current email'=>'Votre adresse e-mail actuelle','New email'=>'Nouvel e-mail','Confirm new email'=>'Confirmez votre nouvel e-mail','Current password is incorrect.'=>'Le mot de passe actuel est incorrect.','Passwords do not match.'=>'Les mots de passe ne correspondent pas.','Password is too short, minimum of 6 characters.'=>'Le mot de passe est trop court, minimum de 6 caractères.','Password successfully changed!'=>'Mot de passe changé avec succès !','Error:'=>'Erreur :','Change password'=>'Changer le mot de passe','Enter your current password'=>'Veuillez saisir votre mot de passe actuel','New password'=>'Nouveau mot de passe','Confirm new password'=>'Confirmer le nouveau mot de passe','Profile successfully updated!'=>'Profil mis à jour avec succès!','Infos'=>'Infos','The current avatar is generated by %s.'=>'L’avatar actuel est généré par %s.','Delete this avatar'=>'Supprimer cet avatar','Avatar'=>'Avatar','Username'=>'Nom d\'utilisateur','Email'=>'E-mail','Edit my infos'=>'Modifier mes infos','Check your email for the confirmation link.'=>'Vérifiez vos courriels pour y trouver le lien de confirmation.','Your account could not be found.'=>'Votre compte est introuvable.','Reset password failed.'=>'Échec de la réinitialisation du mot de passe.','Username or Email Address'=>'Identifiant ou adresse email','Get New Password'=>'Obtenir un nouveau mot de passe','Registration confirmation will be emailed to you.'=>'La confirmation d’inscription vous sera envoyée par courriel.','This username already exists.'=>'Ce nom d’utilisateur existe déjà.','This email is already registered.'=>'Cet e-mail est déjà enregistré.','This username contains invalid characters.'=>'Ce nom d’utilisateur contient des caractères non valides.','Registration failed.'=>'Échec de l’inscription.','Password'=>'Mot de passe','Register'=>'S\'inscrire','Log out'=>'Se déconnecter','First name'=>'Prénom','Last name'=>'Nom'],'language'=>'fr_FR','x-generator'=>'Poedit 3.4.4']; \ No newline at end of file diff --git a/lang/wpu_extranet-fr_FR.mo b/lang/wpu_extranet-fr_FR.mo index ad9f227eeac7cbfc7a849a498446f3e8691f0cb4..cab2bbbec2a8feff8b365e40f9f2fbf401fba9a9 100644 GIT binary patch delta 1470 zcmZA0J8Tq39LMp&=O+Yk%**ECj3JnZ@ga~EgaX115ta=N2#J@(>UOXX?cKudu7RX5 zN|6w`NO7V7i6{jHhDa1{KnQ_!p`+p@OyPn8L4_2>R7mjs?HvL$()zQvyEF5f|BNpz zy}Dv-x~=}Aq4jXB7E!c}qxUKek z7b@5QDsY0$_$zM4aqMJ%bBCK{Ja~bt@ITatt<1g!J5a#}aVZ|hZajls_!p|*ecXuC zsQxXa>A*I$xCvE>z35Zr%xsk9mnI^&3>6I+nEym!l>)jGFK)uEoo!VE0i2 zKSho68o$H0*ozA(-x}PB8_+{unQT|u_hJVEXCbJQNb#y)(9 z3eYpJTH=1(&hNdb34h0RcmpjyM!J~)u^&IoqyEde>1TtqCr3~n#&I=HqE`A0ci?-} zA=^$09o9iqWkzcLhEz6f>aS+gztuCQ>Z&QUwy0bCuclO5xemQbq^1>U5(QAmC0w7H zs-}`F%%a*uRZ8JiNtKsHrcIU8LFN3WVYRgzx%A&LU#n8n!BW%ys`Ots9i;VK6d*m- z-(zEWrmm;K6})^Z77g3VSxhOi31i?9* zobtWc`CZj_k@Z7c3}ajH;@n8Kd^7XY!GYqa7vz1LPLwr6UKHD+S8!%19JXN+n|s`t61RC2|*HqK;Y{nVVcLt#>~vtE>^8)h=h#I?pc= z)mhh@E_1laTk^9V4dap{W-{u6PjBuuo!vV0^8BUhht?6&uS}e*{B4ssALOIT1kpdg z_iSY%u1u7Vv~+aaE;Hn!+CY&l5<4X4DRSq166a4RF3OgFXwD7qPGeBdv?Nq?Usy2v zou8;oY9#(ew3q5noV5|6}56^5fKO~xU>jGa?zrj4u$1h$;oA7&_dUT z7JY5PO^P76D+rmkNsCqmDzpqFh=f|z|C#cIGrz-d?>X;z?pbYLPM7vlu_s1#GEOnh zMa%|pu!&>=?FTKlWlXPU2~t#T2e!J-)zdT*G$UM6L4ylV&CR#N;@C z?4cg~jvgLj9RFY)#$#p)Y(_PhL2Y;iPvAYw;A7NtuP}$}s0Md2jX$s(JvQrLf6Fq_ zi{sdb^QZ-$V;iobkMD4XboNn6jnbV?5}+EmgG0E49k`8M_!ZSaf<=`~2K8PRd)ePE zG0}+wUpXYFQPi1!a;n9jrbOI@*PxS-;hA8g~7D4nHp+fsMPFH=>RI7T!;E!rOGAY zlTYd;)Y|_+?UvB<5;jz^b5gU-p0b)e)yocRjmFTaW~^Xqqz$?cRlgUCA}%Ph diff --git a/lang/wpu_extranet-fr_FR.po b/lang/wpu_extranet-fr_FR.po index 93522f1..c9bc8e9 100644 --- a/lang/wpu_extranet-fr_FR.po +++ b/lang/wpu_extranet-fr_FR.po @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: WPU Extranet\n" -"POT-Creation-Date: 2022-08-04 13:54+0200\n" +"POT-Creation-Date: 2024-08-08 12:06+0200\n" "PO-Revision-Date: \n" "Last-Translator: Darklg \n" "Language-Team: \n" @@ -9,16 +9,52 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Generator: Poedit 3.1.1\n" +"X-Generator: Poedit 3.4.4\n" "X-Poedit-SourceCharset: UTF-8\n" "X-Poedit-Basepath: .\n" "X-Poedit-KeywordsList: __;_e\n" "X-Poedit-SearchPath-0: ../.\n" -#: .././inc/modules/change-password.php:40 +#: .././inc/modules/change-email.php:40 .././inc/modules/change-password.php:40 msgid "All fields are required." msgstr "Tous les champs sont requis." +#: .././inc/modules/change-email.php:45 +msgid "Invalid email." +msgstr "E-mail invalide." + +#: .././inc/modules/change-email.php:50 +msgid "New email is the same as the current email." +msgstr "Le nouvel e-mail est le même que l’e-mail actuel." + +#: .././inc/modules/change-email.php:55 +msgid "Emails do not match." +msgstr "Les e-mails ne sont pas identiques." + +#: .././inc/modules/change-email.php:60 +msgid "Email is already in use." +msgstr "L’e-mail est déjà utilisé." + +#: .././inc/modules/change-email.php:72 +msgid "Email successfully updated!" +msgstr "L’e-mail a été mis à jour avec succès !" + +#: .././inc/modules/change-email.php:98 .././inc/modules/change-email.php:120 +msgid "Change email" +msgstr "Changer d'adresse e-mail" + +#: .././inc/modules/change-email.php:105 +msgid "Your current email" +msgstr "Votre adresse e-mail actuelle" + +#: .././inc/modules/change-email.php:111 +msgid "New email" +msgstr "Nouvel e-mail" + +#: .././inc/modules/change-email.php:116 +msgid "Confirm new email" +msgstr "Confirmez votre nouvel e-mail" + #: .././inc/modules/change-password.php:45 msgid "Current password is incorrect." msgstr "Le mot de passe actuel est incorrect." @@ -61,32 +97,32 @@ msgstr "Confirmer le nouveau mot de passe" msgid "Profile successfully updated!" msgstr "Profil mis à jour avec succès!" -#: .././inc/modules/edit-metas.php:111 +#: .././inc/modules/edit-metas.php:115 msgid "Infos" msgstr "Infos" -#: .././inc/modules/edit-metas.php:118 +#: .././inc/modules/edit-metas.php:138 #, php-format msgid "The current avatar is generated by %s." msgstr "L’avatar actuel est généré par %s." -#: .././inc/modules/edit-metas.php:121 +#: .././inc/modules/edit-metas.php:141 msgid "Delete this avatar" msgstr "Supprimer cet avatar" -#: .././inc/modules/edit-metas.php:124 +#: .././inc/modules/edit-metas.php:144 msgid "Avatar" msgstr "Avatar" -#: .././inc/modules/edit-metas.php:133 .././inc/modules/register.php:140 +#: .././inc/modules/edit-metas.php:154 .././inc/modules/register.php:140 msgid "Username" msgstr "Nom d'utilisateur" -#: .././inc/modules/edit-metas.php:138 .././inc/modules/register.php:146 +#: .././inc/modules/edit-metas.php:159 .././inc/modules/register.php:146 msgid "Email" msgstr "E-mail" -#: .././inc/modules/edit-metas.php:151 +#: .././inc/modules/edit-metas.php:175 msgid "Edit my infos" msgstr "Modifier mes infos" diff --git a/wpu_extranet.php b/wpu_extranet.php index a9ae30b..eaa2369 100644 --- a/wpu_extranet.php +++ b/wpu_extranet.php @@ -1,33 +1,41 @@