#427, avoir des commentaires de réponses par défaut dans la validation
authorx2001corpet <x2001corpet@839d8a87-29fc-0310-9880-83ba4fa771e5>
Sun, 30 Jul 2006 09:44:43 +0000 (09:44 +0000)
committerx2001corpet <x2001corpet@839d8a87-29fc-0310-9880-83ba4fa771e5>
Sun, 30 Jul 2006 09:44:43 +0000 (09:44 +0000)
git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@706 839d8a87-29fc-0310-9880-83ba4fa771e5

ChangeLog
include/validations.inc.php
modules/admin.php
templates/admin/valider.tpl
upgrade/0.9.11/06_validations.sql [new file with mode: 0644]

index 268aa1e..204fa9c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -75,11 +75,12 @@ New:
 Bug/Wish:
 
     * Admin:
+        - #390: Add date of request in validation form.                    -FRU
+        - #397: Can edit death date in user admin page.                    -FRU
+        - #427: Automatic answers for validation.                          -Car
+        - #429: Tools to administrate duplicated adresses.                 -FRU
         - #430: Specify date format on downtime admin page.                -Car
-        - #397: Can edit death date in user admin page                     -FRU
-        - #429: Tools to administrate duplicated adresses                  -FRU
-        - #390: Add date of request in validation form                     -FRU
-        - #440: Rewrite events admin page                                  -FRU
+        - #440: Rewrite events admin page.                                 -FRU
 
     * Carnet:
         - #435: Calendar contains yearly events for all the contacts.      -FRU
@@ -90,17 +91,17 @@ Bug/Wish:
         - #426: Add an identification header in mails.                     -FRU
 
     * Lists:
-        - #127: Add promo in member list when sorted by name               -FRU
-        - #423: Allow line breaks in mailing list descriptions             -FRU
+        - #127: Add promo in member list when sorted by name.              -FRU
+        - #423: Allow line breaks in mailing list descriptions.            -FRU
 
     * Profile:
         - #344: Tels can be bigger (up to 30 chars).                       -Car
-        - #422: Parasitic strings in vcard                                 -FRU
+        - #422: Parasitic strings in vcard.                                -FRU
 
     * Xnet:
         - #426: Add an identification header in mails.                     -FRU
-        - #384: substitution of non-X's names in mail from web interface   -FRU
-        - #380: Add sex for non-X                                          -FRU
+        - #384: Substitution of non-X's names in mail from web interface.  -FRU
+        - #380: Add sex for non-X.                                         -FRU
 
 From 0.9.10 Branch:
 
index dc97259..9de580f 100644 (file)
@@ -294,6 +294,19 @@ class Validate
     { return null; }
 
     // }}}
+    // {{{ function answers()
+
+    /** automatic answers table for this type of validation */
+    function answers() {
+        static $answers_table;
+        if (!isset($answers_table[$this->type])) {
+            $r = XDB::query("SELECT id, title, answer FROM requests_answers WHERE category = {?}", $this->type);
+            $answers_table[$this->type] = $r->fetchAllAssoc($r);
+        }
+        return $answers_table[$this->type];
+    }
+
+    // }}}
 }
 
 foreach (glob(dirname(__FILE__).'/validations/*.inc.php') as $file) {
index 1e09b8a..f39dac8 100644 (file)
@@ -39,6 +39,7 @@ class AdminModule extends PLModule
             'admin/synchro_ax'             => $this->make_hook('synchro_ax', AUTH_MDP, 'admin'),
             'admin/user'                   => $this->make_hook('user', AUTH_MDP, 'admin'),
             'admin/validate'               => $this->make_hook('validate', AUTH_MDP, 'admin'),
+            'admin/validate/answers'       => $this->make_hook('validate_answers', AUTH_MDP, 'admin'),
             'admin/wiki'                   => $this->make_hook('wiki', AUTH_MDP, 'admin'),
         );
     }
@@ -466,6 +467,16 @@ class AdminModule extends PLModule
         
         $page->assign('vit', new ValidateIterator());
     }
+    function handler_validate_answers(&$page, $action = 'list', $id = null) {
+        require_once('../classes/PLTableEditor.php');
+        $page->assign('xorg_title','Polytechnique.org - Administration - Réponses automatiques de validation');
+        $page->assign('title', 'Gestion des réponses automatiques');
+        $table_editor = new PLTableEditor('admin/validate/answers','requests_answers','id');
+        $table_editor->describe('category','catégorie',true);
+        $table_editor->describe('title','titre',true);
+        $table_editor->describe('answer','texte',false);
+        $table_editor->apply($page, $action, $id);
+    }
     function handler_skins(&$page, $action = 'list', $id = null) {
         require_once('../classes/PLTableEditor.php');
         $page->assign('xorg_title','Polytechnique.org - Administration - Skins');
index 6ad4a45..93e4000 100644 (file)
   </tr>
   <tr><th colspan='2'>Réponse</th></tr>
   <tr>
-    <td colspan='2' class='center' {popup caption="Règles de validation" text=$valid->rules}>
+    <td colspan='2' {popup caption="Règles de validation" text=$valid->rules}>
       <form action="admin/validate" method="post">
         <div>
+          Réponse préremplie :
+          <select onchange="this.form.comm.value=this.value">
+            <option value=""></option>
+            {foreach from=$valid->answers() item=automatic_answer}
+              <option value="{$automatic_answer.answer}">{$automatic_answer.title}</option>
+            {/foreach}
+          </select>
+          <a href="admin/validate/answers">{icon name="page_edit" title="Editer les réponses automatiques"}</a>
+        </div>
+        <div class='center'>
           Ajouté dans l'email :<br />
           <textarea rows="5" cols="50" name="comm"></textarea><br />
 
diff --git a/upgrade/0.9.11/06_validations.sql b/upgrade/0.9.11/06_validations.sql
new file mode 100644 (file)
index 0000000..b3ca18d
--- /dev/null
@@ -0,0 +1,6 @@
+CREATE TABLE `requests_answers` (\r
+`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,\r
+`category` ENUM( 'alias', 'list', 'nomusage', 'photo', 'evt', 'marketing', 'orange', 'homonyme', 'nl', 'paiement' ) NOT NULL ,\r
+`title` VARCHAR( 50 ) NOT NULL ,\r
+`answer` TEXT NOT NULL\r
+);\r