X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=WEB-INF%2Flib%2FttNotificationHelper.class.php;h=c9f0a1e9c364677bfb89ff96dc0c34889d240815;hb=035970e91c0a4c132874656b8f13a88c46684717;hp=8fd185c00257a268d689222fd1faa50f84ce4e93;hpb=9a23a8c0a51b7ec38a96f525484134f3cb85dc7e;p=timetracker.git diff --git a/WEB-INF/lib/ttNotificationHelper.class.php b/WEB-INF/lib/ttNotificationHelper.class.php index 8fd185c0..c9f0a1e9 100644 --- a/WEB-INF/lib/ttNotificationHelper.class.php +++ b/WEB-INF/lib/ttNotificationHelper.class.php @@ -26,9 +26,6 @@ // | https://www.anuko.com/time_tracker/credits.htm // +----------------------------------------------------------------------+ -import('ttTeamHelper'); -import('ttUserHelper'); - // Class ttNotificationHelper is used to help with notification related tasks. class ttNotificationHelper { @@ -39,9 +36,9 @@ class ttNotificationHelper { $mdb2 = getConnection(); - $sql = "select c.id, c.cron_spec, c.report_id, c.email, c.status, fr.name from tt_cron c + $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.team_id = $user->team_id"; + where c.id = $id and c.group_id = ".$user->getGroup(); $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { $val = $res->fetchRow(); @@ -57,7 +54,7 @@ class ttNotificationHelper { $mdb2 = getConnection(); - $sql = "delete from tt_cron where id = $id and team_id = $user->team_id"; + $sql = "delete from tt_cron where id = $id and group_id = ".$user->getGroup(); $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -68,17 +65,22 @@ class ttNotificationHelper { // insert function inserts a new notification into database. static function insert($fields) { + global $user; $mdb2 = getConnection(); - $team_id = (int) $fields['team_id']; + $group_id = $user->getGroup(); + $org_id = $user->org_id; $cron_spec = $fields['cron_spec']; $next = (int) $fields['next']; $report_id = (int) $fields['report_id']; $email = $fields['email']; + $cc = $fields['cc']; + $subject = $fields['subject']; + $report_condition = $fields['report_condition']; $status = $fields['status']; - $sql = "insert into tt_cron (team_id, cron_spec, next, report_id, email, status) - values ($team_id, ".$mdb2->quote($cron_spec).", $next, $report_id, ".$mdb2->quote($email).", ".$mdb2->quote($status).")"; + $sql = "insert into tt_cron (group_id, org_id, cron_spec, next, report_id, email, cc, subject, report_condition, status)". + " values ($group_id, $org_id, ".$mdb2->quote($cron_spec).", $next, $report_id, ".$mdb2->quote($email).", ".$mdb2->quote($cc).", ".$mdb2->quote($subject).", ".$mdb2->quote($report_condition).", ".$mdb2->quote($status).")"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -92,17 +94,19 @@ class ttNotificationHelper { $mdb2 = getConnection(); $notification_id = (int) $fields['id']; - $team_id = (int) $fields['team_id']; + $group_id = (int) $fields['group_id']; $cron_spec = $fields['cron_spec']; $next = (int) $fields['next']; $report_id = (int) $fields['report_id']; $email = $fields['email']; + $cc = $fields['cc']; + $subject = $fields['subject']; + $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).", status = ".$mdb2->quote($status). - " where id = $notification_id and team_id = $team_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"; $affected = $mdb2->exec($sql); return (!is_a($affected, 'PEAR_Error')); } } -?> \ No newline at end of file