From cd58b105cb88183676ac3e0f26dc243e281387bd Mon Sep 17 00:00:00 2001 From: markjcrane Date: Mon, 25 Jan 2016 20:38:45 -0700 Subject: [PATCH] More work on user assigned contacts. --- app/provision/resources/classes/provision.php | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/app/provision/resources/classes/provision.php b/app/provision/resources/classes/provision.php index 95a3304d7f..f4426f160b 100644 --- a/app/provision/resources/classes/provision.php +++ b/app/provision/resources/classes/provision.php @@ -519,12 +519,12 @@ include "root.php"; $sql = "select user_uuid from v_extension_users "; $sql .= "where extension_uuid = '$extension_uuid' "; $sql .= "and domain_uuid = '$domain_uuid' "; - //echo $sql."\n"; $prep_statement = $this->db->prepare(check_sql($sql)); $prep_statement->execute(); $extension_users = $prep_statement->fetchAll(PDO::FETCH_NAMED); unset($prep_statement); foreach ($extension_users as &$row) { + //echo "user uuid: ".$row["user_uuid"]."\n"; //get the list of contacts [multiple results] $sql = "select contact_uuid from v_contact_users "; $sql .= "where user_uuid = '".$row["user_uuid"]."' "; @@ -535,7 +535,7 @@ include "root.php"; $extension_users = $prep_statement->fetchAll(PDO::FETCH_NAMED); unset($prep_statement); foreach ($extension_users as &$row) { - $contacts[] = $row["contact_uuid"]; + $contact_uuids[] = $row["contact_uuid"]; } } } @@ -543,23 +543,23 @@ include "root.php"; //get the contacts assigned to the user //SQL 'in' with implode contacts array prevents returning duplicate contacts if (sizeof($contacts) > 0) { - $sql = "select c.contact_organization, c.contact_name_given, c.contact_name_family, "; - $sql .= "p.phone_number, p.phone_extension "; - $sql .= "from v_contacts as c, v_contact_phones as p "; - $sql .= "where c.contact_uuid in ('".implode("','",$contacts)."') "; - $sql .= "and c.contact_uuid = p.contact_uuid "; - $sql .= "and p.phone_type_voice = '1' "; - $sql .= "and c.domain_uuid = '$domain_uuid' "; - //echo $sql."\n"; - $prep_statement = $this->db->prepare(check_sql($sql)); - $prep_statement->execute(); - $directory_personal = $prep_statement->fetchAll(PDO::FETCH_NAMED); - unset($prep_statement); - //print_r($contacts); + //get the contact details + $sql = "select c.contact_organization, c.contact_name_given, c.contact_name_family, "; + $sql .= "p.phone_number, p.phone_extension "; + $sql .= "from v_contacts as c, v_contact_phones as p "; + $sql .= "where c.contact_uuid in ('".implode("','",$contact_uuids)."') "; + $sql .= "and c.contact_uuid = p.contact_uuid "; + $sql .= "and p.phone_type_voice = '1' "; + $sql .= "and c.domain_uuid = '$domain_uuid' "; + //echo $sql."\n"; + $prep_statement = $this->db->prepare(check_sql($sql)); + $prep_statement->execute(); + $user_contacts = $prep_statement->fetchAll(PDO::FETCH_NAMED); + unset($prep_statement); + //assign the contacts array + $view->assign("user_contacts", $user_contacts); } - //assign the contacts array - $view->assign("directory_personal", $contacts); } //get the contact extensions array and add to the template engine