diff --git a/lbplanner/classes/helpers/kanban_helper.php b/lbplanner/classes/helpers/kanban_helper.php
index f106f571..4e7a4af6 100644
--- a/lbplanner/classes/helpers/kanban_helper.php
+++ b/lbplanner/classes/helpers/kanban_helper.php
@@ -81,16 +81,7 @@ public static function set_entry(kanbanentry $entry): void {
throw $e;
}
if ($entry->column !== KANBANCOL_TYPE_NUMERIC::BACKLOG) {
- $table = $CFG->prefix . self::TABLE;
- try {
- // Moodle is too stupid to compensate for 'column' being a keyword so I need to shit my own ass manually.
- $newid = $DB->execute("INSERT INTO {$table} VALUES (null,?,?,?)", [$entry->userid, $entry->cmid, $entry->column]);
- } catch (\dml_exception $e) {
- // Needed for low-reporting contexts such as a prod server.
- echo 'error while trying to insert new kanban entry: '.$e->getMessage()."\nFurther info:\n".$e->debuginfo;
- var_dump($entry);
- throw $e;
- }
+ $newid = $DB->insert_record(self::TABLE, $entry->prepare_for_db(), true);
$entry->set_fresh($newid);
}
}
diff --git a/lbplanner/classes/model/kanbanentry.php b/lbplanner/classes/model/kanbanentry.php
index f6f270a7..1f4d7417 100644
--- a/lbplanner/classes/model/kanbanentry.php
+++ b/lbplanner/classes/model/kanbanentry.php
@@ -83,6 +83,25 @@ public function set_fresh(int $id) {
$this->id = $id;
}
+ /**
+ * Prepares data for the DB endpoint.
+ * doesn't set ID if it's 0
+ *
+ * @return object a representation of this kanban entry and its data
+ */
+ public function prepare_for_db(): object {
+ $obj = new \stdClass();
+
+ $obj->selectedcolumn = $this->column;
+ $obj->cmid = $this->cmid;
+ $obj->userid = $this->userid;
+
+ if ($this->id !== 0) {
+ $obj->id = $this->id;
+ }
+ return $obj;
+ }
+
/**
* Prepares data for the API endpoint.
*
diff --git a/lbplanner/db/install.xml b/lbplanner/db/install.xml
index 43c02073..a2902db5 100644
--- a/lbplanner/db/install.xml
+++ b/lbplanner/db/install.xml
@@ -155,7 +155,7 @@
-
+
diff --git a/lbplanner/db/upgrade.php b/lbplanner/db/upgrade.php
index ab063e4f..5c41670c 100644
--- a/lbplanner/db/upgrade.php
+++ b/lbplanner/db/upgrade.php
@@ -98,5 +98,12 @@ function xmldb_local_lbplanner_upgrade($oldversion): bool {
upgrade_plugin_savepoint(true, 202509060001, 'local', 'lbplanner');
}
+ if ($oldversion < 202510090000) {
+ $table = new xmldb_table('local_lbplanner_kanbanentries');
+ $field = new xmldb_field('column', XMLDB_TYPE_INTEGER, '2', null, XMLDB_NOTNULL, null, null, 'cmid');
+ $dbman->rename_field($table, $field, 'selectedcolumn');
+
+ upgrade_plugin_savepoint(true, 202510090000, 'local', 'lbplanner');
+ }
return true;
}
diff --git a/lbplanner/version.php b/lbplanner/version.php
index 45bc0080..29a582a1 100644
--- a/lbplanner/version.php
+++ b/lbplanner/version.php
@@ -28,7 +28,7 @@
$plugin->maturity = MATURITY_BETA;
$plugin->component = 'local_lbplanner';
$plugin->release = '1.1.8';
-$plugin->version = 202510040000;
+$plugin->version = 202510090000;
$plugin->dependencies = [
// Depend upon version 2023110600 of local_modcustomfields.
'local_modcustomfields' => 2023110600,