Adds a comment for addresses
authorGuillaume Bandet <guillaume.bandet@polytechnique.org>
Tue, 3 Jun 2008 13:34:25 +0000 (15:34 +0200)
committerGuillaume Bandet <guillaume.bandet@polytechnique.org>
Tue, 10 Jun 2008 20:32:10 +0000 (22:32 +0200)
include/user.func.inc.php
modules/profile/addresses.inc.php
plugins/function.display_address.php
templates/profile/adresses.address.tpl
upgrade/fusionax-0.0.1/01_addrcomment.sql [new file with mode: 0644]

index b903654..c866ef9 100644 (file)
@@ -347,7 +347,7 @@ function get_user_details_adr($uid, $view = 'private') {
                      gp.pays AS countrytxt,a.region, a.regiontxt,
                      FIND_IN_SET('active', a.statut) AS active, a.adrid,
                      FIND_IN_SET('res-secondaire', a.statut) AS secondaire,
-                     a.pub, gp.display
+                     a.pub, gp.display, a.comment
                FROM  adresses AS a
           LEFT JOIN  geoloc_pays AS gp ON (gp.a2=a.country)
               WHERE  uid= {?} AND NOT FIND_IN_SET('pro',a.statut)
index 2fe7a8d..1e518aa 100644 (file)
@@ -138,17 +138,17 @@ class ProfileAddress extends ProfileGeoloc
                                               postcode, city, cityid,
                                               country, region, regiontxt,
                                               pub, datemaj, statut,
-                                              uid, adrid, glat, glng)
+                                              uid, adrid, glat, glng, comment)
                            VALUES  ({?}, {?}, {?},
                                     {?}, {?}, {?},
                                     {?}, {?}, {?},
                                     {?}, FROM_UNIXTIME({?}), {?},
-                                    {?}, {?}, {?}, {?})",
+                                    {?}, {?}, {?}, {?}, {?})",
                      $address['adr1'], $address['adr2'], $address['adr3'],
                      $address['postcode'], $address['city'], $address['cityid'],
                      $address['country'], $address['region'], $address['regiontxt'],
                      $address['pub'], $address['datemaj'], $flags,
-                     S::i('uid'), $adrid, $address['precise_lat'], $address['precise_lon']);
+                     S::i('uid'), $adrid, $address['precise_lat'], $address['precise_lon'], $address['comment']);
         foreach ($address['tel'] as $telid=>&$tel) {
             $this->saveTel($adrid, $telid, $tel);
         }
@@ -191,7 +191,8 @@ class ProfileAddresses extends ProfilePage
                                    FIND_IN_SET('courrier', a.statut) AS mail,
                                    FIND_IN_SET('temporaire', a.statut) AS temporary,
                                    FIND_IN_SET('active', a.statut) AS current,
-                                   a.glat AS precise_lat, a.glng AS precise_lon
+                                   a.glat AS precise_lat, a.glng AS precise_lon,
+                                   a.comment
                              FROM  adresses AS a
                        INNER JOIN  geoloc_pays AS gp ON(gp.a2 = a.country)
                             WHERE  uid = {?} AND NOT FIND_IN_SET('pro', statut)
index 07ce7c3..98dfdef 100644 (file)
@@ -61,15 +61,29 @@ function smarty_function_display_address($param, &$smarty)
     $map = "<a href=\"http://maps.google.fr/?q="
         .   urlencode(implode(", ", $lines) . " ($idt)")
         . "\"><img src=\"images/icons/map.gif\" alt=\"Google Maps\" title=\"Carte\"/></a>";
+    $comment = "";
+    if ($param['adr']['comment'] != "")
+    {
+        $commentHtml = str_replace(array('&', '"'), array('&amp;', '&quot;'), $param['adr']['comment']);
+        $commentJs = str_replace(array('\\', '\''), array('\\\\', '\\\''), $commentHtml);
+        $comment = "<img style=\"margin-left: 5px;\" src=\"images/icons/comments.gif\""
+            . " onmouseover=\"return overlib('"
+            . $commentJs
+            . "',WIDTH,250);\""
+            . " onmouseout=\"nd();\""
+            . " alt=\"Commentaire\" title=\""
+            . $commentHtml
+            . "\"/>";
+    }
     if ($restore) {
         array_unshift($lines, $idt);
     }
     if ($param['titre'])
     {
         if ($param['titre_div'])
-            $txthtml .= "<div class='titre'>".pl_entity_decode($param['titre'])."&nbsp;".$map."</div>\n";
+            $txthtml .= "<div class='titre'>".pl_entity_decode($param['titre'])."&nbsp;".$map.$comment."</div>\n";
         else
-            $txthtml .= "<em>".pl_entity_decode($param['titre'])."&nbsp;</em>".$map."<br />\n";
+            $txthtml .= "<em>".pl_entity_decode($param['titre'])."&nbsp;</em>".$map.$comment."<br />\n";
     }
     foreach ($lines as $line)
     {
index c0b7287..46d9dec 100644 (file)
                  {if $adr.mail}checked="checked"{/if} />
           <label for="{$adid}_mail">on peut m'y envoyer du courrier par la poste</label>
         </div>
+        <div>
+          <label for="{$adpref}[comment]">Commentaire : </label>
+          <input type="text" size="35" maxlength="100" name="{$adpref}[comment]" id="{$adpref}_comment" value="{$adr.comment}" />
+        </div>
       </div>
     </td>
   </tr>
diff --git a/upgrade/fusionax-0.0.1/01_addrcomment.sql b/upgrade/fusionax-0.0.1/01_addrcomment.sql
new file mode 100644 (file)
index 0000000..7de4690
--- /dev/null
@@ -0,0 +1,2 @@
+ALTER TABLE `adresses` ADD `comment` varchar(100) NOT NULL;
+