Ejemplo n.º 1
0
 /**
  * Create a sugar folder for this inbound email account
  * if the Enable Auto Import option is selected
  *
  * @return String Id of the sugar folder created.
  */
 function createAutoImportSugarFolder()
 {
     global $current_user;
     $guid = create_guid();
     $GLOBALS['log']->debug("Creating Sugar Folder for IE with id {$guid}");
     $folder = new SugarFolder();
     $folder->id = $guid;
     $folder->new_with_id = TRUE;
     $folder->name = $this->name;
     $folder->has_child = 0;
     $folder->is_group = 1;
     $folder->assign_to_id = $current_user->id;
     $folder->parent_folder = "";
     //If this inbound email is marked as inactive, don't add subscriptions.
     $addSubscriptions = $this->status == 'Inactive' || $this->mailbox_type == 'bounce' ? FALSE : TRUE;
     $folder->save($addSubscriptions);
     return $guid;
 }
Ejemplo n.º 2
0
 /**
  * Creates Mail folder
  *
  * @param object $user User in focus
  * @param array $folder_params Array of parameters for folder creation
  */
 protected function createFolder($user, $folder_params)
 {
     $folder = new SugarFolder();
     foreach ($folder_params as $key => $val) {
         $folder->{$key} = $val;
     }
     $folder->save();
     return $folder;
 }
Ejemplo n.º 3
0
 /**
  * Creates defaults for the User
  * @param object $user User in focus
  */
 function preflightUser(&$user)
 {
     global $mod_strings;
     $goodToGo = $user->getPreference("email2Preflight", "Emails");
     $q = "SELECT count(*) count FROM folders f where f.created_by = '{$user->id}' AND f.folder_type = 'inbound' AND f.deleted = 0";
     $r = $user->db->query($q);
     $a = $user->db->fetchByAssoc($r);
     if ($a['count'] < 1) {
         require_once "include/SugarFolders/SugarFolders.php";
         // My Emails
         $folder = new SugarFolder();
         $folder->new_with_id = true;
         $folder->id = create_guid();
         $folder->name = $mod_strings['LNK_MY_INBOX'];
         $folder->has_child = 1;
         $folder->created_by = $user->id;
         $folder->modified_by = $user->id;
         $folder->is_dynamic = 1;
         $folder->folder_type = "inbound";
         $folder->dynamic_query = $this->generateDynamicFolderQuery('inbound', $user->id);
         $folder->save();
         // My Drafts
         $drafts = new SugarFolder();
         $drafts->name = $mod_strings['LNK_MY_DRAFTS'];
         $drafts->has_child = 0;
         $drafts->parent_folder = $folder->id;
         $drafts->created_by = $user->id;
         $drafts->modified_by = $user->id;
         $drafts->is_dynamic = 1;
         $drafts->folder_type = "draft";
         $drafts->dynamic_query = $this->generateDynamicFolderQuery('draft', $user->id);
         $drafts->save();
         // My Archived
         //$archived = new SugarFolder();
         //$archived->name = $mod_strings['LNK_MY_ARCHIVED_LIST'];
         //$archived->has_child = 0;
         //$archived->parent_folder = $folder->id;
         //$archived->created_by = $user->id;
         //$archived->modified_by = $user->id;
         //$archived->is_dynamic = 1;
         //$archived->dynamic_query = $this->generateDynamicFolderQuery('archived', $user->id);
         //$archived->save();
         // Sent Emails
         $archived = new SugarFolder();
         $archived->name = $mod_strings['LNK_SENT_EMAIL_LIST'];
         $archived->has_child = 0;
         $archived->parent_folder = $folder->id;
         $archived->created_by = $user->id;
         $archived->modified_by = $user->id;
         $archived->is_dynamic = 1;
         $archived->folder_type = "sent";
         $archived->dynamic_query = $this->generateDynamicFolderQuery('sent', $user->id);
         $archived->save();
         // set flag to show that this was run
         $user->setPreference("email2Preflight", true, 1, "Emails");
     }
 }
Ejemplo n.º 4
0
/**
 * Certain updates to the IE account need to be reflected in the related SugarFolder since they are
 * created automatically.  Only valid for IE accounts with auto import turned on.
 *
 * @param string $fieldName The field name that changed
 * @param SugarBean $focus The InboundEmail bean being saved.
 */
function syncSugarFoldersWithBeanChanges($fieldName, $focus)
{
    $f = new SugarFolder();
    $f->retrieve($focus->groupfolder_id);
    switch ($fieldName) {
        case 'name':
        case 'team_id':
        case 'team_set_id':
            $f->{$fieldName} = $focus->{$fieldName};
            $f->save();
            break;
        case 'status':
            if ($focus->status == 'Inactive') {
                $f->clearSubscriptionsForFolder($focus->groupfolder_id);
            } else {
                if ($focus->mailbox_type != 'bounce') {
                    $f->addSubscriptionsToGroupFolder();
                }
            }
            break;
    }
}
Ejemplo n.º 5
0
 /**
  * Tests sugar folder methods that deal with emails.
  *
  */
 function testFolderEmailMethods()
 {
     $emailParams = array('status' => 'read');
     $email = $this->_createEmailObject($emailParams);
     $this->emails[] = $email->id;
     $this->_createNewSugarFolder();
     $this->folder->addBean($email, $GLOBALS['current_user']);
     $emailExists = $this->folder->checkEmailExistForFolder($email->id);
     $this->assertTrue($emailExists, "Unable to check for emails with a specific folder");
     //Remove the specific email from our folder.
     $this->folder->deleteEmailFromFolder($email->id);
     $emailExists = $this->folder->checkEmailExistForFolder($email->id);
     $this->assertFalse($emailExists, "Unable to check for emails with a specific folder.");
     //Move the Email bean from one folder to another
     $f3 = new SugarFolder();
     $f3->id = create_guid();
     $f3->new_with_id = TRUE;
     $f3->save();
     $this->additionalFolders[] = $f3->id;
     $this->folder->addBean($email, $GLOBALS['current_user']);
     $emailExists = $f3->checkEmailExistForFolder($email->id);
     $this->assertFalse($emailExists);
     $this->folder->move($this->folder->id, $f3->id, $email->id);
     $emailExists = $f3->checkEmailExistForFolder($email->id);
     $this->assertTrue($emailExists, "Unable to move Emails bean to a different sugar folder");
 }