Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
mahara
mahara
Commits
6b30b435
Commit
6b30b435
authored
Jun 23, 2008
by
Richard Mansfield
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow artefact access to be granted by virtue of group role
parent
972a77dc
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
55 additions
and
2 deletions
+55
-2
htdocs/artefact/lib.php
htdocs/artefact/lib.php
+1
-0
htdocs/auth/user.php
htdocs/auth/user.php
+13
-1
htdocs/lib/db/install.xml
htdocs/lib/db/install.xml
+25
-0
htdocs/lib/db/upgrade.php
htdocs/lib/db/upgrade.php
+15
-0
htdocs/lib/version.php
htdocs/lib/version.php
+1
-1
No files found.
htdocs/artefact/lib.php
View file @
6b30b435
...
...
@@ -95,6 +95,7 @@ abstract class ArtefactType {
protected
$note
;
protected
$tags
=
array
();
protected
$institution
;
protected
$group
;
protected
$viewsinstances
;
protected
$viewsmetadata
;
...
...
htdocs/auth/user.php
View file @
6b30b435
...
...
@@ -509,7 +509,19 @@ class User {
}
public
function
can_view_artefact
(
$a
)
{
return
$this
->
get
(
'admin'
)
||
$this
->
get
(
'id'
)
==
$a
->
get
(
'owner'
);
if
(
$this
->
get
(
'admin'
)
||
$this
->
get
(
'id'
)
==
$a
->
get
(
'owner'
)
||
$this
->
is_institutional_admin
(
$a
->
get
(
'institution'
)))
{
return
true
;
}
if
(
$a
->
get
(
'group'
))
{
// Only group artefacts can have artefact_access_role & artefact_access_usr records
return
(
bool
)
count_records_sql
(
"SELECT COUNT(*) FROM
{
artefact_access_role
}
ar
INNER JOIN
{
group_member
}
g ON ar.role = g.role
WHERE ar.artefact = ? AND g.member = ? AND ar.can_view = 1"
,
array
(
$a
->
get
(
'id'
),
$this
->
get
(
'id'
)))
||
record_exists
(
'artefact_access_usr'
,
'usr'
,
$this
->
get
(
'id'
),
'artefact'
,
$a
->
get
(
'id'
));
}
return
false
;
}
}
...
...
htdocs/lib/db/install.xml
View file @
6b30b435
...
...
@@ -268,6 +268,31 @@
<KEY
NAME=
"parentfk"
TYPE=
"foreign"
FIELDS=
"parent"
REFTABLE=
"artefact"
REFFIELDS=
"id"
/>
</KEYS>
</TABLE>
<TABLE
NAME=
"artefact_access_usr"
>
<FIELDS>
<FIELD
NAME=
"usr"
TYPE=
"int"
LENGTH=
"10"
NOTNULL=
"true"
/>
<FIELD
NAME=
"artefact"
TYPE=
"int"
LENGTH=
"10"
NOTNULL=
"true"
/>
<FIELD
NAME=
"can_republish"
TYPE=
"int"
LENGTH=
"1"
NOTNULL=
"false"
/>
</FIELDS>
<KEYS>
<KEY
NAME=
"primary"
TYPE=
"primary"
FIELDS=
"usr,artefact"
/>
<KEY
NAME=
"usrfk"
TYPE=
"foreign"
FIELDS=
"usr"
REFTABLE=
"usr"
REFFIELDS=
"id"
/>
<KEY
NAME=
"artefactfk"
TYPE=
"foreign"
FIELDS=
"artefact"
REFTABLE=
"artefact"
REFFIELDS=
"id"
/>
</KEYS>
</TABLE>
<TABLE
NAME=
"artefact_access_role"
>
<FIELDS>
<FIELD
NAME=
"role"
TYPE=
"text"
NOTNULL=
"true"
/>
<FIELD
NAME=
"artefact"
TYPE=
"int"
LENGTH=
"10"
NOTNULL=
"true"
/>
<FIELD
NAME=
"can_view"
TYPE=
"int"
LENGTH=
"1"
NOTNULL=
"true"
/>
<FIELD
NAME=
"can_edit"
TYPE=
"int"
LENGTH=
"1"
NOTNULL=
"true"
/>
<FIELD
NAME=
"can_republish"
TYPE=
"int"
LENGTH=
"1"
NOTNULL=
"true"
/>
</FIELDS>
<KEYS>
<KEY
NAME=
"primary"
TYPE=
"primary"
FIELDS=
"role,artefact"
/>
<KEY
NAME=
"artefactfk"
TYPE=
"foreign"
FIELDS=
"artefact"
REFTABLE=
"artefact"
REFFIELDS=
"id"
/>
</KEYS>
</TABLE>
<TABLE
NAME=
"group"
>
<FIELDS>
<FIELD
NAME=
"id"
TYPE=
"int"
LENGTH=
"10"
NOTNULL=
"true"
SEQUENCE=
"true"
/>
...
...
htdocs/lib/db/upgrade.php
View file @
6b30b435
...
...
@@ -1070,6 +1070,21 @@ function xmldb_core_upgrade($oldversion=0) {
execute_sql
(
'ALTER TABLE {artefact} ADD CONSTRAINT {arte_gro_fk} FOREIGN KEY ("group") REFERENCES {group}(id)'
);
}
if
(
$oldversion
<
2008062301
)
{
execute_sql
(
'CREATE TABLE {artefact_access_role} (
role TEXT NOT NULL,
artefact INTEGER NOT NULL REFERENCES {artefact}(id),
can_view SMALLINT NOT NULL,
can_edit SMALLINT NOT NULL,
can_republish SMALLINT NOT NULL
);'
);
execute_sql
(
'CREATE TABLE {artefact_access_usr} (
usr INTEGER NOT NULL REFERENCES {usr}(id),
artefact INTEGER NOT NULL REFERENCES {artefact}(id),
can_republish SMALLINT
);'
);
}
return
$status
;
}
...
...
htdocs/lib/version.php
View file @
6b30b435
...
...
@@ -27,7 +27,7 @@
defined
(
'INTERNAL'
)
||
die
();
$config
=
new
StdClass
;
$config
->
version
=
200806230
0
;
$config
->
version
=
200806230
1
;
$config
->
release
=
'1.1.0alpha'
;
$config
->
minupgradefrom
=
2007080700
;
$config
->
minupgraderelease
=
'0.8.0 (release tag 0.8.0_RELEASE)'
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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