~ubuntu-branches/ubuntu/natty/moodle/natty

« back to all changes in this revision

Viewing changes to user/profile/index_category_form.php

  • Committer: Bazaar Package Importer
  • Author(s): Tomasz Muras
  • Date: 2010-10-30 12:19:28 UTC
  • mfrom: (1.1.12 upstream) (3.1.10 squeeze)
  • Revision ID: james.westby@ubuntu.com-20101030121928-qzobi6mctpnk4dif
Tags: 1.9.9.dfsg2-2
* Added Romanian translation
* Updated Japanese translation (closes: #596820)
* Backporting security fixes from Moodle 1.9.10 (closes: #601384)
   - Updated embedded CAS to 1.1.3
   - Added patch for MDL-24523:
     clean_text() not filtering text in markdown format
   - Added patch for MDL-24810 and upgraded customized HTML Purifier to 4.2.0 
   - Added patch for MDL-24258:
     students can delete their forum posts later than $CFG->maxeditingtime 
     under certain conditions
   - Added patch for MDL-23377:
     Can't delete quiz attempts in course without enrolled students

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php //$Id: index_category_form.php,v 1.3.4.1 2007/11/23 22:12:36 skodak Exp $
 
1
<?php //$Id: index_category_form.php,v 1.3.4.4 2009/11/04 12:16:18 jmg324 Exp $
2
2
 
3
3
require_once($CFG->dirroot.'/lib/formslib.php');
4
4
 
14
14
 
15
15
        /// Add some extra hidden fields
16
16
        $mform->addElement('hidden', 'id');
 
17
        $mform->setType('id', PARAM_INT);
17
18
        $mform->addElement('hidden', 'action', 'editcategory');
 
19
        $mform->setType('action', PARAM_ACTION);
18
20
 
19
21
        $mform->addElement('text', 'name', get_string('profilecategoryname', 'admin'), 'maxlength="255" size="30"');
20
22
        $mform->setType('name', PARAM_MULTILANG);
31
33
 
32
34
        $data  = (object)$data;
33
35
 
34
 
        $category = get_record('user_info_category', 'id', $data->id);
 
36
        $duplicate = record_exists('user_info_category', 'name', $data->name);
35
37
 
36
38
        /// Check the name is unique
37
 
        if ($category and ($category->name !== $data->name) and (record_exists('user_info_category', 'name', $data->name))) {
 
39
        if (!empty($data->id)) { // we are editing an existing record
 
40
            $olddata = get_record('user_info_category', 'id', $data->id);
 
41
            // name has changed, new name in use, new name in use by another record
 
42
            $dupfound = (($olddata->name !== $data->name) && $duplicate && ($data->id != $duplicate->id));
 
43
        }
 
44
        else { // new profile category
 
45
            $dupfound = $duplicate;
 
46
        }
 
47
        
 
48
        if ($dupfound ) {
38
49
            $errors['name'] = get_string('profilecategorynamenotunique', 'admin');
39
50
        }
40
51