Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
ad08bee0
Commit
ad08bee0
authored
Jun 27, 2008
by
Richard Mansfield
Browse files
Store grouptype data in the db
parent
c34b0a9c
Changes
6
Hide whitespace changes
Inline
Side-by-side
htdocs/lib/db/install.xml
View file @
ad08bee0
...
...
@@ -293,6 +293,26 @@
<KEY
NAME=
"artefactfk"
TYPE=
"foreign"
FIELDS=
"artefact"
REFTABLE=
"artefact"
REFFIELDS=
"id"
/>
</KEYS>
</TABLE>
<TABLE
NAME=
"grouptype"
>
<FIELDS>
<FIELD
NAME=
"name"
TYPE=
"char"
LENGTH=
"20"
NOTNULL=
"true"
/>
<FIELD
NAME=
"usercancreate"
TYPE=
"int"
LENGTH=
"1"
NOTNULL=
"true"
DEFAULT=
"1"
/>
<FIELD
NAME=
"takesviewsubmissions"
TYPE=
"int"
LENGTH=
"1"
NOTNULL=
"true"
DEFAULT=
"0"
/>
</FIELDS>
<KEYS>
<KEY
NAME=
"primary"
TYPE=
"primary"
FIELDS=
"name"
/>
</KEYS>
</TABLE>
<TABLE
NAME=
"grouptype_roles"
>
<FIELDS>
<FIELD
NAME=
"grouptype"
TYPE=
"char"
LENGTH=
"20"
NOTNULL=
"true"
/>
<FIELD
NAME=
"role"
TYPE=
"text"
NOTNULL=
"true"
/>
</FIELDS>
<KEYS>
<KEY
NAME=
"primary"
TYPE=
"primary"
FIELDS=
"grouptype,role"
/>
<KEY
NAME=
"grouptypefk"
TYPE=
"foreign"
FIELDS=
"grouptype"
REFTABLE=
"grouptype"
REFFIELDS=
"name"
/>
</KEYS>
</TABLE>
<TABLE
NAME=
"group"
>
<FIELDS>
<FIELD
NAME=
"id"
TYPE=
"int"
LENGTH=
"10"
NOTNULL=
"true"
SEQUENCE=
"true"
/>
...
...
@@ -307,6 +327,7 @@
<KEYS>
<KEY
NAME=
"primary"
TYPE=
"primary"
FIELDS=
"id"
/>
<KEY
NAME=
"nameuk"
TYPE=
"unique"
FIELDS=
"name"
/>
<KEY
NAME=
"grouptypefk"
TYPE=
"foreign"
FIELDS=
"grouptype"
REFTABLE=
"grouptype"
REFFIELDS=
"name"
/>
</KEYS>
</TABLE>
<TABLE
NAME=
"group_member"
>
...
...
htdocs/lib/db/upgrade.php
View file @
ad08bee0
...
...
@@ -1085,6 +1085,29 @@ function xmldb_core_upgrade($oldversion=0) {
);'
);
}
if
(
$oldversion
<
2008062302
)
{
execute_sql
(
'CREATE TABLE {grouptype} (
name VARCHAR(20) PRIMARY KEY,
usercancreate SMALLINT NOT NULL,
submittableto SMALLINT NOT NULL
);'
);
execute_sql
(
"INSERT INTO
{
grouptype
}
(name,usercancreate,submittableto) VALUES ('standard',1,0)"
);
execute_sql
(
"INSERT INTO
{
grouptype
}
(name,usercancreate,submittableto) VALUES ('course',0,1)"
);
execute_sql
(
'CREATE TABLE {grouptype_roles} (
grouptype VARCHAR(20) NOT NULL REFERENCES {grouptype}(name),
role TEXT NOT NULL
);'
);
execute_sql
(
"INSERT INTO
{
grouptype_roles
}
(grouptype,role) VALUES ('standard','admin')"
);
execute_sql
(
"INSERT INTO
{
grouptype_roles
}
(grouptype,role) VALUES ('standard','member')"
);
execute_sql
(
"INSERT INTO
{
grouptype_roles
}
(grouptype,role) VALUES ('course','admin')"
);
execute_sql
(
"INSERT INTO
{
grouptype_roles
}
(grouptype,role) VALUES ('course','tutor')"
);
execute_sql
(
"INSERT INTO
{
grouptype_roles
}
(grouptype,role) VALUES ('course','member')"
);
$table
=
new
XMLDBTable
(
'group'
);
$key
=
new
XMLDBKey
(
'grouptypefk'
);
$key
->
setAttributes
(
XMLDB_KEY_FOREIGN
,
array
(
'grouptype'
),
'grouptype'
,
array
(
'name'
));
add_key
(
$table
,
$key
);
}
return
$status
;
}
...
...
htdocs/lib/group.php
View file @
ad08bee0
...
...
@@ -527,6 +527,26 @@ function group_get_membersearch_data($group, $query, $offset, $limit) {
*/
abstract
class
GroupType
{
public
function
install
()
{
$classname
=
get_class
(
$this
);
$type
=
strtolower
(
substr
(
$classname
,
strlen
(
'GroupType'
)));
insert_record
(
'grouptype'
,
(
object
)
array
(
'name'
=>
$type
,
'usercancreate'
=>
$this
->
can_be_created_by_user
(),
'submittableto'
=>
$this
->
takes_view_submissions
(),
));
$roles
=
$this
->
get_roles
();
if
(
!
in_array
(
$roles
,
'admin'
))
{
$roles
[]
=
'admin'
;
}
foreach
(
$roles
as
$r
)
{
insert_record
(
'grouptype_roles'
,
(
object
)
array
(
'grouptype'
=>
$type
,
'role'
=>
$r
,
));
}
}
public
static
abstract
function
allowed_join_types
();
/**
...
...
@@ -542,6 +562,10 @@ abstract class GroupType {
*/
public
static
abstract
function
get_roles
();
public
static
function
takes_view_submissions
()
{
return
false
;
}
}
/**
...
...
htdocs/lib/grouptype/course.php
View file @
ad08bee0
...
...
@@ -44,6 +44,10 @@ class GroupTypeCourse extends GroupType {
return
array
(
'member'
,
'tutor'
,
'admin'
);
}
public
static
function
takes_view_submissions
()
{
return
true
;
}
}
?>
htdocs/lib/upgrade.php
View file @
ad08bee0
...
...
@@ -585,6 +585,14 @@ function core_install_lastcoredata_defaults() {
insert_record
(
'usr'
,
$user
);
}
// add standard and course group types
require_once
(
get_config
(
'docroot'
)
.
'lib/grouptype/standard.php'
);
$gt
=
new
GroupTypeStandard
;
$gt
->
install
();
require_once
(
get_config
(
'docroot'
)
.
'lib/grouptype/course.php'
);
$gt
=
new
GroupTypeCourse
;
$gt
->
install
();
// Insert the admin user
$user
=
new
StdClass
;
$user
->
username
=
'admin'
;
...
...
htdocs/lib/version.php
View file @
ad08bee0
...
...
@@ -27,7 +27,7 @@
defined
(
'INTERNAL'
)
||
die
();
$config
=
new
StdClass
;
$config
->
version
=
200806230
1
;
$config
->
version
=
200806230
2
;
$config
->
release
=
'1.1.0alpha'
;
$config
->
minupgradefrom
=
2007080700
;
$config
->
minupgraderelease
=
'0.8.0 (release tag 0.8.0_RELEASE)'
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment