Geoloc validation
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Fri, 31 Aug 2007 20:04:41 +0000 (22:04 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Fri, 31 Aug 2007 20:04:41 +0000 (22:04 +0200)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
modules/profile/addresses.inc.php
templates/geoloc/form.address.tpl
templates/profile/adresses.address.tpl
templates/profile/adresses.tpl

index 4243527..e78a5a0 100644 (file)
@@ -34,6 +34,8 @@ class ProfileAddress
     {
         require_once 'geoloc.inc.php';
         $success = true;
+        unset($address['geoloc']);
+        unset($address['geoloc_cityid']);
         if (@$address['parsevalid'] || (@$address['text'] && @$address['changed']) || !@$address['cityid']) {
             $address = array_merge($address, empty_address());
             $new = get_address_infos(@$address['text']);
index 9561af5..3b4f87d 100644 (file)
 
 <input type="hidden" name="{$name}[changed]" value="0"/>
 {if $adr.geoloc}
-<div class="erreur">
+<div class="erreur" id="{$id}_geoloc_error">
   La geolocalisation n'a pas donné un résultat certain, valide la nouvelle adresse
   ou modifie l'ancienne pour que ton adresse puisse être prise en compte.
 </div>
 <script type="text/javascript">setTimeout("document.location += '#{$adid}'", 10);</script>
 {/if}
+<div>
 <textarea name="{$name}[text]" cols="30" rows="4"
           onchange="form['{$name}[changed]'].value=1"
           {if !$adr.cityid && $adr.datemaj}class="error"{/if}
           >{$adr.text}</textarea>
 {if $adr.geoloc}
+<span id="{$id}_geoloc">
 <textarea cols="30" rows="4"
           class="valid"
+          name="{$name}[geoloc]"
           onclick="blur()"
           >{$adr.geoloc}</textarea>
-<p class="center">
-  <input type="submit" name="{$name}[parsevalid]" value="Valider l'adresse" />
-</p>
+<input type="hidden" name="{$name}[parsevalid]" value="0" />
+</span>
+</div>
+<div class="center" id="{$id}_geoloc_valid">
+  <a href="javascript:validAddress('{$id}', '{$name}')">Valider ta version</a>
+  &bull;
+  <a href="javascript:validGeoloc('{$id}', '{$name}')">Valider la version géolocalisée</a>
 {/if}
+</div>
 <input type="hidden" name="{$name}[cityid]" value="{$adr.cityid}" />
 <input type="hidden" name="{$name}[adr1]" value="{$adr.adr1}" />
 <input type="hidden" name="{$name}[adr2]" value="{$adr.adr2}" />
index 5b49c91..09d13b0 100644 (file)
@@ -56,7 +56,7 @@
       <div>{include file="include/flags.radio.tpl" name="`$adpref`[pub]" notable=true val=$adr.pub}</div>
       <div style="clear: both"></div>
       <div style="float: left">{include file="geoloc/form.address.tpl" name=$adpref id=$adid adr=$adr}</div>
-      <div style="float: right">
+      <div style="float: left">
         <div>
           <input type="radio" name="{$adpref}[temporary]" id="{$adid}_temp_0" value="0"
                  {if !$adr.temporary}checked="checked"{/if} /><label for="{$adid}_temp_0">permanente</label>
index 833d716..8ca6568 100644 (file)
@@ -107,6 +107,29 @@ function addTel(id)
   Ajax.update_html(tel + i, 'profile/ajax/tel/' + id + '/' + i);
 }
 
+function validGeoloc(id, pref)
+{
+  document.getElementById(id + '_geoloc').style.display = 'none';
+  document.getElementById(id + '_geoloc_error').style.display = 'none';
+  document.getElementById(id + '_geoloc_valid').style.display = 'none';
+  document.forms.prof_annu[pref + "[parsevalid]"] = "1";
+  document.forms.prof_annu[pref + "[text]"].value = document.forms.prof_annu[pref + "[geoloc]"].value;
+  attachEvent(document.forms.prof_annu[pref + "[text]"], "click",
+              function() { document.forms.prof_annu[pref + "[text]"].blur(); });
+  document.forms.prof_annu[pref + "[text]"].className = '';
+}
+
+function validAddress(id, pref)
+{
+  document.getElementById(id + '_geoloc').style.display = 'none';
+  document.getElementById(id + '_geoloc_error').style.display = 'none';
+  document.getElementById(id + '_geoloc_valid').style.display = 'none';
+  document.forms.prof_annu[pref + "[parsevalid]"] = "0";
+  attachEvent(document.forms.prof_annu[pref + "[text]"], "click",
+              function() { document.forms.prof_annu[pref + "[text]"].blur(); });
+  document.forms.prof_annu[pref + "[text]"].className = '';
+}
+
 {/literal}
 //]]></script>