зеркало из https://github.com/nextcloud/activity.git
Merge pull request #116 from owncloud/notify-setting-self
Notify setting self
This commit is contained in:
Коммит
93923ea9b3
|
@ -42,5 +42,6 @@ if ($_POST['notify_setting_batchtime'] == \OCA\Activity\UserSettings::EMAIL_SEND
|
|||
$email_batch_time = 3600 * 24 * 7;
|
||||
}
|
||||
OCP\Config::setUserValue(OCP\User::getUser(), 'activity', 'notify_setting_batchtime', $email_batch_time);
|
||||
OCP\Config::setUserValue(OCP\User::getUser(), 'activity', 'notify_setting_self', !empty($_POST['notify_setting_self']));
|
||||
|
||||
OC_JSON::success(array("data" => array( "message" => $l->t('Your settings have been updated.'))));
|
||||
|
|
|
@ -65,9 +65,9 @@ class Data
|
|||
\OCA\Activity\Data::TYPE_SHARED => $l->t('A file or folder has been <strong>shared</strong>'),
|
||||
// \OCA\Activity\Data::TYPE_SHARE_UNSHARED => $l->t('Previously shared file or folder has been <strong>unshared</strong>'),
|
||||
// \OCA\Activity\Data::TYPE_SHARE_EXPIRED => $l->t('Expiration date of shared file or folder <strong>expired</strong>'),
|
||||
\OCA\Activity\Data::TYPE_SHARE_CREATED => $l->t('A new file or folder has been <strong>created</strong> in a shared folder'),
|
||||
\OCA\Activity\Data::TYPE_SHARE_CHANGED => $l->t('A file or folder has been <strong>changed</strong> in a shared folder'),
|
||||
\OCA\Activity\Data::TYPE_SHARE_DELETED => $l->t('A file or folder has been <strong>deleted</strong> from a shared folder'),
|
||||
\OCA\Activity\Data::TYPE_SHARE_CREATED => $l->t('A new file or folder has been <strong>created</strong>'),
|
||||
\OCA\Activity\Data::TYPE_SHARE_CHANGED => $l->t('A file or folder has been <strong>changed</strong>'),
|
||||
\OCA\Activity\Data::TYPE_SHARE_DELETED => $l->t('A file or folder has been <strong>deleted</strong>'),
|
||||
// \OCA\Activity\Data::TYPE_SHARE_RESHARED => $l->t('A file or folder has been <strong>reshared</strong>'),
|
||||
// \OCA\Activity\Data::TYPE_SHARE_DOWNLOADED => $l->t('A file or folder shared via link has been <strong>downloaded</strong>'),
|
||||
// \OCA\Activity\Data::TYPE_SHARE_UPLOADED => $l->t('A file has been <strong>uploaded</strong> into a folder shared via link'),
|
||||
|
|
|
@ -94,6 +94,10 @@ class Hooks {
|
|||
}
|
||||
|
||||
if ($user === \OCP\User::getUser()) {
|
||||
if (!UserSettings::getUserSetting(\OCP\User::getUser(), 'setting', 'self')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$userSubject = $subject;
|
||||
$userParams = array($path);
|
||||
} else {
|
||||
|
@ -164,15 +168,8 @@ class Hooks {
|
|||
* @param array $params The hook params
|
||||
*/
|
||||
public static function shareFileOrFolderWithUser($params) {
|
||||
$file_path = \OC\Files\Filesystem::getPath($params['fileSource']);
|
||||
|
||||
// User performing the share
|
||||
self::addNotificationsForUser(
|
||||
\OCP\User::getUser(), 'shared_user_self', array($file_path, $params['shareWith']),
|
||||
$file_path, ($params['itemType'] === 'file'),
|
||||
UserSettings::getUserSetting(\OCP\User::getUser(), 'stream', Data::TYPE_SHARED),
|
||||
UserSettings::getUserSetting(\OCP\User::getUser(), 'email', Data::TYPE_SHARED) ? UserSettings::getUserSetting(\OCP\User::getUser(), 'setting', 'batchtime') : 0
|
||||
);
|
||||
self::shareNotificationForSharer('shared_user_self', $params['shareWith'], $params['fileSource'], $params['itemType']);
|
||||
|
||||
// New shared user
|
||||
$path = $params['fileTarget'];
|
||||
|
@ -189,15 +186,8 @@ class Hooks {
|
|||
* @param array $params The hook params
|
||||
*/
|
||||
public static function shareFileOrFolderWithGroup($params) {
|
||||
$file_path = \OC\Files\Filesystem::getPath($params['fileSource']);
|
||||
|
||||
// User performing the share
|
||||
self::addNotificationsForUser(
|
||||
\OCP\User::getUser(), 'shared_group_self', array($file_path, $params['shareWith']),
|
||||
$file_path, ($params['itemType'] === 'file'),
|
||||
UserSettings::getUserSetting(\OCP\User::getUser(), 'stream', Data::TYPE_SHARED),
|
||||
UserSettings::getUserSetting(\OCP\User::getUser(), 'email', Data::TYPE_SHARED) ? UserSettings::getUserSetting(\OCP\User::getUser(), 'setting', 'batchtime') : 0
|
||||
);
|
||||
self::shareNotificationForSharer('shared_group_self', $params['shareWith'], $params['fileSource'], $params['itemType']);
|
||||
|
||||
// Members of the new group
|
||||
$affectedUsers = array();
|
||||
|
@ -242,6 +232,28 @@ class Hooks {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add notifications for the user that shares a file/folder
|
||||
*
|
||||
* @param string $subject
|
||||
* @param string $shareWith
|
||||
* @param int $fileSource
|
||||
* @param string $itemType
|
||||
*/
|
||||
public static function shareNotificationForSharer($subject, $shareWith, $fileSource, $itemType) {
|
||||
// User performing the share
|
||||
if (UserSettings::getUserSetting(\OCP\User::getUser(), 'setting', 'self')) {
|
||||
$file_path = \OC\Files\Filesystem::getPath($fileSource);
|
||||
|
||||
self::addNotificationsForUser(
|
||||
\OCP\User::getUser(), $subject, array($file_path, $shareWith),
|
||||
$file_path, ($itemType === 'file'),
|
||||
UserSettings::getUserSetting(\OCP\User::getUser(), 'stream', Data::TYPE_SHARED),
|
||||
UserSettings::getUserSetting(\OCP\User::getUser(), 'email', Data::TYPE_SHARED) ? UserSettings::getUserSetting(\OCP\User::getUser(), 'setting', 'batchtime') : 0
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the activity and email for a user when the settings require it
|
||||
*
|
||||
|
@ -277,12 +289,14 @@ class Hooks {
|
|||
* @param array $params The hook params
|
||||
*/
|
||||
public static function shareFileOrFolder($params) {
|
||||
$path = \OC\Files\Filesystem::getPath($params['fileSource']);
|
||||
$link = \OCP\Util::linkToAbsolute('files', 'index.php', array(
|
||||
'dir' => ($params['itemType'] === 'file') ? dirname($path) : $path,
|
||||
));
|
||||
if (UserSettings::getUserSetting(\OCP\User::getUser(), 'setting', 'self') &&
|
||||
UserSettings::getUserSetting(\OCP\User::getUser(), 'stream', Data::TYPE_SHARED)) {
|
||||
|
||||
$path = \OC\Files\Filesystem::getPath($params['fileSource']);
|
||||
$link = \OCP\Util::linkToAbsolute('files', 'index.php', array(
|
||||
'dir' => ($params['itemType'] === 'file') ? dirname($path) : $path,
|
||||
));
|
||||
|
||||
if (UserSettings::getUserSetting(\OCP\User::getUser(), 'stream', Data::TYPE_SHARED)) {
|
||||
Data::send('files', 'shared_link_self', array($path), '', array(), $path, $link, \OCP\User::getUser(), Data::TYPE_SHARED, Data::PRIORITY_MEDIUM);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ class UserSettings
|
|||
*
|
||||
* @param string $user
|
||||
* @param string $method Should be one of 'stream', 'email' or 'setting'
|
||||
* @param string $type One of the activity types or 'batchtime'
|
||||
* @param string $type One of the activity types, 'batchtime' or 'self'
|
||||
* @return mixed
|
||||
*/
|
||||
public static function getUserSetting($user, $method, $type) {
|
||||
|
@ -59,12 +59,16 @@ class UserSettings
|
|||
* Get a good default setting for a preference
|
||||
*
|
||||
* @param string $method Should be one of 'stream', 'email' or 'setting'
|
||||
* @param string $type One of the activity types or 'batchtime'
|
||||
* @param string $type One of the activity types, 'batchtime' or 'self'
|
||||
* @return bool|int
|
||||
*/
|
||||
public static function getDefaultSetting($method, $type) {
|
||||
if ($method == 'setting' && $type == 'batchtime') {
|
||||
return 3600;
|
||||
if ($method == 'setting') {
|
||||
if ($type == 'batchtime') {
|
||||
return 3600;
|
||||
} else if ($type == 'self') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
$settings = self::getDefaultTypes($method);
|
||||
|
|
|
@ -48,5 +48,6 @@ else {
|
|||
$template->assign('setting_batchtime', \OCA\Activity\UserSettings::EMAIL_SEND_HOURLY);
|
||||
}
|
||||
$template->assign('activity_email', \OCP\Config::getUserValue($user, 'settings', 'email', ''));
|
||||
$template->assign('notify_self', \OCA\Activity\UserSettings::getUserSetting($user, 'setting', 'self'));
|
||||
|
||||
return $template->fetchPage();
|
||||
|
|
|
@ -44,6 +44,12 @@
|
|||
</tbody>
|
||||
</table>
|
||||
|
||||
<br />
|
||||
<input id="notify_setting_self" name="notify_setting_self" type="checkbox"
|
||||
value="1" <?php if ($_['notify_self']): ?> checked="checked"<?php endif; ?> />
|
||||
<label for="notify_setting_self"><?php p($l->t('Notify about my own actions')); ?></label>
|
||||
<br />
|
||||
|
||||
<?php if (empty($_['activity_email'])): ?>
|
||||
<br />
|
||||
<strong><?php p($l->t('You need to set up your email address before you can receive notification emails.')); ?></strong>
|
||||
|
|
Загрузка…
Ссылка в новой задаче