Skip to content

Commit

Permalink
Merge pull request #1181 from fatfreecrm/more-hooks
Browse files Browse the repository at this point in the history
Added controller hooks to make it easier to hook plugins into the FFCRM bootup sequence
  • Loading branch information
CloCkWeRX authored Oct 21, 2023
2 parents 982832a + 01abeb9 commit 1823e27
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -268,4 +268,6 @@ def find_class(asset)
raise "Unknown resource"
end
end

ActiveSupport.run_load_hooks(:fat_free_crm_application_controller, self)
end
2 changes: 2 additions & 0 deletions app/controllers/comments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,6 @@ def comment_params
def extract_commentable_name(params)
params.keys.detect { |x| x =~ /_id$/ }.try(:sub, /_id$/, '')
end

ActiveSupport.run_load_hooks(:fat_free_crm_comments_controller, self)
end
2 changes: 2 additions & 0 deletions app/controllers/emails_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ def destroy
@email.destroy
respond_with(@email)
end

ActiveSupport.run_load_hooks(:fat_free_crm_emails_controller, self)
end
2 changes: 2 additions & 0 deletions app/controllers/entities/accounts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,6 @@ def get_data_for_sidebar
@account_category_total[:all] = Account.my(current_user).count
@account_category_total[:other] = @account_category_total[:all] - categorized
end

ActiveSupport.run_load_hooks(:fat_free_crm_accounts_controller, self)
end
2 changes: 2 additions & 0 deletions app/controllers/entities/campaigns_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,6 @@ def get_data_for_sidebar
end
@campaign_status_total[:other] += @campaign_status_total[:all]
end

ActiveSupport.run_load_hooks(:fat_free_crm_campaigns_controller, self)
end
2 changes: 2 additions & 0 deletions app/controllers/entities/contacts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,6 @@ def respond_to_destroy(method)
redirect_to contacts_path
end
end

ActiveSupport.run_load_hooks(:fat_free_crm_contacts_controller, self)
end
2 changes: 2 additions & 0 deletions app/controllers/entities/leads_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -268,4 +268,6 @@ def update_sidebar
get_data_for_sidebar(:campaign)
end
end

ActiveSupport.run_load_hooks(:fat_free_crm_leads_controller, self)
end
2 changes: 2 additions & 0 deletions app/controllers/entities/opportunities_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,6 @@ def set_params
current_user.pref[:opportunities_sort_by] = Opportunity.sort_by_map[params[:sort_by]] if params[:sort_by]
session[:opportunities_filter] = params[:stage] if params[:stage]
end

ActiveSupport.run_load_hooks(:fat_free_crm_opportunities_controller, self)
end
2 changes: 2 additions & 0 deletions app/controllers/entities_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -245,4 +245,6 @@ def guess_related_account(id, url, user)
Account.new(user: user)
end
end

ActiveSupport.run_load_hooks(:fat_free_crm_entities_controller, self)
end
2 changes: 2 additions & 0 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,6 @@ def activity_duration
%w[zero one two].index(words.first).send(words.last) if %w[one two].include?(words.first) && %w[hour day days week weeks month].include?(words.last)
end
end

ActiveSupport.run_load_hooks(:fat_free_crm_home_controller, self)
end
2 changes: 2 additions & 0 deletions app/controllers/lists_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,6 @@ def list_params
:user_id
)
end

ActiveSupport.run_load_hooks(:fat_free_crm_lists_controller, self)
end
2 changes: 2 additions & 0 deletions app/controllers/tasks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -224,4 +224,6 @@ def view
views = Task::ALLOWED_VIEWS
views.include?(view) ? view : views.first
end

ActiveSupport.run_load_hooks(:fat_free_crm_tasks_controller, self)
end
2 changes: 2 additions & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,6 @@ def avatar_params
.permit(:image)
.merge(entity: @user, user_id: @user.id)
end

ActiveSupport.run_load_hooks(:fat_free_crm_users_controller, self)
end

0 comments on commit 1823e27

Please sign in to comment.