Adding tables for customisable user profile fields. See MDL-474

This commit is contained in:
ikawhero
2006-09-20 14:17:21 +00:00
parent d7e901c669
commit adecf1c475
5 changed files with 181 additions and 2 deletions
+39 -2
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="lib/db" VERSION="20060918" COMMENT="XMLDB file for core Moodle tables"
<XMLDB PATH="lib/db" VERSION="20060920" COMMENT="XMLDB file for core Moodle tables"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
>
@@ -1031,7 +1031,7 @@
<INDEX NAME="roleid-contextid-capability" UNIQUE="true" FIELDS="roleid, contextid, capability"/>
</INDEXES>
</TABLE>
<TABLE NAME="role_names" COMMENT="role names in native strings" PREVIOUS="role_capabilities">
<TABLE NAME="role_names" COMMENT="role names in native strings" PREVIOUS="role_capabilities" NEXT="user_info_field">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="roleid"/>
<FIELD NAME="roleid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="contextid"/>
@@ -1047,6 +1047,43 @@
<INDEX NAME="roleid-contextid" UNIQUE="true" FIELDS="roleid, contextid"/>
</INDEXES>
</TABLE>
<TABLE NAME="user_info_field" COMMENT="Customisable user profile fields" PREVIOUS="role_names" NEXT="user_info_category">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="true" ENUM="false" COMMENT="id of the table, please edit me" NEXT="name"/>
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" COMMENT="field name" PREVIOUS="id" NEXT="datatype"/>
<FIELD NAME="datatype" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" COMMENT="Type of data held in this field" PREVIOUS="name" NEXT="categoryid"/>
<FIELD NAME="categoryid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="id from category table" PREVIOUS="datatype" NEXT="sortorder"/>
<FIELD NAME="sortorder" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="order within the category" PREVIOUS="categoryid" NEXT="required"/>
<FIELD NAME="required" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="Field required" PREVIOUS="sortorder" NEXT="locked"/>
<FIELD NAME="locked" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="Field locked" PREVIOUS="required" NEXT="visible"/>
<FIELD NAME="visible" TYPE="int" LENGTH="4" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="Visibility: private, public, hidden" PREVIOUS="locked" NEXT="defaultdata"/>
<FIELD NAME="defaultdata" TYPE="text" LENGTH="big" NOTNULL="false" SEQUENCE="false" ENUM="false" COMMENT="Default value for this field" PREVIOUS="visible"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="primary key of the table, please edit me"/>
</KEYS>
</TABLE>
<TABLE NAME="user_info_category" COMMENT="Customisable fields categories" PREVIOUS="user_info_field" NEXT="user_info_data">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="true" ENUM="false" COMMENT="id of the table, please edit me" NEXT="name"/>
<FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" COMMENT="Category name" PREVIOUS="id" NEXT="sortorder"/>
<FIELD NAME="sortorder" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="Display order" PREVIOUS="name"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="primary key of the table, please edit me"/>
</KEYS>
</TABLE>
<TABLE NAME="user_info_data" COMMENT="Data for the customisable user fields" PREVIOUS="user_info_category">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="false" SEQUENCE="true" ENUM="false" COMMENT="id of the table, please edit me" NEXT="userid"/>
<FIELD NAME="userid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="id from the user table" PREVIOUS="id" NEXT="fieldid"/>
<FIELD NAME="fieldid" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="id from the field table" PREVIOUS="userid" NEXT="data"/>
<FIELD NAME="data" TYPE="text" LENGTH="big" NOTNULL="true" SEQUENCE="false" ENUM="false" COMMENT="Field data" PREVIOUS="fieldid"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id" COMMENT="primary key of the table, please edit me"/>
</KEYS>
</TABLE>
</TABLES>
<STATEMENTS>
<STATEMENT NAME="insert log_display" TYPE="insert" TABLE="log_display" COMMENT="Initial insert of records on table log_display">
+37
View File
@@ -2249,6 +2249,43 @@ function main_upgrade($oldversion=0) {
}
}
/// Tables for customisable user profile fields
if ($oldversion < 2006092000) {
execute_sql("CREATE TABLE {$CFG->prefix}user_info_field (
id BIGINT(10) NOT NULL auto_increment,
name VARCHAR(255) NOT NULL default '',
datatype VARCHAR(255) NOT NULL default '',
categoryid BIGINT(10) unsigned NOT NULL default 0,
sortorder BIGINT(10) unsigned NOT NULL default 0,
required TINYINT(2) unsigned NOT NULL default 0,
locked TINYINT(2) unsigned NOT NULL default 0,
visible SMALLINT(4) unsigned NOT NULL default 0,
defaultdata LONGTEXT,
CONSTRAINT PRIMARY KEY (id));", true);
execute_sql("ALTER TABLE {$CFG->prefix}user_info_field COMMENT='Customisable user profile fields';", true);
execute_sql("CREATE TABLE {$CFG->prefix}user_info_category (
id BIGINT(10) NOT NULL auto_increment,
name VARCHAR(255) NOT NULL default '',
sortorder BIGINT(10) unsigned NOT NULL default 0,
CONSTRAINT PRIMARY KEY (id));", true);
execute_sql("ALTER TABLE {$CFG->prefix}user_info_category COMMENT='Customisable fields categories';", true);
execute_sql("CREATE TABLE {$CFG->prefix}user_info_data (
id BIGINT(10) NOT NULL auto_increment,
userid BIGINT(10) unsigned NOT NULL default 0,
fieldid BIGINT(10) unsigned NOT NULL default 0,
data LONGTEXT NOT NULL,
CONSTRAINT PRIMARY KEY (id));", true);
execute_sql("ALTER TABLE {$CFG->prefix}user_info_data COMMENT='Data for the customisable user fields';", true);
}
return $result;
}
+34
View File
@@ -1030,3 +1030,37 @@ INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('message'
INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('message', 'remove contact', 'user', 'CONCAT(firstname," ",lastname)');
INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('message', 'block contact', 'user', 'CONCAT(firstname," ",lastname)');
INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('message', 'unblock contact', 'user', 'CONCAT(firstname," ",lastname)');
CREATE TABLE prefix_user_info_field (
id BIGINT(10) NOT NULL auto_increment,
name VARCHAR(255) NOT NULL default '',
datatype VARCHAR(255) NOT NULL default '',
categoryid BIGINT(10) unsigned NOT NULL default 0,
sortorder BIGINT(10) unsigned NOT NULL default 0,
required TINYINT(2) unsigned NOT NULL default 0,
locked TINYINT(2) unsigned NOT NULL default 0,
visible SMALLINT(4) unsigned NOT NULL default 0,
defaultdata LONGTEXT,
CONSTRAINT PRIMARY KEY (id)
);
ALTER TABLE prefix_user_info_field COMMENT='Customisable user profile fields';
CREATE TABLE prefix_user_info_category (
id BIGINT(10) NOT NULL auto_increment,
name VARCHAR(255) NOT NULL default '',
sortorder BIGINT(10) unsigned NOT NULL default 0,
CONSTRAINT PRIMARY KEY (id)
);
ALTER TABLE prefix_user_info_category COMMENT='Customisable fields categories';
CREATE TABLE prefix_user_info_data (
id BIGINT(10) NOT NULL auto_increment,
userid BIGINT(10) unsigned NOT NULL default 0,
fieldid BIGINT(10) unsigned NOT NULL default 0,
data LONGTEXT NOT NULL,
CONSTRAINT PRIMARY KEY (id)
);
ALTER TABLE prefix_user_info_data COMMENT='Data for the customisable user fields';
+36
View File
@@ -1849,6 +1849,42 @@ function main_upgrade($oldversion=0) {
}
}
/// Tables for customisable user profile fields
if ($oldversion < 2006092000) {
execute_sql("CREATE TABLE {$CFG->prefix}user_info_field (
id BIGSERIAL,
name VARCHAR(255) NOT NULL default '',
datatype VARCHAR(255) NOT NULL default '',
categoryid BIGINT NOT NULL default 0,
sortorder BIGINT NOT NULL default 0,
required SMALLINT NOT NULL default 0,
locked SMALLINT NOT NULL default 0,
visible SMALLINT NOT NULL default 0,
defaultdata TEXT,
CONSTRAINT {$CFG->prefix}userinfofiel_id_pk PRIMARY KEY (id));", true);
execute_sql("COMMENT ON TABLE {$CFG->prefix}user_info_field IS 'Customisable user profile fields';", true);
execute_sql("CREATE TABLE {$CFG->prefix}user_info_category (
id BIGSERIAL,
name VARCHAR(255) NOT NULL default '',
sortorder BIGINT NOT NULL default 0,
CONSTRAINT {$CFG->prefix}userinfocate_id_pk PRIMARY KEY (id));", true);
execute_sql("COMMENT ON TABLE {$CFG->prefix}user_info_category IS 'Customisable fields categories';", true);
execute_sql("CREATE TABLE {$CFG->prefix}user_info_data (
id BIGSERIAL,
userid BIGINT NOT NULL default 0,
fieldid BIGINT NOT NULL default 0,
data TEXT NOT NULL,
CONSTRAINT {$CFG->prefix}userinfodata_id_pk PRIMARY KEY (id));", true);
execute_sql("COMMENT ON TABLE {$CFG->prefix}user_info_data IS 'Data for the customisable user fields';", true);
}
return $result;
}
+35
View File
@@ -793,3 +793,38 @@ INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('message'
INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('message', 'remove contact', 'user', 'firstname||\' \'||lastname');
INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('message', 'block contact', 'user', 'firstname||\' \'||lastname');
INSERT INTO prefix_log_display (module, action, mtable, field) VALUES ('message', 'unblock contact', 'user', 'firstname||\' \'||lastname');
CREATE TABLE prefix_user_info_field (
id BIGSERIAL,
name VARCHAR(255) NOT NULL default '',
datatype VARCHAR(255) NOT NULL default '',
categoryid BIGINT NOT NULL default 0,
sortorder BIGINT NOT NULL default 0,
required SMALLINT NOT NULL default 0,
locked SMALLINT NOT NULL default 0,
visible SMALLINT NOT NULL default 0,
defaultdata TEXT,
CONSTRAINT prefix_userinfofiel_id_pk PRIMARY KEY (id)
);
COMMENT ON TABLE prefix_user_info_field IS 'Customisable user profile fields';
CREATE TABLE prefix_user_info_category (
id BIGSERIAL,
name VARCHAR(255) NOT NULL default '',
sortorder BIGINT NOT NULL default 0,
CONSTRAINT prefix_userinfocate_id_pk PRIMARY KEY (id)
);
COMMENT ON TABLE prefix_user_info_category IS 'Customisable fields categories';
CREATE TABLE prefix_user_info_data (
id BIGSERIAL,
userid BIGINT NOT NULL default 0,
fieldid BIGINT NOT NULL default 0,
data TEXT NOT NULL,
CONSTRAINT prefix_userinfodata_id_pk PRIMARY KEY (id)
);
COMMENT ON TABLE prefix_user_info_data IS 'Data for the customisable user fields';