Modules/Groupware/Email/Item/Model/Item.php

Show: inherited
Table of Contents

\Conjoon_Modules_Groupware_Email_Item_Model_Item

Package: Conjoon\Groupware\Email\Model

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

Propertyprotectedstring  $_name= ''groupware_email_items''

The name of the table in the underlying datastore this class represents.

Default value'groupware_email_items'Details
Type
string
Propertyprotectedstring  $_primary= ''id''

The name of the column that denotes the primary key for this table

Default value'id'Details
Type
string
PropertyprotectedString  $_tblPrefix= '""'
staticinherited

Default table prefix.

Inherited from: \Conjoon_Db_Table::$$_tblPrefix
Default value""Details
Type
String
Inherited_from
\Conjoon_Db_Table::$$_tblPrefix  

Methods

methodpublic__construct( string | array $config = array(), \unknown_type $definition = null ) : void
inherited

__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.

Parameters
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
methodpublicdeleteItemsForFolder( integer $id, integer $userId ) : integer

Deletes all items and the corresponding data for the specified folder.

Parameters
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

Returns
Type Description
integer The number of items deleted
methodpublicdeleteItemsForUser( array $itemIds, integer $userId ) : integer

Deletes 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.

Parameters
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.

Returns
Type Description
integer The number of total rows deleted
methodpublicgetDecoratableMethods( ) : void

methodpublicgetEmailItemCountForFolder( integer $folderId ) : integer

Returns the total number of email items in this folder.

Parameters
Name Type Description
$folderId integer
Returns
Type Description
integer
methodpublicgetEmailItemsFor( integer $userId, integer $folderId, array $sortInfo ) : array

Fetches the email items for the specified user for the specified folder.

Parameters
Name Type Description
$userId integer

The id of the user

$folderId integer

The id of the folder

$sortInfo array

An array with sortInfo.

Returns
Type Description
array
methodpublicgetItemBaseQuery( integer $userId, array $sortInfo = null, array $addTable = null ) : \Zend_Db_Table_Select
static

Returns 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.

Parameters
Name Type Description
$userId integer
$sortInfo array
$addTable array
Returns
Type Description
\Zend_Db_Table_Select
methodpublicgetItemForUser( integer $itemId, integer $userId ) : array

Returns a single item with the specified id for the specified user.

Returns an empty array if entry was not found.

Parameters
Name Type Description
$itemId integer
$userId integer
Returns
Type Description
array
methodpublicgetItemsForUser( array $itemIds, integer $userId, array $sortInfo = array() ) : array

Returns the email items with the specified ids for the specified user.

Parameters
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

Returns
Type Description
array
methodpublicgetReferencedItem( integer $itemId, integer $userId ) : array

Looks 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

Parameters
Name Type Description
$itemId integer
$userId integer
Returns
Type Description
array
methodpublicgetRepresentedEntity( ) : void

methodpublicgetTablePrefix( ) : String
staticinherited

Returns the table prefix.

Inherited from: \Conjoon_Db_Table::getTablePrefix()
Returns
Type Description
String
methodprivategetTableWithSortField(  $field ) : void
static

Applies the correct table alias to the passed fieldname

Parameters
Name Type Description
$field
methodpublicmoveDraftToOutbox( \Conjoon_Modules_Groupware_Email_Draft $draft, \Conjoon_Modules_Groupware_Email_Account $account, integer $userId, string $type = '',  $referencesId = -1, array | array $postedAttachments,  $removeAttachmentIds ) : array

Saves 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.

Parameters
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
Returns
Type Description
array the data from groupware_email_item associated with the newly saved entry
methodpublicmoveItemsToFolder( array $itemIds, integer $groupwareEmailFoldersId ) : integer

Moves all items with the specified ids to the folder with the specified folderId

Parameters
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.

Returns
Type Description
integer The number of total rows updated
methodpublicsaveAttachmentsForDraft(  $draft, array $postedAttachments = array(), array $removeAttachmentIds = array(), array $attachmentMap = array() ) : void

Will 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.

Parameters
Name Type Description
$draft
$postedAttachments array
$removeAttachmentIds array
$attachmentMap array
Throws
Exception Description
\InvalidArgumentException
methodpublicsaveDraft( \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() ) : array

Saves 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.

Parameters
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

Returns
Type Description
array the data from groupware_email_item associated with the newly saved entry
methodpublicsaveSentEmail( \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() ) : array

Saves a sent email into the database.

Parameters
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
Returns
Type Description
array the data from groupware_email_item associated with the newly saved entry
methodpublicsetTablePrefix( String $prefix ) : void
staticinherited

Sets the table prefix.

Inherited from: \Conjoon_Db_Table::setTablePrefix()
Parameters
Name Type Description
$prefix String
Documentation was generated by DocBlox 0.18.1.