kit_cms 2.3.20 → 2.3.22
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/app/assets/images/kit/toolbar/smile.png +0 -0
 - data/app/assets/images/kit/toolbar/wink.gif +0 -0
 - data/app/assets/images/kit/toolbar/wink.png +0 -0
 - data/app/assets/javascripts/codemirror/editor.js +55 -17
 - data/app/assets/javascripts/codemirror/jquery.js +0 -1
 - data/app/assets/javascripts/codemirror/ruby.js +196 -0
 - data/app/assets/javascripts/jquery.js +3036 -2838
 - data/app/assets/javascripts/kit/utilities.js +655 -586
 - data/app/assets/stylesheets/codemirror/style.css +1 -1
 - data/app/assets/stylesheets/codemirror/theme.css +23 -3
 - data/app/assets/stylesheets/kit/calendar.css +6 -1
 - data/app/assets/stylesheets/kit/cms/cms.css +36 -0
 - data/app/assets/stylesheets/kit/forums.css +5 -1
 - data/app/assets/stylesheets/kit/kit.css +3 -1
 - data/app/controllers/account_controller.rb +306 -0
 - data/app/controllers/ad_controller.rb +2 -0
 - data/app/controllers/admin/ad_units_controller.rb +1 -1
 - data/app/controllers/admin/ad_zones_controller.rb +15 -0
 - data/app/controllers/admin/ads_controller.rb +5 -0
 - data/app/controllers/admin/block_controller.rb +1 -65
 - data/app/controllers/admin/blocks_controller.rb +2 -0
 - data/app/controllers/admin/content_controller.rb +3 -1
 - data/app/controllers/admin/dashboard_controller.rb +28 -4
 - data/app/controllers/admin/dj_controller.rb +45 -0
 - data/app/controllers/admin/help_controller.rb +1 -1
 - data/app/controllers/admin/html_asset_controller.rb +0 -12
 - data/app/controllers/admin/q_controller.rb +120 -0
 - data/app/controllers/admin/user_controller.rb +4 -4
 - data/app/controllers/api_controller.rb +34 -0
 - data/app/controllers/calendar_controller.rb +1 -1
 - data/app/controllers/form_controller.rb +3 -3
 - data/app/controllers/forum_controller.rb +39 -29
 - data/app/controllers/kit_controller.rb +42 -15
 - data/app/controllers/pages_controller.rb +25 -5
 - data/app/controllers/q_controller.rb +235 -0
 - data/app/controllers/repo_controller.rb +7 -0
 - data/app/controllers/user_controller.rb +14 -10
 - data/app/controllers/utility_controller.rb +1 -1
 - data/app/helpers/account_helper.rb +47 -0
 - data/app/helpers/admin/layouts_helper.rb +8 -0
 - data/app/helpers/admin/page_templates_helper.rb +8 -0
 - data/app/helpers/ads_helper.rb +11 -12
 - data/app/helpers/calendar_helper.rb +6 -2
 - data/app/helpers/form_data_helper.rb +1 -1
 - data/app/helpers/form_helper.rb +8 -0
 - data/app/helpers/forum_helper.rb +5 -1
 - data/app/helpers/kit_helper.rb +65 -35
 - data/app/helpers/kit_modules_helper.rb +4 -0
 - data/app/helpers/user_helper.rb +0 -28
 - data/app/jobs/page_link_job.rb +34 -0
 - data/app/jobs/queue_job.rb +134 -0
 - data/app/mailers/notification.rb +10 -0
 - data/app/mailers/queue_mailer.rb +13 -0
 - data/app/models/ad.rb +6 -6
 - data/app/models/ad_unit.rb +1 -1
 - data/app/models/ad_zone.rb +4 -0
 - data/app/models/block.rb +1 -1
 - data/app/models/delayed_job.rb +3 -0
 - data/app/models/form.rb +16 -4
 - data/app/models/html_asset.rb +19 -4
 - data/app/models/html_asset_usage.rb +3 -0
 - data/app/models/html_assetable.rb +4 -0
 - data/app/models/layout.rb +36 -6
 - data/app/models/newsletter.rb +1 -1
 - data/app/models/page.rb +36 -2
 - data/app/models/page_link.rb +5 -0
 - data/app/models/page_template.rb +22 -2
 - data/app/models/preference.rb +1 -1
 - data/app/models/q_event.rb +12 -0
 - data/app/models/q_klass.rb +5 -0
 - data/app/models/q_message.rb +9 -0
 - data/app/models/q_publisher.rb +35 -0
 - data/app/models/q_subscription.rb +7 -0
 - data/app/models/q_user.rb +29 -0
 - data/app/models/q_users_method.rb +6 -0
 - data/app/models/q_users_publisher.rb +6 -0
 - data/app/models/user.rb +127 -19
 - data/app/models/user_login.rb +4 -0
 - data/app/validators/email_validator.rb +14 -0
 - data/app/views/account/_edit.html.haml +40 -0
 - data/app/views/account/_edit_intro.html.haml +3 -0
 - data/app/views/account/_forgotten.html.haml +20 -0
 - data/app/views/account/_forgotten_intro.html.haml +5 -0
 - data/app/views/account/_sign_in.html.haml +31 -0
 - data/app/views/account/_sign_in_intro.html.haml +4 -0
 - data/app/views/account/_sign_up.html.haml +51 -0
 - data/app/views/account/_sign_up_intro.html.haml +4 -0
 - data/app/views/account/edit.html.haml +1 -0
 - data/app/views/account/forgotten.html.haml +1 -0
 - data/app/views/account/sign_in.html.haml +2 -0
 - data/app/views/account/sign_up.html.haml +1 -0
 - data/app/views/ad/_buy.html.haml +2 -1
 - data/app/views/admin/ad_zones/_form.html.haml +1 -1
 - data/app/views/admin/ad_zones/show.html.haml +2 -0
 - data/app/views/admin/blocks/_form.html.haml +11 -1
 - data/app/views/admin/dashboard/broken_links.html.haml +9 -0
 - data/app/views/admin/dashboard/system.html.haml +11 -0
 - data/app/views/admin/dj/index.html.haml +43 -0
 - data/app/views/admin/form/_form.html.haml +15 -10
 - data/app/views/admin/group/index.html.haml +1 -1
 - data/app/views/admin/help/edit.html.haml +1 -1
 - data/app/views/admin/html_asset/show.html.haml +9 -2
 - data/app/views/admin/layouts/show.html.haml +10 -16
 - data/app/views/admin/page_templates/_form.html.haml +9 -17
 - data/app/views/admin/page_templates/show.html.haml +5 -4
 - data/app/views/admin/q/events.html.haml +26 -0
 - data/app/views/admin/q/index.html.haml +28 -0
 - data/app/views/admin/q/klasses.html.haml +61 -0
 - data/app/views/admin/q/messages.html.haml +37 -0
 - data/app/views/admin/q/show.html.haml +98 -0
 - data/app/views/admin/q/subscriptions.html.haml +26 -0
 - data/app/views/admin/q/users.html.haml +27 -0
 - data/app/views/admin/snippet/edit.html.erb +1 -1
 - data/app/views/admin/snippet/new.html.erb +1 -1
 - data/app/views/admin/stylesheet/show.html.haml +1 -1
 - data/app/views/admin/user/index.html.erb +15 -6
 - data/app/views/admin/user/view.html.erb +5 -4
 - data/app/views/admin/views/_form.html.haml +3 -3
 - data/app/views/calendar/_buy_tickets.html.haml +1 -1
 - data/app/views/calendar/_calendar_entry.html.haml +1 -1
 - data/app/views/calendar/_month.html.haml +7 -7
 - data/app/views/form/_show.html.haml +1 -1
 - data/app/views/forum/_add_post.html.haml +7 -8
 - data/app/views/forum/_mod_thread.js.erb +46 -6
 - data/app/views/forum/_post_moderation.html.haml +2 -1
 - data/app/views/forum/_post_preview.html.haml +1 -9
 - data/app/views/forum/_post_scripts.js.erb +29 -5
 - data/app/views/forum/fetch_raw.html.haml +1 -0
 - data/app/views/forum/moderate.html.haml +1 -0
 - data/app/views/forum/topic_index.html.haml +4 -0
 - data/app/views/notification/{event.txt.erb → event.text.erb} +0 -0
 - data/app/views/notification/forgotten_password.text.erb +2 -0
 - data/app/views/pages/content_edit.html.haml +1 -1
 - data/app/views/pages/info.html.erb +13 -2
 - data/app/views/pages/links.html.haml +63 -0
 - data/app/views/user/edit_profile.html.haml +1 -1
 - data/app/views/utility/_cm_editor.html.erb +13 -10
 - data/app/views/utility/_cm_toolbar_markdown.html.haml +8 -1
 - data/app/views/utility/_menu.html.haml +4 -0
 - data/app/views/utility/mercury_html.html.haml +1 -0
 - data/config/initializers/elastic_search.rb +6 -3
 - data/config/initializers/extend_controller.rb +3 -0
 - data/config/initializers/string.rb +9 -6
 - data/config/initializers/warden.rb +49 -0
 - data/config/locales/en.yml +29 -1
 - data/config/routes.rb +35 -2
 - data/lib/kit_cms.rb +7 -2
 - data/lib/tasks/kit.rake +90 -2
 - metadata +139 -27
 - data/app/controllers/user/confirmations_controller.rb +0 -11
 - data/app/controllers/user/passwords_controller.rb +0 -13
 - data/app/controllers/user/registrations_controller.rb +0 -110
 - data/app/controllers/user/sessions_controller.rb +0 -33
 - data/app/controllers/user/unlocks_controller.rb +0 -13
 - data/app/views/devise/_links.erb +0 -25
 - data/app/views/devise/confirmations/new.html.erb +0 -12
 - data/app/views/devise/mailer/confirmation_instructions.html.erb +0 -5
 - data/app/views/devise/mailer/reset_password_instructions.html.erb +0 -8
 - data/app/views/devise/mailer/unlock_instructions.html.erb +0 -7
 - data/app/views/devise/passwords/edit.html.erb +0 -16
 - data/app/views/devise/passwords/new.html.erb +0 -12
 - data/app/views/devise/registrations/edit.html.erb +0 -28
 - data/app/views/devise/registrations/new.html.erb +0 -18
 - data/app/views/devise/sessions/new.html.erb +0 -18
 - data/app/views/devise/shared/_links.erb +0 -25
 - data/app/views/devise/unlocks/new.html.erb +0 -12
 - data/app/views/pages/links.html.erb +0 -8
 - data/app/views/user/shared/_links.erb +0 -25
 - data/config/initializers/devise.rb +0 -196
 - data/config/initializers/devise_extender.rb +0 -39
 
| 
         @@ -0,0 +1,29 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'bcrypt'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'digest/md5'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            class QUser < ActiveRecord::Base
         
     | 
| 
      
 5 
     | 
    
         
            +
              include BCrypt
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
              has_many :q_users_publishers
         
     | 
| 
      
 8 
     | 
    
         
            +
              has_many :q_publishers, :through=>:q_users_publishers
         
     | 
| 
      
 9 
     | 
    
         
            +
              has_many :q_subscriptions, :dependent => :destroy
         
     | 
| 
      
 10 
     | 
    
         
            +
              has_many :q_messages, :dependent=>:destroy
         
     | 
| 
      
 11 
     | 
    
         
            +
              has_many :q_users_methods
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
              def methods
         
     | 
| 
      
 14 
     | 
    
         
            +
                self.q_users_methods.map { |m| m.method }.join ", "
         
     | 
| 
      
 15 
     | 
    
         
            +
              end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              def password
         
     | 
| 
      
 18 
     | 
    
         
            +
                @password ||= Password.new(encrypted_password)
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
              def password=(new_password)
         
     | 
| 
      
 22 
     | 
    
         
            +
                @password = Password.create(new_password)
         
     | 
| 
      
 23 
     | 
    
         
            +
                self.encrypted_password = @password
         
     | 
| 
      
 24 
     | 
    
         
            +
              end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
              def generate_session_token
         
     | 
| 
      
 27 
     | 
    
         
            +
                self.session_token = Digest::MD5.hexdigest(Time.now.to_s + rand(10000000).to_s)
         
     | 
| 
      
 28 
     | 
    
         
            +
              end  
         
     | 
| 
      
 29 
     | 
    
         
            +
            end
         
     | 
    
        data/app/models/user.rb
    CHANGED
    
    | 
         @@ -1,4 +1,10 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            class User < KitIndexed
         
     | 
| 
      
 2 
     | 
    
         
            +
              include BCrypt
         
     | 
| 
      
 3 
     | 
    
         
            +
              include ActionView::Helpers
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
              has_many :user_logins
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
              after_initialize { self.skip_password = true }
         
     | 
| 
       2 
8 
     | 
    
         | 
| 
       3 
9 
     | 
    
         
             
              User.do_indexing :User, [
         
     | 
| 
       4 
10 
     | 
    
         
             
                {:name=>"id", :index=>:not_analyzed, :include_in_all=>false},
         
     | 
| 
         @@ -103,29 +109,30 @@ class User < KitIndexed 
     | 
|
| 
       103 
109 
     | 
    
         
             
                "%d" % r rescue nil
         
     | 
| 
       104 
110 
     | 
    
         
             
              end
         
     | 
| 
       105 
111 
     | 
    
         | 
| 
       106 
     | 
    
         
            -
              def active_for_authentication?
         
     | 
| 
       107 
     | 
    
         
            -
                super && self.banned_at == nil
         
     | 
| 
       108 
     | 
    
         
            -
              end
         
     | 
| 
       109 
     | 
    
         
            -
             
     | 
| 
       110 
     | 
    
         
            -
              devise :database_authenticatable, :registerable,
         
     | 
| 
       111 
     | 
    
         
            -
                     :recoverable, :rememberable, :trackable, :lockable,
         
     | 
| 
       112 
     | 
    
         
            -
                     :maximum_attempts=>10, :unlock_strategy=>:time
         
     | 
| 
       113 
     | 
    
         
            -
             
     | 
| 
       114 
     | 
    
         
            -
              if Rails.configuration.respond_to?(:use_rest_auth) && Rails.configuration.use_rest_auth
         
     | 
| 
       115 
     | 
    
         
            -
                devise :encryptable, :encryptor => :restful_authentication_sha1
         
     | 
| 
       116 
     | 
    
         
            -
              end
         
     | 
| 
       117 
     | 
    
         
            -
             
     | 
| 
       118 
112 
     | 
    
         
             
              after_create :welcome_message
         
     | 
| 
       119 
113 
     | 
    
         | 
| 
       120 
     | 
    
         
            -
              validates :display_name, :uniqueness=>{:scope=>:system_id}, : 
     | 
| 
       121 
     | 
    
         
            -
             
     | 
| 
       122 
     | 
    
         
            -
               
     | 
| 
       123 
     | 
    
         
            -
             
     | 
| 
      
 114 
     | 
    
         
            +
              validates :display_name, :format=>{:with=>/\A[a-z0-9\-\_\ \.]+\z/i, :message=>"Invalid name (may only contain letters, numbers, spaces, hyphens and underscores"}, :presence=>{:message=>"You must enter a name"}, :uniqueness=>{:case_sensitive => false, :message=>"That name has already been used", :scope=>:system_id}, :if => Proc.new { |u| 
         
     | 
| 
      
 115 
     | 
    
         
            +
                Preference.get_cached(u.system_id, "show_forum_nickname_on_signup")=='true' 
         
     | 
| 
      
 116 
     | 
    
         
            +
              }
         
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
      
 118 
     | 
    
         
            +
              validates :email, :presence=>true, :uniqueness=>{:scope=>:system_id, :case_sensitive => false}, :email=>true
         
     | 
| 
      
 119 
     | 
    
         
            +
              attr_accessor :skip_password
         
     | 
| 
       124 
120 
     | 
    
         | 
| 
      
 121 
     | 
    
         
            +
              validates :password, :presence=>true, :confirmation=>true, :length=>{:minimum=>4, :maximum=>40}, :unless=>proc {self.skip_password==true}
         
     | 
| 
      
 122 
     | 
    
         
            +
              validates :password_confirmation, :presence=>true, :unless=>proc {self.skip_password==true}
         
     | 
| 
       125 
123 
     | 
    
         
             
              attr_accessible :email, :password, :password_confirmation, :remember_me, :display_name, :subscribe_newsletter, :spam_points, :system_id
         
     | 
| 
       126 
124 
     | 
    
         | 
| 
       127 
125 
     | 
    
         
             
              attr_accessor :fave_pages
         
     | 
| 
       128 
126 
     | 
    
         | 
| 
      
 127 
     | 
    
         
            +
              def password=(new_password)
         
     | 
| 
      
 128 
     | 
    
         
            +
                @password = new_password
         
     | 
| 
      
 129 
     | 
    
         
            +
                self.encrypted_password = Password.create(new_password)
         
     | 
| 
      
 130 
     | 
    
         
            +
              end
         
     | 
| 
      
 131 
     | 
    
         
            +
             
     | 
| 
      
 132 
     | 
    
         
            +
              def password
         
     | 
| 
      
 133 
     | 
    
         
            +
                @password ||= Password.new(self.encrypted_password)
         
     | 
| 
      
 134 
     | 
    
         
            +
              end
         
     | 
| 
      
 135 
     | 
    
         
            +
             
     | 
| 
       129 
136 
     | 
    
         
             
              def concatenated_groups
         
     | 
| 
       130 
137 
     | 
    
         
             
                self.groups.map {|g| g.name}.join(", ")
         
     | 
| 
       131 
138 
     | 
    
         
             
              end
         
     | 
| 
         @@ -142,11 +149,22 @@ class User < KitIndexed 
     | 
|
| 
       142 
149 
     | 
    
         
             
                User.connection.execute("update users set last_heard_from=now() where id = #{self.id}")
         
     | 
| 
       143 
150 
     | 
    
         
             
              end
         
     | 
| 
       144 
151 
     | 
    
         | 
| 
      
 152 
     | 
    
         
            +
              def unlock_access!
         
     | 
| 
      
 153 
     | 
    
         
            +
                Activity.add(self.system.id, "UnLocking user <a href='/admin/user/#{self.id}'>#{self.email}</a>", 0, "Users")
         
     | 
| 
      
 154 
     | 
    
         
            +
                self.locked_at = nil
         
     | 
| 
      
 155 
     | 
    
         
            +
                self.save
         
     | 
| 
      
 156 
     | 
    
         
            +
              end
         
     | 
| 
      
 157 
     | 
    
         
            +
             
     | 
| 
       145 
158 
     | 
    
         
             
              def lock_access!
         
     | 
| 
       146 
159 
     | 
    
         
             
                Activity.add(self.system.id, "Locking user <a href='/admin/user/#{self.id}'>#{self.email}</a> after #{self.failed_attempts} failed attempts", 0, "Users")
         
     | 
| 
       147 
     | 
    
         
            -
                 
     | 
| 
      
 160 
     | 
    
         
            +
                self.locked_at = Time.now
         
     | 
| 
      
 161 
     | 
    
         
            +
                self.save
         
     | 
| 
       148 
162 
     | 
    
         
             
              end 
         
     | 
| 
       149 
163 
     | 
    
         | 
| 
      
 164 
     | 
    
         
            +
              def locked?
         
     | 
| 
      
 165 
     | 
    
         
            +
                self.locked_at != nil
         
     | 
| 
      
 166 
     | 
    
         
            +
              end
         
     | 
| 
      
 167 
     | 
    
         
            +
             
     | 
| 
       150 
168 
     | 
    
         
             
              def load_favourite_pages
         
     | 
| 
       151 
169 
     | 
    
         
             
                unless self.fave_pages
         
     | 
| 
       152 
170 
     | 
    
         
             
                  self.fave_pages = Hash.new
         
     | 
| 
         @@ -230,7 +248,7 @@ class User < KitIndexed 
     | 
|
| 
       230 
248 
     | 
    
         
             
              end
         
     | 
| 
       231 
249 
     | 
    
         | 
| 
       232 
250 
     | 
    
         
             
              def active?
         
     | 
| 
       233 
     | 
    
         
            -
                 
     | 
| 
      
 251 
     | 
    
         
            +
                self.not_banned?
         
     | 
| 
       234 
252 
     | 
    
         
             
              end
         
     | 
| 
       235 
253 
     | 
    
         | 
| 
       236 
254 
     | 
    
         
             
              def add_role(role, current_user_id = nil)
         
     | 
| 
         @@ -294,5 +312,95 @@ class User < KitIndexed 
     | 
|
| 
       294 
312 
     | 
    
         
             
              def mailchimp_connection
         
     | 
| 
       295 
313 
     | 
    
         
             
                Gibbon.new(Preference.get_cached(self.system_id,'mailchimp_api_key'))
         
     | 
| 
       296 
314 
     | 
    
         
             
              end
         
     | 
| 
       297 
     | 
    
         
            -
             
     | 
| 
      
 315 
     | 
    
         
            +
             
     | 
| 
      
 316 
     | 
    
         
            +
              def self.authenticate(sid, email, password)
         
     | 
| 
      
 317 
     | 
    
         
            +
                logger.debug "Authenticating #{email}"
         
     | 
| 
      
 318 
     | 
    
         
            +
                u = User.sys(sid).where(:email=>email).first
         
     | 
| 
      
 319 
     | 
    
         
            +
             
     | 
| 
      
 320 
     | 
    
         
            +
                unlock_hours = Preference.get_cached(sid, "account_unlock_after_hours")
         
     | 
| 
      
 321 
     | 
    
         
            +
                if unlock_hours.not_blank?
         
     | 
| 
      
 322 
     | 
    
         
            +
                  unlock_hours = unlock_hours.to_i
         
     | 
| 
      
 323 
     | 
    
         
            +
                  if Time.now >= u.locked_at + unlock_hours.hours
         
     | 
| 
      
 324 
     | 
    
         
            +
                    u.unlock_access!
         
     | 
| 
      
 325 
     | 
    
         
            +
                  end
         
     | 
| 
      
 326 
     | 
    
         
            +
                end
         
     | 
| 
      
 327 
     | 
    
         
            +
             
     | 
| 
      
 328 
     | 
    
         
            +
                return nil unless u
         
     | 
| 
      
 329 
     | 
    
         
            +
                return nil unless u.password==password
         
     | 
| 
      
 330 
     | 
    
         
            +
                return nil unless u.not_banned?
         
     | 
| 
      
 331 
     | 
    
         
            +
                return nil if u.locked?
         
     | 
| 
      
 332 
     | 
    
         
            +
                return u
         
     | 
| 
      
 333 
     | 
    
         
            +
              end
         
     | 
| 
      
 334 
     | 
    
         
            +
             
     | 
| 
      
 335 
     | 
    
         
            +
              def self.cookie_authenticate(sid, token)
         
     | 
| 
      
 336 
     | 
    
         
            +
                return nil unless token
         
     | 
| 
      
 337 
     | 
    
         
            +
                User.sys(sid).where(:remember_token=>token).where("remember_token is not null and remember_token <> ''").first
         
     | 
| 
      
 338 
     | 
    
         
            +
              end
         
     | 
| 
      
 339 
     | 
    
         
            +
             
     | 
| 
      
 340 
     | 
    
         
            +
              def self.token_authenticate(sid, token)
         
     | 
| 
      
 341 
     | 
    
         
            +
                if Preference.get_cached(sid, "account_token_auth")=="true" 
         
     | 
| 
      
 342 
     | 
    
         
            +
                  User.sys(sid).where("token is not null and token<>''").where(:token=>token).first rescue nil
         
     | 
| 
      
 343 
     | 
    
         
            +
                else
         
     | 
| 
      
 344 
     | 
    
         
            +
                  nil
         
     | 
| 
      
 345 
     | 
    
         
            +
                end
         
     | 
| 
      
 346 
     | 
    
         
            +
              end
         
     | 
| 
      
 347 
     | 
    
         
            +
             
     | 
| 
      
 348 
     | 
    
         
            +
              def status_display
         
     | 
| 
      
 349 
     | 
    
         
            +
                status = []
         
     | 
| 
      
 350 
     | 
    
         
            +
                roles = self.roles.collect {|r| r.name }.join(',  ')
         
     | 
| 
      
 351 
     | 
    
         
            +
                status << "[#{roles}]" if roles.not_blank?
         
     | 
| 
      
 352 
     | 
    
         
            +
                status << "Banned" if self.banned_at
         
     | 
| 
      
 353 
     | 
    
         
            +
                status << "Locked" if self.locked_at
         
     | 
| 
      
 354 
     | 
    
         
            +
                status << "Failures: #{self.failed_attempts}" if self.failed_attempts>0
         
     | 
| 
      
 355 
     | 
    
         
            +
                status.join(", ")
         
     | 
| 
      
 356 
     | 
    
         
            +
              end
         
     | 
| 
      
 357 
     | 
    
         
            +
             
     | 
| 
      
 358 
     | 
    
         
            +
             
     | 
| 
      
 359 
     | 
    
         
            +
              def dont_remember
         
     | 
| 
      
 360 
     | 
    
         
            +
                self.remember_created_at = nil
         
     | 
| 
      
 361 
     | 
    
         
            +
                self.remember_token = nil
         
     | 
| 
      
 362 
     | 
    
         
            +
                self.save
         
     | 
| 
      
 363 
     | 
    
         
            +
              end
         
     | 
| 
      
 364 
     | 
    
         
            +
             
     | 
| 
      
 365 
     | 
    
         
            +
              def record_signin(sid, request, method = 'e')
         
     | 
| 
      
 366 
     | 
    
         
            +
                lh = UserLogin.new
         
     | 
| 
      
 367 
     | 
    
         
            +
                lh.user_id = self.id
         
     | 
| 
      
 368 
     | 
    
         
            +
                lh.ip = request.remote_ip
         
     | 
| 
      
 369 
     | 
    
         
            +
                lh.method = method
         
     | 
| 
      
 370 
     | 
    
         
            +
                lh.system_id = sid
         
     | 
| 
      
 371 
     | 
    
         
            +
                lh.save
         
     | 
| 
      
 372 
     | 
    
         
            +
                self.sign_in_count = (self.sign_in_count + 1) rescue 1
         
     | 
| 
      
 373 
     | 
    
         
            +
                self.last_sign_in_at = self.current_sign_in_at
         
     | 
| 
      
 374 
     | 
    
         
            +
                self.current_sign_in_at = Time.now
         
     | 
| 
      
 375 
     | 
    
         
            +
                self.last_sign_in_ip = self.current_sign_in_ip
         
     | 
| 
      
 376 
     | 
    
         
            +
                self.current_sign_in_ip = request.remote_ip
         
     | 
| 
      
 377 
     | 
    
         
            +
                self.failed_attempts = 0
         
     | 
| 
      
 378 
     | 
    
         
            +
                self.skip_password = true
         
     | 
| 
      
 379 
     | 
    
         
            +
             
     | 
| 
      
 380 
     | 
    
         
            +
                if method=='c' || request.params[:remember_me]
         
     | 
| 
      
 381 
     | 
    
         
            +
                  self.remember_created_at = Time.now
         
     | 
| 
      
 382 
     | 
    
         
            +
                  self.remember_token ||= Digest::MD5.hexdigest(self.email + Time.now.to_s + rand(100000).to_s) 
         
     | 
| 
      
 383 
     | 
    
         
            +
                else
         
     | 
| 
      
 384 
     | 
    
         
            +
                  self.remember_created_at = nil
         
     | 
| 
      
 385 
     | 
    
         
            +
                  self.remember_token = nil
         
     | 
| 
      
 386 
     | 
    
         
            +
                end
         
     | 
| 
      
 387 
     | 
    
         
            +
                self.save
         
     | 
| 
      
 388 
     | 
    
         
            +
              end
         
     | 
| 
      
 389 
     | 
    
         
            +
             
         
     | 
| 
      
 390 
     | 
    
         
            +
              def self.record_failed_signin(sid, request, method = 'e')
         
     | 
| 
      
 391 
     | 
    
         
            +
                user = nil
         
     | 
| 
      
 392 
     | 
    
         
            +
                email = request.params[:email] || request.params[:user][:email]
         
     | 
| 
      
 393 
     | 
    
         
            +
                if email
         
     | 
| 
      
 394 
     | 
    
         
            +
                  user = User.sys(sid).where(:email=>email).first
         
     | 
| 
      
 395 
     | 
    
         
            +
                  if user
         
     | 
| 
      
 396 
     | 
    
         
            +
                    user.failed_attempts = (self.failed_attempts + 1) rescue 1
         
     | 
| 
      
 397 
     | 
    
         
            +
                    if user.failed_attempts >= (Preference.get_cached(sid, "account_lock_after_failures") || "10").to_i
         
     | 
| 
      
 398 
     | 
    
         
            +
                      user.lock_access!
         
     | 
| 
      
 399 
     | 
    
         
            +
                    end
         
     | 
| 
      
 400 
     | 
    
         
            +
                    user.save
         
     | 
| 
      
 401 
     | 
    
         
            +
                  end
         
     | 
| 
      
 402 
     | 
    
         
            +
                end
         
     | 
| 
      
 403 
     | 
    
         
            +
                return user
         
     | 
| 
      
 404 
     | 
    
         
            +
              end 
         
     | 
| 
      
 405 
     | 
    
         
            +
             
     | 
| 
       298 
406 
     | 
    
         
             
            end
         
     | 
| 
         @@ -0,0 +1,14 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'mail'
         
     | 
| 
      
 2 
     | 
    
         
            +
            class EmailValidator < ActiveModel::EachValidator
         
     | 
| 
      
 3 
     | 
    
         
            +
              def validate_each(record,attribute,value)
         
     | 
| 
      
 4 
     | 
    
         
            +
                begin
         
     | 
| 
      
 5 
     | 
    
         
            +
                  m = Mail::Address.new(value)
         
     | 
| 
      
 6 
     | 
    
         
            +
                  r = m.domain && m.address == value
         
     | 
| 
      
 7 
     | 
    
         
            +
                  t = m.__send__(:tree)
         
     | 
| 
      
 8 
     | 
    
         
            +
                  r &&= (t.domain.dot_atom_text.elements.size > 1)
         
     | 
| 
      
 9 
     | 
    
         
            +
                rescue Exception => e   
         
     | 
| 
      
 10 
     | 
    
         
            +
                  r = false
         
     | 
| 
      
 11 
     | 
    
         
            +
                end
         
     | 
| 
      
 12 
     | 
    
         
            +
                record.errors[attribute] << (options[:message] || "is invalid") unless r
         
     | 
| 
      
 13 
     | 
    
         
            +
              end
         
     | 
| 
      
 14 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,40 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #edit.users
         
     | 
| 
      
 2 
     | 
    
         
            +
              %h2= t "account.edit_user_title"
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
              - unless options[:dont_show_intro]
         
     | 
| 
      
 5 
     | 
    
         
            +
                .intro
         
     | 
| 
      
 6 
     | 
    
         
            +
                  = render :partial=>"edit_intro"
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              
         
     | 
| 
      
 9 
     | 
    
         
            +
              = form_tag "/users/edit" do |f|
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                - if user
         
     | 
| 
      
 12 
     | 
    
         
            +
                  = error_messages_for user
         
     | 
| 
      
 13 
     | 
    
         
            +
                
         
     | 
| 
      
 14 
     | 
    
         
            +
                - if options[:return_to]
         
     | 
| 
      
 15 
     | 
    
         
            +
                  = hidden_field_tag :return_to, options[:return_to]
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                - unless options[:must_change_password]==true || params[:must_change_password]=="1"
         
     | 
| 
      
 18 
     | 
    
         
            +
                  #email
         
     | 
| 
      
 19 
     | 
    
         
            +
                    %label= t "account.email_label"
         
     | 
| 
      
 20 
     | 
    
         
            +
                    = email_field_tag :email, user.email
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                - if options[:must_change_password]==true || params[:must_change_password]=="1"
         
     | 
| 
      
 23 
     | 
    
         
            +
                  = hidden_field_tag :must_change_password, 1
         
     | 
| 
      
 24 
     | 
    
         
            +
              
         
     | 
| 
      
 25 
     | 
    
         
            +
                #password 
         
     | 
| 
      
 26 
     | 
    
         
            +
                  = t "account.only_if_changing_password" unless options[:dont_show_leave_blank_passwords]==true
         
     | 
| 
      
 27 
     | 
    
         
            +
                  %label= t "account.password_label"
         
     | 
| 
      
 28 
     | 
    
         
            +
                  = password_field_tag :password
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                #password_confirmation
         
     | 
| 
      
 31 
     | 
    
         
            +
                  %label= t "account.password_confirmation_label"
         
     | 
| 
      
 32 
     | 
    
         
            +
                  = password_field_tag :password_confirmation
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                #submit
         
     | 
| 
      
 35 
     | 
    
         
            +
                  = submit_tag t("account.edit_user_label")
         
     | 
| 
      
 36 
     | 
    
         
            +
              
         
     | 
| 
      
 37 
     | 
    
         
            +
              - unless options[:dont_show_intro]
         
     | 
| 
      
 38 
     | 
    
         
            +
                .outro
         
     | 
| 
      
 39 
     | 
    
         
            +
                  = render :partial=>"edit_intro"
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,20 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #forgotten.users
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
              %h2= t "account.forgotten_title"
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
              .intro
         
     | 
| 
      
 6 
     | 
    
         
            +
                = render :partial=>"account/forgotten_intro"
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              = form_tag "/users/forgotten" do |f|
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                #email
         
     | 
| 
      
 11 
     | 
    
         
            +
                  %label= t "account.email_label"
         
     | 
| 
      
 12 
     | 
    
         
            +
                  = text_field_tag :email, params[:email]
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
                #submit
         
     | 
| 
      
 15 
     | 
    
         
            +
                  = submit_tag t("account.forgotten_label")
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              .outro
         
     | 
| 
      
 18 
     | 
    
         
            +
                = render :partial=>"account/forgotten_intro"
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,31 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #sign_in.users
         
     | 
| 
      
 2 
     | 
    
         
            +
              %h2= t "account.sign_in_title"
         
     | 
| 
      
 3 
     | 
    
         
            +
              
         
     | 
| 
      
 4 
     | 
    
         
            +
              .intro
         
     | 
| 
      
 5 
     | 
    
         
            +
                = render :partial=>"account/sign_in_intro"
         
     | 
| 
      
 6 
     | 
    
         
            +
              
         
     | 
| 
      
 7 
     | 
    
         
            +
              = form_tag "/users/sign_in" do |f|
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
                - if options[:return_to]
         
     | 
| 
      
 10 
     | 
    
         
            +
                  = hidden_field_tag :return_to, options[:return_to]
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                #email
         
     | 
| 
      
 13 
     | 
    
         
            +
                  %label= t "account.email_label"
         
     | 
| 
      
 14 
     | 
    
         
            +
                  = email_field_tag :email, params[:email]
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                #password
         
     | 
| 
      
 17 
     | 
    
         
            +
                  %label= t "account.password_label"
         
     | 
| 
      
 18 
     | 
    
         
            +
                  = password_field_tag :password
         
     | 
| 
      
 19 
     | 
    
         
            +
                  .forgotten
         
     | 
| 
      
 20 
     | 
    
         
            +
                    = link_to t("account.forgotten_password"), forgotten_url
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                - unless sys_pref('account_no_remember')=='true'
         
     | 
| 
      
 23 
     | 
    
         
            +
                  #remember
         
     | 
| 
      
 24 
     | 
    
         
            +
                    %label= t "account.remember_label"
         
     | 
| 
      
 25 
     | 
    
         
            +
                    = check_box_tag :remember_me, params[:remember_me]
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                #submit
         
     | 
| 
      
 28 
     | 
    
         
            +
                  = submit_tag t("account.sign_in_label")
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
              .outro
         
     | 
| 
      
 31 
     | 
    
         
            +
                = render :partial=>"account/sign_in_intro"
         
     | 
| 
         @@ -0,0 +1,51 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #sign_up.users
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
              %h2= t "account.sign_up_title"
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
              .intro
         
     | 
| 
      
 6 
     | 
    
         
            +
                = render :partial=>"account/sign_up_intro"
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              = form_tag "/users/sign_up" do |f|
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                - if @user
         
     | 
| 
      
 11 
     | 
    
         
            +
                  = error_messages_for @user
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                #email
         
     | 
| 
      
 14 
     | 
    
         
            +
                  %label= t "account.email_label"
         
     | 
| 
      
 15 
     | 
    
         
            +
                  = text_field_tag :email, params[:email]
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                #password
         
     | 
| 
      
 18 
     | 
    
         
            +
                  %label= t "account.password_label"
         
     | 
| 
      
 19 
     | 
    
         
            +
                  = password_field_tag :password
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                #password_confirmation
         
     | 
| 
      
 22 
     | 
    
         
            +
                  %label= t "account.password_confirmation_label"
         
     | 
| 
      
 23 
     | 
    
         
            +
                  = password_field_tag :password_confirmation
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                - if params[:groups]
         
     | 
| 
      
 26 
     | 
    
         
            +
                  = hidden_field_tag :groups, params[:groups]
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                - if sys_pref("show_forum_nickname_on_signup")=='true'
         
     | 
| 
      
 29 
     | 
    
         
            +
                  #forum_nickname
         
     | 
| 
      
 30 
     | 
    
         
            +
                    %label= t "account.forum_nickname"
         
     | 
| 
      
 31 
     | 
    
         
            +
                    = text_field_tag :display_name, params[:display_name]
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                - @attributes = UserAttribute.sys(_sid).where(:show_on_signup=>1).all
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
                - if @attributes && @attributes.size>0
         
     | 
| 
      
 36 
     | 
    
         
            +
                  .attributes
         
     | 
| 
      
 37 
     | 
    
         
            +
                    - @attributes.each do |attr|
         
     | 
| 
      
 38 
     | 
    
         
            +
                      .attribute(class="#{attr.code_name}")
         
     | 
| 
      
 39 
     | 
    
         
            +
                        %label= attr.name
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                        = render :partial=>"form/form_field", :locals=>{:type=>attr.form_field_type, :field=>attr, :value=>params["#{attr.code_name}"], :is_mandatory=>attr.is_mandatory?, :has_error=>@errors && @errors[attr.id], :show_options_editor=>false}
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                        - if attr.description.not_blank?
         
     | 
| 
      
 44 
     | 
    
         
            +
                          .description
         
     | 
| 
      
 45 
     | 
    
         
            +
                            = attr.description
         
     | 
| 
      
 46 
     | 
    
         
            +
                #submit
         
     | 
| 
      
 47 
     | 
    
         
            +
                  = submit_tag t("account.sign_up_label")
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
              .outro
         
     | 
| 
      
 50 
     | 
    
         
            +
                = render :partial=>"account/sign_up_intro"
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            = account_edit_form(@options)
         
     | 
| 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            = account_forgotten
         
     | 
| 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            = account_sign_up_form
         
     | 
    
        data/app/views/ad/_buy.html.haml
    CHANGED
    
    | 
         @@ -5,6 +5,7 @@ 
     | 
|
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
                = hidden_field_tag :options, options.to_json
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
      
 8 
     | 
    
         
            +
                = f.error_messages 
         
     | 
| 
       8 
9 
     | 
    
         
             
                %label(for="name") 
         
     | 
| 
       9 
10 
     | 
    
         
             
                  Name
         
     | 
| 
       10 
11 
     | 
    
         
             
                  = f.text_field :name, :class=>"required"
         
     | 
| 
         @@ -34,7 +35,7 @@ 
     | 
|
| 
       34 
35 
     | 
    
         
             
                  Content
         
     | 
| 
       35 
36 
     | 
    
         
             
                  = f.file_field :creative, :class=>"required"
         
     | 
| 
       36 
37 
     | 
    
         
             
                  .help
         
     | 
| 
       37 
     | 
    
         
            -
                    The content of your ad - a GIF, JPG or PNG file, no larger than 100Kb in size.  It will automatically be resized to fit but for best results you should resize it to  
     | 
| 
      
 38 
     | 
    
         
            +
                    The content of your ad - a GIF, JPG or PNG file, no larger than 100Kb in size.  It will automatically be resized to fit but for best results you should resize it to be the same size as the zone you're creating the ad for.
         
     | 
| 
       38 
39 
     | 
    
         | 
| 
       39 
40 
     | 
    
         
             
                %label(for="link")
         
     | 
| 
       40 
41 
     | 
    
         
             
                  Link
         
     |