Modules/Groupware/Email/Folder/Model/Folder.php

Show: inherited
Table of Contents

\Conjoon_Modules_Groupware_Email_Folder_Model_Folder

Package: Conjoon\Groupware\Email\Model

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

Constant  META_INFO_OUTBOX = 'outbox'
Constant  META_INFO_DRAFT = 'draft'
Constant  META_INFO_SENT = 'sent'
Constant  META_INFO_INBOX = 'inbox'

Properties

Propertyprotectedstring  $_name= ''groupware_email_folders''

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

Default value'groupware_email_folders'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
methodprotected_addAccountsRootBaseHierarchy( integer $userId ) : array

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

Parameters
Name Type Description
$userId integer
Returns
Type Description
array
methodprotected_getDefaultFolderIdForType(  $accountId,  $userId,  $type ) : \intger

Parameters
Name Type Description
$accountId
$userId
$type
Returns
Type Description
\intger
methodprivate_getFolders( integer $id, integer $userId, boolean $isParentId = false ) : mixed

Helper for fetching a single folder or child folders froma given parentId.

Parameters
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

Returns
Type Description
mixed
methodprivate_getFoldersForAccountsRoot(  $adapter,  $folderId,  $collectedIds ) : void

Parameters
Name Type Description
$adapter
$folderId
$collectedIds
methodpublicaddFolder( integer $parentId, string $name, integer $userId ) : void

Appends 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

Parameters
Name Type Description
$parentId integer
$name string
$userId integer
methodpubliccreateFolderBaseHierarchyAndMapAccountIdForUserId( integer $accountId, integer $userId ) : integer

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

Parameters
Name Type Description
$accountId integer
$userId integer
Returns
Type Description
integer The total number of data inserted
methodpubliccreateFolderHierarchyForImapAccount( integer $accountId, integer $userId, string $name ) : integer

Adds an individual folder hierarchy for an imap account.

Parameters
Name Type Description
$accountId integer
$userId integer
$name string

The name of the account to use as the folders name

Returns
Type Description
integer The total number of data inserted
methodpublicdeleteFolder( integer $id, integer $userId, boolean $checkForDeletable = true ) : integer

Deletes a folder and all related data permanently from the datastore.

Parameters
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

Returns
Type Description
integer 0 if the folder was not deleted, otherwise 1 (equals to the number of deleted folders)
Details
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.  
methodpublicdoesFolderAllowChildren( integer $id ) : boolean

Returns true if the specified folder allows child nodes to be added, otherwise false.

Parameters
Name Type Description
$id integer

The id of the folder to check

Returns
Type Description
boolean true if the folder allows child nodes to be appended, otherwise false
methodpublicgetAccountsRootFolderId( integer $accountId, integer $userId ) : integer

Returns 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

Parameters
Name Type Description
$accountId integer
$userId integer
Returns
Type Description
integer
methodpublicgetAccountsRootOrRootFolderId( integer $accountId, integer $userId ) : integer

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

Parameters
Name Type Description
$accountId integer
$userId integer
Returns
Type Description
integer
methodpublicgetChildFolderIdsAsFlatArray( integer $folderId ) : array

Returns all ids of all child folders as a flat array without hierarchy.

Parameters
Name Type Description
$folderId integer
Returns
Type Description
array
Throws
Exception Description
\Conjoon_Argument_Exception
methodpublicgetDecoratableMethods( ) : void

methodpublicgetDraftFolderId( integer $accountId, integer $userId ) : integer

Returns 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

Parameters
Name Type Description
$accountId integer
$userId integer
Returns
Type Description
integer
methodpublicgetFolderBaseData( integer $folderId ) : \Zend_Db_Table_Row

Returns a single folder entry.

Parameters
Name Type Description
$folderId integer

The id of the folder to fetch

Returns
Type Description
\Zend_Db_Table_Row
methodpublicgetFolderBaseQuery(  $userId ) : void
static

Returns the base query for reading out folders.

Parameters
Name Type Description
$userId
methodpublicgetFolderForId( integer $id, integer $userId ) : \Zend_Db_Table_Row

Returns a single folder with all nedded information, including pending count.

Parameters
Name Type Description
$id integer

The id of the folder to fetch.

$userId integer

The id of the user to fetch this folder for.

Returns
Type Description
\Zend_Db_Table_Row
methodpublicgetFolderIdForName( string $name, integer $parentId ) : integer

Returns the id of the folder with the the sppecified name for the specified parent folder. Returns 0 if no wolder was found.

Parameters
Name Type Description
$name string
$parentId integer
Returns
Type Description
integer
methodpublicgetFolders(  $parentId,  $userId ) : array

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

Parameters
Name Type Description
$parentId
$userId
Returns
Type Description
array
methodpublicgetFoldersForAccountsRoot(  $userId ) : void

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

Parameters
Name Type Description
$userId
methodpublicgetInboxFolderId( integer $accountId, integer $userId ) : integer

Returns 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

Parameters
Name Type Description
$accountId integer
$userId integer
Returns
Type Description
integer
methodpublicgetItemCountForFolderAndUser( integer $folderId, integer $userId ) : integer

Returns the total count of messages for the specified folder belonging to the specified user.

Parameters
Name Type Description
$folderId integer
$userId integer
Returns
Type Description
integer the total count of items, or 0 if an error occured or no items where available.
methodpublicgetLocalMappingsForUser( integer $userId ) : array

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

Parameters
Name Type Description
$userId integer

The id of the user to fetch informations about his standard mappings for

Returns
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
methodpublicgetMetaInfo( integer $folderId ) : string

Returns the meta info for the folder with the specified id.

Returns null if the folder was not found.

Parameters
Name Type Description
$folderId integer
Returns
Type Description
string
methodpublicgetOutboxFolderId( integer $accountId, integer $userId ) : integer

Returns 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

Parameters
Name Type Description
$accountId integer
$userId integer
Returns
Type Description
integer
methodpublicgetPendingCountForFolderAndUser( integer $folderId, integer $userId ) : integer

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

Parameters
Name Type Description
$folderId integer
$userId integer
Returns
Type Description
integer the total count of pending items, or 0 if an error occured or no items where available.
methodpublicgetRepresentedEntity( ) : void

methodpublicgetRootFolderId( integer $accountId, integer $userId ) : integer

Returns 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

Parameters
Name Type Description
$accountId integer
$userId integer
Returns
Type Description
integer
methodprotectedgetRootFolders(  $userId ) : array

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

Parameters
Name Type Description
$userId
Returns
Type Description
array
methodpublicgetRootRemoteFolderId( integer $accountId, integer $userId ) : integer

Returns 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

Parameters
Name Type Description
$accountId integer
$userId integer
Returns
Type Description
integer
methodpublicgetRootTypeForFolderId( integer $folderId ) : String

Returns the type of the root node for the specified folder id.

Returns null if the folder was not found.

Parameters
Name Type Description
$folderId integer
Returns
Type Description
String
Throws
Exception Description
\Conjoon_Argument_Exception
methodpublicgetSentFolder( integer $accountId, integer $userId ) : integer

Returns 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

Parameters
Name Type Description
$accountId integer
$userId integer
Returns
Type Description
integer
Details
Deprecated
use getSentFolderId() instead  
methodpublicgetSentFolderId( integer $accountId, integer $userId ) : integer

Returns 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

Parameters
Name Type Description
$accountId integer
$userId integer
Returns
Type Description
integer
methodpublicgetTablePrefix( ) : String
staticinherited

Returns the table prefix.

Inherited from: \Conjoon_Db_Table::getTablePrefix()
Returns
Type Description
String
methodpublicisFolderDeletable( integer $id, integer $userId = -1 ) : boolean

Returns true if the folder may be deleted, otherwise false.

Parameters
Name Type Description
$id integer

The id of the folder to delete

$userId integer

If specified, the owner status will also be considered

Returns
Type Description
boolean true if the folder may be deleted, otherwise false
methodpublicisFolderMoveableToFolder( integer $id, integer $parentId ) : boolean

Returns true if the specified folder may be moved to the , otherwise false.

Parameters
Name Type Description
$id integer

The id of the folder to delete

$parentId integer

The id of the folder the folder gets moved into

Returns
Type Description
boolean true if the folder may be deleted, otherwise false
methodpublicisFolderNameEditable( integer $id ) : boolean

Returns true if the folder's name may be edited, otherwise false.

Parameters
Name Type Description
$id integer

The id of the folder to rename

Returns
Type Description
boolean true if the folder may be renamed, otherwise false
methodpublicmoveFolder( integer $id,  $parentId ) : integer

Moves a folder to a new node.

Parameters
Name Type Description
$id integer

The id of the folder to move

$parentId
Returns
Type Description
integer The number of rows updated, i.e. 0 if no update happened, otherwise 1
methodpublicrenameFolder( integer $id, string $name ) : integer

Renames a folder.

Parameters
Name Type Description
$id integer

The id of the folder to rename

$name string

The new name of the folder

Returns
Type Description
integer The number of rows updated, i.e. 0 if no update happened, otherwise 1
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.