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

string
$_name= ''groupware_email_items''
The name of the table in the underlying datastore this class represents.
'groupware_email_items'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 |

deleteItemsForFolder(
integer $id, integer $userId
)
:
integerDeletes all items and the corresponding data for the specified folder.
| Name | Type | Description |
|---|---|---|
| $id | integer | The id of the folder for which the data gets deleted. |
| $userId | integer | The id of the user to delete the data for |
| Type | Description |
|---|---|
| integer | The number of items deleted |

deleteItemsForUser(
array $itemIds, integer $userId
)
:
integerDeletes all items with the specified ids for the specified user.
The items will only be deleted if all rows in groupware_email_items_flags for the corresponding item have been set to is_deleted=1. Otherwise, only the is_deleted field for the specified user will be set to 1. If that is the case and the item gets entirely deleted, the method will use the accounts-model to check whether there are any accounts flagged as "is_deleted = 1" and also remove this accounts if no more items are exiting in the data storage.
| Name | Type | Description |
|---|---|---|
| $itemIds | array | A numeric array with all id's of the items that are about to be deleted |
| $userId | integer | The id of the user for which the items get deleted. |
| Type | Description |
|---|---|
| integer | The number of total rows deleted |

getEmailItemCountForFolder(
integer $folderId
)
:
integerReturns the total number of email items in this folder.
| Name | Type | Description |
|---|---|---|
| $folderId | integer |
| Type | Description |
|---|---|
| integer |

getEmailItemsFor(
integer $userId, integer $folderId, array $sortInfo
)
:
arrayFetches the email items for the specified user for the specified folder.
| Name | Type | Description |
|---|---|---|
| $userId | integer | The id of the user |
| $folderId | integer | The id of the folder |
| $sortInfo | array | An array with sortInfo. |
| Type | Description |
|---|---|
| array |

getItemBaseQuery(
integer $userId, array $sortInfo
=
null, array $addTable
=
null
)
:
\Zend_Db_Table_SelectReturns the base query for email-items
For some queries it can be crucial to add tables which get joined at the beginning of the statement. The optional argument $addTable allows for adding INNER JOIN sources to the beginning of the statement. It keys are "name" which holds a value as specified in the "from" method from Zend_Db_Select, and "cols". The base query will consider owner relationships for the folder the item sits in.
| Name | Type | Description |
|---|---|---|
| $userId | integer | |
| $sortInfo | array | |
| $addTable | array |
| Type | Description |
|---|---|
| \Zend_Db_Table_Select |

getItemForUser(
integer $itemId, integer $userId
)
:
arrayReturns a single item with the specified id for the specified user.
Returns an empty array if entry was not found.
| Name | Type | Description |
|---|---|---|
| $itemId | integer | |
| $userId | integer |
| Type | Description |
|---|---|
| array |

getItemsForUser(
array $itemIds, integer $userId, array $sortInfo
=
array()
)
:
arrayReturns the email items with the specified ids for the specified user.
| Name | Type | Description |
|---|---|---|
| $itemIds | array | A numeric array with all ids of the email items to fetch |
| $userId | integer | The id of the user |
| $sortInfo | array | optional, an array with sort configuration |
| Type | Description |
|---|---|
| array |

getReferencedItem(
integer $itemId, integer $userId
)
:
arrayLooks up if the specified id for the specified user has an entry in groupware_email_items_references has an entry and returns the item with the corresponding id
| Name | Type | Description |
|---|---|---|
| $itemId | integer | |
| $userId | integer |
| Type | Description |
|---|---|
| array |

getTableWithSortField(
$field
)
:
voidApplies the correct table alias to the passed fieldname
| Name | Type | Description |
|---|---|---|
| $field |

moveDraftToOutbox(
\Conjoon_Modules_Groupware_Email_Draft $draft, \Conjoon_Modules_Groupware_Email_Account $account, integer $userId, string $type
=
'', $referencesId
=
-1, array | array $postedAttachments, $removeAttachmentIds
)
:
arraySaves a draft and moves it into the outbox folder. The draft can either already be existing - in case the passed id id available in groupware_email_items_outbox - or new, in which case a whole new record will be created.
If the type is anything but new or an empty string, the referenced message will be saved in the reference-table, but still with the flag is_pending set to true, which will be set to false once the email is sent.
| Name | Type | Description |
|---|---|---|
| $draft | \Conjoon_Modules_Groupware_Email_Draft | The draft object to save |
| $account | \Conjoon_Modules_Groupware_Email_Account | The account which was used writing the draft |
| $userId | integer | The id of the user for whom the draft gets saved. |
| $type | string | The context in which the draft was moved to the outbox, either 'reply', 'reply_all', 'forward' or 'new' (or empty string) |
| $referencesId | ||
| $postedAttachments | array | array | A list of attachments, key/value pairs according to com.conjoon.cudgets.data.FileRecord |
| $removeAttachmentIds |
| Type | Description |
|---|---|
| array | the data from groupware_email_item associated with the newly saved entry |

moveItemsToFolder(
array $itemIds, integer $groupwareEmailFoldersId
)
:
integerMoves all items with the specified ids to the folder with the specified folderId
| Name | Type | Description |
|---|---|---|
| $itemIds | array | A numeric array with all id's of the items that get moved |
| $groupwareEmailFoldersId | integer | The id of the target folder the items get moved to. |
| Type | Description |
|---|---|
| integer | The number of total rows updated |

saveAttachmentsForDraft(
$draft, array $postedAttachments
=
array(), array $removeAttachmentIds
=
array(), array $attachmentMap
=
array()
)
:
voidWill save attachments for a draft.
When requested to save/send a message by a client, all existing attachments/files will be available in the postedAttachments property, data according to the structure of com.conjoon.cudgets.data.FileRecord. Important keys are 'orgId', 'metaType', 'key', 'name'
Warning! since its notguaranteed that the ids in removeAttachments are ids for attachments that indeed belong to the draft, it's needed to check whether the current list of attachments holds this id.
| Name | Type | Description |
|---|---|---|
| $draft | ||
| $postedAttachments | array | |
| $removeAttachmentIds | array | |
| $attachmentMap | array |
| Exception | Description |
|---|---|
| \InvalidArgumentException |

saveDraft(
\Conjoon_Modules_Groupware_Email_Draft $draft, \Conjoon_Modules_Groupware_Email_Account $account, integer $userId, string $type
=
'', integer $referencesId
=
-1, array $postedAttachments
=
array(), array $removeAttachmentIds
=
array(), array $attachmentMap
=
array()
)
:
arraySaves a draft into the database. The draft can either already be existing - in case the passed id id available in groupware_email_items_outbox - or new, in which case a whole new record will be created.
| Name | Type | Description |
|---|---|---|
| $draft | \Conjoon_Modules_Groupware_Email_Draft | The draft object to save |
| $account | \Conjoon_Modules_Groupware_Email_Account | The account which was used writing the draft |
| $userId | integer | The id of the user for whom the draft gets saved. |
| $type | string | The context the draft was created in. If this is reply or reply_all, the id stored in referencesId will be stored in the references-table |
| $referencesId | integer | The id of the message that was referenced creating the draft |
| $postedAttachments | array | A list of attachments, key/value pairs according to com.conjoon.cudgets.data.FileRecord |
| $removeAttachmentIds | array | a list of attachment ids to remove from a list of existing attachments belonging to the draft |
| $attachmentMap | array | An reference to an array which will map all attachments that have beens stored |
| Type | Description |
|---|---|
| array | the data from groupware_email_item associated with the newly saved entry |

saveSentEmail(
\Conjoon_Modules_Groupware_Email_Draft $message, \Conjoon_Modules_Groupware_Email_Account $account, integer $userId, \Conjoon_Mail_Sent $mailSent, string $type
=
"", integer $referencesId
=
-1, array $postedAttachments
=
array(), array $removeAttachmentIds
=
array()
)
:
arraySaves a sent email into the database.
| Name | Type | Description |
|---|---|---|
| $message | \Conjoon_Modules_Groupware_Email_Draft | |
| $account | \Conjoon_Modules_Groupware_Email_Account | |
| $userId | integer | |
| $mailSent | \Conjoon_Mail_Sent | |
| $type | string | |
| $referencesId | integer | The id of the email that was refernced sending this message. This argument will only be taken into account if $type euqals to reply or reply_all |
| $postedAttachments | array | |
| $removeAttachmentIds | array |
| Type | Description |
|---|---|
| array | the data from groupware_email_item associated with the newly saved entry |