--- /dev/null
+<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>
$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 -';
}
}
+ 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;
}
`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`
#
}\r
\r
// Get all wikis for this course.\r
- $wikis = get_records('wiki', 'course', $courseid);\r
+ $wikis = wiki_get_course_wikis($courseid);\r
if (empty($wikis)) {\r
return $text;\r
}\r
/// 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);
}
/// 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);
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.
}
}
+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
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");
}
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) {
</TD>
</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>
/// 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)
?>
/// 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
/// 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"]);
$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;
/// ################# EWIKI Part ###########################
}
else {
- $content = $wiki_entry_text;
+ $content = '<div align="center">'.get_string('nowikicreated', 'wiki').'</div>';
}