forked from matomo-org/matomo
/
Controller.php
executable file
·81 lines (63 loc) · 2.1 KB
/
Controller.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
<?php
/**
* Piwik - Open source web analytics
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later
* @version $Id$
*
* @category Piwik_Plugins
* @package Piwik_Alerts
*/
namespace Piwik\Plugins\CustomAlerts;
use Piwik\View;
use Piwik\Common;
use Piwik\Plugins\SitesManager\API as SitesManagerApi;
use Piwik\Plugins\API\API as MetadataApi;
use Piwik\Period;
use Piwik\Db;
/**
*
* @package Piwik_Alerts
*/
class Controller extends \Piwik\Plugin\Controller
{
/**
* Shows all Alerts of the current selected idSite.
*/
public function index()
{
$idSite = Common::getRequestVar('idSite', null, 'int');
$view = new View('@CustomAlerts/index');
$this->setGeneralVariablesView($view);
$view->alerts = API::getInstance()->getAlerts(array($idSite));
return $view->render();
}
public function addNewAlert()
{
$view = new View('@CustomAlerts/addNewAlert');
$this->setGeneralVariablesView($view);
$view->sitesList = SitesManagerApi::getInstance()->getSitesWithAtLeastViewAccess();
// ToDo need to collect metrics,processedMetrics,goalMetrics, goalProcessedMetric
$view->alertGroups = array();
$view->alerts = MetadataApi::getInstance()->getReportMetadata();
$view->alertGroupConditions = Processor::getGroupConditions();
$view->alertMetricConditions = Processor::getMetricConditions();
return $view->render();
}
public function editAlert()
{
$idAlert = Common::getRequestVar('idAlert', null, 'int');
$view = new View('@CustomAlerts/editAlert');
$this->setGeneralVariablesView($view);
$view->alert = API::getInstance()->getAlert($idAlert);
$view->sitesList = SitesManagerApi::getInstance()->getSitesWithAtLeastViewAccess();
$model = new Model();
$view->sitesDefined = $model->fetchSiteIdsTheAlertWasDefinedOn($idAlert);
$view->alerts = MetadataApi::getInstance()->getReportMetadata();
$view->alertGroupConditions = Processor::getGroupConditions();
$view->alertMetricConditions = Processor::getMetricConditions();
return $view->render();
}
}
?>