diff --git a/lbplanner/classes/enums/CAPABILITY_FLAG_ORNONE.php b/lbplanner/classes/enums/CAPABILITY_FLAG_ORNONE.php
new file mode 100644
index 00000000..9a9f45cb
--- /dev/null
+++ b/lbplanner/classes/enums/CAPABILITY_FLAG_ORNONE.php
@@ -0,0 +1,55 @@
+.
+
+/**
+ * capability flag
+ *
+ * @package local_lbplanner
+ * @subpackage enums
+ * @copyright 2025 Pallasys
+ * @license https://creativecommons.org/licenses/by-nc-sa/4.0/ CC-BY-NC-SA 4.0 International or later
+ */
+
+namespace local_lbplanner\enums;
+
+// TODO: revert to native enums once we migrate to php8.
+
+use local_lbplanner\enums\{CAPABILITY, CAPABILITY_FLAG};
+
+/**
+ * Bitmappable flags for capabilities a user can have.
+ * Also includes 0 for the lack of any capabilities.
+ */
+class CAPABILITY_FLAG_ORNONE extends CAPABILITY_FLAG {
+ /**
+ * Absence of any CAPABILITY.
+ */
+ const NONE = 0;
+
+ /**
+ * matches a flag to its capability string
+ * @param int $num the bitmappable flag
+ * @return string the capability string
+ * @throws \coding_exception if $num === 0 (not an actual capability)
+ * @link CAPABILITY
+ */
+ public static function to_capability(int $num): string {
+ if ($num === 0) { // TODO: put in translation strings.
+ throw new \coding_exception('0 means the absence of capabilities, and thus cannot be converted to a capability');
+ }
+ return parent::to_capability($num);
+ }
+}
diff --git a/lbplanner/classes/helpers/user_helper.php b/lbplanner/classes/helpers/user_helper.php
index 16f3311a..abd3fb20 100644
--- a/lbplanner/classes/helpers/user_helper.php
+++ b/lbplanner/classes/helpers/user_helper.php
@@ -73,7 +73,7 @@ public static function get_user(int $userid): user {
}
// Register user if not found.
- $eduplanneruser = new user(0, $userid, 'default', 'none', 1, false, true, null, null, null);
+ $eduplanneruser = new user(0, $userid, 'default', 'none', 1, false, true, 0, null, null, null);
$epid = $DB->insert_record(self::EDUPLANNER_USER_TABLE, $eduplanneruser->prepare_for_db());
$eduplanneruser->set_fresh($epid);
diff --git a/lbplanner/classes/model/user.php b/lbplanner/classes/model/user.php
index 82744c67..1b2157b4 100644
--- a/lbplanner/classes/model/user.php
+++ b/lbplanner/classes/model/user.php
@@ -28,7 +28,7 @@
use core\context\system as context_system;
use core_external\{external_single_structure, external_value};
use user_picture;
-use local_lbplanner\enums\{CAPABILITY, CAPABILITY_FLAG, KANBANCOL_TYPE_ORNONE};
+use local_lbplanner\enums\{CAPABILITY, CAPABILITY_FLAG, KANBANCOL_TYPE_ORNONE, CAPABILITY_FLAG_ORNONE};
use local_lbplanner\helpers\{plan_helper, user_helper};
/**
@@ -70,6 +70,12 @@ class user {
*/
public bool $showcolumncolors;
+ /**
+ * @var ?int $defaultcapabilityview Which capability's view to show in app per default.
+ * @see CAPABILITY_FLAG_ORNONE
+ */
+ public ?int $defaultcapabilityview;
+
/**
* @var ?string $automovecompletedtasks what kanban column to move completed tasks to (null → don't move)
* @see KANBANCOL_TYPE
@@ -117,6 +123,7 @@ class user {
'displaytaskcount',
'ekenabled',
'showcolumncolors',
+ 'defaultcapabilityview',
'automovecompletedtasks',
'automovesubmittedtasks',
'automoveoverduetasks',
@@ -131,6 +138,7 @@ class user {
* @param bool $displaytaskcount user's display task count
* @param bool $ekenabled whether the user wants to see EK modules
* @param bool $showcolumncolors whether column colors should show in kanban board
+ * @param ?int $defaultcapabilityview Which capability's view to show in app per default
* @param ?string $automovecompletedtasks what kanban column to move completed tasks to (null → don't move)
* @param ?string $automovesubmittedtasks what kanban column to move submitted tasks to (null → don't move)
* @param ?string $automoveoverduetasks what kanban column to move overdue tasks to (null → don't move)
@@ -143,6 +151,7 @@ public function __construct(
bool $displaytaskcount,
bool $ekenabled,
bool $showcolumncolors,
+ int $defaultcapabilityview,
?string $automovecompletedtasks,
?string $automovesubmittedtasks,
?string $automoveoverduetasks,
@@ -309,7 +318,7 @@ public function get_capabilitybitmask(): int {
* Prepares data for the DB endpoint.
* doesn't set ID if it's 0
*
- * @return object a representation of this course and its data
+ * @return object a representation of this user and its data
*/
public function prepare_for_db(): object {
$obj = new \stdClass();
@@ -388,6 +397,7 @@ public function prepare_for_api(): array {
'colorblindness' => $this->colorblindness,
'displaytaskcount' => $this->displaytaskcount,
'showcolumncolors' => $this->showcolumncolors,
+ 'defaultcapabilityview' => $this->defaultcapabilityview,
'automovecompletedtasks' => $this->automovecompletedtasks ?? KANBANCOL_TYPE_ORNONE::NONE,
'automovesubmittedtasks' => $this->automovesubmittedtasks ?? KANBANCOL_TYPE_ORNONE::NONE,
'automoveoverduetasks' => $this->automoveoverduetasks ?? KANBANCOL_TYPE_ORNONE::NONE,
@@ -415,6 +425,10 @@ public static function api_structure(): external_single_structure {
'colorblindness' => new external_value(PARAM_TEXT, 'The colorblindness of the user'),
'displaytaskcount' => new external_value(PARAM_BOOL, 'Whether the user has the taskcount enabled'),
'showcolumncolors' => new external_value(PARAM_BOOL, 'Whether column colors should show in kanban board'),
+ 'defaultcapabilityview' => new external_value(
+ PARAM_INT,
+ 'Which capability\'s view to show in app per default ' . CAPABILITY_FLAG_ORNONE::format()
+ ),
'automovecompletedtasks' => new external_value(
PARAM_TEXT,
'The kanban column to move a task to if completed ' . KANBANCOL_TYPE_ORNONE::format()
diff --git a/lbplanner/db/install.xml b/lbplanner/db/install.xml
index a2902db5..f21bcacb 100644
--- a/lbplanner/db/install.xml
+++ b/lbplanner/db/install.xml
@@ -9,6 +9,7 @@
+
diff --git a/lbplanner/db/upgrade.php b/lbplanner/db/upgrade.php
index 70d877ec..453ca90f 100644
--- a/lbplanner/db/upgrade.php
+++ b/lbplanner/db/upgrade.php
@@ -104,5 +104,12 @@ function xmldb_local_lbplanner_upgrade($oldversion): bool {
upgrade_plugin_savepoint(true, 202510090000, 'local', 'lbplanner');
}
+ if ($oldversion < 202511210000) {
+ $table = new xmldb_table('local_lbplanner_users');
+ $f5 = new xmldb_field('defaultcapabilityview', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, false, 0, 'showcolumncolors');
+ $dbman->add_field($table, $f5);
+
+ upgrade_plugin_savepoint(true, 202511210000, 'local', 'lbplanner');
+ }
return true;
}
diff --git a/lbplanner/services/user/update_user.php b/lbplanner/services/user/update_user.php
index 7778960a..3270e058 100644
--- a/lbplanner/services/user/update_user.php
+++ b/lbplanner/services/user/update_user.php
@@ -22,7 +22,7 @@
use dml_exception;
use local_lbplanner\helpers\user_helper;
use local_lbplanner\model\user;
-use local_lbplanner\enums\KANBANCOL_TYPE_ORNONE;
+use local_lbplanner\enums\{KANBANCOL_TYPE_ORNONE, CAPABILITY_FLAG_ORNONE};
/**
* Update current user settings. null values or unset parameters are left unmodified.
@@ -74,6 +74,13 @@ public static function update_user_parameters(): external_function_parameters {
null,
NULL_ALLOWED
),
+ 'defaultcapabilityview' => new external_value(
+ PARAM_INT,
+ 'Which capability\'s view to show in app per default ' . CAPABILITY_FLAG_ORNONE::format(),
+ VALUE_DEFAULT,
+ null,
+ NULL_ALLOWED
+ ),
'automovecompletedtasks' => new external_value(
PARAM_TEXT,
'The kanban column to move a task to if completed ' . KANBANCOL_TYPE_ORNONE::format(),
@@ -105,6 +112,7 @@ public static function update_user_parameters(): external_function_parameters {
* @param ?bool $displaytaskcount The displaytaskcount the user has selected
* @param ?bool $ekenabled whether the user wants to see EK modules
* @param ?bool $showcolumncolors whether column colors should show in kanban board
+ * @param ?int $defaultcapabilityview Which capability's view to show in app per default
* @param ?string $automovecompletedtasks what kanban column to move completed tasks to ("" → don't move)
* @param ?string $automovesubmittedtasks what kanban column to move submitted tasks to ("" → don't move)
* @param ?string $automoveoverduetasks what kanban column to move overdue tasks to ("" → don't move)
@@ -119,6 +127,7 @@ public static function update_user(
?bool $displaytaskcount,
?bool $ekenabled,
?bool $showcolumncolors,
+ ?int $defaultcapabilityview,
?string $automovecompletedtasks,
?string $automovesubmittedtasks,
?string $automoveoverduetasks,
@@ -133,6 +142,7 @@ public static function update_user(
'displaytaskcount' => $displaytaskcount,
'ekenabled' => $ekenabled,
'showcolumncolors' => $showcolumncolors,
+ 'defaultcapabilityview' => $defaultcapabilityview,
'automovecompletedtasks' => $automovecompletedtasks,
'automovesubmittedtasks' => $automovesubmittedtasks,
'automoveoverduetasks' => $automoveoverduetasks,
@@ -159,6 +169,9 @@ public static function update_user(
if ($showcolumncolors !== null) {
$user->showcolumncolors = $showcolumncolors;
}
+ if ($defaultcapabilityview !== null) {
+ $user->defaultcapabilityview = CAPABILITY_FLAG_ORNONE::from($defaultcapabilityview);
+ }
foreach (['automovecompletedtasks', 'automovesubmittedtasks', 'automoveoverduetasks'] as $propname) {
if ($$propname !== null) {
if ($$propname === KANBANCOL_TYPE_ORNONE::NONE) {
diff --git a/lbplanner/version.php b/lbplanner/version.php
index 89f7924b..cb82aa63 100644
--- a/lbplanner/version.php
+++ b/lbplanner/version.php
@@ -30,7 +30,7 @@
$plugin->maturity = MATURITY_BETA;
$plugin->component = 'local_lbplanner';
$plugin->release = '1.1.11';
-$plugin->version = 202510190000;
+$plugin->version = 202511210000;
$plugin->dependencies = [
// Depend upon version 2023110600 of local_modcustomfields.
'local_modcustomfields' => 2023110600,