diff --git a/init.rb b/init.rb index 286b73e..215daab 100644 --- a/init.rb +++ b/init.rb @@ -8,61 +8,52 @@ # #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# Dynamically load all Hooks & Patches +ActiveSupport::Reloader.to_prepare do + Dir::foreach(File.join(File.dirname(__FILE__), 'lib')) do |file| + next unless /\.rb$/ =~ file + require_dependency file + end +end + Redmine::Plugin.register :redmine_qbo do - - # View Hook Listeners - require_dependency 'issues_form_hook_listener' - require_dependency 'issues_save_hook_listener' - require_dependency 'issues_show_hook_listener' - require_dependency 'users_show_hook_listener' - require_dependency 'header_footer_hook_listener' - require_dependency 'projects_form_hook_listener' - require_dependency 'view_hook_listener' - - # Patches to the Redmine core. Will not work in development mode - require_dependency 'issue_patch' - require_dependency 'project_patch' - require_dependency 'user_patch' - require_dependency 'query_patch' - require_dependency 'time_entry_query_patch' - require_dependency 'pdf_patch' - require_dependency 'attachments_controller_patch' - - # About - name 'Redmine Quickbooks Online plugin' - author 'Rick Barrette' - description 'This is a plugin for Redmine to intergrate with Quickbooks Online to allow for seamless intergration CRM and invoicing of completed issues' - version '1.1.0' - url 'https://github.com/rickbarrette/redmine_qbo' - author_url 'http://rickbarrette.org' - settings :default => {'empty' => true}, :partial => 'qbo/settings' - # Add safe attributes - Issue.safe_attributes 'customer_id' - Issue.safe_attributes 'qbo_item_id' - Issue.safe_attributes 'qbo_estimate_id' - Issue.safe_attributes 'qbo_invoice_id' - Issue.safe_attributes 'vehicles_id' - User.safe_attributes 'qbo_employee_id' - TimeEntry.safe_attributes 'qbo_billed' - Project.safe_attributes 'customer_id' - Project.safe_attributes 'vehicle_id' - - # We are playing in the sandbox - #Quickbooks.sandbox_mode = true - - # set per_page globally - WillPaginate.per_page = 20 + # About + name 'Redmine Quickbooks Online plugin' + author 'Rick Barrette' + description 'This is a plugin for Redmine to intergrate with Quickbooks Online to allow for seamless intergration CRM and invoicing of completed issues' + version '1.1.0' + url 'https://github.com/rickbarrette/redmine_qbo' + author_url 'http://rickbarrette.org' + settings :default => {'empty' => true}, :partial => 'qbo/settings' + requires_redmine :version_or_higher => '4.0.0' - # Permissions for security - permission :view_customers, :customers => :index, :public => false - permission :add_customers, :customers => :new, :public => false - permission :view_payments, :payments => :index, :public => false - permission :add_payments, :payments => :new, :public => false - permission :view_vehicles, :payments => :new, :public => false - - # Register QBO top menu item - menu :top_menu, :customers, { :controller => :customers, :action => :index }, :caption => 'Customers', :if => Proc.new {User.current.logged?} - menu :top_menu, :vehicles, { :controller => :vehicles, :action => :index }, :caption => 'Vehicles', :if => Proc.new { User.current.logged? } + # Add safe attributes for core models + Issue.safe_attributes 'customer_id' + Issue.safe_attributes 'qbo_item_id' + Issue.safe_attributes 'qbo_estimate_id' + Issue.safe_attributes 'qbo_invoice_id' + Issue.safe_attributes 'vehicles_id' + User.safe_attributes 'qbo_employee_id' + TimeEntry.safe_attributes 'qbo_billed' + Project.safe_attributes 'customer_id' + Project.safe_attributes 'vehicle_id' + + # We are playing in the sandbox + #Quickbooks.sandbox_mode = true + + # set per_page globally + WillPaginate.per_page = 20 + + # Permissions for security + permission :view_customers, :customers => :index, :public => false + permission :add_customers, :customers => :new, :public => false + permission :view_payments, :payments => :index, :public => false + permission :add_payments, :payments => :new, :public => false + permission :view_vehicles, :payments => :new, :public => false + + # Register top menu items + menu :top_menu, :customers, { :controller => :customers, :action => :index }, :caption => 'Customers', :if => Proc.new {User.current.logged?} + menu :top_menu, :vehicles, { :controller => :vehicles, :action => :index }, :caption => 'Vehicles', :if => Proc.new { User.current.logged? } end