Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added options to select or deselect administration flags for students.

  • Loading branch information...
commit c513f599e5da410a5820cf52923e7f82f0fa24f7 1 parent 4b14ebd
mchurch authored
View
6 lang/en/help/wiki/studentadminoptions.html
@@ -0,0 +1,6 @@
+<P ALIGN=CENTER><B>Allow Binary Files</B></P>
+
+<P>Certain administration options can be turned 'on' or 'off' for students. When 'on', these options only
+take affect for wikis that can be edited by the student. When 'off', they will not appear in the administrator
+menu.
+</P>
View
1  lang/en/wiki.php
@@ -10,6 +10,7 @@
$string['ewikiprinttitle'] = 'Print the wiki name on every page.';
$string['htmlmode'] = 'HTML Mode';
$string['ewikiacceptbinary'] = 'Allow binary files';
+$string['studentadminoptions'] = 'Student admin options';
$string['initialcontent'] = 'Choose an Initial Page';
$string['chooseafile'] = 'Choose/upload initial page';
$string['pagenamechoice'] = '- or -';
View
8 mod/wiki/db/mysql.php
@@ -38,6 +38,14 @@ function wiki_upgrade($oldversion) {
}
}
+ if ($oldversion < 2004061300) {
+ execute_sql('ALTER TABLE `'.$CFG->prefix.'wiki`'
+ .' ADD `setpageflags` TINYINT DEFAULT \'1\' NOT NULL AFTER `ewikiacceptbinary`,'
+ .' ADD `strippages` TINYINT DEFAULT \'1\' NOT NULL AFTER `setpageflags`,'
+ .' ADD `removepages` TINYINT DEFAULT \'1\' NOT NULL AFTER `strippages`,'
+ .' ADD `revertchanges` TINYINT DEFAULT \'1\' NOT NULL AFTER `removepages`');
+ }
+
return true;
}
View
5 mod/wiki/db/mysql.sql
@@ -15,13 +15,16 @@ CREATE TABLE `prefix_wiki` (
`ewikiprinttitle` tinyint(4) NOT NULL default '1',
`htmlmode` tinyint(4) NOT NULL default '0',
`ewikiacceptbinary` tinyint(4) NOT NULL default '0',
+ `setpageflags` tinyint(4) NOT NULL default '1',
+ `strippages` tinyint(4) NOT NULL default '1',
+ `removepages` tinyint(4) NOT NULL default '1',
+ `revertchanges` tinyint(4) NOT NULL default '1',
`initialcontent` varchar(255) default NULL,
`timemodified` int(10) NOT NULL default '0',
PRIMARY KEY (`id`)
) TYPE=MyISAM COMMENT='Main wiki table';
-
#
# Table structure for table `mdl_wiki_entries`
#
View
2  mod/wiki/filter.php
@@ -27,7 +27,7 @@ function wiki_page_filter($courseid, $text) {
}
// Get all wikis for this course.
- $wikis = get_records('wiki', 'course', $courseid);
+ $wikis = wiki_get_course_wikis($courseid);
if (empty($wikis)) {
return $text;
}
View
72 mod/wiki/lib.php
@@ -23,6 +23,13 @@ function wiki_add_instance($wiki) {
/// Determine the pagename for this wiki and save.
$wiki->pagename = wiki_page_name($wiki);
+
+ /// Check 'check boxes'. The variables won't be set at all of they were deselected.
+ $wiki->setpageflags = (isset($wiki->setpageflags)) ? 1 : 0;
+ $wiki->removepages = (isset($wiki->removepages)) ? 1 : 0;
+ $wiki->strippages = (isset($wiki->strippages)) ? 1 : 0;
+ $wiki->revertchanges = (isset($wiki->revertchanges)) ? 1 : 0;
+
return insert_record("wiki", $wiki);
}
@@ -35,6 +42,12 @@ function wiki_update_instance($wiki) {
/// Determine the pagename for this wiki.
$wiki->pagename = wiki_page_name($wiki);
+ /// Check 'check boxes'. The variables won't be set at all of they were deselected.
+ $wiki->setpageflags = (isset($wiki->setpageflags)) ? 1 : 0;
+ $wiki->removepages = (isset($wiki->removepages)) ? 1 : 0;
+ $wiki->strippages = (isset($wiki->strippages)) ? 1 : 0;
+ $wiki->revertchanges = (isset($wiki->revertchanges)) ? 1 : 0;
+
$wiki->timemodified = time();
$wiki->id = $wiki->instance;
return update_record("wiki", $wiki);
@@ -241,6 +254,16 @@ function wiki_content_dir(&$wiki) {
return $contentdir;
}
+function wiki_get_course_wikis($courseid, $wtype='*') {
+/// Returns all wikis for the specified course and optionally of the specified type.
+
+ $select = 'course = '.$courseid;
+ if ($wtype != '*') {
+ $select .= ' AND wtype = \''.$wtype.'\'';
+ }
+ return get_records_select('wiki', $select, 'id');
+}
+
function wiki_has_entries(&$wiki) {
/// Returns true if wiki already has wiki entries; otherwise false.
@@ -265,6 +288,27 @@ function wiki_get_entries(&$wiki, $byindex=NULL) {
}
}
+function wiki_get_default_entry(&$wiki, &$course, $userid=0, $groupid=0) {
+/// Returns the wiki entry according to the wiki type.
+/// Optionally, will return wiki entry for $userid student wiki, or
+/// $groupid group or teacher wiki.
+/// Creates one if it needs to and it can.
+
+ global $USER;
+
+ /// If the wiki entry doesn't exist, can this user create it?
+ if (($wiki_entry = wiki_get_entry($wiki, $course, $userid, $groupid)) === false) {
+
+ if (wiki_can_add_entry($wiki, $USER, $course, $userid, $groupid)) {
+ wiki_add_entry($wiki, $course, $userid, $groupid);
+ if (($wiki_entry = wiki_get_entry($wiki, $course, $userid, $groupid)) === false) {
+ error("Could not add wiki entry.");
+ }
+ }
+ }
+ return $wiki_entry;
+}
+
function wiki_get_entry(&$wiki, &$course, $userid=0, $groupid=0) {
/// Returns the wiki entry according to the wiki type.
/// Optionally, will return wiki entry for $userid student wiki, or
@@ -948,16 +992,24 @@ function wiki_print_administration_actions($wiki, $cmid, $userid, $groupid, $wik
if (isset($wikipage)) $ewscript .= '&wikipage='.$wikipage;
$ewscript.="&action=";
-
- $action=array(
- "setpageflags" => get_string("setpageflags", "wiki"),
- );
- // We cannot do certain things if html is used !
- if($wiki->wtype=="student" || isteacher($course->id)) {
- $action["removepages"] = get_string("removepages", "wiki");
- $action["strippages"] = get_string("strippages", "wiki");
- $action["revertpages"] = get_string("revertpages", "wiki");
- }
+
+ /// Build that action array according to wiki flags.
+ $action = array();
+ $isteacher = isteacher($course->id);
+
+ if ($wiki->setpageflags or $isteacher) {
+ $action['setpageflags'] = get_string('setpageflags', 'wiki');
+ }
+ if ($wiki->removepages or $isteacher) {
+ $action['removepages'] = get_string('removepages', 'wiki');
+ }
+ if ($wiki->strippages or $isteacher) {
+ $action['strippages'] = get_string('strippages', 'wiki');
+ }
+ if ($wiki->revertchanges or $isteacher) {
+ $action['revertpages'] = get_string('revertpages', 'wiki');
+ }
+
if($noeditor) {
$action["checklinks"]=get_string("checklinks", "wiki");
}
View
37 mod/wiki/mod.html
@@ -28,9 +28,24 @@
if (!isset($form->ewikiacceptbinary)) {
$form->ewikiacceptbinary = 0;
}
+ if (!isset($form->setpageflags)) {
+ $form->setpageflags = 0;
+ }
+ if (!isset($form->strippages)) {
+ $form->strippages = 0;
+ }
+ if (!isset($form->removepages)) {
+ $form->removepages = 0;
+ }
+ if (!isset($form->revertchanges)) {
+ $form->revertchanges = 0;
+ }
if (!isset($form->initialcontent)) {
$form->initialcontent = '';
}
+ if (!isset($form->pagename)) {
+ $form->pagename = '';
+ }
/// If updating an existing wiki, find out if it has entries.
if ($form->id) {
@@ -102,6 +117,28 @@
</TR>
<tr valign="top">
+ <td align="right">
+ <?php helpbutton('studentadminoptions', get_string('studentadminoptions', 'wiki'), 'wiki') ?>
+ <b> <?php print_string('studentadminoptions', 'wiki') ?>:</b></td>
+ <td>
+ <table cellpadding="0" cellspacing="0" border="0" width="100%"><tr>
+ <td width="50%">
+ <input type="checkbox" name="setpageflags" value="1" <?php echo $form->setpageflags?"CHECKED":""; ?> />
+ Allow 'set page flags'<br />
+ <input type="checkbox" name="strippages" value="1" <?php echo $form->strippages?"CHECKED":""; ?> />
+ Allow 'strip pages'<br />
+ </td>
+ <td width="50%">
+ <input type="checkbox" name="removepages" value="1" <?php echo $form->removepages?"CHECKED":""; ?> />
+ Allow 'remove pages'<br />
+ <input type="checkbox" name="revertchanges" value="1" <?php echo $form->revertchanges?"CHECKED":""; ?> />
+ Allow 'revert mass changes'<br />
+ </td>
+ </tr></table>
+ </td>
+</tr>
+
+<tr valign="top">
<td align="right"><b> Optional: </b></td>
<td></td>
</tr>
View
2  mod/wiki/version.php
@@ -5,7 +5,7 @@
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
/////////////////////////////////////////////////////////////////////////////////
-$module->version = 2004060400; // The current module version (Date: YYYYMMDDXX)
+$module->version = 2004061300; // The current module version (Date: YYYYMMDDXX)
$module->cron = 0; // Period for cron to check this module (secs)
?>
View
39 mod/wiki/view.php
@@ -2,6 +2,8 @@
/// Extended by Michael Schneider
/// This page prints a particular instance of wiki
+ global $CFG;
+
require_once("../../config.php");
require_once("lib.php");
# require_once("$CFG->dirroot/course/lib.php"); // For side-blocks
@@ -52,37 +54,20 @@
/// Add the course module 'groupmode' to the wiki object, for easy access.
$wiki->groupmode = $cm->groupmode;
- /// If the wiki entry doesn't exist, can this user create it?
-
- if (($wiki_entry = wiki_get_entry($wiki, $course, $userid, $groupid)) === false) {
-
- if (wiki_can_add_entry($wiki, $USER, $course, $userid, $groupid)) {
- wiki_add_entry($wiki, $course, $userid, $groupid);
- if (($wiki_entry = wiki_get_entry($wiki, $course, $userid, $groupid)) === false) {
- error("Could not add wiki entry.");
- }
- }
- else {
- $wiki_entry_text = '<div align="center">'.get_string('nowikicreated', 'wiki').'</div>';
- }
- }
-
- /// How shall we display the wiki-page ?
+ /// Default format:
$moodle_format=FORMAT_MOODLE;
### SAVE ID from Moodle
$moodleID=@$_REQUEST["id"];
- if ($wiki_entry) {
-
+
+ if (($wiki_entry = wiki_get_default_entry($wiki, $course, $userid, $groupid))) {
+
+/// ################# EWIKI Part ###########################
/// The wiki_entry->pagename is set to the specified value of the wiki,
/// or the default value in the 'lang' file if the specified value was empty.
define("EWIKI_PAGE_INDEX",$wiki_entry->pagename);
$wikipage = ($wikipage === false) ? EWIKI_PAGE_INDEX: $wikipage;
-//////
-
-
-/// ################# EWIKI Part ###########################
/// ### Prevent ewiki getting id as PageID...
unset($_REQUEST["id"]);
@@ -195,10 +180,10 @@
$ewiki_use_editor=1;
$ewiki_config["htmlentities"]=array(); // HTML is allowed
$ewiki_config["wiki_link_regex"] = "\007 [!~]?(
- \#?\[[^<>\[\]\n]+\] |
- \^[-".EWIKI_CHARS_U.EWIKI_CHARS_L."]{3,} |
- \b([\w]{3,}:)*([".EWIKI_CHARS_U."]+[".EWIKI_CHARS_L."]+){2,}\#?[\w\d]* |
- \w[-_.+\w]+@(\w[-_\w]+[.])+\w{2,} ) \007x";
+ \#?\[[^<>\[\]\n]+\] |
+ \^[-".EWIKI_CHARS_U.EWIKI_CHARS_L."]{3,} |
+ \b([\w]{3,}:)*([".EWIKI_CHARS_U."]+[".EWIKI_CHARS_L."]+){2,}\#?[\w\d]* |
+ \w[-_.+\w]+@(\w[-_\w]+[.])+\w{2,} ) \007x";
}
global $ewiki_author, $USER;
@@ -211,7 +196,7 @@
/// ################# EWIKI Part ###########################
}
else {
- $content = $wiki_entry_text;
+ $content = '<div align="center">'.get_string('nowikicreated', 'wiki').'</div>';
}
Please sign in to comment.
Something went wrong with that request. Please try again.