Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ffb6a2de9c | ||
|
|
13332ecef6 | ||
|
|
4f090c5b6e | ||
|
|
4dd9ad2fa3 | ||
|
|
1c4cc0f963 | ||
|
|
a5b566edd0 |
15
CHANGELOG.md
15
CHANGELOG.md
@@ -1,6 +1,21 @@
|
||||
# Changelog
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## 0.2.7 - 2017-11-10
|
||||
|
||||
### Fixed
|
||||
- Fix bug that caused update to fail
|
||||
|
||||
## 0.2.6 - 2017-11-10
|
||||
|
||||
### Fixed
|
||||
- Fix duedates not being updated with MySQL databases
|
||||
|
||||
## 0.2.5 - 2017-11-08
|
||||
|
||||
### Fixed
|
||||
- Fix duedates not being saved with MySQL databases
|
||||
|
||||
## 0.2.4 - 2017-10-08
|
||||
|
||||
### Fixed
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
💥 This is still alpha software: it may not be stable enough for production!
|
||||
|
||||
</description>
|
||||
<version>0.2.4</version>
|
||||
<version>0.2.7</version>
|
||||
<licence>agpl</licence>
|
||||
<author>Julius Härtl</author>
|
||||
<namespace>Deck</namespace>
|
||||
|
||||
@@ -53,6 +53,10 @@ class Application extends App {
|
||||
});
|
||||
$container->registerMiddleware('SharingMiddleware');
|
||||
|
||||
$container->registerService('databaseType', function($container) {
|
||||
return $container->getServer()->getConfig()->getSystemValue('dbtype', 'sqlite');
|
||||
});
|
||||
|
||||
// Delete user/group acl entries when they get deleted
|
||||
/** @var IUserManager $userManager */
|
||||
$userManager = $server->getUserManager();
|
||||
|
||||
@@ -42,6 +42,8 @@ class Card extends RelationalEntity implements JsonSerializable {
|
||||
protected $archived = false;
|
||||
protected $duedate = null;
|
||||
|
||||
private $databaseType = 'sqlite';
|
||||
|
||||
const DUEDATE_FUTURE = 0;
|
||||
const DUEDATE_NEXT = 1;
|
||||
const DUEDATE_NOW = 2;
|
||||
@@ -58,10 +60,17 @@ class Card extends RelationalEntity implements JsonSerializable {
|
||||
$this->addResolvable('owner');
|
||||
}
|
||||
|
||||
public function getDuedate() {
|
||||
public function setDatabaseType($type) {
|
||||
$this->databaseType = $type;
|
||||
}
|
||||
|
||||
public function getDuedate($isoFormat = false) {
|
||||
if($this->duedate === null)
|
||||
return null;
|
||||
$dt = new DateTime($this->duedate);
|
||||
if (!$isoFormat && $this->databaseType === 'mysql') {
|
||||
return $dt->format('Y-m-d H:i:s');
|
||||
}
|
||||
return $dt->format('c');
|
||||
}
|
||||
|
||||
@@ -91,7 +100,7 @@ class Card extends RelationalEntity implements JsonSerializable {
|
||||
$json['overdue'] = self::DUEDATE_OVERDUE;
|
||||
}
|
||||
}
|
||||
$json['duedate'] = $this->getDuedate();
|
||||
$json['duedate'] = $this->getDuedate(true);
|
||||
return $json;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,20 +32,29 @@ class CardMapper extends DeckMapper implements IPermissionMapper {
|
||||
|
||||
private $labelMapper;
|
||||
private $userManager;
|
||||
private $databaseType;
|
||||
|
||||
public function __construct(IDBConnection $db, LabelMapper $labelMapper, IUserManager $userManager) {
|
||||
public function __construct(
|
||||
IDBConnection $db,
|
||||
LabelMapper $labelMapper,
|
||||
IUserManager $userManager,
|
||||
$databaseType = 'sqlite'
|
||||
) {
|
||||
parent::__construct($db, 'deck_cards', '\OCA\Deck\Db\Card');
|
||||
$this->labelMapper = $labelMapper;
|
||||
$this->userManager = $userManager;
|
||||
$this->databaseType = $databaseType;
|
||||
}
|
||||
|
||||
public function insert(Entity $entity) {
|
||||
$entity->setDatabaseType($this->databaseType);
|
||||
$entity->setCreatedAt(time());
|
||||
$entity->setLastModified(time());
|
||||
return parent::insert($entity);
|
||||
}
|
||||
|
||||
public function update(Entity $entity) {
|
||||
$entity->setDatabaseType($this->databaseType);
|
||||
$entity->setLastModified(time());
|
||||
return parent::update($entity);
|
||||
}
|
||||
@@ -141,4 +150,4 @@ class CardMapper extends DeckMapper implements IPermissionMapper {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,4 +99,11 @@ class CardTest extends \PHPUnit_Framework_TestCase {
|
||||
], $card->jsonSerialize());
|
||||
}
|
||||
|
||||
public function testMysqlDateFallback() {
|
||||
$date = new DateTime();
|
||||
$card = new Card();
|
||||
$card->setDuedate($date->format('c'));
|
||||
$card->setDatabaseType('mysql');
|
||||
$this->assertEquals($date->format('Y-m-d H:i:s'), $card->getDuedate(false));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user