Fix for NC12 $container->getDb()

This commit is contained in:
brantje 2016-12-19 17:51:59 +01:00
parent c573f2d3de
commit 892965e869
No known key found for this signature in database
GPG key ID: 5FF1D117F918687F
3 changed files with 9 additions and 9 deletions

View file

@ -329,7 +329,7 @@
delete _credential.shared_key;
var _useKey = (key != null);
var regex = /(<([^>]+)>)/ig;
if(_credential.description && _credential.description != "") {
if(_credential.description && _credential.description !== "") {
_credential.description = _credential.description.replace(regex, "");
}
CredentialService.updateCredential(_credential, _useKey).then(function () {

View file

@ -36,6 +36,7 @@ use OCA\Passman\Service\FileService;
use OCA\Passman\Service\VaultService;
use OCA\Passman\Utility\Utils;
use OCA\Passman\Service\NotificationService;
use OCP\IDBConnection;
use OCP\AppFramework\App;
use OCP\IL10N;
@ -75,7 +76,7 @@ class Application extends App {
/** Cron **/
/** Cron **/
$container->registerService('CronService', function ($c) {
return new CronService(
$c->query('CredentialService'),
@ -83,7 +84,7 @@ class Application extends App {
$c->query('Utils'),
$c->query('NotificationService'),
$c->query('ActivityService'),
$c->query('ServerContainer')->getDb()
$c->query('IDBConnection')
);
});
@ -107,6 +108,7 @@ class Application extends App {
$container->registerAlias('FileService', FileService::class);
$container->registerAlias('ShareService', ShareService::class);
$container->registerAlias('Utils', Utils::class);
$container->registerAlias('IDBConnection', IDBConnection::class);
}
/**

View file

@ -37,7 +37,7 @@ class CronService {
private $notificationService;
private $activityService;
private $db;
public function __construct(CredentialService $credentialService, ILogger $logger, Utils $utils, NotificationService $notificationService, ActivityService $activityService, $db) {
public function __construct(CredentialService $credentialService, ILogger $logger, Utils $utils, NotificationService $notificationService, ActivityService $activityService, IDBConnection $db) {
$this->credentialService = $credentialService;
$this->logger = $logger;
$this->utils = $utils;
@ -54,14 +54,12 @@ class CronService {
$link = ''; // @TODO create direct link to credential
$sql = 'SELECT count(*) as rows from `*PREFIX*notifications` WHERE `subject`= \'credential_expired\' AND object_id=?';
$query = $this->db->prepareQuery($sql);
$id = $credential->getId();
$query->bindParam(1, $id, \PDO::PARAM_INT);
$result = $query->execute();
$result = $this->db->executeQuery($sql, array($id));
$this->logger->debug($credential->getLabel() .' is expired, checking notifications!', array('app' => 'passman'));
if($result->fetchRow()['rows'] === 0) {
$notifications = intval($result->fetch()['rows']);
if($notifications === 0) {
$this->logger->debug($credential->getLabel() .' is expired, adding notification!', array('app' => 'passman'));
$this->activityService->add(
Activity::SUBJECT_ITEM_EXPIRED, array($credential->getLabel(), $credential->getUserId()),
'', array(),