1ea88695fd19b448b3155bc908af93ad1bbe278c
2 /***************************************************************************
3 * Copyright (C) 2003-2007 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
22 class ProfileAddress
extends ProfileNoSave
24 public function value(ProfilePage
&$page, $field, $value, &$success)
27 if (is_null($value)) {
28 return $page->values
['addresses'];
30 foreach ($value as $key=>&$adr) {
31 if ($adr['removed']) {
39 class ProfileAddresses
extends ProfilePage
41 protected $pg_template = 'profile/adresses.tpl';
43 public function __construct(PlWizard
&$wiz)
45 parent
::__construct($wiz);
46 $this->settings
['addresses'] = new ProfileAddress();
49 protected function fetchData()
51 if (count($this->orig
) > 0) {
52 $this->values
= $this->orig
;
55 // Build the addresses tree
56 $res = XDB
::query("SELECT adrid AS id, adr1, adr2, adr3,
57 postcode, city, cityid, region, regiontxt,
58 fax, glat, glng, datemaj, pub,
59 FIND_IN_SET('res-secondaire', statut) AS secondaire,
60 FIND_IN_SET('courrier', statut) AS mail,
61 FIND_IN_SET('temporary', statut) AS temporary,
62 FIND_IN_SET('active', statut) AS current,
63 FIND_IN_SET('coord-checked', statut) AS checked,
64 FIND_IN_SET('coord-valid', statut) AS valid
69 $this->values
['addresses'] = $res->fetchAllAssoc();
71 $res = XDB
::iterRow("SELECT adrid, telid, tel_type, tel_pub, tel
77 while (list($adrid, $telid, $type, $pub, $tel) = $res->next()) {
78 while ($this->values
['addresses'][$i]['id'] < $adrid) {
81 $address =& $this->values
['addresses'][$i];
82 if (!isset($address['tel'])) {
83 $address['tel'] = array();
85 if ($address['id'] == $adrid) {
86 $address['tel'][] = array('id' => $telid,
95 protected function saveData()
100 public function prepare(PlatalPage
&$page)
102 parent
::prepare($page);
106 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: