From: Stéphane Jacob Date: Mon, 2 May 2011 15:51:29 +0000 (+0200) Subject: A user's contacts are profiles. X-Git-Tag: xorg/1.1.1~34 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=ba4ddab60284c90647b546e5d1acd511288fa3dc;p=platal.git A user's contacts are profiles. Signed-off-by: Stéphane Jacob --- diff --git a/modules/carnet.php b/modules/carnet.php index aee2890..b813289 100644 --- a/modules/carnet.php +++ b/modules/carnet.php @@ -280,7 +280,7 @@ class CarnetModule extends PLModule } switch (Env::v('action')) { case 'retirer': - if (($contact = User::get(Env::v('user')))) { + if (($contact = Profile::get(Env::v('user')))) { if (XDB::execute("DELETE FROM contacts WHERE uid = {?} AND contact = {?}", $uid, $contact->id())) { @@ -291,7 +291,7 @@ class CarnetModule extends PLModule break; case 'ajouter': - if (($contact = User::get(Env::v('user')))) { + if (($contact = Profile::get(Env::v('user')))) { XDB::execute('INSERT IGNORE INTO contacts (uid, contact) VALUES ({?}, {?})', $uid, $contact->id()); diff --git a/upgrade/1.1.1/14_contacts.sql b/upgrade/1.1.1/14_contacts.sql new file mode 100644 index 0000000..10a965c --- /dev/null +++ b/upgrade/1.1.1/14_contacts.sql @@ -0,0 +1,8 @@ +ALTER TABLE contacts DROP FOREIGN KEY contacts_ibfk_2; +DELETE FROM contacts + WHERE NOT EXISTS (SELECT profiles.* + FROM profiles + WHERE profiles.pid = contacts.contact); +ALTER TABLE contacts ADD FOREIGN KEY (contact) REFERENCES profiles (pid) ON DELETE CASCADE ON UPDATE CASCADE; + +-- vim:set syntax=mysql: