Merge pull request #318 from owncloud/deprecation-cleanup-8.1

Deprecation cleanup after 8.1
This commit is contained in:
Joas Schilling 2015-07-02 11:13:41 +02:00
Родитель 1e397f53de 139bddd48f
Коммит 8d22b745b5
15 изменённых файлов: 136 добавлений и 58 удалений

Просмотреть файл

@ -33,7 +33,6 @@ use OCA\Activity\Display;
use OCA\Activity\GroupHelper;
use OCA\Activity\FilesHooks;
use OCA\Activity\MailQueueHandler;
use OCA\Activity\MockUtilSendMail;
use OCA\Activity\Navigation;
use OCA\Activity\ParameterHelper;
use OCA\Activity\UserSettings;
@ -112,9 +111,13 @@ class Application extends App {
});
$container->registerService('Hooks', function(IContainer $c) {
/** @var \OC\Server $server */
$server = $c->query('ServerContainer');
return new FilesHooks(
$c->query('ActivityData'),
$c->query('UserSettings'),
$server->getDatabaseConnection(),
$c->query('CurrentUID')
);
});
@ -196,6 +199,9 @@ class Application extends App {
});
$container->registerService('ActivitiesController', function(IContainer $c) {
/** @var \OC\Server $server */
$server = $c->query('ServerContainer');
return new Activities(
$c->query('AppName'),
$c->query('Request'),
@ -204,6 +210,7 @@ class Application extends App {
$c->query('GroupHelper'),
$c->query('Navigation'),
$c->query('UserSettings'),
$server->getDateTimeFormatter(),
$c->query('CurrentUID')
);
});

Просмотреть файл

@ -1,6 +1,7 @@
<?php
$installedVersion = \OCP\Config::getAppValue('activity', 'installed_version');
$installedVersion = \OC::$server->getConfig()->getAppValue('activity', 'installed_version');
$connection = \OC::$server->getDatabaseConnection();
if (version_compare($installedVersion, '1.2.2', '<')) {
$mistakes = [
@ -11,18 +12,16 @@ if (version_compare($installedVersion, '1.2.2', '<')) {
foreach ($mistakes as $entry) {
list($table, $column) = $entry;
$query = \OCP\DB::prepare(
$numEntries = $connection->executeUpdate(
'DELETE FROM `' . $table . '` WHERE `' . $column . "` NOT LIKE '%]' AND `" . $column . "` NOT LIKE '%}'"
);
$numEntries = $query->execute();
\OC::$server->getLogger()->debug('Deleting ' . $numEntries . ' activities with a broken ' . $column . ' value.', ['app' => 'acitivity']);
}
}
if (version_compare($installedVersion, '1.2.2', '<')) {
$update = \OCP\DB::prepare('UPDATE `*PREFIX*activity` SET `app` = ? WHERE `type` = ?');
$update->execute(array('files_sharing', 'shared'));
$update = \OCP\DB::prepare('UPDATE `*PREFIX*activity_mq` SET `amq_appid` = ? WHERE `amq_type` = ?');
$update->execute(array('files_sharing', 'shared'));
$connection->executeUpdate('UPDATE `*PREFIX*activity` SET `app` = ? WHERE `type` = ?', array('files_sharing', 'shared'));
$connection->executeUpdate('UPDATE `*PREFIX*activity_mq` SET `amq_appid` = ? WHERE `amq_type` = ?', array('files_sharing', 'shared'));
}

Просмотреть файл

@ -23,7 +23,6 @@
namespace OCA\Activity\Controller;
use OC\Files\View;
use OCA\Activity\Data;
use OCA\Activity\Display;
use OCA\Activity\GroupHelper;
@ -31,6 +30,7 @@ use OCA\Activity\Navigation;
use OCA\Activity\UserSettings;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IDateTimeFormatter;
use OCP\IRequest;
class Activities extends Controller {
@ -51,6 +51,9 @@ class Activities extends Controller {
/** @var \OCA\Activity\UserSettings */
protected $settings;
/** @var IDateTimeFormatter */
protected $dateTimeFormatter;
/** @var string */
protected $user;
@ -64,15 +67,25 @@ class Activities extends Controller {
* @param GroupHelper $helper
* @param Navigation $navigation
* @param UserSettings $settings
* @param IDateTimeFormatter $dateTimeFormatter
* @param string $user
*/
public function __construct($appName, IRequest $request, Data $data, Display $display, GroupHelper $helper, Navigation $navigation, UserSettings $settings, $user) {
public function __construct($appName,
IRequest $request,
Data $data,
Display $display,
GroupHelper $helper,
Navigation $navigation,
UserSettings $settings,
IDateTimeFormatter $dateTimeFormatter,
$user) {
parent::__construct($appName, $request);
$this->data = $data;
$this->display = $display;
$this->helper = $helper;
$this->navigation = $navigation;
$this->settings = $settings;
$this->dateTimeFormatter = $dateTimeFormatter;
$this->user = $user;
}
@ -106,6 +119,7 @@ class Activities extends Controller {
return new TemplateResponse('activity', 'stream.list', [
'activity' => $this->data->read($this->helper, $this->settings, $pageOffset * self::DEFAULT_PAGE_SIZE, self::DEFAULT_PAGE_SIZE, $filter),
'displayHelper' => $this->display,
'dateTimeFormatter' => $this->dateTimeFormatter,
], '');
}
}

Просмотреть файл

@ -69,7 +69,15 @@ class Settings extends Controller {
* @param IL10N $l10n
* @param string $user
*/
public function __construct($appName, IRequest $request, IConfig $config, ISecureRandom $random, IURLGenerator $urlGenerator, Data $data, UserSettings $userSettings, IL10N $l10n, $user) {
public function __construct($appName,
IRequest $request,
IConfig $config,
ISecureRandom $random,
IURLGenerator $urlGenerator,
Data $data,
UserSettings $userSettings,
IL10N $l10n,
$user) {
parent::__construct($appName, $request);
$this->config = $config;
$this->random = $random;

Просмотреть файл

@ -8,11 +8,12 @@ $(document).ready(function() {
});
}
$('#activity_notifications input[type=checkbox]').change(saveSettings);
var $activityNotifications = $('#activity_notifications');
$activityNotifications.find('input[type=checkbox]').change(saveSettings);
$('#activity_notifications select').change(saveSettings);
$activityNotifications.find('select').change(saveSettings);
$('#activity_notifications .activity_select_group').click(function() {
$activityNotifications.find('.activity_select_group').click(function() {
var selectGroup = '#activity_notifications .' + $(this).attr('data-select-group');
var checkedBoxes = $(selectGroup + ':checked').length;
$(selectGroup).attr('checked', true);

Просмотреть файл

@ -32,7 +32,7 @@ class Api
{
const DEFAULT_LIMIT = 30;
static public function get($param) {
static public function get() {
$app = new AppInfo\Application();
$data = $app->getContainer()->query('ActivityData');

Просмотреть файл

@ -23,6 +23,7 @@
namespace OCA\Activity\BackgroundJob;
use OC\BackgroundJob\TimedJob;
use OCA\Activity\AppInfo\Application;
use OCA\Activity\MailQueueHandler;
use OCP\IConfig;
@ -33,7 +34,7 @@ use OCP\ILogger;
*
* @package OCA\Activity\BackgroundJob
*/
class EmailNotification extends \OC\BackgroundJob\TimedJob {
class EmailNotification extends TimedJob {
const CLI_EMAIL_BATCH_SIZE = 500;
const WEB_EMAIL_BATCH_SIZE = 25;
@ -72,7 +73,7 @@ class EmailNotification extends \OC\BackgroundJob\TimedJob {
}
}
public function fixDIForJobs() {
protected function fixDIForJobs() {
$application = new Application();
$this->mqHandler = $application->getContainer()->query('MailQueueHandler');

Просмотреть файл

@ -23,23 +23,48 @@
namespace OCA\Activity\BackgroundJob;
use OC\BackgroundJob\TimedJob;
use OCA\Activity\AppInfo\Application;
use OCA\Activity\Data;
use OCP\IConfig;
/**
* Class ExpireActivities
*
* @package OCA\Activity\BackgroundJob
*/
class ExpireActivities extends \OC\BackgroundJob\TimedJob {
public function __construct() {
class ExpireActivities extends TimedJob {
/** @var Data */
protected $data;
/** @var IConfig */
protected $config;
/**
* @param Data $data
* @param IConfig $config
*/
public function __construct(Data $data = null, IConfig $config = null) {
// Run once per day
$this->setInterval(60 * 60 * 24);
if ($data === null || $config === null) {
$this->fixDIForJobs();
} else {
$this->data = $data;
$this->config = $config;
}
}
protected function fixDIForJobs() {
$application = new Application();
$this->data = $application->getContainer()->query('ActivityData');
$this->config = \OC::$server->getConfig();
}
protected function run($argument) {
// Remove activities that are older then one year
$expireDays = \OCP\Config::getSystemValue('activity_expire_days', 365);
$data = new \OCA\Activity\Data(
\OC::$server->getActivityManager()
);
$data->expire($expireDays);
$expireDays = $this->config->getSystemValue('activity_expire_days', 365);
$this->data->expire($expireDays);
}
}

Просмотреть файл

@ -24,9 +24,11 @@
namespace OCA\Activity;
use OC\Files\View;
use OCP\Files;
use OCP\IDateTimeFormatter;
use OCP\IPreview;
use OCP\IURLGenerator;
use OCP\Template;
use OCP\User;
use OCP\Util;
/**
* Class Display
@ -34,13 +36,13 @@ use OCP\Util;
* @package OCA\Activity
*/
class Display {
/** @var \OCP\IDateTimeFormatter */
/** @var IDateTimeFormatter */
protected $dateTimeFormatter;
/** @var \OCP\IPreview */
/** @var IPreview */
protected $preview;
/** @var \OCP\IURLGenerator */
/** @var IURLGenerator */
protected $urlGenerator;
/** @var View */
@ -49,15 +51,15 @@ class Display {
/**
* Constructor
*
* @param \OCP\IDateTimeFormatter $dateTimeFormatter
* @param \OCP\IPreview $preview
* @param \OCP\IURLGenerator $urlGenerator
* @param IDateTimeFormatter $dateTimeFormatter
* @param IPreview $preview
* @param IURLGenerator $urlGenerator
* @param View $view
*/
public function __construct(\OCP\IDateTimeFormatter $dateTimeFormatter,
\OCP\IPreview $preview,
\OCP\IURLGenerator $urlGenerator,
\OC\Files\View $view) {
public function __construct(IDateTimeFormatter $dateTimeFormatter,
IPreview $preview,
IURLGenerator $urlGenerator,
View $view) {
$this->view = $view;
$this->preview = $preview;
$this->dateTimeFormatter = $dateTimeFormatter;
@ -74,8 +76,6 @@ class Display {
$tmpl = new Template('activity', 'stream.item');
$tmpl->assign('formattedDate', $this->dateTimeFormatter->formatDateTime($activity['timestamp']));
$tmpl->assign('formattedTimestamp', Template::relative_modified_date($activity['timestamp']));
$tmpl->assign('user', $activity['user']);
$tmpl->assign('displayName', User::getDisplayName($activity['user']));
if (strpos($activity['subjectformatted']['markup']['trimmed'], '<a ') !== false) {
// We do not link the subject as we create links for the parameters instead
@ -91,7 +91,7 @@ class Display {
$tmpl->assign('previewLink', $this->getPreviewLink($activity['file'], $is_dir));
// show a preview image if the file still exists
$mimeType = \OCP\Files::getMimeType($activity['file']);
$mimeType = Files::getMimeType($activity['file']);
if ($mimeType && !$is_dir && $this->preview->isMimeSupported($mimeType) && $exist) {
$tmpl->assign('previewImageLink',
$this->urlGenerator->linkToRoute('core_ajax_preview', array(

Просмотреть файл

@ -27,7 +27,7 @@ use OC\Files\View;
use OCA\Activity\Extension\Files;
use OCA\Activity\Extension\Files_Sharing;
use OCP\Activity\IExtension;
use OCP\DB;
use OCP\IDBConnection;
use OCP\Share;
use OCP\Util;
@ -42,6 +42,9 @@ class FilesHooks {
/** @var \OCA\Activity\UserSettings */
protected $userSettings;
/** @var \OCP\IDBConnection */
protected $connection;
/** @var string|false */
protected $currentUser;
@ -50,11 +53,13 @@ class FilesHooks {
*
* @param Data $activityData
* @param UserSettings $userSettings
* @param IDBConnection $connection
* @param string|false $currentUser
*/
public function __construct(Data $activityData, UserSettings $userSettings, $currentUser) {
public function __construct(Data $activityData, UserSettings $userSettings, IDBConnection $connection, $currentUser) {
$this->activityData = $activityData;
$this->userSettings = $userSettings;
$this->connection = $connection;
$this->currentUser = $currentUser;
}
@ -158,8 +163,10 @@ class FilesHooks {
if ($uidOwner !== $this->currentUser) {
Filesystem::initMountPoints($uidOwner);
$info = Filesystem::getFileInfo($path);
$ownerView = new View('/'.$uidOwner.'/files');
$path = $ownerView->getPath($info['fileid']);
if ($info !== false) {
$ownerView = new View('/' . $uidOwner . '/files');
$path = $ownerView->getPath((int) $info['fileid']);
}
}
return array($path, $uidOwner);
@ -228,14 +235,9 @@ class FilesHooks {
// Check when there was a naming conflict and the target is different
// for some of the users
$query = DB::prepare('SELECT `share_with`, `file_target` FROM `*PREFIX*share` WHERE `parent` = ? ');
$result = $query->execute(array($params['id']));
if (DB::isError($result)) {
Util::writeLog('OCA\Activity\Hooks::shareFileOrFolderWithGroup', DB::getErrorMessage($result), Util::ERROR);
} else {
while ($row = $result->fetchRow()) {
$affectedUsers[$row['share_with']] = $row['file_target'];
}
$query = $this->connection->executeQuery('SELECT `share_with`, `file_target` FROM `*PREFIX*share` WHERE `parent` = ? ', [(int) $params['id']]);
while ($row = $query->fetch()) {
$affectedUsers[$row['share_with']] = $row['file_target'];
}
foreach ($affectedUsers as $user => $path) {

Просмотреть файл

@ -26,7 +26,6 @@ namespace OCA\Activity;
use \OCP\Activity\IManager;
use \OCP\IURLGenerator;
use \OCP\Template;
use \OCP\Util;
/**
* Class Navigation
@ -43,6 +42,9 @@ class Navigation {
/** @var \OCP\IURLGenerator */
protected $URLGenerator;
/** @var UserSettings */
protected $userSettings;
/** @var string */
protected $active;
@ -63,7 +65,13 @@ class Navigation {
* @param string $rssToken
* @param null|string $active Navigation entry that should be marked as active
*/
public function __construct(\OC_L10N $l, IManager $manager, IURLGenerator $URLGenerator, UserSettings $userSettings, $user, $rssToken, $active = 'all') {
public function __construct(\OC_L10N $l,
IManager $manager,
IURLGenerator $URLGenerator,
UserSettings $userSettings,
$user,
$rssToken,
$active = 'all') {
$this->l = $l;
$this->activityManager = $manager;
$this->URLGenerator = $URLGenerator;

Просмотреть файл

@ -27,7 +27,6 @@ use OCP\Activity\IManager;
use OCP\IConfig;
use OCP\IL10N;
use OCP\IUserManager;
use OCP\User;
use OCP\Util;
use OC\Files\View;
@ -58,7 +57,12 @@ class ParameterHelper {
* @param IL10N $l
* @param string $user
*/
public function __construct(IManager $activityManager, IUserManager $userManager, View $rootView, IConfig $config, IL10N $l, $user) {
public function __construct(IManager $activityManager,
IUserManager $userManager,
View $rootView,
IConfig $config,
IL10N $l,
$user) {
$this->activityManager = $activityManager;
$this->userManager = $userManager;
$this->rootView = $rootView;

Просмотреть файл

@ -63,7 +63,7 @@ style('activity', 'settings');
<?php endif; ?>
<br />
<?php p($l->t('Send emails:')); ?>
<label for="notify_setting_batchtime"><?php p($l->t('Send emails:')); ?></label>
<select id="notify_setting_batchtime" name="notify_setting_batchtime">
<option value="0"<?php if ($_['setting_batchtime'] === \OCA\Activity\UserSettings::EMAIL_SEND_HOURLY): ?> selected="selected"<?php endif; ?>><?php p($l->t('Hourly')); ?></option>
<option value="1"<?php if ($_['setting_batchtime'] === \OCA\Activity\UserSettings::EMAIL_SEND_DAILY): ?> selected="selected"<?php endif; ?>><?php p($l->t('Daily')); ?></option>

Просмотреть файл

@ -25,13 +25,15 @@
/** @var $theme OC_Defaults */
/** @var $_ array */
/** @var $displayHelper \OCA\Activity\Display */
/** @var $dateTimeFormatter \OCP\IDateTimeFormatter */
$displayHelper = $_['displayHelper'];
$dateTimeFormatter = $_['dateTimeFormatter'];
$lastDate = null;
foreach ($_['activity'] as $event) {
// group by date
// TODO: use more efficient way to group by date (don't group by localized string...)
$currentDate = (string)(\OCP\relative_modified_date($event['timestamp'], true));
$currentDate = (string)(\OCP\Template::relative_modified_date($event['timestamp'], true));
// new date group
if ($currentDate !== $lastDate) {
@ -47,7 +49,7 @@ foreach ($_['activity'] as $event) {
?>
<div class="section activity-section group" data-date="<?php p($currentDate) ?>">
<h2>
<span class="tooltip" title="<?php p(\OCP\Util::formatDate(strip_time($event['timestamp']), true)) ?>">
<span class="tooltip" title="<?php p($dateTimeFormatter->formatDate($event['timestamp'])) ?>">
<?php p(ucfirst($currentDate)) ?>
</span>
</h2>

Просмотреть файл

@ -37,6 +37,9 @@ class ActivitiesTest extends TestCase {
/** @var \PHPUnit_Framework_MockObject_MockObject */
protected $userSettings;
/** @var \PHPUnit_Framework_MockObject_MockObject */
protected $dateTimeFormatter;
/** @var \OCP\IL10N */
protected $l10n;
@ -61,6 +64,9 @@ class ActivitiesTest extends TestCase {
$this->userSettings = $this->getMockBuilder('OCA\Activity\UserSettings')
->disableOriginalConstructor()
->getMock();
$this->dateTimeFormatter = $this->getMockBuilder('OCP\IDateTimeFormatter')
->disableOriginalConstructor()
->getMock();
$this->request = $this->getMock('OCP\IRequest');
@ -72,6 +78,7 @@ class ActivitiesTest extends TestCase {
$this->helper,
$this->navigation,
$this->userSettings,
$this->dateTimeFormatter,
'test'
);
}