Repository navigation
Expand file tree
/
Copy pathUser.php
More file actions
104 lines (80 loc) · 2.23 KB
/
Copy pathUser.php
File metadata and controls
104 lines (80 loc) · 2.23 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
96
97
98
99
100
101
102
103
104
<?php
namespace Gitlab\Model;
use Gitlab\Client;
class User extends AbstractModel
{
protected static $_properties = array(
'id',
'email',
'password',
'username',
'name',
'bio',
'skype',
'linkedin',
'twitter',
'dark_scheme',
'theme_id',
'color_scheme_id',
'blocked',
'projects_limit',
'access_level',
'created_at',
'extern_uid',
'provider',
'state',
'is_admin',
'can_create_group',
'can_create_project'
);
public static function fromArray(Client $client, array $data)
{
$id = isset($data['id']) ? $data['id'] : 0;
$user = new User($id, $client);
return $user->hydrate($data);
}
public static function create(Client $client, $email, $password, array $params = array())
{
$data = $client->api('users')->create($email, $password, $params);
return User::fromArray($client, $data);
}
public function __construct($id = null, Client $client = null)
{
$this->setClient($client);
$this->id = $id;
}
public function show()
{
$data = $this->api('users')->show($this->id);
return User::fromArray($this->getClient(), $data);
}
public function keys()
{
$data = $this->api('users')->keys();
$keys = array();
foreach ($data as $key) {
$keys[] = Key::fromArray($this->getClient(), $key);
}
return $keys;
}
public function createKey($title, $key)
{
$data = $this->api('users')->createKey($title, $key);
return Key::fromArray($this->getClient(), $data);
}
public function removeKey($id)
{
$this->api('users')->removeKey($id);
return true;
}
public function addToGroup($group_id, $access_level)
{
$group = new Group($group_id, $this->getClient());
return $group->addMember($this->id, $access_level);
}
public function removeFromGroup($group_id)
{
$group = new Group($group_id, $this->getClient());
return $group->removeMember($this->id);
}
}