$res = XDB::query('SELECT id, target, writer, writername, title, body, ishtml FROM mails WHERE processed IS NULL')->fetchAllRow(); $ids = array(); if (count($res) == 0) { exit; } foreach ($res as $r) { $ids[] = $r[0]; } XDB::execute('UPDATE mails SET processed = NOW() WHERE id IN {?}', $ids); XDB::commit(); foreach ($res as $r) { $uf = new UserFilter($r[1]); $users = $uf->get(); $users->select(UserSelect::base()); foreach ($users as $user) { $mail = new FrankizMailer(); $mail->addAddress($user->bestEmail(), $user->fullName()); $mail->SetFrom($r[2], $r[3]); $mail->subject($r[4]); $mail->body($r[5]); $mail->send($r[6]); } XDB::execute('UPDATE mails SET done = NOW() WHERE id = {?}', $r[0]); } // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
function handler_participants($page, $id) { $act = new ActivityInstanceFilter(new PFC_AND(new AIFC_CanBeSeen(S::user()), new AIFC_Id($id))); $act = $act->get(true); if ($act === false) { throw new Exception("Invalid credentials"); } $act->select(ActivityInstanceSelect::all()); if (Env::has('mail')) { S::assert_xsrf_token(); if (Env::t('mail_body') != '' && s::user()->id() == $act->writer()->id()) { $mail = new FrankizMailer(); $mail->subject('[Mail groupé] Activité ' . $act->title() . ' du ' . $act->date() . ' à ' . $act->hour_begin()); $mail->body(Env::t('mail_body')); $mail->setFrom(S::user()->bestEmail(), S::user()->displayName()); $mail->toUserFilter(new UserFilter(new UFC_ActivityInstance($act->id()))); $mail->sendLater(false); } else { $page->assign('msg', 'Votre mail n\'est pas rempli.'); } } $page->assign('user', s::user()); $page->assign('id', $id); $page->assign('activity', $act); $page->assign('title', 'Participants à une activité'); $page->addCssLink('activity.css'); $page->changeTpl('activity/participants.tpl'); }
public function commit() { $mail = new FrankizMailer(); $sub = $this->type_mail == 'promo' ? 'promo' : $this->formation->label(); $mail->subject('[Mail ' . $sub . '] ' . $this->subject); if ($this->origin) { global $globals; $mail->setFrom($this->origin->name() . '@' . $globals->mails->group_suffix, 'Frankiz - ' . $this->origin->label() . ''); } else { $mail->setFrom($this->writer->bestEmail(), $this->writer->fullName()); } if ($this->type_mail == 'promo' && !$this->targets) { $uf = new UserFilter(new PFC_AND(new UFC_Group($this->formation), new UFC_Group(Group::from('on_platal')))); } else { if ($this->type_mail == 'promo') { $uf = new UserFilter(new PFC_AND(new UFC_Group($this->formation), new UFC_Caste($this->targets), new UFC_Group(Group::from('on_platal')))); } else { $uf = new UserFilter(new PFC_AND(new UFC_Caste($this->targets->first()), new UFC_Group(Group::from('on_platal')))); } } if (!$this->nowiki) { $mail->body(MiniWiki::wikiToHTML($this->body, false)); } else { $mail->body(MiniWiki::wikiToText($this->body, false, 0, 80)); } $mail->ToUserFilter($uf); $mail->sendLater(!$this->nowiki); return true; }
/** Sends the news items to the newsgroups via mail. */ public function sendnewsgroupmail() { global $globals; if ($this->target->group()->ns() == Group::NS_BINET) { $mail = new FrankizMailer(); $suffix = $globals->mails->newsgroup_suffix; if (!$suffix) { $suffix = 'news.eleves.polytechnique.fr'; } $mail->addAddress('br.binet.' . $this->target->group()->name() . '@' . $suffix); if ($this->origin) { $mail->setFrom($this->origin->name() . '@' . $globals->mails->group_suffix, $this->origin->label()); } else { $mail->setFrom($this->writer->bestEmail(), $this->writer->displayName()); } $mail->subject('[Frankiz] ' . $this->title); $mail->body(MiniWiki::wikiToText($this->content, false, 0, 80)); $mail->send(false); } //But what else }