X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fvalidations%2Fevts.inc.php;h=c33ce5e06309cff271f3ec62426e1db8983ec6c5;hb=a7d35093a40837b3a17d7fbac0259995f084812c;hp=6714ab75358ab7848a02c26940ca4fe6aad9d654;hpb=0337d704b62718d7c77106c0e4c4e26fb02beacf;p=platal.git diff --git a/include/validations/evts.inc.php b/include/validations/evts.inc.php index 6714ab7..c33ce5e 100644 --- a/include/validations/evts.inc.php +++ b/include/validations/evts.inc.php @@ -1,6 +1,6 @@ Validate($_uid, false, 'evts'); + public function __construct($_titre, $_texte, $_pmin, $_pmax, $_peremption, $_comment, $_uid, PlUpload &$upload = null) + { + parent::__construct($_uid, false, 'evts'); $this->titre = $_titre; $this->texte = $_texte; $this->pmin = $_pmin; $this->pmax = $_pmax; $this->peremption = $_peremption; $this->comment = $_comment; + if ($upload) { + $this->readImage($upload); + } + } + + // }}} + // {{{ function readImage() + + private function readImage(PlUpload &$upload) + { + if ($upload->exists() && $upload->isType('image')) { + list($this->imgx, $this->imgy, $this->imgtype) = $upload->imageInfo(); + $this->img = $upload->getContents(); + $upload->rm(); + } } // }}} // {{{ function formu() - function formu() - { return 'include/form.valid.evts.tpl'; } + public function formu() + { + return 'include/form.valid.evts.tpl'; + } + + // }}} + // {{{ functon editor() + + public function editor() + { + return 'include/form.valid.edit-evts.tpl'; + } + + // }}} + // {{{ function handle_editor() + + protected function handle_editor() + { + $this->titre = Env::v('titre'); + $this->texte = Env::v('texte'); + $this->pmin = Env::i('promo_min'); + $this->pmax = Env::i('promo_max'); + $this->peremption = Env::v('peremption'); + if (@$_FILES['image']['tmp_name']) { + $upload = PlUpload::get($_FILES['image'], S::v('forlife'), 'event'); + if (!$upload) { + $this->trigError("Impossible de télécharger le fichier"); + } elseif (!$upload->isType('image')) { + $page->trigError('Le fichier n\'est pas une image valide au format JPEG, GIF ou PNG'); + $upload->rm(); + } elseif (!$upload->resizeImage(200, 300, 100, 100, 32284)) { + $page->trigError('Impossible de retraiter l\'image'); + } else { + $this->readImage($upload); + } + } + return true; + } // }}} // {{{ function _mail_subj - - function _mail_subj() + + protected function _mail_subj() { - return "[Polytechnique.org/EVENEMENTS] Proposition d'événement"; + return "[Polytechnique.org/EVENEMENTS] Proposition d'événement"; } // }}} // {{{ function _mail_body - function _mail_body($isok) + protected function _mail_body($isok) { if ($isok) { - return " L'annonce que tu avais proposée ({$this->titre}) vient d'être validée."; + return " L'annonce que tu avais proposée ({$this->titre}) vient d'être validée."; } else { - return " L'annonce que tu avais proposée ({$this->titre}) a été refusée."; + return " L'annonce que tu avais proposée ({$this->titre}) a été refusée."; } } // }}} // {{{ function commit() - function commit() + public function commit() { - global $globals; - return $globals->xdb->execute( - "INSERT INTO evenements + if (XDB::execute("INSERT INTO evenements SET user_id = {?}, creation_date=NOW(), titre={?}, texte={?}, - peremption={?}, promo_min={?}, promo_max={?}, flags=CONCAT(flags,',valide')", + peremption={?}, promo_min={?}, promo_max={?}, flags=CONCAT(flags,',valide,wiki')", $this->uid, $this->titre, $this->texte, - $this->peremption, $this->pmin, $this->pmax); + $this->peremption, $this->pmin, $this->pmax)) { + $eid = XDB::insertId(); + if ($this->img) { + XDB::execute("INSERT INTO evenements_photo + 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 'user.func.inc.php'; + $forlife = get_user_forlife($this->uid); + require_once 'banana/forum.inc.php'; + $banana = new ForumsBanana($forlife); + $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 evenements + SET creation_date = creation_date, post_id = {?} + WHERE id = {?}", $post, $eid); + } + } + return true; + } + return false; } // }}} @@ -92,5 +170,5 @@ class EvtReq extends Validate // }}} -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker: +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: ?>