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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
class GsNodesController < ApplicationController
load_and_authorize_resource :gs_node, :only => [:index, :show, :new, :create, :edit, :update, :destroy]
before_filter :spread_breadcrumbs
def index
end
def show
end
def new
@gs_node = GsNode.new
@gs_node.push_updates_to = true
@gs_node.accepts_updates_from = true
@gs_node.element_name = 'gs_cluster_sync_log_entry'
end
def create
@gs_node = GsNode.new(params[:gs_node])
if @gs_node.save
redirect_to @gs_node, :notice => t('gs_nodes.controller.successfuly_created')
else
render :new
end
end
def edit
@gs_node = GsNode.find(params[:id])
end
def update
@gs_node = GsNode.find(params[:id])
if @gs_node.update_attributes(params[:gs_node])
redirect_to @gs_node, :notice => t('gs_nodes.controller.successfuly_updated')
else
render :edit
end
end
def destroy
@gs_node = GsNode.find(params[:id])
@gs_node.destroy
redirect_to gs_nodes_url, :notice => t('gs_nodes.controller.successfuly_destroyed')
end
def sync
if !GsNode.where(:ip_address => request.remote_ip).first
render(
:status => 404,
:layout => false,
:content_type => 'text/plain',
:text => "<!-- Node not found -->",
)
return
end
if ! params[:newer].blank?
@newer_as = Time.at(params[:newer].to_i)
else
@newer_as = Time.at(0)
end
if ! params[:class].blank?
@request_class = params[:class].to_s
else
@request_class = '';
end
@node = GsNode.where(:ip_address => GsParameter.get('HOMEBASE_IP_ADDRESS')).first
if @request_class.blank? || @request_class == "tenants"
@tenants = Tenant.where('updated_at > ?', @newer_as)
end
if @request_class.blank? || @request_class == "user_groups"
@user_groups = UserGroup.where('updated_at > ?', @newer_as)
end
if @request_class.blank? || @request_class == "users"
@users = User.where('updated_at > ?', @newer_as)
end
if @request_class.blank? || @request_class == "user_group_memberships"
@user_group_memberships = UserGroupMembership.where('updated_at > ?', @newer_as)
end
if @request_class.blank? || @request_class == "sip_accounts"
@sip_accounts = SipAccount.where('updated_at > ?',@newer_as)
end
if @request_class.blank? || @request_class == "conferences"
@conferences = Conference.where('updated_at > ?', @newer_as)
end
if @request_class.blank? || @request_class == "fax_accounts"
@fax_accounts = FaxAccount.where('updated_at > ?', @newer_as)
end
if @request_class.blank? || @request_class == "phone_books"
@phone_books = PhoneBook.where('updated_at > ?',@newer_as)
end
if @request_class.blank? || @request_class == "phone_book_entries"
@phone_book_entries = PhoneBookEntry.where('updated_at > ?',@newer_as)
end
if @request_class.blank? || @request_class == "phone_numbers"
@phone_numbers = PhoneNumber.where('updated_at > ?', @newer_as)
end
if @request_class.blank? || @request_class == "call_forwards"
@call_forwards = CallForward.where('updated_at > ?', @newer_as)
end
if @request_class.blank? || @request_class == "softkeys"
@softkeys = Softkey.where('updated_at > ?', @newer_as)
end
if @request_class.blank? || @request_class == "ringtones"
@ringtones = Ringtone.where('updated_at > ?', @newer_as)
end
if @request_class.blank? || @request_class == "conference_invitees"
@conference_invitees = ConferenceInvitee.where('updated_at > ?', @newer_as)
end
if @request_class == "fax_documents"
@fax_documents = FaxDocument.where('updated_at > ?', @newer_as)
end
if @request_class == "call_histories"
@call_histories = CallHistory.where('updated_at > ?', @newer_as)
end
if @request_class.blank? || @request_class == "deleted_items"
@deleted_items = Array.new
deleted_items_log = GsClusterSyncLogEntry.where('action = "destroy" AND updated_at > ?', @newer_as)
deleted_items_log.each do |deleted_item_log_entry|
content = JSON(deleted_item_log_entry.content)
content['class_name'] = deleted_item_log_entry.class_name
if content['uuid']
@deleted_items << content
end
end
end
if params[:image].to_s == 'false'
@image_include = false
else
@image_include = true
end
end
private
def spread_breadcrumbs
if @gs_node
add_breadcrumb t("gs_nodes.index.page_title"), gs_nodes_path
if @gs_node && !@gs_node.new_record?
add_breadcrumb @gs_node, gs_node_path(@gs_node)
end
end
end
end
|