Overview
Comment: | Affichage du statut de l'adresse email si invalide dans la fiche de membre |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | dev |
Files: | files | file ages | folders |
SHA1: |
b267668fe4a664b21b65cce2a60fb65e |
User & Date: | bohwaz on 2018-08-02 23:49:06 |
Other Links: | branch diff | manifest | tags |
Context
2018-08-02
| ||
23:49 | Corrections sur la recherche de membre pour ceux qui n'ont que le droit de lecture check-in: 2b6cfa652b user: bohwaz tags: dev | |
23:49 | Affichage du statut de l'adresse email si invalide dans la fiche de membre check-in: b267668fe4 user: bohwaz tags: dev | |
22:58 | Merge avec trunk check-in: e9ab0666a3 user: bohwaz tags: dev | |
Changes
Modified src/include/lib/Garradin/Email.php from [5d05a885ef] to [14773bb5c2].
1 2 3 4 5 6 7 8 9 10 11 12 | <?php namespace Garradin; use KD2\Security; class Email { const STATUT_ATTENTE_ENVOI = 0; const STATUT_EN_COURS_ENVOI = 1; /** | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 | <?php namespace Garradin; use KD2\Security; use KD2\SMTP; class Email { const STATUT_ATTENTE_ENVOI = 0; const STATUT_EN_COURS_ENVOI = 1; /** |
︙ | ︙ | |||
44 45 46 47 48 49 50 | * @param integer $id_membre ID membre (facultatif) * @param string $pgp_key Clé PGP, si renseigné le message sera chiffré à l'aide de cette clé * @return boolean */ public function appendToQueue($to, $subject, $content, $id_membre = null, $pgp_key = null) { // Ne pas envoyer de mail à des adresses invalides | | | 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | * @param integer $id_membre ID membre (facultatif) * @param string $pgp_key Clé PGP, si renseigné le message sera chiffré à l'aide de cette clé * @return boolean */ public function appendToQueue($to, $subject, $content, $id_membre = null, $pgp_key = null) { // Ne pas envoyer de mail à des adresses invalides if (!SMTP::checkEmailIsValid($to, false)) { throw new UserException('Adresse email invalide: ' . $to); } if ($pgp_key) { $content = Security::encryptWithPublicKey($pgp_key, $content); |
︙ | ︙ | |||
147 148 149 150 151 152 153 | * @param string $message * @return boolean */ public function setRejectedStatus($address, $status, $message) { $address = strtolower(trim($address)); | | | 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | * @param string $message * @return boolean */ public function setRejectedStatus($address, $status, $message) { $address = strtolower(trim($address)); if (!SMTP::checkEmailIsValid($address, false)) { return false; } if ($status < 0 && !in_array($status, [self::REJET_DEFINITIF, self::REJET_OPTOUT])) { throw new \UnexpectedValueException('Statut inconnu: ' . $status); |
︙ | ︙ | |||
169 170 171 172 173 174 175 | return DB::getInstance()->preparedQuery('INSERT OR IGNORE INTO emails_rejets (adresse, message, statut) VALUES (?, ?, ?);', [$address, $message, $status]); } /** * Vérifie qu'une adresse est valide * @param string $address | | > | > > > > | | | | | 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | return DB::getInstance()->preparedQuery('INSERT OR IGNORE INTO emails_rejets (adresse, message, statut) VALUES (?, ?, ?);', [$address, $message, $status]); } /** * Vérifie qu'une adresse est valide * @param string $address * @return integer FALSE si l'adresse est invalide (syntaxe) ou un entier si l'adresse a été rejetée */ static public function checkAddress($address) { $address = strtolower(trim($address)); // Ce domaine n'existe pas (MX inexistant), erreur de saisie courante if (substr($address, -9) == '@gmail.fr') { return false; } if ($statut = DB::getInstance()->firstColumn('SELECT statut FROM emails_rejets WHERE adresse = ?;', $address)) { return $statut; } if (!SMTP::checkEmailIsValid($address, true)) { return false; } return true; } protected function mail($to, $subject, $content, array $headers = []) { // Création du contenu du message $config = Config::getInstance(); $subject = sprintf('[%s] %s', $config->get('nom_asso'), $subject); $unsubscribe_url = sprintf('%semail.php?optout=%s', ADMIN_URL, rawurlencode($to)); $content .= sprintf("\n\n-- \n%s\n%s\n\n", $config->get('nom_asso'), $config('site_asso')); $content .= "Vous recevez ce message car vous êtes inscrit comme membre de\nl'association.\n"; $content .= "Pour ne plus recevoir de message de notre part cliquez ici :\n" . $unsubscribe_url; $content = preg_replace("#(?<!\r)\n#si", "\r\n", $content); $headers['List-Unsubscribe'] = sprintf('<%s>', $unsubscribe_url); if (FORCE_EMAIL_FROM) |
︙ | ︙ |
Modified src/include/lib/Garradin/Template.php from [8050b58d78] to [f111533e27].
︙ | ︙ | |||
49 50 51 52 53 54 55 56 57 58 59 60 61 62 | $this->register_function('html_champ_membre', [$this, 'formChampMembre']); $this->register_function('custom_colors', [$this, 'customColors']); $this->register_function('plugin_url', ['Garradin\Utils', 'plugin_url']); $this->register_function('diff', [$this, 'diff']); $this->register_function('pagination', [$this, 'pagination']); $this->register_function('format_droits', [$this, 'formatDroits']); $this->register_function('csrf_field', function ($params) { return Form::tokenHTML($params['key']); }); $this->register_modifier('strlen', 'strlen'); $this->register_modifier('get_country_name', ['Garradin\Utils', 'getCountryName']); | > | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | $this->register_function('html_champ_membre', [$this, 'formChampMembre']); $this->register_function('custom_colors', [$this, 'customColors']); $this->register_function('plugin_url', ['Garradin\Utils', 'plugin_url']); $this->register_function('diff', [$this, 'diff']); $this->register_function('pagination', [$this, 'pagination']); $this->register_function('format_droits', [$this, 'formatDroits']); $this->register_function('email_link', [$this, 'emailLink']); $this->register_function('csrf_field', function ($params) { return Form::tokenHTML($params['key']); }); $this->register_modifier('strlen', 'strlen'); $this->register_modifier('get_country_name', ['Garradin\Utils', 'getCountryName']); |
︙ | ︙ | |||
110 111 112 113 114 115 116 117 118 119 120 121 122 123 | $this->register_modifier('liens_wiki', function ($str, $prefix) { return preg_replace_callback('!<a href="([^/.:@]+)">!i', function ($matches) use ($prefix) { return '<a href="' . $prefix . Wiki::transformTitleToURI($matches[1]) . '">'; }, $str); }); } protected function formErrors($params) { $form = $this->getTemplateVars('form'); if (!$form->hasErrors()) { | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | $this->register_modifier('liens_wiki', function ($str, $prefix) { return preg_replace_callback('!<a href="([^/.:@]+)">!i', function ($matches) use ($prefix) { return '<a href="' . $prefix . Wiki::transformTitleToURI($matches[1]) . '">'; }, $str); }); } protected function emailLink($params) { if (empty($params['address'])) { throw new \BadFunctionCallException('Missing argument: address'); } $status = Email::checkAddress($params['address']); if ($status === true) { $out = '<a href="mailto:' . $this->escape($params['address'], 'url') . '">' . $this->escape($params['address']) . '</a>'; if (!empty($params['id_membre'])) { $out .= sprintf(' | <a href="%smembres/message.php?id=%s"><b class="icn action">✉</b> Envoyer un message</a>', ADMIN_URL, (int)$params['id_membre']); } return $out; } $out = '<span class="error invalidEmail">' . $this->escape($params['address']) . '</span> <em>(envois désactivés)</em>'; if (!empty($params['show_error'])) { $out .= '<br />'; if ($status === Email::REJET_OPTOUT) { $out .= 'Ce destinataire ne souhaite plus recevoir de message de votre part.'; } elseif ($status === Email::REJET_DEFINITIF) { $out .= 'Cette adresse n\'existe pas.'; } elseif ($status >= EMAIL::REJET_ABANDON) { $out .= 'Cette adresse a renvoyé trop d\'erreurs.'; } else { $out .= 'Cette adresse est invalide.'; } } return $out; } protected function formErrors($params) { $form = $this->getTemplateVars('form'); if (!$form->hasErrors()) { |
︙ | ︙ |
Modified src/templates/admin/membres/fiche.tpl from [a409f17e3e] to [ee27111687].
︙ | ︙ | |||
78 79 80 81 82 83 84 | {/if} {/if} </dd> </dl> </aside> <dl class="describe"> | | | | | | < | | | | | | | | | 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | {/if} {/if} </dd> </dl> </aside> <dl class="describe"> {foreach from=$champs key="c" item="c_config"} <dt>{$c_config.title}</dt> <dd> {if $c_config.type == 'checkbox'} {if $membre->$c}Oui{else}Non{/if} {elseif empty($membre->$c)} <em>(Non renseigné)</em> {elseif $c == $c_config.champ_identite} <strong>{$membre->$c}</strong> {elseif $c == 'email'} {email_link address=$membre->$c show_error=true id_membre=$membre->id} {elseif $c_config.type == 'email'} {email_link address=$membre->$c show_error=true} {elseif $c_config.type == 'tel'} <a href="tel:{$membre->$c}">{$membre->$c|format_tel}</a> {elseif $c_config.type == 'country'} {$membre->$c|get_country_name} {elseif $c_config.type == 'date' || $c_config.type == 'datetime'} {$membre->$c|format_sqlite_date_to_french} {elseif $c_config.type == 'password'} ******* {elseif $c_config.type == 'multiple'} <ul> {foreach from=$c_config.options key="b" item="name"} {if $membre->$c & (0x01 << $b)} <li>{$name}</li> {/if} {/foreach} </ul> {else} {$membre->$c|escape|rtrim|nl2br} {/if} </dd> {/foreach} </dl> {include file="admin/_foot.tpl"} |
Modified src/www/admin/static/admin.css from [903a1b66a2] to [ac3a89353d].
︙ | ︙ | |||
184 185 186 187 188 189 190 191 192 193 194 195 196 197 | span.confirm, b.confirm { color: #090; } span.alert, b.alert { color: #990; } p.error, div.error { border: 1px solid #c00; background: #fcc; padding: 0.5em; margin-bottom: 1em; } | > > > > | 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | span.confirm, b.confirm { color: #090; } span.alert, b.alert { color: #990; } .error.invalidEmail { text-decoration: line-through; } p.error, div.error { border: 1px solid #c00; background: #fcc; padding: 0.5em; margin-bottom: 1em; } |
︙ | ︙ |