lib/postfix_admin/cli.rb in postfix_admin-0.1.2 vs lib/postfix_admin/cli.rb in postfix_admin-0.1.3
- old
+ new
@@ -61,10 +61,11 @@
if domain_name
domain = Domain.find(domain_name)
puts "Mailboxes : %4d / %4s" % [domain.mailboxes.count, max_str(domain.maxmailboxes)]
puts "Aliases : %4d / %4s" % [domain.num_total_aliases, max_str(domain.maxaliases)]
puts "Max Quota : %4d MB" % domain.maxquota
+ puts "Active : %3s" % domain.active_str
else
puts "Domains : %4d" % Domain.all_without_special_domain.count
puts "Admins : %4d" % Admin.count
puts "Mailboxes : %4d" % Mailbox.count
puts "Aliases : %4d" % Domain.num_total_aliases
@@ -99,10 +100,12 @@
admin = Admin.find(name)
report("Admin") do
puts "Name : %s" % admin.username
puts "Password : %s" % admin.password
+ puts "Domains : %s" % (admin.super_admin? ? "ALL" : admin.domains.count)
+ puts "Role : %s" % (admin.super_admin? ? "Super admin" : "Admin")
puts "Active : %s" % admin.active_str
end
end
def show_alias_details(name)
@@ -135,36 +138,36 @@
def add_domain(domain_name)
@base.add_domain(domain_name)
puts_registered(domain_name, "a domain")
end
- def super_admin(user_name, disable)
- admin_check(user_name)
-
- if disable
- Admin.find(user_name).super_admin = false
- puts "Successfully disabled super admin flag of #{user_name}"
- else
- Admin.find(user_name).super_admin = true
- puts "Successfully enabled super admin flag of #{user_name}"
- end
- end
-
def change_admin_password(user_name, password)
change_password(Admin, user_name, password)
end
def change_account_password(user_name, password)
change_password(Mailbox, user_name, password)
end
+ def edit_admin(admin_name, options)
+ admin_check(admin_name)
+ admin = Admin.find(admin_name)
+ admin.super_admin = options[:super] unless options[:super].nil?
+ admin.active = options[:active] unless options[:active].nil?
+ admin.save or raise "Could not save Admin"
+
+ puts "Successfully updated #{admin_name}"
+ show_admin_details(admin_name)
+ end
+
def edit_domain(domain_name, options)
domain_check(domain_name)
domain = Domain.find(domain_name)
domain.maxaliases = options[:aliases] if options[:aliases]
domain.maxmailboxes = options[:mailboxes] if options[:mailboxes]
domain.maxquota = options[:maxquota] if options[:maxquota]
+ domain.active = options[:active] unless options[:active].nil?
domain.save or raise "Could not save Domain"
puts "Successfully updated #{domain_name}"
show_summary(domain_name)
end
@@ -275,9 +278,10 @@
def edit_account(address, options)
mailbox_check(address)
mailbox = Mailbox.find(address)
mailbox.name = options[:name] if options[:name]
mailbox.quota = options[:quota] * KB_TO_MB if options[:quota]
+ mailbox.active = options[:active] unless options[:active].nil?
mailbox.save or raise "Could not save Mailbox"
puts "Successfully updated #{address}"
show_account_details(address)
end