Skip to content

Commit

Permalink
MDL-23929 WIKI, fixed has_capability parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
Dongsheng Cai committed Nov 19, 2010
1 parent 7a534d7 commit cece179
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 32 deletions.
54 changes: 27 additions & 27 deletions mod/wiki/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -704,20 +704,20 @@ function wiki_user_can_view($subwiki) {
// There is one wiki for all the class.
//
// Only view capbility needed
return has_capability('mod/wiki:viewpage', $context, $USER);
return has_capability('mod/wiki:viewpage', $context);
} else if ($wiki->wikimode == 'individual') {
// Individual Mode:
// Each person owns a wiki.
if ($subwiki->userid == $USER->id) {
// Only the owner of the wiki can view it
return has_capability('mod/wiki:viewpage', $context, $USER);
return has_capability('mod/wiki:viewpage', $context);
} else { // User has special capabilities
// User must have:
// mod/wiki:viewpage capability
// and
// mod/wiki:managewiki capability
$view = has_capability('mod/wiki:viewpage', $context, $USER);
$manage = has_capability('mod/wiki:managewiki', $context, $USER);
$view = has_capability('mod/wiki:viewpage', $context);
$manage = has_capability('mod/wiki:managewiki', $context);

return $view && $manage;
}
Expand All @@ -736,7 +736,7 @@ function wiki_user_can_view($subwiki) {
// Only members of subwiki group could view that wiki
if ($subwiki->groupid == groups_get_activity_group($cm)) {
// Only view capability needed
return has_capability('mod/wiki:viewpage', $context, $USER);
return has_capability('mod/wiki:viewpage', $context);

} else { // User is not part of that group
// User must have:
Expand All @@ -745,9 +745,9 @@ function wiki_user_can_view($subwiki) {
// moodle/site:accessallgroups capability
// and
// mod/wiki:viewpage capability
$view = has_capability('mod/wiki:viewpage', $context, $USER);
$manage = has_capability('mod/wiki:managewiki', $context, $USER);
$access = has_capability('moodle/site:accessallgroups', $context, $USER);
$view = has_capability('mod/wiki:viewpage', $context);
$manage = has_capability('mod/wiki:managewiki', $context);
$access = has_capability('moodle/site:accessallgroups', $context);
return ($manage || $access) && $view;
}
} else {
Expand All @@ -765,7 +765,7 @@ function wiki_user_can_view($subwiki) {
// Everybody can read all wikis
//
// Only view capability needed
return has_capability('mod/wiki:viewpage', $context, $USER);
return has_capability('mod/wiki:viewpage', $context);
} else {
//Error
return false;
Expand Down Expand Up @@ -796,22 +796,22 @@ function wiki_user_can_edit($subwiki) {
// There is a wiki for all the class.
//
// Only edit capbility needed
return has_capability('mod/wiki:editpage', $context, $USER);
return has_capability('mod/wiki:editpage', $context);
} else if ($wiki->wikimode == 'individual') {
// Individual Mode
// There is a wiki per user

// Only the owner of that wiki can edit it
if ($subwiki->userid == $USER->id) {
return has_capability('mod/wiki:editpage', $context, $USER);
return has_capability('mod/wiki:editpage', $context);
} else { // Current user is not the owner of that wiki.

// User must have:
// mod/wiki:editpage capability
// and
// mod/wiki:managewiki capability
$edit = has_capability('mod/wiki:editpage', $context, $USER);
$manage = has_capability('mod/wiki:managewiki', $context, $USER);
$edit = has_capability('mod/wiki:editpage', $context);
$manage = has_capability('mod/wiki:managewiki', $context);

return $edit && $manage;
}
Expand All @@ -827,17 +827,17 @@ function wiki_user_can_edit($subwiki) {
// Only members of subwiki group could edit that wiki
if ($subwiki->groupid == groups_get_activity_group($cm)) {
// Only edit capability needed
return has_capability('mod/wiki:editpage', $context, $USER);
return has_capability('mod/wiki:editpage', $context);
} else { // User is not part of that group
// User must have:
// mod/wiki:managewiki capability
// and
// moodle/site:accessallgroups capability
// and
// mod/wiki:editpage capability
$manage = has_capability('mod/wiki:managewiki', $context, $USER);
$access = has_capability('moodle/site:accessallgroups', $context, $USER);
$edit = has_capability('mod/wiki:editpage', $context, $USER);
$manage = has_capability('mod/wiki:managewiki', $context);
$access = has_capability('moodle/site:accessallgroups', $context);
$edit = has_capability('mod/wiki:editpage', $context);
return $manage && $access && $edit;
}
} else if ($wiki->wikimode == 'individual') {
Expand All @@ -846,17 +846,17 @@ function wiki_user_can_edit($subwiki) {
//
// Only the owner of that wiki can edit it
if ($subwiki->userid == $USER->id) {
return has_capability('mod/wiki:editpage', $context, $USER);
return has_capability('mod/wiki:editpage', $context);
} else { // Current user is not the owner of that wiki.
// User must have:
// mod/wiki:managewiki capability
// and
// moodle/site:accessallgroups capability
// and
// mod/wiki:editpage capability
$manage = has_capability('mod/wiki:managewiki', $context, $USER);
$access = has_capability('moodle/site:accessallgroups', $context, $USER);
$edit = has_capability('mod/wiki:editpage', $context, $USER);
$manage = has_capability('mod/wiki:managewiki', $context);
$access = has_capability('moodle/site:accessallgroups', $context);
$edit = has_capability('mod/wiki:editpage', $context);
return $manage && $access && $edit;
}
} else {
Expand All @@ -871,14 +871,14 @@ function wiki_user_can_edit($subwiki) {
// Only members of subwiki group could edit that wiki
if ($subwiki->groupid == groups_get_activity_group($cm)) {
// Only edit capability needed
return has_capability('mod/wiki:editpage', $context, $USER);
return has_capability('mod/wiki:editpage', $context);
} else { // User is not part of that group
// User must have:
// mod/wiki:managewiki capability
// and
// mod/wiki:editpage capability
$manage = has_capability('mod/wiki:managewiki', $context, $USER);
$edit = has_capability('mod/wiki:editpage', $context, $USER);
$manage = has_capability('mod/wiki:managewiki', $context);
$edit = has_capability('mod/wiki:editpage', $context);
return $manage && $edit;
}
} else if ($wiki->wikimode == 'individual') {
Expand All @@ -887,14 +887,14 @@ function wiki_user_can_edit($subwiki) {
//
// Only the owner of that wiki can edit it
if ($subwiki->userid == $USER->id) {
return has_capability('mod/wiki:editpage', $context, $USER);
return has_capability('mod/wiki:editpage', $context);
} else { // Current user is not the owner of that wiki.
// User must have:
// mod/wiki:managewiki capability
// and
// mod/wiki:editpage capability
$manage = has_capability('mod/wiki:managewiki', $context, $USER);
$edit = has_capability('mod/wiki:editpage', $context, $USER);
$manage = has_capability('mod/wiki:managewiki', $context);
$edit = has_capability('mod/wiki:editpage', $context);
return $manage && $edit;
}
} else {
Expand Down
8 changes: 4 additions & 4 deletions mod/wiki/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,8 @@ public function wiki_print_subwiki_selector($wiki, $subwiki, $page) {
} else if ($wiki->wikimode == 'individual') {
// We have private wikis here

$view = has_capability('mod/wiki:viewpage', $context, $USER);
$manage = has_capability('mod/wiki:managewiki', $context, $USER);
$view = has_capability('mod/wiki:viewpage', $context);
$manage = has_capability('mod/wiki:managewiki', $context);

// Only people with these capabilities can view all wikis
if ($view && $manage) {
Expand Down Expand Up @@ -340,8 +340,8 @@ public function wiki_print_subwiki_selector($wiki, $subwiki, $page) {
return;
} else if ($wiki->wikimode == 'individual') {
// @TODO: Print here a combo that contains all users of that subwiki.
$view = has_capability('mod/wiki:viewpage', $context, $USER);
$manage = has_capability('mod/wiki:managewiki', $context, $USER);
$view = has_capability('mod/wiki:viewpage', $context);
$manage = has_capability('mod/wiki:managewiki', $context);

// Only people with these capabilities can view all wikis
if ($view && $manage) {
Expand Down
2 changes: 1 addition & 1 deletion mod/wiki/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@
// *
// * Error. No more options
// */
} else {
} else {
print_error('incorrectparameters');
}
require_course_login($course, true, $cm);
Expand Down

0 comments on commit cece179

Please sign in to comment.