Adds phone and fax for groups.
authorStéphane Jacob <sj@m4x.org>
Mon, 28 Feb 2011 14:59:43 +0000 (15:59 +0100)
committerStéphane Jacob <sj@m4x.org>
Mon, 28 Feb 2011 14:59:43 +0000 (15:59 +0100)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
classes/group.php
classes/phone.php
modules/xnetgrp.php
templates/xnetgrp/asso.tpl
templates/xnetgrp/edit.tpl
upgrade/1.1.0/08_phones.sql [new file with mode: 0644]

index db1a7ef..477bcf9 100644 (file)
@@ -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))) {
index 34d7db9..29449e7 100644 (file)
@@ -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.
index abadfaf..e863912 100644 (file)
@@ -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);
index 12dc248..9714d14 100644 (file)
   </tr>
   {/if}
 
+  {if $asso->phone}
+  <tr>
+    <td class="titre">Téléphone&nbsp;:</td>
+    <td>{$asso->phone}</td>
+  </tr>
+  {/if}
+
+  {if $asso->fax}
+  <tr>
+    <td class="titre">Fax&nbsp;:</td>
+    <td>{$asso->fax}</td>
+  </tr>
+  {/if}
+
   {if !$is_member && $is_logged && $asso->inscriptible && $xnet_type != 'promotions'}
   <tr>
     <td class="titre">
index e0c77d6..668896d 100644 (file)
     </tr>
 
     <tr>
+      <td class="titre">Téléphone</td>
+      <td>
+        <input type="text" maxlength="28" name="phone" value="{$asso->phone}" />
+      </td>
+    </tr>
+    <tr>
+      <td class="titre">Fax</td>
+      <td>
+        <input type="text" maxlength="28" name="fax" value="{$asso->fax}" />
+      </td>
+    </tr>
+
+    <tr>
       <td class="titre">
         Forum&nbsp;:
       </td>
diff --git a/upgrade/1.1.0/08_phones.sql b/upgrade/1.1.0/08_phones.sql
new file mode 100644 (file)
index 0000000..9e5c234
--- /dev/null
@@ -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: