This repository was archived by the owner on Oct 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathSetDefaultDashboardSettings.php
More file actions
152 lines (126 loc) · 5.1 KB
/
Copy pathSetDefaultDashboardSettings.php
File metadata and controls
152 lines (126 loc) · 5.1 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<?php
/*
* Nextcloud - Dashboard App
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author tuxedo-rb
* @copyright TUXEDO Computers GmbH
* @license GNU AGPL version 3 or any later version
* @contributor tuxedo-rb | TUXEDO Computers GmbH | https://www.tuxedocomputers.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Dashboard\Migration;
use OCP\Migration\IRepairStep;
use OCP\Migration\IOutput;
use OCA\Dashboard\Db\DashboardSettings;
use OCA\Dashboard\Db\DashboardSettingsMapper;
use OCP\IConfig;
/**
* writes default settings into table dashboard_settings during app-installation
*
* see also ./dashboard/appinfo/info.xml
*/
class SetDefaultDashboardSettings implements IRepairStep {
/** @var DashboardSettings */
private $dashboardSettings;
/** @var DashboardSettingsMapper */
private $dashboardSettingsMapper;
/** @var IConfig */
private $config;
/**
* @param DashboardSettings $dashboardSettings
* @param DashboardSettingsMapper $dashboardSettingsMapper
* @param IConfig $config
*/
public function __construct(
DashboardSettings $dashboardSettings,
DashboardSettingsMapper $dashboardSettingsMapper,
IConfig $config
) {
$this->dashboardSettings = $dashboardSettings;
$this->dashboardSettingsMapper = $dashboardSettingsMapper;
$this->config = $config;
}
public function getName() {
return 'set default Dashboard settings';
}
/**
* @param IOutput $output
*/
public function run(IOutput $output) {
// enabling the app is not the only one event which triggers install
if ($this->config->getAppValue('dashboard', 'setDefaultDashboardSettings') === 'yes') {
$output->info('default Dashboard settings already saved');
return;
}
$this->dashboardSettings->setId(1);
$this->dashboardSettings->setKey('show_activity');
$this->dashboardSettings->setValue(1);
$this->dashboardSettingsMapper->insert($this->dashboardSettings);
$this->dashboardSettings->setId(2);
$this->dashboardSettings->setKey('show_inbox');
$this->dashboardSettings->setValue(1);
$this->dashboardSettingsMapper->insert($this->dashboardSettings);
$this->dashboardSettings->setId(3);
$this->dashboardSettings->setKey('show_announcement');
$this->dashboardSettings->setValue(1);
$this->dashboardSettingsMapper->insert($this->dashboardSettings);
$this->dashboardSettings->setId(4);
$this->dashboardSettings->setKey('show_calendar');
$this->dashboardSettings->setValue(1);
$this->dashboardSettingsMapper->insert($this->dashboardSettings);
$this->dashboardSettings->setId(5);
$this->dashboardSettings->setKey('show_wide_activity');
$this->dashboardSettings->setValue(0);
$this->dashboardSettingsMapper->insert($this->dashboardSettings);
$this->dashboardSettings->setId(6);
$this->dashboardSettings->setKey('show_wide_inbox');
$this->dashboardSettings->setValue(0);
$this->dashboardSettingsMapper->insert($this->dashboardSettings);
$this->dashboardSettings->setId(7);
$this->dashboardSettings->setKey('show_wide_announcement');
$this->dashboardSettings->setValue(0);
$this->dashboardSettingsMapper->insert($this->dashboardSettings);
$this->dashboardSettings->setId(8);
$this->dashboardSettings->setKey('show_wide_calendar');
$this->dashboardSettings->setValue(0);
$this->dashboardSettingsMapper->insert($this->dashboardSettings);
$this->dashboardSettings->setId(9);
$this->dashboardSettings->setKey('activity_position');
$this->dashboardSettings->setValue(1);
$this->dashboardSettingsMapper->insert($this->dashboardSettings);
$this->dashboardSettings->setId(10);
$this->dashboardSettings->setKey('inbox_position');
$this->dashboardSettings->setValue(2);
$this->dashboardSettingsMapper->insert($this->dashboardSettings);
$this->dashboardSettings->setId(11);
$this->dashboardSettings->setKey('announcement_position');
$this->dashboardSettings->setValue(3);
$this->dashboardSettingsMapper->insert($this->dashboardSettings);
$this->dashboardSettings->setId(12);
$this->dashboardSettings->setKey('calendar_position');
$this->dashboardSettings->setValue(4);
$this->dashboardSettingsMapper->insert($this->dashboardSettings);
$this->dashboardSettings->setId(13);
$this->dashboardSettings->setKey('show_quota');
$this->dashboardSettings->setValue(1);
$this->dashboardSettingsMapper->insert($this->dashboardSettings);
$this->config->setAppValue('dashboard', 'setDefaultDashboardSettings', 'yes');
$output->info("initial default Dashboard settings saved");
}
}