]> git.mjollnir.org Git - moodle.git/commitdiff
Added options to select or deselect administration flags for students.
authormchurch <mchurch>
Sun, 13 Jun 2004 19:41:47 +0000 (19:41 +0000)
committermchurch <mchurch>
Sun, 13 Jun 2004 19:41:47 +0000 (19:41 +0000)
lang/en/help/wiki/studentadminoptions.html [new file with mode: 0644]
lang/en/wiki.php
mod/wiki/db/mysql.php
mod/wiki/db/mysql.sql
mod/wiki/filter.php
mod/wiki/lib.php
mod/wiki/mod.html
mod/wiki/version.php
mod/wiki/view.php

diff --git a/lang/en/help/wiki/studentadminoptions.html b/lang/en/help/wiki/studentadminoptions.html
new file mode 100644 (file)
index 0000000..59d7535
--- /dev/null
@@ -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>
index 3da18795880066c7089b1f8300881d19c4e8f07b..73429834145c5b3a87f62f5522ac42ed5360cc11 100644 (file)
@@ -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 -';
index 16dcdc32308c66af92bc09e696e42db559adb3aa..e6421f7c3098106c73785d9d70793b74bc7d5886 100644 (file)
@@ -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;
 }
 
index 32b6c19ab63f93f019da4895f9e8797c0b55f4cc..d52f88120a757c95f271a89db32382cbb8c5c135 100644 (file)
@@ -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`
 #
index 3ad5f655668abb7a1f6092b11fcf62660e108cca..900683e2babb20f6285e4e4bf628069180208bb2 100755 (executable)
@@ -27,7 +27,7 @@
         }\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
index c18a219529821dcdd567af8d54862ad4b366aca4..9b37a12c24badc795e998d64648401221f9595ac 100644 (file)
@@ -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");
   }
index 1af045a1906cf0fb208629e3e75979c229e569c8..c6b66b590d7359f5de2fa0c3bf73549483a652ee 100644 (file)
     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>
index d6a36adc287d8d760d28372d18d05490b6ca15f1..9d446606a423e1f6cf9d2cc1ba00165083602a49 100644 (file)
@@ -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)
 
 ?>
index dc61808eabbe4799e68979f805bd29fe136b79e4..09cd3debc7c593332dc7f203590d596fd2cbe41a 100644 (file)
@@ -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
     /// 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>';
     }