From: Nik Okuntseff Date: Mon, 19 Nov 2018 13:32:15 +0000 (+0000) Subject: Populating org_id in tt_cron table. X-Git-Tag: timetracker_1.19-1~615 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=118c3d9a6326a6b1ebc3c5a018047cec00ffbd62;p=timetracker.git Populating org_id in tt_cron table. --- diff --git a/WEB-INF/lib/ttNotificationHelper.class.php b/WEB-INF/lib/ttNotificationHelper.class.php index af1bcd3c..a4fa5e6d 100644 --- a/WEB-INF/lib/ttNotificationHelper.class.php +++ b/WEB-INF/lib/ttNotificationHelper.class.php @@ -65,9 +65,11 @@ class ttNotificationHelper { // insert function inserts a new notification into database. static function insert($fields) { + global $user; $mdb2 = getConnection(); - $group_id = (int) $fields['group_id']; + $group_id = $user->getActiveGroup(); + $org_id = $user->org_id; $cron_spec = $fields['cron_spec']; $next = (int) $fields['next']; $report_id = (int) $fields['report_id']; @@ -77,8 +79,8 @@ class ttNotificationHelper { $report_condition = $fields['report_condition']; $status = $fields['status']; - $sql = "insert into tt_cron (group_id, cron_spec, next, report_id, email, cc, subject, report_condition, status) - values ($group_id, ".$mdb2->quote($cron_spec).", $next, $report_id, ".$mdb2->quote($email).", ".$mdb2->quote($cc).", ".$mdb2->quote($subject).", ".$mdb2->quote($report_condition).", ".$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; diff --git a/WEB-INF/lib/ttTeamHelper.class.php b/WEB-INF/lib/ttTeamHelper.class.php index 4203fdc6..b861e669 100644 --- a/WEB-INF/lib/ttTeamHelper.class.php +++ b/WEB-INF/lib/ttTeamHelper.class.php @@ -703,6 +703,11 @@ class ttTeamHelper { $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; + // Delete cron entries. + $sql = "delete from tt_cron where group_id = $group_id"; + $affected = $mdb2->exec($sql); + if (is_a($affected, 'PEAR_Error')) return false; + // Delete predefined expenses. $sql = "delete from tt_predefined_expenses where group_id = $group_id"; $affected = $mdb2->exec($sql); diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 397c6600..a6340288 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.20.4456 | Copyright © Anuko | +  Anuko Time Tracker 1.18.20.4457 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/dbinstall.php b/dbinstall.php index 6497dbbf..e31783a7 100644 --- a/dbinstall.php +++ b/dbinstall.php @@ -1016,6 +1016,7 @@ if ($_POST) { setChange("update `tt_fav_reports` fr inner join `tt_site_config` sc on (sc.param_name = 'version_db' and sc.param_value = '1.18.19') inner join `tt_users` u on u.id = fr.user_id set fr.group_id = u.group_id, fr.org_id = u.org_id where fr.org_id is null"); setChange("ALTER TABLE `tt_cron` ADD `org_id` int(11) default NULL AFTER `group_id`"); setChange("UPDATE `tt_site_config` SET param_value = '1.18.20', modified = now() where param_name = 'version_db' and param_value = '1.18.19'"); + setChange("UPDATE `tt_cron` inner join `tt_site_config` sc on (sc.param_name = 'version_db' and sc.param_value = '1.18.20') set org_id = group_id where org_id is null"); } if ($_POST["cleanup"]) {