Location: PHPKode > scripts > AfterLogic WebMail Lite PHP > afterlogic-webmail-lite-php/webmail/api/webmail/contact_manager.php
<?php

defined('WM_ROOTPATH') || define('WM_ROOTPATH', (dirname(__FILE__).'/../../'));

require_once(WM_ROOTPATH.'core/base/base_exception.php');
require_once(WM_ROOTPATH.'core/base/base_manager.php');

require_once(WM_ROOTPATH.'webmail/containers/contact_container.php');
require_once(WM_ROOTPATH.'webmail/containers/group_container.php');

class ContactManager extends BaseManager
{
	private $_account;
	
	public function __construct()
	{
		$this->_defaultCommandCreatorPath = WM_ROOTPATH.'webmail/command_creators/contact_command_creator.php';
		$this->_defaultCommandeCreatorNames[WM_DB_MYSQL] = 'MySqlContactCommandCreator';
		$this->_defaultCommandeCreatorNames[WM_DB_MSSQLSERVER] = 'MsSqlContactCommandCreator';
		$this->_defaultModelPath = WM_ROOTPATH.'webmail/models/contact_model.php';
		$this->_defaultModelName = 'ContactModel';
	}

	public function InitAccount(&$account)
	{
		$this->_account =& $account;
	}

	/**
	 * @return	array
	 */
	protected function _GetFullContactsList()
	{
		return $this->_currentModel->GetFullContactsList($this->_account->IdUser);
	}

	protected function _ExportVcard($obj)
	{
		return $this->_currentModel->ExportVcard($obj);
	}

	protected function _ImportVcard($filePath)
	{
		$contactContainers = $this->_currentModel->ImportVcard($filePath);
		if (is_array($contactContainers))
		{
			if (count($contactContainers) > 0)
			{
				$existingContactsIds = $this->_currentModel->GetFullContactsIdsList($this->_account->IdUser);
				$existingGroupsIds = $this->_currentModel->GetFullGroupsIdsList($this->_account->IdUser);

				foreach ($contactContainers as $contactContainer)
				{
					$contactId = $contactContainer->GetValue('IdAddress', 'int');
					$groupId = $contactContainer->GetValue('GroupId', 'int');

					if ($contactId > 0 && isset($existingContactsIds[$contactId]))
					{
						unset($existingContactsIds[$contactId]);
					}

					if ($groupId > 0 && isset($existingGroupsIds[$groupId]))
					{
						unset($existingGroupsIds[$groupId]);
					}

					$this->_currentModel->ProcessParsedContact($this->_account->IdUser, $contactContainer);
				}

				$this->_currentModel->RemoveContactsAndGroupsByIds($this->_account->IdUser, $existingContactsIds, $existingGroupsIds);
			}
			else
			{
				$this->_currentModel->RemoveAllContactsAndGroups($this->_account->IdUser);
			}
		}

		return true;
	}
}
Return current item: AfterLogic WebMail Lite PHP