Modules/Groupware/Email/Folder/Model/Folder.php
\Conjoon_Modules_Groupware_Email_Folder_Model_Folder
Table data gateway. Models the table <tt>groupware_email_folders</tt>.
- Parent(s)
- \Conjoon_BeanContext_Decoratable < ?\Zend_Db_Table
- Author
- Thorsten Suckow-Homberg
- Category
- Model
- Uses
- \Conjoon_Db_Table
Constants
Properties

string
$_name= ''groupware_email_folders''
The name of the table in the underlying datastore this class represents.
'groupware_email_folders'Details- Type
- string

string
$_primary= ''id''
The name of the column that denotes the primary key for this table
'id'Details- Type
- string

String
$_tblPrefix= '""'
""Details- Type
- String
- Inherited_from
- \Conjoon_Db_Table::$$_tblPrefix
Methods

__construct(
string | array $config
=
array(), \unknown_type $definition
=
null
)
:
void__construct() - For concrete implementation of Conjoon_Db_Table
Inherited from: \Conjoon_Db_Table::__construct()This constructor automatically prepends the prefix as defined using setTablePrefix() to this table's name.
| Name | Type | Description |
|---|---|---|
| $config | string | array | string can reference a Zend_Registry key for a db adapter OR it can refernece the name of a table |
| $definition | \unknown_type |

_addAccountsRootBaseHierarchy(
integer $userId
)
:
arrayAdds a default folder hierarchy and returns all the id's added in a flat numeric array.
This method will also store the relation of the user and the created folders in the folders_users table.
| Name | Type | Description |
|---|---|---|
| $userId | integer |
| Type | Description |
|---|---|
| array |

_getDefaultFolderIdForType(
$accountId, $userId, $type
)
:
\intger| Name | Type | Description |
|---|---|---|
| $accountId | ||
| $userId | ||
| $type |
| Type | Description |
|---|---|
| \intger |

_getFolders(
integer $id, integer $userId, boolean $isParentId
=
false
)
:
mixedHelper for fetching a single folder or child folders froma given parentId.
| Name | Type | Description |
|---|---|---|
| $id | integer | eitehr the id of the folder to fetch, or the parent id of the folder to fetch the children for. if $isParentId is set to true, child folders for this id will be returned. |
| $userId | integer | |
| $isParentId | boolean | Whether the specified id is the id of a folder to fetch child folders for |
| Type | Description |
|---|---|
| mixed |

_getFoldersForAccountsRoot(
$adapter, $folderId, $collectedIds
)
:
void| Name | Type | Description |
|---|---|---|
| $adapter | ||
| $folderId | ||
| $collectedIds |

addFolder(
integer $parentId, string $name, integer $userId
)
:
voidAppends a new folder to the folder with the specified $parentId.
If the folder is connected to an email-account, the new folder will inherit the account-id from it's parent-folder. The new folder will also inherit the meta-info-value of the parent folder
Checks first if the
| Name | Type | Description |
|---|---|---|
| $parentId | integer | |
| $name | string | |
| $userId | integer |

createFolderBaseHierarchyAndMapAccountIdForUserId(
integer $accountId, integer $userId
)
:
integerMaps the account id for the user to the users list of folders.
This method will check if the user already has a folder root hierarchy. If that is not the case, one will be created.
| Name | Type | Description |
|---|---|---|
| $accountId | integer | |
| $userId | integer |
| Type | Description |
|---|---|
| integer | The total number of data inserted |

createFolderHierarchyForImapAccount(
integer $accountId, integer $userId, string $name
)
:
integerAdds an individual folder hierarchy for an imap account.
| Name | Type | Description |
|---|---|---|
| $accountId | integer | |
| $userId | integer | |
| $name | string | The name of the account to use as the folders name |
| Type | Description |
|---|---|
| integer | The total number of data inserted |

deleteFolder(
integer $id, integer $userId, boolean $checkForDeletable
=
true
)
:
integerDeletes a folder and all related data permanently from the datastore.
| Name | Type | Description |
|---|---|---|
| $id | integer | The id of the folder to delete |
| $userId | integer | The id of the user to delete the data for |
| $checkForDeletable | boolean | Check whether the folder may get deleted |
| Type | Description |
|---|---|
| integer | 0 if the folder was not deleted, otherwise 1 (equals to the number of deleted folders) |
- Todo
- The method will first try to delete the folder related data primary, and signal a successfull operation even if other contextual data (such as email items stored in this folder) could not be deleted. In this case, a script should from time to time determine which email items etc. are not related to a folder anymore.

doesFolderAllowChildren(
integer $id
)
:
booleanReturns true if the specified folder allows child nodes to be added, otherwise false.
| Name | Type | Description |
|---|---|---|
| $id | integer | The id of the folder to check |
| Type | Description |
|---|---|
| boolean | true if the folder allows child nodes to be appended, otherwise false |

getAccountsRootFolderId(
integer $accountId, integer $userId
)
:
integerReturns the base accounts_root folder id for the specified account and the specified user, i.e. the folder with type "accounts_root".
Returns 0 if the folder could not be found
| Name | Type | Description |
|---|---|---|
| $accountId | integer | |
| $userId | integer |
| Type | Description |
|---|---|
| integer |

getAccountsRootOrRootFolderId(
integer $accountId, integer $userId
)
:
integerReturns the root/accounts_root folder id for the specified account and the specified user, i.e. the folder with type "root" or "accounts_root".
Returns 0 if the folder could not be found If no accounts_root could be found, the method will look up a "root" marked folder. If no "root" folder was found, the "root_remote" folder will be queried.
| Name | Type | Description |
|---|---|---|
| $accountId | integer | |
| $userId | integer |
| Type | Description |
|---|---|
| integer |

getChildFolderIdsAsFlatArray(
integer $folderId
)
:
arrayReturns all ids of all child folders as a flat array without hierarchy.
| Name | Type | Description |
|---|---|---|
| $folderId | integer |
| Type | Description |
|---|---|
| array |
| Exception | Description |
|---|---|
| \Conjoon_Argument_Exception |

getDraftFolderId(
integer $accountId, integer $userId
)
:
integerReturns the base draft folder id for the specified account and the specified user, i.e. the folder with type "draft".
Returns 0 if the folder could not be found
| Name | Type | Description |
|---|---|---|
| $accountId | integer | |
| $userId | integer |
| Type | Description |
|---|---|
| integer |

getFolderBaseData(
integer $folderId
)
:
\Zend_Db_Table_RowReturns a single folder entry.
| Name | Type | Description |
|---|---|---|
| $folderId | integer | The id of the folder to fetch |
| Type | Description |
|---|---|
| \Zend_Db_Table_Row |

getFolderBaseQuery(
$userId
)
:
voidReturns the base query for reading out folders.
| Name | Type | Description |
|---|---|---|
| $userId |

getFolderForId(
integer $id, integer $userId
)
:
\Zend_Db_Table_RowReturns a single folder with all nedded information, including pending count.
| Name | Type | Description |
|---|---|---|
| $id | integer | The id of the folder to fetch. |
| $userId | integer | The id of the user to fetch this folder for. |
| Type | Description |
|---|---|
| \Zend_Db_Table_Row |

getFolderIdForName(
string $name, integer $parentId
)
:
integerReturns the id of the folder with the the sppecified name for the specified parent folder. Returns 0 if no wolder was found.
| Name | Type | Description |
|---|---|---|
| $name | string | |
| $parentId | integer |
| Type | Description |
|---|---|
| integer |

getFolders(
$parentId, $userId
)
:
arrayReturns the child-folders for the specified id and userId.
If the parentId equals to 0, all root folders for the user will be read out.
| Name | Type | Description |
|---|---|---|
| $parentId | ||
| $userId |
| Type | Description |
|---|---|
| array |

getFoldersForAccountsRoot(
$userId
)
:
voidReturns all the ids of the folder hierarchy marked as accounts_root for a specific user. The ids will be returned in a flat numeric array.
| Name | Type | Description |
|---|---|---|
| $userId |

getInboxFolderId(
integer $accountId, integer $userId
)
:
integerReturns the base inbox folder id for the specified account and the specified user, i.e. the folder with type "inbox".
Returns 0 if the folder could not be found
| Name | Type | Description |
|---|---|---|
| $accountId | integer | |
| $userId | integer |
| Type | Description |
|---|---|
| integer |

getItemCountForFolderAndUser(
integer $folderId, integer $userId
)
:
integerReturns the total count of messages for the specified folder belonging to the specified user.
| Name | Type | Description |
|---|---|---|
| $folderId | integer | |
| $userId | integer |
| Type | Description |
|---|---|
| integer | the total count of items, or 0 if an error occured or no items where available. |

getLocalMappingsForUser(
integer $userId
)
:
arrayReturns the standard mapping for folders. A standard mapping consists of a group of folders where each one is mapped to a specific type, i.e.
of the type inbox, sent, draft, trash or outbox. This method does also consider "is_deleted" flagged accounts, since this information may still be needed for items which show up in "accounts_root" folder hierarchies.
| Name | Type | Description |
|---|---|---|
| $userId | integer | The id of the user to fetch informations about his standard mappings for |
| Type | Description |
|---|---|
| array | an associative array with the following key/value pairs: - parent_id: The id of the parent - folder (i.e. the folder with the type "root" or "accounts_root" for the queried folder - id: The id of the folder - groupware_email_accounts_id: The id of teh account for which the folder was created - type: the type of the folder, i.e. inbox, outbox, sent, trash, draft |

getMetaInfo(
integer $folderId
)
:
stringReturns the meta info for the folder with the specified id.
Returns null if the folder was not found.
| Name | Type | Description |
|---|---|---|
| $folderId | integer |
| Type | Description |
|---|---|
| string |

getOutboxFolderId(
integer $accountId, integer $userId
)
:
integerReturns the base outbox folder id for the specified account and the specified user, i.e. the folder with type "outbox".
Returns 0 if the folder could not be found
| Name | Type | Description |
|---|---|---|
| $accountId | integer | |
| $userId | integer |
| Type | Description |
|---|---|
| integer |

getPendingCountForFolderAndUser(
integer $folderId, integer $userId
)
:
integerReturns the total count of pendning messages for the specified folder belonging to the specified user.
A pending item is either a message flagged as unread, or a message in a draft or outbox folder waiting to be edited/send.
| Name | Type | Description |
|---|---|---|
| $folderId | integer | |
| $userId | integer |
| Type | Description |
|---|---|
| integer | the total count of pending items, or 0 if an error occured or no items where available. |

getRootFolderId(
integer $accountId, integer $userId
)
:
integerReturns the base root/ folder id for the specified account and the specified user, i.e. the folder with type "root".
Returns 0 if the folder could not be found
| Name | Type | Description |
|---|---|---|
| $accountId | integer | |
| $userId | integer |
| Type | Description |
|---|---|
| integer |

getRootFolders(
$userId
)
:
arrayReturns all root folders for the user. A root folder is either a folder that was created when an account was created, or a folder that was put into public that contains only folders of the type 'folder'.
A root folder that is connectec with multiple accounts usually is of the type 'accounts_root', a root-folder that was created for a specific account is usually of the type 'root'. If the folder is of the type 'root' (i.e. was created for a specific account), the name of the folder will default to the name of the account it is connected with. Folders of the type "root_remote" map a remote folder location, i.e. folders which are not managed by conjoon.
| Name | Type | Description |
|---|---|---|
| $userId |
| Type | Description |
|---|---|
| array |

getRootRemoteFolderId(
integer $accountId, integer $userId
)
:
integerReturns the base root_remote folder id for the specified account and the specified user, i.e. the folder with type "root_remote".
Returns 0 if the folder could not be found
| Name | Type | Description |
|---|---|---|
| $accountId | integer | |
| $userId | integer |
| Type | Description |
|---|---|
| integer |

getRootTypeForFolderId(
integer $folderId
)
:
StringReturns the type of the root node for the specified folder id.
Returns null if the folder was not found.
| Name | Type | Description |
|---|---|---|
| $folderId | integer |
| Type | Description |
|---|---|
| String |
| Exception | Description |
|---|---|
| \Conjoon_Argument_Exception |

getSentFolder(
integer $accountId, integer $userId
)
:
integerReturns the base sent folder id for the specified account and the specified user, i.e. the folder with type "sent".
Returns 0 if the folder could not be found
| Name | Type | Description |
|---|---|---|
| $accountId | integer | |
| $userId | integer |
| Type | Description |
|---|---|
| integer |
- Deprecated
- use getSentFolderId() instead

getSentFolderId(
integer $accountId, integer $userId
)
:
integerReturns the base sent folder id for the specified account and the specified user, i.e. the folder with type "sent".
Returns 0 if the folder could not be found
| Name | Type | Description |
|---|---|---|
| $accountId | integer | |
| $userId | integer |
| Type | Description |
|---|---|
| integer |

isFolderDeletable(
integer $id, integer $userId
=
-1
)
:
booleanReturns true if the folder may be deleted, otherwise false.
| Name | Type | Description |
|---|---|---|
| $id | integer | The id of the folder to delete |
| $userId | integer | If specified, the owner status will also be considered |
| Type | Description |
|---|---|
| boolean | true if the folder may be deleted, otherwise false |

isFolderMoveableToFolder(
integer $id, integer $parentId
)
:
booleanReturns true if the specified folder may be moved to the , otherwise false.
| Name | Type | Description |
|---|---|---|
| $id | integer | The id of the folder to delete |
| $parentId | integer | The id of the folder the folder gets moved into |
| Type | Description |
|---|---|
| boolean | true if the folder may be deleted, otherwise false |

isFolderNameEditable(
integer $id
)
:
booleanReturns true if the folder's name may be edited, otherwise false.
| Name | Type | Description |
|---|---|---|
| $id | integer | The id of the folder to rename |
| Type | Description |
|---|---|
| boolean | true if the folder may be renamed, otherwise false |

moveFolder(
integer $id, $parentId
)
:
integerMoves a folder to a new node.
| Name | Type | Description |
|---|---|---|
| $id | integer | The id of the folder to move |
| $parentId |
| Type | Description |
|---|---|
| integer | The number of rows updated, i.e. 0 if no update happened, otherwise 1 |

renameFolder(
integer $id, string $name
)
:
integerRenames a folder.
| Name | Type | Description |
|---|---|---|
| $id | integer | The id of the folder to rename |
| $name | string | The new name of the folder |
| Type | Description |
|---|---|
| integer | The number of rows updated, i.e. 0 if no update happened, otherwise 1 |