]> git.mjollnir.org Git - moodle.git/commitdiff
changed method name addDependency to disabledIf and removed data/mod.html
authorjamiesensei <jamiesensei>
Wed, 22 Nov 2006 15:19:20 +0000 (15:19 +0000)
committerjamiesensei <jamiesensei>
Wed, 22 Nov 2006 15:19:20 +0000 (15:19 +0000)
lib/formslib.php
mod/data/mod.html [deleted file]
mod/data/mod_form.php
mod/forum/mod_form.php

index 8a20466b1b484b6a1491b0e6842add08a06419ea..b2173f1303ab7b28fefd886c5add79055fcc160e 100644 (file)
@@ -849,12 +849,13 @@ function validate_' . $this->_attributes['id'] . '(frm) {
      *                            condition
      * @param string $condition the condition to check
      */
-    function addDependency($elementName, $dependentOn, $condition='notchecked'){
+    function disabledIf($elementName, $dependentOn, $condition='notchecked'){
         $dependents=$this->_getElNamesRecursive($elementName);
         foreach ($dependents as $dependent){
-
-            $this->_dependencies[$dependentOn][]=array('dependent'=>$dependent,
-                                'condition'=>$condition);
+            if ($dependent != $dependentOn) {
+                $this->_dependencies[$dependentOn][]=array('dependent'=>$dependent,
+                                    'condition'=>$condition);
+            }
         }
     }
 }
diff --git a/mod/data/mod.html b/mod/data/mod.html
deleted file mode 100644 (file)
index 8f430a2..0000000
+++ /dev/null
@@ -1,304 +0,0 @@
-<?php  // $Id$
-
-    require_once($CFG->dirroot.'/mod/data/lib.php');
-
-    if (!isset($form->name)) {
-        $form->name = '';
-    }
-    if (!isset($form->intro)) {
-        $form->intro = '';
-    }
-    if (!isset($form->keepdays)) {
-        $form->keepdays = 30;
-    }
-    if (!isset($form->studentlogs)) {
-        $form->studentlogs = 0;
-    }
-    if (!isset($form->timeavailablefrom)) {
-        $form->timeavailablefrom = 0;
-    }
-    if (!isset($form->timeavailableto)) {
-        $form->timeavailableto = 0;
-    }
-    if (!isset($form->timeviewfrom)) {
-        $form->timeviewfrom = 0;
-    }
-    if (!isset($form->timeviewto)) {
-        $form->timeviewto = 0;
-    }
-    if (!isset($form->schedule)) {
-        $form->schedule = 0;
-    }
-    if (!isset($form->requiredentries)) {
-        $form->requiredentries = 0;
-    }
-    if (!isset($form->requiredentriestoview)) {
-        $form->requiredentriestoview = 0;
-    }
-    if (!isset($form->maxentries)) {
-        $form->maxentries = 0;
-    }
-    if (!isset($form->rssarticles)) {
-        $form->rssarticles = 0;
-    }
-    if (!isset($form->comments)) {
-        $form->comments = 0;
-    }
-    if (!isset($form->approval)) {
-        $form->approval = 0;
-    }
-    if (!isset($form->scale)) {
-        $form->scale = 0;
-    }
-    if (!isset($form->assessed)) {
-        $form->assessed = 0;
-    }
-?>
-
-<script type="text/javascript" language="javascript">
-    var availablefromitems = ['availablefromday','availablefrommonth','availablefromyear','availablefromhour', 'availablefromminute'];
-    var availabletoitems = ['availabletoday','availabletomonth','availabletoyear','availabletohour', 'availabletominute'];
-    var viewfromitems = ['viewfromday','viewfrommonth','viewfromyear','viewfromhour', 'viewfromminute'];
-    var viewtoitems = ['viewtoday','viewtomonth','viewtoyear','viewtohour', 'viewtominute'];
-</script>
-
-
-
-<form name="form" method="post" action="mod.php">
-<table cellpadding="5">
-<tr valign="top">
-    <td align="right"><?php print_string('name')?>:</b></td>
-    <td>
-        <input type="text" name="name" size="30" value="<?php p($form->name) ?>" alt="<?php print_string('name') ?>" />
-    </td>
-</tr>
-<tr valign="top">
-    <td align="right"><?php print_string('intro', 'data')?>:</b><br /><br />
-     <?php
-        helpbutton('writing', get_string('helpwriting'), 'moodle', true, true);
-        echo '<br />';
-        helpbutton('questions', get_string('helpquestions'), 'moodle', true, true);
-        echo '<br />';
-        emoticonhelpbutton('form', 'intro');
-        echo '<br />';
-      ?>
-    </td>
-    <td>
-        <?php print_textarea($usehtmleditor, 20, 50, 680, 400, 'intro', $form->intro); ?>
-    </td>
-</tr>
-
-<tr valign="top">
-   <td align="right"><b><?php print_string('availablefromdate','data') ?>:</b></td>
-    <td>
-        <input name="availablefromenable" type="checkbox" value="1" alt="<?php print_string('availablefromdate', 'data') ?>" onclick="return lockoptions('form', 'availablefromenable', availablefromitems)" <?php if ($form->timeavailablefrom) echo 'checked="checked"' ?> />
-    <?php
-           print_date_selector("availablefromday", "availablefrommonth", "availablefromyear", $form->timeavailablefrom);
-           echo "&nbsp;-&nbsp;";
-           print_time_selector("availablefromhour", "availablefromminute", $form->timeavailablefrom);
-    ?>
-        <input type="hidden" name="havailablefromday"    value="0" />
-        <input type="hidden" name="havailablefrommonth"  value="0" />
-        <input type="hidden" name="havailablefromyear"   value="0" />
-        <input type="hidden" name="havailablefromhour"   value="0" />
-        <input type="hidden" name="havailablefromminute" value="0" />
-    </td>
-</tr>
-
-
-<tr valign="top">
-   <td align="right"><b><?php print_string('availabletodate','data') ?>:</b></td>
-    <td>
-        <input name="availabletoenable" type="checkbox" value="1" alt="<?php print_string('availabletodate', 'data') ?>" onclick="return lockoptions('form', 'availabletoenable', availabletoitems)" <?php if ($form->timeavailableto) echo 'checked="checked"' ?> />
-    <?php
-           print_date_selector("availabletoday", "availabletomonth", "availabletoyear", $form->timeavailableto);
-           echo "&nbsp;-&nbsp;";
-           print_time_selector("availabletohour", "availabletominute", $form->timeavailableto);
-    ?>
-        <input type="hidden" name="havailabletoday"    value="0" />
-        <input type="hidden" name="havailabletomonth"  value="0" />
-        <input type="hidden" name="havailabletoyear"   value="0" />
-        <input type="hidden" name="havailabletohour"   value="0" />
-        <input type="hidden" name="havailabletominute" value="0" />
-    </td>
-</tr>
-
-<tr valign="top">
-   <td align="right"><b><?php print_string('viewfromdate','data') ?>:</b></td>
-    <td>
-        <input name="viewfromenable" type="checkbox" value="1" alt="<?php print_string('viewfromdate', 'data') ?>" onclick="return lockoptions('form', 'viewfromenable', viewfromitems)" <?php if ($form->timeviewfrom) echo 'checked="checked"' ?> />
-    <?php
-           print_date_selector("viewfromday", "viewfrommonth", "viewfromyear", $form->timeviewfrom);
-           echo "&nbsp;-&nbsp;";
-           print_time_selector("viewfromhour", "viewfromminute", $form->timeviewfrom);
-    ?>
-        <input type="hidden" name="hviewfromday"    value="0" />
-        <input type="hidden" name="hviewfrommonth"  value="0" />
-        <input type="hidden" name="hviewfromyear"   value="0" />
-        <input type="hidden" name="hviewfromhour"   value="0" />
-        <input type="hidden" name="hviewfromminute" value="0" />
-    </td>
-</tr>
-
-
-<tr valign="top">
-   <td align="right"><b><?php print_string('viewtodate','data') ?>:</b></td>
-    <td>
-        <input name="viewtoenable" type="checkbox" value="1" alt="<?php print_string('viewtodate', 'data') ?>" onclick="return lockoptions('form', 'viewtoenable', viewtoitems)" <?php if ($form->timeviewto) echo 'checked="checked"' ?> />
-    <?php
-           print_date_selector("viewtoday", "viewtomonth", "viewtoyear", $form->timeviewto);
-           echo "&nbsp;-&nbsp;";
-           print_time_selector("viewtohour", "viewtominute", $form->timeviewto);
-    ?>
-        <input type="hidden" name="hviewtoday"    value="0" />
-        <input type="hidden" name="hviewtomonth"  value="0" />
-        <input type="hidden" name="hviewtoyear"   value="0" />
-        <input type="hidden" name="hviewtohour"   value="0" />
-        <input type="hidden" name="hviewtominute" value="0" />
-    </td>
-</tr>
-
-
-<tr valign="top">
-    <td align="right"><b><?php print_string('requiredentries', 'data') ?>:</b></td>
-    <td>
-    <?php
-        $countoptions = array();
-        for($count=1;$count<=DATA_MAX_ENTRIES;$count++) $countoptions[$count] = $count;
-        choose_from_menu($countoptions, 'requiredentries', $form->requiredentries, get_string('none'));
-        helpbutton('requiredentries', get_string('requiredentries', 'data'), 'data');
-    ?>
-    </td>
-</tr>
-
-<tr valign="top">
-    <td>&nbsp;</td>
-    <td><b><?php print_string('requiredentriestoview', 'data') ?>: </b>
-        <?php
-            choose_from_menu($countoptions, 'requiredentriestoview', $form->requiredentriestoview, get_string('none'));
-            helpbutton('requiredentriestoview', get_string('requiredentriestoview', 'data'), 'data');
-        ?>
-    </td>
-</tr>
-
-<tr valign="top">
-    <td align="right"><b><?php print_string('maxentries', 'data') ?>:</b></td>
-    <td>
-        <?php
-            choose_from_menu($countoptions, 'maxentries', $form->maxentries, get_string('nomaximum', 'data'));
-            helpbutton('maxentries', get_string('maxentries', 'data'), 'data');
-        ?>
-    </td>
-</tr>
-
-
-<tr valign="top">
-    <td align="right"><b><?php print_string('comments', 'data') ?>:</b></td>
-    <td>
-    <?php
-        $ynoptions = array( 0 => get_string('no'), 1 => get_string('yes'));
-        choose_from_menu($ynoptions, 'comments', $form->comments, '');
-        helpbutton('comments', get_string('allowcomments', 'data'), 'data');
-   ?>
-   </td>
-</tr>
-
-<tr valign="top">
-    <td align="right"><b><?php print_string('requireapproval', 'data') ?>:</b></td>
-    <td>
-    <?php
-        $ynoptions = array( 0 => get_string('no'), 1 => get_string('yes'));
-        choose_from_menu($ynoptions, 'approval', $form->approval, '');
-        helpbutton('requireapproval', get_string('requireapproval', 'data'), 'data');
-   ?>
-   </td>
-</tr>
-
-<?php if (!empty($CFG->data_enablerssfeeds) and !empty($CFG->enablerssfeeds)) { ?>
-<tr valign="top">
-    <td align="right"><b><?php print_string('numberrssarticles', 'data') ?>:</b></td>
-    <td>
-        <?php
-            choose_from_menu($countoptions, 'rssarticles', $form->rssarticles, get_string('none'));
-            echo ' ' . get_string('rsshowmany', 'data');
-        ?>
-    </td>
-</tr>
-<?php } ?>
-
-<tr>
-    <td align="right" valign="top"><b><?php print_string("allowratings", "data") ?>:</b></td>
-    <td>
-        <table cellpadding="1">
-        <tr>
-            <td colspan="2">
-        <?php
-            echo '<script type="text/javascript">';
-            echo "  var subitemsall = ['scale'];";
-            echo '</script>';
-
-            //echo '<input name="ratings" type="checkbox" alt="'.get_string('ratingsuse', 'data').'" value="1" ';
-            echo '<input name="assessed" type="checkbox" alt="'.get_string('ratingsuse', 'data').'" value="1" ';
-            echo " onclick=\"return lockoptions('form', 'assessed', subitemsall)\" ";
-            if ($form->assessed) {
-                echo ' checked="checked" ';
-            }
-            echo ' />';
-            echo '&nbsp;'.get_string('ratingsuse', 'data').':';
-            echo '</td></tr>';
-
-/*
-            echo '<tr><td>';
-            // The odd order below was to maintain backward compatibility
-            unset($options);
-            $options[2] = get_string('ratingonlyteachers', 'data', moodle_strtolower($course->teachers));
-            $options[1] = get_string('ratingeveryone', 'data');
-            echo get_string('users').': ';
-            echo '</td><td>';
-            choose_from_menu($options, 'assessed', $form->assessed, '');
-            echo '</td></tr>';
-*/
-            echo '<tr><td>';
-            echo get_string('grade').': ';
-            echo '</td><td>';
-            print_grade_menu($course->id, 'scale', $form->scale, false);
-            echo '</td></tr>';
-
-            echo '</td></tr></table>';
-
-            echo '<input type="hidden" name="hassessed"     value="0" />';
-            echo '<input type="hidden" name="hscale"        value="0" />';
-
-            echo '<script type="text/javascript">';
-            echo "lockoptions('form','assessed', subitemsall);";
-            echo '</script>';
-
-        ?>
-    </td>
-</tr>
-<?php print_standard_coursemodule_settings($form); ?>
-
-</table>
-<center>
-<input type="hidden" name="course"     value="<?php  p($form->course) ?>" />
-<input type="hidden" name="sesskey"    value="<?php  p($form->sesskey) ?>" />
-<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') ?>" />
-<input type="submit" name="cancel" value="<?php  print_string('cancel') ?>" />
-</center>
-</form>
-
-<script type="text/javascript">
-<?php
-    if (!$form->timeavailablefrom) echo "lockoptions('form','availablefromenable', availablefromitems);";
-    if (!$form->timeavailableto) echo "lockoptions('form','availabletoenable', availabletoitems);";
-    if (!$form->timeviewfrom) echo "lockoptions('form','viewfromenable', viewfromitems);";
-    if (!$form->timeviewto) echo "lockoptions('form','viewtoenable', viewtoitems);";
-?>
-</script>
-
index dff1de8301084c58f8eebcd4c096efab9d2c6dc1..bd38fc278668114c254a7ceb1b9f786085e8e6d0 100644 (file)
@@ -23,25 +23,25 @@ class data_mod_form extends moodleform_mod {
            $availablefromgroup[]=&MoodleQuickForm::createElement('date_selector', 'availablefrom', '');
            $availablefromgroup[]=&MoodleQuickForm::createElement('checkbox', 'availablefromenabled', '', get_string('enable'));
         $mform->addGroup($availablefromgroup, 'availablefromgroup', get_string('availablefromdate', 'data'), '&nbsp;', false);
-        $mform->addDependency('availablefromgroup', 'availablefromenabled');
+        $mform->disabledIf('availablefromgroup', 'availablefromenabled');
 
         $availabletogroup=array();
            $availabletogroup[]=&MoodleQuickForm::createElement('date_selector', 'availableto', '');
            $availabletogroup[]=&MoodleQuickForm::createElement('checkbox', 'availabletoenabled', '', get_string('enable'));
         $mform->addGroup($availabletogroup, 'availabletogroup', get_string('availabletodate', 'data'), '&nbsp;', false);
-        $mform->addDependency('availabletogroup', 'availabletoenabled');
+        $mform->disabledIf('availabletogroup', 'availabletoenabled');
 
         $viewfromgroup=array();
            $viewfromgroup[]=&MoodleQuickForm::createElement('date_selector', 'viewfrom', '');
            $viewfromgroup[]=&MoodleQuickForm::createElement('checkbox', 'viewfromenabled', '', get_string('enable'));
         $mform->addGroup($viewfromgroup, 'viewfromgroup', get_string('viewfromdate', 'data'), '&nbsp;', false);
-        $mform->addDependency('viewfromgroup', 'viewfromenabled');
+        $mform->disabledIf('viewfromgroup', 'viewfromenabled');
 
         $viewtogroup=array();
            $viewtogroup[]=&MoodleQuickForm::createElement('date_selector', 'viewto', '');
            $viewtogroup[]=&MoodleQuickForm::createElement('checkbox', 'viewtoenabled', '', get_string('enable'));
         $mform->addGroup($viewtogroup, 'viewtogroup', get_string('viewtodate', 'data'), '&nbsp;', false);
-        $mform->addDependency('viewtogroup', 'viewtoenabled');
+        $mform->disabledIf('viewtogroup', 'viewtoenabled');
 
 
         $countoptions=  array(0=>get_string('none'))+
@@ -68,7 +68,7 @@ class data_mod_form extends moodleform_mod {
         $mform->addElement('checkbox', 'assessed', get_string("allowratings", "data") , get_string('ratingsuse', 'data'));
 
         $mform->addElement('modgrade', 'scale', get_string('grade'), false);
-        $mform->addDependency('scale', 'assessed');
+        $mform->disabledIf('scale', 'assessed');
 
 
         $this->standard_coursemodule_elements();
index 38de1b4af475f28c3f060061d4540e8a6765ed91..cece4deba587b92905e070aab6635cdf98422e6b 100644 (file)
@@ -79,18 +79,18 @@ class forum_mod_form extends moodleform_mod {
         $mform->addElement('checkbox', 'assessed', get_string('allowratings', 'forum') , get_string('ratingsuse', 'forum'));
 
         $mform->addElement('modgrade', 'scale', get_string('grade'), false);
-        $mform->addDependency('scale', 'assessed');
+        $mform->disabledIf('scale', 'assessed');
 
         $mform->addElement('checkbox', 'ratingtime', get_string('ratingtime', 'forum'));
-        $mform->addDependency('ratingtime', 'assessed');
+        $mform->disabledIf('ratingtime', 'assessed');
 
         $mform->addElement('date_time_selector', 'assesstimestart', get_string('from'));
-        $mform->addDependency('assesstimestart', 'assessed');
-        $mform->addDependency('assesstimestart', 'ratingtime');
+        $mform->disabledIf('assesstimestart', 'assessed');
+        $mform->disabledIf('assesstimestart', 'ratingtime');
 
         $mform->addElement('date_time_selector', 'assesstimefinish', get_string('to'));
-        $mform->addDependency('assesstimefinish', 'assessed');
-        $mform->addDependency('assesstimefinish', 'ratingtime');
+        $mform->disabledIf('assesstimefinish', 'assessed');
+        $mform->disabledIf('assesstimefinish', 'ratingtime');
 
 
 //-------------------------------------------------------------------------------
@@ -112,7 +112,7 @@ class forum_mod_form extends moodleform_mod {
                $mform->setDefault('blockafter', '0');
                $mform->addRule('blockafter', null, 'numeric', null, 'client');
                $mform->setHelpButton('blockafter', array('manageposts', get_string('blockafter', 'forum'),'forum'));
-               $mform->addDependency('blockafter', 'blockperiod', 0);
+               $mform->disabledIf('blockafter', 'blockperiod', 0);
 
 
         $mform->addElement('text', 'warnafter', get_string('warnafter', 'forum'));
@@ -120,7 +120,7 @@ class forum_mod_form extends moodleform_mod {
                $mform->setDefault('warnafter', '0');
                $mform->addRule('warnafter', null, 'numeric', null, 'client');
                $mform->setHelpButton('warnafter', array('manageposts', get_string('warnafter', 'forum'),'forum'));
-               $mform->addDependency('warnafter', 'blockperiod', 0);
+               $mform->disabledIf('warnafter', 'blockperiod', 0);
 
 //-------------------------------------------------------------------------------
                $this->standard_coursemodule_elements();