Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 1 addition & 24 deletions lbplanner/classes/model/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ class user {
*/
public string $theme;

/**
* @var string $lang user language
*/
public string $lang;

/**
* @var string $colorblindness the kind of color blindness of a user
*/
Expand Down Expand Up @@ -94,23 +89,20 @@ class user {
* @param int $lbpid ID of the lb planner user
* @param int $mdlid ID of the moodle user
* @param string $theme user-chosen theme
* @param string $lang user language
* @param string $colorblindness user's colorblindness
* @param int $displaytaskcount user's display task count
*/
public function __construct(
int $lbpid,
int $mdlid,
string $theme,
string $lang,
string $colorblindness,
int $displaytaskcount
) {
global $USER;
$this->lbpid = $lbpid;
$this->mdlid = $mdlid;
$this->set_theme($theme);
$this->set_lang($lang);
$this->set_colorblindness($colorblindness);
$this->set_displaytaskcount($displaytaskcount);
$this->planid = null;
Expand All @@ -131,7 +123,7 @@ public function __construct(
* @return user a representation of this user and its data
*/
public static function from_db(object $obj): self {
return new self($obj->id, $obj->userid, $obj->theme, $obj->language, $obj->colorblindness, $obj->displaytaskcount);
return new self($obj->id, $obj->userid, $obj->theme, $obj->colorblindness, $obj->displaytaskcount);
}

/**
Expand Down Expand Up @@ -165,18 +157,6 @@ public function set_colorblindness(string $cbn): void {
$this->colorblindness = $cbn;
}

/**
* Sets user language
* @param string $lang language
* @throws \coding_exception if $lang isn't ISO 639-1 conformant
*/
public function set_lang(string $lang): void {
if (preg_match('/^[a-z]{2}$/', $lang) !== 1) {
throw new \coding_exception('Incorrect language format - must be ISO 639-1, e.g. en or de');
}
$this->lang = $lang;
}

/**
* Sets user theme
* @param string $theme theme
Expand Down Expand Up @@ -278,7 +258,6 @@ public function prepare_for_db(): object {

$obj->userid = $this->mdlid;
$obj->theme = $this->theme;
$obj->language = $this->lang;
$obj->colorblindness = $this->colorblindness;
$obj->displaytaskcount = $this->displaytaskcount;

Expand Down Expand Up @@ -341,7 +320,6 @@ public function prepare_for_api(): array {
$this->prepare_for_api_short(),
[
'theme' => $this->theme,
'lang' => $this->lang,
'planid' => $this->get_planid(),
'colorblindness' => $this->colorblindness,
'displaytaskcount' => $this->displaytaskcount,
Expand All @@ -363,7 +341,6 @@ public static function api_structure(): external_single_structure {
'firstname' => new external_value(PARAM_TEXT, 'The firstname of the user'),
'lastname' => new external_value(PARAM_TEXT, 'The lastname of the user'),
'theme' => new external_value(PARAM_TEXT, 'The theme the user has selected'),
'lang' => new external_value(PARAM_TEXT, 'The language the user has selected'),
'profileimageurl' => new external_value(PARAM_URL, 'The url of the profile image'),
'planid' => new external_value(PARAM_INT, 'The id of the plan the user is assigned to'),
'colorblindness' => new external_value(PARAM_TEXT, 'The colorblindness of the user'),
Expand Down
3 changes: 1 addition & 2 deletions lbplanner/db/install.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" />
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="User ID assigned from moodle." />
<FIELD NAME="theme" TYPE="text" NOTNULL="true" SEQUENCE="false" COMMENT="The name of the theme the user has selected in the app." />
<FIELD NAME="language" TYPE="char" LENGTH="2" NOTNULL="true" DEFAULT="en" SEQUENCE="false" COMMENT="Language the user has selected in the app." />
<FIELD NAME="colorblindness" TYPE="text" NOTNULL="true" SEQUENCE="false" COMMENT="The colorblindness the user has selected in the app." />
<FIELD NAME="displaytaskcount" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="1" SEQUENCE="false" COMMENT="The display task count the user has selected in the app." />
</FIELDS>
Expand Down Expand Up @@ -43,7 +42,7 @@
<KEY NAME="userid" TYPE="foreign" FIELDS="userid" REFTABLE="local_lbplanner_users" REFFIELDS="userid" />
</KEYS>
</TABLE>
<TABLE NAME="local_lbplanner_plan_invites" COMMENT="Table for Invites for the LBPLANNER Appme">
<TABLE NAME="local_lbplanner_plan_invites" COMMENT="Table for Invites for the LBPLANNER App">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true" />
<FIELD NAME="planid" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="false" COMMENT="The id of the plan the user is inviting to." />
Expand Down
Loading