* - `id` is the id of the job to which we refer (in profile_job)
* - `jobid` is set to 0
*
+ * - for a Group:
+ * - `type` is set to 'group'
+ * - `pid` is set to 0
+ * - `jobid` is set to 0
+ * - `groupid` is set to the group id
+ *
* Thus an Address can be linked to a Company, a Profile, or a Job.
*/
class Address
const LINK_JOB = 'job';
const LINK_COMPANY = 'hq';
const LINK_PROFILE = 'home';
+ const LINK_GROUP = 'group';
// List of all available postal formattings.
private static $formattings = array('FRANCE' => 'FR');
// Primary key fields: the quadruplet ($pid, $jobid, $type, $id) defines a unique address.
public $pid = 0;
public $jobid = 0;
+ public $groupid = 0;
public $type = Address::LINK_PROFILE;
public $id = 0;
Geocoder::getAreaId($this, $area);
}
- XDB::execute('INSERT IGNORE INTO profile_addresses (pid, jobid, type, id, flags, accuracy,
+ XDB::execute('INSERT IGNORE INTO profile_addresses (pid, jobid, groupid, type, id, flags, accuracy,
text, postalText, postalCode, localityId,
subAdministrativeAreaId, administrativeAreaId,
countryId, latitude, longitude, pub, comment,
north, south, east, west)
VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?},
- {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})',
- $this->pid, $this->jobid, $this->type, $this->id, $this->flags, $this->accuracy,
+ {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})',
+ $this->pid, $this->jobid, $this->groupid, $this->type, $this->id, $this->flags, $this->accuracy,
$this->text, $this->postalText, $this->postalCode, $this->localityId,
$this->subAdministrativeAreaId, $this->administrativeAreaId,
$this->countryId, $this->latitude, $this->longitude,
public function delete()
{
XDB::execute('DELETE FROM profile_addresses
- WHERE pid = {?} AND jobid = {?} AND type = {?} AND id = {?}',
- $this->pid, $this->jobid, $this->type, $this->id);
+ WHERE pid = {?} AND jobid = {?} AND groupid = {?} AND type = {?} AND id = {?}',
+ $this->pid, $this->jobid, $this->groupid, $this->type, $this->id);
}
- static public function deleteAddresses($pid, $type, $jobid = null, $deletePrivate = true)
+ static public function deleteAddresses($pid, $type, $jobid = null, $groupid = null, $deletePrivate = true)
{
$where = '';
if (!is_null($pid)) {
if (!is_null($jobid)) {
$where = XDB::format(' AND jobid = {?}', $jobid);
}
+ if (!is_null($groupid)) {
+ $where = XDB::format(' AND groupid = {?}', $groupid);
+ }
XDB::execute('DELETE FROM profile_addresses
WHERE type = {?}' . $where . (($deletePrivate) ? '' : ' AND pub IN (\'public\', \'ax\')'),
$type);
$res = XDB::query('SELECT a.*, d.nom AS domnom,
FIND_IN_SET(\'wiki_desc\', a.flags) AS wiki_desc,
FIND_IN_SET(\'notif_unsub\', a.flags) AS notif_unsub,
- (nls.id IS NOT NULL) AS has_nl,
+ (nls.id IS NOT NULL) AS has_nl, ad.text AS address,
p.display_tel AS phone, f.display_tel AS fax
FROM groups AS a
LEFT JOIN group_dom AS d ON d.id = a.dom
LEFT JOIN newsletters AS nls ON (nls.group_id = a.id)
LEFT JOIN profile_phones AS p ON (p.link_type = \'group\' AND p.link_id = a.id AND p.tel_id = 0)
LEFT JOIN profile_phones AS f ON (f.link_type = \'group\' AND f.link_id = a.id AND f.tel_id = 1)
+ LEFT JOIN profile_addresses AS ad ON (ad.type = \'group\' AND ad.groupid = a.id)
WHERE ' . $where);
if ($res->numRows() != 1) {
if ($can_be_shortname && (is_int($id) || ctype_digit($id))) {
$deletePrivate = S::user()->isMe($page->owner) || S::admin();
Phone::deletePhones($page->pid(), Phone::LINK_ADDRESS, null, $deletePrivate);
- Address::deleteAddresses($page->pid(), Address::LINK_PROFILE, null, $deletePrivate);
+ Address::deleteAddresses($page->pid(), Address::LINK_PROFILE, null, null, $deletePrivate);
Address::saveFromArray($value, $page->pid(), Address::LINK_PROFILE, null, $deletePrivate);
if (S::user()->isMe($page->owner) && count($value) > 1) {
Platal::page()->trigWarning('Attention, tu as plusieurs adresses sur ton profil. Pense à supprimer celles qui sont obsolètes.');
LEFT JOIN profile_job_term AS pjt ON (pj.pid = pjt.pid AND pj.id = pjt.jid)
WHERE pj.pid = {?}' . (($deletePrivate) ? '' : ' AND pj.pub IN (\'public\', \'ax\')'),
$page->pid());
- Address::deleteAddresses($page->pid(), Address::LINK_JOB, null, $deletePrivate);
+ Address::deleteAddresses($page->pid(), Address::LINK_JOB, null, null, $deletePrivate);
Phone::deletePhones($page->pid(), Phone::LINK_JOB, null, $deletePrivate);
$terms_values = array();
foreach ($value as $id => &$job) {
'type' => 'fax', 'display' => Post::v('fax'), 'pub' => 'public'));
$phone->save();
$fax->save();
+ Address::deleteAddresses(null, Address::LINK_GROUP, null, $globals->asso('id'));
+ $address = new Address(array('groupid' => $globals->asso('id'), 'type' => Address::LINK_GROUP, 'text' => Post::v('address')));
+ $address->save();
if ($_FILES['logo']['name']) {
$upload = PlUpload::get($_FILES['logo'], $globals->asso('id'), 'asso.logo', true);
</tr>
{/if}
+ {if $asso->address}
+ <tr>
+ <td class="titre">Adresse :</td>
+ <td>{$asso->address}</td>
+ </tr>
+ {/if}
+
{if !$is_member && $is_logged && $asso->inscriptible && $xnet_type != 'promotions'}
<tr>
<td class="titre">
<input type="text" maxlength="28" name="fax" value="{$asso->fax}" />
</td>
</tr>
+ <tr>
+ <td class="titre">Adresse</td>
+ <td>
+ <textarea name="address" cols="30" rows="4">{$asso->address}</textarea>
+ </td>
+ </tr>
<tr>
<td class="titre">
--- /dev/null
+DROP TABLE IF EXISTS tmp_profile_addresses;
+CREATE TEMPORARY TABLE tmp_profile_addresses LIKE profile_addresses;
+INSERT INTO tmp_profile_addresses SELECT * FROM profile_addresses;
+DROP TABLE profile_addresses;
+CREATE TABLE profile_addresses (
+ pid int(11) unsigned NOT NULL DEFAULT '0',
+ jobid int(6) unsigned NOT NULL DEFAULT '0',
+ groupid SMALLINT(5) UNSIGNED NOT NULL DEFAULT 0,
+ type enum('home','job','hq','group') NOT NULL DEFAULT 'home',
+ id tinyint(3) unsigned NOT NULL DEFAULT '0',
+ flags set('current','temporary','secondary','mail','cedex','deliveryIssue') DEFAULT NULL,
+ accuracy tinyint(1) unsigned NOT NULL DEFAULT '0',
+ text text NOT NULL,
+ postalText text NOT NULL,
+ postalCode varchar(255) DEFAULT NULL,
+ localityId bigint(20) unsigned DEFAULT NULL,
+ subAdministrativeAreaId int(11) unsigned DEFAULT NULL,
+ administrativeAreaId int(11) unsigned DEFAULT NULL,
+ countryId char(2) DEFAULT NULL,
+ latitude float(10,7) DEFAULT NULL,
+ longitude float(10,7) DEFAULT NULL,
+ north float(10,7) DEFAULT NULL,
+ south float(10,7) DEFAULT NULL,
+ east float(10,7) DEFAULT NULL,
+ west float(10,7) DEFAULT NULL,
+ pub enum('public','ax','private') NOT NULL DEFAULT 'private',
+ comment varchar(255) DEFAULT NULL,
+ PRIMARY KEY (pid,jobid,groupid,type,id),
+ KEY pid (pid),
+ KEY jobid (jobid),
+ KEY type (type),
+ KEY adrid (id),
+ KEY localityId (localityId),
+ KEY administrativeAreaId (administrativeAreaId),
+ KEY subAdministrativeAreaId (subAdministrativeAreaId),
+ KEY countryId (countryId),
+ CONSTRAINT profile_addresses_ibfk_1 FOREIGN KEY (localityId) REFERENCES geoloc_localities (id) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT profile_addresses_ibfk_2 FOREIGN KEY (subAdministrativeAreaId) REFERENCES geoloc_subadministrativeareas (id) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT profile_addresses_ibfk_3 FOREIGN KEY (administrativeAreaId) REFERENCES geoloc_administrativeareas (id) ON DELETE CASCADE ON UPDATE CASCADE,
+ CONSTRAINT profile_addresses_ibfk_4 FOREIGN KEY (countryId) REFERENCES geoloc_countries (iso_3166_1_a2) ON DELETE CASCADE ON UPDATE CASCADE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+INSERT INTO profile_addresses (pid, jobid, groupid, type, id, flags, accuracy, text, postalText,
+ postalCode, localityId, subAdministrativeAreaId, administrativeAreaId, countryId,
+ latitude, longitude, north, south, east, west, pub, comment)
+ SELECT pid, jobid, 0, type, id, flags, accuracy, text, postalText,
+ postalCode, localityId, subAdministrativeAreaId, administrativeAreaId, countryId,
+ latitude, longitude, north, south, east, west, pub, comment
+ FROM tmp_profile_addresses;
+DROP TABLE IF EXISTS tmp_profile_addresses;
+
+-- vim:set syntax=mysql: