mod-wiki MDL-19817 Added set_url calls, replaced deprecated functions
This commit is contained in:
+37
-13
@@ -1,4 +1,4 @@
|
||||
<?PHP // $Id$
|
||||
<?PHP
|
||||
/// Extended by Michael Schneider
|
||||
|
||||
require_once("../../config.php");
|
||||
@@ -37,6 +37,24 @@
|
||||
}
|
||||
}
|
||||
|
||||
$url = new moodle_url($CFG->wwwroot.'/mod/wiki/admin.php', array('id'=>$cm->id));
|
||||
if ($page !== false) {
|
||||
$url->param('page', $page);
|
||||
}
|
||||
if ($confirm !== '') {
|
||||
$url->param('confirm', $confirm);
|
||||
}
|
||||
if ($action !== '') {
|
||||
$url->param('action', $action);
|
||||
}
|
||||
if ($userid !== 0) {
|
||||
$url->param('userid', $userid);
|
||||
}
|
||||
if ($groupid !== 0) {
|
||||
$url->param('groupid', $groupid);
|
||||
}
|
||||
$PAGE->set_url($url);
|
||||
|
||||
require_login($course->id, false, $cm);
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
require_capability('mod/wiki:manage', $context);
|
||||
@@ -118,7 +136,7 @@
|
||||
$PAGE->navbar->add(get_string("administration","wiki"));
|
||||
$PAGE->set_title($wiki_entry->pagename);
|
||||
$PAGE->set_focuscontrol($focus);
|
||||
$PAGE->set_button(update_module_button($cm->id, $course->id, $strwiki));
|
||||
$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'wiki'));
|
||||
echo $OUTPUT->header();
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
@@ -302,10 +320,10 @@
|
||||
/// Page Actions
|
||||
echo '<table border="0" width="100%">';
|
||||
echo '<tr>';
|
||||
# echo '<tr><td align="center">';
|
||||
# $specialpages=array("SearchPages", "PageIndex","NewestPages","MostVisitedPages","MostOftenChangedPages","UpdatedPages","FileDownload","FileUpload","OrphanedPages","WantedPages");
|
||||
# wiki_print_page_actions($cm->id, $specialpages, $ewiki_id, $ewiki_action, $wiki->ewikiacceptbinary, $canedit);
|
||||
# echo '</td>';
|
||||
/* echo '<tr><td align="center">';
|
||||
* $specialpages=array("SearchPages", "PageIndex","NewestPages","MostVisitedPages","MostOftenChangedPages","UpdatedPages","FileDownload","FileUpload","OrphanedPages","WantedPages");
|
||||
* wiki_print_page_actions($cm->id, $specialpages, $ewiki_id, $ewiki_action, $wiki->ewikiacceptbinary, $canedit);
|
||||
* echo '</td>';*/
|
||||
|
||||
/// Searchform
|
||||
echo '<td align="center">';
|
||||
@@ -324,12 +342,12 @@
|
||||
wiki_print_administration_actions($wiki, $cm->id, $userid, $groupid, $page, $wiki->htmlmode!=2, $course);
|
||||
echo '</td>';
|
||||
|
||||
# if($wiki->htmlmode!=2) {
|
||||
# echo '<td align="center">';
|
||||
# helpbutton('formattingrules', get_string('formattingrules', 'wiki'), 'wiki');
|
||||
# echo get_string("formattingrules","wiki");
|
||||
# echo '</td>';
|
||||
# }
|
||||
/** if($wiki->htmlmode!=2) {
|
||||
* echo '<td align="center">';
|
||||
* helpbutton('formattingrules', get_string('formattingrules', 'wiki'), 'wiki');
|
||||
* echo get_string("formattingrules","wiki");
|
||||
* echo '</td>';
|
||||
* }*/
|
||||
|
||||
echo '</tr></table>';
|
||||
}
|
||||
@@ -338,7 +356,13 @@
|
||||
echo $OUTPUT->box_start();
|
||||
// Do the Action
|
||||
# "setpageflags", "removepages", "strippages", "checklinks", "revertpages"
|
||||
print_heading_with_help(get_string($action,"wiki"), $action, "wiki");
|
||||
|
||||
$helpicon = new moodle_help_icon();
|
||||
$helpicon->text = get_string($action,"wiki");
|
||||
$helpicon->page = $action;
|
||||
$helpicon->module = "wiki";
|
||||
echo $OUTPUT->heading_with_help($helpicon);
|
||||
|
||||
include $action.".html";
|
||||
echo $OUTPUT->box_end();
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
|
||||
require_once("../../config.php");
|
||||
|
||||
$PAGE->set_url($CFG->wwwroot.'/mod/wiki/confirmlock.php');
|
||||
|
||||
header('Content-Type: text/plain');
|
||||
|
||||
$lockid = optional_param('lockid', 0, PARAM_INT);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php // $Id$
|
||||
<?php
|
||||
require_once("../../config.php");
|
||||
require_once($CFG->libdir.'/filelib.php');
|
||||
|
||||
|
||||
+3
-1
@@ -1,4 +1,4 @@
|
||||
<?PHP // $Id$
|
||||
<?PHP
|
||||
|
||||
/// This page lists all the instances of wiki in a particular course
|
||||
/// Replace wiki with the name of your module
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
$id = required_param('id', PARAM_INT); // course
|
||||
|
||||
$PAGE->set_url(new moodle_url($CFG->wwwroot.'/mod/wiki/index.php', array('id'=>$id)));
|
||||
|
||||
if (!$course = $DB->get_record('course', array('id'=>$id))) {
|
||||
print_error('invalidcourseid');
|
||||
}
|
||||
|
||||
+63
-14
@@ -557,7 +557,11 @@ function wiki_get_default_entry(&$wiki, &$course, $userid=0, $groupid=0) {
|
||||
$groupmode = groups_get_activity_groupmode($wiki);
|
||||
// if groups mode is in use and no group supplied, use the first one found
|
||||
if ($groupmode && !$groupid) {
|
||||
if(($mygroupids=mygroupid($course->id)) && count($mygroupids)>0) {
|
||||
$mygroupids = groups_get_all_groups($course->id, $USER->id);
|
||||
if ($mygroupids) {
|
||||
$mygroupids = array_keys($mygroupids);
|
||||
}
|
||||
if($mygroupids && count($mygroupids)>0) {
|
||||
// Use first group. They ought to be able to change later
|
||||
$groupid=$mygroupids[0];
|
||||
} else {
|
||||
@@ -622,7 +626,11 @@ function wiki_get_entry(&$wiki, &$course, $userid=0, $groupid=0) {
|
||||
$groupmode = groups_get_activity_groupmode($wiki);
|
||||
if($groupmode) {
|
||||
if(!$groupid) {
|
||||
if(($mygroupids=mygroupid($course->id)) && count($mygroupids)>0) {
|
||||
$mygroupids = groups_get_all_groups($course->id, $USER->id);
|
||||
if ($mygroupids) {
|
||||
$mygroupids = array_keys($mygroupids);
|
||||
}
|
||||
if($mygroupids && count($mygroupids)>0) {
|
||||
// Use first group. They ought to be able to change later
|
||||
$groupid=$mygroupids[0];
|
||||
} else {
|
||||
@@ -652,8 +660,18 @@ function wiki_get_entry(&$wiki, &$course, $userid=0, $groupid=0) {
|
||||
|
||||
case 'teacher':
|
||||
/// If there is a groupmode, get the user's group id.
|
||||
if (groupmode($course, $wiki)) {
|
||||
$mygroupids = mygroupid($course->id);//same here, default to the first one
|
||||
|
||||
if (isset($cm->groupmode) && empty($course->groupmodeforce)) {
|
||||
$groupmode = $cm->groupmode;
|
||||
} else {
|
||||
$groupmode = $course->groupmode;
|
||||
}
|
||||
|
||||
if ($groupmode) {
|
||||
$mygroupids = groups_get_all_groups($course->id, $USER->id);
|
||||
if ($mygroupids) {
|
||||
$mygroupids = array_keys($mygroupids);
|
||||
}
|
||||
$groupid = $groupid ? $groupid : $mygroupids[0]/*mygroupid($course->id)*/;
|
||||
}
|
||||
|
||||
@@ -724,12 +742,15 @@ function wiki_get_student_entry(&$wiki, $userid=null) {
|
||||
* @return array
|
||||
*/
|
||||
function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
|
||||
global $CFG, $id, $DB;
|
||||
global $CFG, $id, $DB, $USER;
|
||||
|
||||
$wikis = false;
|
||||
|
||||
$groupmode = groups_get_activity_groupmode($wiki);
|
||||
$mygroupid = mygroupid($course->id);
|
||||
$mygroupid = groups_get_all_groups($course->id, $USER->id);
|
||||
if ($mygroupid) {
|
||||
$mygroupid = array_keys($mygroupid);
|
||||
}
|
||||
$isteacher = wiki_is_teacher($wiki, $user->id);
|
||||
$isteacheredit = wiki_is_teacheredit($wiki, $user->id);
|
||||
|
||||
@@ -860,7 +881,10 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
|
||||
$viewall = true;
|
||||
}
|
||||
else if ($groupmode == SEPARATEGROUPS) {
|
||||
$viewall = mygroupid($course->id);
|
||||
$viewall = groups_get_all_groups($course->id, $USER->id);
|
||||
if ($viewall) {
|
||||
$viewall = array_keys($viewall);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$viewall = false;
|
||||
@@ -1114,7 +1138,10 @@ function wiki_add_entry(&$wiki, &$course, $userid=0, $groupid=0) {
|
||||
$groupmode = groups_get_activity_groupmode($wiki);
|
||||
|
||||
///give the first groupid by default and try
|
||||
$mygroups = mygroupid($course->id);
|
||||
$mygroups = groups_get_all_groups($course->id, $USER->id);
|
||||
if ($mygroups) {
|
||||
$mygroups = array_keys($mygroups);
|
||||
}
|
||||
|
||||
/// If there is a groupmode, get the group id.
|
||||
if ($groupmode) {
|
||||
@@ -1137,7 +1164,10 @@ function wiki_add_entry(&$wiki, &$course, $userid=0, $groupid=0) {
|
||||
|
||||
/// If there is a groupmode, get the user's group id.
|
||||
if ($groupmode and $groupid == 0) {
|
||||
$mygroupid = mygroupid($course->id);
|
||||
$mygroupid = groups_get_all_groups($course->id, $USER->id);
|
||||
if ($mygroupid) {
|
||||
$mygroupid = array_keys($mygroupid);
|
||||
}
|
||||
$groupid = $mygroupid[0]/*mygroupid($course->id)*/;
|
||||
}
|
||||
|
||||
@@ -1164,9 +1194,13 @@ function wiki_add_entry(&$wiki, &$course, $userid=0, $groupid=0) {
|
||||
* @return bool
|
||||
*/
|
||||
function wiki_can_add_entry(&$wiki, &$user, &$course, $userid=0, $groupid=0) {
|
||||
global $USER;
|
||||
/// Get the groupmode. It's been added to the wiki object.
|
||||
$groupmode = groups_get_activity_groupmode($wiki);
|
||||
$mygroupid = mygroupid($course->id);
|
||||
$mygroupid = groups_get_all_groups($course->id, $USER->id);
|
||||
if ($mygroupid) {
|
||||
$mygroupid = array_keys($mygroupid);
|
||||
}
|
||||
|
||||
switch ($wiki->wtype) {
|
||||
|
||||
@@ -1242,7 +1276,10 @@ function wiki_can_edit_entry(&$wiki_entry, &$wiki, &$user, &$course) {
|
||||
|
||||
$can_edit = false;
|
||||
$groupmode = groups_get_activity_groupmode($wiki);
|
||||
$mygroupid = mygroupid($course->id);
|
||||
$mygroupid = groups_get_all_groups($course->id, $USER->id);
|
||||
if ($mygroupid) {
|
||||
$mygroupid = array_keys($mygroupid);
|
||||
}
|
||||
|
||||
/// Editing teacher's and admins can edit all wikis, non-editing teachers can edit wikis in their groups,
|
||||
/// or all wikis if group mode is 'no groups' or they don't belong to a group.
|
||||
@@ -1299,7 +1336,10 @@ function wiki_user_can_access_student_wiki(&$wiki, $userid, &$course) {
|
||||
|
||||
/// Get the groupmode. It's been added to the wiki object.
|
||||
$groupmode = groups_get_activity_groupmode($wiki);
|
||||
$usersgroup = mygroupid($course->id);
|
||||
$usersgroup = groups_get_all_groups($course->id, $USER->id);
|
||||
if ($usersgroup) {
|
||||
$usersgroup = array_keys($usersgroup);
|
||||
}
|
||||
$isteacher = wiki_is_teacher($wiki, $USER->id);
|
||||
|
||||
/// If this user is allowed to access this wiki then return TRUE.
|
||||
@@ -1336,7 +1376,10 @@ function wiki_user_can_access_group_wiki(&$wiki, $groupid, &$course) {
|
||||
|
||||
/// Get the groupmode. It's been added to the wiki object.
|
||||
$groupmode = groups_get_activity_groupmode($wiki);
|
||||
$usersgroup = mygroupid($course->id);
|
||||
$usersgroup = groups_get_all_groups($course->id, $USER->id);
|
||||
if ($usersgroup) {
|
||||
$usersgroup = array_keys($usersgroup);
|
||||
}
|
||||
$isteacher = wiki_is_teacher($wiki, $USER->id);
|
||||
|
||||
/// A user can access a group wiki, if:
|
||||
@@ -1375,8 +1418,14 @@ function wiki_user_can_access_teacher_wiki(&$wiki, $groupid, &$course) {
|
||||
/// - group mode is VISIBLEGROUPS,
|
||||
/// - group mode is SEPARATEGROUPS, and they are a member of the requested group,
|
||||
/// - they are a teacher or administrator,
|
||||
|
||||
$mygroupids = groups_get_all_groups($course->id, $USER->id);
|
||||
if ($mygroupids) {
|
||||
$mygroupids = array_keys($mygroupids);
|
||||
}
|
||||
|
||||
if (($groupmode == NOGROUPS) or ($groupmode == VISIBLEGROUPS) or
|
||||
(($groupmode == SEPARATEGROUPS) and (@in_array($groupid, mygroupid($course->id))/*mygroupid($course->id) == $groupid*/)) or
|
||||
(($groupmode == SEPARATEGROUPS) and (@in_array($groupid, $mygroupids)/*mygroupid($course->id) == $groupid*/)) or
|
||||
(wiki_is_teacher($wiki, $USER->id))){
|
||||
$can_access = true;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ require_once('../../config.php');
|
||||
$id=required_param('id',PARAM_INT);
|
||||
$page=required_param('page',PARAM_RAW);
|
||||
|
||||
$PAGE->set_url(new moodle_url($CFG->wwwroot.'/mod/wiki/overridelock.php', array('id'=>$id, 'page'=>$page)));
|
||||
|
||||
if (! $cm = get_coursemodule_from_id('wiki', $id)) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
+4
-2
@@ -1,4 +1,4 @@
|
||||
<?php // $Id$
|
||||
<?php
|
||||
/// Extended by Michael Schneider
|
||||
/// This page prints a particular instance of wiki
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
// Only want to add edit log entries if we have made some changes ie submitted a form
|
||||
$editsave = optional_param('thankyou', '', PARAM_RAW);
|
||||
|
||||
$PAGE->set_url(new moodle_url($FULLME));
|
||||
|
||||
if($page) {
|
||||
// Split page command into action and page
|
||||
$actions = explode('/', $page,2);
|
||||
@@ -271,7 +273,7 @@
|
||||
}
|
||||
$PAGE->set_title($ewiki_title?$ewiki_title:format_string($wiki->name));
|
||||
$PAGE->set_cacheable($cacheme);
|
||||
$PAGE->set_button(update_module_button($cm->id, $course->id, $strwiki));
|
||||
$PAGE->set_button($OUTPUT->update_module_button($cm->id, 'wiki'));
|
||||
echo $OUTPUT->header();
|
||||
/// Print Page
|
||||
echo ' <div id="wikiPageActions">
|
||||
|
||||
Reference in New Issue
Block a user