[Devel] r427 - branches/dui

svn at agendadulibre.org svn at agendadulibre.org
Dim 1 Mar 18:37:24 CET 2009


Author: ldayot
Date: Sun Mar  1 18:37:22 2009
New Revision: 427

Log:
Nouveau script de definition des propriete et methode de l'objet event.
Ca rend beaucoup plus simple le develeppement des autres scripts.
Attention, il s'agit de la version DUI de l'agenda du libre. c'est facilement declinable 
sur la version officielle.
Les autres modifications suivent, mais elles ne passeront pas sur la liste car c'est 
trop volumineux.

Added:
   branches/dui/class.event.inc.php

Added: branches/dui/class.event.inc.php
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ branches/dui/class.event.inc.php	Sun Mar  1 18:37:22 2009	(r427)
@@ -0,0 +1,715 @@
+<?php
+
+/* Copyright 2004-2009
+ * - Melanie Bats <melanie POINT bats CHEZ utbm POINT fr>
+ * - Thomas Petazzoni <thomas POINT petazzoni CHEZ enix POINT org>
+ * - Loic Dayot <ldayot CHEZ ouvaton POINT org>
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+//require_once("class.db.inc.php");
+
+class event {
+  var $id;
+  var $title,
+      $description,
+      $start_time,
+      $end_time,
+      $address,
+      $postalcode,
+      $city,
+      $department,
+      $region,
+      $latitude,
+      $longitude,
+      $locality,
+      $url,
+      $contact,
+      $submitter,
+      $moderated,
+      $secret,
+      $decision_time,
+      $submission_time;
+  var $tags;
+  var $error, $message;
+  var $db;
+
+  // -------------------------------------------------------------------
+
+  function event($db, $id)
+  {
+    $this->db = $db;
+    $this->error = 0;
+    $this->message = "";
+    if ($id>0)
+    {
+      $this->id = $id;
+      $this->get($db);
+    }
+    return ! $this->error;
+  }
+    
+  // -------------------------------------------------------------------  
+    
+  function get()
+  {
+    $query = "SELECT * FROM events WHERE id=" . $this->db->quote_smart($this->id);
+    $result = $this->db->query ($query);
+    if (! ($record = $this->db->fetchObject($result)))
+    {
+      $this->message = "Aucun évènement avec l'ID ". $this->id;
+      $this->error = true;
+      return false;
+    }
+    $this->title            = $record->title;
+    $this->description      = $record->description;
+    $this->start_time       = $record->start_time;
+    $this->end_time         = $record->end_time;
+    $this->start            = strtotime($this->start_time);
+    $this->end              = strtotime($this->end_time);
+    $this->address          = $record->address;
+    $this->postalcode       = $record->postalcode;
+    $this->city             = $record->city;
+    $this->department       = $record->department;
+    $this->region           = $record->region;
+    $this->latitude         = $record->latitude;
+    $this->longitude        = $record->longitude;
+    $this->locality         = $record->locality;
+    $this->url              = $record->url;
+    $this->contact          = $record->contact;
+    $this->submitter        = $record->submitter;
+    $this->moderated        = $record->moderated;
+    $this->secret           = $record->secret;
+    $this->decision_time    = $record->decision_time;
+    $this->submission_time  = $record->submission_time;
+    $this->tags             = eventTagsList($this->id);
+
+    $this->message = "";
+    $this->error = false;
+    return true;
+  }
+
+  // -------------------------------------------------------------------
+
+  function save()
+  {
+    $sql = ($this->id>0 ? "UPDATE " : "INSERT INTO ");
+    $sql .= "events SET " .
+      "title=" .       $this->db->quote_smart ($this->title)                        . ", " .
+      "start_time=" .  $this->db->quote_smart (date_timestamp2mysql ($this->start)) . ", ".
+      "end_time=" .    $this->db->quote_smart (date_timestamp2mysql ($this->end))   . ", ".
+      "description=" . $this->db->quote_smart ($this->description)                  . ", ".
+      "address=" .     $this->db->quote_smart ($this->address)                      . ", ".
+      "postalcode=" .  $this->db->quote_smart ($this->postalcode)                   . ", ".
+      "city=" .        $this->db->quote_smart ($this->city)                         . ", ".
+      "region=" .      $this->db->quote_smart ($this->region)                       . ", ".
+      "latitude=" .    $this->db->quote_smart ($this->latitude)                      . "," .
+      "longitude=" .   $this->db->quote_smart ($this->longitude)                     . "," .
+      "locality=" .    $this->db->quote_smart ($this->locality)                     . ", ".
+      "url=" .         $this->db->quote_smart ($this->url)                          . ", ".
+      "contact=" .     $this->db->quote_smart ($this->contact)                      . ", ".
+      "submitter=" .   $this->db->quote_smart ($this->submitter);
+    if ($this->id==0)
+      $sql .= ", moderated='0', ".
+        "secret='" . ($secret = md5(uniqid(rand(), true))) . "', ".
+        "submission_time=NOW()";
+    else
+      $sql .= " WHERE id=" .    $this->db->quote_smart ($this->id);
+
+    $ret = $this->db->query($sql);
+    if ($ret == FALSE)
+    {
+      $this->error=true;
+      $this->message = "La requ&ecirc;te <i>" . $sql . "</i> a &eacute;chou&eacute;";
+      return false;
+    }
+    // about tags
+    if ($this->id==0) $this->id = $this->db->insertid();
+    else
+    {
+      // delete old
+      $query = "DELETE FROM tags_events WHERE event_id='{$this->id}'";
+      $result = $this->db->query($query);
+      if (! $result)
+      {
+        $this->error=true;
+        $this->message=_("Impossible de supprimer les anciens mots-clés");
+        return false;
+      }
+    }
+    // add new
+    // manual tags
+    $aTags = explode(" ", $this->tags);
+    $aTagsKnown = array();
+    // get tags which already exist
+    $query = "SELECT id, name FROM tags WHERE name IN ('". implode("', '", $aTags). "')";
+    $result = $this->db->query($query);
+    if (! $result)
+    {
+      $this->error=true;
+      $this->message=_("Impossible de lire les mots-clés");
+      return false;
+    }
+    while ($record = $this->db->fetchObject($result))
+    {
+      $aTagsKnown[]=$record->name;
+    }
+    // Insert new tags
+    if (count($aTagsNew = array_diff($aTags, $aTagsKnown))>0)
+    {
+      $query = "INSERT INTO tags (name) VALUES ('". implode("'), ('", $aTagsNew). "')";
+      $result = $this->db->query($query);
+      if (! $result)
+      {
+        $this->error=true;
+        $this->message=_("Impossible d'ajouter les mots-clés");
+        return false;
+      }
+    }
+    // make link between event and tags
+    $query = "INSERT INTO tags_events (event_id, tag_id) ".
+      "SELECT {$this->id}, id FROM tags ".
+      "WHERE name IN ('". implode("','", $aTags). "')";
+    $result = $this->db->query($query);
+    if (! $result)
+    {
+      $this->error=true;
+      $this->message=_("Impossible d'attribuer les mots-clés");
+    }
+    return ! $this->error;
+  } // end function_save();
+ 
+  // ------------------------------------------------------------------- 
+
+  function delete()
+  {
+    $sql = "DELETE FROM events WHERE id=" . $this->db->quote_smart($this->id);
+    $ret = $this->db->query($sql);
+    if (! $ret)
+    {
+      $this->error=true;
+      $this->message = returnError("Impossible de supprimer l'événement");
+      error ("La requ&ecirc;te <i>" . $sql . "</i> a &eacute;chou&eacute;");
+      return false;
+    }
+    // delete link between event and tags
+    $query = "DELETE FROM tags_events ".
+      "WHERE event_id=". $this->db->quote_smart($this->id);
+    $ret = $this->db->query($query);
+    if (! $ret)
+    {
+      error("Impossible de supprimer les mots-clés");
+      // not required to return true 
+    }
+    // else
+    // clear tags table of tags not used
+    return true;
+  }
+
+  // ------------------------------------------------------------------- 
+
+  function edit($previewEnable=false, $submitEnable=true, $postUrl="submit.php")
+  {
+    global $adl_form_description_guide, $adl_form_tags_guide;
+
+    echo "<form method=\"post\" action=\"{$postUrl}\">\n";
+
+    if (file_exists("tiny_mce"))
+    {
+      ?>
+  <!-- tinyMCE -->
+  <script language="javascript" type="text/javascript" src="tiny_mce/tiny_mce.js"></script>
+  <script language="javascript" type="text/javascript">
+          // Notice: The simple theme does not use all options some of them are limited to the advanced theme
+          tinyMCE.init({
+                  mode : "textareas",
+                  language : "fr",
+                  theme : "advanced",
+                  plugins : "paste,preview",
+                  theme_advanced_buttons1 : "bold,italic,underline,separator, bullist,numlist,undo,redo,link,unlink,separator,cut,copy,paste,pastetext,pasteword,separator,preview,code",
+                  theme_advanced_buttons2 : "",
+                  theme_advanced_buttons3 : "",
+                  theme_advanced_toolbar_location : "top",
+                  theme_advanced_toolbar_align : "left",
+                  theme_advanced_path_location : "bottom",
+                  plugin_preview_width : "500", 
+                  plugin_preview_height : "600",
+                  extended_valid_elements : "a[name|href|target|title|onclick]"
+          });
+  </script>
+  <!-- /tinyMCE -->
+  <?php
+    } // end if tiny_mce
+
+  ?>
+   <table class='form'>
+
+    <tr><td>Titre*:</td>
+     <td><b>Décrivez en moins de 5 mots votre évènement, sans y indiquer le lieu, la ville ni la date.</b><br/>
+      <input type="text" size="70" name="__event_title" value="<?php echo $this->title;?>"/></td>
+    </tr>
+
+    <tr><td>Début*:</td>
+     <td><?php generate_date_forms("start", $this->start); ?></td>
+    </tr>
+
+    <tr><td>Fin*:<br/><br/></td>
+     <td><?php generate_date_forms("end", $this->end); ?><br/></td>
+    </tr>
+
+    <tr><td>Description*:</td>
+     <td><b>Décrivez de la manière la plus complète possible votre évènement.</b><br/>
+      <?php 
+        if (file_exists("tiny_mce"))
+          echo "<noscript>". $adl_form_description_guide. "</noscript>\n";
+        else
+          echo $adl_form_description_guide. "\n";
+      ?>
+      <textarea rows="25" cols="70" name="__event_description"><?php echo $this->description;?></textarea></td>
+    </tr>
+
+    <tr><td>Adresse:</td>
+     <td><i>Adresse postale seule (numéro, type-de-voie, nom-de-voie), afin de faciliter la géolocalisation.</i><br/>
+      <input type="text" size="70" name="__event_address" value="<?php echo $this->address;?>"/></td>
+    </tr>
+
+    <tr><td>Commune*:</td>
+     <td> <?php
+    if ($this->postalcode==-1)
+    {
+      $city_res = $this->db->query("SELECT * FROM cities WHERE majname LIKE '" . 
+        addslashes(stripslashes(strip_tags($this->city))) . "%'");
+      echo "<input type='hidden' name='__event_postalcode' value='choose' />";
+      echo "<p><strong>Choisir la ville dans la liste</strong> : <select name='__event_city_id'>";
+      echo "<option value=''>Choisir dans la liste ou saisir en dessous</option>";
+      while ($city_record = $this->db->fetchObject($city_res))
+        {
+          echo "<option value='{$city_record->id}'>".
+            substr("0". $city_record->postalcode, -5). " ".
+            $city_record->majname. "</option>";
+        }
+      echo "</select> <br/>ou "; 
+    } ?>
+       <input type="text" size="70" name="__event_city" value="<?php echo $this->city;?>"/>
+      </td>
+    </tr>
+
+    <tr><td>Région*:</td>
+     <td><?php region_select_form($this->db, "__event_region", $this->region); ?></td>
+    </tr>
+
+    <tr><td>Portée*:</td>
+     <td><select name="__event_locality"><?php
+          foreach ($GLOBALS["adl_locality"] as $key=>$value)
+            echo "<option value=\"$key\"". ($this->locality == $key ? " selected=\"selected\"" : ""). ">$value</option>\n";
+        ?></select></td>
+    </tr>
+
+    <tr><td>URL*:</td>
+     <td><i>Lien <b>direct</b> vers une page donnant plus d'informations sur 
+      l'évènement (lieu et horaire précis, programme détaillé...)</i><br/>
+      <input type="text" size="70" name="__event_url" value="<?php echo $this->url;?>"/></td>
+    </tr>
+
+    <tr><td>Contact*:</td>
+     <td><i>Adresse courriel de contact (elle sera transformée de manière à éviter le spam).</i><br/>
+      <input type="text" size="70" name="__event_contact" value="<?php echo $this->contact;?>"/></td>
+    </tr>
+
+    <tr><td>Soumetteur:</td>
+     <td><i>Adresse courriel du soumetteur de l'évènement (qui ne sera utilisée que par les modérateurs pour informer de la validation ou du rejet). A défaut, l'adresse de contact sera utilisée.</i><br/>
+      <input type="text" size="70" name="__event_submitter" value="<?php echo $this->submitter;?>"/></td>
+    </tr>
+  <?php
+    $aCategoryTags = selectWithCategoryTags(explode(" ", $this->tags));
+    foreach ($aCategoryTags->HTML as $category_id=>$aSelect)
+      echo "<tr><td>{$aSelect['categoryName']}:</td>".
+        "<td>{$aSelect['categoryDescription']}<br />".
+        "{$aSelect['HTMLSelect']} </td>\n</tr>\n";
+    $aTags = explode(' ', $aCategoryTags->tagsRest);
+  ?>
+    <tr><td>Mots-clés :</td>
+     <td><?php
+    echo $adl_form_tags_guide;
+    $oTags = selectCategoryTags($aTags, 0, $fieldName="tags[0]", $multiple=true);
+    echo _("Dans les mots-clés courants"). " : <br />". $oTags->HTML;
+    $tags = $oTags->tagsRest;
+    ?><br /><input type="text" size="70" name="__event_tags" value="<?php echo $tags; ?>"/></td>
+    </tr>
+
+   <tr><td></td>
+    <td><?php
+    if ($previewEnable)
+      echo "<input name=\"__event_preview\" type=\"submit\" value=\"Aperçu\"/>";
+    echo "<input name=\"__event_save\" type=\"submit\" value=\"Valider\" ".
+      (! $submitEnable ? "disabled='disabled'" : ""). "/>";
+  ?></td>
+   </tr>
+
+   </table>
+  </form>
+  <?php
+  } // end function_edit
+    
+  // -------------------------------------------------------------------
+
+  /**
+   * Format an event in an ASCII format, suitable for e-mails
+   *
+   * @return An ASCII description of the event
+   */
+  function formatAscii()
+  {
+    global $db;
+    $title       = stripslashes($this->title);
+    $start       = date_timestamp2humanreadable($this->start);
+    $end         = date_timestamp2humanreadable($this->end);
+    $address     = stripslashes($this->address);
+    $postalcode  = stripslashes($this->postalcode);
+    $city        = stripslashes($this->city);
+    $region      = stripslashes(region_find($db, $this->region));
+    $description = stripslashes($this->description);
+    $url         = stripslashes($this->url);
+    $contact     = scramble_email(stripslashes($this->contact));
+    $submitter   = scramble_email(stripslashes($this->submitter));
+    $tags        = stripslashes($this->tags);
+
+    $str =
+      "Titre       : " . $title . "\n" .
+      "Début       : " . $start . "\n".
+      "Fin         : " . $end . "\n" .
+      "Adresse     : " . $address . "\n" .
+      "Code postal : " . $postalcode . "\n" .
+      "Ville       : " . $city . "\n" .
+      "Région      : " . $region . "\n" .
+      "URL         : " . $url . "\n".
+      "Contact     : " . $contact . "\n" .
+      "Soumetteur  : " . $submitter . "\n" .
+      "Mots-clés   : " . $tags . "\n" .
+      "Description : \n " . preg_replace ("/\n/", "\n ", $description);
+
+    return $str;
+  }
+  
+  // -------------------------------------------------------------------
+
+  /**
+   * Format an event so that it can be displayed in a nice fashion
+   *
+   * @param db Database handle
+   *
+   * @param title Title of the event
+   *
+   * @param start Starting time (timestamp format)
+   *
+   * @param end Ending time (timestamp format)
+   *
+   *
+   * @return The HTML code that corresponds to the formatted event
+   */
+  function formatHtml($moderation = FALSE)
+  {
+    $title       = stripslashes($this->title);
+    //$start       = date_timestamp2humanreadable($this->start);
+    $end         = date_timestamp2humanreadable($this->end);
+    $address     = stripslashes($this->address);
+    $postalcode  = stripslashes($this->postalcode);
+    $city        = stripslashes($this->city);
+    $region      = stripslashes(region_find($this->db, $this->region));
+    //$description = stripslashes($this->description);
+    $url         = stripslashes($this->url);
+    $contact     = scramble_email(stripslashes($this->contact));
+
+    $start_day = onlyday_timestamp2humanreadable($this->start);
+    if ($start_day == onlyday_timestamp2humanreadable($this->end)) {
+      $date = "<p>Le " .  $start_day . ", de "
+        . onlyhour_timestamp2humanreadable($this->start) . " &agrave; "
+        . onlyhour_timestamp2humanreadable($this->end) . ".</p>\n";
+    } else {
+      $date = "<p>Du " . date_timestamp2humanreadable($this->start)
+        . " au " . date_timestamp2humanreadable($this->end) . ".</p>\n";
+    }
+
+    $result  = "<h2><i>" . $city . "</i> : " . $title . "</h2>\n\n";
+    $result .= "<h3>Date et lieu</h3>\n";
+    $result .= $date;
+
+    $result .= "<p>&agrave; $address - $postalcode <i><a href=\"http://fr.wikipedia.org/wiki/" . $city . "\">" 
+              . $city . "</a></i>, <a href=\"http://fr.wikipedia.org/wiki/" 
+              . $region . "\">" . $region . "</a></p>\n\n";
+    $result .= "<h3>Description</h3>\n";
+    $result .= $this->description . "\n\n";
+    $result .= "<h3>Informations</h3>\n";
+    $result .= "<p>Site Web: <a href=\"" . $url . "\">" . $url . "</a></p>\n";
+    $result .= "<p>Contact: <a href=\"mailto:" . $contact . "\">" . $contact . "</a></p>\n";
+
+    if ($moderation)
+      $result .= "<p>Évènement à portée <b>". $GLOBALS["adl_locality"][$this->locality]. "</b></p>";
+
+    if ($this->tags != "")
+    {
+      $result .= format_tags($this->tags);
+    }
+
+    return $result;
+  }
+  
+  // -------------------------------------------------------------------
+
+  /*
+   * Came from From (edit function)
+   * 
+   */
+  function fromForm()
+  {
+    /* Convert form date to timestamp */
+    if (isset($_POST['__event_start_day']))
+    {
+      $this->start = mktime($_POST['__event_start_hour'],
+          $_POST['__event_start_minute'],
+          0,
+          $_POST['__event_start_month'],
+          $_POST['__event_start_day'],
+          $_POST['__event_start_year']);
+    }
+
+    if (isset($_POST['__event_end_day']))
+    {
+      $this->end = mktime($_POST['__event_end_hour'],
+        $_POST['__event_end_minute'],
+        0,
+        $_POST['__event_end_month'],
+        $_POST['__event_end_day'],
+        $_POST['__event_end_year']);
+    }
+
+    $afieldName = array('title', 'description', 
+      'address', 'postalcode', 'city', 'region', 'locality',
+      'url', 'contact', 'submitter');
+    
+    foreach ($afieldName as $fieldName)
+    {
+      if (isset($_POST['__event_'. $fieldName]))
+        $this->$fieldName = stripslashes(strip_tags($_POST['__event_'. $fieldName],
+          $fieldName=='description' ? "<p><strong><em><br/><a><ul><li><ol><b><i>" : ""));
+    }
+
+    if (isset($_POST['__event_tags']))
+    { // format tags
+      $event_tags = $_POST['__event_tags'];
+      if (isset($_POST['tags']) && is_array($_POST['tags']))
+      {
+        foreach($_POST['tags'] as $aTags)
+          if (is_array($aTags))
+            $event_tags .= " ". implode(' ', $aTags);
+          else
+            $event_tags .= " ". $aTags;
+      }
+      $this->tags = stripslashes(strip_tags(trim(str_replace("  ", " ", $event_tags))));
+    }
+    else
+      $this->tags = "";
+
+    return true;
+    
+  } // end function_fromForm
+
+  // -------------------------------------------------------------------
+
+  // Check information from event edit form
+  function check()
+  {
+    $error_cnt = 0;
+
+    if (! $this->title)
+      {
+        $this->message .= returnError("Titre vide");
+        $error_cnt++;
+      }
+
+    if (stristr($this->title, "viagra"))
+      {
+        $this->message .= returnError ("Les spammeurs, dehors");
+        $error_cnt++;
+      }
+
+    if (! $this->description)
+      {
+        $this->message .= returnError ("Description vide");
+        $error_cnt++;
+      }
+
+    if (! $this->city)
+      {
+        $this->message .= returnError ("Ville vide");
+        $error_cnt++;
+      }
+    elseif ($this->region!=27)
+      { // find city in cities tables
+        if ($this->postalcode == "choose")
+          {
+            $city_res = $this->db->query("SELECT * FROM cities WHERE id='". 
+              $_POST['__event_city_id']. "'");
+          }
+        else
+          {      
+            $city_res = $this->db->query("SELECT * FROM cities WHERE majname LIKE '" . 
+              addslashes($this->city) . "'");
+          }
+        if ($this->db->numRows($city_res) == 0)
+          {
+            $this->message .= returnError ("Ville non trouvée.");
+            $this->postalcode = 0;
+            $error_cnt++;
+          }
+        elseif ($this->db->numRows($city_res)==1)
+          {
+            $city_record = $this->db->fetchObject($city_res);
+            $this->city = $city_record->majname;
+            $this->postalcode = 
+              (strlen($city_record->postalcode)==4 ? "0" : ""). $city_record->postalcode;
+          }
+        else
+          {
+            $this->message .= returnError ("Plusieurs villes portent ce nom. Veuillez préciser.");
+            $this->postalcode = -1;
+            $error_cnt++;
+          }
+      }
+    else
+      { // abroad
+        $this->postalcode = 0;
+      }
+      
+    if (! $this->address)
+      {
+        $this->message .= returnError ("Adresse vide");
+        $this->latitude = $_POST['longitude'] = 0;
+        // no $error_cnt++ because it's not required
+      }
+    elseif ($this->postalcode>0)
+      { // Find coordonnates from address, postalcode, city
+        $url_gps = "http://maps.google.com/maps/geo?q=".
+          $this->address. " ". $this->postalcode. " ". $this->city. 
+          " France&output=csv&key=ABQIAAAATndsWAV5Q2y7pRRi-22W_hTxw9fvAnrsiYejTsRxd4b0cj9HKxSNCXUxAANaoACDzXWznNLVPto_jA";
+        $gps_file = file(str_replace(" ", "+", $url_gps), 
+          FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
+        list(,,$this->latitude, $this->longitude) = explode(",", $gps_file[0]);
+        
+        if ($this->latitude==0 && $this->longitude==0)
+        {
+          $this->message .= returnError ("Adresse non reconnaissable");
+          // $error_cnt++;
+        }
+      }
+
+    if (! $this->url)
+      {
+        $this->message .= returnError ("URL vide");
+        $error_cnt++;
+      }
+    elseif (strncmp ($this->url, "http://", 7) && strncmp($this->url, "https://", 8))
+      {
+        $this->message .= returnError ("URL ne commençant pas par http:// ou https://");
+        $error_cnt++;
+      }
+
+    if ($this->start <= mktime())
+      {
+        $this->message .= returnError ("Le d&eacute;but de la manifestation est dans le pass&eacute;.");
+        $error_cnt++;
+      }
+
+    if ($this->end <= mktime())
+      {
+        $this->message .= returnError ("La fin de la manifestation est dans le pass&eacute;.");
+        $error_cnt++;
+      }
+
+    if ($this->end <= $this->start)
+      {
+        $this->message .= returnError ("La fin de la manifestation est avant le d&eacute;but");
+        $error_cnt++;
+      }
+
+    if (! ereg("^([-A-Za-z0-9_+.]*)@([-A-Za-z0-9_]*)\.([-A-Za-z0-9_.]*)$", $this->contact))
+      {
+        $this->message .= returnError ("Email de contact invalide");
+        $error_cnt++;
+      }
+
+    if (!empty($this->submitter) && ! 
+      ereg("^([-A-Za-z0-9_+.]*)@([-A-Za-z0-9_]*)\.([-A-Za-z0-9_.]*)$", 
+      $this->submitter))
+      {
+        $this->message .= returnError ("Email du soumetteur invalide");
+        $error_cnt++;
+      }
+
+    $tags = ereg_replace(" +", " ", $this->tags);
+    foreach(explode(" ", $tags) as $tag)
+      {
+        if ($tag == "")
+          continue;
+
+        if (! ereg("^[a-z0-9\-]*$", $tag))
+          {
+            $this->message .= returnError("Tag '" . $tag . "' invalide. Les tags ne doivent contenir que des lettres minuscules, des chiffres ou des tirets.");
+            $error_cnt++;
+          }
+        if (strlen($tag) < 3)
+          {
+            $this->message .= returnError("Tag '" . $tag . "' trop court. Les tags doivent faire au moins 4 caract&egrave;res de long.");
+            $error_cnt++;
+          }
+      }
+
+    $this->error = $error_cnt;
+    return ($error_cnt == 0);
+  } // end function check_event
+
+  // -------------------------------------------------------------------
+
+  function notifySubmitter ()
+  {
+    $mail_title = "Votre évènement : '" . $this->title . "' est en attente de modération";
+    
+    $mail_body = "Bonjour,\n\n" .
+      wordwrap("Votre évènement intitulé '" . $this->title .
+               "', qui aura lieu le '" . date_timestamp2humanreadable($this->start) .
+               "' a bien été enregistré dans ". $GLOBALS['adl_title']. ". ".
+               "L'équipe de modération le prendra en charge très prochainement. " .
+               "Pendant la modération et après celle-ci si votre évènement est validé, " .
+               "vous pouvez éditer votre évènement à l'adresse :\n" .
+               "  " . calendar_absolute_url("editevent.php?id=" . 
+                $this->id . "&secret=" . $this->secret) . "\n\n" .
+               "et vous pouvez l'annuler en utilisant l'adresse :\n" .
+               "  " . calendar_absolute_url("cancelevent.php?id=" . 
+                $this->id . "&secret=" . $this->secret) . "\n\n") .
+      "Merci de votre participation !\n" .
+      "-- ". $GLOBALS["adl_title"];
+      
+    calendar_mail($this->submitter, "", $mail_title, $mail_body);
+    
+    return true;
+  }
+
+  // -------------------------------------------------------------------
+
+}
+
+?>


Plus d'informations sur la liste de diffusion Devel