X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fgroup.php;h=d17562c2f5ffd32078fcce27d732e46163dad85c;hb=9860732a5b6de1cdf71e1f55a1f5773ce95fa67b;hp=db1a7efe9202fd521bd4a6937fc0a473e48131b3;hpb=6c21094e45512da7fb1321a1df4335b1d48ed9bd;p=platal.git diff --git a/classes/group.php b/classes/group.php index db1a7ef..d17562c 100644 --- a/classes/group.php +++ b/classes/group.php @@ -117,10 +117,14 @@ 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, 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))) { @@ -136,6 +140,26 @@ class Group $data['id']); return new Group(array_merge($data, array('positions' => $positions))); } + + static public function subscribe($group_id, $uid) + { + XDB::execute('DELETE FROM group_former_members + WHERE uid = {?} AND asso_id = {?}', + $uid, $group_id); + XDB::execute('INSERT IGNORE INTO group_members (asso_id, uid) + VALUES ({?}, {?})', + $group_id, $uid); + } + + static public function unsubscribe($group_id, $uid, $remember) + { + XDB::execute('INSERT INTO group_former_members (asso_id, uid, remember, unsubsciption_date) + VALUES ({?}, {?}, {?}, NOW())', + $group_id, $uid, $remember); + XDB::execute('DELETE FROM group_members + WHERE uid = {?} AND asso_id = {?}', + $uid, $group_id); + } } // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: