Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit 35d4400

Browse files
author
Jamie Snape
committed
Add more documentation to tracker module
1 parent 199554b commit 35d4400

34 files changed

+899
-228
lines changed

modules/tracker/AppController.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@
1818
limitations under the License.
1919
=========================================================================*/
2020

21-
/** App controller for the tracker module */
21+
/**
22+
* Generic controller class for the tracker module.
23+
*
24+
* @package Modules\Tracker\Controller
25+
*/
2226
class Tracker_AppController extends MIDAS_GlobalModule
2327
{
28+
/** @var string */
2429
public $moduleName = 'tracker';
2530
}

modules/tracker/Bootstrap.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818
limitations under the License.
1919
=========================================================================*/
2020

21-
/** Bootstrap for the tracker module. */
21+
/**
22+
* Bootstrap for the tracker module.
23+
*
24+
* @package Modules\Tracker\Bootstrap
25+
*/
2226
class Tracker_Bootstrap extends Zend_Application_Module_Bootstrap
2327
{
2428
}

modules/tracker/Notification.php

Lines changed: 58 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,34 @@
2020

2121
require_once BASE_PATH.'/modules/api/library/APIEnabledNotification.php';
2222

23-
/** Notification manager for the tracker module */
23+
/**
24+
* Notification manager for the tracker module.
25+
*
26+
* @property Tracker_ScalarModel $Tracker_Scalar
27+
* @property Tracker_TrendModel $Tracker_Trend
28+
* @package Modules\Tracker\Notification
29+
*/
2430
class Tracker_Notification extends ApiEnabled_Notification
2531
{
32+
/** @var string */
2633
public $moduleName = 'tracker';
34+
35+
/** @var array */
2736
public $_models = array('User');
37+
38+
/** @var array */
2839
public $_moduleModels = array('Scalar', 'Trend');
40+
41+
/** @var array */
2942
public $_moduleComponents = array('Api');
3043

31-
/** init notification process */
44+
/** @var string */
45+
public $moduleWebroot = null;
46+
47+
/** @var string */
48+
public $webroot = null;
49+
50+
/** Initialize the notification process. */
3251
public function init()
3352
{
3453
$baseUrl = Zend_Controller_Front::getInstance()->getBaseUrl();
@@ -51,61 +70,85 @@ public function init()
5170
}
5271

5372
/**
54-
* Show trackers tab on the community view page
73+
* Show the trackers tab on the community view page.
74+
*
75+
* @param array $args associative array of parameters including the key "community"
76+
* @return array
5577
*/
5678
public function communityViewTabs($args)
5779
{
80+
/** @var CommunityDao $community */
5881
$community = $args['community'];
5982

6083
return array('Trackers' => $this->moduleWebroot.'/producer/list?communityId='.$community->getKey());
6184
}
6285

6386
/**
64-
* When a community is deleted, we must delete all associated producers
87+
* When a community is deleted, we must delete all associated producers.
88+
*
89+
* @todo
90+
* @param array $args associative array of parameters including the key "community"
6591
*/
6692
public function communityDeleted($args)
6793
{
68-
// TODO
69-
// $comm = $args['community'];
94+
// TODO: Implement communityDeleted().
7095
}
7196

7297
/**
73-
* When an item is deleted, we must delete associated item2scalar records
98+
* When an item is deleted, we must delete associated item2scalar records.
99+
*
100+
* @todo
101+
* @param array $args associative array of parameters including the key "item"
74102
*/
75103
public function itemDeleted($args)
76104
{
77-
// TODO
78-
// $item = $args['item'];
105+
// TODO: Implement itemDeleted().
79106
}
80107

81108
/**
82-
* When a user is deleted, we should delete their threshold notifications
109+
* When a user is deleted, we should delete their threshold notifications.
110+
*
111+
* @todo
112+
* @param array $args associative array of parameters including the key "userDao"
83113
*/
84114
public function userDeleted($args)
85115
{
86-
// TODO
87-
// $user = $args['userDao'];
116+
// TODO: Implement userDeleted().
88117
}
89118

90119
/**
91120
* Delete temporary (unofficial) scalars after n hours, where n is specified as
92-
* a module configuration option
121+
* a module configuration option.
122+
*
123+
* @param array $params associative array of parameters including the key "scalarId"
93124
*/
94125
public function deleteTempScalar($params)
95126
{
127+
/** @var int $scalarId */
96128
$scalarId = $params['scalarId'];
129+
130+
/** @var Tracker_ScalarDao $scalar */
97131
$scalar = $this->Tracker_Scalar->load($scalarId);
98132
$this->Tracker_Scalar->delete($scalar);
99133
}
100134

101135
/**
102-
* Send an email to the user that a threshold was crossed
136+
* Send an email to the user that a threshold was crossed.
137+
*
138+
* @param array $params associative array of parameters including the keys "notification" and "scalar"
103139
*/
104140
public function sendEmail($params)
105141
{
142+
/** @var array $notification */
106143
$notification = $params['notification'];
144+
145+
/** @var array $scalar */
107146
$scalar = $params['scalar'];
147+
148+
/** @var Tracker_TrendDao $trend */
108149
$trend = $this->Tracker_Trend->load($scalar['trend_id']);
150+
151+
/** @var UserDao $user */
109152
$user = $this->User->load($notification['recipient_id']);
110153
$producer = $trend->getProducer();
111154

@@ -129,7 +172,7 @@ public function sendEmail($params)
129172
).'">'.$trend->getDisplayName().'</a><br/>';
130173
$body .= '<b>Value:</b> '.$scalar['value'];
131174

132-
$result = Zend_Registry::get('notifier')->callback(
175+
Zend_Registry::get('notifier')->callback(
133176
'CALLBACK_CORE_SEND_MAIL_MESSAGE',
134177
array(
135178
'to' => $email,

modules/tracker/controllers/AdminController.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818
limitations under the License.
1919
=========================================================================*/
2020

21-
/** Admin controller for the tracker module. */
21+
/**
22+
* Admin controller for the tracker module.
23+
*
24+
* @package Modules\Tracker\Controller
25+
*/
2226
class Tracker_AdminController extends Tracker_AppController
2327
{
2428
/** @var array */
@@ -32,8 +36,11 @@ public function indexAction()
3236
$this->view->pageTitle = 'Tracker Module Configuration';
3337
$form = new Tracker_Form_Admin();
3438

35-
if ($this->getRequest()->isPost()) {
36-
$data = $this->getRequest()->getPost();
39+
/** @var Zend_Controller_Request_Http $request */
40+
$request = $this->getRequest();
41+
42+
if ($request->isPost()) {
43+
$data = $request->getPost();
3744

3845
if ($form->isValid($data)) {
3946
$values = $form->getValues();
@@ -49,6 +56,7 @@ public function indexAction()
4956
} else {
5057
$elements = $form->getElements();
5158

59+
/** @var Zend_Form_Element $element */
5260
foreach ($elements as $element) {
5361
$name = $element->getName();
5462

modules/tracker/controllers/ProducerController.php

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,43 @@
1818
limitations under the License.
1919
=========================================================================*/
2020

21-
/** Producer controller */
21+
/**
22+
* Producer controller for the tracker module.
23+
*
24+
* @property Tracker_ProducerModel $Tracker_Producer
25+
* @property Tracker_TrendModel $Tracker_Trend
26+
* @package Modules\Tracker\Controller
27+
*/
2228
class Tracker_ProducerController extends Tracker_AppController
2329
{
30+
/** @var array */
2431
public $_components = array('Breadcrumb');
32+
33+
/** @var array */
2534
public $_models = array('Community');
35+
36+
/** @var array */
2637
public $_moduleModels = array('Producer', 'Trend');
2738

2839
/**
2940
* List all producers for a given community (in the tab). Requires read permission on community.
3041
*
31-
* @param communityId The community id
42+
* Request parameters:
43+
* communityId - The community id
44+
*
3245
* @throws Zend_Exception
3346
*/
3447
public function listAction()
3548
{
3649
$this->disableLayout();
50+
51+
/** @var int $commId */
3752
$commId = $this->getParam('communityId');
3853
if (!isset($commId)) {
3954
throw new Zend_Exception('Must pass communityId parameter');
4055
}
56+
57+
/** @var CommunityDao $comm */
4158
$comm = $this->Community->load($commId);
4259
if (!$comm || !$this->Community->policyCheck($comm, $this->userSession->Dao, MIDAS_POLICY_READ)
4360
) {
@@ -48,17 +65,22 @@ public function listAction()
4865
}
4966

5067
/**
51-
* View a producer, displaying all available trends
68+
* View a producer, displaying all available trends.
69+
*
70+
* Request parameters:
71+
* producerId - The id of the producer to display (requires community read permission)
5272
*
53-
* @param producerId The id of the producer to display (requires community read permission)
5473
* @throws Zend_Exception
5574
*/
5675
public function viewAction()
5776
{
77+
/** @var int $producerId */
5878
$producerId = $this->getParam('producerId');
5979
if (!isset($producerId)) {
6080
throw new Zend_Exception('Must pass producerId parameter');
6181
}
82+
83+
/** @var Tracker_ProducerDao $producer */
6284
$producer = $this->Tracker_Producer->load($producerId);
6385
$comm = $producer->getCommunity();
6486
if (!$producer || !$this->Community->policyCheck($comm, $this->userSession->Dao, MIDAS_POLICY_READ)
@@ -80,19 +102,25 @@ public function viewAction()
80102
}
81103

82104
/**
83-
* Delete a producer, deleting all trend data within it (requires community admin)
105+
* Delete a producer, deleting all trend data within it (requires community admin).
106+
*
107+
* Request parameters:
108+
* producerId - The id of the producer to delete
84109
*
85-
* @param producerId The id of the producer to delete
86110
* @throws Zend_Exception
87111
*/
88112
public function deleteAction()
89113
{
90114
$this->disableLayout();
91115
$this->disableView();
116+
117+
/** @var int $producerId */
92118
$producerId = $this->getParam('producerId');
93119
if (!isset($producerId)) {
94120
throw new Zend_Exception('Must pass producerId parameter');
95121
}
122+
123+
/** @var Tracker_ProducerDao $producer */
96124
$producer = $this->Tracker_Producer->load($producerId);
97125
$comm = $producer->getCommunity();
98126
if (!$producer || !$this->Community->policyCheck($comm, $this->userSession->Dao, MIDAS_POLICY_ADMIN)
@@ -103,17 +131,20 @@ public function deleteAction()
103131
}
104132

105133
/**
106-
* Show the dialog for editing the producer information
134+
* Show the dialog for editing the producer information.
107135
*
108136
* @throws Zend_Exception
109137
*/
110138
public function editAction()
111139
{
140+
/** @var int $producerId */
112141
$producerId = $this->getParam('producerId');
113142

114143
if (!isset($producerId)) {
115144
throw new Zend_Exception('Must pass producerId parameter');
116145
}
146+
147+
/** @var Tracker_ProducerDao $producer */
117148
$producer = $this->Tracker_Producer->load($producerId);
118149
if (!$producer) {
119150
throw new Zend_Exception('Invalid producerId', 404);
@@ -127,20 +158,26 @@ public function editAction()
127158
}
128159

129160
/**
130-
* Handle edit form submission
161+
* Handle edit form submission.
162+
*
163+
* Request parameters:
164+
* producerId - The id of the producer to edit
131165
*
132-
* @param producerId The id of the producer to edit
133166
* @throws Zend_Exception
134167
*/
135168
public function editsubmitAction()
136169
{
137170
$this->disableLayout();
138171
$this->disableView();
172+
173+
/** @var int $producerId */
139174
$producerId = $this->getParam('producerId');
140175

141176
if (!isset($producerId)) {
142177
throw new Zend_Exception('Must pass producerId parameter');
143178
}
179+
180+
/** @var Tracker_ProducerDao $producer */
144181
$producer = $this->Tracker_Producer->load($producerId);
145182
if (!$this->Community->policyCheck($producer->getCommunity(), $this->userSession->Dao, MIDAS_POLICY_ADMIN)
146183
) {

0 commit comments

Comments
 (0)