diff --git a/app/extensions/extension_imports.php b/app/extensions/extension_imports.php index a8f878fe37..00c960ebef 100644 --- a/app/extensions/extension_imports.php +++ b/app/extensions/extension_imports.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2018 + Portions created by the Initial Developer are Copyright (C) 2018 the Initial Developer. All Rights Reserved. Contributor(s): @@ -126,10 +126,11 @@ $i++; } } - //echo "
\n";
-			//print_r($schema);
-			//echo "
\n"; - //exit; + + $i++; + $schema[$i]['table'] = 'extension_users'; + $schema[$i]['parent'] = 'extensions'; + $schema[$i]['fields'][] = 'username'; } //match the column names to the field names @@ -244,6 +245,12 @@ //set the domain_uuid $domain_uuid = $_SESSION['domain_uuid']; + //get the users + $sql = "select * from v_users where domain_uuid = '".$domain_uuid."' "; + $prep_statement = $db->prepare($sql); + $prep_statement->execute(); + $users = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + //get the contents of the csv file and convert them into an array $handle = @fopen($_SESSION['file'], "r"); if ($handle) { @@ -283,8 +290,21 @@ $array[$table_name][$row_id][$field_name] = $result[$key]; } else { - $array[$parent][$row_id][$table_name][$y]['domain_uuid'] = $domain_uuid; - $array[$parent][$row_id][$table_name][$y][$field_name] = $result[$key]; + if ($field_name != "username") { + $array[$parent][$row_id][$table_name][$y]['domain_uuid'] = $domain_uuid; + $array[$parent][$row_id][$table_name][$y][$field_name] = $result[$key]; + } + } + + if ($field_name == "username") { + foreach ($users as $field) { + if ($field['username'] == $result[$key]) { + //$array[$parent][$row_id]['extension_users'][$y]['cextension_user_uuid'] = uuid(); + $array[$parent][$row_id]['extension_users'][$y]['domain_uuid'] = $domain_uuid; + //$array[$parent][$row_id]['extension_users'] = $row['extension_uuid']; + $array[$parent][$row_id]['extension_users'][$y]['user_uuid'] = $field['user_uuid']; + } + } } } }