Class: Confluence::User
Defined Under Namespace
Classes: NoSuchUser
Instance Attribute Summary
#attributes, #confluence, #encore
Class Method Summary
collapse
Instance Method Summary
collapse
#==, #[], #[]=, #as_boolean, #as_datetime, #as_int, #as_string, confluence, connector, connector=, #destroy, encore, find, #initialize, #load_from_object, #method_missing, #reload, #save
Class Method Details
.find_all ⇒ Object
99
100
101
102
103
|
# File 'lib/confluence/user.rb', line 99
def self.find_all
usernames = find_all_usernames
usernames.collect{|u| find_by_username(u)}
end
|
.find_all_usernames ⇒ Object
105
106
107
|
# File 'lib/confluence/user.rb', line 105
def self.find_all_usernames
confluence.getActiveUsers(true)
end
|
.find_by_email(email) ⇒ Object
89
90
91
92
93
94
95
96
97
|
# File 'lib/confluence/user.rb', line 89
def self.find_by_email(email)
usernames = confluence.getActiveUsers(true)
usernames.each do |username|
user = find_by_username(username)
return user if user.email == email
end
return nil
end
|
.find_by_name(username) ⇒ Object
DEPRECATED: this method is confusing since it could be taken as meaning “find by first/last name”
85
86
87
|
# File 'lib/confluence/user.rb', line 85
def self.find_by_name(username)
find_by_username(username)
end
|
.find_by_username(username) ⇒ Object
class methods #########################################################
80
81
82
|
# File 'lib/confluence/user.rb', line 80
def self.find_by_username(username)
find(username)
end
|
Instance Method Details
#add_profile_picture(filename, mime_type, picture_data) ⇒ Object
66
67
68
|
# File 'lib/confluence/user.rb', line 66
def add_profile_picture(filename, mime_type, picture_data)
confluence.addProfilePicture(self.username, filename, mime_type, picture_data)
end
|
#add_to_group(group) ⇒ Object
44
45
46
47
|
# File 'lib/confluence/user.rb', line 44
def add_to_group(group)
@groups = nil confluence.addUserToGroup(username, group)
end
|
#groups ⇒ Object
31
32
33
34
35
36
37
38
|
# File 'lib/confluence/user.rb', line 31
def groups
@groups ||= confluence.getUserGroups(username)
end
|
#has_permission?(permtype, page) ⇒ Boolean
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/confluence/user.rb', line 54
def has_permission?(permtype, page)
if permtype == :edit
group_or_name = page.edit_group
else
group_or_name = page.view_group
end
return true if group_or_name.nil?
return true if group_or_name == username
return in_group?(group_or_name)
end
|
#id ⇒ Object
15
16
17
|
# File 'lib/confluence/user.rb', line 15
def id
self.username
end
|
#id=(new_id) ⇒ Object
19
20
21
|
# File 'lib/confluence/user.rb', line 19
def id=(new_id)
self.username = new_id
end
|
#in_group?(group) ⇒ Boolean
40
41
42
|
# File 'lib/confluence/user.rb', line 40
def in_group?(group)
groups.include? group
end
|
#remove_from_group(group) ⇒ Object
49
50
51
52
|
# File 'lib/confluence/user.rb', line 49
def remove_from_group(group)
@groups = nil confluence.removeUserFromGroup(username, group)
end
|
#to_s ⇒ Object
70
71
72
|
# File 'lib/confluence/user.rb', line 70
def to_s
self.username
end
|
#to_wiki ⇒ Object
74
75
76
|
# File 'lib/confluence/user.rb', line 74
def to_wiki
"[~#{self.username}]"
end
|
#username ⇒ Object
23
24
25
|
# File 'lib/confluence/user.rb', line 23
def username
self.name
end
|
#username=(new_username) ⇒ Object
27
28
29
|
# File 'lib/confluence/user.rb', line 27
def username=(new_username)
self.username=(new_username)
end
|