Repository navigation
Expand file tree
/
Copy pathclaimDao.class.php
More file actions
95 lines (66 loc) · 1.51 KB
/
Copy pathclaimDao.class.php
File metadata and controls
95 lines (66 loc) · 1.51 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
class VChainClaimDao
{
public static function create($data, $source_id, $ip)
{
unset($data["id"]);
unset($data["_id"]);
$m = new MongoClient();
$db = $m->vchain;
$collection = $db->claims;
$current_time = time();
$data["created"] = $current_time;
$data["status"] = CLAIM_STATUS_UNRESOLVED;
$data["source_id"] = $source_id;
$data["ip"] = $ip;
$collection->insert($data);
$data["id"] = (string) $data["_id"];
unset($data["_id"]);
return $data;
}
public static function setResolved($claim_id, $resolution, $source_id, $ip)
{
$m = new MongoClient();
$db = $m->vchain;
$collection = $db->claims;
$current_time = time();
$collection->update(
array("_id" => new MongoId($claim_id)),
array(
'$set' => array(
"status" => CLAIM_STATUS_RESOLVED
)
)
);
$collection->update(
array("_id" => new MongoId($claim_id)),
array(
'$set' => array(
"resolution" => array(
"type" => $resolution,
"source_id" => $source_id,
"ip" => $ip,
"time" => $current_time
)
)
)
);
return true;
}
public static function getByIdentityId($identity_id)
{
$output = array();
$m = new MongoClient();
$db = $m->vchain;
$collection = $db->claims;
$cursor = $collection->find(array( "affected_identities.identity_id" => $identity_id ));
foreach ($cursor as $document)
{
$document["id"] = (string) $document["_id"];
unset($document["_id"]);
$output[] = $document;
}
return $output;
}
}
?>