<?php

/**
 * @category 	Atmail
 * @package 	Models
 * @subpackage	Carrier Contacts
 * @copyright 	Copyright (c) 2009-2011 ATMAIL. All rights reserved
 * @license 	See http://atmail.com/license.php for license agreement
 * @author		Allan Wrethman allan@staff.atmail.com
 * @author		Atmail (http://atmail.com)
 */
 
require_once('library/Atmail/Abook/Abook/Abook.php');
require_once('application/models/sync.php'); 

class contacts
{
	private $_session;
	private $_account;
	private $_tableNames;
	private $_namespaceName = 'carrier';
	private $_admin = false; //this will allow an admin to modify contacts without needing a valid Account (owner)
	private $_abook;
		
	public function __construct(Array $args)
	{

		if( !isset($args['Account']) )
		{
			throw new Atmail_Exception('Carrier constructor requires Account field in arguments array');
		}
		else
		{
			$this->_account = $args['Account'];               
		}
			
		$email = explode('@', $this->_account);
		
		if(!empty($email['1']))
		{
			$this->_username = $email['0'];
			$this->_domain = $email['1'];		
		}
		else
		{	
			$this->_username = '';		
			$this->_domain = '';	
		}

		$this->view->global = Zend_Registry::get('config')->global;
        	if( isset($args['namespaceName']) )
			$this->_namespaceName = $args['namespaceName'];
		$this->_session = new Zend_Session_Namespace($this->_namespaceName); // session used as seperate persistent store for if caching disabled
		
		$this->dbAdapter = Zend_Registry::get('dbAdapter');
		//$this->dbAdapter->getProfiler()->setEnabled(true); //link to enable debug for performance 
		
		$this->log = Zend_Registry::get('log');
	}
	
}
