<?PHP  // $Id: mod.html,v 1.29.2.1 2004/08/24 20:35:43 stronk7 Exp $

include_once($CFG->dirroot.'/mod/glossary/lib.php');

if (!isset($form->studentcanpost)) {
    $form->studentcanpost = $CFG->glossary_studentspost;
}
if (!isset($form->allowduplicatedentries)) {
    $form->allowduplicatedentries = $CFG->glossary_dupentries;
}
if (!isset($form->allowcomments)) {
    $form->allowcomments = $CFG->glossary_allowcomments;
}
if (!isset($form->usedynalink)) {
    $form->usedynalink = $CFG->glossary_linkbydefault;
}
if (!isset($form->defaultapproval)) {
    $form->defaultapproval = $CFG->glossary_defaultapproval;
}
if (!isset($form->entbypage)) {
    $form->entbypage = $CFG->glossary_entbypage;
}
if (!isset($form->mainglossary)) {
    $form->mainglossary = 0;
}
if (!isset($form->displayformat)) {
    $form->displayformat = 'dictionary';
}
if ( !isset($form->globalglossary) ) {
    $form->globalglossary = 0;
}
if (!isset($form->intro)) {
    $form->intro = "";
}
if (!isset($form->name)) {
    $form->name = "";
}
if (!isset($form->showall)) {
    $form->showall = 1;
}
if (!isset($form->showalphabet)) {
    $form->showalphabet = 1;
}
if (!isset($form->showspecial)) {
    $form->showspecial = 1;
}
if (!isset($form->editalways)) {
    $form->editalways = 0;
}
if (!isset($form->rsstype)) {
    $form->rsstype = 0;
}
if (!isset($form->rssarticles)) {
    $form->rssarticles = 0;
}
if (!isset($form->assessed)) {
    $form->assessed = 0;
}
if (!isset($form->scale)) {
    $form->scale = 0;
}
if (!isset($form->assesstimestart)) {
    $form->assesstimestart = 0;
}
if (!isset($form->assesstimefinish)) {
    $form->assesstimefinish = 0;
}
?>
<FORM name="form" method="post" action="<?php p($ME) ?>">
<CENTER>
<TABLE cellpadding=5>
<TR valign=top>
    <TD align=right><P><B><?php print_string("name") ?>:</B></P></TD>
    <TD>
        <INPUT type="text" name="name" size=30 value="<?php p($form->name) ?>">
    </TD>
</TR>
<tr valign=top>
    <td align=right><p><b><?php print_string("description") ?>:</b></p>
     <font size="1">
     <?php
        helpbutton("description", get_string("description"), "glossary", true, true);
        echo "<br />";
        helpbutton("writing", get_string("helpwriting"), "moodle", true, true);
        echo "<br />";
        helpbutton("text", get_string("helptext"), "moodle", true, true);
     ?>
     <br />
     </font>
    </td>
    <td>
        <?php print_textarea($usehtmleditor, 20, 50, 680, 400, "intro", $form->intro); ?>
    </td>
</tr>
<TR valign=top>
    <TD align=right><P><B><?php echo get_string("entbypage", "glossary") ?>:</B></P></TD>
    <TD>
		<input name=entbypage type=text size=2 value="<?php p($form->entbypage) ?>"> <?php helpbutton("entbypage", get_string("entbypage", "glossary"), "glossary") ?>
    </TD>
</TR>

<!-- More rows go in here... -->
<?php
if (isadmin() ) {
?>
<TR valign=top>
    <TD align=right><P><B><?php echo get_string("isglobal", "glossary") ?>:</B></P></TD>
    <TD>
<?php
    $selected = "";
    if ( isset($form->globalglossary) ) {
        if ($form->globalglossary) {
            $selected = "checked";
        }
    }
?> 
  <input type="checkbox" name="globalglossary" value=1 <?PHP p($selected)?>> <?php helpbutton("globalglossary", get_string("globalglossary", "glossary"), "glossary") ?>
    </TD>
</TR>
<?php
} else {
   echo '<INPUT type="hidden" name=globalglossary value="' . $form->globalglossary . '">';
}
?>
<?php
$mainglossary = get_record("glossary","mainglossary",1,"course",$form->course);
if (!$mainglossary or $mainglossary->id == $form->instance ) {
?>
<TR valign=top>
    <TD align=right><P><B><?php echo get_string("glossarytype", "glossary") ?>:</B></P></TD>
    <TD>
  <select size="1" name="mainglossary">
  <option value="1" <?php
   if ( $form->mainglossary ) {
      echo "selected";
   }
?>>
<?php echo get_string("mainglossary", "glossary") ?></option>
  <option value="0" <?php
   if ( !$form->mainglossary ) {
      echo "selected";
   }
   ?>><?php echo get_string("secondaryglossary", "glossary") ?>
  </option>
  </select> <?php helpbutton("mainglossary", get_string("mainglossary", "glossary"), "glossary") ?>
    </TD>
</TR>
<?php
} else {
	echo "<INPUT type=\"hidden\" name=mainglossary value=\"0\">";
}
?>
<TR valign=top>
    <TD align=right><P><B><?php p(get_string("studentcanpost", "glossary")) ?>:</B><br>
    <font size=1><?php p(get_string("warningstudentcapost","glossary")) ?></font></P></TD>
    <TD>
  <select size="1" name="studentcanpost">
  <option value="1" <?php
   if ( $form->studentcanpost ) {
      echo "selected";
   }
   ?>><?php echo get_string("yes") ?></option>
  <option value="0" <?php
   if ( !$form->studentcanpost ) {
      echo "selected";
   }
   ?>><?php echo get_string("no") ?>
  </option>
  </select> <?php helpbutton("studentcanpost", get_string("studentcanpost", "glossary"), "glossary") ?>
    </TD>
</TR>
<TR valign=top>
    <TD align=right><P><B><?php echo get_string("allowduplicatedentries", "glossary") ?>:</B></P></TD>
    <TD>
  <select size="1" name="allowduplicatedentries">
  <option value="1" <?php
   if ( $form->allowduplicatedentries ) {
      echo "selected";
   }
   ?> 
   ><?php echo get_string("yes") ?></option>
  <option value="0" <?php
   if ( !$form->allowduplicatedentries ) {
      echo "selected";
   }
   ?>><?php echo get_string("no") ?>
  </option>
  </select> <?php helpbutton("allowduplicatedentries", get_string("allowduplicatedentries", "glossary"), "glossary") ?>
    </TD>
</TR>
<TR valign=top>
    <TD align=right><P><B><?php echo get_string("allowcomments", "glossary") ?>:</B></P></TD>
    <TD>
  <select size="1" name="allowcomments">
  <option value="1" <?php
   if ( $form->allowcomments ) {
      echo "selected";
   }
   ?> 
   ><?php echo get_string("yes") ?></option>
  <option value="0" <?php
   if ( !$form->allowcomments ) {
      echo "selected";
   }
   ?>><?php echo get_string("no") ?>
  </option>
  </select> <?php helpbutton("allowcomments", get_string("allowcomments", "glossary"), "glossary") ?>
    </TD>
</TR>
<TR valign=top>
    <TD align=right><P><B><?php echo get_string("usedynalink", "glossary") ?>:</B></P></TD>
    <TD>
  <select size="1" name="usedynalink">
  <option value="1" <?php
   if ( $form->usedynalink ) {
      echo "selected";
   }
   ?> 
   ><?php echo get_string("yes") ?></option>
  <option value="0" <?php
   if ( !$form->usedynalink ) {
      echo "selected";
   }
   ?>><?php echo get_string("no") ?>
  </option>
  </select> <?php helpbutton("usedynalink", get_string("usedynalink", "glossary"), "glossary") ?>
    </TD>
</TR>
<TR valign=top>
    <TD align=right><P><B><?php echo get_string("defaultapproval", "glossary") ?>:</B></P></TD>
    <TD>
  <select size="1" name="defaultapproval">
  <option value="1" <?php
   if ( $form->defaultapproval ) {
      echo "selected";
   }
   ?> 
   ><?php echo get_string("yes") ?></option>
  <option value="0" <?php
   if ( !$form->defaultapproval ) {
      echo "selected";
   }
   ?>><?php echo get_string("no") ?>
  </option>
  </select> <?php helpbutton("defaultapproval", get_string("defaultapproval", "glossary"), "glossary") ?>
    </TD>
</TR>
<TR valign=top>
<td colspan=2><hr>
</tr>
</tr>
<TR valign=top>
    <TD align=right><P><B><?php echo get_string("displayformat", "glossary") ?>:</B></P></TD>
    <TD>
    <?php
        //get and update available formats
        $recformats = glossary_get_available_formats();
        //reload current format, because of it has changed (deleted format)
        if (isset($form->id)) {
            if ($currentglossary = get_record("glossary",'id',$form->id)) {
                $form->displayformat = $currentglossary->displayformat;
            }
        }
    
        $formats = array(); 
        
        //Take names
        foreach ($recformats as $format) {
           $formats[$format->name] = get_string("displayformat$format->name", "glossary");
        }       
        //Sort it
        asort($formats);
        
        choose_from_menu($formats,'displayformat',$form->displayformat,'');
    ?>
    <?php helpbutton("displayformat", get_string("displayformat", "glossary"), "glossary") ?>
    </TD>
</TR>
<TR valign=top>
    <TD align=right><P><B><?php echo get_string("showspecial", "glossary") ?>:</B></P></TD>
    <TD>
  <select size="1" name="showspecial">
  <option value="1" <?php
   if ( $form->showspecial ) {
      echo "selected";
   }
   ?> 
   ><?php echo get_string("yes") ?></option>
  <option value="0" <?php
   if ( !$form->showspecial ) {
      echo "selected";
   }
   ?>><?php echo get_string("no") ?>
  </option>
  </select> <?php helpbutton("shows", get_string("showspecial", "glossary"), "glossary") ?>
    </TD>
</TR>
<TR valign=top>
    <TD align=right><P><B><?php echo get_string("showalphabet", "glossary") ?>:</B></P></TD>
    <TD>
  <select size="1" name="showalphabet">
  <option value="1" <?php
   if ( $form->showalphabet ) {
      echo "selected";
   }
   ?> 
   ><?php echo get_string("yes") ?></option>
  <option value="0" <?php
   if ( !$form->showalphabet ) {
      echo "selected";
   }
   ?>><?php echo get_string("no") ?>
  </option>
  </select> <?php helpbutton("shows", get_string("showalphabet", "glossary"), "glossary") ?>
    </TD>
</TR>
<TR valign=top>
    <TD align=right><P><B><?php echo get_string("showall", "glossary") ?>:</B></P></TD>
    <TD>
  <select size="1" name="showall">
  <option value="1" <?php
   if ( $form->showall ) {
      echo "selected";
   }
   ?> 
   ><?php echo get_string("yes") ?></option>
  <option value="0" <?php
   if ( !$form->showall ) {
      echo "selected";
   }
   ?>><?php echo get_string("no") ?>
  </option>
  </select> <?php helpbutton("shows", get_string("showall", "glossary"), "glossary") ?>
    </TD>
</TR>
<TR valign=top>
    <TD align=right><P><B><?php echo get_string("editalways", "glossary") ?>:</B></P></TD>
    <TD>
  <select size="1" name="editalways">
  <option value="1" <?php
   if ( $form->editalways ) {
      echo "selected";
   }
   ?>
   ><?php echo get_string("yes") ?></option>
  <option value="0" <?php
   if ( !$form->editalways ) {
      echo "selected";
   }
   ?>><?php echo get_string("no") ?>
  </option>
  </select> <?php helpbutton("editalways", get_string("editalways", "glossary"), "glossary") ?>
    </TD>
</TR>
<?php
    //Only show rss parameters if rss is activated at site and glossary levels
    if (isset($CFG->enablerssfeeds) && isset($CFG->glossary_enablerssfeeds) &&
        $CFG->enablerssfeeds && $CFG->glossary_enablerssfeeds) {
        echo "<tr valign=top>";
        echo "<td align=right><p><b>".get_string("rsstype").":</b></p></td>";
        echo "<td>";
        unset($choices);
        $choices[0] = get_string("none");
        $choices[1] = get_string("withauthor", "glossary");
        $choices[2] = get_string("withoutauthor", "glossary");
        choose_from_menu ($choices, "rsstype", $form->rsstype, "");
        helpbutton("rsstype", get_string("rsstype"), "glossary");
        echo "</td>";
        echo "</tr>";

        echo "<tr valign=top>";
        echo "<td align=right><p><b>".get_string("rssarticles").":</b></p></td>";
        echo "<td>";
        unset($choices);
        $choices[0] = "0";
        $choices[1] = "1";
        $choices[2] = "2";
        $choices[3] = "3";
        $choices[4] = "4";
        $choices[5] = "5";
        $choices[10] = "10";
        $choices[15] = "15";
        $choices[20] = "20";
        $choices[25] = "25";
        $choices[30] = "30";
        $choices[40] = "40";
        $choices[50] = "50";
        choose_from_menu ($choices, "rssarticles", $form->rssarticles, "");
        helpbutton("rssarticles", get_string("rssarticles"), "glossary");
        echo "</td>";
        echo "</tr>";
    }
?>
<tr>
    <td align=right valign=top><p><b><?php print_string("allowratings", "glossary") ?>:</b></p></td>
    <td>
        <?php 
            echo "<script>";
            echo "  var subitemstime = ['startday','startmonth','startyear','starthour', 'startminute',".
                                   "'finishday','finishmonth','finishyear','finishhour','finishminute'];";
            echo "  var subitemsall = ['assessed', 'ratingtime', 'scale', 'startday','startmonth','startyear','starthour', 'startminute',".
                                   "'finishday','finishmonth','finishyear','finishhour','finishminute'];";
            echo "</script>";

            echo "<input name=\"userating\" type=checkbox value=1 ";
            echo " onclick=\"return lockoptions('form','userating', subitemsall)\" ";
            if ($form->assessed) {
                echo " checked ";
            }
            echo ">";
            echo get_string("ratingsuse", "glossary").":";
            echo "<br />";

            // The odd order below was to maintain backward compatibility
            unset($options);
            $options[2] = get_string("ratingonlyteachers", "glossary", moodle_strtolower($course->teachers));
            $options[1] = get_string("ratingeveryone", "glossary");
            echo get_string("users").":";
            choose_from_menu($options, "assessed", $form->assessed, "");
            echo "<br />";

            echo get_string("grade").":";
            print_grade_menu($course->id, "scale", $form->scale, false);
            echo "<br />";

            echo "<input name=\"ratingtime\" type=checkbox value=1 ";
            echo " onclick=\"return lockoptions('form','ratingtime', subitemstime)\" ";
            if ($form->assesstimestart and $form->assesstimefinish and $form->assessed) {
                $form->ratingtime = 1;
                echo " checked ";
            }
            echo ">";

            print_string("ratingtime", "glossary");
            echo "<table align=left><tr><td align=right nowrap>";
            echo get_string("from").":";
            print_date_selector("startday", "startmonth", "startyear", $form->assesstimestart);
            print_time_selector("starthour", "startminute", $form->assesstimestart);
            echo "<br />";
            echo get_string("to").":";
            print_date_selector("finishday", "finishmonth", "finishyear", $form->assesstimefinish);
            print_time_selector("finishhour", "finishminute", $form->assesstimefinish);
            echo "<br />";
            echo "</td></tr></table>";
            echo "<input type=\"hidden\" name=\"hratingtime\" value=0>";
            echo "<input type=\"hidden\" name=\"hassessed\" value=0>";
            echo "<input type=\"hidden\" name=\"hscale\" value=0>";
            echo "<input type=\"hidden\" name=\"hstartday\" value=0>";
            echo "<input type=\"hidden\" name=\"hstartmonth\" value=0>";
            echo "<input type=\"hidden\" name=\"hstartyear\" value=0>";
            echo "<input type=\"hidden\" name=\"hstarthour\" value=0>";
            echo "<input type=\"hidden\" name=\"hstartminute\" value=0>";
            echo "<input type=\"hidden\" name=\"hfinishday\" value=0>";
            echo "<input type=\"hidden\" name=\"hfinishmonth\" value=0>";
            echo "<input type=\"hidden\" name=\"hfinishyear\" value=0>";
            echo "<input type=\"hidden\" name=\"hfinishhour\" value=0>";
            echo "<input type=\"hidden\" name=\"hfinishminute\" value=0>";

            echo "<script>";
            echo "lockoptions('form','userating', subitemsall);";
            echo "</script>";

            if (empty($form->ratingtime)) {
                echo "<script>";
                echo "lockoptions('form','ratingtime', subitemstime);";
                echo "</script>";
            }
        ?>
    </td>
</tr>
</TABLE>
<!-- These hidden variables are always the same -->
<INPUT type="hidden" name=course        value="<?php p($form->course) ?>">
<INPUT type="hidden" name=coursemodule  value="<?php p($form->coursemodule) ?>">
<INPUT type="hidden" name=section       value="<?php p($form->section) ?>">
<INPUT type="hidden" name=module        value="<?php p($form->module) ?>">
<INPUT type="hidden" name=modulename    value="<?php p($form->modulename) ?>">
<INPUT type="hidden" name=instance      value="<?php p($form->instance) ?>">
<INPUT type="hidden" name=mode          value="<?php p($form->mode) ?>">
<INPUT type="submit" value="<?php print_string("savechanges") ?>">
</CENTER>
</FORM>
