Commit a7487103 authored by Jean-Noël Rouchon's avatar Jean-Noël Rouchon

Déplacement des modules dans le dossier /lib

parent c1b6565d
class MailsController < ApplicationController
include Core::Zimbra::Helper
include OpenSSL
before_action :only_logged_users
......@@ -8,9 +7,10 @@ class MailsController < ApplicationController
def index
configmodule = ConfigModule.where(name: "Zimbra").first
if configmodule
domain = Domain.find(current_user.domain_id)
domaininfo = DomainInfo.where(config_module_id: configmodule.id, domain_id: current_user.domain_id).first
if domaininfo && domaininfo.instance_id
@url_embedded = get_login_url
@url_embedded = Core::Zimbra::Helper.get_login_url(domain, current_user)
else
redirect_to "/services", notice: "Le module Zimbra n'est pas disponible pour votre domaine"
end
......
......@@ -141,7 +141,8 @@ class UsersController < ApplicationController
# GET /logout
def logout
@urls = [get_logout_url, Core::Garradin::Helper.get_logout_url(current_user)]
domain = Domain.find(current_user.domain_id)
@urls = [Core::Zimbra::Helper.get_logout_url(domain), Core::Garradin::Helper.get_logout_url(current_user)]
session[:user] = nil
end
......
......@@ -25,7 +25,7 @@ module ZouritAdmin
# Do not swallow errors in after_commit/after_rollback callbacks.
config.active_record.raise_in_transactional_callbacks = true
config.autoload_paths << Rails.root.join('modules')
config.autoload_paths << Rails.root.join('lib').join('modules')
# application's version
VERSION = '0.5.0 beta2'
......
# Chargement de tous les modules Core
Dir.foreach(Rails.root.join("modules/core")) do |folder|
file = File.join(Rails.root.join("modules/core", folder), "helper.rb")
require file if File.exist?(file)
end
#Dir.foreach(Rails.root.join("modules/core")) do |folder|
# file = File.join(Rails.root.join("modules/core", folder), "helper.rb")
# require file if File.exist?(file)
#end
# Chargement de tous les modules Others
Dir.foreach(Rails.root.join("modules/others")) do |folder|
file = File.join(Rails.root.join("modules/others", folder), "helper.rb")
require file if File.exist?(file)
end
\ No newline at end of file
#Dir.foreach(Rails.root.join("modules/others")) do |folder|
# file = File.join(Rails.root.join("modules/others", folder), "helper.rb")
# require file if File.exist?(file)
#end
\ No newline at end of file
......@@ -26,7 +26,8 @@ module Core::Zimbra::Helper
zimbra_cd domain.name
puts "Création de la liste de diffusion tous@#{domain.name}"
zimbra_cdl_tous domain.name
#puts "Préparation de la clé d'authentification de #{domain.name}"
puts "Préparation de la clé d'authentification de #{domain.name}"
puts get_preauthkey domain
#set_preauthkey domain
end
......@@ -135,12 +136,16 @@ module Core::Zimbra::Helper
return zimbra_ssh requete
end
def self.set_preauthkey domain
def self.get_preauthkey domain
requete = "zmprov generateDomainPreAuthKey #{domain.name}"
result, message, output = zimbra_ssh requete
preauthkey = output.to_s.gsub("preAuthKey: ", "")
return preauthkey
end
def self.set_preauthkey domain
domainInfo = get_domaininfo domain
domainInfo.datas = {authkey: preauthkey}
domainInfo.datas = {authkey: get_preauthkey(domain)}
return domainInfo.save
end
......@@ -222,19 +227,19 @@ module Core::Zimbra::Helper
# FIN ALIAS ==========================
# url de logout
def self.get_logout_url
url = get_module_url
def self.get_logout_url domain
url = get_module_url domain
url += "/?loginOp=logout" if url
return url
end
# url de pré-authentification
def self.get_login_url domain=nil
url = get_module_url
key = get_authkey
def self.get_login_url domain, user
url = get_module_url domain
key = get_authkey domain
if key
time = (Time.now.to_f * 1000).to_i
account = current_user.email
account = user.email
preauth = compute_preauth(account, time, key)
url += "/service/preauth?account=#{account}&expires=0&timestamp=#{time}&preauth=#{preauth}"
end
......@@ -251,8 +256,8 @@ module Core::Zimbra::Helper
return hmacd.to_s
end
def self.get_authkey
domainDatas = get_domain_datas
def self.get_authkey domain
domainDatas = get_domain_datas domain
return domainDatas ? domainDatas[:authkey] : nil
end
......@@ -263,24 +268,18 @@ module Core::Zimbra::Helper
return module_id
end
def self.get_module_url
domainInfo = get_domaininfo
def self.get_module_url domain
domainInfo = get_domaininfo domain
instanceDatas = eval(domainInfo.instance.datas)
return instanceDatas ? instanceDatas[:url] : nil
end
def self.get_domain_datas
domainInfo = get_domaininfo
def self.get_domain_datas domain
domainInfo = get_domaininfo domain
data = domainInfo ? eval(domainInfo.data) : nil
return data
end
def self.get_domaininfo
puts "get_domaininfo"
domain_id = current_user.domain_id
domainInfo = DomainInfo.where(domain_id: domain_id, config_module_id: get_module_id).first
end
def self.get_domaininfo domain
puts "get_domaininfo"
domain_id = domain.id
......
......@@ -2,7 +2,7 @@ namespace :modules do
desc "TODO"
task populate: :environment do
directories = ["modules/core", "modules/others"]
directories = ["lib/modules/core", "lib/modules/others"]
directories.each do |dir|
puts "#{dir} integration"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment