This repository was archived by the owner on Jun 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathresult.php
116 lines (98 loc) · 2.48 KB
/
result.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
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?php
class Result {
// fields must be public, so they will be json_encoded
public $message;
public $data;// string[][]
public $header;// string[]
public $error;//string
//login
public $id;
public $user;
public $secret;
public $loginStatus;//2 if admin, 1 if user
//get users
public $users = [];
//hub datasets
public $datasets = [];
/*
public $currentPage;//number
public $highestPage;//number
public $table;//string
public $tables;//string[]
public $error;//string
public $info;//Debug
public $type;//string "table" or "view"
*/
function loginResult( $id, $user, $secret, $admin ) {
$this->id = $id;
$this->user = $user;
$this->secret = $secret;
if ( $admin == 1 ) {
$this->loginStatus = 2;
} else {
$this->loginStatus = 1;
}
return $this;
}
public function header( $header ) {
$this->header = $header;
return $this;
}
public function data( $data ) {
$this->data = $data;
return $this;
}
public function addDataset ( $ds ) {
array_push( $this->datasets, $ds );
}
public function addUser ( $user ) {
array_push( $this->users, $user );
}
public function error( $error ) {
$this->error = $error;
return $this;
}
public function message( $msg ) {
$this->message = $msg;
return $this;
}
public function asJson() {
return json_encode( $this );
}
}
class Dataset {
public $name;
public $description;
public $lines;
public $zipSize;
public $uploaded;
public $pub;
public $dsId;
public $file;
public $username;
public $userId;
function __construct( $name, $description, $lines, $zipSize, $uploaded, $pub, $dsId, $file, $username, $userId ) {
$this->name = $name;
$this->description = $description;
$this->lines = $lines;
$this->zipSize = $zipSize;
$this->uploaded = $uploaded;
$this->pub = $pub;
$this->dsId = $dsId;
$this->file = $file;
$this->username = $username;
$this->userId = $userId;
}
}
class HubUser {
public $id;
public $name;
public $email;
public $admin;
public function __construct($id, $user, $email, $isAdmin) {
$this->id = $id;
$this->name = $user;
$this->email = $email;
$this->admin = $isAdmin;
}
}