Modules/Groupware/Email/Folder/Facade.php

Show: inherited
Table of Contents

\Conjoon_Modules_Groupware_Email_Folder_Facade

Package: Default

This facade eases the access to often neededoperations on local folders/ mailboxes. It provides an interface to automatically establish connections to either the local database or other servers for manipulation folder/ mailbox information.

Author
Thorsten Suckow-Homberg  

Properties

Propertyprivate\Conjoon_BeanContext_Decorator  $_accountDecorator= 'null'

Default valuenullDetails
Type
\Conjoon_BeanContext_Decorator
Propertyprivate\Conjoon_Modules_Groupware_Email_Account_Model_Account  $_accountModel= 'null'

Propertyprivate\Conjoon_BeanContext_Decorator  $_folderDecorator= 'null'

Default valuenullDetails
Type
\Conjoon_BeanContext_Decorator
Propertyprivate\Conjoon_Modules_Groupware_Email_Folder_Model_Folder  $_folderModel= 'null'

Propertyprivate\Conjoon_Modules_Groupware_Email_Folder_FolderRootTypeBuilder  $_folderRootTypeBuilder= 'null'

Propertyprivate\Conjoon_Modules_Groupware_Email_Folder_Model_FoldersAccounts  $_foldersAccountsModel= 'null'

Propertyprivate\Conjoon_Modules_Groupware_Email_Folder_Facade  $_instance= 'null'
static

Default valuenullDetails
Type
\Conjoon_Modules_Groupware_Email_Folder_Facade

Methods

methodprivate__clone( ) : void

Enforce singleton.

methodprivate__construct( ) : void

Enforce singleton.

methodprivate_checkParam( mixed $value, string $type ) : mixed

Function for often needed param checks.

Parameters
Name Type Description
$value mixed
$type string
Returns
Type Description
mixed
Throws
Exception Description
\InvalidArgumentException
methodprivate_extractPathInfo( string $path ) : array

Function extracts information from a given path.

Parameters
Name Type Description
$path string
Returns
Type Description
array An array with the following key value pairs: If the array is empty, no further path information is available. This indicates that a possible operation on all root folders is requested. Otherwise, if existing, the following information will be returned: 'nodeId' => The id of the node, i.e. the last id found in the path 'rootId' => The id of the root node of the path 'path' => The sanitized path, without "/root" and the numeric id of the root folder
Throws
Exception Description
\RuntimeException
methodprivate_getAccountDecorator( ) : \Conjoon_BeanContext_Decorator

Returns
Type Description
\Conjoon_BeanContext_Decorator
methodprivate_getFolderDecorator( ) : \Conjoon_BeanContext_Decorator

Returns
Type Description
\Conjoon_BeanContext_Decorator
methodprivate_sanitizeImapPath( string $path, string $delim, boolean $popHead = false ) : mixed

Sanitizes a path from an IMAP mailboxes and removes/replaces hierarchy delimiter.

Parameters
Name Type Description
$path string
$delim string
$popHead boolean

whether or not to remove the head of the path

Returns
Type Description
mixed The sanitized path or false if the string could not be sanitized
methodprivate_transformImapFolder( \Zend_Mail_Storage_Folder $folder, \Conjoon_Modules_Groupware_Email_Account_Dto $account, \Zend_Mail_Protocol_Imap $protocol, boolean $isRootLevel = false ) : \Conjoon_Modules_Groupware_Email_Folder_Dto

Gathers all needed information to tranform an imap folder to a Conjoon_Modules_Groupware_Email_Folder_Dto obejct.

Parameters
Name Type Description
$folder \Zend_Mail_Storage_Folder
$account \Conjoon_Modules_Groupware_Email_Account_Dto
$protocol \Zend_Mail_Protocol_Imap
$isRootLevel boolean

Whether the folder is on the first level of the mailbox hierarchy

Returns
Type Description
\Conjoon_Modules_Groupware_Email_Folder_Dto
methodpublicaddFolderToPathForUserId( string $name, string $path, integer $userId ) : mixed

Adds a folder with the specified name to the specified path for the specified user.

Parameters
Name Type Description
$name string
$path string

The path to the parent folder of the new folder

$userId integer
Returns
Type Description
mixed Conjoon_Modules_Groupware_Email_Folder_Dto or false
methodpublicaddImapFolderToPath( string $name, string $path, \Conjoon_Modules_Groupware_Email_Account_Dto $account, integer $userId ) : mixed

Creates a new folder/mailbox for the specified account at the specified path.

Parameters
Name Type Description
$name string
$path string
$account \Conjoon_Modules_Groupware_Email_Account_Dto
$userId integer
Returns
Type Description
mixed The path to the newly created folder, or false
methodpublicdeleteLocalFolderForUser( integer $folderId, integer $userId ) : boolean

Deletes the local folder for the user after checking if all of the folders belong to the specify user. Otherwise, no folder will be deleted.

Parameters
Name Type Description
$folderId integer
$userId integer
Returns
Type Description
boolean true if all folders, including subfolders have been deleted, otherwise false
Throws
Exception Description
\Conjoon_Argument_Exception
methodpublicgetAccountsForFolderIdAndUserId( integer $folderId, integer $userId ) : Array

Returns an array of Conjoon_Groupware_Email_Account_Dto which are mapped to the specified folder id.

NOTE: This will not return accounts which are flagged as deleted.

Parameters
Name Type Description
$folderId integer

The id of the folder for which all accounts should be queried.

$userId integer

The id of the user this folder should belong.

Returns
Type Description
Array
methodpublicgetFoldersForPathAndUserId( mixed $path, integer $userId ) : \Conjoon_Modules_Groupware_Email_Folder_Dto

Returns the folder for the user based upon the passed parameter.

This method does automatically determine if the connected account is an IMAP account, and if thatis the case, queries the specified IMAP server for the folders.

Parameters
Name Type Description
$path mixed

The path to the folder that should be opened, delimited by a slash. The last token is the id of the folder that should be expanded, i.e. which child folders should be loaded. The very first token should equal to "root". If the first token equals to "root", all root folders for the user will be loaded.

$userId integer

The id of the user

Returns
Type Description
\Conjoon_Modules_Groupware_Email_Folder_Dto
methodpublicgetImapAccountForFolderIdAndUserId( integer $folderId, integer $userId ) : mixed

Checks whether there is a single imap account mapped to the given folder id. Returns the Conjoon_Modules_Groupware_Email_Account_Dto of the account as found in the database, otherwise null.

Parameters
Name Type Description
$folderId integer
$userId integer
Returns
Type Description
mixed
Throws
Exception Description
\InvalidArgumentException
methodpublicgetImapFoldersForPath( \Conjoon_Groupware_Email_Account_Dto $account, string $path = "" ) : \Conjoon_Modules_Groupware_Email_Folder_Dto

Queries the IMAP server as specified in $account for child folders for the specified path.

Parameters
Name Type Description
$account \Conjoon_Groupware_Email_Account_Dto
$path string
Returns
Type Description
\Conjoon_Modules_Groupware_Email_Folder_Dto
methodpublicgetLocalFolderForIdAndUserId( integer $folderId, integer $userId ) : \Conjoon_Modules_Groupware_Email_Folder_Dto

Returns a Conjoon_Modules_Groupware_Email_Folder_Dto for the given folder and userId. This queries the database and does not consider IMAP accaounts!

Parameters
Name Type Description
$folderId integer
$userId integer
Returns
Type Description
\Conjoon_Modules_Groupware_Email_Folder_Dto or null
Throws
Exception Description
\InvalidArgumentException
methodpublicisPopAccountMappedToFolderIdForUserId( integer $folderId, integer $userId ) : boolean

Checks whether one or more POP accounts are mapped to this folder.

Note: This might not return the expected results if one or more accounts related to the folder are flagged as deleted. See isRemoteFolder instead.

Parameters
Name Type Description
$folderId integer
$userId integer
Returns
Type Description
boolean true if there is one ore more pop accounts mapped to this id, otherwise false
Throws
Exception Description
\InvalidArgumentException
methodpublicisRemoteFolder( integer $folderId ) : boolean

Returns true if the folder represents a remote folder, i.e. if the folder is not part of a accounts_root or root hierarchy, otherwise true.

Parameters
Name Type Description
$folderId integer
Returns
Type Description
boolean
Throws
Exception Description
\Conjoon_Argument_Exception, RuntimeException
methodpublicmoveFolderFromPathToPathForUserId( string $path, string $parentPath, integer $userId ) : \Conjoon_Modules_Groupware_Email_Folder_Dto

Moves the folder found under the specified path as a new child to the new path for the specified user.

This method does autmatically determine whether the path belongs to an IMAP or POP account.

Parameters
Name Type Description
$path string
$parentPath string
$userId integer
Returns
Type Description
\Conjoon_Modules_Groupware_Email_Folder_Dto
Throws
Exception Description
\InvalidArgumentException
methodpublicmoveImapFolderFromPathToPath( string $path, string $parentPath,  $account, integer $userId ) : mixed

Moves the IMAP folder specified in $path as a new child to the path found in $parentPath.

Parameters
Name Type Description
$path string
$parentPath string
$account
$userId integer
Returns
Type Description
mixed the new path for the moved folder, or false on failure
Details
Praram
Conjoon_Modules_Groupware_Email_Account_Dto $account  
methodpublicrenameFolderForPathAndUserId( string $name, string $path, integer $userId ) : mixed

Renames the folder found under the specified path.

This method does automatically determine whether the related account is an IMAP account and invokes server communications accordingly.

Parameters
Name Type Description
$name string

The new name for the folder

$path string

The path to the folder that should get renamed.

$userId integer

The id of the user the renamed folder should belong to

Returns
Type Description
mixed A Conjoon_Modules_Groupware_Email_Account_Dto with the data for the renamed folder, or false if the operation did not succeed
Throws
Exception Description
\Exception
methodpublicrenameImapFolderForPath( string $name, string $path, \Conjoon_Modules_Groupware_Email_Account_Dto $account, integer $userId ) : \the

Queries the IMAP server and renames the folder found in the deepest level of the path.

Parameters
Name Type Description
$name string
$path string
$account \Conjoon_Modules_Groupware_Email_Account_Dto
$userId integer
Returns
Type Description
\the global name of the folder is renaming was successfull, otherwise false
Throws
Exception Description
\Exception
Documentation was generated by DocBlox 0.18.1.