ffcrm_cloudfuji 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +2 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +193 -0
- data/MIT-LICENSE +20 -0
- data/README +6 -0
- data/Rakefile +7 -0
- data/config/initializers/cloudfuji.rb +1 -0
- data/config/routes.rb +14 -0
- data/config/settings.yml +128 -0
- data/db/migrate/20120227184555_add_cloudfuji_fields_to_users.rb +6 -0
- data/ffcrm_cloudfuji.gemspec +19 -0
- data/install.rb +1 -0
- data/lib/fat_free_crm/cloudfuji/engine.rb +6 -0
- data/lib/fat_free_crm/cloudfuji/event_observers/app_observer.rb +25 -0
- data/lib/fat_free_crm/cloudfuji/event_observers/customer_observer.rb +54 -0
- data/lib/fat_free_crm/cloudfuji/event_observers/email_observer.rb +124 -0
- data/lib/fat_free_crm/cloudfuji/event_observers/payment_observer.rb +7 -0
- data/lib/fat_free_crm/cloudfuji/event_observers/user_observer.rb +52 -0
- data/lib/fat_free_crm/cloudfuji/version.rb +5 -0
- data/lib/fat_free_crm/cloudfuji.rb +79 -0
- data/lib/ffcrm_cloudfuji.rb +1 -0
- data/uninstall.rb +1 -0
- metadata +115 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
ffcrm_cloudfuji (1.0.0)
|
|
5
|
+
authlogic_cloudfuji (~> 0.9)
|
|
6
|
+
cloudfuji
|
|
7
|
+
fat_free_crm (>= 0.11.2)
|
|
8
|
+
|
|
9
|
+
GEM
|
|
10
|
+
remote: http://rubygems.org/
|
|
11
|
+
specs:
|
|
12
|
+
actionmailer (3.2.3)
|
|
13
|
+
actionpack (= 3.2.3)
|
|
14
|
+
mail (~> 2.4.4)
|
|
15
|
+
actionpack (3.2.3)
|
|
16
|
+
activemodel (= 3.2.3)
|
|
17
|
+
activesupport (= 3.2.3)
|
|
18
|
+
builder (~> 3.0.0)
|
|
19
|
+
erubis (~> 2.7.0)
|
|
20
|
+
journey (~> 1.0.1)
|
|
21
|
+
rack (~> 1.4.0)
|
|
22
|
+
rack-cache (~> 1.2)
|
|
23
|
+
rack-test (~> 0.6.1)
|
|
24
|
+
sprockets (~> 2.1.2)
|
|
25
|
+
activemodel (3.2.3)
|
|
26
|
+
activesupport (= 3.2.3)
|
|
27
|
+
builder (~> 3.0.0)
|
|
28
|
+
activerecord (3.2.3)
|
|
29
|
+
activemodel (= 3.2.3)
|
|
30
|
+
activesupport (= 3.2.3)
|
|
31
|
+
arel (~> 3.0.2)
|
|
32
|
+
tzinfo (~> 0.3.29)
|
|
33
|
+
activeresource (3.2.3)
|
|
34
|
+
activemodel (= 3.2.3)
|
|
35
|
+
activesupport (= 3.2.3)
|
|
36
|
+
activesupport (3.2.3)
|
|
37
|
+
i18n (~> 0.6)
|
|
38
|
+
multi_json (~> 1.0)
|
|
39
|
+
acts-as-taggable-on (2.2.2)
|
|
40
|
+
rails (~> 3.0)
|
|
41
|
+
acts_as_commentable (3.0.1)
|
|
42
|
+
acts_as_list (0.1.6)
|
|
43
|
+
addressable (2.2.8)
|
|
44
|
+
ajax-chosen-rails (0.2.0)
|
|
45
|
+
chosen-rails_ffcrm
|
|
46
|
+
railties (~> 3.0)
|
|
47
|
+
thor (~> 0.14)
|
|
48
|
+
arel (3.0.2)
|
|
49
|
+
authlogic (3.1.0)
|
|
50
|
+
activerecord (>= 3.0.7)
|
|
51
|
+
activerecord (>= 3.0.7)
|
|
52
|
+
authlogic_cloudfuji (0.9.4)
|
|
53
|
+
authlogic
|
|
54
|
+
rubycas-client (= 2.2.1)
|
|
55
|
+
builder (3.0.0)
|
|
56
|
+
cancan (1.6.7)
|
|
57
|
+
chosen-rails_ffcrm (0.9.5)
|
|
58
|
+
railties (~> 3.0)
|
|
59
|
+
thor (~> 0.14)
|
|
60
|
+
chronic (0.6.7)
|
|
61
|
+
cloudfuji (0.0.39)
|
|
62
|
+
highline (>= 1.6.1)
|
|
63
|
+
json (>= 1.4.6)
|
|
64
|
+
orm_adapter (~> 0.0.3)
|
|
65
|
+
rest-client (>= 1.6.1)
|
|
66
|
+
cocaine (0.2.1)
|
|
67
|
+
css_parser (1.2.6)
|
|
68
|
+
addressable
|
|
69
|
+
rdoc
|
|
70
|
+
dynamic_form (1.1.4)
|
|
71
|
+
email_reply_parser_ffcrm (0.5.0)
|
|
72
|
+
erubis (2.7.0)
|
|
73
|
+
fat_free_crm (0.11.3)
|
|
74
|
+
acts-as-taggable-on (~> 2.2.1)
|
|
75
|
+
acts_as_commentable (~> 3.0.1)
|
|
76
|
+
acts_as_list (~> 0.1.4)
|
|
77
|
+
ajax-chosen-rails (>= 0.2.0)
|
|
78
|
+
authlogic (~> 3.1.0)
|
|
79
|
+
cancan
|
|
80
|
+
chosen-rails_ffcrm
|
|
81
|
+
dynamic_form
|
|
82
|
+
email_reply_parser_ffcrm
|
|
83
|
+
ffaker (>= 1.12.0)
|
|
84
|
+
haml (~> 3.1.3)
|
|
85
|
+
jquery-rails
|
|
86
|
+
nokogiri
|
|
87
|
+
paper_trail
|
|
88
|
+
paperclip (~> 2.7.0)
|
|
89
|
+
premailer
|
|
90
|
+
prototype-rails
|
|
91
|
+
rails (~> 3.2.2)
|
|
92
|
+
ransack_ffcrm (~> 0.6.0)
|
|
93
|
+
responds_to_parent_ffcrm
|
|
94
|
+
sass (~> 3.1.10)
|
|
95
|
+
simple_form (~> 2.0.1)
|
|
96
|
+
squeel (~> 0.9.3)
|
|
97
|
+
will_paginate (~> 3.0.2)
|
|
98
|
+
ffaker (1.14.0)
|
|
99
|
+
haml (3.1.5)
|
|
100
|
+
highline (1.6.11)
|
|
101
|
+
hike (1.2.1)
|
|
102
|
+
htmlentities (4.3.1)
|
|
103
|
+
i18n (0.6.0)
|
|
104
|
+
journey (1.0.3)
|
|
105
|
+
jquery-rails (2.0.2)
|
|
106
|
+
railties (>= 3.2.0, < 5.0)
|
|
107
|
+
thor (~> 0.14)
|
|
108
|
+
json (1.7.0)
|
|
109
|
+
mail (2.4.4)
|
|
110
|
+
i18n (>= 0.4.0)
|
|
111
|
+
mime-types (~> 1.16)
|
|
112
|
+
treetop (~> 1.4.8)
|
|
113
|
+
mime-types (1.18)
|
|
114
|
+
multi_json (1.3.4)
|
|
115
|
+
nokogiri (1.5.2)
|
|
116
|
+
orm_adapter (0.0.7)
|
|
117
|
+
paper_trail (2.6.3)
|
|
118
|
+
activerecord (~> 3.0)
|
|
119
|
+
railties (~> 3.0)
|
|
120
|
+
paperclip (2.7.0)
|
|
121
|
+
activerecord (>= 2.3.0)
|
|
122
|
+
activesupport (>= 2.3.2)
|
|
123
|
+
cocaine (>= 0.0.2)
|
|
124
|
+
mime-types
|
|
125
|
+
polyamorous (0.5.0)
|
|
126
|
+
activerecord (~> 3.0)
|
|
127
|
+
polyglot (0.3.3)
|
|
128
|
+
premailer (1.7.3)
|
|
129
|
+
css_parser (>= 1.1.9)
|
|
130
|
+
htmlentities (>= 4.0.0)
|
|
131
|
+
prototype-rails (3.2.1)
|
|
132
|
+
rails (~> 3.2)
|
|
133
|
+
rack (1.4.1)
|
|
134
|
+
rack-cache (1.2)
|
|
135
|
+
rack (>= 0.4)
|
|
136
|
+
rack-ssl (1.3.2)
|
|
137
|
+
rack
|
|
138
|
+
rack-test (0.6.1)
|
|
139
|
+
rack (>= 1.0)
|
|
140
|
+
rails (3.2.3)
|
|
141
|
+
actionmailer (= 3.2.3)
|
|
142
|
+
actionpack (= 3.2.3)
|
|
143
|
+
activerecord (= 3.2.3)
|
|
144
|
+
activeresource (= 3.2.3)
|
|
145
|
+
activesupport (= 3.2.3)
|
|
146
|
+
bundler (~> 1.0)
|
|
147
|
+
railties (= 3.2.3)
|
|
148
|
+
railties (3.2.3)
|
|
149
|
+
actionpack (= 3.2.3)
|
|
150
|
+
activesupport (= 3.2.3)
|
|
151
|
+
rack-ssl (~> 1.3.2)
|
|
152
|
+
rake (>= 0.8.7)
|
|
153
|
+
rdoc (~> 3.4)
|
|
154
|
+
thor (~> 0.14.6)
|
|
155
|
+
rake (0.9.2.2)
|
|
156
|
+
ransack_ffcrm (0.6.0)
|
|
157
|
+
actionpack (~> 3.0)
|
|
158
|
+
activerecord (~> 3.0)
|
|
159
|
+
chronic (~> 0.6.7)
|
|
160
|
+
polyamorous (~> 0.5.0)
|
|
161
|
+
rdoc (3.12)
|
|
162
|
+
json (~> 1.4)
|
|
163
|
+
responds_to_parent_ffcrm (1.1.0)
|
|
164
|
+
rest-client (1.6.7)
|
|
165
|
+
mime-types (>= 1.16)
|
|
166
|
+
rubycas-client (2.2.1)
|
|
167
|
+
activesupport
|
|
168
|
+
sass (3.1.16)
|
|
169
|
+
simple_form (2.0.2)
|
|
170
|
+
actionpack (~> 3.0)
|
|
171
|
+
activemodel (~> 3.0)
|
|
172
|
+
sprockets (2.1.3)
|
|
173
|
+
hike (~> 1.2)
|
|
174
|
+
rack (~> 1.0)
|
|
175
|
+
tilt (~> 1.1, != 1.3.0)
|
|
176
|
+
squeel (0.9.5)
|
|
177
|
+
activerecord (~> 3.0)
|
|
178
|
+
activesupport (~> 3.0)
|
|
179
|
+
polyamorous (~> 0.5.0)
|
|
180
|
+
thor (0.14.6)
|
|
181
|
+
tilt (1.3.3)
|
|
182
|
+
treetop (1.4.10)
|
|
183
|
+
polyglot
|
|
184
|
+
polyglot (>= 0.3.1)
|
|
185
|
+
tzinfo (0.3.33)
|
|
186
|
+
will_paginate (3.0.3)
|
|
187
|
+
|
|
188
|
+
PLATFORMS
|
|
189
|
+
ruby
|
|
190
|
+
|
|
191
|
+
DEPENDENCIES
|
|
192
|
+
fat_free_crm
|
|
193
|
+
ffcrm_cloudfuji!
|
data/MIT-LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2011 [name of plugin creator]
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README
ADDED
data/Rakefile
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
|
2
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
|
3
|
+
|
|
4
|
+
require File.expand_path('../../../../config/application', __FILE__)
|
|
5
|
+
require 'rake'
|
|
6
|
+
|
|
7
|
+
FatFreeCRM::Application.load_tasks
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'fat_free_crm/cloudfuji'
|
data/config/routes.rb
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
begin
|
|
2
|
+
Rails.application.routes.draw do
|
|
3
|
+
cloudfuji_routes
|
|
4
|
+
end
|
|
5
|
+
rescue => e
|
|
6
|
+
puts "Error loading the Cloudfuji routes:"
|
|
7
|
+
puts "#{e.inspect}"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
FatFreeCRM::Application.routes.draw do
|
|
11
|
+
|
|
12
|
+
cloudfuji_authentication_routes if Cloudfuji::Platform.on_cloudfuji?
|
|
13
|
+
|
|
14
|
+
end
|
data/config/settings.yml
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# Fat Free CRM
|
|
2
|
+
# Copyright (C) 2008-2011 by Michael Dvorkin
|
|
3
|
+
#
|
|
4
|
+
# This program is free software: you can redistribute it and/or modify
|
|
5
|
+
# it under the terms of the GNU Affero General Public License as published by
|
|
6
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
7
|
+
# (at your option) any later version.
|
|
8
|
+
#
|
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
# GNU Affero General Public License for more details.
|
|
13
|
+
#
|
|
14
|
+
# You should have received a copy of the GNU Affero General Public License
|
|
15
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
#------------------------------------------------------------------------------
|
|
17
|
+
|
|
18
|
+
#
|
|
19
|
+
# Default application settings to be loaded during installation:
|
|
20
|
+
#
|
|
21
|
+
# rake crm:settings:load
|
|
22
|
+
#
|
|
23
|
+
|
|
24
|
+
# Host
|
|
25
|
+
#------------------------------------------------------------------------------
|
|
26
|
+
# Host for URLS when action mailer generates emails.
|
|
27
|
+
#
|
|
28
|
+
# When sending email, you will need to set the host name so that the mailer can
|
|
29
|
+
# generate urls inside emails that point back to your site. Unlike controllers
|
|
30
|
+
# from Action Pack, the mailer instance doesn’t have any context about the
|
|
31
|
+
# incoming request, so you’ll need to provide all of the details needed to
|
|
32
|
+
# generate a URL.
|
|
33
|
+
#
|
|
34
|
+
# :host: "http://www.example.com"
|
|
35
|
+
#
|
|
36
|
+
:host: http://<%= ENV['CLOUDFUJI_DOMAIN'] %>/
|
|
37
|
+
|
|
38
|
+
# Base URL
|
|
39
|
+
#------------------------------------------------------------------------------
|
|
40
|
+
# Leave base_url blank if Fat Free CRM has been deployed in root URL, otherwise
|
|
41
|
+
# specify subdirectory. For example, when deployed to:
|
|
42
|
+
#
|
|
43
|
+
# http://www.domain.com => :base_url: "" # (leave blank)
|
|
44
|
+
# http://crm.domain.com => :base_url: "" # (leave blank)
|
|
45
|
+
# http://www.domain.com/crm => :base_url: "/crm" # (without trailing slash)
|
|
46
|
+
# http://www.domain.com/a/crm => :base_url: "/a/crm" # (without trailing slash)
|
|
47
|
+
#
|
|
48
|
+
:base_url: ""
|
|
49
|
+
|
|
50
|
+
# Locale
|
|
51
|
+
#------------------------------------------------------------------------------
|
|
52
|
+
# Default locale is American English.
|
|
53
|
+
#
|
|
54
|
+
:locale: "en-US"
|
|
55
|
+
|
|
56
|
+
# By default individual users can't pick their own locale and are presented
|
|
57
|
+
# with the one set above. To enable language selection in User/Profile set
|
|
58
|
+
# the following option to true.
|
|
59
|
+
#
|
|
60
|
+
:per_user_locale: false
|
|
61
|
+
|
|
62
|
+
# User Signup
|
|
63
|
+
#------------------------------------------------------------------------------
|
|
64
|
+
# The following setting controls user signup. Possible values are:
|
|
65
|
+
# :allowed -- users can sign up and use the system once they have registered.
|
|
66
|
+
# :not_allowed -- users can only be added by system administrator. This is the default.
|
|
67
|
+
# :needs_approval -- users can sign up but must be approved before they can use the system.
|
|
68
|
+
#
|
|
69
|
+
:user_signup: :not_allowed
|
|
70
|
+
|
|
71
|
+
# Default records permissions
|
|
72
|
+
#------------------------------------------------------------------------------
|
|
73
|
+
# Set the defaults permission for new records. Possible values are:
|
|
74
|
+
# Private -- private access, only for the creator of the record.
|
|
75
|
+
# Public -- public access, share with everyone. This is the default.
|
|
76
|
+
# Shared -- shared with selected accounts, should be selected by the user.
|
|
77
|
+
#
|
|
78
|
+
:default_access: "Public"
|
|
79
|
+
|
|
80
|
+
# Require last name on Leads and Contacts
|
|
81
|
+
#------------------------------------------------------------------------------
|
|
82
|
+
# If this validation is disabled, records will only require a first name.
|
|
83
|
+
#
|
|
84
|
+
:require_last_names: true
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
# Background information
|
|
88
|
+
#------------------------------------------------------------------------------
|
|
89
|
+
# Specify model names that should have background information displayed. Select any combination
|
|
90
|
+
# from the following list. By default no background information is shown.
|
|
91
|
+
# :background_info:
|
|
92
|
+
# - :account
|
|
93
|
+
# - :campaign
|
|
94
|
+
# - :contact
|
|
95
|
+
# - :lead
|
|
96
|
+
# - :opportunity
|
|
97
|
+
# - :task
|
|
98
|
+
#
|
|
99
|
+
:background_info: []
|
|
100
|
+
|
|
101
|
+
# Address format
|
|
102
|
+
#------------------------------------------------------------------------------
|
|
103
|
+
# Sets the address format for Accounts, Contacts, and Leads.
|
|
104
|
+
# true -- use separate street1, street2, city, state, zipcode, and country field.
|
|
105
|
+
# false -- use single text area field to enter the entire address. This is the default.
|
|
106
|
+
#
|
|
107
|
+
:compound_address: true
|
|
108
|
+
|
|
109
|
+
# Dropdown calendar format
|
|
110
|
+
#------------------------------------------------------------------------------
|
|
111
|
+
# The following setting controls whether to show time in dropdown calendar
|
|
112
|
+
# when scheduling a task for specific date.
|
|
113
|
+
# true -- allow selecting date and time.
|
|
114
|
+
# false -- allow selecting date only. This is the default.
|
|
115
|
+
#
|
|
116
|
+
task_calendar_with_time: false
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
# Beta features
|
|
120
|
+
#------------------------------------------------------------------------------
|
|
121
|
+
# These are features that need to be in the master branch due to extensive codebase changes,
|
|
122
|
+
# but are disabled by default until ready for general use.
|
|
123
|
+
|
|
124
|
+
# - Ransack advanced search
|
|
125
|
+
:advanced_search_enabled: true
|
|
126
|
+
|
|
127
|
+
# - PaperTrail history UI
|
|
128
|
+
:paper_trail_ui_enabled: true
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
|
3
|
+
require 'fat_free_crm/cloudfuji/version'
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |s|
|
|
6
|
+
s.name = 'ffcrm_cloudfuji'
|
|
7
|
+
s.authors = ['Sean Grove', 'Nathan Broadbent']
|
|
8
|
+
s.email = 's@cloudfuji.com'
|
|
9
|
+
s.homepage = 'http://cloudfuji.com'
|
|
10
|
+
s.summary = 'Fat Free CRM - Cloudfuji Integration'
|
|
11
|
+
s.description = 'Integrates Fat Free CRM with the Cloudfuji hosting platform.'
|
|
12
|
+
s.files = `git ls-files`.split("\n")
|
|
13
|
+
s.version = FatFreeCRM::Cloudfuji::VERSION
|
|
14
|
+
|
|
15
|
+
s.add_dependency 'fat_free_crm', '>= 0.11.3'
|
|
16
|
+
s.add_dependency 'cloudfuji'
|
|
17
|
+
s.add_dependency 'authlogic_cloudfuji', '~> 0.9'
|
|
18
|
+
|
|
19
|
+
end
|
data/install.rb
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Install hook code here
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Cloudfuji
|
|
2
|
+
module EventObservers
|
|
3
|
+
class AppObserver < Cloudfuji::EventObserver
|
|
4
|
+
def app_claimed
|
|
5
|
+
puts "Updating #{User.first.inspect} with incoming data #{params.inspect}"
|
|
6
|
+
puts "Authlogic username column: #{::Authlogic::Cas.cas_username_column}="
|
|
7
|
+
puts "Setting username to: #{params.try(:[], 'ido_id')}"
|
|
8
|
+
|
|
9
|
+
user = User.first
|
|
10
|
+
if user
|
|
11
|
+
data = params['data']
|
|
12
|
+
|
|
13
|
+
user.email = data['email']
|
|
14
|
+
user.first_name = user.email.split('@').first
|
|
15
|
+
user.last_name = user.email.split('@').last
|
|
16
|
+
user.username = data['email']
|
|
17
|
+
user.deleted_at = nil
|
|
18
|
+
user.send("#{::Authlogic::Cas.cas_username_column}=".to_sym, params['data'].try(:[], 'ido_id'))
|
|
19
|
+
puts user.inspect
|
|
20
|
+
user.save!
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
module Cloudfuji
|
|
2
|
+
module EventObservers
|
|
3
|
+
class CustomerObserver < Cloudfuji::EventObserver
|
|
4
|
+
# "customer_created"
|
|
5
|
+
# :account_balance => 0
|
|
6
|
+
# :object => "customer"
|
|
7
|
+
# :email => "s+cfdemo@cloudfuji.com"
|
|
8
|
+
# :created => 1332269951
|
|
9
|
+
# :id => "cus_cpkg4h0KfLD3lp"
|
|
10
|
+
# :livemode => true
|
|
11
|
+
# :human => "Customer CREATED (cus_cpkg4h0KfLD3lp), s+cfdemo@cloudfuji.com"}
|
|
12
|
+
def customer_created
|
|
13
|
+
note_customer_activity("#{data['email']} created as a customer with external id #{data['id']}") if data['livemode']
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def customer_signed_up
|
|
17
|
+
note_customer_activity("#{data['first_name']} #{data['last_name']} (#{data['email']}) signed up as a customer")
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def note_customer_activity(message)
|
|
23
|
+
subject = find_or_create_activity_subject!
|
|
24
|
+
puts "Found subject: #{subject.inspect}"
|
|
25
|
+
|
|
26
|
+
subject.versions.create! :event => message
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def data
|
|
30
|
+
params['data']
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def find_or_create_activity_subject!
|
|
34
|
+
lookups = [Account, Lead, Contact]
|
|
35
|
+
lookups.each do |model|
|
|
36
|
+
puts "#{model}.find_by_email( #{data['email']} )"
|
|
37
|
+
result = model.find_by_email(data['email'])
|
|
38
|
+
return result if result
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
lead = Lead.find_by_email(data['email'])
|
|
42
|
+
lead ||= Lead.new
|
|
43
|
+
|
|
44
|
+
lead.email = data['email']
|
|
45
|
+
lead.first_name ||= data['first_name'] || recipient.split("@").first if lead.first_name.blank?
|
|
46
|
+
lead.last_name ||= data['last_name'] || recipient.split("@").last if lead.last_name.blank?
|
|
47
|
+
|
|
48
|
+
lead.save
|
|
49
|
+
|
|
50
|
+
lead
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
module Cloudfuji
|
|
2
|
+
module EventObservers
|
|
3
|
+
class EmailObserver < Cloudfuji::EventObserver
|
|
4
|
+
# NOTE: It'd be nice to have a before_filter.
|
|
5
|
+
|
|
6
|
+
# "email_delivered"
|
|
7
|
+
# :message_headers => "[[\"Received\", \"by luna.mailgun.net with SMTP mgrt 7313261; Tue, 20 Mar 2012 19:00:58 +0000\"], [\"Received\", \"from localhost.localdomain (ec2-23-20-14-40.compute-1.amazonaws.com [23.20.14.40]) by mxa.mailgun.org with ESMTP id 4f68d3e9.4ddcdf0-luna; Tue, 20 Mar 2012 19:00:57 -0000 (UTC)\"], [\"Date\", \"Tue, 20 Mar 2012 19:00:57 +0000\"], [\"From\", \"Sean Grove <sean@cloudfuji.com>\"], [\"Reply-To\", \"Cloudfuji Team <support@cloudfuji.com>\"], [\"Message-Id\", \"<4f68d3e9ad834_3c29377ea432615@ip-10-190-150-17.mail>\"], [\"X-Mailgun-Campaign-Id\", \"cloudfuji_buddies\"], [\"Repy-To\", \"support@cloudfuji.com\"], [\"To\", \"s+cfdemo@cloudfuji.com\"], [\"Subject\", \"Cloudfuji Beta: Thank you for your early support. Here's a gift for you.\"], [\"List-Unsubscribe\", \"<mailto:u+na6wcn3gmqzdszbsmrrdam3ghfstkzrxgbstgn3fgvtdgzjumvrgmyzgmm6tqnlkgetheplteuzeey3gmrsw23zfgqyge5ltnbus4zdpez2d2jjsietgipjrmi4a@email.cloudfuji.com>\"], [\"X-Mailgun-Sid\", \"WyI2NWQ4MSIsICJzK2NmZGVtb0BidXNoaS5kbyIsICIxYjgiXQ==\"], [\"Sender\", \"sean=cloudfuji.com@cloudfuji.com\"]]"
|
|
8
|
+
# :message_id =>"<4f68d3e9ad834_3c29377ea432615@ip-10-190-150-17.mail>"
|
|
9
|
+
# :recipient => "s+cfdemo@cloudfuji.com"
|
|
10
|
+
# :domain => "cloudfuji.com"
|
|
11
|
+
# :custom_variables => nil
|
|
12
|
+
# :human =>"Mail to s+cfdemo@cloudfuji.com successfully delievered."}}
|
|
13
|
+
def email_delivered
|
|
14
|
+
message = ""
|
|
15
|
+
message += "Email delivered to #{recipient}"
|
|
16
|
+
message += " in email campaign '#{campaign.titleize}'" if campaign
|
|
17
|
+
|
|
18
|
+
note_email_activity( message.strip )
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# "email_opened"
|
|
22
|
+
# :recipient=>"s+cfdemo@cloudfuji.com"
|
|
23
|
+
# :domain=>"cloudfuji.com"
|
|
24
|
+
# :campaign_id=>"cloudfuji_buddies"
|
|
25
|
+
# :campaign_name=>"Cloudfuji Buddies"
|
|
26
|
+
# :tag=>nil
|
|
27
|
+
# :mailing_list=>nil
|
|
28
|
+
# :custom_variables=>nil
|
|
29
|
+
def email_opened
|
|
30
|
+
message = ""
|
|
31
|
+
message += "Email opened by #{recipient}"
|
|
32
|
+
message += " in email campaign '#{campaign.titleize}" if campaign
|
|
33
|
+
|
|
34
|
+
note_email_activity( message.strip )
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# :event=>"clicked"
|
|
38
|
+
# :recipient=>"s+cfdemo@cloudfuji.com"
|
|
39
|
+
# :domain=>"cloudfuji.com"
|
|
40
|
+
# :campaign_id=>"cloudfuji_buddies"
|
|
41
|
+
# :campaign_name=>"Cloudfuji Buddies"
|
|
42
|
+
# :tag=>nil
|
|
43
|
+
# :mailing_list=>nil
|
|
44
|
+
# :custom_variables=>nil
|
|
45
|
+
# :url=>"https://cloudfuji.com/cas/invite/?invitation_token=8hswc7kqhPys6FsUJ1Nm&service=https://cloudfuji.com/users/service&redirect=https://cloudfuji.com/apps/new?app=fat_free_crm&src=icon"
|
|
46
|
+
# :human=>"s+cfdemo@cloudfuji.com clicked on link in Cloudfuji Buddies to https://cloudfuji.com/cas/invite/?invitation_token=8hswc7kqhPys6FsUJ1Nm&service=https://cloudfuji.com/users/service&redirect=https://cloudfuji.com/apps/new?app=fat_free_crm&src=icon"}
|
|
47
|
+
def email_clicked
|
|
48
|
+
message = "#{recipient} clicked #{data['url']}"
|
|
49
|
+
message += "in email campaign '#{campaign.titleize}" if campaign
|
|
50
|
+
|
|
51
|
+
note_email_activity(message)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def email_subscribed
|
|
56
|
+
note_email_activity("#{recipient} subscribed to a mailing list")
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
private
|
|
60
|
+
|
|
61
|
+
def note_email_activity(message)
|
|
62
|
+
subject = find_or_create_activity_subject!
|
|
63
|
+
puts "Found subject: #{subject.inspect}"
|
|
64
|
+
|
|
65
|
+
subject.versions.create! :event => message
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def data
|
|
69
|
+
params['data']
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def find_or_create_activity_subject!
|
|
73
|
+
lookups = [Account, Lead, Contact]
|
|
74
|
+
lookups.each do |model|
|
|
75
|
+
puts "#{model}.find_by_email( #{recipient} )"
|
|
76
|
+
result = model.find_by_email(recipient)
|
|
77
|
+
return result if result
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
puts "No pre-existing records found, creating a lead"
|
|
81
|
+
lead = Lead.find_by_email(recipient)
|
|
82
|
+
lead ||= Lead.new
|
|
83
|
+
|
|
84
|
+
lead.email = recipient
|
|
85
|
+
lead.first_name = recipient.split("@").first if lead.first_name.blank?
|
|
86
|
+
lead.last_name = recipient.split("@").last if lead.last_name.blank?
|
|
87
|
+
lead.user = User.first if lead.user_id.nil?
|
|
88
|
+
|
|
89
|
+
puts "About to save:"
|
|
90
|
+
puts lead.inspect
|
|
91
|
+
|
|
92
|
+
lead.save!
|
|
93
|
+
|
|
94
|
+
puts lead.inspect
|
|
95
|
+
|
|
96
|
+
lead
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Temp workarounds until umi delivers events properly
|
|
100
|
+
# Good example of the necessity of deep-schema enforcement for events
|
|
101
|
+
def headers
|
|
102
|
+
begin
|
|
103
|
+
JSON(data['message_headers'])
|
|
104
|
+
rescue => e
|
|
105
|
+
return []
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def recipient
|
|
110
|
+
data['recipient']
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
def custom_variables
|
|
114
|
+
JSON(data['custom_variables'])
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def campaign
|
|
118
|
+
campaign = data['campaign_id'] || data['campaign_name']
|
|
119
|
+
campaign ||= headers.select{|key, value| key == "X-Mailgun-Campaign-Id"}.try(:first).try(:last) unless headers.empty?
|
|
120
|
+
campaign
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
module Cloudfuji
|
|
2
|
+
module EventObservers
|
|
3
|
+
class UserObserver < Cloudfuji::EventObserver
|
|
4
|
+
def user_added
|
|
5
|
+
puts "Adding a new user with incoming data #{params.inspect}"
|
|
6
|
+
puts "Authlogic username column: #{::Authlogic::Cas.cas_username_column}="
|
|
7
|
+
puts "Setting username to: #{params['data'].try(:[], 'ido_id')}"
|
|
8
|
+
|
|
9
|
+
data = params['data']
|
|
10
|
+
|
|
11
|
+
user = User.unscoped.find_or_create_by_ido_id(data['ido_id'])
|
|
12
|
+
|
|
13
|
+
user.email = data['email']
|
|
14
|
+
user.first_name = user.email.split('@').first
|
|
15
|
+
user.last_name = user.email.split('@').last
|
|
16
|
+
user.username = data['email']
|
|
17
|
+
user.deleted_at = nil
|
|
18
|
+
user.send("#{::Authlogic::Cas.cas_username_column}=".to_sym, data.try(:[], 'ido_id'))
|
|
19
|
+
|
|
20
|
+
puts user.inspect
|
|
21
|
+
|
|
22
|
+
user.save!
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def user_removed
|
|
26
|
+
puts "Removing user based on incoming data #{params.inspect}"
|
|
27
|
+
puts "Authlogic username column: #{::Authlogic::Cas.cas_username_column}="
|
|
28
|
+
|
|
29
|
+
user = User.unscoped.find_by_ido_id(params['data']['ido_id'])
|
|
30
|
+
|
|
31
|
+
# TODO: Disable the user instead of destroying them (to prevent data loss)
|
|
32
|
+
user.try(:destroy)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def user_updated
|
|
36
|
+
puts "Updating user based on incoming data #{params.inspect}"
|
|
37
|
+
puts "Authlogic username column: #{::Authlogic::Cas.cas_username_column}="
|
|
38
|
+
|
|
39
|
+
data = params['data']
|
|
40
|
+
user = User.unscoped.find_by_ido_id(data['ido_id'])
|
|
41
|
+
|
|
42
|
+
if user
|
|
43
|
+
# Re-use the CAS login method to set all the extra attributes we
|
|
44
|
+
# care about (first_name, last_name, email, local, timezone,
|
|
45
|
+
# etc.)
|
|
46
|
+
user.cloudfuji_extra_attributes(data)
|
|
47
|
+
user.save
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
module FatFreeCRM
|
|
2
|
+
module Cloudfuji
|
|
3
|
+
class << self
|
|
4
|
+
def enable_cloudfuji!
|
|
5
|
+
load_observers!
|
|
6
|
+
extend_user!
|
|
7
|
+
setup_authentication!
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def extend_user!
|
|
11
|
+
puts "Extending the user model"
|
|
12
|
+
User.instance_eval do
|
|
13
|
+
include ::Cloudfuji::UserHelper
|
|
14
|
+
|
|
15
|
+
validates_presence_of :ido_id
|
|
16
|
+
validates_uniqueness_of :ido_id
|
|
17
|
+
|
|
18
|
+
before_create :make_admin
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
User.class_eval do
|
|
22
|
+
def make_admin
|
|
23
|
+
self.admin = true
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def cloudfuji_extra_attributes(extra_attributes)
|
|
27
|
+
self.first_name = extra_attributes["first_name"]
|
|
28
|
+
self.last_name = extra_attributes["last_name"]
|
|
29
|
+
self.locale = extra_attributes["locale"]
|
|
30
|
+
self.email = extra_attributes["email"]
|
|
31
|
+
self.username ||= extra_attributes["email"].split("@").first
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def load_observers!
|
|
37
|
+
Dir[File.expand_path("../cloudfuji/event_observers/*.rb", __FILE__)].each { |file| require file }
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def setup_authentication!
|
|
41
|
+
Authlogic::Cas.actor_model = User
|
|
42
|
+
Authlogic::Cas.authentication_model = Authentication
|
|
43
|
+
Authlogic::Cas.setup_authentication
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
module ActionDispatch::Routing
|
|
51
|
+
class RouteSet
|
|
52
|
+
Mapper.class_eval do
|
|
53
|
+
def cloudfuji_authentication_routes
|
|
54
|
+
Rails.application.routes.draw do
|
|
55
|
+
scope :module => :authlogic do
|
|
56
|
+
scope :module => :cas do
|
|
57
|
+
match "login" => "cas_authentication#new_cas_session", :as => :login
|
|
58
|
+
match "logout" => "cas_authentication#destroy_cas_session", :as => :logout
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
if Cloudfuji::Platform.on_cloudfuji?
|
|
69
|
+
class CloudfujiRailtie < Rails::Railtie
|
|
70
|
+
# Enabling it via this hook means that it'll be reloaded on each
|
|
71
|
+
# request in development mode, so you can make changes in here and
|
|
72
|
+
# it'll be immeidately reflected
|
|
73
|
+
config.to_prepare do
|
|
74
|
+
puts "Enabling Cloudfuji"
|
|
75
|
+
FatFreeCRM::Cloudfuji.enable_cloudfuji!
|
|
76
|
+
puts "Finished enabling Cloudfuji"
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'fat_free_crm/cloudfuji/engine'
|
data/uninstall.rb
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Uninstall hook code here
|
metadata
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: ffcrm_cloudfuji
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Sean Grove
|
|
9
|
+
- Nathan Broadbent
|
|
10
|
+
autorequire:
|
|
11
|
+
bindir: bin
|
|
12
|
+
cert_chain: []
|
|
13
|
+
date: 2012-05-10 00:00:00.000000000 Z
|
|
14
|
+
dependencies:
|
|
15
|
+
- !ruby/object:Gem::Dependency
|
|
16
|
+
name: fat_free_crm
|
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
|
18
|
+
none: false
|
|
19
|
+
requirements:
|
|
20
|
+
- - ! '>='
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: 0.11.3
|
|
23
|
+
type: :runtime
|
|
24
|
+
prerelease: false
|
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
26
|
+
none: false
|
|
27
|
+
requirements:
|
|
28
|
+
- - ! '>='
|
|
29
|
+
- !ruby/object:Gem::Version
|
|
30
|
+
version: 0.11.3
|
|
31
|
+
- !ruby/object:Gem::Dependency
|
|
32
|
+
name: cloudfuji
|
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
|
34
|
+
none: false
|
|
35
|
+
requirements:
|
|
36
|
+
- - ! '>='
|
|
37
|
+
- !ruby/object:Gem::Version
|
|
38
|
+
version: '0'
|
|
39
|
+
type: :runtime
|
|
40
|
+
prerelease: false
|
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
42
|
+
none: false
|
|
43
|
+
requirements:
|
|
44
|
+
- - ! '>='
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '0'
|
|
47
|
+
- !ruby/object:Gem::Dependency
|
|
48
|
+
name: authlogic_cloudfuji
|
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
|
50
|
+
none: false
|
|
51
|
+
requirements:
|
|
52
|
+
- - ~>
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0.9'
|
|
55
|
+
type: :runtime
|
|
56
|
+
prerelease: false
|
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
58
|
+
none: false
|
|
59
|
+
requirements:
|
|
60
|
+
- - ~>
|
|
61
|
+
- !ruby/object:Gem::Version
|
|
62
|
+
version: '0.9'
|
|
63
|
+
description: Integrates Fat Free CRM with the Cloudfuji hosting platform.
|
|
64
|
+
email: s@cloudfuji.com
|
|
65
|
+
executables: []
|
|
66
|
+
extensions: []
|
|
67
|
+
extra_rdoc_files: []
|
|
68
|
+
files:
|
|
69
|
+
- .gitignore
|
|
70
|
+
- Gemfile
|
|
71
|
+
- Gemfile.lock
|
|
72
|
+
- MIT-LICENSE
|
|
73
|
+
- README
|
|
74
|
+
- Rakefile
|
|
75
|
+
- config/initializers/cloudfuji.rb
|
|
76
|
+
- config/routes.rb
|
|
77
|
+
- config/settings.yml
|
|
78
|
+
- db/migrate/20120227184555_add_cloudfuji_fields_to_users.rb
|
|
79
|
+
- ffcrm_cloudfuji.gemspec
|
|
80
|
+
- install.rb
|
|
81
|
+
- lib/fat_free_crm/cloudfuji.rb
|
|
82
|
+
- lib/fat_free_crm/cloudfuji/engine.rb
|
|
83
|
+
- lib/fat_free_crm/cloudfuji/event_observers/app_observer.rb
|
|
84
|
+
- lib/fat_free_crm/cloudfuji/event_observers/customer_observer.rb
|
|
85
|
+
- lib/fat_free_crm/cloudfuji/event_observers/email_observer.rb
|
|
86
|
+
- lib/fat_free_crm/cloudfuji/event_observers/payment_observer.rb
|
|
87
|
+
- lib/fat_free_crm/cloudfuji/event_observers/user_observer.rb
|
|
88
|
+
- lib/fat_free_crm/cloudfuji/version.rb
|
|
89
|
+
- lib/ffcrm_cloudfuji.rb
|
|
90
|
+
- uninstall.rb
|
|
91
|
+
homepage: http://cloudfuji.com
|
|
92
|
+
licenses: []
|
|
93
|
+
post_install_message:
|
|
94
|
+
rdoc_options: []
|
|
95
|
+
require_paths:
|
|
96
|
+
- lib
|
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
98
|
+
none: false
|
|
99
|
+
requirements:
|
|
100
|
+
- - ! '>='
|
|
101
|
+
- !ruby/object:Gem::Version
|
|
102
|
+
version: '0'
|
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
|
+
none: false
|
|
105
|
+
requirements:
|
|
106
|
+
- - ! '>='
|
|
107
|
+
- !ruby/object:Gem::Version
|
|
108
|
+
version: '0'
|
|
109
|
+
requirements: []
|
|
110
|
+
rubyforge_project:
|
|
111
|
+
rubygems_version: 1.8.24
|
|
112
|
+
signing_key:
|
|
113
|
+
specification_version: 3
|
|
114
|
+
summary: Fat Free CRM - Cloudfuji Integration
|
|
115
|
+
test_files: []
|