summaryrefslogtreecommitdiffstats
path: root/lib/model/Domain.php
blob: 0d34108733362dfa7922f9767909365968778000 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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();
	}
}