Class: PostfixAdmin::Mailbox
Constant Summary
collapse
- UNLIMITED_QUOTA =
version: 1841 > describe mailbox; ----------------
————–------
—–---------------------
——-+ | Field | Type | Null | Key | Default | Extra | ----------------
————–------
—–---------------------
——-+ | username | varchar(255) | NO | PRI | NULL | | | password | varchar(255) | NO | | NULL | | | name | varchar(255) | NO | | NULL | | | maildir | varchar(255) | NO | | NULL | | | quota | bigint(20) | NO | | 0 | | | local_part | varchar(255) | NO | | NULL | | | domain | varchar(255) | NO | MUL | NULL | | | created | datetime | NO | | 2000-01-01 00:00:00 | | | modified | datetime | NO | | 2000-01-01 00:00:00 | | | active | tinyint(1) | NO | | 1 | | | phone | varchar(30) | NO | | | | | email_other | varchar(255) | NO | | | | | token | varchar(255) | NO | | | | | token_validity | datetime | NO | | 2000-01-01 00:00:00 | | ----------------
————–------
—–---------------------
——-+
0
- DISABLED_QUOTA =
-1
ApplicationRecord::RE_DOMAIN_NAME_LIKE, ApplicationRecord::RE_DOMAIN_NAME_LIKE_BASE, ApplicationRecord::RE_DOMAIN_NAME_LIKE_WITH_ANCHORS, ApplicationRecord::RE_EMAIL_LIKE, ApplicationRecord::RE_EMAIL_LIKE_BASE, ApplicationRecord::RE_EMAIL_LIKE_WITH_ANCHORS
Instance Method Summary
collapse
#scheme_prefix
#active_str, #has_timestamp_columns?, #inactive?, #set_current_time_to_timestamp_columns
Instance Method Details
#quota_display_str(format: "%6.1f") ⇒ Object
139
140
141
|
# File 'lib/postfix_admin/models/mailbox.rb', line 139
def quota_display_str(format: "%6.1f")
"%s / %s" % [quota_usage_str(format: format), quota_mb_str(format: format)]
end
|
#quota_mb ⇒ Object
104
105
106
107
108
|
# File 'lib/postfix_admin/models/mailbox.rb', line 104
def quota_mb
raise Error, "quota is out of range: #{quota}" if quota < 0
quota / KB_TO_MB
end
|
#quota_mb=(value) ⇒ Object
110
111
112
113
114
|
# File 'lib/postfix_admin/models/mailbox.rb', line 110
def quota_mb=(value)
raise Error, "quota is out of range: #{value}" if value < 0
self.quota = value * KB_TO_MB
end
|
#quota_mb_str(format: "%6.1f") ⇒ Object
126
127
128
129
130
131
132
133
134
135
136
137
|
# File 'lib/postfix_admin/models/mailbox.rb', line 126
def quota_mb_str(format: "%6.1f")
case quota
when DISABLED_QUOTA
"Disabled"
when UNLIMITED_QUOTA
"Unlimited"
else
quota_mb = quota / KB_TO_MB.to_f
format % quota_mb
end
end
|
#quota_unlimited? ⇒ Boolean
100
101
102
|
# File 'lib/postfix_admin/models/mailbox.rb', line 100
def quota_unlimited?
quota.zero?
end
|
#quota_usage_str(format: "%6.1f") ⇒ Object
116
117
118
119
120
121
122
123
124
|
# File 'lib/postfix_admin/models/mailbox.rb', line 116
def quota_usage_str(format: "%6.1f")
usage_mb = if quota_usage
usage_mb = quota_usage.bytes / KB_TO_MB.to_f
else
0.0
end
format % usage_mb
end
|