<?php
/***************************************************************************
- * Copyright (C) 2003-2007 Polytechnique.org *
+ * Copyright (C) 2003-2009 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
}
}
$current = 0;
+ $success = true;
foreach ($value as $key=>&$adr) {
if (@$adr['current']) {
$current++;
}
}
- if (!$init && $current != 1 && count($value) > 0) {
+ if ($current == 0 && count($value) > 0) {
+ foreach ($value as $key=>&$adr) {
+ $adr['current'] = true;
+ break;
+ }
+ } else if ($current > 1) {
$success = false;
- } else {
- $success = true;
}
foreach ($value as $key=>&$adr) {
$ls = true;
private function saveAddress($adrid, array &$address)
{
- $flags = array();
+ $flags = new PlFlagSet();
if ($address['secondaire']) {
- $flags[] = 'res-secondaire';
+ $flags->addFlag('res-secondaire');
}
if ($address['mail']) {
- $flags[] = 'courrier';
+ $flags->addFlag('courrier');
}
if ($address['temporary']) {
- $flags[] = 'temporaire';
+ $flags->addFlag('temporaire');
}
if ($address['current']) {
- $flags[] = 'active';
+ $flags->addFlag('active');
}
if ($address['checked']) {
- $flags[] = 'coord-checked';
+ $flags->addFlag('coord-checked');
}
- $flags = implode(',', $flags);
XDB::execute("INSERT INTO adresses (adr1, adr2, adr3,
postcode, city, cityid,
country, region, regiontxt,
pub, datemaj, statut,
- uid, adrid)
+ uid, adrid, glat, glng)
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);
+ S::i('uid'), $adrid, $address['precise_lat'], $address['precise_lon']);
foreach ($address['tel'] as $telid=>&$tel) {
$this->saveTel($adrid, $telid, $tel);
}
{
parent::__construct($wiz);
$this->settings['addresses'] = new ProfileAddress();
+ $this->watched['addresses'] = true;
}
protected function _fetchData()
FIND_IN_SET('res-secondaire', a.statut) AS secondaire,
FIND_IN_SET('courrier', a.statut) AS mail,
FIND_IN_SET('temporaire', a.statut) AS temporary,
- FIND_IN_SET('active', a.statut) AS current
+ FIND_IN_SET('active', a.statut) AS current,
+ a.glat AS precise_lat, a.glng AS precise_lon
FROM adresses AS a
INNER JOIN geoloc_pays AS gp ON(gp.a2 = a.country)
WHERE uid = {?} AND NOT FIND_IN_SET('pro', statut)