}
return $result;
}
+
+ // getNotifications - obtains notification descriptions for a group.
+ static function getNotifications() {
+ global $user;
+ $mdb2 = getConnection();
+
+ $group_id = $user->getGroup();
+ $org_id = $user->org_id;
+
+ $result = array();
+ $sql = "select c.id, c.cron_spec, c.email, c.report_condition, fr.name from tt_cron c".
+ " left join tt_fav_reports fr on (fr.id = c.report_id)".
+ " where c.group_id = $group_id and c.org_id = $org_id and c.status = 1 and fr.status = 1";
+ $res = $mdb2->query($sql);
+ $result = array();
+ if (!is_a($res, 'PEAR_Error')) {
+ while ($val = $res->fetchRow()) {
+ $result[] = $val;
+ }
+ return $result;
+ }
+ return false;
+ }
}
class ttNotificationHelper {
// get - gets notification details.
- static function get($id)
- {
+ static function get($id) {
global $user;
-
$mdb2 = getConnection();
- $sql = "select c.id, c.cron_spec, c.report_id, c.email, c.cc, c.subject, c.report_condition, c.status, fr.name from tt_cron c
- left join tt_fav_reports fr on (fr.id = c.report_id)
- where c.id = $id and c.group_id = ".$user->getGroup();
+ $group_id = $user->getGroup();
+ $org_id = $user->org_id;
+
+ $sql = "select c.id, c.cron_spec, c.report_id, c.email, c.cc, c.subject, c.report_condition, c.status, fr.name from tt_cron c".
+ " left join tt_fav_reports fr on (fr.id = c.report_id)".
+ " where c.id = $id and c.group_id = $group_id and c.org_id = $org_id";
$res = $mdb2->query($sql);
if (!is_a($res, 'PEAR_Error')) {
$val = $res->fetchRow();
// delete - deletes a notification from tt_cron table.
static function delete($id) {
global $user;
-
$mdb2 = getConnection();
-
- $sql = "delete from tt_cron where id = $id and group_id = ".$user->getGroup();
+
+ $group_id = $user->getGroup();
+ $org_id = $user->org_id;
+
+ $sql = "delete from tt_cron where id = $id and group_id = $group_id and org_id = $org_id";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error'))
return false;
- return true;
+ return true;
}
// insert function inserts a new notification into database.
- static function insert($fields)
- {
+ static function insert($fields) {
global $user;
$mdb2 = getConnection();
$group_id = $user->getGroup();
$org_id = $user->org_id;
+
$cron_spec = $fields['cron_spec'];
$next = (int) $fields['next'];
$report_id = (int) $fields['report_id'];
}
// update function - updates a notification in database.
- static function update($fields)
- {
+ static function update($fields) {
+ global $user;
$mdb2 = getConnection();
-
+
+ $group_id = $user->getGroup();
+ $org_id = $user->org_id;
+
$notification_id = (int) $fields['id'];
- $group_id = (int) $fields['group_id'];
$cron_spec = $fields['cron_spec'];
$next = (int) $fields['next'];
$report_id = (int) $fields['report_id'];
$report_condition = $fields['report_condition'];
$status = $fields['status'];
- $sql = "update tt_cron set cron_spec = ".$mdb2->quote($cron_spec).", next = $next, report_id = $report_id, email = ".$mdb2->quote($email).", cc = ".$mdb2->quote($cc).", subject = ".$mdb2->quote($subject).", report_condition = ".$mdb2->quote($report_condition).", status = ".$mdb2->quote($status).
- " where id = $notification_id and group_id = $group_id";
+ $sql = "update tt_cron".
+ " set cron_spec = ".$mdb2->quote($cron_spec).", next = $next, report_id = $report_id".
+ ", email = ".$mdb2->quote($email).", cc = ".$mdb2->quote($cc).", subject = ".$mdb2->quote($subject).
+ ", report_condition = ".$mdb2->quote($report_condition).", status = ".$mdb2->quote($status).
+ " where id = $notification_id and group_id = $group_id and org_id = $org_id";
$affected = $mdb2->exec($sql);
return (!is_a($affected, 'PEAR_Error'));
}
return false;
}
- // getNotifications - obtains notification descriptions for a group.
- static function getNotifications($group_id) {
- $mdb2 = getConnection();
-
- $result = array();
- $sql = "select c.id, c.cron_spec, c.email, c.report_condition, fr.name from tt_cron c
- left join tt_fav_reports fr on (fr.id = c.report_id)
- where c.group_id = $group_id and c.status = 1 and fr.status = 1";
- $res = $mdb2->query($sql);
- $result = array();
- if (!is_a($res, 'PEAR_Error')) {
- while ($val = $res->fetchRow()) {
- $result[] = $val;
- }
- return $result;
- }
- return false;
- }
-
// getMonthlyQuotas - obtains monthly quotas for a group.
static function getMonthlyQuotas($group_id) {
$mdb2 = getConnection();