]> git.mjollnir.org Git - moodle.git/commitdiff
changes to how we generate the id attribute of forms and the naming convention of...
authorjamiesensei <jamiesensei>
Thu, 28 Dec 2006 09:32:45 +0000 (09:32 +0000)
committerjamiesensei <jamiesensei>
Thu, 28 Dec 2006 09:32:45 +0000 (09:32 +0000)
migrate blog edit to formslib

29 files changed:
blog/edit.html [deleted file]
blog/edit.php
blog/edit_form.php [new file with mode: 0644]
course/modedit.php
enrol/authorize/enrol_form.php
lang/en_utf8/blog.php
lang/en_utf8/moodle.php
lib/formslib.php
lib/javascript-static.js
login/change_password_form.php
login/forgot_password_form.php
mod/assignment/type/online/assignment.class.php
mod/assignment/type/upload/assignment.class.php
mod/chat/mod_form.php
mod/choice/mod_form.php
mod/data/comment_form.php
mod/data/mod_form.php
mod/exercise/mod_form.php
mod/forum/mod_form.php
mod/forum/post_form.php
mod/glossary/comment_form.php
mod/glossary/edit_form.php
mod/glossary/mod_form.php
mod/journal/mod_form.php
mod/label/mod_form.php
mod/lesson/mod_form.php
mod/quiz/lib.php
mod/quiz/mod_form.php
mod/survey/details.php

diff --git a/blog/edit.html b/blog/edit.html
deleted file mode 100755 (executable)
index a91e26a..0000000
+++ /dev/null
@@ -1,194 +0,0 @@
-<?php //$Id$
-
-    // find all the tags this post uses
-    $usedtags = array();
-    if (!empty($post->id)) {
-        if ($tagsused = get_records('blog_tag_instance', 'entryid', $post->id)) {
-            foreach ($tagsused as $usedtag) {
-                $usedtags[] = $usedtag -> tagid;
-            }
-        }
-    }
-
-    if ($usehtmleditor) {
-        // clean and convert to html before editting
-        $options = new object();
-        $options->smiley = false;
-        $options->filter = false;
-        $options->nocache = true;
-        $post->summary = format_text($post->summary, $post->format, $options);
-    }
-?>
-
-<form name="entry" method="post" action="edit.php" enctype="multipart/form-data">
-
-<table border="0" cellpadding="5">
-<tr valign="top">
-    <td align="right">&nbsp;
-    </td>
-    <td colspan="2"><strong><?php echo $strformheading; ?></strong>
-    </td>
-</tr>
-<tr valign="top">
-    <td align="right"><strong><?php print_string('entrytitle', 'blog'); ?>:</strong></td>
-    <td colspan="2">
-        <input type="text" name="subject" size="60" value="<?php p($post->subject) ?>" />
-        <?php  if (isset($errors["subject"])) formerr($errors["subject"]); ?>
-    </td>
-</tr>
-<tr valign="top">
-    <td align="right"><strong>
-    <?php
-            print_string('entrybody', 'blog');
-    ?>:
-    </strong><br /><br />
-    <small><small>
-    <?php
-        helpbutton('writing', get_string('helpwriting'), 'moodle', true, true);
-        echo '<br />';
-        if ($usehtmleditor) {
-           helpbutton('richtext', get_string('helprichtext'), 'moodle', true, true);
-        } else {
-           emoticonhelpbutton('entry', 'body');
-        }
-    ?>
-    </small></small>
-    </td>
-    <td align="left" colspan="2">
-    <?php print_textarea($usehtmleditor, 25, 62, 500, 600, 'summary', $post->summary); ?>
-    </td>
-</tr>
-<tr valign="top">
-    <td align="right"><strong><?php print_string('formattexttype'); ?>:</strong></td>
-    <td colspan="2">
-    <?php
-        if ($usehtmleditor) {   /// Trying this out for a while
-            print_string('formathtml');
-            echo '<input type="hidden" name="format" value="'.FORMAT_HTML.'" />';
-        } else {
-            choose_from_menu(format_text_menu(), 'format', $post->format, '');
-        }
-     ?>
-    <small><small>
-    <?php
-        helpbutton('textformat', get_string('helpformatting'));
-     ?>
-    </small></small>
-    <?php  if (isset($errors["summary"])) formerr($errors["summary"]); ?>
-    </td>
-</tr>
-<tr valign="top">
-    <td align="right">
-        <strong><?php print_string('tags'); echo ':';?></strong>
-    </td>
-
-    <td>
-        <table width="100%">
-            <tr>
-                <td>
-                <b><?php print_string('otags','blog'); ?></b>
-                </td>
-                <td>
-                <b><?php print_string('ptags','blog'); ?></b>
-                </td>
-            </tr>
-            <tr>
-                <td>
-                <select name="otags[]" multiple="multiple" size="8">
-                <?php
-                    $otags = get_records_sql('SELECT * from '.$CFG->prefix.'tags WHERE type=\'official\' ORDER by text ASC');
-                    foreach ($otags as $otag) {
-                        if (in_array($otag->id, $usedtags)) {
-                            echo '<option value="'.$otag->id.'" selected="selected">'.$otag->text.'</option>';
-                        } else {
-                            echo '<option value="'.$otag->id.'">'.$otag->text.'</option>';
-                        }
-                    }
-                ?>
-                </select>
-                &nbsp;&nbsp;</td>
-
-                <td>
-                <?php
-                    if (!empty($post->id)) {
-                        $idsql = " AND bti.entryid = {$post->id}";
-                    } else {
-                        $idsql = " AND bti.entryid = 0";  
-                    }
-                    
-                    $pptag = '';
-                    if ($ptags = get_records_sql("SELECT t.* FROM 
-                                                 {$CFG->prefix}tags t, 
-                                                 {$CFG->prefix}blog_tag_instance bti
-                                                 WHERE t.id = bti.tagid
-                                                 AND t.type = 'personal'
-                                                 $idsql")) {
-                    
-                        foreach ($ptags as $ptag) {
-                            $pptag .= $ptag->text.',';  
-                        }
-                        $pptag = rtrim($pptag, ",");
-                    }
-                
-                
-                ?>
-                <input type="text" name="ptags" value="<?php echo $pptag;?>"/>
-                <?php
-                    $sitecontext = get_context_instance(CONTEXT_SYSTEM);
-                    // only make sense to link if the user has capablity
-                    if (has_capability('moodle/blog:managepersonaltags', $sitecontext) || has_capability('moodle/blog:manageofficialtags', $sitecontext)) {
-                        echo "<br/>";
-                        link_to_popup_window("/blog/tags.php",'popup',get_string('tagmanagement'));
-                    }
-                ?>
-                </td>
-            </tr>
-        </table>
-    </td>
-</tr>
-<tr valign="top">
-    <td align="right"><b><?php print_string("attachment", "forum") ?>:<br />(<?php print_string("optional") ?>)&nbsp;</b></td>
-    <td>
-    <?php $maxbytes = get_max_upload_file_size($CFG->maxbytes); ?>
-    <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $maxbytes ?>" />
-    <input type="file" name="attachment" size="40" alt="<?php print_string("attachment", "forum") ?>" />
-    <?php
-    print_string("maxsize", "", display_size($maxbytes)); 
-    ?>
-    </td>
-</tr>
-<tr valign="top">
-    <td align="right">
-        <strong><?php print_string('publishto', 'blog'); ?>:</strong>
-    </td>
-    <td colspan="2">
-     <?php
-        $options = blog_applicable_publish_states(); //$blogEntry may be null
-        choose_from_menu($options, 'publishstate', $post->publishstate, '');
-     ?>
-    <?php
-        helpbutton('publish_state', get_string('helppublish', 'blog'), 'blog');
-     ?>
-    </td>
-</tr>
-<tr>
-    <td align="center" colspan="3">
-        <input type="hidden" name="sesskey" value="<?php echo sesskey(); ?>" />
-        <input type="hidden" name="action" value="<?php echo $action; ?>" />
-        <input type="hidden" name="courseid" value="<?php echo $courseid; ?>" />
-<?php
-    if ($action == 'add') {
-?>
-        <input type="hidden" name="action" value="add" />
-        <input type="submit" value="<?php print_string('add'); ?>" />&nbsp;
-        <input type="button" value="<?php print_string('cancel'); ?>" onclick="javascript:history.go(-1)" />
-<?php
-    } else { ?>
-        <input type="hidden" name="id" value="<?php echo $post->id; ?>" />
-        <input type="submit" value="<?php print_string('savechanges'); ?>" />&nbsp;
-        <input type="button" value="<?php print_string('cancel'); ?>" onclick="javascript:history.go(-1)" />
-<?php } ?>
-    </td>
-</tr>
-</table>
-</form>
index 5c1639f716f736f6ffae3f02a22f28a5abed3488..d5343add1bfc8540311005a91ca38c85f8c32267 100755 (executable)
@@ -46,81 +46,104 @@ if (!empty($courseid)) {
     $returnurl .= '&amp;courseid='.$courseid;
 }
 
-$errors = array();
-$post = new object(); // editing form data
 
-$usehtmleditor = can_use_richtext_editor();
 $strblogs = get_string('blogs','blog');
 
-/// Main switch for processing blog entry
-switch ($action) {
+if ($action=='delete'){
+    if (!$existing) {
+        error('Incorrect blog post id');
+    }
+    if (data_submitted() and $confirm and confirm_sesskey()) {
+        do_delete($existing);
+        redirect($returnurl);
+    } else {
+        $optionsyes = array('id'=>$id, 'action'=>'delete', 'confirm'=>1, 'sesskey'=>sesskey(), 'courseid'=>$courseid);
+        $optionsno = array('userid'=>$existing->userid, 'courseid'=>$courseid);
+        print_header("$SITE->shortname: $strblogs", $SITE->fullname);
+        blog_print_entry($existing);
+        echo '<br />';
+        notice_yesno(get_string('blogdeleteconfirm', 'blog'), 'edit.php', 'index.php', $optionsyes, $optionsno, 'post', 'get');
+        print_footer();
+        die;
+    }
+}
 
-    case 'add':
-        if (data_submitted() and confirm_sesskey()) {
-            do_add($post, $errors);
-            if (empty($errors)) {
-                redirect($returnurl);
+require_once('edit_form.php');
+$blogpostform = new blog_post_form(null, compact('existing', 'sitecontext'));
+
+if ($blogpostform->is_cancelled()){
+    redirect($returnurl);
+} elseif ($blogpostform->no_submit_button_pressed()) {
+    no_submit_button_actions($blogpostform, $sitecontext);
+
+
+} elseif ($fromform = $blogpostform->data_submitted()){
+    //save stuff in db
+    switch ($action) {
+        case 'add':
+            do_add($fromform);
+        break;
+
+        case 'edit':
+            if (!$existing) {
+                error('Incorrect blog post id');
             }
-            $post = stripslashes_safe($post); // no db access after this!!
-            // print form again
-        } else {
-            // prepare new empty form
-            $post->subject      = '';
-            $post->summary      = '';
-            $post->publishstate = 'draft';
-            $post->format       = $usehtmleditor ? FORMAT_HTML : FORMAT_MOODLE;
+            do_edit($fromform);
+        break;
+        default :
+            error('Unknown action!');
+    }
+    redirect($returnurl);
+}
 
-        }
+
+// gui setup
+switch ($action) {
+    case 'add':
+        // prepare new empty form
+        $post->publishstate = 'draft';
         $strformheading = get_string('addnewentry', 'blog');
+        $post->action       = $action;
     break;
 
     case 'edit':
         if (!$existing) {
             error('Incorrect blog post id');
         }
-        if (data_submitted() and confirm_sesskey()) {
-            do_edit($post, $errors);
-            if (empty($errors)) {
-                redirect($returnurl);
-            }
-            $post = stripslashes_safe($post); // no db access after this!!
-            // print form again
-        } else {
-            $post->id           = $existing->id;
-            $post->subject      = $existing->subject;
-            $post->summary      = $existing->summary;
-            $post->publishstate = $existing->publishstate;
-            $post->format       = $existing->format;
-        }
+        $post->id           = $existing->id;
+        $post->subject      = $existing->subject;
+        $post->summary      = $existing->summary;
+        $post->publishstate = $existing->publishstate;
+        $post->format       = $existing->format;
+        $post->action       = $action;
         $strformheading = get_string('updateentrywithid', 'blog');
-    break;
 
-    case 'delete':
-        if (!$existing) {
-            error('Incorrect blog post id');
-        }
-        if (data_submitted() and $confirm and confirm_sesskey()) {
-            do_delete($existing);
-            redirect($returnurl);
+        if ($ptags = get_records_sql_menu("SELECT t.id, t.text FROM
+                                     {$CFG->prefix}tags t,
+                                     {$CFG->prefix}blog_tag_instance bti
+                                     WHERE t.id = bti.tagid
+                                     AND t.type = 'personal'
+                                     AND bti.entryid = {$post->id}")) {
+
+            $post->ptags = implode(', ', $ptags);
         } else {
-            $optionsyes = array('id'=>$id, 'action'=>'delete', 'confirm'=>1, 'sesskey'=>sesskey(), 'courseid'=>$courseid);
-            $optionsno = array('userid'=>$existing->userid, 'courseid'=>$courseid);
-            print_header("$SITE->shortname: $strblogs", $SITE->fullname);
-            blog_print_entry($existing);
-            echo '<br />';
-            notice_yesno(get_string('blogdeleteconfirm', 'blog'), 'edit.php', 'index.php', $optionsyes, $optionsno, 'post', 'get');
-            print_footer();
-            die;
+            //$idsql = " AND bti.entryid = 0";
+            //was used but seems redundant.
+            $post->ptags = '';
+        }
+        if ($otags = get_records_sql_menu("SELECT t.id, t.text FROM
+                                     {$CFG->prefix}tags t,
+                                     {$CFG->prefix}blog_tag_instance bti
+                                     WHERE t.id = bti.tagid
+                                     AND t.type = 'official'
+                                     AND bti.entryid = {$post->id}")){
+            $post->otags = array_keys($otags);
         }
     break;
-
-    default:
+    default :
         error('Unknown action!');
-    break;
 }
 
-// gui setup
-
 // done here in order to allow deleting of posts with wrong user id above
 if (!$user = get_record('user', 'id', $userid)) {
     error('Incorrect user id');
@@ -129,21 +152,87 @@ if (!$user = get_record('user', 'id', $userid)) {
 print_header("$SITE->shortname: $strblogs", $SITE->fullname,
                 '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$userid.'">'.fullname($user).'</a> ->
                 <a href="'.$CFG->wwwroot.'/blog/index.php?userid='.$userid.'">'.$strblogs.'</a> -> '.$strformheading,'','',true);
+$blogpostform->set_defaults($post);
+$blogpostform->display();
 
-echo '<br />';
-print_simple_box_start('center');
-require('edit.html');
-print_simple_box_end();
-
-if ($usehtmleditor) {
-    use_html_editor();
-}
 
 print_footer();
 
+
 die;
 
 /*****************************   edit.php functions  ***************************/
+function no_submit_button_actions(&$blogpostform, $sitecontext){
+    $mform =& $blogpostform->_form;
+    $data = $mform->exportValues();
+    //sesskey has been checked already no need to check that
+    //check for official tags to add
+    if (!empty($data['addotags']) && !empty($data['otagsadd'])){ // adding official tag
+        $error = add_otag($data['otagsadd']);
+    }
+    if (!empty($error)){
+        $mform->setElementError('otagsgrp', $error);
+    }
+    if (!empty($data['deleteotags']) && !empty($data['otags'])){ // adding official tag
+        delete_otags($data['otags'], $sitecontext);
+    }
+    $blogpostform->otags_select_setup();
+}
+function delete_otags($tagids, $sitecontext){
+    foreach ($tagids as $tagid) {
+
+        if (!$tag = get_record('tags', 'id', $tagid)) {
+            error('Can not delete tag, tag doesn\'t exist');
+        }
+
+        if ($tag->type == 'official' and !has_capability('moodle/blog:manageofficialtags', $sitecontext)) {
+            //can not delete
+            error('Can not delete tag, you don\'t have permission to delete an official tag');
+        }
+
+        if ($tag->type == 'personal' and !has_capability('moodle/blog:managepersonaltags', $sitecontext)) {
+            //can not delete
+            error('Can not delete tag, you don\'t have permission to delete a personal tag');
+        }
+
+        // Delete the tag itself
+        if (!delete_records('tags', 'id', $tagid)) {
+            error('Can not delete tag');
+        }
+
+        // Deleteing all references to this tag
+        if (!delete_records('blog_tag_instance', 'tagid', $tagid)) {
+            error('Can not delete blog tag instances');
+        }
+
+
+    }
+}
+function add_otag($otag){
+    global $USER;
+    $error = '';
+    if ($tag = get_record('tags', 'text', $otag)) {
+        if ($tag->type == 'official') {
+            // official tag already exist
+            $error = get_string('tagalready');
+        } else {
+            $tag->type = 'official';
+            update_record('tags', $tag);
+            $tagid = $tag->id;
+        }
+    } else { // Brand new offical tag
+
+        $tag = new object();
+        $tag->userid = $USER->id;
+        $tag->text   = $otag;
+        $tag->type   = 'official';
+
+        if (!$tagid = insert_record('tags', $tag)) {
+            error('Can not create tag!');
+        }
+    }
+    return $error;
+}
 /*
 * Delete blog post from database
 */
@@ -163,14 +252,9 @@ function do_delete($post) {
 /**
  * Write a new blog entry into database
  */
-function do_add(&$post, &$errors) {
+function do_add($post) {
     global $CFG, $USER, $returnurl;
 
-    $post->subject      = required_param('subject', PARAM_MULTILANG);
-    $post->summary      = required_param('summary', PARAM_RAW);
-    $post->format       = required_param('format', PARAM_INT);
-    $post->publishstate = required_param('publishstate', PARAM_ALPHA);;
-
     if ($post->summary == '<br />') {
         $post->summary = '';
     }
@@ -190,16 +274,16 @@ function do_add(&$post, &$errors) {
     $post->userid       = $USER->id;
     $post->lastmodified = time();
     $post->created      = time();
-    
+
     // Insert the new blog entry.
     if ($id = insert_record('post', $post)) {
         $post->id = $id;
         // add blog attachment
         if ($post->attachment = blog_add_attachment($post, 'attachment',$message)) {
             set_field("post", "attachment", $post->attachment, "id", $post->id);
-        }       
+        }
         add_tags_info($post->id);
-        add_to_log(SITEID, 'blog', 'add', 'index.php?userid='.$post->userid.'&postid='.$posz->id, $post->subject);
+        add_to_log(SITEID, 'blog', 'add', 'index.php?userid='.$post->userid.'&postid='.$post->id, $post->subject);
 
     } else {
         error('There was an error adding this post in the database', $returnurl);
@@ -212,52 +296,32 @@ function do_add(&$post, &$errors) {
  * @param . $bloginfo_arg argument is reference to a blogInfo object.
  * @todo complete documenting this function. enable trackback and pingback between entries on the same server
  */
-function do_edit(&$post, &$errors) {
+function do_edit($post) {
 
     global $CFG, $USER, $returnurl;
 
-    $post->id           = required_param('id', PARAM_INT);
-    $post->subject      = required_param('subject', PARAM_MULTILANG);
-    $post->summary      = required_param('summary', PARAM_RAW);
-    $post->format       = required_param('format', PARAM_INT);
-    $post->publishstate = required_param('publishstate', PARAM_ALPHA);;
-
-    if ($post->summary == '<br />') {
-        $post->summary = '';
-    }
-
-    if ($post->subject == '') {
-        $errors['subject'] = get_string('emptytitle', 'blog');
-    }
-    if ($post->summary == '') {
-        $errors['summary'] = get_string('emptybody', 'blog');
-    }
-
-    if (!empty($errors)) {
-        return; // no saving
-    }
 
     $post->lastmodified = time();
-    
+
+/*  TODO add attachment processing
     if ($newfilename = blog_add_attachment($post, 'attachment',$message)) {
         $post->attachment = $newfilename;
     } else {
         unset($post->attachment);
-    }
+    }*/
     // update record
     if (update_record('post', $post)) {
         // delete all tags associated with this entry
         delete_records('blog_tag_instance', 'entryid', $post->id);
         // add them back
         add_tags_info($post->id);
-        
+
 
         add_to_log(SITEID, 'blog', 'update', 'index.php?userid='.$post->userid.'&postid='.$post->id, $post->subject);
 
     } else {
         error('There was an error updating this post in the database', $returnurl);
     }
-    
 }
 
 /**
@@ -265,18 +329,18 @@ function do_edit(&$post, &$errors) {
  * @param int postid - id of the blog
  */
 function add_tags_info($postid) {
-    
+
     global $USER;
-    
+
     $post = get_record('post', 'id', $postid);
 
     $tag = new object();
     $tag->entryid = $post->id;
     $tag->userid = $post->userid;
     $tag->timemodified = time();
-        
+
     /// Attach official tags
-    if ($otags = optional_param('otags','', PARAM_INT)) {
+    if ($otags = optional_param('otags', '', PARAM_INT)) {
         foreach ($otags as $otag) {
             $tag->tagid = $otag;
             insert_record('blog_tag_instance', $tag);
@@ -284,8 +348,8 @@ function add_tags_info($postid) {
     }
 
     /// Attach Personal Tags
-    if ($ptags = optional_param('ptags','', PARAM_NOTAGS)) {
-        $ptags = explode(',',$ptags);
+    if ($ptags = optional_param('ptags', '', PARAM_NOTAGS)) {
+        $ptags = explode(',', $ptags);
         foreach ($ptags as $ptag) {
             $ptag = trim($ptag);
             // check for existance
@@ -302,7 +366,7 @@ function add_tags_info($postid) {
                 if ($tagid = insert_record('tags', $ctag)) {
                     $tag->tagid = $tagid;
                     insert_record('blog_tag_instance', $tag);
-                }         
+                }
             }
         }
     }
diff --git a/blog/edit_form.php b/blog/edit_form.php
new file mode 100644 (file)
index 0000000..cef59f4
--- /dev/null
@@ -0,0 +1,103 @@
+<?php  // $Id$
+
+require_once($CFG->libdir.'/formslib.php');
+
+class blog_edit_form extends moodleform {
+
+       function definition() {
+
+               global $CFG, $COURSE, $USER;
+               $mform    =& $this->_form;
+
+               $post = $this->_customdata['existing'];
+        $sitecontext = $this->_customdata['sitecontext'];
+
+        // the upload manager is used directly in post precessing, moodleform::save_files() is not used yet
+        $this->_upload_manager = new upload_manager('attachment', true, false, $COURSE, false, 0, true, true);
+        $this->set_max_file_size($COURSE);
+
+        $mform->addElement('header', 'general', get_string('general', 'form'));
+               $mform->addElement('text', 'subject', get_string('entrytitle', 'blog'), 'size="60"');
+               $mform->setType('subject', PARAM_TEXT);
+               $mform->addRule('subject', get_string('emptytitle', 'blog'), 'required', null, 'client');
+
+               $mform->addElement('htmleditor', 'summary', get_string('entrybody', 'blog'), array('rows'=>25));
+               $mform->setType('summary', PARAM_RAW);
+               $mform->addRule('summary', get_string('emptybody', 'blog'), 'required', null, 'client');
+
+        $mform->addElement('format', 'format', get_string('format'));
+
+        $mform->addElement('file', 'attachment', get_string('attachment', 'forum'));
+
+        $mform->addElement('select', 'publishstate', get_string('publishto', 'blog'), blog_applicable_publish_states());
+        $mform->setHelpButton('publishstate', array('publish_state', get_string('helppublish', 'blog'), 'blog'));
+
+        $mform->addElement('header', 'tagshdr', get_string('tags', 'blog'));
+
+        $mform->createElement('select', 'otags', get_string('otags','blog'));
+
+        $js_escape = array(
+            "\r"    => '\r',
+            "\n"    => '\n',
+            "\t"    => '\t',
+            "'"     => "\\'",
+            '"'     => '\"',
+            '\\'    => '\\\\'
+        );
+
+        $otagsselEl =& $mform->addElement('select', 'otags', get_string('otags', 'blog'), array(), 'size="5"');
+        $otagsselEl->setMultiple(true);
+        $this->otags_select_setup();
+
+        if (has_capability('moodle/blog:manageofficialtags', $sitecontext)){
+            $deleteotagsmsg = strtr(get_string('deleteotagswarn', 'blog'), $js_escape);
+            $mform->registerNoSubmitButton('deleteotags');
+            $mform->addElement('submit', 'deleteotags', get_string('delete'),
+                            array('onclick'=>"return confirm('$deleteotagsmsg');"));
+            $mform->disabledIf('deleteotags', 'otags[]', 'noitemselected');
+            $mform->setAdvanced('deleteotags');
+
+            $mform->registerNoSubmitButton('addotags');
+            $otagsgrp = array();
+            $otagsgrp[] =& $mform->createElement('text', 'otagsadd', get_string('addotags', 'blog'));
+            $otagsgrp[] =& $mform->createElement('submit', 'addotags', get_string('add'));
+            $mform->addGroup($otagsgrp, 'otagsgrp', get_string('addotags','blog'), array(' '), false);
+            $mform->setType('otagsadd', PARAM_NOTAGS);
+            $mform->setAdvanced('otagsgrp');
+        }
+
+        $mform->addElement('textarea', 'ptags', get_string('ptags', 'blog'), array('wrap'=>'soft'));
+        $mform->setType('ptagsadd', PARAM_NOTAGS);
+
+        $this->add_action_buttons();
+
+        $mform->addElement('hidden', 'action');
+               $mform->setType('action', PARAM_ACTION);
+               $mform->setDefault('action', '');
+
+               $mform->addElement('hidden', 'courseid');
+               $mform->setType('courseid', PARAM_INT);
+
+               $mform->addElement('hidden', 'id');
+               $mform->setType('id', PARAM_INT);
+               $mform->setDefault('id', 0);
+
+       }
+
+       /**
+        * This function sets up options of otag select element. This is called from definition and also
+        * after adding new official tags with the add tag button.
+        *
+        */
+       function otags_select_setup(){
+           global $CFG;
+           $mform =& $this->_form;
+        $otagsselect =& $mform->getElement('otags');
+        $otagsselect->removeOptions();
+        if ($otags = get_records_sql_menu('SELECT id, text from '.$CFG->prefix.'tags WHERE type=\'official\' ORDER by text ASC')){
+            $otagsselect->loadArray($otags);
+        }
+       }
+
+}
+?>
index 6eb81e3eb695724820321e9fc01074db55cb025f..b4e7334f27b80a5244006329ca3814ddcf4cffd5 100644 (file)
     $mformclassname=$module->name.'_mod_form';
     $cousesection=isset($cw->section)?$cw->section:$section;
     $mform=& new $mformclassname($form->instance, $cousesection, ((isset($cm))?$cm:null));
+    $mform->set_defaults($form);
 
     if ($mform->is_cancelled()) {
         if ($return && isset($cm)){
         $icon = '<img align="middle" height="16" width="16" src="'.$CFG->modpixpath.'/'.$module->name.'/icon.gif" alt="" style="vertical-align: middle;" />&nbsp;';
 
         print_heading_with_help($pageheading, "mods", $module->name, $icon);
-        $mform->set_defaults($form);
         $mform->display();
         print_footer($course);
     }
index 63a445325928a4a1f23e8d7acb02b94099b930b4..9edc15dff8895f0ddcbab6b984f5a6282b5855bb 100755 (executable)
@@ -2,7 +2,7 @@
 
 require_once($CFG->libdir.'/formslib.php');
 
-class authorize_enrol_form extends moodleform
+class enrol_authorize_enrol_form extends moodleform
 {
     function definition()
     {
index 3bbe80128e76fc0f298e95627b262ee8600b9785..db66304422c0eb3a53e931136b3362f7d88940d5 100755 (executable)
@@ -1,4 +1,4 @@
-<?PHP // $Id$ 
+<?PHP // $Id$
       // blog.php - created with Moodle 1.7 beta + (2006101003)
 
 
@@ -15,6 +15,7 @@ $string['blogs'] = 'Blogs';
 $string['blogtags'] = 'Blog Tags';
 $string['courseblog'] = 'Course blog: $a';
 $string['courseblogs'] = 'Users can only see blogs for people who share a course';
+$string['deleteotagswarn'] = 'Are you sure you want to remove this / these tags \nfrom all blog posts and remove it from the system?';
 $string['disableblogs'] = 'Disable blog system completely';
 $string['emptybody'] = 'Blog entry body can not be empty';
 $string['emptytitle'] = 'Blog entry title can not be empty';
@@ -47,6 +48,7 @@ $string['siteblogs'] = 'All site users can see all blog entries';
 $string['tagdatelastused'] = 'Date tag was last used';
 $string['tagsort'] = 'Sort the tag display by';
 $string['tagtext'] = 'Tag text';
+$string['tags'] = 'Tags';
 $string['timewithin'] = 'Display tags used within this many days';
 $string['updateentrywithid'] = 'Updating entry';
 $string['userblog'] = 'User blog: $a';
index 047d5a3bc564b98c7b862e83d2ea0ece210e48e2..54d8fb0dec61df31e4820b774d4e63339e13c280 100644 (file)
@@ -928,16 +928,16 @@ $string['newuser'] = 'New user';
 $string['newusernewpasswordsubj'] = 'New user account';
 $string['newusernewpasswordtext'] = 'Hi $a->firstname,
 
-A new account has been created for you at \'$a->sitename\' 
+A new account has been created for you at \'$a->sitename\'
 and you have been issued with a new temporary password.
 
 Your current login information is now:
    username: $a->username
    password: $a->newpassword
-             (you will have to change your password 
+             (you will have to change your password
               when you login for the first time)
 
-To start using \'$a->sitename\', login at 
+To start using \'$a->sitename\', login at
    $a->link
 
 In most mail programs, this should appear as a blue link
@@ -975,7 +975,7 @@ $string['nopotentialcreators'] = 'No potential course creators';
 $string['nopotentialstudents'] = 'No potential students';
 $string['nopotentialteachers'] = 'No potential teachers';
 $string['norecentactivity'] = 'No recent activity';
-$string['noreplybouncemessage'] = 'You have replied to a no-reply email address. If you were attempting to reply to a forum post, please instead reply using the $a forums. 
+$string['noreplybouncemessage'] = 'You have replied to a no-reply email address. If you were attempting to reply to a forum post, please instead reply using the $a forums.
 
 Following is the content of your email:';
 $string['noreplybouncesubject'] = '$a - bounced email.';
@@ -1325,6 +1325,7 @@ $string['supplyinfo'] = 'Please supply some information about yourself';
 $string['switchrolereturn'] = 'Return to my normal role';
 $string['switchroleto'] = 'Switch role to...';
 $string['tag'] = 'Tag';
+$string['tagalready'] = 'This tag already exists';
 $string['tagmanagement'] = 'Add/delete tags ...';
 $string['tags'] = 'Tags';
 $string['targetrole'] = 'Target role';
index 88c0f51b9a408597bad382b5580604ba43de1b2e..68246a3b536f8366fe73a0966f10caf3652c1a09 100644 (file)
@@ -49,6 +49,7 @@ if ($CFG->debug >= DEBUG_ALL){
     PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'pear_handle_error');
 }
 
+
 /**
  * Moodle specific wrapper that separates quickforms syntax from moodle code. You won't directly
  * use this class you should write a class defintion which extends this class or a more specific
@@ -107,7 +108,8 @@ class moodleform {
         if (empty($action)){
             $action = strip_querystring(qualified_me());
         }
-        //strip '_form' from the end of class name to make form 'id' attribute.
+
+        //strip '_form' from the end of class name to make form name attribute.
         $this->_formname = preg_replace('/_form$/', '', get_class($this), 1);
         $this->_customdata = $customdata;
         $this->_form =& new MoodleQuickForm($this->_formname, $method, $action, $target, $attributes);
@@ -279,6 +281,9 @@ class moodleform {
         }
         $mform =& $this->_form;
         $nosubmit = false;
+        if (!$this->is_submitted()){
+            return false;
+        }
         foreach ($mform->_noSubmitButtons as $nosubmitbutton){
             if (optional_param($nosubmitbutton, 0, PARAM_RAW)){
                 $nosubmit = true;
@@ -297,9 +302,7 @@ class moodleform {
     function is_validated() {
         static $validated = null; // one validation is enough
         $mform =& $this->_form;
-        if ($this->no_submit_button_pressed()){
-            return false;
-        }
+
         if ($validated === null) {
             $internal_val = $mform->validate();
             $moodle_val = $this->validation($mform->exportValues(null, true));
@@ -324,7 +327,11 @@ class moodleform {
             }
             $validated = ($internal_val and $moodle_val and $file_val);
         }
-        return $validated;
+        if ($this->no_submit_button_pressed()){
+            return false;
+        } else {
+            return $validated;
+        }
     }
 
     /**
@@ -576,6 +583,15 @@ class MoodleQuickForm extends HTML_QuickForm_DHTMLRulesTableless {
      */
     var $_showAdvanced = null;
 
+    /**
+     * The form name is derrived from the class name of the wrapper minus the trailing form
+     * It is a name with words joined by underscores whereas the id attribute is words joined by
+     * underscores.
+     *
+     * @var unknown_type
+     */
+    var $_formName = '';
+
     /**
      * Class constructor - same parameters as HTML_QuickForm_DHTMLRulesTableless
      * @param    string      $formName          Form's name.
@@ -591,8 +607,9 @@ class MoodleQuickForm extends HTML_QuickForm_DHTMLRulesTableless {
 
         HTML_Common::HTML_Common($attributes);
         $target = empty($target) ? array() : array('target' => $target);
+        $this->_formName = $formName;
         //no 'name' atttribute for form in xhtml strict :
-        $attributes = array('action'=>$action, 'method'=>$method, 'id'=>$formName) + $target;
+        $attributes = array('action'=>$action, 'method'=>$method, 'id'=>strtr($formName, '_', '-')) + $target;
         $this->updateAttributes($attributes);
 
         //this is custom stuff for Moodle :
@@ -648,9 +665,9 @@ class MoodleQuickForm extends HTML_QuickForm_DHTMLRulesTableless {
                 return;
             } else { //if setShowAdvanced is called without any preference
                      //make the default to not show advanced elements.
-                $showadvancedNow = 0;
+                $showadvancedNow = get_user_preferences(
+                                moodle_strtolower($this->_formName.'_showadvanced', 0));
             }
-
         }
         //value of hidden element
         $hiddenLast = optional_param('mform_showadvanced_last', -1, PARAM_INT);
@@ -665,6 +682,9 @@ class MoodleQuickForm extends HTML_QuickForm_DHTMLRulesTableless {
             $next = $hiddenLast;
         }
         $this->_showAdvanced = $next;
+        if ($showadvancedNow != $next){
+            set_user_preference($this->_formName.'_showadvanced', $next);
+        }
         $this->setConstants(array('mform_showadvanced_last'=>$next));
     }
     function getShowAdvanced(){
@@ -858,6 +878,74 @@ class MoodleQuickForm extends HTML_QuickForm_DHTMLRulesTableless {
             return $unfiltered;
         }
     }
+    /**
+     * Adds a validation rule for the given field
+     *
+     * If the element is in fact a group, it will be considered as a whole.
+     * To validate grouped elements as separated entities,
+     * use addGroupRule instead of addRule.
+     *
+     * @param    string     $element       Form element name
+     * @param    string     $message       Message to display for invalid data
+     * @param    string     $type          Rule type, use getRegisteredRules() to get types
+     * @param    string     $format        (optional)Required for extra rule data
+     * @param    string     $validation    (optional)Where to perform validation: "server", "client"
+     * @param    boolean    $reset         Client-side validation: reset the form element to its original value if there is an error?
+     * @param    boolean    $force         Force the rule to be applied, even if the target form element does not exist
+     * @since    1.0
+     * @access   public
+     * @throws   HTML_QuickForm_Error
+     */
+    function addRule($element, $message, $type, $format=null, $validation='server', $reset = false, $force = false)
+    {
+        parent::addRule($element, $message, $type, $format, $validation, $reset, $force);
+        if ($validation == 'client') {
+            $this->updateAttributes(array('onsubmit' => 'try { var myValidator = validate_' . $this->_formName . '; } catch(e) { return true; } return myValidator(this);'));
+        }
+
+    } // end func addRule
+    /**
+     * Adds a validation rule for the given group of elements
+     *
+     * Only groups with a name can be assigned a validation rule
+     * Use addGroupRule when you need to validate elements inside the group.
+     * Use addRule if you need to validate the group as a whole. In this case,
+     * the same rule will be applied to all elements in the group.
+     * Use addRule if you need to validate the group against a function.
+     *
+     * @param    string     $group         Form group name
+     * @param    mixed      $arg1          Array for multiple elements or error message string for one element
+     * @param    string     $type          (optional)Rule type use getRegisteredRules() to get types
+     * @param    string     $format        (optional)Required for extra rule data
+     * @param    int        $howmany       (optional)How many valid elements should be in the group
+     * @param    string     $validation    (optional)Where to perform validation: "server", "client"
+     * @param    bool       $reset         Client-side: whether to reset the element's value to its original state if validation failed.
+     * @since    2.5
+     * @access   public
+     * @throws   HTML_QuickForm_Error
+     */
+    function addGroupRule($group, $arg1, $type='', $format=null, $howmany=0, $validation = 'server', $reset = false)
+    {
+        parent::addGroupRule($group, $arg1, $type, $format, $howmany, $validation, $reset);
+        if (is_array($arg1)) {
+             foreach ($arg1 as $elementIndex => $rules) {
+                foreach ($rules as $rule) {
+                    $validation = (isset($rule[3]) && 'client' == $rule[3])? 'client': 'server';
+
+                    if ('client' == $validation) {
+                        $this->updateAttributes(array('onsubmit' => 'try { var myValidator = validate_' . $this->_formName . '; } catch(e) { return true; } return myValidator(this);'));
+                    }
+                }
+            }
+        } elseif (is_string($arg1)) {
+
+            if ($validation == 'client') {
+                $this->updateAttributes(array('onsubmit' => 'try { var myValidator = validate_' . $formname . '; } catch(e) { return true; } return myValidator(this);'));
+            }
+        }
+    } // end func addGroupRule
+
+    // }}}
     /**
      * Returns the client side validation script
      *
@@ -986,7 +1074,7 @@ function qf_errorHandler(element, _qfMsg) {
             list($jsArr,$element)=$jsandelement;
             //end of fix
             $js .= '
-function validate_' . $this->_attributes['id'] . '_' . $elementName . '(element) {
+function validate_' . $this->_formName . '_' . $elementName . '(element) {
   var value = \'\';
   var errFlag = new Array();
   var _qfGroups = {};
@@ -1000,12 +1088,12 @@ function validate_' . $this->_attributes['id'] . '_' . $elementName . '(element)
 }
 ';
             $validateJS .= '
-  ret = validate_' . $this->_attributes['id'] . '_' . $elementName.'(frm.elements[\''.$elementName.'\']) && ret;';
+  ret = validate_' . $this->_formName . '_' . $elementName.'(frm.elements[\''.$elementName.'\']) && ret;';
             // Fix for bug displaying errors for elements in a group
             //unset($element);
             //$element =& $this->getElement($elementName);
             //end of fix
-            $valFunc = 'validate_' . $this->_attributes['id'] . '_' . $elementName . '(this)';
+            $valFunc = 'validate_' . $this->_formName . '_' . $elementName . '(this)';
             $onBlur = $element->getAttribute('onBlur');
             $onChange = $element->getAttribute('onChange');
             $element->updateAttributes(array('onBlur' => $onBlur . $valFunc,
@@ -1013,7 +1101,7 @@ function validate_' . $this->_attributes['id'] . '_' . $elementName . '(element)
         }
 //  do not rely on frm function parameter, because htmlarea breaks it when overloading the onsubmit method
         $js .= '
-function validate_' . $this->_attributes['id'] . '(frm) {
+function validate_' . $this->_formName . '(frm) {
   if (skipClientValidation) {
      return true;
   }
index eb0b8e8e8b728dc3771fcb04316af191d2b44bbb..c7e4444dc1394322932b7acdf450f67e15ad03dd 100644 (file)
@@ -58,10 +58,24 @@ function lockoptions(form, master, subitems) {
   return(true);
 }
 
+function lockoption(form,item) {
+  eval("document."+form+"."+item+".disabled=true");/* IE thing */
+  if(document.forms[form].elements['h'+item]) {
+    eval("document."+form+".h"+item+".value=1");
+  }
+}
+
+function unlockoption(form,item) {
+  eval("document."+form+"."+item+".disabled=false");/* IE thing */
+  if(document.forms[form].elements['h'+item]) {
+    eval("document."+form+".h"+item+".value=0");
+  }
+}
 function lockoptionsall(formid) {
-  var lock=new Object();
-  var items=eval(formid+'items');
-  var form=document.forms[formid];
+  var lock = new Object();
+  var varname = formid.replace(/\-/g, '_');
+  var items = eval(varname+'items');
+  var form = document.forms[formid];
   for (var master in items){
       var subitems=items[master].dependents;
       var thislock;
@@ -94,7 +108,8 @@ function lockoptionsall(formid) {
 }
 
 function lockoptionsallsetup(formid) {
-  var items=eval(formid+'items');
+  var varname = formid.replace(/\-/g, '_');
+  var items=eval(varname+'items');
   var form=document.forms[formid];
   for (var i = 0; i < form.elements.length; i++){
       var found=false;
@@ -113,26 +128,11 @@ function lockoptionsallsetup(formid) {
               }
           }
       }
-      if (found){
-      }
   }
 
   return lockoptionsall(formid);
 }
 
-function lockoption(form,item) {
-  eval("document."+form+"."+item+".disabled=true");/* IE thing */
-  if(document.forms[form].elements['h'+item]) {
-    eval("document."+form+".h"+item+".value=1");
-  }
-}
-
-function unlockoption(form,item) {
-  eval("document."+form+"."+item+".disabled=false");/* IE thing */
-  if(document.forms[form].elements['h'+item]) {
-    eval("document."+form+".h"+item+".value=0");
-  }
-}
 
 function submitFormById(id) {
     var theform = document.getElementById(id);
@@ -219,15 +219,16 @@ function findChildNodes(start, tagName, elementClass, elementID, elementName) {
                 }
             }
         }
-        if( (child.nodeType == 1) &&//element node type
-            (!tagName || child.nodeName == tagName) &&
-            (!elementClass || classfound)&&
-            (!elementID || child.id == elementID) &&
-            (!elementName || child.name == elementName))
-        {
-            children = children.concat(child);
-        } else {
-            children = children.concat(findChildNodes(child, tagName, elementClass, elementID, elementName));
+        if(child.nodeType == 1) { //element node type
+            if  ( (!tagName || child.nodeName == tagName) &&
+                (!elementClass || classfound)&&
+                (!elementID || child.id == elementID) &&
+                (!elementName || child.name == elementName))
+            {
+                children = children.concat(child);
+            } else {
+                children = children.concat(findChildNodes(child, tagName, elementClass, elementID, elementName));
+            }
         }
     }
     return children;
index 1a3438dda92ad749370528ab3c9a8851d1054c14..56cf683ec3b3e6f646952f16cc6dafe5bff93439 100644 (file)
@@ -2,7 +2,7 @@
 
 require_once $CFG->libdir.'/formslib.php';
 
-class change_password_form extends moodleform {
+class login_change_password_form extends moodleform {
 
     function definition() {
         global $USER;
index bf2b386e6065e51855f061dbc80a4c918677ce4b..f035df54c6a1c5b5300a70c7a6a9ac8b6f649e2c 100644 (file)
@@ -2,7 +2,7 @@
 
 require_once $CFG->libdir.'/formslib.php';
 
-class forgot_password_form extends moodleform {
+class login_forgot_password_form extends moodleform {
 
     function definition() {
         $mform    =& $this->_form;
index 592cc737999612a7a1e30a72be2e83bd56e6e23a..28178ade69e595e170dc8d9a11663ac9659f3617 100644 (file)
@@ -240,7 +240,7 @@ class assignment_online extends assignment_base {
 
 }
 
-class assignment_online_edit_form extends moodleform {
+class mod_assignment_online_edit_form extends moodleform {
     function definition() {
         $mform =& $this->_form;
 
index 274f2ce568f53b98bcc2ee2634026fae4f45dd91..3c741c8ea93c1a81f03666f3ed157fcb721a420e 100644 (file)
@@ -914,7 +914,7 @@ class assignment_upload extends assignment_base {
 
 }
 
-class assignment_upload_notes_form extends moodleform {
+class mod_assignment_upload_notes_form extends moodleform {
     function definition() {
         $mform =& $this->_form;
 
index 047913bf9b04f4795b1687538d4fbe92e7f42995..b8f688f3beaef17e7e3f180fac462b4139ff6adf 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 require_once ('moodleform_mod.php');
 
-class chat_mod_form extends moodleform_mod {
+class mod_chat_mod_form extends moodleform_mod {
 
        function definition() {
 
index 810adc912e418f6a2d709c34a688aa302151f6ac..90f269ccca2504ac2b1bc479a89614f04ff31cd8 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 require_once ('moodleform_mod.php');
 
-class choice_mod_form extends moodleform_mod {
+class mod_choice_mod_form extends moodleform_mod {
 
        function definition() {
            global $CHOICE_SHOWRESULTS, $CHOICE_PUBLISH, $CHOICE_DISPLAY;
index dafebf00cea8d47fe357bda6f2fe3fa933faf1de..6a639a79d0a75ee1daa60d10e4be7d373d223a15 100644 (file)
@@ -2,7 +2,7 @@
 
 require_once $CFG->libdir.'/formslib.php';
 
-class data_comment_form extends moodleform {
+class mod_data_comment_form extends moodleform {
     function definition() {
         $mform =& $this->_form;
 
index 695bc7832177d38f2f45ab997d4ee2ab7f6ef637..4a5fff23be4b2a5b0563d742115a65b52258efd6 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 require_once ('moodleform_mod.php');
 
-class data_mod_form extends moodleform_mod {
+class mod_data_mod_form extends moodleform_mod {
 
     function definition() {
 
index a8d0f736fa1e5324257ff92534652ee52c32b5b9..1aecf746922a20ad004688b05d58cca512848ecc 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 require_once ('moodleform_mod.php');
 
-class exercise_mod_form extends moodleform_mod {
+class mod_exercise_mod_form extends moodleform_mod {
 
        function definition() {
 
index 58576ecc631068eb872b88ca63031f2f8c685fdf..e5e1a9b31c7b8c48ad6fc2e8374c0e26372f6aec 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 require_once ('moodleform_mod.php');
 
-class forum_mod_form extends moodleform_mod {
+class mod_forum_mod_form extends moodleform_mod {
 
        function definition() {
 
index a578aefa04c5a780e500d18bdb04aeeaeb3b60db..3adb2b38a9632d2a908f9ff7f41a8585d20a3e2d 100644 (file)
@@ -2,7 +2,7 @@
 
 require_once($CFG->libdir.'/formslib.php');
 
-class forum_post_form extends moodleform {
+class mod_forum_post_form extends moodleform {
 
        function definition() {
 
index b1667d6e245008f938d635eaf4231b58cdf80c3d..a72674084b4f36a290496a181df9cde7206776e4 100644 (file)
@@ -2,7 +2,7 @@
 
 require_once $CFG->libdir.'/formslib.php';
 
-class glossary_comment_form extends moodleform {
+class mod_glossary_comment_form extends moodleform {
     function definition() {
         $mform =& $this->_form;
 
index d803c3d4856bbc94436de3a0eaed552cc366bcfb..a40703090e37509950ab140ff2c3f380dbc44cda 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 require_once ($CFG->dirroot.'/lib/formslib.php');
 
-class glossary_entry_form extends moodleform {
+class mod_glossary_entry_form extends moodleform {
 
        function definition() {
 
index 32a6f52243b884818b3560fa8bfb903bfab6e5ea..52ea260a229af300f4a175936d88614db40c54d3 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 require_once ('moodleform_mod.php');
 
-class glossary_mod_form extends moodleform_mod {
+class mod_glossary_mod_form extends moodleform_mod {
 
        function definition() {
 
index d8ab781c365797b67d95027b3aae62f6876a78bb..d1d02feb37bd561928492801218fbad76c0129e3 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 require_once ('moodleform_mod.php');
 
-class journal_mod_form extends moodleform_mod {
+class mod_journal_mod_form extends moodleform_mod {
 
        function definition() {
 
index 350d1801149c6045290f536c18345601a9995e65..226df4efd6cd1340d058393d51fb0f01c5ea5630 100644 (file)
@@ -1,7 +1,7 @@
 <?php // $Id$
 require_once ('moodleform_mod.php');
 
-class label_mod_form extends moodleform_mod {
+class mod_label_mod_form extends moodleform_mod {
 
        function definition() {
 
index f2c9807072425266369fe4a2779261cbba1c6dd4..cfc2fb71928a290cdd0a48003c6691bb231f5f48 100644 (file)
@@ -10,7 +10,7 @@
 require_once ('moodleform_mod.php');
 
 require_once('locallib.php');
-class lesson_mod_form extends moodleform_mod {
+class mod_lesson_mod_form extends moodleform_mod {
 
        function definition() {
 
index f5f3c27da8a2185f10c6f74718565c0c77321412..882fe0efcf0981c2077f1073df0fc47f9a6a4012 100644 (file)
@@ -646,8 +646,6 @@ function quiz_after_add_or_update($quiz) {
         }
     }
 
-    // Remember whether this user likes the advanced settings visible or hidden.
-    set_user_preference('quiz_optionsettingspref', $quiz->mform_showadvanced_last);
 
     // Update the events relating to this quiz.
     // This is slightly inefficient, deleting the old events and creating new ones. However,
index fd1374537b81e59c66c9d6d6239897452440f80d..172c8c7711b265b1165f3c13b50bb82a5147de8d 100644 (file)
@@ -3,7 +3,7 @@ require_once ('moodleform_mod.php');
 
 require_once("$CFG->dirroot/mod/quiz/locallib.php");
 
-class quiz_mod_form extends moodleform_mod {
+class mod_quiz_mod_form extends moodleform_mod {
     var $_feedbacks;
 
        function definition() {
@@ -11,7 +11,6 @@ class quiz_mod_form extends moodleform_mod {
                global $COURSE, $CFG, $QUIZ_GRADE_METHOD;
                $mform    =& $this->_form;
 
-               $mform->setShowAdvanced(get_user_preferences('quiz_optionsettingspref', 0));
 //-------------------------------------------------------------------------------
         $mform->addElement('header', 'general', get_string('general', 'form'));
 
index 4e4630d7554261ba77b405be6b24cb92ab122a5a..43289e076560986dcea4ce837459746270155873 100644 (file)
@@ -2,7 +2,7 @@
 
     require_once("../../config.php");
     include_once $CFG->libdir.'/formslib.php';
-    class survey_details_form extends moodleform {
+    class mod_survey_details_form extends moodleform {
 
         function definition() {
             $mform    =& $this->_form;