Skip to content

Commit

Permalink
basic conversion of old wiki to new roles framework
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Sep 10, 2006
1 parent 07642ae commit ee3cc99
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 50 deletions.
4 changes: 3 additions & 1 deletion mod/wiki/admin.php
Expand Up @@ -38,6 +38,8 @@
}

require_login($course->id, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/wiki:manage', $context);

/// Build the ewsiki script constant
$ewbase = 'view.php?id='.$id;
Expand Down Expand Up @@ -73,7 +75,7 @@
$canedit = wiki_can_edit_entry($wiki_entry, $wiki, $USER, $course);
# Check for dangerous events (hacking) !
if(in_array($action,array("removepages","strippages","revertpages"))) {
if(!($wiki->wtype=="student" || ($wiki->wtype=="group" and $canedit) || isteacher($course->id))) {
if(!($wiki->wtype=="student" || ($wiki->wtype=="group" and $canedit) || wiki_is_teacher($wiki))) {
add_to_log($course->id, "wiki", "hack", "", $wiki->name.": Tried to trick admin.php with action=$action.");
error("Hack attack detected !");
}
Expand Down
64 changes: 64 additions & 0 deletions mod/wiki/db/access.php
@@ -0,0 +1,64 @@
<?php // $Id$
/**
* Capability definitions for the wiki module.
*
* For naming conventions, see lib/db/access.php.
*/
$mod_wiki_capabilities = array(

'mod/wiki:view' => array(

'captype' => 'read',
'contextlevel' => CONTEXT_MODULE,
'legacy' => array(
'guest' => CAP_ALLOW,
'student' => CAP_ALLOW,
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
'coursecreator' => CAP_ALLOW,
'admin' => CAP_ALLOW
)
),

'mod/wiki:participate' => array(

'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
'legacy' => array(
'guest' => CAP_PREVENT,
'student' => CAP_ALLOW,
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
'coursecreator' => CAP_PREVENT,
'admin' => CAP_PREVENT
)
),

'mod/wiki:manage' => array(

'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
'legacy' => array(
'guest' => CAP_PREVENT,
'student' => CAP_PREVENT,
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
'coursecreator' => CAP_PREVENT,
'admin' => CAP_ALLOW
)
),

'mod/wiki:manageallgroups' => array(

'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
'legacy' => array(
'guest' => CAP_PREVENT,
'student' => CAP_PREVENT,
'teacher' => CAP_PREVENT,
'editingteacher' => CAP_ALLOW,
'coursecreator' => CAP_PREVENT,
'admin' => CAP_ALLOW
)
)
);
4 changes: 2 additions & 2 deletions mod/wiki/ewiki/plugins/moodle/moodle_wikidump.php
Expand Up @@ -108,7 +108,7 @@ function moodle_ewiki_page_wiki_dump($id=0, $data=0, $action=0) {
" </TR>\n";
/// Destination
$exportdestinations=array("0" => get_string("downloadaszip","wiki"));
if(isteacher($course->id)) {
if(wiki_is_teacher($wiki)) {
// Get Directory List
$rawdirs = get_directory_list("$CFG->dataroot/$course->id", 'moddata', true, true, false);

Expand Down Expand Up @@ -229,7 +229,7 @@ function ewiki_page_wiki_dump_send($exportbinaries=0, $exportformats=0, $withvir
/// Create/Set Directory
$wname=clean_filename(strip_tags(format_string($wiki->name,true)));
if($exportdestinations) {
if(isteacher($course->id)) {
if(wiki_is_teacher($wiki)) {
$exportdir=$CFG->dataroot."/".$course->id."/".$exportdestinations;
} else {
add_to_log($course->id, "wiki", "hack", "", format_string($wiki->name,true).": Tried to export a wiki as non-teacher into $exportdestinations.");
Expand Down

0 comments on commit ee3cc99

Please sign in to comment.