<?php

/**
 * Provides a global endpoint for access to Zend_Cache
 *
 * @package Atmail
 * @subpackage Quota
 * @copyright Copyright (C) 2011 Atmail. All rights reserved.
 * @author Atmail
 */
class Atmail_Quota_Subadmin extends Atmail_Quota
{
	public function _getUsedQuota()
	{
		self::log('subadmin quota');
		$domains = $this->configuration[self::DATA];
		$dbAdapter = Zend_Registry::get('dbAdapter');

		$domainWhere = array();
		foreach($domains as $domain)
		{
			$domainWhere[] = "Account like " . $dbAdapter->quote("%@" . $domain);
		}
		if( count($domainWhere) > 0 )
		{
			$searchWhere = "where " . implode(" OR ", $domainWhere);

		}
		self::log("select sum(UserQuota) from Users $searchWhere");
		$result =  $dbAdapter->fetchOne("select sum(UserQuota) from Users $searchWhere");
		self::log(__METHOD__ . ": Quota = " . $result);
		return $result;
	}

	public function _getTotalQuota()
	{
		throw new Exception(__METHOD__ . ": NOT IMPLEMENTED");
		return false;
	}
}
