### Eclipse Workspace Patch 1.0
#P 19stable
Index: mod/data/field/picture/mod.html
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/data/field/picture/mod.html,v
retrieving revision 1.11
diff -u -r1.11 mod.html
--- mod/data/field/picture/mod.html	12 Dec 2006 23:34:56 -0000	1.11
+++ mod/data/field/picture/mod.html	24 Jul 2009 22:35:05 -0000
@@ -13,6 +13,10 @@
         </td>
     </tr>
     <tr>
+        <td class="c0"><label for="required"><?php echo get_string('fieldrequired', 'data'); ?></label></td>
+        <td class="c1"><input type="checkbox" name="required" id="required" <?php if($this->field->required) {echo 'checked="checked"';} ?> value="1" /></td>
+    </tr>
+    <tr>
         <td class="c0"><label for="param1">
             <?php echo get_string('fieldwidthsingleview', 'data');?></label></td>
         <td class="c1">
Index: mod/data/field/multimenu/mod.html
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/data/field/multimenu/mod.html,v
retrieving revision 1.7
diff -u -r1.7 mod.html
--- mod/data/field/multimenu/mod.html	12 Dec 2006 23:34:57 -0000	1.7
+++ mod/data/field/multimenu/mod.html	24 Jul 2009 22:35:05 -0000
@@ -8,6 +8,10 @@
         <td class="c1"><input class="fielddescription" type="text" name="description" id="description" value="<?php p($this->field->description); ?>" /></td>
     </tr>
     <tr>
+        <td class="c0"><label for="required"><?php echo get_string('fieldrequired', 'data'); ?></label></td>
+        <td class="c1"><input type="checkbox" name="required" id="required" <?php if($this->field->required) {echo 'checked="checked"';} ?> value="1" /></td>
+    </tr>
+    <tr>
         <td class="c0" valign="top"><label for="param1"><?php echo get_string('fieldoptions', 'data'); ?></label></td>
         <td class="c1"><textarea style="width:300px; height:150px;" name="param1" id="param1" cols="80" rows="10"><?php if($this->field->param1) {p($this->field->param1);} ?></textarea></td>
     </tr>
Index: mod/data/db/upgrade.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/data/db/upgrade.php,v
retrieving revision 1.8.2.4
diff -u -r1.8.2.4 upgrade.php
--- mod/data/db/upgrade.php	8 Jan 2009 01:01:05 -0000	1.8.2.4
+++ mod/data/db/upgrade.php	24 Jul 2009 22:35:04 -0000
@@ -131,6 +131,19 @@
             }
         }
     }
+    
+    if ($result && $oldversion < 2007101515) {
+    /// Launch add field asearchtemplate again if does not exists yet - reported on several sites
+
+        $table = new XMLDBTable('data_fields');
+        $field = new XMLDBField('required');
+        $field->setAttributes(XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'description');
+
+        if (!field_exists($table, $field)) {
+            $result = $result && add_field($table, $field);
+        }
+    }
+    
 
     return $result;
 }
Index: mod/data/field.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/data/field.php,v
retrieving revision 1.24.4.2
diff -u -r1.24.4.2 field.php
--- mod/data/field.php	22 Apr 2008 07:30:52 -0000	1.24.4.2
+++ mod/data/field.php	24 Jul 2009 22:35:02 -0000
@@ -126,6 +126,7 @@
 
                     $field->field->name = $fieldinput->name;
                     $field->field->description = $fieldinput->description;
+                    $field->field->required = $fieldinput->required;
 
                     for ($i=1; $i<=10; $i++) {
                         if (isset($fieldinput->{'param'.$i})) {
Index: mod/data/lib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/data/lib.php,v
retrieving revision 1.137.2.55
diff -u -r1.137.2.55 lib.php
--- mod/data/lib.php	21 Apr 2009 14:13:15 -0000	1.137.2.55
+++ mod/data/lib.php	24 Jul 2009 22:35:04 -0000
@@ -160,6 +160,9 @@
 
 // Print the relevant form element in the ADD template for this field
     function display_add_field($recordid=0){
+        global $CFG;
+        $required = get_field('data_fields','required', 'id', $this->field->id);
+        $str = '';
         if ($recordid){
             $content = get_field('data_content', 'content', 'fieldid', $this->field->id, 'recordid', $recordid);
         } else {
@@ -170,10 +173,18 @@
         if ($content===false) {
             $content='';
         }
-
-        $str = '<div title="'.s($this->field->description).'">';
+        if ($required) {
+            $str .= '<div class="fitem required"><div class="fitemtitle"><label for="fieldid_'.$this->field->id.'">';
+        }
+        $str .= '<div title="'.s($this->field->description).'">';
+        if ($required) {
+            $str .= '<img class="req" title="Required field" alt="Required field" src="'.$CFG->wwwroot.'/pix/req.gif" /></label></div> ';
+        }
         $str .= '<input style="width:300px;" type="text" name="field_'.$this->field->id.'" id="field_'.$this->field->id.'" value="'.s($content).'" />';
         $str .= '</div>';
+        if ($required) {
+            $str .= '</div>';
+        }
 
         return $str;
     }
Index: mod/data/version.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/data/version.php,v
retrieving revision 1.29.2.8
diff -u -r1.29.2.8 version.php
--- mod/data/version.php	8 Jan 2009 01:01:05 -0000	1.29.2.8
+++ mod/data/version.php	24 Jul 2009 22:35:04 -0000
@@ -5,7 +5,7 @@
 //  This fragment is called by /admin/index.php
 ////////////////////////////////////////////////////////////////////////////////
 
-$module->version  = 2007101514;
+$module->version  = 2007101515;
 $module->requires = 2007101509;  // Requires this Moodle version
 $module->cron     = 60;
 
Index: mod/data/field/menu/mod.html
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/data/field/menu/mod.html,v
retrieving revision 1.8
diff -u -r1.8 mod.html
--- mod/data/field/menu/mod.html	12 Dec 2006 23:34:56 -0000	1.8
+++ mod/data/field/menu/mod.html	24 Jul 2009 22:35:05 -0000
@@ -8,6 +8,10 @@
         <td class="c1"><input class="fielddescription" type="text" name="description" id="description" value="<?php p($this->field->description);?>" /></td>
     </tr>
     <tr>
+        <td class="c0"><label for="required"><?php echo get_string('fieldrequired', 'data'); ?></label></td>
+        <td class="c1"><input type="checkbox" name="required" id="required" <?php if($this->field->required) {echo 'checked="checked"';} ?> value="1" /></td>
+    </tr>
+    <tr>
         <td class="c0" valign="top"><label for="param1"><?php echo get_string('fieldoptions', 'data'); ?></label></td>
         <td class="c1"><textarea style="width:300px; height:150px;" name="param1" id="param1" cols="80" rows="10"><?php if($this->field->param1) {p($this->field->param1);} ?></textarea></td>
     </tr>
Index: mod/data/field/url/mod.html
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/data/field/url/mod.html,v
retrieving revision 1.11
diff -u -r1.11 mod.html
--- mod/data/field/url/mod.html	15 Apr 2007 17:19:35 -0000	1.11
+++ mod/data/field/url/mod.html	24 Jul 2009 22:35:05 -0000
@@ -8,6 +8,10 @@
         <td class="c1"><input class="fielddescription" type="text" name="description" id="description" value="<?php p($this->field->description);?>" /></td>
     </tr>
     <tr>
+        <td class="c0"><label for="required"><?php echo get_string('fieldrequired', 'data'); ?></label></td>
+        <td class="c1"><input type="checkbox" name="required" id="required" <?php if($this->field->required) {echo 'checked="checked"';} ?> value="1" /></td>
+    </tr>
+    <tr>
         <td class="c0"><label for="param2"><?php echo get_string('forcelinkname', 'data'); ?></label></td>
         <td class="c1"><input class="forcelinkname" type="text" name="param2" id="forcelinkname" value="<?php p($this->field->param2);?>" /></td>
     </tr>
Index: mod/data/field/url/field.class.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/data/field/url/field.class.php,v
retrieving revision 1.15.2.1
diff -u -r1.15.2.1 field.class.php
--- mod/data/field/url/field.class.php	30 May 2008 01:34:42 -0000	1.15.2.1
+++ mod/data/field/url/field.class.php	24 Jul 2009 22:35:05 -0000
@@ -31,6 +31,8 @@
 
     function display_add_field($recordid=0) {
         global $CFG;
+        $required = get_field('data_fields','required', 'id', $this->field->id);
+        $str = '';
         $url = '';
         $text = '';
         if ($recordid) {
@@ -40,7 +42,14 @@
             }
         }
         $url = empty($url) ? 'http://' : $url;
-        $str = '<div title="'.s($this->field->description).'">';
+        if ($required) {
+            $str .= '<div class="fitem required"><div class="fitemtitle"><label for="fieldid_'.$this->field->id.'">';
+        }
+        $str .= '<div title="'.s($this->field->description).'">';
+        if ($required) {
+            $str .= '<img class="req" title="Required field" alt="Required field" src="'.$CFG->wwwroot.'/pix/req.gif" /></label></div> ';
+        }
+        
         if (!empty($this->field->param1) and empty($this->field->param2)) {
             $str .= '<table><tr><td align="right">';
             $str .= get_string('url','data').':</td><td><input type="text" name="field_'.$this->field->id.'_0" id="field_'.$this->field->id.'_0" value="'.$url.'" size="60" /></td></tr>';
@@ -51,6 +60,9 @@
             $str .= '<input type="text" name="field_'.$this->field->id.'_0" id="field_'.$this->field->id.'_0" value="'.s($url).'" size="60" />';
         }
         $str .= '</div>';
+        if ($required) {
+            $str .= '</div>';
+        }
         return $str;
     }
 
Index: mod/data/field/file/mod.html
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/data/field/file/mod.html,v
retrieving revision 1.8
diff -u -r1.8 mod.html
--- mod/data/field/file/mod.html	12 Dec 2006 23:34:56 -0000	1.8
+++ mod/data/field/file/mod.html	24 Jul 2009 22:35:05 -0000
@@ -8,6 +8,10 @@
         <td class="c1"><input class="fielddescription" type="text" name="description" id="description" value="<?php p($this->field->description);?>" /></td>
     </tr>
     <tr>
+        <td class="c0"><label for="required"><?php echo get_string('fieldrequired', 'data'); ?></label></td>
+        <td class="c1"><input type="checkbox" name="required" id="required" <?php if($this->field->required) {echo 'checked="checked"';} ?> value="1" /></td>
+    </tr>
+    <tr>
         <td class="c0"><label for="param3">
             <?php echo get_string('maxsize', 'data'); ?></label></td>
         <td class="c1">
Index: mod/data/field/textarea/mod.html
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/data/field/textarea/mod.html,v
retrieving revision 1.13
diff -u -r1.13 mod.html
--- mod/data/field/textarea/mod.html	16 Jul 2007 14:50:25 -0000	1.13
+++ mod/data/field/textarea/mod.html	24 Jul 2009 22:35:05 -0000
@@ -11,6 +11,10 @@
         </td>
     </tr>
     <tr>
+        <td class="c0"><label for="required"><?php echo get_string('fieldrequired', 'data'); ?></label></td>
+        <td class="c1"><input type="checkbox" name="required" id="required" <?php if($this->field->required) {echo 'checked="checked"';} ?> value="1" /></td>
+    </tr>
+    <tr>
         <td class="c0"><label for="param2">
             <?php echo get_string('fieldwidth', 'data'); ?></label></td>
         <td class="c1">
Index: mod/data/field/date/mod.html
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/data/field/date/mod.html,v
retrieving revision 1.2
diff -u -r1.2 mod.html
--- mod/data/field/date/mod.html	12 Dec 2006 23:34:57 -0000	1.2
+++ mod/data/field/date/mod.html	24 Jul 2009 22:35:04 -0000
@@ -7,4 +7,8 @@
         <td class="c0"><label for="description"><?php echo get_string('fielddescription', 'data'); ?></label></td>
         <td class="c1"><input class="fielddescription" type="text" name="description" id="description" value="<?php p($this->field->description);?>" /></td>
     </tr>
+    <tr>
+        <td class="c0"><label for="required"><?php echo get_string('fieldrequired', 'data'); ?></label></td>
+        <td class="c1"><input type="checkbox" name="required" id="required" <?php if($this->field->required) {echo 'checked="checked"';} ?> value="1" /></td>
+    </tr>
 </table>
Index: mod/data/field/checkbox/mod.html
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/data/field/checkbox/mod.html,v
retrieving revision 1.7
diff -u -r1.7 mod.html
--- mod/data/field/checkbox/mod.html	12 Dec 2006 23:34:56 -0000	1.7
+++ mod/data/field/checkbox/mod.html	24 Jul 2009 22:35:04 -0000
@@ -8,6 +8,10 @@
         <td class="c1"><input class="fielddescription" type="text" name="description" id="description" value="<?php p($this->field->description); ?>" /></td>
     </tr>
     <tr>
+        <td class="c0"><label for="required"><?php echo get_string('fieldrequired', 'data'); ?></label></td>
+        <td class="c1"><input type="checkbox" name="required" id="required" <?php if($this->field->required) {echo 'checked="checked"';} ?> value="1" /></td>
+    </tr>
+    <tr>
         <td class="c0" valign="top"><label for="param1"><?php echo get_string('fieldoptions', 'data'); ?></label></td>
         <td class="c1"><textarea style="width:300px; height:150px;" name="param1" id="param1" cols="80" rows="10"><?php if($this->field->param1) {p($this->field->param1);} ?></textarea></td>
     </tr>
Index: mod/data/field/latlong/mod.html
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/data/field/latlong/mod.html,v
retrieving revision 1.4
diff -u -r1.4 mod.html
--- mod/data/field/latlong/mod.html	12 Dec 2006 23:34:56 -0000	1.4
+++ mod/data/field/latlong/mod.html	24 Jul 2009 22:35:05 -0000
@@ -8,6 +8,10 @@
         <td class="c1"><input class="fielddescription" type="text" name="description" id="description" value="<?php p ($this->field->description);?>" /></td>
     </tr>
     <tr>
+        <td class="c0"><label for="required"><?php echo get_string('fieldrequired', 'data'); ?></label></td>
+        <td class="c1"><input type="checkbox" name="required" id="required" <?php if($this->field->required) {echo 'checked="checked"';} ?> value="1" /></td>
+    </tr>
+    <tr>
         <td class="c0"><label for="param1"><?php echo get_string('latlonglinkservicesdisplayed', 'data'); ?></label></td>
         <td class="c1">
           <select class="linkservicesdisplayed" name="param1[]" id="param1" multiple="multiple" size="<?php p(sizeof($this->linkoutservices)); ?>">
Index: mod/data/field/radiobutton/mod.html
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/data/field/radiobutton/mod.html,v
retrieving revision 1.8
diff -u -r1.8 mod.html
--- mod/data/field/radiobutton/mod.html	12 Dec 2006 23:34:56 -0000	1.8
+++ mod/data/field/radiobutton/mod.html	24 Jul 2009 22:35:05 -0000
@@ -8,6 +8,10 @@
         <td class="c1"><input class="fielddescription" type="text" name="description" id="description" value="<?php p($this->field->description); ?>" /></td>
     </tr>
     <tr>
+        <td class="c0"><label for="required"><?php echo get_string('fieldrequired', 'data'); ?></label></td>
+        <td class="c1"><input type="checkbox" name="required" id="required" <?php if($this->field->required) {echo 'checked="checked"';} ?> value="1" /></td>
+    </tr>
+    <tr>
         <td class="c0" valign="top"><label for="param1"><?php echo get_string('fieldoptions', 'data'); ?></label></td>
         <td class="c1"><textarea style="width:300px; height:150px;" name="param1" id="param1" cols="80" rows="10"><?php if($this->field->param1) {p($this->field->param1);} ?></textarea></td>
     </tr>
Index: mod/data/field/text/mod.html
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/data/field/text/mod.html,v
retrieving revision 1.10
diff -u -r1.10 mod.html
--- mod/data/field/text/mod.html	12 Dec 2006 23:34:56 -0000	1.10
+++ mod/data/field/text/mod.html	24 Jul 2009 22:35:05 -0000
@@ -8,6 +8,10 @@
         <td class="c1"><input class="fielddescription" type="text" name="description" id="description" value="<?php p($this->field->description); ?>" /></td>
     </tr>
     <tr>
+        <td class="c0"><label for="required"><?php echo get_string('fieldrequired', 'data'); ?></label></td>
+        <td class="c1"><input type="checkbox" name="required" id="required" <?php if($this->field->required) {echo 'checked="checked"';} ?> value="1" /></td>
+    </tr>
+    <tr>
         <td class="c0"><label for="param1"><?php echo get_string('fieldallowautolink', 'data'); ?></label></td>
         <td class="c1"><input type="checkbox" name="param1" id="param1" <?php if($this->field->param1) {echo 'checked="checked"';} ?> value="1" /></td>
     </tr>
Index: mod/data/field/number/mod.html
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/data/field/number/mod.html,v
retrieving revision 1.2
diff -u -r1.2 mod.html
--- mod/data/field/number/mod.html	12 Dec 2006 23:34:57 -0000	1.2
+++ mod/data/field/number/mod.html	24 Jul 2009 22:35:05 -0000
@@ -7,4 +7,8 @@
         <td class="c0"><label for="description"><?php echo get_string('fielddescription', 'data'); ?></label></td>
         <td class="c1"><input class="fielddescription" type="text" name="description" id="description" value="<?php p($this->field->description);?>" /></td>
     </tr>
+    <tr>
+        <td class="c0"><label for="required"><?php echo get_string('fieldrequired', 'data'); ?></label></td>
+        <td class="c1"><input type="checkbox" name="required" id="required" <?php if($this->field->required) {echo 'checked="checked"';} ?> value="1" /></td>
+    </tr>
 </table>
