From: Pierre Habouzit Date: Thu, 11 Sep 2003 16:06:57 +0000 (+0000) Subject: small pool of emails for the filter screen X-Git-Tag: procmail~23 X-Git-Url: http://git.polytechnique.org/?p=old-projects.git;a=commitdiff_plain;h=f0bef58b2ffdf347a66fa503026db93e6b63fcb8 small pool of emails for the filter screen --- diff --git a/philter/philter/include/emails.inc.php b/philter/philter/include/emails.inc.php index b7905f2..f699f2c 100644 --- a/philter/philter/include/emails.inc.php +++ b/philter/philter/include/emails.inc.php @@ -141,6 +141,38 @@ class EmailPool { return $res; } + /** create the part of the small form for the mail pool. + * @return the string containing the form + */ + function to_small_form() { + $res = "
\n" + . "\n" + . "\n" + . "\n"; + + $pair = true; + + foreach($this->emails as $id => $email) { + + $res .= "\n" + . "\n" + . "\n"; + $pair = !$pair; + } + + $val = _i18n('your_email'); + $res .= "\n" + . "
"._i18n('email')."
".($email->is_active() ? "" : "") + .$email->email.($email->is_active() ? "" : "")."
\n" + . "\n" + . "\n" + . "
\n" + . "
\n"; + + return $res; + } + /** return the string containing the list of $this->emails in javascript. * @return the JS code */ @@ -238,6 +270,35 @@ class EmailPool { return true; } } + + /** handle the data from the small form + * @return true if all is ok, false and sets $philter->error() else + */ + function handle_small_form() { + global $philter; + + if(isset($_POST['emails']['add'])) { // add an email to the pool + if(Email::Check($_POST['emails']['new'])) { + $new_mail = strtolower($_POST['emails']['new']); + + // we check that the email is not already there + foreach($this->emails as $id=>$key) + if($key->email == $new_mail) { + $philter->set_error("$new_mail "._i18n('pool_err_already')); + return false; + } + + // then we compute one free id, and we add it to the list + $mid = $this->new_mail_id(); + $this->emails[$mid] = new Email($new_mail, ''); + $this->emails[$mid]->commit($this->uid, $mid); + uasort($this->emails, "email_cmp"); + } else { + $philter->set_error($_POST['emails']['new'].' '._i18n('pool_err_not_valid')); + return false; + } + } + } } /******************************************************************************** diff --git a/philter/philter/include/form_filter.inc.php b/philter/philter/include/form_filter.inc.php index 97bf2ce..1e6a5d7 100644 --- a/philter/philter/include/form_filter.inc.php +++ b/philter/philter/include/form_filter.inc.php @@ -1,5 +1,8 @@ handle_small_form()) + echo "

".$philter->error()."

\n"; if(!empty($_POST['order']['action'])) // FORM order if($_POST['order']['action']=='submit') { foreach($filter->rules as $id=>$rule) @@ -10,12 +13,13 @@ if(count($_POST)) { // a FORM has been submitted $filter->delete_rule($_POST['order']['select']); unset($_POST['order']['select']); } - if(!empty($_POST['rule'])) + if(!empty($_POST['rule'])) // FORM rule if(!$filter->handle_form()) echo "

".$philter->error()."

\n"; } require("include/js_factory.inc.php"); + ?>
@@ -26,6 +30,12 @@ require("include/js_factory.inc.php");
+
+to_small_form(); +?> +
config['i18n'] = Array( 'pool_err_active' => 'Cet email est encore utilisé et ne peut pas être supprimé !', 'pool_err_need_one' => 'Tu dois avoir au moins un email actif !', + 'spool_help' => '

Tu peux ajouter ici des adresses mails utilisabels dans ton + filtre. Ces adresses mails sont ajoutées comme inactives dans ton filtre global.

+

Les adresses en gras sont tes addresses actives

', 'pool_help' => '

Tu configures ici les adresses emails vers lesquelles tu rediriges ton courrier.

Toutes les modifications faites sur cette page sont immédiatement prises