return false;
}
+ // get - returns a report identified by its id for user.
+ static function get($id) {
+ global $user;
+ $mdb2 = getConnection();
+
+ $user_id = $user->getUser();
+ $group_id = $user->getGroup();
+ $org_id = $user->org_id;
+
+ $sql = "select * from tt_fav_reports".
+ " where id = $id and user_id = $user_id and group_id = $group_id and org_id = $org_id and status = 1";
+ $res = $mdb2->query($sql);
+ if (!is_a($res, 'PEAR_Error')) {
+ if ($val = $res->fetchRow()) {
+ return $val;
+ }
+ }
+ return false;
+ }
+
// getReport - returns a report identified by its id.
+ // TODO: get rid of this function by encapsulating all cron related tasks in its own class.
+ // Because cron works for all orgs and we want this class to always work in context of
+ // a logged on user, for better security.
static function getReport($id) {
$mdb2 = getConnection();
<br>
<table cellspacing="0" cellpadding="4" width="100%" border="0">
<tr>
- <td align="center"> Anuko Time Tracker 1.18.29.4613 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+ <td align="center"> Anuko Time Tracker 1.18.29.4614 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
<a href="https://www.anuko.com/lp/tt_4.htm" target="_blank">{$i18n.footer.credits}</a> |
<a href="https://www.anuko.com/lp/tt_5.htm" target="_blank">{$i18n.footer.license}</a> |
<a href="https://www.anuko.com/lp/tt_7.htm" target="_blank">{$i18n.footer.improve}</a>
exit();
}
if ($request->isPost()) {
- // TODO: improve this, perhaps by refactoring elsewhere.
- $cl_fav_report = (int) $request->getParameter('fav_report');
- $fav_report = ttFavReportHelper::getReport($cl_fav_report);
- if ($user->getUser() != $fav_report['user_id']) {
+ $cl_fav_report_id = (int) $request->getParameter('fav_report');
+ if (!ttFavReportHelper::get($cl_fav_report_id)) {
header('Location: access_denied.php'); // Invalid fav report id in post.
exit();
}
$form->addInput(array('type'=>'combobox',
'name'=>'fav_report',
'style'=>'width: 250px;',
- 'value'=>$cl_fav_report,
+ 'value'=>$cl_fav_report_id,
'data'=>$fav_reports,
'datakeys'=>array('id','name'),
'empty'=>array(''=>$i18n->get('dropdown.select'))
if ($request->isPost()) {
// Validate user input.
- if (!$cl_fav_report) $err->add($i18n->get('error.report'));
+ if (!$cl_fav_report_id) $err->add($i18n->get('error.report'));
if (!ttValidCronSpec($cl_cron_spec)) $err->add($i18n->get('error.field'), $i18n->get('label.schedule'));
if (!ttValidEmail($cl_email)) $err->add($i18n->get('error.field'), $i18n->get('label.email'));
if (!ttValidEmail($cl_cc, true)) $err->add($i18n->get('error.field'), $i18n->get('label.cc'));
if (ttNotificationHelper::insert(array(
'cron_spec' => $cl_cron_spec,
'next' => $next,
- 'report_id' => $cl_fav_report,
+ 'report_id' => $cl_fav_report_id,
'email' => $cl_email,
'cc' => $cl_cc,
'subject' => $cl_subject,
exit();
}
if ($request->isPost()) {
- // TODO: improve this, perhaps by refactoring elsewhere.
- $cl_fav_report = (int) $request->getParameter('fav_report');
- $fav_report = ttFavReportHelper::getReport($cl_fav_report);
- if ($user->getUser() != $fav_report['user_id']) {
+ $cl_fav_report_id = (int) $request->getParameter('fav_report');
+ if ($cl_fav_report_id && !ttFavReportHelper::get($cl_fav_report_id)) {
header('Location: access_denied.php'); // Invalid fav report id in post.
exit();
}
$cl_report_condition = trim($request->getParameter('report_condition'));
} else {
$notification = ttNotificationHelper::get($notification_id);
- $cl_fav_report = $notification['report_id'];
+ $cl_fav_report_id = $notification['report_id'];
$cl_cron_spec = $notification['cron_spec'];
$cl_email = $notification['email'];
$cl_cc = $notification['cc'];
$form->addInput(array('type'=>'combobox',
'name'=>'fav_report',
'style'=>'width: 250px;',
- 'value'=>$cl_fav_report,
+ 'value'=>$cl_fav_report_id,
'data'=>$fav_reports,
'datakeys'=>array('id','name'),
'empty'=>array(''=>$i18n->get('dropdown.select'))));
if ($request->isPost()) {
// Validate user input.
- if (!$cl_fav_report) $err->add($i18n->get('error.report'));
+ if (!$cl_fav_report_id) $err->add($i18n->get('error.report'));
if (!ttValidCronSpec($cl_cron_spec)) $err->add($i18n->get('error.field'), $i18n->get('label.schedule'));
if (!ttValidEmail($cl_email)) $err->add($i18n->get('error.field'), $i18n->get('label.email'));
if (!ttValidEmail($cl_cc, true)) $err->add($i18n->get('error.field'), $i18n->get('label.cc'));
'id' => $notification_id,
'cron_spec' => $cl_cron_spec,
'next' => $next,
- 'report_id' => $cl_fav_report,
+ 'report_id' => $cl_fav_report_id,
'email' => $cl_email,
'cc' => $cl_cc,
'subject' => $cl_subject,