google_apps_api 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/google_apps_api.gemspec +1 -1
- data/lib/google_apps_api/calendar.rb +22 -5
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/google_apps_api.gemspec
CHANGED
@@ -13,6 +13,11 @@ module GoogleAppsApi #:nodoc:
|
|
13
13
|
def set_calendar_for_user(calendar, user, *args)
|
14
14
|
options = args.extract_options!
|
15
15
|
|
16
|
+
acl_ranking = ["none", "freebusy", "read", "editor", "owner", "root"]
|
17
|
+
acl_comparison = options.delete(:acl_comparison) || :set
|
18
|
+
|
19
|
+
do_not_subscribe = options.delete(:do_not_subscribe) || false
|
20
|
+
|
16
21
|
existing_acl = "none"
|
17
22
|
need_to_create = false
|
18
23
|
|
@@ -23,13 +28,16 @@ module GoogleAppsApi #:nodoc:
|
|
23
28
|
need_to_create = true
|
24
29
|
end
|
25
30
|
|
31
|
+
existing_acl_rank = acl_ranking.index(existing_acl) || raise("invalid existing acl")
|
32
|
+
|
26
33
|
acl = options.delete(:accesslevel) || existing_acl
|
27
|
-
|
34
|
+
acl_rank = acl_ranking.index(acl) || raise("new acl invalid")
|
35
|
+
|
28
36
|
if need_to_create
|
29
37
|
raise "Must set accesslevel for a newly added calendar" unless acl
|
30
38
|
owner_acl = CalendarAcl.new(:calendar => calendar, :scope => user, :role => "owner")
|
31
39
|
set_calendar_acl(owner_acl)
|
32
|
-
add_calendar_to_user(calendar, user)
|
40
|
+
add_calendar_to_user(calendar, user) unless do_not_subscribe
|
33
41
|
|
34
42
|
end
|
35
43
|
|
@@ -37,10 +45,19 @@ module GoogleAppsApi #:nodoc:
|
|
37
45
|
remove_calendar_from_user(calendar, user) unless existing_acl == "none"
|
38
46
|
else
|
39
47
|
|
40
|
-
|
41
|
-
|
48
|
+
set_acl = case acl_comparison
|
49
|
+
when :set
|
50
|
+
true
|
51
|
+
when :set_if_higher
|
52
|
+
acl_rank > existing_acl_rank
|
53
|
+
when :set_if_lower
|
54
|
+
acl_rank < existing_acl_rank
|
42
55
|
end
|
43
|
-
|
56
|
+
|
57
|
+
|
58
|
+
set_calendar_acl(CalendarAcl.new(:calendar => calendar, :scope => user, :role => acl)) if set_acl
|
59
|
+
|
60
|
+
update_calendar_for_user(calendar, user, options) unless options.empty? unless do_not_subscribe && need_to_create
|
44
61
|
|
45
62
|
end
|
46
63
|
end
|