From eb41eda94f6b91fbff6600e23a226e994ce1d7ef Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Sun, 14 Feb 2010 15:19:16 +0100 Subject: [PATCH] (groupex.*|groupesx_*) -> group_* AFAICT, account branch is now mono-db. Signed-off-by: Florent Bruneau --- classes/group.php | 4 +- classes/user.php | 2 +- classes/userfilter.php | 10 ++-- classes/xnetpage.php | 4 +- classes/xnetsession.php | 4 +- htdocs/listes_redirect.php | 2 +- include/directory.enums.inc.php | 4 +- include/reminder/promotion_ml.inc.php | 8 ++-- include/user.func.inc.php | 2 +- include/validations/paiements.inc.php | 10 ++-- modules/auth.php | 4 +- modules/auth/auth.inc.php | 4 +- modules/lists.php | 2 +- modules/payment.php | 14 +++--- modules/payment/money.inc.php | 6 +-- modules/profile.php | 8 ++-- modules/profile/groups.inc.php | 8 ++-- modules/register.php | 4 +- modules/search.php | 2 +- modules/search/search.inc.php | 2 +- modules/xnet.php | 30 ++++++------ modules/xnetevents.php | 56 +++++++++++----------- modules/xnetevents/xnetevents.inc.php | 32 ++++++------- modules/xnetgrp.php | 88 +++++++++++++++++------------------ modules/xnetgrp/feed.inc.php | 4 +- modules/xnetlists.php | 6 +-- templates/payment/index.tpl | 2 +- upgrade/account/08_groups.sql | 67 ++++++++++++++++++++++++++ 28 files changed, 228 insertions(+), 161 deletions(-) create mode 100644 upgrade/account/08_groups.sql diff --git a/classes/group.php b/classes/group.php index 8512d84..4f3f0b7 100644 --- a/classes/group.php +++ b/classes/group.php @@ -84,8 +84,8 @@ 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 - FROM #groupex#.asso AS a - LEFT JOIN #groupex#.dom AS d ON d.id = a.dom + FROM groups AS a + LEFT JOIN group_dom AS d ON d.id = a.dom WHERE ' . $where); if ($res->numRows() != 1) { return null; diff --git a/classes/user.php b/classes/user.php index 71b21c9..efa333d 100644 --- a/classes/user.php +++ b/classes/user.php @@ -152,7 +152,7 @@ class User extends PlUser $joins = ''; $fields = array(); if ($globals->asso('id')) { - $joins .= XDB::format("LEFT JOIN groupex.membres AS gpm ON (gpm.uid = a.uid AND gpm.asso_id = {?})\n", $globals->asso('id')); + $joins .= XDB::format("LEFT JOIN group_members AS gpm ON (gpm.uid = a.uid AND gpm.asso_id = {?})\n", $globals->asso('id')); $fields[] = 'gpm.perms AS group_perms'; $fields[] = 'gpm.comm AS group_comm'; } diff --git a/classes/userfilter.php b/classes/userfilter.php index 7df8762..2c8385b 100644 --- a/classes/userfilter.php +++ b/classes/userfilter.php @@ -2029,13 +2029,13 @@ class UserFilter extends PlFilter $joins = array(); foreach ($this->gpm as $sub => $key) { if (is_null($key)) { - $joins['gpa' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_INNER, 'groupex.asso'); - $joins['gpm' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'groupex.membres', '$ME.uid = $UID AND $ME.asso_id = gpa' . $sub . '.id'); + $joins['gpa' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_INNER, 'groups'); + $joins['gpm' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'group_members', '$ME.uid = $UID AND $ME.asso_id = gpa' . $sub . '.id'); } else if (ctype_digit($key)) { - $joins['gpm' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'groupex.membres', '$ME.uid = $UID AND $ME.asso_id = ' . $key); + $joins['gpm' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'group_members', '$ME.uid = $UID AND $ME.asso_id = ' . $key); } else { - $joins['gpa' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_INNER, 'groupex.asso', XDB::format('$ME.diminutif = {?}', $key)); - $joins['gpm' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'groupex.membres', '$ME.uid = $UID AND $ME.asso_id = gpa' . $sub . '.id'); + $joins['gpa' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_INNER, 'groups', XDB::format('$ME.diminutif = {?}', $key)); + $joins['gpm' . $sub] = new PlSqlJoin(PlSqlJoin::MODE_LEFT, 'group_members', '$ME.uid = $UID AND $ME.asso_id = gpa' . $sub . '.id'); } } return $joins; diff --git a/classes/xnetpage.php b/classes/xnetpage.php index 7fdd2bb..8a2574e 100644 --- a/classes/xnetpage.php +++ b/classes/xnetpage.php @@ -142,8 +142,8 @@ function list_all_my_groups($params) return; } $res = XDB::iterRow('SELECT a.nom, a.diminutif - FROM #groupex#.asso AS a - INNER JOIN #groupex#.membres AS m ON m.asso_id = a.id + FROM groups AS a + INNER JOIN group_members AS m ON m.asso_id = a.id WHERE m.uid = {?}', S::i('uid')); $links = 'déconnexion'; $html = '
Mes groupes (' . $links . ') :
'; diff --git a/classes/xnetsession.php b/classes/xnetsession.php index fdda6d7..4dc4d1c 100644 --- a/classes/xnetsession.php +++ b/classes/xnetsession.php @@ -166,7 +166,7 @@ function may_update($force = false, $lose = false) $may_update[$asso_id] = true; } elseif (!isset($may_update[$asso_id]) || $force) { $res = XDB::query("SELECT perms - FROM #groupex#.membres + FROM group_members WHERE uid={?} AND asso_id={?}", S::v('uid'), $asso_id); $may_update[$asso_id] = ($res->fetchOneCell() == 'admin'); @@ -198,7 +198,7 @@ function is_member($force = false, $lose = false) $is_member[$asso_id] = true; } elseif (!isset($is_member[$asso_id]) || $force) { $res = XDB::query("SELECT COUNT(*) - FROM #groupex#.membres + FROM group_members WHERE uid={?} AND asso_id={?}", S::v('uid'), $asso_id); $is_member[$asso_id] = ($res->fetchOneCell() == 1); diff --git a/htdocs/listes_redirect.php b/htdocs/listes_redirect.php index 42a7dd9..9606ab5 100644 --- a/htdocs/listes_redirect.php +++ b/htdocs/listes_redirect.php @@ -35,7 +35,7 @@ if ($matches) { http_redirect("https://www.polytechnique.org/lists/$action/$mbox$sup"); } - $res = XDB::query("SELECT diminutif FROM #groupex#.asso WHERE mail_domain = {?}", $fqdn); + $res = XDB::query("SELECT diminutif FROM groups WHERE mail_domain = {?}", $fqdn); if ($gpx = $res->fetchOneCell()) { http_redirect("http://www.polytechnique.net/$gpx/lists/$action/$mbox$sup"); } diff --git a/include/directory.enums.inc.php b/include/directory.enums.inc.php index 02c013f..83a8821 100644 --- a/include/directory.enums.inc.php +++ b/include/directory.enums.inc.php @@ -311,10 +311,10 @@ class DE_GroupesX extends DirEnumeration protected $idfield = 'asso.id'; protected $valfield = 'asso.nom'; protected $valfield2 = 'asso.diminutif'; - protected $from = '#groupex#.asso AS asso'; + protected $from = 'groups AS asso'; protected $where = 'WHERE (cat = \'GroupesX\' OR cat = \'Institutions\') AND pub = \'public\''; - protected $ac_join = "INNER JOIN #groupex#.membres AS memb ON (asso.id = memb.asso_id + protected $ac_join = "INNER JOIN group_members AS memb ON (asso.id = memb.asso_id AND (asso.cat = 'GroupesX' OR asso.cat = 'Institutions') AND asso.pub = 'public')"; protected $ac_unique = 'memb.uid'; diff --git a/include/reminder/promotion_ml.inc.php b/include/reminder/promotion_ml.inc.php index ec1b0c5..7e4276e 100644 --- a/include/reminder/promotion_ml.inc.php +++ b/include/reminder/promotion_ml.inc.php @@ -26,11 +26,11 @@ class ReminderPromotionMl extends Reminder switch ($action) { case 'yes': $res = XDB::query('SELECT id - FROM #groupex#.asso + FROM groups WHERE diminutif = {?}', S::v('promo')); $asso_id = $res->fetchOneCell(); - XDB::execute('REPLACE INTO #groupex#.membres (uid, asso_id) + XDB::execute('REPLACE INTO group_members (uid, asso_id) VALUES ({?}, {?})', S::v('uid'), $asso_id); $mmlist = new MMList(S::v('uid'), S::v('password')); @@ -67,9 +67,9 @@ class ReminderPromotionMl extends Reminder // We only test if the user is in her promotion group for it is too // expensive to check if she is in the corresponding ML as well. $res = XDB::query('SELECT COUNT(*) - FROM #groupex#.membres + FROM group_members WHERE uid = {?} AND asso_id = (SELECT id - FROM #groupex#.asso + FROM groups WHERE diminutif = {?})', $user->id(), S::v('promo')); diff --git a/include/user.func.inc.php b/include/user.func.inc.php index 82afc63..db4eaa4 100644 --- a/include/user.func.inc.php +++ b/include/user.func.inc.php @@ -42,7 +42,7 @@ function user_clear_all_subs($user_id, $really_del=true) 'user_id' => array('requests', 'user_changes')); if ($really_del) { - array_push($tables_to_clear['uid'], 'emails', '#groupex#.membres', 'contacts', 'adresses', 'profile_phones', + array_push($tables_to_clear['uid'], 'emails', 'group_members', 'contacts', 'adresses', 'profile_phones', 'photo', 'perte_pass', 'langues_ins', 'forum_subs', 'forum_profiles'); array_push($tables_to_clear['user_id'], 'newsletter_ins', 'binets_ins'); $tables_to_clear['id'] = array('aliases'); diff --git a/include/validations/paiements.inc.php b/include/validations/paiements.inc.php index 6c13c31..9c5851e 100644 --- a/include/validations/paiements.inc.php +++ b/include/validations/paiements.inc.php @@ -60,11 +60,11 @@ Si le télépaiement n'est pas lié à un groupe ou supérieur à 51 euros, lais $this->montant_max = $_montantmax; if ($_asso_id) { - $res = XDB::query("SELECT nom FROM #groupex#.asso WHERE id = {?}", $_asso_id); + $res = XDB::query("SELECT nom FROM groups WHERE id = {?}", $_asso_id); $this->asso = $res->fetchOneCell(); } if ($_asso_id && $_evt) { - $res = XDB::query("SELECT intitule FROM #groupex#.evenements WHERE asso_id = {?} AND eid = {?}", $_asso_id, $_evt); + $res = XDB::query("SELECT intitule FROM group_events WHERE asso_id = {?} AND eid = {?}", $_asso_id, $_evt); $this->evt_intitule = $res->fetchOneCell(); } } @@ -176,13 +176,13 @@ Si le télépaiement n'est pas lié à un groupe ou supérieur à 51 euros, lais $this->montant, $this->montant_min, $this->montant_max, $this->user->bestEmail(), $this->msg_reponse, $this->asso_id); if ($this->asso_id && $this->evt) { - XDB::execute("UPDATE #groupex#.evenements + XDB::execute("UPDATE group_events SET paiement_id = {?} WHERE asso_id = {?} AND eid = {?}", $id, $this->asso_id, $this->evt); $res = XDB::query("SELECT a.nom, a.diminutif, e.intitule - FROM #groupex#.asso AS a - INNER JOIN #groupex#.evenements AS e ON (a.id = e.asso_id) + FROM groups AS a + INNER JOIN group_events AS e ON (a.id = e.asso_id) WHERE e.eid = {?}", $this->evt); list($nom, $diminutif, $evt) = $res->fetchOneRow(); diff --git a/modules/auth.php b/modules/auth.php index ead9cd2..dadf0a4 100644 --- a/modules/auth.php +++ b/modules/auth.php @@ -136,7 +136,7 @@ class AuthModule extends PLModule } // Iterate over the auth token to find which one did sign the request. - $res = XDB::iterRow('SELECT privkey, name, datafields, returnurls FROM groupesx_auth'); + $res = XDB::iterRow('SELECT privkey, name, datafields, returnurls FROM group_auth'); while (list($privkey,$name,$datafields,$returnurls) = $res->next()) { if (md5($gpex_challenge.$privkey) == $gpex_pass) { $returnurls = trim($returnurls); @@ -161,7 +161,7 @@ class AuthModule extends PLModule { $page->setTitle('Administration - Auth groupes X'); $page->assign('title', 'Gestion de l\'authentification centralisée'); - $table_editor = new PLTableEditor('admin/auth-groupes-x','groupesx_auth','id'); + $table_editor = new PLTableEditor('admin/auth-groupes-x','group_auth','id'); $table_editor->describe('name','nom',true); $table_editor->describe('privkey','clé privée',false); $table_editor->describe('datafields','champs renvoyés',true); diff --git a/modules/auth/auth.inc.php b/modules/auth/auth.inc.php index f232d67..e87d10d 100644 --- a/modules/auth/auth.inc.php +++ b/modules/auth/auth.inc.php @@ -67,8 +67,8 @@ function gpex_make($chlg, $privkey, $datafields, $charset) } else if ($val == 'grpauth') { if (isset($_GET['group'])) { $res = XDB::query("SELECT perms - FROM #groupex#.membres - INNER JOIN #groupex#.asso ON(id = asso_id) + FROM group_members + INNER JOIN groups ON(id = asso_id) WHERE uid = {?} AND diminutif = {?}", S::v('uid'), $_GET['group']); $perms = $res->fetchOneCell(); diff --git a/modules/lists.php b/modules/lists.php index 300789f..cad6c57 100644 --- a/modules/lists.php +++ b/modules/lists.php @@ -258,7 +258,7 @@ class ListsModule extends PLModule if ($asso == "groupex") { $groupex_name = Post::v('groupex_name'); - $res_groupe = XDB::query('SELECT mail_domain FROM #groupex#.asso WHERE nom={?}', $groupex_name); + $res_groupe = XDB::query('SELECT mail_domain FROM groups WHERE nom={?}', $groupex_name); $domain = $res_groupe->fetchOneCell(); if (!$domain) { diff --git a/modules/payment.php b/modules/payment.php index d15281d..7b2311a 100644 --- a/modules/payment.php +++ b/modules/payment.php @@ -219,7 +219,7 @@ class PaymentModule extends PLModule // We check if it is an Xnet payment and then update the related ML. $res = XDB::query('SELECT eid - FROM #groupex#.evenements + FROM group_events WHERE paiement_id = {?}', $ref); if ($eid = $res->fetchOneCell()) { $this->load('xnetevents.inc.php'); @@ -313,7 +313,7 @@ class PaymentModule extends PLModule // We check if it is an Xnet payment and then update the related ML. $res = XDB::query('SELECT eid - FROM #groupex#.evenements + FROM group_events WHERE paiement_id = {?}', $ref); if ($eid = $res->fetchOneCell()) { $this->load('xnetevents.inc.php'); @@ -364,8 +364,8 @@ class PaymentModule extends PLModule return PL_FORBIDDEN; } $res = XDB::query("SELECT 1 - FROM #groupex#.evenements AS e - INNER JOIN #groupex#.evenements_participants AS ep ON (ep.eid = e.eid AND uid = {?}) + FROM group_events AS e + INNER JOIN group_event_participants AS ep ON (ep.eid = e.eid AND uid = {?}) WHERE e.paiement_id = {?} AND e.asso_id = {?}", S::i('uid'), $pid, $globals->asso('id')); if ($res->numRows() == 0) { @@ -406,9 +406,9 @@ class PaymentModule extends PLModule 'montant' => strtr($sum, '.', ',').' €'); } $res = XDB::iterRow("SELECT e.eid, e.short_name, e.intitule, ep.nb, ei.montant, ep.paid - FROM #groupex#.evenements AS e - LEFT JOIN #groupex#.evenements_participants AS ep ON (ep.eid = e.eid AND uid = {?}) - INNER JOIN #groupex#.evenements_items AS ei ON (ep.eid = ei.eid AND ep.item_id = ei.item_id) + FROM group_events AS e + LEFT JOIN group_event_participants AS ep ON (ep.eid = e.eid AND uid = {?}) + INNER JOIN group_event_items AS ei ON (ep.eid = ei.eid AND ep.item_id = ei.item_id) WHERE e.paiement_id = {?}", S::v('uid'), $pid); $event[$pid] = array(); diff --git a/modules/payment/money.inc.php b/modules/payment/money.inc.php index bb0f8f1..9c1d501 100644 --- a/modules/payment/money.inc.php +++ b/modules/payment/money.inc.php @@ -88,9 +88,9 @@ class Payment { if ($this->asso_id) { $res = XDB::query("SELECT e.eid, a.diminutif - FROM #groupex#.evenements AS e - INNER JOIN #groupex#.asso AS a ON (e.asso_id = a.id) - LEFT JOIN #groupex#.evenements_participants AS p ON (p.eid = e.eid AND p.uid = {?}) + FROM group_events AS e + INNER JOIN groups AS a ON (e.asso_id = a.id) + LEFT JOIN group_event_participants AS p ON (p.eid = e.eid AND p.uid = {?}) WHERE e.paiement_id = {?} AND p.uid IS NULL", S::i('uid'), $this->id); if ($res->numRows()) { return $res->fetchOneAssoc(); diff --git a/modules/profile.php b/modules/profile.php index 4bf9813..4c62e1a 100644 --- a/modules/profile.php +++ b/modules/profile.php @@ -724,9 +724,9 @@ class ProfileModule extends PLModule $req = XDB::query(' SELECT m.asso_id, a.nom, diminutif, a.logo IS NOT NULL AS has_logo, COUNT(e.eid) AS events, mail_domain AS lists - FROM #groupex#.membres AS m - INNER JOIN #groupex#.asso AS a ON(m.asso_id = a.id) - LEFT JOIN #groupex#.evenements AS e ON(e.asso_id = m.asso_id AND e.archive = 0) + FROM group_members AS m + INNER JOIN groups AS a ON(m.asso_id = a.id) + LEFT JOIN group_events AS e ON(e.asso_id = m.asso_id AND e.archive = 0) WHERE uid = {?} GROUP BY m.asso_id ORDER BY a.nom', S::i('uid')); $page->assign('assos', $req->fetchAllAssoc()); } @@ -738,7 +738,7 @@ class ProfileModule extends PLModule } $res = XDB::query('SELECT logo, logo_mime - FROM #groupex#.asso + FROM groups WHERE id = {?}', $id); list($logo, $logo_mime) = $res->fetchOneRow(); diff --git a/modules/profile/groups.inc.php b/modules/profile/groups.inc.php index 95dc483..3cbc8d1 100644 --- a/modules/profile/groups.inc.php +++ b/modules/profile/groups.inc.php @@ -109,14 +109,14 @@ class ProfileGroups extends ProfilePage public function _prepare(PlPage &$page, $id) { $page->assign('mygroups', XDB::iterator("SELECT a.nom, a.site, a.diminutif, a.unsub_url, a.pub, m.perms - FROM #groupex#.asso AS a - INNER JOIN #groupex#.membres AS m ON (m.asso_id = a.id) + FROM groups AS a + INNER JOIN group_members AS m ON (m.asso_id = a.id) WHERE m.uid = {?} AND (a.cat = 'GroupesX' OR a.cat = 'Institutions')", $this->pid())); $page->assign('listgroups', XDB::iterator("SELECT a.nom, a.diminutif, a.sub_url, IF (a.cat = 'Institutions', a.cat, d.nom) AS dom - FROM #groupex#.asso AS a - LEFT JOIN #groupex#.dom AS d ON (d.id = a.dom) + FROM groups AS a + LEFT JOIN group_dom AS d ON (d.id = a.dom) WHERE a.inscriptible != 0 AND (a.cat = 'GroupesX' OR a.cat = 'Institutions') ORDER BY a.cat, a.dom, a.nom")); diff --git a/modules/register.php b/modules/register.php index 7e2d4bb..6cee226 100644 --- a/modules/register.php +++ b/modules/register.php @@ -348,10 +348,10 @@ class RegisterModule extends PLModule $storage->activate(); break; case 'ml_promo': - $r = XDB::query('SELECT id FROM #groupex#.asso WHERE diminutif = {?}', S::user()->promo()); + $r = XDB::query('SELECT id FROM groups WHERE diminutif = {?}', S::user()->promo()); if ($r->numRows()) { $asso_id = $r->fetchOneCell(); - XDB::execute('REPLACE INTO #groupex#.membres (uid, asso_id) + XDB::execute('REPLACE INTO group_members (uid, asso_id) VALUES ({?}, {?})', S::user()->id(), $asso_id); $mmlist = new MMList(S::user()->id(), S::v('password')); diff --git a/modules/search.php b/modules/search.php index a1539b1..8e013ae 100644 --- a/modules/search.php +++ b/modules/search.php @@ -48,7 +48,7 @@ class SearchModule extends PLModule global $globals; $res = XDB::query("SELECT MIN(diminutif), MAX(diminutif) - FROM #groupex#.asso + FROM groups WHERE cat = 'Promotions'"); list($min, $max) = $res->fetchOneRow(); $page->assign('promo_min', $min); diff --git a/modules/search/search.inc.php b/modules/search/search.inc.php index 7665c12..d184779 100644 --- a/modules/search/search.inc.php +++ b/modules/search/search.inc.php @@ -59,7 +59,7 @@ function advancedSearchFromInput() $natField = new RefSField('nationalite', array('u.nationalite', 'u.nationalite2', 'u.nationalite3'), '', '', ''); $binetField = new RefSField('binet', array('b.binet_id'), 'binets_ins', 'b', 'u.user_id=b.user_id'); - $groupexField = new RefSField('groupex', array('g.id'), array('#groupex#.asso', '#groupex#.membres'), array('g', 'gm'), + $groupexField = new RefSField('groupex', array('g.id'), array('groups', 'group_members'), array('g', 'gm'), array("(g.cat = 'GroupesX' OR g.cat = 'Institutions') AND g.pub = 'public'", 'gm.asso_id = g.id AND u.user_id = gm.uid')); $sectionField = new RefSField('section', array('u.section'), '', '', ''); diff --git a/modules/xnet.php b/modules/xnet.php index ea1d55c..aafe36e 100644 --- a/modules/xnet.php +++ b/modules/xnet.php @@ -76,14 +76,14 @@ class XnetModule extends PLModule if (Get::has('del')) { $res = XDB::query('SELECT id, nom, mail_domain - FROM #groupex#.asso WHERE diminutif={?}', + FROM groups WHERE diminutif={?}', Get::v('del')); list($id, $nom, $domain) = $res->fetchOneRow(); $page->assign('nom', $nom); if ($id && Post::has('del')) { S::assert_xsrf_token(); - XDB::query('DELETE FROM #groupex#.membres WHERE asso_id={?}', $id); + XDB::query('DELETE FROM group_members WHERE asso_id={?}', $id); $page->trigSuccess('membres supprimés'); if ($domain) { @@ -102,7 +102,7 @@ class XnetModule extends PLModule } } - XDB::query('DELETE FROM #groupex#.asso WHERE id={?}', $id); + XDB::query('DELETE FROM groups WHERE id={?}', $id); $page->trigSuccess("Groupe $nom supprimé"); Get::kill('del'); } @@ -115,12 +115,12 @@ class XnetModule extends PLModule S::assert_xsrf_token(); $res = XDB::query('SELECT COUNT(*) - FROM #groupex#.asso + FROM groups WHERE diminutif = {?}', Post::v('diminutif')); if ($res->fetchOneCell() == 0) { - XDB::execute('INSERT INTO #groupex#.asso (id, diminutif) + XDB::execute('INSERT INTO groups (id, diminutif) VALUES (NULL, {?})', Post::v('diminutif')); pl_redirect('../' . Post::v('diminutif') . '/edit'); @@ -130,7 +130,7 @@ class XnetModule extends PLModule } $res = XDB::query('SELECT nom, diminutif - FROM #groupex#.asso + FROM groups ORDER BY nom'); $page->assign('assos', $res->fetchAllAssoc()); } @@ -143,8 +143,8 @@ class XnetModule extends PLModule $res = XDB::iterator( 'SELECT dom.id, dom.nom as domnom, asso.diminutif, asso.nom - FROM #groupex#.dom - INNER JOIN #groupex#.asso ON dom.id = asso.dom + FROM group_dom + INNER JOIN groups ON dom.id = asso.dom WHERE FIND_IN_SET("GroupesX", dom.cat) AND FIND_IN_SET("GroupesX", asso.cat) ORDER BY dom.nom, asso.nom'); $groupesx = array(); @@ -153,8 +153,8 @@ class XnetModule extends PLModule $res = XDB::iterator( 'SELECT dom.id, dom.nom as domnom, asso.diminutif, asso.nom - FROM #groupex#.dom - INNER JOIN #groupex#.asso ON dom.id = asso.dom + FROM group_dom + INNER JOIN groups ON dom.id = asso.dom WHERE FIND_IN_SET("Binets", dom.cat) AND FIND_IN_SET("Binets", asso.cat) ORDER BY dom.nom, asso.nom'); $binets = array(); @@ -163,14 +163,14 @@ class XnetModule extends PLModule $res = XDB::iterator( 'SELECT asso.diminutif, asso.nom - FROM #groupex#.asso + FROM groups WHERE cat LIKE "%Promotions%" ORDER BY diminutif'); $page->assign('promos', $res); $res = XDB::iterator( 'SELECT asso.diminutif, asso.nom - FROM #groupex#.asso + FROM groups WHERE FIND_IN_SET("Institutions", cat) ORDER BY diminutif'); $page->assign('inst', $res); @@ -194,7 +194,7 @@ class XnetModule extends PLModule $page->assign('dom', $dom); $res = XDB::query("SELECT id,nom - FROM #groupex#.dom + FROM group_dom WHERE FIND_IN_SET({?}, cat) ORDER BY nom", $cat); $doms = $res->fetchAllAssoc(); @@ -202,13 +202,13 @@ class XnetModule extends PLModule if (empty($doms)) { $res = XDB::query("SELECT diminutif, nom, site - FROM #groupex#.asso + FROM groups WHERE FIND_IN_SET({?}, cat) ORDER BY nom", $cat); $page->assign('gps', $res->fetchAllAssoc()); } elseif (!is_null($dom)) { $res = XDB::query("SELECT diminutif, nom, site - FROM #groupex#.asso + FROM groups WHERE FIND_IN_SET({?}, cat) AND dom={?} ORDER BY nom", $cat, $dom); $page->assign('gps', $res->fetchAllAssoc()); diff --git a/modules/xnetevents.php b/modules/xnetevents.php index bda8816..698e515 100644 --- a/modules/xnetevents.php +++ b/modules/xnetevents.php @@ -60,7 +60,7 @@ class XnetEventsModule extends PLModule } S::assert_xsrf_token(); - $res = XDB::query("SELECT asso_id, short_name FROM #groupex#.evenements + $res = XDB::query("SELECT asso_id, short_name FROM group_events WHERE eid = {?} AND asso_id = {?}", $eid, $globals->asso('id')); @@ -81,15 +81,15 @@ class XnetEventsModule extends PLModule } // deletes the event items - XDB::execute('DELETE FROM #groupex#.evenements_items + XDB::execute('DELETE FROM group_event_items WHERE eid = {?}', $eid); // deletes the event participants - XDB::execute('DELETE FROM #groupex#.evenements_participants + XDB::execute('DELETE FROM group_event_participants WHERE eid = {?}', $eid); // deletes the event - XDB::execute('DELETE FROM #groupex#.evenements + XDB::execute('DELETE FROM group_events WHERE eid = {?} AND asso_id = {?}', $eid, $globals->asso('id')); @@ -102,14 +102,14 @@ class XnetEventsModule extends PLModule } if ($action == 'archive') { - XDB::execute("UPDATE #groupex#.evenements + XDB::execute("UPDATE group_events SET archive = 1 WHERE eid = {?} AND asso_id = {?}", $eid, $globals->asso('id')); } if ($action == 'unarchive') { - XDB::execute("UPDATE #groupex#.evenements + XDB::execute("UPDATE group_events SET archive = 0 WHERE eid = {?} AND asso_id = {?}", $eid, $globals->asso('id')); @@ -122,8 +122,8 @@ class XnetEventsModule extends PLModule 1) AS inscr_open, e.deadline_inscription, MAX(ep.nb) IS NOT NULL AS inscrit, MAX(ep.paid) AS paid - FROM #groupex#.evenements AS e - LEFT JOIN #groupex#.evenements_participants AS ep ON (ep.eid = e.eid AND ep.uid = {?}) + FROM group_events AS e + LEFT JOIN group_event_participants AS ep ON (ep.eid = e.eid AND ep.uid = {?}) WHERE asso_id = {?} AND archive = {?} GROUP BY e.eid ORDER BY inscr_open DESC, debut DESC', @@ -141,8 +141,8 @@ class XnetEventsModule extends PLModule $e['show_participants'] = ($e['show_participants'] && (is_member() || may_update())); $e['moments'] = XDB::fetchAllAssoc('SELECT titre, details, montant, ei.item_id, nb, ep.paid - FROM #groupex#.evenements_items AS ei - LEFT JOIN #groupex#.evenements_participants AS ep + FROM group_event_items AS ei + LEFT JOIN group_event_participants AS ep ON (ep.eid = ei.eid AND ep.item_id = ei.item_id AND ep.uid = {?}) WHERE ei.eid = {?}', S::i('uid'), $e['eid']); @@ -252,14 +252,14 @@ class XnetEventsModule extends PLModule foreach ($subs as $j => $nb) { if ($nb >= 0) { XDB::execute( - "REPLACE INTO #groupex#.evenements_participants + "REPLACE INTO group_event_participants VALUES ({?}, {?}, {?}, {?}, {?}, {?})", $eid, S::v('uid'), $j, $nb, Env::has('notify_payment') ? 'notify_payment' : '', $j == 1 ? $paid - $telepaid : 0); $updated = $eid; } else { XDB::execute( - "DELETE FROM #groupex#.evenements_participants + "DELETE FROM group_event_participants WHERE eid = {?} AND uid = {?} AND item_id = {?}", $eid, S::v("uid"), $j); $updated = $eid; @@ -342,7 +342,7 @@ class XnetEventsModule extends PLModule // get eid if the the given one is a short name if (!is_null($eid) && !is_numeric($eid)) { $res = XDB::query("SELECT eid - FROM #groupex#.evenements + FROM group_events WHERE asso_id = {?} AND short_name = {?}", $globals->asso('id'), $eid); if ($res->numRows()) { @@ -353,7 +353,7 @@ class XnetEventsModule extends PLModule // check the event is in our group if (!is_null($eid)) { $res = XDB::query("SELECT short_name - FROM #groupex#.evenements + FROM group_events WHERE eid = {?} AND asso_id = {?}", $eid, $globals->asso('id')); if ($res->numRows()) { @@ -410,7 +410,7 @@ class XnetEventsModule extends PLModule } // Store the modifications in the database - XDB::execute('REPLACE INTO #groupex#.evenements + XDB::execute('REPLACE INTO group_events SET eid={?}, asso_id={?}, organisateur_uid={?}, intitule={?}, paiement_id = {?}, descriptif = {?}, debut = {?}, fin = {?}, show_participants = {?}, short_name = {?}, @@ -437,12 +437,12 @@ class XnetEventsModule extends PLModule $montant = strtr(Post::v('montant'.$i), ',', '.'); $money_defaut += (float)$montant; XDB::execute(" - REPLACE INTO #groupex#.evenements_items + REPLACE INTO group_event_items VALUES ({?}, {?}, {?}, {?}, {?})", $eid, $i, Post::v('titre'.$i), Post::v('details'.$i), $montant); } else { - XDB::execute("DELETE FROM #groupex#.evenements_items + XDB::execute("DELETE FROM group_event_items WHERE eid = {?} AND item_id = {?}", $eid, $i); } } @@ -465,7 +465,7 @@ class XnetEventsModule extends PLModule // events with no sub-event: add a sub-event with no name if ($nb_moments == 0) { - XDB::execute("INSERT INTO #groupex#.evenements_items + XDB::execute("INSERT INTO group_event_items VALUES ({?}, {?}, '', '', 0)", $eid, 1); } @@ -489,7 +489,7 @@ class XnetEventsModule extends PLModule "SELECT eid, intitule, descriptif, debut, fin, organisateur_uid, show_participants, paiement_id, short_name, deadline_inscription, noinvite, accept_nonmembre - FROM #groupex#.evenements + FROM group_events WHERE eid = {?}", $eid); $evt = $res->fetchOneAssoc(); // find out if there is already a request for a payment for this event @@ -506,8 +506,8 @@ class XnetEventsModule extends PLModule // get all the different moments infos $res = XDB::iterator( "SELECT item_id, titre, details, montant - FROM #groupex#.evenements_items AS ei - INNER JOIN #groupex#.evenements AS e ON(e.eid = ei.eid) + FROM group_event_items AS ei + INNER JOIN group_events AS e ON(e.eid = ei.eid) WHERE e.eid = {?} ORDER BY item_id", $eid); $items = array(); @@ -545,7 +545,7 @@ class XnetEventsModule extends PLModule // change the price paid by a participant if (Env::v('adm') == 'prix' && $member) { - XDB::execute("UPDATE #groupex#.evenements_participants + XDB::execute("UPDATE group_event_participants SET paid = paid + {?} WHERE uid = {?} AND eid = {?} AND item_id = 1", strtr(Env::v('montant'), ',', '.'), @@ -555,7 +555,7 @@ class XnetEventsModule extends PLModule // change the number of personns coming with a participant if (Env::v('adm') == 'nbs' && $member) { $res = XDB::query("SELECT paid - FROM #groupex#.evenements_participants + FROM group_event_participants WHERE uid = {?} AND eid = {?}", $member['uid'], $evt['eid']); @@ -564,13 +564,13 @@ class XnetEventsModule extends PLModule foreach ($nbs as $id => $nb) { $nb = max(intval($nb), 0); - XDB::execute("REPLACE INTO #groupex#.evenements_participants + XDB::execute("REPLACE INTO group_event_participants VALUES ({?}, {?}, {?}, {?}, {?}, {?})", $evt['eid'], $member['uid'], $id, $nb, '', $id == 1 ? $paid : 0); } $res = XDB::query("SELECT COUNT(uid) AS cnt, SUM(nb) AS nb - FROM #groupex#.evenements_participants + FROM group_event_participants WHERE uid = {?} AND eid = {?} GROUP BY uid", $member['uid'], $evt['eid']); @@ -593,7 +593,7 @@ class XnetEventsModule extends PLModule $infos = User::getBulkUsersWithUIDs( XDB::fetchAllAssoc('SELECT t.uid, t.montant FROM ' . $globals->money->mpay_tprefix . 'transactions AS t - LEFT JOIN #groupex#.evenements_participants AS ep ON(ep.uid = t.uid AND ep.eid = {?}) + LEFT JOIN group_event_participants AS ep ON(ep.uid = t.uid AND ep.eid = {?}) WHERE t.ref = {?} AND ep.uid IS NULL', $evt['eid'], $evt['paiement_id']), 'uid', 'user'); @@ -602,8 +602,8 @@ class XnetEventsModule extends PLModule } $absents = User::getBulkUsersFromDB('SELECT p.uid - FROM #groupex#.evenements_participants AS p - LEFT JOIN #groupex#.evenements_participants AS p2 ON (p2.uid = p.uid + FROM group_event_participants AS p + LEFT JOIN group_event_participants AS p2 ON (p2.uid = p.uid AND p2.eid = p.eid AND p2.nb != 0) WHERE p.eid = {?} AND p2.eid IS NULL diff --git a/modules/xnetevents/xnetevents.inc.php b/modules/xnetevents/xnetevents.inc.php index fe8fc4a..2d92b16 100644 --- a/modules/xnetevents/xnetevents.inc.php +++ b/modules/xnetevents/xnetevents.inc.php @@ -34,9 +34,9 @@ function get_event_detail($eid, $item_id = false, $asso_id = null) LEFT(10, e.debut) AS start_day, LEFT(10, e.fin) AS last_day, LEFT(NOW(), 10) AS now, ei.titre, al.vid AS absent_list, pl.vid AS participant_list - FROM #groupex#.evenements AS e - INNER JOIN #groupex#.evenements_items AS ei ON (e.eid = ei.eid) - LEFT JOIN #groupex#.evenements_participants AS ep ON(e.eid = ep.eid AND ei.item_id = ep.item_id) + FROM group_events AS e + INNER JOIN group_event_items AS ei ON (e.eid = ei.eid) + LEFT JOIN group_event_participants AS ep ON(e.eid = ep.eid AND ei.item_id = ep.item_id) LEFT JOIN #x4dat#.virtual AS al ON(al.type = \'evt\' AND al.alias = CONCAT(short_name, {?})) LEFT JOIN #x4dat#.virtual AS pl ON(pl.type = \'evt\' AND pl.alias = CONCAT(short_name, {?})) WHERE (e.eid = {?} OR e.short_name = {?}) AND ei.item_id = {?} AND e.asso_id = {?} @@ -58,9 +58,9 @@ function get_event_detail($eid, $item_id = false, $asso_id = null) // smart calculation of the total number if (!$item_id) { $res = XDB::query('SELECT MAX(nb) - FROM #groupex#.evenements AS e - INNER JOIN #groupex#.evenements_items AS ei ON (e.eid = ei.eid) - LEFT JOIN #groupex#.evenements_participants AS ep ON (e.eid = ep.eid AND ei.item_id = ep.item_id) + FROM group_events AS e + INNER JOIN group_event_items AS ei ON (e.eid = ei.eid) + LEFT JOIN group_event_participants AS ep ON (e.eid = ep.eid AND ei.item_id = ep.item_id) WHERE e.eid = {?} GROUP BY ep.uid', $evt['eid']); $evt['nb_tot'] = array_sum($res->fetchColumn()); @@ -70,8 +70,8 @@ function get_event_detail($eid, $item_id = false, $asso_id = null) $evt['moments'] = XDB::fetchAllAssoc('SELECT titre, details, montant, ei.item_id, nb, ep.paid, FIND_IN_SET(\'notify_payment\', ep.flags) AS notify_payment - FROM #groupex#.evenements_items AS ei - LEFT JOIN #groupex#.evenements_participants AS ep ON (ep.eid = ei.eid AND ep.item_id = ei.item_id + FROM group_event_items AS ei + LEFT JOIN group_event_participants AS ep ON (ep.eid = ei.eid AND ep.item_id = ei.item_id AND uid = {?}) WHERE ei.eid = {?}', S::i('uid'), $evt['eid']); @@ -117,7 +117,7 @@ function get_event_participants(&$evt, $item_id, array $tri = array(), $count = $append = $item_id ? XDB::foramt(' AND ep.item_id = {?}', $item_id) : ''; $query = XDB::fetchAllAssoc('uid', 'SELECT ep.uid, SUM(ep.paid) AS paid, SUM(ep.nb) AS nb, FIND_IN_SET(\'notify_payment\', ep.flags) AS notify_payment - FROM #groupex#.evenements_participants AS ep + FROM group_event_participants AS ep WHERE ep.eid = {?} AND nb > 0 ' . $append . ' GROUP BY ep.uid', $eid); $uf = new UserFilter(new UFC_True(), $tri); @@ -152,8 +152,8 @@ function get_event_participants(&$evt, $item_id, array $tri = array(), $count = } $u['telepayment'] = $u['paid'] - $u['adminpaid']; $res_ = XDB::iterator('SELECT ep.nb, ep.item_id, ei.montant - FROM #groupex#.evenements_participants AS ep - INNER JOIN #groupex#.evenements_items AS ei ON (ei.eid = ep.eid AND ei.item_id = ep.item_id) + FROM group_event_participants AS ep + INNER JOIN group_event_items AS ei ON (ei.eid = ep.eid AND ei.item_id = ep.item_id) WHERE ep.eid = {?} AND ep.uid = {?}', $eid, $uid); while ($i = $res_->next()) { @@ -185,7 +185,7 @@ function subscribe_lists_event($participate, $uid, $evt, $paid, $payment = null) $email = $user->forlifeEmail(); } else { $res = XDB::query("SELECT email - FROM #groupex#.membres + FROM group_members WHERE uid = {?} AND asso_id = {?}", $uid, $globals->asso('id')); $email = $res->fetchOneCell(); @@ -256,7 +256,7 @@ function event_change_shortname(&$page, $eid, $old, $new) //vérifier que l'alias n'est pas déja pris if ($new && $old != $new) { $res = XDB::query('SELECT COUNT(*) - FROM #groupex#.evenements + FROM group_events WHERE short_name = {?}', $new); if ($res->fetchOneCell() > 0) { @@ -301,7 +301,7 @@ function event_change_shortname(&$page, $eid, $old, $new) foreach (array('-participants@', '-paye@', '-participants-non-paye@') as $v) { XDB::execute("INSERT IGNORE INTO virtual_redirect ( SELECT {?} AS vid, IF(al.alias IS NULL, a.email, CONCAT(al.alias, {?})) AS redirect - FROM #groupex#.evenements_participants AS ep + FROM group_event_participants AS ep LEFT JOIN #x4dat#.accounts AS a ON (ep.uid = a.uid) LEFT JOIN #x4dat#.aliases AS al ON (al.id = a.uid AND al.type = 'a_vie') WHERE ep.eid = {?} AND " . $where[$v] . " @@ -310,10 +310,10 @@ function event_change_shortname(&$page, $eid, $old, $new) } XDB::execute("INSERT IGNORE INTO virtual_redirect ( SELECT {?} AS vid, IF(al.alias IS NULL, a.email, CONCAT(al.alias, {?})) AS redirect - FROM #groupex#.membres AS m + FROM group_members AS m LEFT JOIN #x4dat#.accounts AS a ON (a.uid = m.uid) LEFT JOIN #x4dat#.aliases AS al ON (al.id = a.uid AND al.type = 'a_vie') - LEFT JOIN #groupex#.evenements_participants AS ep ON (ep.uid = m.uid AND ep.eid = {?}) + LEFT JOIN group_event_participants AS ep ON (ep.uid = m.uid AND ep.eid = {?}) WHERE m.asso_id = {?} AND ep.uid IS NULL GROUP BY m.uid)", $lastid['-absents@'], '@' . $globals->mail->domain, $eid, $globals->asso('id')); diff --git a/modules/xnetgrp.php b/modules/xnetgrp.php index 6c0a5da..248b4a1 100644 --- a/modules/xnetgrp.php +++ b/modules/xnetgrp.php @@ -66,25 +66,25 @@ class XnetGrpModule extends PLModule if (S::logged()) { if (Env::has('read')) { - XDB::query('DELETE #groupex#.r.* - FROM #groupex#.announces_read AS r - INNER JOIN #groupex#.announces AS a ON a.id = r.announce_id + XDB::query('DELETE group_r.* + FROM group_announces_read AS r + INNER JOIN group_announces AS a ON a.id = r.announce_id WHERE peremption < CURRENT_DATE()'); - XDB::query('INSERT INTO #groupex#.announces_read + XDB::query('INSERT INTO group_announces_read VALUES ({?}, {?})', Env::i('read'), S::i('uid')); pl_redirect(""); } if (Env::has('unread')) { - XDB::query('DELETE FROM #groupex#.announces_read + XDB::query('DELETE FROM group_announces_read WHERE announce_id={?} AND user_id={?}', Env::i('unread'), S::i('uid')); pl_redirect("#art" . Env::i('unread')); } // XXX: Fix promo_min; promo_max $arts = XDB::iterator("SELECT a.*, FIND_IN_SET('photo', a.flags) AS photo - FROM #groupex#.announces AS a - LEFT JOIN #groupex#.announces_read AS r ON (r.user_id = {?} AND r.announce_id = a.id) + FROM group_announces AS a + LEFT JOIN group_announces_read AS r ON (r.user_id = {?} AND r.announce_id = a.id) WHERE asso_id = {?} AND peremption >= CURRENT_DATE() AND (promo_min = 0 OR promo_min <= {?}) AND (promo_max = 0 OR promo_max >= {?}) @@ -92,8 +92,8 @@ class XnetGrpModule extends PLModule ORDER BY a.peremption", S::i('uid'), $globals->asso('id'), S::i('promo'), S::i('promo')); $index = XDB::iterator("SELECT a.id, a.titre, r.user_id IS NULL AS nonlu - FROM #groupex#.announces AS a - LEFT JOIN #groupex#.announces_read AS r ON (a.id = r.announce_id AND r.user_id = {?}) + FROM group_announces AS a + LEFT JOIN group_announces_read AS r ON (a.id = r.announce_id AND r.user_id = {?}) WHERE asso_id = {?} AND peremption >= CURRENT_DATE() AND (promo_min = 0 OR promo_min <= {?}) AND (promo_max = 0 OR promo_max >= {?}) @@ -102,14 +102,14 @@ class XnetGrpModule extends PLModule $page->assign('article_index', $index); } else { $arts = XDB::iterator("SELECT a.*, FIND_IN_SET('photo', a.flags) AS photo - FROM #groupex#.announces AS a + FROM group_announces AS a WHERE asso_id = {?} AND peremption >= CURRENT_DATE() AND FIND_IN_SET('public', a.flags)", $globals->asso('id')); } if (may_update()) { $subs_valid = XDB::query("SELECT uid - FROM #groupex#.membres_sub_requests + FROM group_member_sub_requests WHERE asso_id = {?}", $globals->asso('id')); $page->assign('requests', $subs_valid->numRows()); @@ -131,7 +131,7 @@ class XnetGrpModule extends PLModule global $globals; $res = XDB::query("SELECT logo, logo_mime - FROM #groupex#.asso + FROM groups WHERE id = {?}", $globals->asso('id')); list($logo, $logo_mime) = $res->fetchOneRow(); @@ -177,7 +177,7 @@ class XnetGrpModule extends PLModule return; } XDB::execute( - "UPDATE #groupex#.asso + "UPDATE groups SET nom={?}, diminutif={?}, cat={?}, dom={?}, descr={?}, site={?}, mail={?}, resp={?}, forum={?}, mail_domain={?}, ax={?}, pub={?}, @@ -198,7 +198,7 @@ class XnetGrpModule extends PLModule } } else { XDB::execute( - "UPDATE #groupex#.asso + "UPDATE groups SET descr={?}, site={?}, mail={?}, resp={?}, forum={?}, pub= {?}, sub_url={?}, unsub_url={?},flags={?} @@ -216,7 +216,7 @@ class XnetGrpModule extends PLModule if (!$upload) { $page->trigError("Impossible de télécharger le logo."); } else { - XDB::execute('UPDATE #groupex#.asso + XDB::execute('UPDATE groups SET logo = {?}, logo_mime = {?} WHERE id = {?}', $upload->getContents(), $upload->contentType(), $globals->asso('id')); @@ -228,7 +228,7 @@ class XnetGrpModule extends PLModule } if (S::admin()) { - $dom = XDB::iterator('SELECT * FROM #groupex#.dom ORDER BY nom'); + $dom = XDB::iterator('SELECT * FROM group_dom ORDER BY nom'); $page->assign('dom', $dom); $page->assign('super', true); } @@ -370,7 +370,7 @@ class XnetGrpModule extends PLModule private function removeSubscriptionRequest($uid) { global $globals; - XDB::execute("DELETE FROM #groupex#.membres_sub_requests + XDB::execute("DELETE FROM group_member_sub_requests WHERE asso_id = {?} AND uid = {?}", $globals->asso('id'), $uid); } @@ -379,7 +379,7 @@ class XnetGrpModule extends PLModule { global $globals; $this->removeSubscriptionRequest($user->id()); - XDB::execute("INSERT IGNORE INTO #groupex#.membres (asso_id, uid) + XDB::execute("INSERT IGNORE INTO group_members (asso_id, uid) VALUES ({?}, {?})", $globals->asso('id'), $user->id()); if (XDB::affectedRows() == 1) { @@ -420,13 +420,13 @@ class XnetGrpModule extends PLModule // Retrieves the subscription status, and the reason. $res = XDB::query("SELECT reason - FROM #groupex#.membres_sub_requests + FROM group_member_sub_requests WHERE asso_id = {?} AND uid = {?}", $globals->asso('id'), $user->id()); $reason = ($res->numRows() ? $res->fetchOneCell() : null); $res = XDB::query("SELECT COUNT(*) - FROM #groupex#.membres + FROM group_members WHERE asso_id = {?} AND uid = {?}", $globals->asso('id'), $user->id()); $already_member = ($res->fetchOneCell() > 0); @@ -464,7 +464,7 @@ class XnetGrpModule extends PLModule } $res = XDB::query("SELECT uid - FROM #groupex#.membres_sub_requests + FROM group_member_sub_requests WHERE uid = {?} AND asso_id = {?}", S::i('uid'), $globals->asso('id')); if ($res->numRows() != 0) { @@ -475,13 +475,13 @@ class XnetGrpModule extends PLModule if (Post::has('inscrire')) { S::assert_xsrf_token(); - XDB::execute("INSERT INTO #groupex#.membres_sub_requests (asso_id, uid, ts, reason) + XDB::execute("INSERT INTO group_member_sub_requests (asso_id, uid, ts, reason) VALUES ({?}, {?}, NOW(), {?})", $globals->asso('id'), S::i('uid'), Post::v('message')); $res = XDB::query('SELECT IF(m.email IS NULL, CONCAT(al.alias,"@polytechnique.org"), m.email) - FROM #groupex#.membres AS m + FROM group_members AS m INNER JOIN #x4dat#.aliases AS al ON (al.type = "a_vie" AND al.id = m.uid) WHERE perms="admin" AND m.asso_id = {?}', @@ -539,7 +539,7 @@ class XnetGrpModule extends PLModule } $it = XDB::iterator('SELECT s.uid, a.hruid, s.ts AS date - FROM #groupex#.membres_sub_requests AS s + FROM group_member_sub_requests AS s INNER JOIN #x4dat#.accounts AS a ON(s.uid = a.uid) WHERE s.asso_id = {?} ORDER BY s.ts', $globals->asso('id')); @@ -630,7 +630,7 @@ class XnetGrpModule extends PLModule if (!User::isForeignEmailAddress($email)) { $user = User::get($email); if ($user) { - XDB::execute("REPLACE INTO #groupex#.membres (uid, asso_id, origine) + XDB::execute("REPLACE INTO group_members (uid, asso_id, origine) VALUES ({?}, {?}, 'X')", $user->id(), $globals->asso('id')); pl_redirect("member/" . $user->login()); @@ -649,7 +649,7 @@ class XnetGrpModule extends PLModule $market->add(); } } - XDB::execute('REPLACE INTO #groupex#.membres (uid, asso_id, origine, email) + XDB::execute('REPLACE INTO group_members (uid, asso_id, origine, email) VALUES ({?}, {?}, "X", {?})', $uid, $globals->asso('id'), $email); $this->removeSubscriptionRequest($uid); @@ -657,9 +657,9 @@ class XnetGrpModule extends PLModule } $page->trigError("Utilisateur invalide"); } else { - $res = XDB::query('SELECT MAX(uid) + 1 FROM #groupex#.membres'); + $res = XDB::query('SELECT MAX(uid) + 1 FROM group_members'); $uid = max(intval($res->fetchOneCell()), 50001); - XDB::execute('REPLACE INTO #groupex#.membres (uid, asso_id, origine, email) + XDB::execute('REPLACE INTO group_members (uid, asso_id, origine, email) VALUES ({?}, {?}, "ext", {?})', $uid, $globals->asso('id'), $email); pl_redirect("member/$email"); @@ -706,7 +706,7 @@ class XnetGrpModule extends PLModule function unsubscribe(PlUser &$user) { global $globals; - XDB::execute("DELETE FROM #groupex#.membres + XDB::execute("DELETE FROM group_members WHERE uid = {?} AND asso_id = {?}", $user->id(), $globals->asso('id')); @@ -828,17 +828,17 @@ class XnetGrpModule extends PLModule // Check if the user is already in the group global $globals; $res = XDB::query("SELECT uid, email - FROM #groupex#.membres + FROM group_members WHERE uid = {?} AND asso_id = {?}", $uid, $globals->asso('id')); if ($res->numRows()) { list($uid, $email) = $res->fetchOneRow(); - XDB::execute("DELETE FROM #groupex#.membres + XDB::execute("DELETE FROM group_members WHERE uid = {?}", $user['uid']); } else { $email = $user['email']; - XDB::execute("UPDATE #groupex#.membres + XDB::execute("UPDATE group_members SET uid = {?}, origine = 'X' WHERE uid = {?} AND asso_id = {?}", $uid, $user['uid'], $globals->asso('id')); @@ -902,7 +902,7 @@ class XnetGrpModule extends PLModule $user['prenom'] = (Post::v('origine') == 'ext') ? Post::v('prenom') : ''; $user['sexe'] = (Post::v('origine') == 'ext') ? Post::v('sexe') : 0; $user['origine'] = Post::v('origine'); - XDB::query('UPDATE #groupex#.membres + XDB::query('UPDATE group_members SET prenom = {?}, nom = {?}, email = {?}, sexe = {?}, origine = {?} WHERE uid = {?} AND asso_id = {?}', $user['prenom'], $user['nom'], Post::v('email'), @@ -916,7 +916,7 @@ class XnetGrpModule extends PLModule $perms = Post::i('is_admin'); $comm = Post::t('comm'); if ($user['perms'] != $perms || $user['comm'] != $comm) { - XDB::query('UPDATE #groupex#.membres + XDB::query('UPDATE group_members SET perms = {?}, comm = {?} WHERE uid = {?} AND asso_id = {?}', $perms ? 'admin' : 'membre', $comm, @@ -1014,7 +1014,7 @@ class XnetGrpModule extends PLModule function handler_photo_announce(&$page, $eid = null) { if ($eid) { - $res = XDB::query("SELECT * FROM #groupex#.announces_photo WHERE eid = {?}", $eid); + $res = XDB::query("SELECT * FROM group_announces_photo WHERE eid = {?}", $eid); if ($res->numRows()) { $photo = $res->fetchOneAssoc(); pl_cached_dynamic_content_headers("image/" . $photo['attachmime']); @@ -1091,7 +1091,7 @@ class XnetGrpModule extends PLModule } $art['photo'] = $upload->exists() || Post::i('photo'); if (Post::v('valid') == 'Pas d\'image' && !is_null($aid)) { - XDB::query("DELETE FROM #groupex#.announces_photo WHERE eid = {?}", $aid); + XDB::query("DELETE FROM group_announces_photo WHERE eid = {?}", $aid); $upload->rm(); Post::kill('valid'); $art['photo'] = false; @@ -1120,7 +1120,7 @@ class XnetGrpModule extends PLModule $post = $banana->post($globals->asso('forum'), null, $art['titre'], MiniWiki::wikiToText($fulltext, false, 0, 80)); }*/ - XDB::query("INSERT INTO #groupex#.announces + XDB::query("INSERT INTO group_announces (user_id, asso_id, create_date, titre, texte, contacts, peremption, promo_min, promo_max, flags, post_id) VALUES ({?}, {?}, NOW(), {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})", @@ -1129,7 +1129,7 @@ class XnetGrpModule extends PLModule $aid = XDB::insertId(); if ($art['photo']) { list($imgx, $imgy, $imgtype) = $upload->imageInfo(); - XDB::execute("INSERT INTO #groupex#.announces_photo + XDB::execute("INSERT INTO group_announces_photo SET eid = {?}, attachmime = {?}, x = {?}, y = {?}, attach = {?}", $aid, $imgtype, $imgx, $imgy, $upload->getContents()); } @@ -1151,7 +1151,7 @@ class XnetGrpModule extends PLModule $page->trigWarning("La parution dans la Lettre Mensuelle est en attente de validation."); } } else { - XDB::query("UPDATE #groupex#.announces + XDB::query("UPDATE group_announces SET titre={?}, texte={?}, contacts={?}, peremption={?}, promo_min={?}, promo_max={?}, flags={?} WHERE id={?} AND asso_id={?}", @@ -1160,7 +1160,7 @@ class XnetGrpModule extends PLModule $art['id'], $globals->asso('id')); if ($art['photo'] && $upload->exists()) { list($imgx, $imgy, $imgtype) = $upload->imageInfo(); - XDB::execute("REPLACE INTO #groupex#.announces_photo + XDB::execute("REPLACE INTO group_announces_photo SET eid = {?}, attachmime = {?}, x = {?}, y = {?}, attach = {?}", $aid, $imgtype, $imgx, $imgy, $upload->getContents()); $upload->rm(); @@ -1174,7 +1174,7 @@ class XnetGrpModule extends PLModule if (empty($art) && !is_null($aid)) { $res = XDB::query("SELECT a.*, FIND_IN_SET('public', a.flags) AS public, FIND_IN_SET('photo', a.flags) AS photo - FROM #groupex#.announces AS a + FROM group_announces AS a WHERE asso_id = {?} AND a.id = {?}", $globals->asso('id'), $aid); if ($res->numRows()) { @@ -1187,7 +1187,7 @@ class XnetGrpModule extends PLModule if (is_null($aid)) { $events = XDB::iterator("SELECT * - FROM #groupex#.evenements + FROM group_events WHERE asso_id = {?} AND archive = 0", $globals->asso('id')); if ($events->total()) { @@ -1207,12 +1207,12 @@ class XnetGrpModule extends PLModule if (Env::has('del')) { S::assert_xsrf_token(); - XDB::execute("DELETE FROM #groupex#.announces + XDB::execute("DELETE FROM group_announces WHERE id = {?} AND asso_id = {?}", Env::i('del'), $globals->asso('id')); } $res = XDB::iterator("SELECT a.id, a.titre, a.peremption, a.peremption < CURRENT_DATE() AS perime - FROM #groupex#.announces AS a + FROM group_announces AS a WHERE a.asso_id = {?} ORDER BY a.peremption DESC", $globals->asso('id')); diff --git a/modules/xnetgrp/feed.inc.php b/modules/xnetgrp/feed.inc.php index d7a30d3..1d2037e 100644 --- a/modules/xnetgrp/feed.inc.php +++ b/modules/xnetgrp/feed.inc.php @@ -79,14 +79,14 @@ class XnetGrpEventFeed extends PlFeed a.create_date AS publication, FIND_IN_SET('photo', a.flags) AS photo, CONCAT({?}, '/#art', a.id) AS link - FROM #groupex#.announces AS a + FROM group_announces AS a WHERE peremption >= NOW() AND a.asso_id = {?}", $this->link, $globals->asso('id'), $user)); } else { return XDB::iterator("SELECT a.id, a.titre AS title, a.texte, a.create_date AS publication, CONCAT({?}, '/#art', a.id) AS link, NULL AS photo, NULL AS contacts - FROM #groupex#.announces AS a + FROM group_announces AS a WHERE FIND_IN_SET('public', a.flags) AND peremption >= NOW() AND a.asso_id = {?}", $this->link, $globals->asso('id')); } diff --git a/modules/xnetlists.php b/modules/xnetlists.php index b4e5987..e07612f 100644 --- a/modules/xnetlists.php +++ b/modules/xnetlists.php @@ -119,7 +119,7 @@ class XnetListsModule extends ListsModule $page->assign('may_update', may_update()); if (count($listes) > 0 && !$globals->asso('has_ml')) { - XDB::execute("UPDATE #groupex#.asso + XDB::execute("UPDATE groups SET flags = CONCAT_WS(',', IF(flags = '', NULL, flags), 'has_ml') WHERE id = {?}", $globals->asso('id')); @@ -191,7 +191,7 @@ class XnetListsModule extends ListsModule $red . $mdir . '@listes.polytechnique.org'); } - XDB::execute("UPDATE #groupex#.asso + XDB::execute("UPDATE groups SET flags = CONCAT_WS(',', IF(flags = '', NULL, flags), 'has_ml') WHERE id = {?}", $globals->asso('id')); @@ -222,7 +222,7 @@ class XnetListsModule extends ListsModule $not_in_group_ext = array(); $ann = XDB::fetchColumn('SELECT uid - FROM #groupex#.membres + FROM group_members WHERE asso_id = {?}', $globals->asso('id')); $users = User::getBuildUsersWithUIDs($ann, 'promo,full_name'); diff --git a/templates/payment/index.tpl b/templates/payment/index.tpl index be1474c..bf141cc 100644 --- a/templates/payment/index.tpl +++ b/templates/payment/index.tpl @@ -116,7 +116,7 @@ function payment_submit(form) {/if} {if $pay->url} diff --git a/upgrade/account/08_groups.sql b/upgrade/account/08_groups.sql new file mode 100644 index 0000000..58e13b6 --- /dev/null +++ b/upgrade/account/08_groups.sql @@ -0,0 +1,67 @@ +CREATE TABLE group_announces + LIKE groupex.announces; + INSERT INTO group_announces + SELECT * + FROM groupex.announces; + +CREATE TABLE group_announces_photo + LIKE groupex.announces_photo; + INSERT INTO group_announces_photo + SELECT * + FROM groupex.announces_photo; + +CREATE TABLE group_announces_read + LIKE groupex.announces_read; + INSERT INTO group_announces_read + SELECT * + FROM groupex.announces_read; + +CREATE TABLE groups + LIKE groupex.asso; + INSERT INTO groups + SELECT * + FROM groupex.asso; + +CREATE TABLE group_dom + LIKE groupex.dom; + INSERT INTO group_dom + SELECT * + FROM groupex.dom; + +CREATE TABLE group_events + LIKE groupex.evenements; + INSERT INTO group_events + SELECT * + FROM groupex.evenements; + +CREATE TABLE group_event_items + LIKE groupex.evenements_items; + INSERT INTO group_event_items + SELECT * + FROM groupex.evenements_items; + +CREATE TABLE group_event_participants + LIKE groupex.evenements_participants; + INSERT INTO group_event_participants + SELECT * + FROM groupex.evenements_participants; + +CREATE TABLE group_members + LIKE groupex.membres; + INSERT INTO group_members + SELECT * + FROM groupex.membres; + +CREATE TABLE group_member_sub_requests + LIKE groupex.membres_sub_requests; + INSERT INTO group_member_sub_requests + SELECT * + FROM groupex.membres_sub_requests; + +CREATE TABLE group_auth + LIKE x4dat.groupesx_auth; + INSERT INTO group_auth + SELECT * + FROM x4dat.groupesx_auth; + +# vim:set ft=mysql: -- 2.1.4