Sha256: e703160cc59f8ef33c4047a89aabb01327055ba19154a7184a0a5083f1e7caad

Contents?: true

Size: 940 Bytes

Versions: 2

Compression:

Stored size: 940 Bytes

Contents

event :admin_tasks, on: :update, before: :approve do
  if (task = Env.params[:task])
    if Auth.always_ok?
      case task.to_sym
      when :clear_cache          then Card::Cache.reset_all
      when :repair_references    then Card::Reference.repair_all
      when :empty_trash          then Card.empty_trash
      when :clear_view_cache     then Card::ViewCache.reset
      when :delete_old_revisions then Card::Action.delete_old
      when :delete_old_sessions  then Card.delete_old_sessions
      when :repair_permissions   then Card.repair_all_permissions
      end
      Env.params[:success] = Card[:stats].name
      abort :success
    else
      raise Card::PermissionDenied.new(self)
    end
  end
end

module ClassMethods
  def delete_old_sessions
    return unless (months = Env.params[:months].to_i) && months > 0
    ActiveRecord::SessionStore::Session.delete_all(
      ['updated_at < ?', months.months.ago]
    )
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
card-1.17.4 mod/05_standard/set/self/all.rb
card-1.17.3 mod/05_standard/set/self/all.rb