X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/timetracker.git/blobdiff_plain/098a79f0819ebb89b7d48df4a6b154af4560f68e..9a23a8c0a51b7ec38a96f525484134f3cb85dc7e:/WEB-INF/lib/ttNotificationHelper.class.php diff --git a/WEB-INF/lib/ttNotificationHelper.class.php b/WEB-INF/lib/ttNotificationHelper.class.php new file mode 100644 index 00000000..8fd185c0 --- /dev/null +++ b/WEB-INF/lib/ttNotificationHelper.class.php @@ -0,0 +1,108 @@ +team_id"; + $res = $mdb2->query($sql); + if (!is_a($res, 'PEAR_Error')) { + $val = $res->fetchRow(); + if ($val && $val['id']) + return $val; + } + return false; + } + + // 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 team_id = $user->team_id"; + $affected = $mdb2->exec($sql); + if (is_a($affected, 'PEAR_Error')) + return false; + + return true; + } + + // insert function inserts a new notification into database. + static function insert($fields) + { + $mdb2 = getConnection(); + + $team_id = (int) $fields['team_id']; + $cron_spec = $fields['cron_spec']; + $next = (int) $fields['next']; + $report_id = (int) $fields['report_id']; + $email = $fields['email']; + $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).")"; + $affected = $mdb2->exec($sql); + if (is_a($affected, 'PEAR_Error')) + return false; + + return true; + } + + // update function - updates a notification in database. + static function update($fields) + { + $mdb2 = getConnection(); + + $notification_id = (int) $fields['id']; + $team_id = (int) $fields['team_id']; + $cron_spec = $fields['cron_spec']; + $next = (int) $fields['next']; + $report_id = (int) $fields['report_id']; + $email = $fields['email']; + $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"; + $affected = $mdb2->exec($sql); + return (!is_a($affected, 'PEAR_Error')); + } +} +?> \ No newline at end of file