diff options
Diffstat (limited to 'lib/model/Domain.php')
-rw-r--r-- | lib/model/Domain.php | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/lib/model/Domain.php b/lib/model/Domain.php new file mode 100644 index 0000000..0d34108 --- /dev/null +++ b/lib/model/Domain.php @@ -0,0 +1,49 @@ +<?php + +/** + * Subclass for representing a row from the 'domain' table. + * + * + * + * @package lib.model + */ +class Domain extends BaseDomain +{ + public function __construct() + { + // set defaults + $this->setMaxMailboxCount(sfConfig::get('app_domain_max_mailbox_count')); + $this->setQuota(sfConfig::get('app_domain_quota')); + $this->setDefaultMailboxQuota(sfConfig::get('app_domain_default_mailbox_quota')); + } + + public function getMailboxCount() + { + return $this->countMailboxs(); + } + + public function getUsedQuota() + { + $used = 0; + + $c = new Criteria(); + $c->add(MailboxPeer::DOMAIN_ID, $this->getId()); + $c->addSelectColumn('SUM('.MailboxPeer::MAX_QUOTA.')'); + $rs = MailboxPeer::doSelectRS($c); + if($rs->next()) + return $rs->getInt(1); + + /* + foreach($this->getMailboxs() as $mbox) + { + $used += $mbox->getQuota(); + } + */ + return $used; + } + + public function __toString() + { + return $this->getName(); + } +} |