Пример #1
0
function send_warning_homonym(PlUser $user, $email)
{
    $cc = "validation+homonyme@" . Platal::globals()->mail->domain;
    $from = "\"Support Polytechnique.org\" <{$cc}>";
    $body = Post::has('mailbody') ? Post::t('mailbody') : get_warning_mail_text($user, $email);
    $mymail = new PlMailer();
    $mymail->setFrom($from);
    $mymail->addCc($cc);
    $mymail->setSubject("Dans 1 semaine, suppression de {$email}@" . $user->mainEmailDomain());
    $mymail->setTxtBody($body);
    $mymail->sendTo($user);
}
Пример #2
0
 function handler_homonyms($page, $op = 'list', $target = null)
 {
     $page->changeTpl('admin/homonymes.tpl');
     $page->setTitle('Administration - Homonymes');
     $this->load("homonyms.inc.php");
     if ($target) {
         $user = User::getSilentWithUID($target);
         if (!$user || !($loginbis = select_if_homonym($user))) {
             $target = 0;
         } else {
             $page->assign('user', $user);
             $page->assign('loginbis', $loginbis);
         }
     }
     $page->assign('op', $op);
     $page->assign('target', $target);
     // When we have a valid target, prepare emails.
     if ($target) {
         // Examine what operation needs to be performed.
         switch ($op) {
             case 'mail':
                 S::assert_xsrf_token();
                 send_warning_homonym($user, $loginbis);
                 $op = 'list';
                 $page->trigSuccess('Email envoyé à ' . $user->forlifeEmail() . '.');
                 break;
             case 'correct':
                 S::assert_xsrf_token();
                 fix_homonym($user, $loginbis);
                 send_robot_homonym($user, $loginbis);
                 $op = 'list';
                 $page->trigSuccess('Email envoyé à ' . $user->forlifeEmail() . ', alias supprimé.');
                 break;
         }
     }
     if ($op == 'list') {
         // Retrieves homonyms that are already been fixed.
         $res = XDB::iterator('SELECT  o.email AS homonym, f.email AS forlife, o.expire, f.uid
                                 FROM  email_source_other    AS o
                           INNER JOIN  homonyms_list         AS h ON (o.hrmid = h.hrmid)
                           INNER JOIN  email_source_account  AS f ON (h.uid = f.uid AND f.type = \'forlife\')
                                WHERE  o.expire IS NOT NULL
                             ORDER BY  homonym, forlife');
         $homonyms = array();
         while ($item = $res->next()) {
             $homonyms[$item['homonym']][] = $item;
         }
         $page->assign_by_ref('homonyms', $homonyms);
         // Retrieves homonyms that needs to be fixed.
         $res = XDB::iterator('SELECT  e.email AS homonym, f.email AS forlife, e.expire, e.uid, (e.expire < NOW()) AS urgent
                                 FROM  email_source_account  AS e
                           INNER JOIN  homonyms_list         AS l ON (e.uid = l.uid)
                           INNER JOIN  homonyms_list         AS h ON (l.hrmid = h.hrmid)
                           INNER JOIN  email_source_account  AS f ON (h.uid = f.uid AND f.type = \'forlife\')
                                WHERE  e.expire IS NOT NULL
                             ORDER BY  homonym, forlife');
         $homonyms_to_fix = array();
         while ($item = $res->next()) {
             $homonyms_to_fix[$item['homonym']][] = $item;
         }
         $page->assign_by_ref('homonyms_to_fix', $homonyms_to_fix);
     }
     if ($op == 'correct-conf') {
         $page->assign('robot_mail_text', get_robot_mail_text($user, $loginbis));
     }
     if ($op == 'mail-conf') {
         $page->assign('warning_mail_text', get_warning_mail_text($user, $loginbis));
     }
 }