modules/Emails/EmailUI.php
\EmailUI
Properties
$cacheTimeouts= 'array(
'messages' => 86400, // 24 hours
'folders' => 300, // 5 mins
'attachments' => 86400, // 24 hours
)'
array(
'messages' => 86400, // 24 hours
'folders' => 300, // 5 mins
'attachments' => 86400, // 24 hours
)
Details- Type
- n/a
$coreDynamicFolderQuery= '"SELECT emails.id polymorphic_id, 'Emails' polymorphic_module FROM emails
JOIN emails_text on emails.id = emails_text.email_id
WHERE (type = '::TYPE::' OR status = '::STATUS::') AND assigned_user_id = '::USER_ID::' AND emails.deleted = '0'"'
"SELECT emails.id polymorphic_id, 'Emails' polymorphic_module FROM emails
JOIN emails_text on emails.id = emails_text.email_id
WHERE (type = '::TYPE::' OR status = '::STATUS::') AND assigned_user_id = '::USER_ID::' AND emails.deleted = '0'"
Details- Type
- n/a
$rolloverStyle= '"<style>div#rollover {position: relative;float: left;margin: none;text-decoration: none;}div#rollover a:hover {padding: 0;}div#rollover a span {display: none;}div#rollover a:hover span {text-decoration: none;display: block;width: 250px;margin-top: 5px;margin-left: 5px;position: absolute;padding: 10px;color: #333; border: 1px solid #ccc; background-color: #fff; font-size: 12px;z-index: 1000;}</style>\n"'
"<style>div#rollover {position: relative;float: left;margin: none;text-decoration: none;}div#rollover a:hover {padding: 0;}div#rollover a span {display: none;}div#rollover a:hover span {text-decoration: none;display: block;width: 250px;margin-top: 5px;margin-left: 5px;position: absolute;padding: 10px;color: #333; border: 1px solid #ccc; background-color: #fff; font-size: 12px;z-index: 1000;}</style>\n"
Details- Type
- n/a
Methods
_cleanUIDList(
mixed $uids, bool $returnString
=
false
)
:
mixed
Cleans UID lists
Name | Type | Description |
---|---|---|
$uids | mixed | |
$returnString | bool | False will return an array |
Type | Description |
---|---|
mixed |
_generateComposeConfigData(
String $type
=
"email_compose_light"
)
:
void
Generate the config data needed for the Full Compose UI and the Quick Compose UI. The set of config data returned is the minimum set needed by the quick compose UI.
Name | Type | Description |
---|---|---|
$type | String | Drives which tinyMCE options will be included. |
_getPeopleUnionQuery(
$whereArr, $person
)
:
void
Generates a UNION query to get one list of users, contacts, leads, and prospects; used specifically for the addressBook
Name | Type | Description |
---|---|---|
$whereArr | ||
$person |
_loadQuickCreateModules(
)
:
array
Load the modules from the metadata file and include in a custom one if it exists
Type | Description |
---|---|
array |
_writeCacheFile(
array $array, string $file
)
:
bool
Performs the actual file write. Abstracted from writeCacheFile() for flexibility
Name | Type | Description |
---|---|---|
$array | array | The array to write to the cache |
$file | string | Full path (relative) with cache file name |
Type | Description |
---|---|
bool |
addContactsToList(
string $list_id, array $contacts, string $newName, bool $truncate
=
false
)
:
void
Adds contact items to a mailing list
Name | Type | Description |
---|---|---|
$list_id | string | list_id GUID |
$contacts | array | contacts |
$newName | string | newName |
$truncate | bool | truncate |
arrayToXML(
array $a, string $paramName
)
:
string
takes an array and creates XML
Name | Type | Description |
---|---|---|
$a | array | Array to convert |
$paramName | string | Name to wrap highest level items in array |
Type | Description |
---|---|
string | XML |
buildTreeNode(
$key, $label, $mbox, string $ieId, string $nodePath, bool $isGroup, bool $ie
)
:
mixed
Builds up a TreeView Node object
Name | Type | Description |
---|---|---|
$key | mixed |
|
$label | mixed |
|
$mbox | string |
|
$ieId | string | ID of InboundEmail instance |
$nodePath | string | nodePath Serialized path from root node to current node |
$isGroup | bool | isGroup |
$ie | bool | forceRefresh |
Type | Description |
---|---|
mixed |
createCopyOfInboundAttachment(
$ie, $ret, $uid
)
:
void
Name | Type | Description |
---|---|---|
$ie | ||
$ret | ||
$uid |
createList(
string $name
)
:
void
Creates a blank mailing list
Name | Type | Description |
---|---|---|
$name | string | name |
displayComposeEmail(
object $email
)
:
void
Returns the templatized compose screen. Used by reply, forwards and draft status messages.
Name | Type | Description |
---|---|---|
object | email Email bean in focus |
displayQuickComposeEmailFrame(
)
:
\JSON
Generate the frame needed for the quick compose email UI. This frame is loaded dynamically by an ajax call.
Type | Description |
---|---|
\JSON | An object containing html markup and js script variables. |
displaySuccessMessage(
string $type
)
:
void
Formats a display message on successful async call
Name | Type | Description |
---|---|---|
$type | string | Type of message to display |
distDirect(
\$user $user, \$mailIds $mailIds
)
:
boolean
distributes emails to 1 user
Name | Type | Description |
---|---|---|
$user | \$user | users to dist to |
$mailIds | \$mailIds | array of email ids to push |
Type | Description |
---|---|
boolean | true on success |
distLeastBusy(
\$userIds $userIds, \$mailIds $mailIds
)
:
boolean
distributes emails to users on Least Busy basis
Name | Type | Description |
---|---|---|
$userIds | \$userIds | array of users to dist to |
$mailIds | \$mailIds | array of email ids to push on those users |
Type | Description |
---|---|
boolean | true on success |
distRoundRobin(
\$userIds $userIds, \$mailIds $mailIds
)
:
boolean
distributes emails to users on Round Robin basis
Name | Type | Description |
---|---|---|
$userIds | \$userIds | array of users to dist to |
$mailIds | \$mailIds | array of email ids to push on those users |
Type | Description |
---|---|
boolean | true on success |
doAssignment(
$distributeMethod, $ieid, $folder, $uids, $users
)
:
void
Name | Type | Description |
---|---|---|
$distributeMethod | ||
$ieid | ||
$folder | ||
$uids | ||
$users |
doDistributionWithMethod(
$users, $emailIds, $distributionMethod
)
:
void
Name | Type | Description |
---|---|---|
$users | ||
$emailIds | ||
$distributionMethod |
emptyTrash(
object $ie
)
:
void
Identifies subscribed mailboxes and empties the trash
Name | Type | Description |
---|---|---|
$ie | object | InboundEmail |
findEmailFromBeanIds(
$beanIds, $beanType, $whereArr
)
:
void
Name | Type | Description |
---|---|---|
$beanIds | ||
$beanType | ||
$whereArr |
generateComposePackageForQuickCreate(
Array $composeData, String $fullLinkUrl, $lazyLoad
=
false, \SugarBean $bean
=
null
)
:
\JSON
Generate the composePackage for the quick compose email UI. The package contains key/value pairs generated by the Compose.php file which are then set into the quick compose email UI (eg. to addr, parent id, parent type, etc)
Name | Type | Description |
---|---|---|
$composeData | Array | Associative array read and processed by generateComposeDataPackage. |
$fullLinkUrl | String | A link that contains all pertinant information so the user can be directed to the full compose screen if needed |
$lazyLoad | ||
$bean | \SugarBean | Optional - the parent object bean with data |
Type | Description |
---|---|
\JSON | Object containg composePackage and fullLinkUrl |
generateComposePackageForQuickCreateFromComposeUrl(
String $emailLinkUrl, $lazyLoad
=
false
)
:
\JSON
Given an email link url (eg. index.php?action=Compose&parent_type=Contacts...) break up the request components and create a compose package that can be used by the quick compose UI. The result is typically passed into the js call SUGAR.quickCompose.init which initalizes the quick compose UI.
Name | Type | Description |
---|---|---|
$emailLinkUrl | String | |
$lazyLoad |
Type | Description |
---|---|
\JSON | Object containing the composePackage and full link url |
generateDynamicFolderQuery(
string $type, string $userId
)
:
string
Parses the core dynamic folder query
Name | Type | Description |
---|---|---|
$type | string | 'inbound', 'draft', etc. |
$userId | string |
Type | Description |
---|---|
string |
generateExpandableAddrs(
string $str
)
:
string
Generate to/cc addresses string in email detailview.
Name | Type | Description |
---|---|---|
$str | string |
Type | Description |
---|---|
string | $str |
getCacheTimestamp(
string $ieId, string $type, string $file
)
:
string
retrieves the cache file last touched time
Name | Type | Description |
---|---|---|
$ieId | string | |
$type | string | Type of cache file: folders, messages, etc. |
$file | string | The cachefile name |
Type | Description |
---|---|
string |
getCacheValue(
string $ieId, string $type, string $file, string $key
)
:
mixed
retrieves the cached value
Name | Type | Description |
---|---|---|
$ieId | string | |
$type | string | Type of cache file: folders, messages, etc. |
$file | string | The cachefile name |
$key | string | name of cache value |
Type | Description |
---|---|
mixed |
getContacts(
)
:
array
Retrieves all relationship metadata for a user's address book
Type | Description |
---|---|
array |
getDetailViewForEmail2(
$emailId
)
:
void
This function returns the detail view for email in new 2.0 interface
Name | Type | Description |
---|---|---|
$emailId |
getDraftAttachments(
array $ret
)
:
array
Used exclusively by draft code. Returns Notes and Documents as attachments.
Name | Type | Description |
---|---|---|
$ret | array |
Type | Description |
---|---|
array |
getEditContact(
string $id, string $module
)
:
array
Prepares the Edit Contact mini-form via template assignment
Name | Type | Description |
---|---|---|
$id | string | id ID of contact in question |
$module | string | module Module in focus |
Type | Description |
---|---|
array |
getEditMailingList(
string $id
)
:
string
Returns metadata including the full HTML form to edit a mailing list
Name | Type | Description |
---|---|---|
$id | string | id ID of the Mailing List |
Type | Description |
---|---|
string | HTML, empty on error |
getEmailTemplatesArray(
)
:
array
returns an array of EmailTemplates that the user has access to for the compose email screen
Type | Description |
---|---|
array |
getFromAllAccountsArray(
\unknown_type $ie, $ret
)
:
\unknown
This function will return all the accounts this user has access to based on the match of the emailId passed in as a parameter
Name | Type | Description |
---|---|---|
$ie | \unknown_type | |
$ret |
Type | Description |
---|---|
\unknown |
getImportForm(
array $vars, object $email, $formName
=
'ImportEditView'
)
:
array
Renders the Import form from Smarty and returns HTML
Name | Type | Description |
---|---|---|
$vars | array | request variable global |
object | Fetched email object |
|
$formName |
Type | Description |
---|---|
array |
getListEmails(
\GUID $ieId, string $mbox, int $folderListCacheOffset, $forceRefresh
=
'false'
)
:
string
Returns the HTML for a list of emails in a given folder
Name | Type | Description |
---|---|---|
$ieId | \GUID | GUID to InboundEmail instance |
$mbox | string | Mailbox path name in dot notation |
$folderListCacheOffset | int | Seconds for valid cache file |
$forceRefresh |
Type | Description |
---|---|
string | HTML render of list. |
getLists(
)
:
array
Returns metadata to construct a user's mailing lists
Type | Description |
---|---|
array |
getMailboxNodes(
)
:
object
returns an array of nodes that correspond to IMAP mailboxes.
Type | Description |
---|---|
object | TreeView object |
getQuickCreateForm(
array $vars, object $email, $addToAddressBookButton
=
false
)
:
array
Renders the QuickCreate form from Smarty and returns HTML
Name | Type | Description |
---|---|---|
$vars | array | request variable global |
object | Fetched email object |
|
$addToAddressBookButton |
Type | Description |
---|---|
array |
getRelatedEmail(
$beanType, \$condition $whereArr, $relatedBeanInfoArr
=
''
)
:
\array('query'
get emails of related bean for a given bean id
Name | Type | Description |
---|---|---|
$beanType | ||
$whereArr | \$condition | array of conditions inclued bean id |
$relatedBeanInfoArr |
Type | Description |
---|---|
\array('query' | => $q, 'countQuery' => $countq); |
getShowAccountsOptions(
$ie
)
:
void
Re-used option getter for Show Accounts multiselect pane
Name | Type | Description |
---|---|---|
$ie |
getSingleMessage(
$ie
)
:
array
returns the metadata defining a single email message for display. Uses cache file if it exists
Name | Type | Description |
---|---|---|
$ie |
Type | Description |
---|---|
array |
getUnreadCount(
$ie, $mailbox
)
:
void
Totals the unread emails
Name | Type | Description |
---|---|---|
$ie | ||
$mailbox |
getUserContacts(
array $contacts, object $user
=
null
)
:
array
Retrieves a concatenated list of contacts, those with assigned_user_id = user's id and those in the address_book table
Name | Type | Description |
---|---|---|
$contacts | array | Array of contact types -> IDs |
$user | object | User in focus |
Type | Description |
---|---|
array |
handleReplyType(
object $email, string $type
)
:
object
Formats email body on reply/forward
Name | Type | Description |
---|---|---|
object | email Email object in focus |
|
$type | string | type |
Type | Description |
---|---|
object |
jsonOuput(
array $data, string $resultsParam, $count
=
0, $fromCache
=
true, $unread
=
-1
)
:
string
Generate JSON encoded data to be consumed by yui datatable.
Name | Type | Description |
---|---|---|
$data | array | |
$resultsParam | string | The resultsList name |
$count | ||
$fromCache | ||
$unread |
Type | Description |
---|---|
string |
markEmails(
string $type, string $ieId, string $folder, string $uids
)
:
void
Marks emails with the passed flag type. This will be applied to local cache files as well as remote emails.
Name | Type | Description |
---|---|---|
$type | string | Flag type |
$ieId | string | |
$folder | string | IMAP folder structure or SugarFolder GUID |
$uids | string | Comma sep list of UIDs or GUIDs |
parseAttachmentInfo(
$actualAttachmentInfo, $attachmentHtmlData
)
:
void
Name | Type | Description |
---|---|---|
$actualAttachmentInfo | ||
$attachmentHtmlData |
preflightEmailCache(
$cacheRoot
)
:
void
Generates cache folder structure
Name | Type | Description |
---|---|---|
$cacheRoot |
preflightUser(
object $user
)
:
void
Creates defaults for the User
Name | Type | Description |
---|---|---|
$user | object | User in focus |
removeContacts(
array $ids
)
:
void
Removes contacts from the user's address book
Name | Type | Description |
---|---|---|
$ids | array | ids |
removeLists(
array $removeIds
)
:
void
Removes selected lists from User's preferences
Name | Type | Description |
---|---|---|
$removeIds | array | IDs of lists to remove |
saveContactEdit(
string $str
)
:
void
saves editted Contact info
Name | Type | Description |
---|---|---|
$str | string | JSON serialized object |
saveFolderOpenState(
$focusFolder, $focusFolderOpen
)
:
void
Stickies folder collapse/open state
Name | Type | Description |
---|---|---|
$focusFolder | ||
$focusFolderOpen |
saveListView(
$ieId, $folder
)
:
void
saves a folder's view state
Name | Type | Description |
---|---|---|
$ieId | ||
$folder |
saveListViewSortOrder(
$ieId, $focusFolder, $sortBy, $sortDir
)
:
void
Saves user sort prefernces
Name | Type | Description |
---|---|---|
$ieId | ||
$focusFolder | ||
$sortBy | ||
$sortDir |
saveNewFolder(
string $nodeLabel, $parentId, $isGroup
=
0
)
:
void
Creates a new Sugar folder
Name | Type | Description |
---|---|---|
$nodeLabel | string | New sugar folder name |
$parentId | ||
$isGroup |
setCacheTimestamp(
string $ieId, string $type, string $file
)
:
void
Updates the timestamp for a cache file - usually to mark a "check email" process
Name | Type | Description |
---|---|---|
$ieId | string | |
$type | string | Type of cache file: folders, messages, etc. |
$file | string | The cachefile name |
setContacts(
array $contacts
)
:
void
Saves changes to a user's address book
Name | Type | Description |
---|---|---|
$contacts | array | contacts |
setReadFlag(
$ieId, $mbox, $uid
)
:
void
Sets the "read" flag in the overview cache
Name | Type | Description |
---|---|---|
$ieId | ||
$mbox | ||
$uid |
unifyEmailString(
String $str
)
:
String
Unify the seperator as ,
Name | Type | Description |
---|---|---|
$str | String | email address string |
Type | Description |
---|---|
String | converted string |
validCacheFileExists(
string $ieId, string $type, string $file, int $refreshOffset
=
-1
)
:
\mixed.
Validates existence and expiration of a cache file
Name | Type | Description |
---|---|---|
$ieId | string | |
$type | string | Type of cache file: folders, messages, etc. |
$file | string | The cachefile name |
$refreshOffset | int | refreshOffset Refresh time in secs. |
Type | Description |
---|---|
\mixed. |
writeCacheFile(
string $key, mixed $var, string $ieId, string $type, string $file
)
:
void
Writes caches to flat file in cache dir.
Name | Type | Description |
---|---|---|
$key | string | Key to the main cache entry (not timestamp) |
$var | mixed | Variable to be cached |
$ieId | string | I-E focus ID |
$type | string | Folder in cache |
$file | string | Cache file name |