From cfd9b24303a37276bc28ae3ef7c399f515507341 Mon Sep 17 00:00:00 2001 From: Coding with Peter Date: Mon, 29 Jan 2024 15:38:30 -0800 Subject: [PATCH] post sp24 login changes --- api2.php | 3 +++ fix_users.php | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++ js/dir_app.js | 7 ++++++- sessions.php | 1 + 4 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 fix_users.php diff --git a/api2.php b/api2.php index c14d7b1..590e0de 100644 --- a/api2.php +++ b/api2.php @@ -228,6 +228,8 @@ function appdata() { // hosts $hh = multi_row_1d("select session FROM conf_hosts WHERE host='{$USER['conf_id']}';"); + + $hbs = multi_row_select("select s.id, s.title, s.starttime, u.name, u.email, u.id AS hostid from conf_sessions as s LEFT OUTER JOIN conf_hosts as h ON h.session=s.id LEFT OUTER JOIN conf_users AS u ON h.host=u.id WHERE s.id>1319 ORDER BY u.name;",0); // conferences $c = multi_row_select('SELECT * FROM conf_conferences;',0); @@ -241,6 +243,7 @@ function appdata() { "mysessions" => $m, "sessions" => $s, "host" => $hh, + "hostbysession" => $hbs, "user" => $USER, "conference" => $c, "ay" => $y, diff --git a/fix_users.php b/fix_users.php new file mode 100644 index 0000000..b95d967 --- /dev/null +++ b/fix_users.php @@ -0,0 +1,53 @@ +connect_error) { + die("Connection failed: " . $mysqli->connect_error); + } + + // Start a query to get rows ordered by 'goo' + $query = "SELECT * FROM conf_users ORDER BY goo DESC LIMIT 5000"; + $result = $mysqli->query($query); + + // Key: goo, Value: id + $goo_to_id = array(); + + // Iterating through each result + while ($row = $result->fetch_assoc()) { + $id = $row['id']; + $goo = $row['goo']; + + // Check if an entry exists for this 'goo' + if (array_key_exists($goo, $goo_to_id)) { + // Save lower and higher id + $lower_id = min($id, $goo_to_id[$goo]); + $higher_id = max($id, $goo_to_id[$goo]); + + echo "(test) UPDATE conf_signups SET user={$lower_id} WHERE user={$higher_id}\n
\n"; + + // Prepare an update statement and execute + + if (! $TEST) { + $update_stmt = $mysqli->prepare("UPDATE conf_signups SET user=? WHERE user=?"); + $update_stmt->bind_param("ii", $lower_id, $higher_id); + $update_stmt->execute(); + echo "UPDATE conf_signups SET user={$lower_id} WHERE user={$higher_id}\n
\n"; + + } + + } else { + $goo_to_id[$goo] = $id; + } + } + + // Closing the database connection + $mysqli->close(); diff --git a/js/dir_app.js b/js/dir_app.js index 320afc1..dbc97d6 100644 --- a/js/dir_app.js +++ b/js/dir_app.js @@ -925,7 +925,7 @@ const ActivityList = Vue.component('activitylist', { methods: { hoststr: function(id) { var self = this return _.reduce( self.hosts_by_sesid[id], function(mem,val) { if (val.name) { return mem + val.name + ", " } return mem }, '') }, - mode_string: function(a) { if (this.active>3) { return _.findWhere(this.$root.modes_menu, { 'id': a.mode })['string'] } return a.mode }, + mode_string: function(a) { if (this.$root.active) { return _.findWhere(this.$root.modes_menu, { 'id': a.mode })['string'] } return a.mode }, get_day_title: function(day) { console.log(day) var d = dayjs(day, 'MMM DD YYYY') @@ -942,6 +942,10 @@ const ActivityList = Vue.component('activitylist', { am_editing: function(id) { return 0 }, fetch_myevents: function() { var self = this; + basic_get('dir_api.php?a=get/hosts', function(r2) { + self.hosts_by_sesid = _.groupBy(r2,function(x) { return x.id } ) + } ) + basic_get('api2.php?query=app', function(r2) { self.mysessions = r2.mysessions @@ -952,6 +956,7 @@ const ActivityList = Vue.component('activitylist', { self.options = r2.options self.conference = r2.conference self.ay = r2.ay + self.hosts_by_sesid = _.groupBy(r2.hostbysession,function(x) { return x.id } ) self.survey_on = parseInt( _.findWhere(self.options, { label:'survey_on' }).value ) self.zoom_on = parseInt( _.findWhere(self.options, { label:'zoom_on' }).value ) diff --git a/sessions.php b/sessions.php index cb6d9ee..aaae6da 100644 --- a/sessions.php +++ b/sessions.php @@ -3,6 +3,7 @@