include/SugarFolders/SugarFolders.php
\SugarFolder
Polymorphic buckets - place any item in a folder
Properties
$core= '"SELECT f.id, f.name, f.has_child, f.is_group, f.is_dynamic, f.dynamic_query, f.folder_type, f.created_by, i.deleted FROM folders f left join inbound_email i on f.id = i.groupfolder_id "'
"SELECT f.id, f.name, f.has_child, f.is_group, f.is_dynamic, f.dynamic_query, f.folder_type, f.created_by, i.deleted FROM folders f left join inbound_email i on f.id = i.groupfolder_id "
Details- Type
- n/a
$coreOrderBy= '" ORDER BY f.is_dynamic, f.is_group, f.name ASC "'
" ORDER BY f.is_dynamic, f.is_group, f.name ASC "
Details- Type
- n/a
$coreSubscribed= '"SELECT f.id, f.name, f.has_child, f.is_group, f.is_dynamic, f.dynamic_query, f.folder_type, f.created_by, i.deleted FROM folders f LEFT JOIN folders_subscriptions fs ON f.id = fs.folder_id LEFT JOIN inbound_email i on i.groupfolder_id = f.id "'
"SELECT f.id, f.name, f.has_child, f.is_group, f.is_dynamic, f.dynamic_query, f.folder_type, f.created_by, i.deleted FROM folders f LEFT JOIN folders_subscriptions fs ON f.id = fs.folder_id LEFT JOIN inbound_email i on i.groupfolder_id = f.id "
Details- Type
- n/a
$coreWhereSubscribed= '"WHERE f.deleted = 0 AND fs.assigned_user_id = "'
"WHERE f.deleted = 0 AND fs.assigned_user_id = "
Details- Type
- n/a
$hrSortLocal= 'array(
'flagged' => 'type',
'status' => 'reply_to_status',
'from' => 'emails_text.from_addr',
'subject' => 'name',
'date' => 'date_sent',
'AssignedTo' => 'assigned_user_id',
'flagged' => 'flagged'
)'
array(
'flagged' => 'type',
'status' => 'reply_to_status',
'from' => 'emails_text.from_addr',
'subject' => 'name',
'date' => 'date_sent',
'AssignedTo' => 'assigned_user_id',
'flagged' => 'flagged'
)
Details- Type
- n/a
Methods
addBean(
$bean, $user
=
null
)
:
void
Convenience method, pass a SugarBean and User to this to add anything to a given folder
Name | Type | Description |
---|---|---|
$bean | ||
$user |
buildTreeNodeFolders(
$a, $nodePath, $folderStates, $subscriptions
)
:
\$folderNode
Builds children nodes for folders for TreeView
Name | Type | Description |
---|---|---|
$a | ||
$nodePath | ||
$folderStates | ||
$subscriptions |
Type | Description |
---|---|
\$folderNode | TreeView node |
buildTreeNodeRefresh(
$folderNode, $subscriptions
)
:
void
Builds up a metanode for folder refresh (Sugar folders only)
Name | Type | Description |
---|---|---|
$folderNode | ||
$subscriptions |
clearSubscriptionsForFolder(
$folderID
)
:
\unknown
Deletes all subscriptions for a particular folder id
Name | Type | Description |
---|---|---|
$folderID |
Type | Description |
---|---|
\unknown |
copyBean(
$fromFolder, $toFolder, $beanId, $module
)
:
void
Copies one bean from one folder to another
Name | Type | Description |
---|---|---|
$fromFolder | ||
$toFolder | ||
$beanId | ||
$module |
createSubscriptionForUser(
$user_id
)
:
void
Add subscriptions to this group folder.
Name | Type | Description |
---|---|---|
$user_id |
deleteChildrenCascade(
string $id
)
:
bool
Deletes all children in a cascade
Name | Type | Description |
---|---|---|
$id | string | ID of parent |
Type | Description |
---|---|
bool | True on success |
findAllChildren(
$folderId, $childrenArray
)
:
void
Name | Type | Description |
---|---|---|
$folderId | ||
$childrenArray |
getCountNewItems(
string $id, array $criteria, $folder
)
:
int
Returns the number of "new" items (based on passed criteria)
Name | Type | Description |
---|---|---|
$id | string | id ID of folder |
$criteria | array | criteria expected: array('field' => 'status', 'value' => 'unread'); |
$folder | array |
Type | Description |
---|---|
int |
getFoldersChildForSettings(
$a, $collection, $subscriptions
)
:
void
Name | Type | Description |
---|---|---|
$a | ||
$collection | ||
$subscriptions |
getFoldersForSettings(
$focusUser
=
null
)
:
void
Preps object array for async call from user's Settings->Folders
Name | Type | Description |
---|---|---|
$focusUser |
getGroupFoldersForSettings(
$focusUser
=
null
)
:
void
Preps object array for async call from user's Settings->Folders
Name | Type | Description |
---|---|---|
$focusUser |
getListItemsForEmailXML(
$folderId, $page
=
1, $pageSize
=
10, $sort
=
'', $direction
=
''
)
:
void
returns array of items for listView display in yui-ext Grid
Name | Type | Description |
---|---|---|
$folderId | ||
$page | ||
$pageSize | ||
$sort | ||
$direction |
getParentIDRecursive(
string $id, array $ret
=
array()
)
:
array
Recursively finds parent node until it hits root
Name | Type | Description |
---|---|---|
$id | string | id Starting id to follow up |
$ret | array | ret collected ids |
Type | Description |
---|---|
array | of IDs |
getSubscriptions(
object $user
)
:
array
Returns GUIDs of folders that the user in focus is subscribed to
Name | Type | Description |
---|---|---|
$user | object | user User object in focus |
Type | Description |
---|---|
array |
getUserFolders(
\objec $rootNode, array $folderStates, object $user
=
null, $forRefresh
=
false
)
:
array
Collects, sorts, and builds tree of user's folders
Name | Type | Description |
---|---|---|
$rootNode | \objec | Reference to tree root node |
$folderStates | array | User pref folder open/closed states |
$user | object | Optional User in focus, default current_user |
$forRefresh |
Type | Description |
---|---|
array |
insertFolderSubscription(
String $folderId, String $userID
)
:
String
Given a folder id and user id, create a folder subscription entry.
Name | Type | Description |
---|---|---|
$folderId | String | |
$userID | String |
Type | Description |
---|---|
String | The id of the newly created folder subscription. |
move(
string $fromFolder, string $toFolder, string $beanId
)
:
void
Moves beans from one folder to another folder
Name | Type | Description |
---|---|---|
$fromFolder | string | fromFolder GUID of source folder |
$toFolder | string | toFolder GUID of destination folder |
$beanId | string | beanId GUID of SugarBean being moved |
retrieve(
string $id
)
:
bool
Retrieves and populates object
Name | Type | Description |
---|---|---|
$id | string | ID of folder |
Type | Description |
---|---|
bool | True on success |
retrieveFoldersForProcessing(
object $user, $subscribed
=
true
)
:
array
Builds up a metacollection of user/group folders to be passed to processor methods
Name | Type | Description |
---|---|---|
$user | object | User object, defaults to $current_user |
$subscribed |
Type | Description |
---|---|
array | Array of abstract folder objects |
save(
$addSubscriptions
=
TRUE
)
:
bool
Saves folder
Name | Type | Description |
---|---|---|
$addSubscriptions |
Type | Description |
---|---|
bool |
setFolder(
array $fields
)
:
void
Creates a new group Folder from the passed fields
Name | Type | Description |
---|---|---|
$fields | array | fields |
setSubscriptions(
array $subs
)
:
void
Sets a user's preferences for subscribe folders (Sugar only)
Name | Type | Description |
---|---|---|
$subs | array | subs Array of IDs for subscribed folders |