forked from dehnhardt/nc_dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroutewidgetmanagementcontroller.php
executable file
·98 lines (84 loc) · 2.37 KB
/
routewidgetmanagementcontroller.php
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
<?php
/**
* Created by PhpStorm.
* User: flost
* Date: 27.04.15
* Time: 20:54
*/
namespace OCA\Dashboard\Controller;
use OCA\Dashboard\Services\WidgetManagementService;
use OCP\AppFramework\Controller;
use OCP\IL10N;
use OCP\IRequest;
use OCP\Util;
class RouteWidgetManagementController extends Controller {
private $widgetManagementService;
private $L10N;
public function __construct($appName, IRequest $request, $user, WidgetManagementService $widgetManagementService, IL10N $l10n){
parent::__construct($appName, $request);
$this->user = $user;
$this->widgetManagementService = $widgetManagementService;
$this->L10N = $l10n;
}
/**
*
* return a array of widgets for this user
*
* @NoAdminRequired
* @return array
*/
public function getEnabledWidgets() {
return $this->widgetManagementService->getEnabled();
}
/**
*
* return a array of widgets that are available
*
* @NoAdminRequired
* @return array
*/
public function getAvailableWidgets() {
return $this->widgetManagementService->getAvailable(true);
}
/**
*
* returns the basic conf as array
* includes wId, name, refresh, icon
*
* @NoAdminRequired
* @param $wId
* @return array
*/
public function getBasicConf( $wId ) {
/** @var $controllerClass \OCA\Dashboard\Widgets\IWidgetController */
if( $controllerClass = $this->widgetManagementService->getInstance($wId.'-0') ) {
return $controllerClass->getBasicValues();
}
return false;
}
public function enableWidgetGroup($wIdG) {
if( !isset($wIdG) ) {
return array('success' => 0);
}
return $this->widgetManagementService->enable($wIdG);
}
public function disableWidgetGroup($wIdG) {
if( !isset($wIdG) ) {
return array('success' => 0);
}
return $this->widgetManagementService->disable($wIdG);
}
/**
* @NoAdminRequired
* @param $wId
* @return array
*/
public function addNewInstance($wId) {
return array(
'wIId' => $this->widgetManagementService->addNewInstance($wId)
);
}
public function removeInstance($wIId) {
$this->widgetManagementService->removeInstance($wIId);
}
}