Signed-off-by: Stéphane Jacob <sj@m4x.org>
}
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())) {
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());
--- /dev/null
+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: