Move the contact user data to the correct table.

This commit is contained in:
markjcrane 2016-01-18 17:51:32 -07:00
parent 38af18d127
commit bad658ac68
1 changed files with 192 additions and 158 deletions

View File

@ -2,8 +2,6 @@
if ($domains_processed == 1) {
require_once "resources/classes/schema.php";
//populate new phone_label values, phone_type_* values
$obj = new schema;
$obj->db = $db;
@ -25,12 +23,15 @@ if ($domains_processed == 1) {
$sql .= "or phone_type = 'pcs' ";
$db->exec(check_sql($sql));
unset($sql);
$sql = "update v_contact_phones set phone_type_fax = '1' where phone_type = 'fax'";
$db->exec(check_sql($sql));
unset($sql);
$sql = "update v_contact_phones set phone_type_video = '1' where phone_type = 'video'";
$db->exec(check_sql($sql));
unset($sql);
$sql = "update v_contact_phones set phone_type_text = '1' where phone_type = 'cell' or phone_type = 'pager'";
$db->exec(check_sql($sql));
unset($sql);
@ -180,6 +181,39 @@ if ($domains_processed == 1) {
}
unset($name_tables, $name_fields);
//move the users from the contact groups table into the contact users table
$sql = "select * from v_contact_groups ";
$sql .= "where group_uuid in (select user_uuid from v_users) ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach ($result as &$row) {
$sql = "insert into v_contact_users ";
$sql .= "( ";
$sql .= "contact_user_uuid, ";
$sql .= "domain_uuid, ";
$sql .= "contact_uuid, ";
$sql .= "user_uuid ";
$sql .= ") ";
$sql .= "values ";
$sql .= "( ";
$sql .= "'".uuid()."', ";
$sql .= "'".$row["domain_uuid"]."', ";
$sql .= "'".$row["contact_uuid"]."', ";
$sql .= "'".$row["group_uuid"]."' ";
$sql .= ");";
//echo $sql."\n";
$db->exec($sql);
unset($sql);
$sql = "delete from v_contact_groups ";
$sql .= "where contact_group_uuid = '".$row["contact_group_uuid"]."';";
//echo $sql."\n";
$db->exec($sql);
unset($sql);
}
unset ($prep_statement);
}
?>