Some improvements to [1057]:
authorx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Wed, 8 Nov 2006 09:07:16 +0000 (09:07 +0000)
committerx2003bruneau <x2003bruneau@839d8a87-29fc-0310-9880-83ba4fa771e5>
Wed, 8 Nov 2006 09:07:16 +0000 (09:07 +0000)
* check promotion range
* fix public attribute behaviour

git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1058 839d8a87-29fc-0310-9880-83ba4fa771e5

modules/xnetgrp.php
templates/xnet/groupe/announce-edit.tpl
templates/xnet/groupe/asso.tpl

index 4c624b7..c5e2dc1 100644 (file)
@@ -148,7 +148,7 @@ class XnetGrpModule extends PLModule
                                      FROM groupex.announces AS a
                                INNER JOIN auth_user_md5 AS u USING(user_id)
                                     WHERE asso_id = {?} AND peremption >= CURRENT_DATE()
-                                          AND FIND_IN_SET(u.flags, 'public')",
+                                          AND FIND_IN_SET(a.flags, 'public')",
                                   $globals->asso('id'));
         }
 
@@ -897,21 +897,32 @@ class XnetGrpModule extends PLModule
             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_min'] != 0 && ($art['promo_min'] <= 1900 || $art['promo_min'] >= 2020)) ||
+                 ($art['promo_max'] != 0 && ($art['promo_max'] <= 1900 || $art['promo_max'] >= 2020))))
+            {
+                $page->trig("L'intervalle de promotions est invalide");
+                Post::kill('valid');
+            }
         }
 
         if (Post::v('valid') == 'Enregistrer') {
+            $promo_min = ($art['public'] ? 0 : $art['promo_min']);
+            $promo_max = ($art['public'] ? 0 : $art['promo_max']);
             if (is_null($aid)) {
                 XDB::query("INSERT INTO groupex.announces
                                  (user_id, asso_id, create_date, titre, texte, contacts,
                                    peremption, promo_min, promo_max, flags)
                             VALUES ({?}, {?}, NOW(), {?}, {?}, {?}, {?}, {?}, {?}, {?})",
                            S::i('uid'), $globals->asso('id'), $art['titre'], $art['texte'], $art['contact_html'],
-                           $art['peremption'], $art['promo_min'], $art['promo_max'], $art['public'] ? 'public' : '');
+                           $art['peremption'], $promo_min, $promo_max, $art['public'] ? 'public' : '');
                 $aid = mysql_insert_id();
                 if ($art['xorg']) {
                     require_once('validations.inc.php');
                     require_once('url_catcher.inc.php');
-                    $article = new EvtReq($art['titre'],
+                    $article = new EvtReq("[{$globals->asso('nom')}] " . $art['titre'],
                                     url_catcher($art['texte'] . (!empty($art['contacts']) ? "\n\nContacts :\n" . $art['contacts'] : "")),
                                     $art['promo_min'], $art['promo_max'], $art['peremption'], "", S::v('uid'));
                     $article->submit();
@@ -919,7 +930,8 @@ class XnetGrpModule extends PLModule
                 }
                 if ($art['nl']) {
                     require_once('validations.inc.php');
-                    $article = new NLReq(S::v('uid'), $art['titre'], $art['texte'], $art['contact_html']);
+                    $article = new NLReq(S::v('uid'), $globals->asso('nom') . " : " .$art['titre'],
+                                         $art['texte'], $art['contact_html']);
                     $article->submit();
                     $page->trig("La parution dans la Lettre Mensuelle est en attente de validation");
                 }
@@ -929,9 +941,11 @@ class XnetGrpModule extends PLModule
                                    promo_min={?}, promo_max={?}, flags={?}
                              WHERE id={?} AND asso_id={?}",
                            $art['titre'], $art['texte'], $art['contacts'], $art['peremption'],
-                           $art['promo_min'], $art['promo_max'],  $art['public'] ? 'public' : '',
+                           $promo_min, $promo_max,  $art['public'] ? 'public' : '',
                            $art['id'], $globals->asso('id'));
             }
+        }
+        if (Post::v('valid') == 'Enregistrer' || Post::v('valid') == 'Annuler') {
             pl_redirect("");
         } 
 
index 927b3d6..4f1da7a 100644 (file)
 {*                                                                        *}
 {**************************************************************************}
 
+<script type="text/javascript">
+{literal}
+function visibilityChange(box)
+{
+    var state = (box.checked ? 'none' : 'normal');
+    document.getElementById('promo_titre').style.display = state;
+    document.getElementById('promo_min').style.display = state;
+    document.getElementById('promo_max').style.display = state;
+    document.getElementById('promo_desc').style.display = state;
+}
+{/literal}
+</script>
 <h1>{$asso.nom} : Edition d'une annonce</h1>
 
 {if $art.texte}
 
   <table class="tinybicol">
     <tr>
-      <th colspan="2">Promotions cibles</th>
-    </tr>
-    <tr>
-      <td class="titre">Promotion minimale :</td>
-      <td>
-        <input type="text" size="4" maxlength="4" name="promo_min" value="{$art.promo_min|default:0}" />
-        incluse*  (ex : 1980)
-      </td>
-    </tr>
-    <tr>
-      <td class="titre">Promotion minimale :</td>
-      <td>
-        <input type="text" size="4" maxlength="4" name="promo_max" value="{$art.promo_max|default:0}" />
-        incluse*  (ex : 2000)
-      </td>
-    </tr>
-    <tr class="pair">
-      <td colspan="2">
-        <small>* 0 signifie qu'il n'y a pas de limite</small>
-      </td>
-    </tr>
-    <tr>
-      <th colspan="2">Options</th>
-    </tr>
-    <tr>
       <td class="titre">Date de péremption :</td>
       <td>
         <select name="peremption">
       </td>
     </tr>
     {/if}
-    <tr> 
+    <tr>
       <td class="titre">Visibilité :</td>
       <td>
-        <input type="checkbox" name="public" {if $art.public}checked="checked"{/if} />
+        <input type="checkbox" name="public" {if $art.public}checked="checked"{/if} onchange="visibilityChange(this)" />
         Rendre cette annonce publique
       </td>
     </tr>
+    <tr id="promo_titre" {if $art.public}style="display: none"{/if}>
+      <th colspan="2">Promotions cibles</th>
+    </tr>
+    <tr id="promo_min"  {if $art.public}style="display: none"{/if}>
+      <td class="titre">Promotion minimale :</td>
+      <td>
+        <input type="text" size="4" maxlength="4" name="promo_min" value="{$art.promo_min|default:0}" />
+        incluse*  (ex : 1980)
+      </td>
+    </tr>
+    <tr id="promo_max"  {if $art.public}style="display: none"{/if}>
+      <td class="titre">Promotion minimale :</td>
+      <td>
+        <input type="text" size="4" maxlength="4" name="promo_max" value="{$art.promo_max|default:0}" />
+        incluse*  (ex : 2000)
+      </td>
+    </tr>
+    <tr class="pair" id="promo_desc"  {if $art.public}style="display: none"{/if}>
+      <td colspan="2">
+        <small>* 0 signifie qu'il n'y a pas de limite</small>
+      </td>
+    </tr>
     {if $new}
     <tr>
       <th colspan="2">Demandes de publication</th>
index 7ba1550..24a9b35 100644 (file)
   <tr>
     <td>&bull; 
     {if $art.nonlu}
-      <a href="{$platal->ns}#art{$art.id}">
+      <a href="{$platal->ns}#art{$art.id}"><strong>
     {else}
-      <a href="{$platal->ns}?unread={$art.id}"><strong>
+      <a href="{$platal->ns}?unread={$art.id}">
     {/if}
     {tidy}{$art.titre}{/tidy}
-    {if !$art.nonlu}</strong>{/if}</a>
+    {if $art.nonlu}</strong>{/if}</a>
     </td>
   </tr>
   {/iterate}