~ubuntu-branches/ubuntu/maverick/mahara/maverick-updates

« back to all changes in this revision

Viewing changes to htdocs/admin/users/uploadcsv.php

  • Committer: Bazaar Package Importer
  • Author(s): Francois Marier
  • Date: 2008-09-29 13:00:12 UTC
  • mfrom: (1.1.3 upstream)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: james.westby@ubuntu.com-20080929130012-7swv3jiomgpsm4b8
Tags: 1.0.5-1
* New Upstream Version
* Fix comments in maintainer scripts (closes: #491924)
* Add lintian override for embedded copies of mochikit
* Bump debhelper compatibility to 7 to use dh_lintian

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
    }
80
80
}
81
81
 
82
 
if (count($authinstances) > 1) {
 
82
if (count($authinstances) > 0) {
83
83
    $options = array();
84
84
 
85
85
    foreach ($authinstances as $authinstance) {
97
97
        'defaultvalue' => $default
98
98
    );
99
99
}
100
 
else {
101
 
    foreach ($authinstances as $authinstance) {
102
 
        $string = $authinstance->id .'_'. $authinstance->name;
103
 
    }
104
 
 
105
 
    $authinstanceelement = array(
106
 
        'type' => 'hidden',
107
 
        'value' => $string
108
 
    );
109
 
}
110
100
 
111
101
$form = array(
112
102
    'name' => 'uploadcsv',
172
162
        return;
173
163
    }
174
164
 
 
165
    $usernames = array();
 
166
    $emails = array();
175
167
    $conf = File_CSV::discoverFormat($values['file']['tmp_name']);
176
168
    $i = 0;
177
169
    while ($line = File_CSV::readQuoted($values['file']['tmp_name'], $conf)) {
233
225
                $form->set_error('file', get_string('uploadcsverrorinvalidusername', 'admin', $i));
234
226
                return;
235
227
            }
236
 
            if (record_exists_select('usr', 'LOWER(username) = ?', strtolower($username))) {
 
228
            if (record_exists_select('usr', 'LOWER(username) = ?', strtolower($username)) || isset($usernames[strtolower($username)])) {
237
229
                $form->set_error('file', get_string('uploadcsverroruseralreadyexists', 'admin', $i, $username));
238
230
                return;
239
231
            }
240
 
            if (record_exists('usr', 'email', $email)) {
 
232
            if (record_exists('usr', 'email', $email) || isset($emails[$email])) {
241
233
                $form->set_error('file', get_string('uploadcsverroremailaddresstaken', 'admin', $i, $email));
242
234
            }
243
235
 
249
241
                return;
250
242
            }
251
243
 
 
244
            $usernames[strtolower($username)] = 1;
 
245
            $emails[$email] = 1;
 
246
 
252
247
            // All OK!
253
248
            $CSVDATA[] = $line;
254
249
        }