diff --git a/app/www/client/ajax/contacts_view.php b/app/www/client/ajax/contacts_view.php index 0444aea..6feb1c8 100755 --- a/app/www/client/ajax/contacts_view.php +++ b/app/www/client/ajax/contacts_view.php @@ -3,7 +3,7 @@ include("../src/prepend.inc.php"); - $sql = "SELECT clid FROM contacts LEFT JOIN contacts_data ON contacts.clid = contacts_data.contactid WHERE userid='{$_SESSION['userid']}' AND contacts_data.field = 'name'"; + $sql = "SELECT clid FROM contacts WHERE userid='{$_SESSION['userid']}'"; if ($req_id) { @@ -31,7 +31,7 @@ // $sort = $req_sort ? mysql_escape_string($req_sort) : "module_name"; // $dir = $req_dir ? mysql_escape_string($req_dir) : "ASC"; - $sql .= " ORDER BY tld ASC, contacts_data.value, module_name ASC"; + $sql .= " ORDER BY tld ASC, module_name ASC, (SELECT value FROM contacts_data WHERE contacts_data.contactid = contacts.clid AND contacts_data.field = 'name') ASC, (SELECT value FROM contacts_data WHERE contacts_data.contactid = contacts.clid AND contacts_data.field = 'organization') ASC"; diff --git a/app/www/client/complete_transfer.php b/app/www/client/complete_transfer.php index 16df815..d2261b2 100644 --- a/app/www/client/complete_transfer.php +++ b/app/www/client/complete_transfer.php @@ -79,10 +79,10 @@ if ($contact_count < 25) { $smarty_contact["exists"] = $db->GetAll(" - SELECT clid FROM contacts LEFT JOIN contacts_data ON contacts.clid = contacts_data.contactid - WHERE userid=? AND contacts_data.field = 'name' AND + SELECT clid FROM contacts + WHERE userid=? AND (TLD = ? OR (module_name=? AND section_name=? AND target_index=?)) AND - groupname=? ORDER BY contacts_data.value ASC, contacts.clid ASC + groupname=? ORDER BY (SELECT value FROM contacts_data WHERE contacts_data.contactid = contacts.clid AND contacts_data.field = 'name') ASC, (SELECT value FROM contacts_data WHERE contacts_data.contactid = contacts.clid AND contacts_data.field = 'organization') ASC, clid ASC ", array ( $_SESSION['userid'], //