Sha256: 1bdcab35cd9f402c55f8d2b45415c28654360287dc49a98de152228977d005a4

Contents?: true

Size: 1.43 KB

Versions: 3

Compression:

Stored size: 1.43 KB

Contents

module Ramaze
  module Helper
    ##
    # Helper for the sections package.
    #
    # @since  0.2.8
    #
    module Section
      ##
      # Validates the section ID and returns the section if it's valid.
      #
      # @since  0.2.8
      # @param  [Fixnum] section_id The ID of the section to validate.
      # @return [Sections::Model::Section]
      #
      def validate_section(section_id)
        section = Sections::Model::Section[section_id]

        if section.nil?
          message(:error, lang('sections.errors.invalid_section'))
          redirect(Sections::Controller::Sections.r(:index))
        else
          return section
        end
      end

      ##
      # Validates a section entry and returns it if it's valid.
      #
      #
      # @since  0.2.8
      # @param  [Fixnum] section_entry_id The ID of the section entry to
      #  validate.
      # @param  [Fixnum] section_id The ID of the section to use when
      #  redirecting the user to the overview of all entries.
      # @return [Sections::Model::SectionEntry]
      #
      def validate_section_entry(section_entry_id, section_id)
        entry = Sections::Model::SectionEntry[section_entry_id]

        if entry.nil?
          message(:error, lang('section_entries.errors.invalid_entry'))
          redirect(Sections::Controller::SectionEntries.r(:index, section_id))
        else
          return entry
        end
      end
    end # Section
  end # Helper
end # Ramaze

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
zen-0.3 lib/zen/package/sections/lib/sections/helper/section.rb
zen-0.3b1 lib/zen/package/sections/lib/sections/helper/section.rb
zen-0.3b lib/zen/package/sections/lib/sections/helper/section.rb