Automatically create a new pending issue if it doesn't exist when committing an artic...
[platal.git] / include / validations / nl.inc.php
index 74ff546..2c17f2b 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /***************************************************************************
- *  Copyright (C) 2003-2008 Polytechnique.org                              *
+ *  Copyright (C) 2003-2011 Polytechnique.org                              *
  *  http://opensource.polytechnique.org/                                   *
  *                                                                         *
  *  This program is free software; you can redistribute it and/or modify   *
@@ -33,10 +33,10 @@ class NLReq extends Validate
     // }}}
     // {{{ constructor
 
-    public function __construct($uid, $title, $body, $append)
+    public function __construct(User &$_user, $_title, $_body, $_append)
     {
-        parent::__construct($uid, false, 'nl');
-        $this->art = new NLArticle($title, $body, $append);
+        parent::__construct($_user, false, 'nl');
+        $this->art = new NLArticle($_title, $_body, $_append);
     }
 
     // }}}
@@ -60,9 +60,9 @@ class NLReq extends Validate
 
     protected function handle_editor()
     {
-        $this->art->_body   = Env::v('nl_body');
-        $this->art->_title  = Env::v('nl_title');
-        $this->art->_append = Env::v('nl_append');
+        $this->art->body   = Env::v('nl_body');
+        $this->art->title  = Env::v('nl_title');
+        $this->art->append = Env::v('nl_append');
         return true;
     }
 
@@ -80,18 +80,33 @@ class NLReq extends Validate
     protected function _mail_body($isok)
     {
         if ($isok) {
-            return '  L\'article que tu avais proposé ('.$this->art->title().') vient d\'être validé.';
+            return "  L'article que tu avais proposé (" . $this->art->title() . ") vient d'être validé.";
         } else {
-            return '  L\'article que tu avais proposé ('.$this->art->title().') a été refusé.';
+            return "  L'article que tu avais proposé a été refusé.";
         }
     }
 
     // }}}
+    // {{{ function _mail_ps
+
+    protected function _mail_ps($isok)
+    {
+        if ($isok) {
+            return '';
+        }
+        return "\nPS : pour rappel, en voici le contenu :"
+            . "\n--------------------------------------------------------------------------\n"
+            . $this->art->title()
+            . "\n--------------------------------------------------------------------------\n"
+            . $this->art->body() . "\n\n" . $this->art->append() . "\n";
+    }
+
+    // }}}
     // {{{ function commit()
 
     public function commit()
     {
-        $nl  = new Newsletter();
+        $nl = NewsLetter::forGroup(NewsLetter::GROUP_XORG)->getPendingIssue(true);
         $nl->saveArticle($this->art);
         return true;
     }