summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/models/issue.rb10
-rw-r--r--app/views/issues/change_status.rhtml2
-rw-r--r--app/views/issues/edit.rhtml2
-rw-r--r--app/views/projects/add_issue.rhtml2
-rw-r--r--app/views/roles/_form.rhtml2
-rw-r--r--db/migrate/059_add_roles_assignable.rb9
-rw-r--r--lang/bg.yml1
-rw-r--r--lang/de.yml1
-rw-r--r--lang/en.yml1
-rw-r--r--lang/es.yml1
-rw-r--r--lang/fr.yml1
-rw-r--r--lang/it.yml1
-rw-r--r--lang/ja.yml1
-rw-r--r--lang/nl.yml1
-rw-r--r--lang/pt-br.yml1
-rw-r--r--lang/pt.yml1
-rw-r--r--lang/sv.yml1
-rw-r--r--lang/zh.yml1
18 files changed, 36 insertions, 3 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb
index a73160e57..0e9e7745a 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -59,6 +59,11 @@ class Issue < ActiveRecord::Base
if start_date && soonest_start && start_date < soonest_start
errors.add :start_date, :activerecord_error_invalid
end
+
+ # validate assignment
+ if assigned_to && !assignable_users.include?(assigned_to)
+ errors.add :assigned_to_id, :activerecord_error_invalid
+ end
end
def before_create
@@ -105,6 +110,11 @@ class Issue < ActiveRecord::Base
@current_journal
end
+ # Users the issue can be assigned to
+ def assignable_users
+ project.members.select {|m| m.role.assignable?}.collect {|m| m.user}
+ end
+
def spent_hours
@spent_hours ||= time_entries.sum(:hours) || 0
end
diff --git a/app/views/issues/change_status.rhtml b/app/views/issues/change_status.rhtml
index 550a5d6e0..79a4412db 100644
--- a/app/views/issues/change_status.rhtml
+++ b/app/views/issues/change_status.rhtml
@@ -10,7 +10,7 @@
<div class="box">
<div class="splitcontentleft">
<p><label><%=l(:label_issue_status_new)%></label> <%= @new_status.name %></p>
-<p><%= f.select :assigned_to_id, (@issue.project.members.collect {|m| [m.name, m.user_id]}), :include_blank => true %></p>
+<p><%= f.select :assigned_to_id, (@issue.assignable_users.collect {|m| [m.name, m.id]}), :include_blank => true %></p>
<p><%= f.select :done_ratio, ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }) %></p>
<p><%= f.select :fixed_version_id, (@project.versions.sort.collect {|v| [v.name, v.id]}), { :include_blank => true } %></p>
</div>
diff --git a/app/views/issues/edit.rhtml b/app/views/issues/edit.rhtml
index 18d6e0108..f131041ed 100644
--- a/app/views/issues/edit.rhtml
+++ b/app/views/issues/edit.rhtml
@@ -7,7 +7,7 @@
<div class="splitcontentleft">
<p><label><%=l(:field_status)%></label> <%= @issue.status.name %></p>
<p><%= f.select :priority_id, (@priorities.collect {|p| [p.name, p.id]}), :required => true %></p>
-<p><%= f.select :assigned_to_id, (@issue.project.members.collect {|m| [m.name, m.user_id]}), :include_blank => true %></p>
+<p><%= f.select :assigned_to_id, (@issue.assignable_users.collect {|m| [m.name, m.id]}), :include_blank => true %></p>
<p><%= f.select :category_id, (@project.issue_categories.collect {|c| [c.name, c.id]}), :include_blank => true %>
<%= prompt_to_remote(l(:label_issue_category_new),
l(:label_issue_category_new), 'category[name]',
diff --git a/app/views/projects/add_issue.rhtml b/app/views/projects/add_issue.rhtml
index d35f7f484..1793ef1d8 100644
--- a/app/views/projects/add_issue.rhtml
+++ b/app/views/projects/add_issue.rhtml
@@ -9,7 +9,7 @@
<div class="splitcontentleft">
<p><%= f.select :status_id, (@allowed_statuses.collect {|p| [p.name, p.id]}), :required => true %></p>
<p><%= f.select :priority_id, (@priorities.collect {|p| [p.name, p.id]}), :required => true %></p>
-<p><%= f.select :assigned_to_id, (@issue.project.members.collect {|m| [m.name, m.user_id]}), :include_blank => true %></p>
+<p><%= f.select :assigned_to_id, (@issue.assignable_users.collect {|m| [m.name, m.id]}), :include_blank => true %></p>
<p><%= f.select :category_id, (@project.issue_categories.collect {|c| [c.name, c.id]}), :include_blank => true %>
<%= prompt_to_remote(l(:label_issue_category_new),
l(:label_issue_category_new), 'category[name]',
diff --git a/app/views/roles/_form.rhtml b/app/views/roles/_form.rhtml
index a80d990f9..d69fff132 100644
--- a/app/views/roles/_form.rhtml
+++ b/app/views/roles/_form.rhtml
@@ -2,6 +2,8 @@
<div class="box">
<!--[form:role]-->
<p><%= f.text_field :name, :required => true %></p>
+<p><%= f.check_box :assignable %></p>
+<div class="clear"></div>
<h3><%=l(:label_permissions)%></h3>
<% permissions = @permissions.group_by {|p| p.group_id } %>
diff --git a/db/migrate/059_add_roles_assignable.rb b/db/migrate/059_add_roles_assignable.rb
new file mode 100644
index 000000000..a1ba79634
--- /dev/null
+++ b/db/migrate/059_add_roles_assignable.rb
@@ -0,0 +1,9 @@
+class AddRolesAssignable < ActiveRecord::Migration
+ def self.up
+ add_column :roles, :assignable, :boolean, :default => true
+ end
+
+ def self.down
+ remove_column :roles, :assignable
+ end
+end
diff --git a/lang/bg.yml b/lang/bg.yml
index 337b167b5..9f616532d 100644
--- a/lang/bg.yml
+++ b/lang/bg.yml
@@ -155,6 +155,7 @@ field_identifier: Идентификатор
field_is_filter: Използва се за филтър
field_issue_to_id: Related issue
field_delay: Delay
+field_assignable: Issues can be assigned to this role
setting_app_title: Заглавие
setting_app_subtitle: Описание
diff --git a/lang/de.yml b/lang/de.yml
index 32ad4bcee..da9f7ff89 100644
--- a/lang/de.yml
+++ b/lang/de.yml
@@ -155,6 +155,7 @@ field_identifier: Identifier
field_is_filter: Used as a filter
field_issue_to_id: Related issue
field_delay: Delay
+field_assignable: Issues can be assigned to this role
setting_app_title: Applikation Titel
setting_app_subtitle: Applikation Untertitel
diff --git a/lang/en.yml b/lang/en.yml
index 3488ee345..c7dd0d2ef 100644
--- a/lang/en.yml
+++ b/lang/en.yml
@@ -155,6 +155,7 @@ field_identifier: Identifier
field_is_filter: Used as a filter
field_issue_to_id: Related issue
field_delay: Delay
+field_assignable: Issues can be assigned to this role
setting_app_title: Application title
setting_app_subtitle: Application subtitle
diff --git a/lang/es.yml b/lang/es.yml
index 26eca0bca..5bf61df6a 100644
--- a/lang/es.yml
+++ b/lang/es.yml
@@ -155,6 +155,7 @@ field_identifier: Identifier
field_is_filter: Used as a filter
field_issue_to_id: Related issue
field_delay: Delay
+field_assignable: Issues can be assigned to this role
setting_app_title: Título del aplicación
setting_app_subtitle: Subtítulo del aplicación
diff --git a/lang/fr.yml b/lang/fr.yml
index 364359787..ca1fb16be 100644
--- a/lang/fr.yml
+++ b/lang/fr.yml
@@ -155,6 +155,7 @@ field_identifier: Identifiant
field_is_filter: Utilisé comme filtre
field_issue_to_id: Demande liée
field_delay: Retard
+field_assignable: Demandes assignables à ce rôle
setting_app_title: Titre de l'application
setting_app_subtitle: Sous-titre de l'application
diff --git a/lang/it.yml b/lang/it.yml
index d3f04b9c6..b568873e7 100644
--- a/lang/it.yml
+++ b/lang/it.yml
@@ -155,6 +155,7 @@ field_identifier: Identifier
field_is_filter: Used as a filter
field_issue_to_id: Related issue
field_delay: Delay
+field_assignable: Issues can be assigned to this role
setting_app_title: Titolo applicazione
setting_app_subtitle: Sottotitolo applicazione
diff --git a/lang/ja.yml b/lang/ja.yml
index 703652bcc..87fe5eb36 100644
--- a/lang/ja.yml
+++ b/lang/ja.yml
@@ -156,6 +156,7 @@ field_identifier: 識別子
field_is_filter: フィルタとして使う
field_issue_to_id: 関連する問題
field_delay: 遅延
+field_assignable: Issues can be assigned to this role
setting_app_title: アプリケーションのタイトル
setting_app_subtitle: アプリケーションのサブタイトル
diff --git a/lang/nl.yml b/lang/nl.yml
index 29b7751c5..b80467aec 100644
--- a/lang/nl.yml
+++ b/lang/nl.yml
@@ -155,6 +155,7 @@ field_identifier: Identificatiecode
field_is_filter: Gebruikt als een filter
field_issue_to_id: Gerelateerd issue
field_delay: Vertraging
+field_assignable: Issues can be assigned to this role
setting_app_title: Applicatie titel
setting_app_subtitle: Applicatie ondertitel
diff --git a/lang/pt-br.yml b/lang/pt-br.yml
index 7196db856..d7ac1ef5d 100644
--- a/lang/pt-br.yml
+++ b/lang/pt-br.yml
@@ -155,6 +155,7 @@ field_identifier: Identificador
field_is_filter: Used as a filter
field_issue_to_id: Related issue
field_delay: Delay
+field_assignable: Issues can be assigned to this role
setting_app_title: Titulo da aplicacao
setting_app_subtitle: Sub-titulo da aplicacao
diff --git a/lang/pt.yml b/lang/pt.yml
index face383c8..b0b2210fc 100644
--- a/lang/pt.yml
+++ b/lang/pt.yml
@@ -155,6 +155,7 @@ field_identifier: Identificador
field_is_filter: Usado como filtro
field_issue_to_id: Tarefa relacionada
field_delay: Atraso
+field_assignable: Issues can be assigned to this role
setting_app_title: Título da aplicação
setting_app_subtitle: Sub-título da aplicação
diff --git a/lang/sv.yml b/lang/sv.yml
index 70cb15c3d..8b0254602 100644
--- a/lang/sv.yml
+++ b/lang/sv.yml
@@ -155,6 +155,7 @@ field_identifier: Identifierare
field_is_filter: Used as a filter
field_issue_to_id: Related issue
field_delay: Delay
+field_assignable: Issues can be assigned to this role
setting_app_title: Applikationstitel
setting_app_subtitle: Applicationsunderrubrik
diff --git a/lang/zh.yml b/lang/zh.yml
index de8cfdb7f..7a7ec7b3e 100644
--- a/lang/zh.yml
+++ b/lang/zh.yml
@@ -158,6 +158,7 @@ field_identifier: Identifier
field_is_filter: Used as a filter
field_issue_to_id: Related issue
field_delay: Delay
+field_assignable: Issues can be assigned to this role
setting_app_title: 应用程序标题
setting_app_subtitle: 应用程序子标题
rt/48044/stable29'>backport/48044/stable29 Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/lib/Command/ExiprationNotification.php
blob: b7ea5c5f14e9216ed89570f6ce8b6622bdf0d5f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php

declare(strict_types=1);

/**
 * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */
namespace OCA\Files_Sharing\Command;

use OCA\Files_Sharing\OrphanHelper;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\IDBConnection;
use OCP\Notification\IManager as NotificationManager;
use OCP\Share\IManager as ShareManager;
use OCP\Share\IShare;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class ExiprationNotification extends Command {
	public function __construct(
		private ITimeFactory $time,
		private NotificationManager $notificationManager,
		private IDBConnection $connection,
		private ShareManager $shareManager,
		private OrphanHelper $orphanHelper,
	) {
		parent::__construct();
	}

	protected function configure() {
		$this
			->setName('sharing:expiration-notification')
			->setDescription('Notify share initiators when a share will expire the next day.');
	}

	public function execute(InputInterface $input, OutputInterface $output): int {
		//Current time
		$minTime = $this->time->getDateTime();
		$minTime->add(new \DateInterval('P1D'));
		$minTime->setTime(0, 0, 0);

		$maxTime = clone $minTime;
		$maxTime->setTime(23, 59, 59);

		$shares = $this->shareManager->getAllShares();

		$now = $this->time->getDateTime();

		/** @var IShare $share */
		foreach ($shares as $share) {
			if ($share->getExpirationDate() === null
				|| $share->getExpirationDate()->getTimestamp() < $minTime->getTimestamp()
				|| $share->getExpirationDate()->getTimestamp() > $maxTime->getTimestamp()
				|| !$this->orphanHelper->isShareValid($share->getSharedBy(), $share->getNodeId())) {
				continue;
			}

			$notification = $this->notificationManager->createNotification();
			$notification->setApp('files_sharing')
				->setDateTime($now)
				->setObject('share', $share->getFullId())
				->setSubject('expiresTomorrow');

			// Only send to initiator for now
			$notification->setUser($share->getSharedBy());
			$this->notificationManager->notify($notification);
		}
		return 0;
	}
}