Exemple #1
0
 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;
 }
Exemple #2
0
 function handler_edit_announce($page, $aid = null)
 {
     global $globals, $platal;
     $page->changeTpl('xnetgrp/announce-edit.tpl');
     $page->assign('new', is_null($aid));
     $art = array();
     if (Post::v('valid') == 'Visualiser' || Post::v('valid') == 'Enregistrer' || Post::v('valid') == 'Supprimer l\'image' || Post::v('valid') == 'Pas d\'image') {
         S::assert_xsrf_token();
         if (!is_null($aid)) {
             $art['id'] = $aid;
         }
         $art['titre'] = Post::v('titre');
         $art['texte'] = Post::v('texte');
         $art['contacts'] = Post::v('contacts');
         $art['promo_min'] = Post::i('promo_min');
         $art['promo_max'] = Post::i('promo_max');
         $art['nom'] = S::v('nom');
         $art['prenom'] = S::v('prenom');
         $art['promo'] = S::v('promo');
         $art['hruid'] = S::user()->login();
         $art['uid'] = S::user()->id();
         $art['expiration'] = Post::v('expiration');
         $art['public'] = Post::has('public');
         $art['xorg'] = Post::has('xorg');
         $art['nl'] = Post::has('nl');
         $art['event'] = Post::v('event');
         $upload = new PlUpload(S::user()->login(), 'xnetannounce');
         $this->upload_image($page, $upload);
         $art['contact_html'] = $art['contacts'];
         if ($art['event']) {
             $art['contact_html'] .= "\n{$globals->baseurl}/{$platal->ns}events/sub/{$art['event']}";
         }
         if (!$art['public'] && ($art['promo_min'] > $art['promo_max'] && $art['promo_max'] != 0 || $art['promo_min'] != 0 && ($art['promo_min'] <= 1900 || $art['promo_min'] >= 2020) || $art['promo_max'] != 0 && ($art['promo_max'] <= 1900 || $art['promo_max'] >= 2020))) {
             $page->trigError("L'intervalle de promotions est invalide.");
             Post::kill('valid');
         }
         if (!trim($art['titre']) || !trim($art['texte'])) {
             $page->trigError("L'article doit avoir un titre et un contenu.");
             Post::kill('valid');
         }
         if (Post::v('valid') == 'Supprimer l\'image') {
             $upload->rm();
             Post::kill('valid');
         }
         $art['photo'] = $upload->exists() || Post::i('photo');
         if (Post::v('valid') == 'Pas d\'image' && !is_null($aid)) {
             XDB::query('DELETE FROM  group_announces_photo
                               WHERE  eid = {?}', $aid);
             $upload->rm();
             Post::kill('valid');
             $art['photo'] = false;
         }
     }
     if (Post::v('valid') == 'Enregistrer') {
         $promo_min = $art['public'] ? 0 : $art['promo_min'];
         $promo_max = $art['public'] ? 0 : $art['promo_max'];
         $flags = new PlFlagSet();
         if ($art['public']) {
             $flags->addFlag('public');
         }
         if ($art['photo']) {
             $flags->addFlag('photo');
         }
         if (is_null($aid)) {
             $fulltext = $art['texte'];
             if (!empty($art['contact_html'])) {
                 $fulltext .= "\n\n'''Contacts :'''\\\\\n" . $art['contact_html'];
             }
             $post = null;
             if ($globals->asso('forum')) {
                 require_once 'banana/forum.inc.php';
                 $banana = new ForumsBanana(S::user());
                 $post = $banana->post($globals->asso('forum'), null, $art['titre'], MiniWiki::wikiToText($fulltext, false, 0, 80));
             }
             XDB::query('INSERT INTO  group_announces (uid, asso_id, create_date, titre, texte, contacts,
                                                       expiration, promo_min, promo_max, flags, post_id)
                              VALUES  ({?}, {?}, NOW(), {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})', S::i('uid'), $globals->asso('id'), $art['titre'], $art['texte'], $art['contact_html'], $art['expiration'], $promo_min, $promo_max, $flags, $post);
             $aid = XDB::insertId();
             if ($art['photo']) {
                 list($imgx, $imgy, $imgtype) = $upload->imageInfo();
                 XDB::execute('INSERT INTO  group_announces_photo
                                       SET  eid = {?}, attachmime = {?}, x = {?}, y = {?}, attach = {?}', $aid, $imgtype, $imgx, $imgy, $upload->getContents());
             }
             if ($art['xorg']) {
                 $article = new EvtReq("[{$globals->asso('nom')}] " . $art['titre'], $fulltext, $art['promo_min'], $art['promo_max'], $art['expiration'], "", S::user(), $upload);
                 $article->submit();
                 $page->trigWarning("L'affichage sur la page d'accueil de Polytechnique.org est en attente de validation.");
             } else {
                 if ($upload && $upload->exists()) {
                     $upload->rm();
                 }
             }
             if ($art['nl']) {
                 $article = new NLReq(S::user(), $globals->asso('nom') . " : " . $art['titre'], $art['texte'], $art['contact_html']);
                 $article->submit();
                 $page->trigWarning("La parution dans la Lettre Mensuelle est en attente de validation.");
             }
         } else {
             XDB::query('UPDATE  group_announces
                            SET  titre = {?}, texte = {?}, contacts = {?}, expiration = {?},
                                 promo_min = {?}, promo_max = {?}, flags = {?}
                          WHERE  id = {?} AND asso_id = {?}', $art['titre'], $art['texte'], $art['contacts'], $art['expiration'], $promo_min, $promo_max, $flags, $art['id'], $globals->asso('id'));
             if ($art['photo'] && $upload->exists()) {
                 list($imgx, $imgy, $imgtype) = $upload->imageInfo();
                 XDB::execute('INSERT INTO  group_announces_photo (eid, attachmime, attach, x, y)
                                    VALUES  ({?}, {?}, {?}, {?}, {?})
                   ON DUPLICATE KEY UPDATE  attachmime = VALUES(attachmime), attach = VALUES(attach), x = VALUES(x), y = VALUES(y)', $aid, $imgtype, $upload->getContents(), $imgx, $imgy);
                 $upload->rm();
             }
         }
     }
     if (Post::v('valid') == 'Enregistrer' || Post::v('valid') == 'Annuler') {
         pl_redirect("");
     }
     if (empty($art) && !is_null($aid)) {
         $res = XDB::query("SELECT  *, FIND_IN_SET('public', flags) AS public,\n                                       FIND_IN_SET('photo', flags) AS photo\n                                 FROM  group_announces\n                                WHERE  asso_id = {?} AND id = {?}", $globals->asso('id'), $aid);
         if ($res->numRows()) {
             $art = $res->fetchOneAssoc();
             $art['contact_html'] = $art['contacts'];
         } else {
             $page->kill("Aucun article correspond à l'identifiant indiqué.");
         }
     }
     if (is_null($aid)) {
         $events = XDB::iterator("SELECT *\n                                      FROM group_events\n                                     WHERE asso_id = {?} AND archive = 0", $globals->asso('id'));
         if ($events->total()) {
             $page->assign('events', $events);
         }
     }
     $art['contact_html'] = @MiniWiki::WikiToHTML($art['contact_html']);
     $page->assign('art', $art);
     $page->assign_by_ref('upload', $upload);
 }
Exemple #3
0
 /** 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
 }
Exemple #4
0
 public function commit()
 {
     /* TODO: refines this filter on promotions by using userfilter. */
     if (XDB::execute("INSERT INTO  announces\n                         SET  uid = {?}, creation_date=NOW(), titre={?}, texte={?},\n                              expiration={?}, promo_min={?}, promo_max={?}, flags=CONCAT(flags,',valide,wiki')", $this->user->id(), $this->titre, $this->texte, $this->expiration, $this->pmin, $this->pmax)) {
         $eid = XDB::insertId();
         if ($this->img) {
             XDB::execute("INSERT INTO announce_photos\n                                      SET eid = {?}, attachmime = {?}, x = {?}, y = {?}, attach = {?}", XDB::insertId(), $this->imgtype, $this->imgx, $this->imgy, $this->img);
         }
         global $globals;
         if ($globals->banana->event_forum) {
             require_once 'banana/forum.inc.php';
             $banana = new ForumsBanana($this->user);
             $post = $banana->post($globals->banana->event_forum, $globals->banana->event_reply, $this->titre, MiniWiki::wikiToText($this->texte, false, 0, 80));
             if ($post != -1) {
                 XDB::execute("UPDATE  announces\n                                     SET  creation_date = creation_date, post_id = {?}\n                                   WHERE  id = {?}", $post, $eid);
             }
         }
         return true;
     }
     return false;
 }