Sha256: 712a49585ee0fd9b55497c7b1ca3d9568fa9463f7fafea69b0556a6f60c6102d

Contents?: true

Size: 1.68 KB

Versions: 15

Compression:

Stored size: 1.68 KB

Contents

module Wobauth
  module AdUsersHelper
    def new_from_aduser_link(model, aduser)
      return unless (aduser.present? && model.present?)
      case aduser_class(model, aduser)
      when "table-danger"
        if can? :create, model
	  link_to icon_new, new_polymorphic_path([wobauth, model], aduser_attributes(aduser)),
		class: 'btn btn-danger',
		data: {
		  confirm: "Der Eintrag enthält keine E-Mail-Adresse. Wenn es einen ähnlichen Eintrag mit gepflegter E-Mail-Adresse gibt, ist dies hier womöglich der falsche Eintrag. Wollen Sie dennoch weitermachen? Sie können die Daten im folgenden Formular noch korrigieren."
		}
        end
      when "table-primary"
        if can? :create, model
	  link_to icon_new, new_polymorphic_path([wobauth, model], aduser_attributes(aduser)),
		class: 'btn btn-primary'
        end
      when "table-success"
	show_link([wobauth, model.where(email: aduser.mail).first])
      end
    end

    def aduser_class(model, aduser)
      return unless (aduser.present? && model.present?)
      if aduser.mail.blank?
	"table-danger"
      elsif model.exists?(email: aduser.mail)
	"table-success"
      else
	"table-primary"
      end
    end

  private

    def aduser_attributes(aduser)
      {
	username: aduser.username,
	sn: aduser.sn,
	givenname: aduser.givenname,
	displayname: aduser.displayname,
	cn: aduser.cn,
	dn: aduser.dn,
	email: aduser.mail,
	position: aduser.title,
	telephone: aduser.telephonenumber,
	telefax: aduser.facsimiletelephonenumber,
	mobile: aduser.mobile,
	description: aduser.description,
	department: aduser.department,
	company: aduser.company,
	plz: aduser.postalcode,
	ort: aduser.l,
	streetaddress: aduser.streetaddress,
      }
    end

  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
wobauth-6.0.1 app/helpers/wobauth/ad_users_helper.rb
wobauth-6.0.0 app/helpers/wobauth/ad_users_helper.rb
wobauth-5.1.3 app/helpers/wobauth/ad_users_helper.rb
wobauth-5.1.2 app/helpers/wobauth/ad_users_helper.rb
wobauth-5.1.1 app/helpers/wobauth/ad_users_helper.rb
wobauth-5.1.0 app/helpers/wobauth/ad_users_helper.rb
wobauth-5.0.2 app/helpers/wobauth/ad_users_helper.rb
wobauth-5.0.1 app/helpers/wobauth/ad_users_helper.rb
wobauth-5.0.0 app/helpers/wobauth/ad_users_helper.rb
wobauth-4.0.0 app/helpers/wobauth/ad_users_helper.rb
wobauth-3.4.8 app/helpers/wobauth/ad_users_helper.rb
wobauth-3.4.7 app/helpers/wobauth/ad_users_helper.rb
wobauth-3.4.6 app/helpers/wobauth/ad_users_helper.rb
wobauth-3.4.5 app/helpers/wobauth/ad_users_helper.rb
wobauth-3.4.4 app/helpers/wobauth/ad_users_helper.rb