Permalink
Browse files

- Cleaning a lot of code in edit.php and view.php

- Removing more notices when debug is ON
- Added a new feature: Now the entries have a default approval status... Not approved entries are shown on a teachers-only frame from which they can be approved or not prior to be visible by everyone.
  • Loading branch information...
willcast
willcast committed Oct 21, 2003
1 parent 016f1be commit c76e673ab527e77025b1249041cfd097b501efdc
View
@@ -0,0 +1,38 @@
+<?php
+
+ require_once("../../config.php");
+ require_once("lib.php");
+
+ require_variable($id); // Course Module ID
+ optional_variable($eid); // Entry ID
+
+ optional_variable($tab,GLOSSARY_APPROVAL_VIEW);
+ optional_variable($l,"ALL");
+
+ if (! $cm = get_record("course_modules", "id", $id)) {
+ error("Course Module ID was incorrect");
+ }
+
+ if (! $course = get_record("course", "id", $cm->course)) {
+ error("Course is misconfigured");
+ }
+
+ if (! $glossary = get_record("glossary", "id", $cm->instance)) {
+ error("Course module is incorrect");
+ }
+
+ require_login($course->id);
+ if (!isteacher($course->id)) {
+ error("You must be a teacher to use this page.");
+ }
+ $newentry->id = $eid;
+ $newentry->approved = 1;
+
+ if (! update_record("glossary_entries", $newentry)) {
+ error("Could not update your glossary");
+ } else {
+ add_to_log($course->id, "glossary", "approve entry", "showentry.php?id=$cm->id&eid=$eid", "$eid");
+ }
+ redirect("view.php?id=$cm->id&tab=$tab&l=ALL");
+ die;
+?>
View
Binary file not shown.
View
@@ -28,10 +28,12 @@
helpbutton("textformat", get_string("helpformatting"));
print_string("formattexttype");
echo ":&nbsp;";
- if (!$form->format) {
- $form->format = $defaultformat;
+ if (!isset($form->format)) {
+ if (!$form->format) {
+ $form->format = $defaultformat;
+ }
}
- choose_from_menu(format_text_menu(), "format", $format->format, "");
+ choose_from_menu(format_text_menu(), "format", $form->format, "");
echo "</p>";
?>
</td>
@@ -40,7 +42,7 @@
<td colspan=2>
<p align=center>
<?php
- if ($comment->id) {
+ if (isset($comment->id)) {
echo "<input type=\"hidden\" name=cid value=\"$comment->id\">";
}
?>
View
@@ -150,7 +150,7 @@
$newentry->entryid = $entry->id;
$newentry->comment = $form->text;
$newentry->format = $form->format;
- $newentry->timemodified = $comment->timemodified;
+ $newentry->timemodified = time();
if ( $action == "add" ) {
$newentry->userid = $USER->id;
@@ -185,9 +185,13 @@
$defaultformat = FORMAT_MOODLE;
$onsubmit = "";
}
-
- $form->text = $comment->comment;
- $form->format = $comment->format;
+ if (isset($comment) ) {
+ $form->text = $comment->comment;
+ $form->format = $comment->format;
+ } else {
+ $form->text = "";
+ $form->format = $defaultformat;
+ }
include("comment.html");
}
}
@@ -109,6 +109,15 @@ function glossary_upgrade($oldversion) {
execute_sql( "UPDATE `{$CFG->prefix}glossary`" .
" SET displayformat = 5 WHERE displayformat = 1");
}
+ if ( $oldversion < 2003102000 ) {
+ execute_sql( "ALTER TABLE `{$CFG->prefix}glossary`" .
+ " ADD `defaultapproval` TINYINT(2) UNSIGNED NOT NULL default '1' AFTER `usedynalink`");
+
+ execute_sql( "ALTER TABLE `{$CFG->prefix}glossary_entries`" .
+ " ADD `approved` TINYINT(2) UNSIGNED NOT NULL default '1' AFTER `fullmatch`");
+
+ execute_sql(" INSERT INTO {$CFG->prefix}log_display VALUES ('glossary', 'approve entry', 'glossary', 'name') ");
+ }
return true;
}
@@ -22,6 +22,7 @@ CREATE TABLE prefix_glossary (
showall tinyint(2) unsigned NOT NULL default '1',
allowcomments tinyint(2) unsigned NOT NULL default '0',
usedynalink tinyint(2) unsigned NOT NULL default '1',
+ defaultapproval tinyint(2) unsigned NOT NULL default '1',
timecreated int(10) unsigned NOT NULL default '0',
timemodified int(10) unsigned NOT NULL default '0',
PRIMARY KEY (id)
@@ -46,6 +47,7 @@ CREATE TABLE prefix_glossary_entries (
usedynalink tinyint(2) unsigned NOT NULL default '1',
casesensitive tinyint(2) unsigned NOT NULL default '0',
fullmatch tinyint(2) unsigned NOT NULL default '1',
+ approved tinyint(2) unsigned NOT NULL default '1',
PRIMARY KEY (id)
) TYPE=MyISAM COMMENT='all glossary entries';
@@ -98,4 +100,5 @@ INSERT INTO prefix_log_display VALUES ('glossary', 'delete category', 'glossary'
INSERT INTO prefix_log_display VALUES ('glossary', 'add comment', 'glossary', 'name');
INSERT INTO prefix_log_display VALUES ('glossary', 'update comment', 'glossary', 'name');
INSERT INTO prefix_log_display VALUES ('glossary', 'delete comment', 'glossary', 'name');
+INSERT INTO prefix_log_display VALUES ('glossary', 'approve entry', 'glossary', 'name');
@@ -7,6 +7,8 @@
require_variable($mode); // edit or delete
optional_variable($go); // commit the operation?
optional_variable($entry); // entry id
+ optional_variable($tab); // browsing entries by categories?
+ optional_variable($cat); // categoryID
$strglossary = get_string("modulename", "glossary");
$strglossaries = get_string("modulenameplural", "glossary");
@@ -72,8 +74,8 @@
print_simple_box_end();
}
print_footer($course);
- add_to_log($course->id, "glossary", "delete entry", "view.php?id=$cm->id&currentview=$currentview&cat=$cat", $entry);
- redirect("view.php?id=$cm->id&currentview=$currentview&cat=$cat");
+ add_to_log($course->id, "glossary", "delete entry", "view.php?id=$cm->id&tab=$tab&cat=$cat", $entry);
+ redirect("view.php?id=$cm->id&tab=$tab&cat=$cat");
} else { // the operation has not been confirmed yet so ask the user to do so
if ( $mode == "delete") {
print_simple_box_start("center","40%", "#FFBBBB");
@@ -86,7 +88,7 @@
<input type="hidden" name=mode value="delete">
<input type="hidden" name=go value="1">
<input type="hidden" name=entry value="<?php p($entry) ?>">
- <input type="hidden" name=currentview value=<?php p($currentview) ?>>
+ <input type="hidden" name=tab value=<?php p($tab) ?>>
<input type="hidden" name=cat=<?php p($cat) ?>>
<input type="submit" value=" <?php print_string("yes")?> ">
@@ -20,7 +20,7 @@ function glossary_dynamic_link($courseid, $text) {
}
$glossaries=substr($glossaries,0,-1);
- $entries = get_records_select("glossary_entries", "glossaryid IN ($glossaries) AND usedynalink = 1","glossaryid","id,glossaryid,concept,casesensitive,$GLOSSARY_CONCEPT_IS_ENTRY category,fullmatch");
+ $entries = get_records_select("glossary_entries", "glossaryid IN ($glossaries) AND usedynalink = 1 and approved != 0","glossaryid","id,glossaryid,concept,casesensitive,$GLOSSARY_CONCEPT_IS_ENTRY category,fullmatch");
$categories = get_records_select("glossary_categories", "glossaryid IN ($glossaries)", "glossaryid,id","id,glossaryid,name concept, 1 casesensitive,$GLOSSARY_CONCEPT_IS_CATEGORY category, 1 fullmatch");
if ( $entries and $categories ) {
$concepts = array_merge($entries, $categories);
View
@@ -4,44 +4,49 @@
<tr valign=top>
<td align=right><p><b><?php echo get_string("concept","glossary") ?>:</b></p></td>
<td>
- <INPUT type="text" name="concept" size=30 value="<?php p($form->concept) ?>">
+ <INPUT type="text" name="concept" size=30 value="<?php p($newentry->concept) ?>">
</td>
</tr>
<tr valign=top>
<td align=right><p><b><?php echo get_string("categories","glossary") ?>:</b></p></td>
<td>
- <?php
- $categories = get_records("glossary_categories","glossaryid",$glossary->id);
- echo "<select size=\"6\" name=\"categories[]\" multiple=\"yes\">";
- echo "<option value=\"0\">" . get_string("notcategorised","glossary") . "</optioon>";
+ <?php
+ $categories = get_records("glossary_categories","glossaryid",$glossary->id);
+ echo "<select size=\"6\" name=\"categories[]\" multiple=\"yes\">";
+ echo "<option value=\"0\">" . get_string("notcategorised","glossary") . "</optioon>";
- if ( $categories ) {
+ if ( $categories ) {
foreach ( $categories as $category ) {
- echo " <option ";
-
- if ( record_exists("glossary_entries_categories","entryid",$entry->id,"categoryid",$category->id) ) {
- echo "selected " ;
- }
- echo "value=\"$category->id\">$category->name</option>\n";
+ echo " <option ";
+ if (isset($newentry->id)) {
+ if ( record_exists("glossary_entries_categories","entryid",$newentry->id,"categoryid",$category->id) ) {
+ echo "selected " ;
+ }
+ }
+ echo "value=\"$category->id\">$category->name</option>\n";
}
- }
- ?>
- </select>
+ }
+ ?>
+ </select>
</td>
</tr>
<tr valign=top>
<td align=right><p><b><?php echo get_string("entryusedynalink","glossary") ?>:</b></p></td>
<td>
<select size="1" name="usedynalink">
<option value="1" <?php
- if ( $form->usedynalink ) {
- echo "selected";
+ if ( isset($newentry->usedynalink) ) {
+ if ($newentry->usedynalink) {
+ echo "selected";
+ }
}
?>
><?php echo get_string("yes") ?></option>
<option value="0" <?php
- if ( !$form->usedynalink ) {
- echo "selected";
+ if ( isset($newentry->usedynalink) ) {
+ if (!$newentry->usedynalink) {
+ echo "selected";
+ }
}
?>><?php echo get_string("no") ?>
</option>
@@ -53,14 +58,18 @@
<td>
<select size="1" name="casesensitive">
<option value="1" <?php
- if ( $form->casesensitive ) {
- echo "selected";
+ if ( isset($newentry->casesensitive) ) {
+ if ( $newentry->casesensitive ) {
+ echo "selected";
+ }
}
?>
><?php echo get_string("yes") ?></option>
<option value="0" <?php
- if ( !$form->casesensitive ) {
- echo "selected";
+ if ( isset($newentry->casesensitive) ) {
+ if ( !$newentry->casesensitive ) {
+ echo "selected";
+ }
}
?>><?php echo get_string("no") ?>
</option>
@@ -72,14 +81,18 @@
<td>
<select size="1" name="fullmatch">
<option value="1" <?php
- if ( $form->fullmatch ) {
- echo "selected";
+ if ( isset($newentry->fullmatch) ) {
+ if ( $newentry->fullmatch ) {
+ echo "selected";
+ }
}
?>
><?php echo get_string("yes") ?></option>
<option value="0" <?php
- if ( !$form->fullmatch ) {
- echo "selected";
+ if ( isset($newentry->fullmatch) ) {
+ if ( !$newentry->fullmatch ) {
+ echo "selected";
+ }
}
?>><?php echo get_string("no") ?>
</option>
@@ -103,16 +116,16 @@
</td>
<td>
<?php
- print_textarea($usehtmleditor, 20, 60, 680, 400, "text", $entry->text);
+ print_textarea($usehtmleditor, 20, 60, 680, 400, "text", $newentry->definition);
echo "<p align=right>";
helpbutton("textformat", get_string("helpformatting"));
print_string("formattexttype");
echo ":&nbsp;";
- if (!$form->format) {
- $form->format = $defaultformat;
+ if (!isset($newentry->format)) {
+ $newentry->format = $defaultformat;
}
- choose_from_menu(format_text_menu(), "format", $entry->format, "");
+ choose_from_menu(format_text_menu(), "format", $newentry->format, "");
echo "</p>";
?>
</td>
@@ -131,13 +144,14 @@
<tr>
<td colspan=2>
<p align=center>
- <?php if ($entry->id) {
- echo "<input type=\"hidden\" name=entry value=\"$entry->id\">";
+ <?php if (isset($newentry->id)) {
+ echo "<input type=\"hidden\" name=e value=\"$newentry->id\">";
}
?>
<input type="hidden" name=id value="<?=$cm->id ?>">
- <input type="hidden" name=currentview value="<?=$currentview ?>">
+ <input type="hidden" name=tab value="<?=$tab ?>">
<input type="hidden" name=cat value="<?=$cat ?>">
+ <input type="hidden" name=confirm value="1">
<input type="submit" value="<?php print_string("savechanges") ?>">
<input type="reset" value="<?php print_string("revert") ?>">
Oops, something went wrong.

0 comments on commit c76e673

Please sign in to comment.