aboutsummaryrefslogtreecommitdiffstats
path: root/documentation/themes/chapter-themes.asciidoc
Commit message (Collapse)AuthorAgeFilesLines
* Add documentation to master branchMarkus Koivisto2016-01-221-0/+37
| | | | Change-Id: I2504bb10f1ae73ec0cbc08b7ba5a88925caa1674
* Revert "Merge branch 'documentation'"7.6.0.beta2Ilia Motornyi2015-12-031-37/+0
| | | | | | This reverts commit f6874bde3d945c8b2d1b5c17ab50e2d0f1f8ff00. Change-Id: I67ee1c30ba3e3bcc3c43a1dd2e73a822791514bf
* Framework documentation INelmot2015-09-251-0/+37
Change-Id: I767477c1fc3745f9e1f58075fe30c9ac8da63581
ghlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
# Redmine - project management software
# Copyright (C) 2006-2015  Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

class EmailAddressesController < ApplicationController
  before_filter :find_user, :require_admin_or_current_user
  before_filter :find_email_address, :only => [:update, :destroy]

  def index
    @addresses = @user.email_addresses.order(:id).where(:is_default => false).to_a
    @address ||= EmailAddress.new
  end

  def create
    saved = false
    if @user.email_addresses.count <= Setting.max_additional_emails.to_i
      @address = EmailAddress.new(:user => @user, :is_default => false)
      attrs = params[:email_address]
      if attrs.is_a?(Hash)
        @address.address = attrs[:address].to_s
      end
      saved = @address.save
    end

    respond_to do |format|
      format.html {
        if saved
          redirect_to user_email_addresses_path(@user)
        else
          index
          render :action => 'index'
        end
      }
      format.js {
        @address = nil if saved
        index
        render :action => 'index'
      }
    end
  end

  def update
    if params[:notify].present?
      @address.notify = params[:notify].to_s
    end
    @address.save

    respond_to do |format|
      format.html {
        redirect_to user_email_addresses_path(@user)
      }
      format.js {
        @address = nil
        index
        render :action => 'index'
      }
    end
  end

  def destroy
    @address.destroy

    respond_to do |format|
      format.html {
        redirect_to user_email_addresses_path(@user)
      }
      format.js {
        @address = nil
        index
        render :action => 'index'
      }
    end
  end

  private

  def find_user
    @user = User.find(params[:user_id])
  end

  def find_email_address
    @address = @user.email_addresses.where(:is_default => false).find(params[:id])
  rescue ActiveRecord::RecordNotFound
    render_404
  end

  def require_admin_or_current_user
    unless @user == User.current
      require_admin
    end
  end
end