Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Commit

Permalink
feature(Felamimail/ActiveSync): support FolderCreate command #7172
Browse files Browse the repository at this point in the history
also remove all obsolete Felamimail_Model_Message containers (again)

fixes #7172
  • Loading branch information
pschuele committed May 17, 2021
1 parent fdb4f30 commit b6e8f4e
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 17 deletions.
25 changes: 18 additions & 7 deletions tests/tine20/Felamimail/Frontend/ActiveSyncTest.php
@@ -1,17 +1,13 @@
<?php
/**
* Test class for Felamimail_Frontend_ActiveSync
*
* Tine 2.0 - http://www.tine20.org
*
* @package Felamimail
* @license http://www.gnu.org/licenses/agpl.html AGPL Version 3
* @copyright Copyright (c) 2010-2020 Metaways Infosystems GmbH (http://www.metaways.de)
* @copyright Copyright (c) 2010-2021 Metaways Infosystems GmbH (http://www.metaways.de)
* @author Lars Kneschke <l.kneschke@metaways.de>
*/

/**
* Test class for Felamimail_Frontend_ActiveSync
*
* @package Felamimail
*
* TODO extend Felamimail_TestCase
*/
Expand Down Expand Up @@ -1108,4 +1104,19 @@ public function testSendMailToRecipientsWithComma()
$message = $this->_sendMailTestHelper($email, $messageId, $stringToCheck, "Syncroton_Command_SendMail");
self::assertEquals(1, count($message->to), 'message should have 1 recipient: ' . print_r($message->to, true));
}

public function testCreateFolder()
{
$controller = $this->_getController($this->_getDevice(Syncroton_Model_Device::TYPE_ANDROID_40));
$inbox = $this->_emailTestClass->getFolder('INBOX');
$folder = new Syncroton_Model_Folder([
'parentId' => $inbox->getId(),
'displayName' => 'syncroTestFolder',
]);
$this->_createdFolders[] = 'INBOX.' . $folder->displayName;
$newFolder = $controller->createFolder($folder);

$fmailFolder = Felamimail_Controller_Folder::getInstance()->get($newFolder->serverId);
self::assertEquals($folder->displayName, $fmailFolder->localname);
}
}
2 changes: 1 addition & 1 deletion tine20/Felamimail/Controller/Folder.php
Expand Up @@ -209,7 +209,7 @@ public function getByBackendAndGlobalName($_accountId, $_globalName)
*
* @param string|Felamimail_Model_Account $_accountId
* @param string $_folderName to create
* @param string $_parentFolder
* @param string $_parentFolder parent folder globalname
* @return Felamimail_Model_Folder
* @throws Felamimail_Exception_IMAPServiceUnavailable
* @throws Tinebase_Exception_SystemGeneric
Expand Down
30 changes: 22 additions & 8 deletions tine20/Felamimail/Frontend/ActiveSync.php
Expand Up @@ -42,13 +42,6 @@ class Felamimail_Frontend_ActiveSync extends ActiveSync_Frontend_Abstract implem
Syncroton_Command_Sync::FILTER_1_MONTH_BACK,
);

/**
* felamimail message controller
*
* @var Felamimail_Controller_Message
*/
protected $_messageController;

/**
* felamimail account
*
Expand Down Expand Up @@ -789,7 +782,28 @@ public function updateFolder(Syncroton_Model_IFolder $folder)
Felamimail_Controller_Folder::getInstance()->rename($fmailFolder->account_id, $folder->displayName, $fmailFolder->globalname);
return $folder;
}


/**
* (non-PHPdoc)
* @see Syncroton_Data_IData::createFolder()
*/
public function createFolder(Syncroton_Model_IFolder $folder)
{
if (empty($folder->parentId)) {
if (Tinebase_Core::isLogLevel(Zend_Log::WARN)) Tinebase_Core::getLogger()->warn(
__METHOD__ . '::' . __LINE__ . " It is not possible to create a folder at root level");
return $folder;
}

$parent = Felamimail_Controller_Folder::getInstance()->get($folder->parentId);
$account = Felamimail_Controller_Account::getInstance()->get($parent->account_id);
$newFolder = Felamimail_Controller_Folder::getInstance()->create($account, $folder->displayName, $parent->globalname);

$folder->serverId = $newFolder->getId();

return $folder;
}

/**
* (non-PHPdoc)
* @see ActiveSync_Frontend_Abstract::toTineModel()
Expand Down
30 changes: 30 additions & 0 deletions tine20/Felamimail/Setup/Update/14.php
@@ -0,0 +1,30 @@
<?php
/**
* Tine 2.0
*
* @package Tinebase
* @subpackage Setup
* @license http://www.gnu.org/licenses/agpl.html AGPL3
* @copyright Copyright (c) 2021 Metaways Infosystems GmbH (http://www.metaways.de)
* @author Philipp Schüle <p.schuele@metaways.de>
*/
class Felamimail_Setup_Update_14 extends Setup_Update_Abstract
{
const RELEASE014_UPDATE001 = __CLASS__ . '::update001';

static protected $_allUpdates = [
self::PRIO_NORMAL_APP_UPDATE => [
self::RELEASE014_UPDATE001 => [
self::CLASS_CONST => self::class,
self::FUNCTION_CONST => 'update001',
],
],
];

public function update001()
{
// remove obsolete Felamimail_Model_Message containers that have been created by accident (see \ActiveSync_Frontend_Abstract::createFolder)
$this->_db->query('DELETE FROM ' . SQL_TABLE_PREFIX . 'container WHERE model = "Felamimail_Model_Message"');
$this->addApplicationUpdate('Felamimail', '14.1', self::RELEASE014_UPDATE001);
}
}
2 changes: 1 addition & 1 deletion tine20/Felamimail/Setup/setup.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<application>
<name>Felamimail</name>
<version>13.4</version>
<version>14.1</version>
<order>30</order>
<status>enabled</status>
<tables>
Expand Down

0 comments on commit b6e8f4e

Please sign in to comment.