Modules/Groupware/Email/Folder/Facade.php
\Conjoon_Modules_Groupware_Email_Folder_Facade
Package: DefaultThis 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
Methods



_checkParam(
mixed $value, string $type
)
:
mixedFunction for often needed param checks.
Parameters
| Name |
Type |
Description |
| $value |
mixed |
|
| $type |
string |
|
Returns
Throws



_extractPathInfo(
string $path
)
:
arrayFunction 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



_sanitizeImapPath(
string $path, string $delim, boolean $popHead
=
false
)
:
mixedSanitizes 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 |



addFolderToPathForUserId(
string $name, string $path, integer $userId
)
:
mixedAdds 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 |



addImapFolderToPath(
string $name, string $path, \Conjoon_Modules_Groupware_Email_Account_Dto $account, integer $userId
)
:
mixedCreates a new folder/mailbox for the specified account at the specified
path.
Parameters
Returns
| Type |
Description |
| mixed |
The path to the newly created folder, or false |



deleteLocalFolderForUser(
integer $folderId, integer $userId
)
:
booleanDeletes 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



getAccountsForFolderIdAndUserId(
integer $folderId, integer $userId
)
:
ArrayReturns 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



getFoldersForPathAndUserId(
mixed $path, integer $userId
)
:
\Conjoon_Modules_Groupware_Email_Folder_DtoReturns 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



getImapAccountForFolderIdAndUserId(
integer $folderId, integer $userId
)
:
mixedChecks 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
Throws



getImapFoldersForPath(
\Conjoon_Groupware_Email_Account_Dto $account, string $path
=
""
)
:
\Conjoon_Modules_Groupware_Email_Folder_DtoQueries 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



getLocalFolderForIdAndUserId(
integer $folderId, integer $userId
)
:
\Conjoon_Modules_Groupware_Email_Folder_DtoReturns 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
Throws



isPopAccountMappedToFolderIdForUserId(
integer $folderId, integer $userId
)
:
booleanChecks 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



isRemoteFolder(
integer $folderId
)
:
booleanReturns 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
Throws
| Exception |
Description |
| \Conjoon_Argument_Exception, |
RuntimeException |



moveFolderFromPathToPathForUserId(
string $path, string $parentPath, integer $userId
)
:
\Conjoon_Modules_Groupware_Email_Folder_DtoMoves 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
Throws



moveImapFolderFromPathToPath(
string $path, string $parentPath, $account, integer $userId
)
:
mixedMoves 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



renameFolderForPathAndUserId(
string $name, string $path, integer $userId
)
:
mixedRenames 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



renameImapFolderForPath(
string $name, string $path, \Conjoon_Modules_Groupware_Email_Account_Dto $account, integer $userId
)
:
\theQueries the IMAP server and renames the folder found in the deepest level
of the path.
Parameters
Returns
| Type |
Description |
| \the |
global name of the folder is renaming was successfull, otherwise false |
Throws