From a174a707e5f078a6215a6bb3589de650f407ce4c Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Mon, 28 Feb 2011 15:59:43 +0100 Subject: [PATCH] Adds phone and fax for groups. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Jacob --- classes/group.php | 5 ++++- classes/phone.php | 1 + modules/xnetgrp.php | 7 +++++++ templates/xnetgrp/asso.tpl | 14 ++++++++++++++ templates/xnetgrp/edit.tpl | 13 +++++++++++++ upgrade/1.1.0/08_phones.sql | 3 +++ 6 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 upgrade/1.1.0/08_phones.sql diff --git a/classes/group.php b/classes/group.php index db1a7ef..477bcf9 100644 --- a/classes/group.php +++ b/classes/group.php @@ -117,10 +117,13 @@ class Group $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, + 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) WHERE ' . $where); if ($res->numRows() != 1) { if ($can_be_shortname && (is_int($id) || ctype_digit($id))) { diff --git a/classes/phone.php b/classes/phone.php index 34d7db9..29449e7 100644 --- a/classes/phone.php +++ b/classes/phone.php @@ -55,6 +55,7 @@ class Phone const LINK_ADDRESS = 'address'; const LINK_PROFILE = 'user'; const LINK_COMPANY = 'hq'; + const LINK_GROUP = 'group'; /** The following fields, but $error, all correspond to the fields of the * database table profile_phones. diff --git a/modules/xnetgrp.php b/modules/xnetgrp.php index abadfaf..e863912 100644 --- a/modules/xnetgrp.php +++ b/modules/xnetgrp.php @@ -231,6 +231,13 @@ class XnetGrpModule extends PLModule $globals->asso('id')); } + Phone::deletePhones(0, Phone::LINK_GROUP, $globals->asso('id')); + $phone = new Phone(array('link_type' => 'group', 'link_id' => $globals->asso('id'), 'id' => 0, + 'type' => 'fixed', 'display' => Post::v('phone'), 'pub' => 'public')); + $fax = new Phone(array('link_type' => 'group', 'link_id' => $globals->asso('id'), 'id' => 1, + 'type' => 'fax', 'display' => Post::v('fax'), 'pub' => 'public')); + $phone->save(); + $fax->save(); if ($_FILES['logo']['name']) { $upload = PlUpload::get($_FILES['logo'], $globals->asso('id'), 'asso.logo', true); diff --git a/templates/xnetgrp/asso.tpl b/templates/xnetgrp/asso.tpl index 12dc248..9714d14 100644 --- a/templates/xnetgrp/asso.tpl +++ b/templates/xnetgrp/asso.tpl @@ -72,6 +72,20 @@ {/if} + {if $asso->phone} + + Téléphone : + {$asso->phone} + + {/if} + + {if $asso->fax} + + Fax : + {$asso->fax} + + {/if} + {if !$is_member && $is_logged && $asso->inscriptible && $xnet_type != 'promotions'} diff --git a/templates/xnetgrp/edit.tpl b/templates/xnetgrp/edit.tpl index e0c77d6..668896d 100644 --- a/templates/xnetgrp/edit.tpl +++ b/templates/xnetgrp/edit.tpl @@ -125,6 +125,19 @@ + Téléphone + + + + + + Fax + + + + + + Forum : diff --git a/upgrade/1.1.0/08_phones.sql b/upgrade/1.1.0/08_phones.sql new file mode 100644 index 0000000..9e5c234 --- /dev/null +++ b/upgrade/1.1.0/08_phones.sql @@ -0,0 +1,3 @@ +ALTER TABLE profile_phones CHANGE COLUMN link_type link_type ENUM('address','pro','user','hq', 'group') NOT NULL DEFAULT 'user'; + +-- vim:set syntax=mysql: -- 2.1.4