From: mchurch <mchurch> Date: Sun, 13 Jun 2004 19:41:47 +0000 (+0000) Subject: Added options to select or deselect administration flags for students. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=c513f599e5da410a5820cf52923e7f82f0fa24f7;p=moodle.git Added options to select or deselect administration flags for students. --- diff --git a/lang/en/help/wiki/studentadminoptions.html b/lang/en/help/wiki/studentadminoptions.html new file mode 100644 index 0000000000..59d7535cb1 --- /dev/null +++ b/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> diff --git a/lang/en/wiki.php b/lang/en/wiki.php index 3da1879588..7342983414 100644 --- a/lang/en/wiki.php +++ b/lang/en/wiki.php @@ -10,6 +10,7 @@ $string['wikitype'] = 'Type'; $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 -'; diff --git a/mod/wiki/db/mysql.php b/mod/wiki/db/mysql.php index 16dcdc3230..e6421f7c30 100644 --- a/mod/wiki/db/mysql.php +++ b/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; } diff --git a/mod/wiki/db/mysql.sql b/mod/wiki/db/mysql.sql index 32b6c19ab6..d52f88120a 100644 --- a/mod/wiki/db/mysql.sql +++ b/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` # diff --git a/mod/wiki/filter.php b/mod/wiki/filter.php index 3ad5f65566..900683e2ba 100755 --- a/mod/wiki/filter.php +++ b/mod/wiki/filter.php @@ -27,7 +27,7 @@ } // Get all wikis for this course. - $wikis = get_records('wiki', 'course', $courseid); + $wikis = wiki_get_course_wikis($courseid); if (empty($wikis)) { return $text; } diff --git a/mod/wiki/lib.php b/mod/wiki/lib.php index c18a219529..9b37a12c24 100644 --- a/mod/wiki/lib.php +++ b/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"); } diff --git a/mod/wiki/mod.html b/mod/wiki/mod.html index 1af045a190..c6b66b590d 100644 --- a/mod/wiki/mod.html +++ b/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) { @@ -101,6 +116,28 @@ </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> diff --git a/mod/wiki/version.php b/mod/wiki/version.php index d6a36adc28..9d446606a4 100644 --- a/mod/wiki/version.php +++ b/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) ?> diff --git a/mod/wiki/view.php b/mod/wiki/view.php index dc61808eab..09cd3debc7 100644 --- a/mod/wiki/view.php +++ b/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>'; }