-
Notifications
You must be signed in to change notification settings - Fork 0
/
Utils.php
55 lines (43 loc) · 999 Bytes
/
Utils.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
function getNewUserID($oldId) {
global $users;
global $conn_old;
$result = findNewID($users,$oldId);
if($result == 0){
$sql = "SELECT gue.email as mail FROM glpi_users gu, glpi_useremails gue where gu.id = gue.users_id
and gu.id = :oldid ";
$stmt = $conn_old->prepare($sql);
$stmt->bindParam(':oldid', $oldId, PDO::PARAM_STR);
$stmt->execute();
$mail = $stmt->fetchColumn();
return findNewIDbyMail($users,$mail);
}else{
return $result;
}
}
function findNewID($arr, $id){
if($id == 0)
return $id;
foreach ($arr as $item) {
if ($item['id'] == $id){
if ( isset($item['new_id']) )
return $item['new_id'];
else
return 0;
}
}
return 0;
}
function findNewIDbyMail($arr, $mail){
foreach ($arr as $item) {
if ($item['mail'] == $mail){
if ( isset($item['new_id']) )
return $item['new_id'];
else{
return 0;
}
}
}
return 0;
}
?>