<?php
/**
 * Provides a common access point for all Config settings
 * 
 * @category   Atmail
 * @package    Atmail_Config
 * @author     Brad Kowalczyk <brad@staff.atmail.com>
 */
 
class Atmail_Config extends Atmail_Config_Abstract
{	
	
	/**
	 * Publicly accessible method for fetching a config section or setting
	 * 
	 * @param String $keyName The setting's keyName from the Config table
	 * @param String $section The section name from the Config table
	 * @return Array|String
	 */
	public static function get($section="", $keyName="")
	{
		if (empty($section))
		{
			return Zend_Registry::get("config");
		}
				
		switch ($section)
		{
			case Atmail_Enum::CONFIG_SECTION_GLOBAL   : return Atmail_Config_Global::get($keyName);
			case Atmail_Enum::CONFIG_SECTION_EXIM     : return Atmail_Config_Exim::get($keyName);
			case Atmail_Enum::CONFIG_SECTION_REG 	  : return Atmail_Config_Reg::get($keyName);
			case Atmail_Enum::CONFIG_SECTION_DOVECOT  : return Atmail_Config_Dovecot::get($keyName);
			case Atmail_Enum::CONFIG_SECTION_FOLDERS  : return Atmail_Config_Folders::get($keyname);
			case Atmail_Enum::CONFIG_SECTION_DEFAULTS : return Atmail_Config_DefaultUserSettings::get($keyName);
			case Atmail_Enum::CONFIG_SECTION_ADMIN	  : return Atmail_Config_Admin::get($keyName);
		}
		
		throw new Exception("Invalid Config section requested: $section");
	}

	/**
	 * Returns global section or individual global setting
	 * 
	 * If $keyName specified then return individual global setting, if not then return
	 * entire global section as an array
	 * 
	 * @param String $keyName The name of the setting being requested from the global section
	 * @return Array|String
	 */	
	static function getGlobal($keyName="")
	{
		return Atmail_Config_Global::get($keyName);
	}
	
	
	/**
	 * Returns exim section or individual exim setting
	 * 
	 * If $keyName specified then return individual exim setting, if not then return
	 * entire exim section as an array
	 * 
	 * @param String $keyName The name of the setting being requested from the exim section
	 * @return Array|String
	 */
	static function getExim($keyName="")
	{
		Atmail_Config_Exim::get($keyName);
	}
	
	/**
	 * Returns reg section or individual reg setting
	 * 
	 * If $keyName specified then return individual reg setting, if not then return
	 * entire reg section as an array
	 * 
	 * @param String $keyName The name of the setting being requested from the reg section
	 * @return Array|String
	 */
	static function getReg($keyName="")
	{
		return Atmail_Config_Reg::get($keyName);
	}

	/**
	 * Returns dovecot section or individual dovecot setting
	 * 
	 * If $keyName specified then return individual dovecot setting, if not then return
	 * entire dovecot section as an array
	 * 
	 * @param String $keyName The name of the setting being requested from the dovecot section
	 * @return Array|String
	 */	
	static function getDovecot($keyName="")
	{
		return Atmail_Config_Dovecot::get($keyName);
	}
	
	/**
	 * Returns folder section or individual folder name
	 * 
	 * @param String $keyName The name of the folder being requested from the folders section
	 * @return Array|String
	 */
	static function getFolders($keyName="")
	{
		return Atmail_Config_Folders::get($keyName);
	}


	/**
	 * Returns defaultUserSettings section or individual defaultUserSettings setting
	 * 
	 * If $keyName specified then return individual defaultUserSettings setting, if not then return
	 * entire defaultUserSettings section as an array
	 * 
	 * @param String $keyName The name of the setting being requested from the defaultUserSettings section
	 * @return Array|String
	 */
	static function getDefaultUserSettings($keyName="")
	{
		return Atmail_Config_DefaultUserSettings::get($keyName);
	}
	
	
	/**
	 * Returns admin section or individual admin setting
	 * 
	 * If $keyName specified then return individual admin setting, if not then return
	 * entire admin section as an array
	 * 
	 * @param String $keyName The name of the setting being requested from the admin section
	 * @return Array|String
	 */
	static function getAdmin($keyName="")
	{
		return Atmail_Config_Admin::get($keyName);
	}

}
