$fh_bof = fopen($host_input_file, "r"); while ($a_line = fgetcsv($fh_bof)) { $user = new stdClass(); $user->auth = 'pubcookie'; $user->confirmed = 1; $user->username = $a_line[CCID]; $user->idnumber = $a_line[EMPID]; $user->firstname = $a_line[FIRSTNAME]; $user->lastname = $a_line[LASTNAME]; $user->email = $a_line[CCID] . '@ualberta.ca'; $user->mnethostid = $CFG->mnet_localhost_id; $user->lang = "en"; $user->autosubscribe = 0; $user->trackforums = 1; if (ACONNECT_ENABLED) { $id = connectsync_create_user($user); if (isset($options['hosts'])) { connectsync_add_user_to_host_group($id); } $stat_total_created_moodle_users += 1; } } fclose($fh_bof); } } echo <<<STATS Stats: Created User Count: {$stat_total_created_moodle_users} STATS ;
$logger->setstatus('SUCCESS with some FAILURES'); } else { if (ACONNECT_ENABLED) { if (!empty($options['business_list']) and is_business_user($userinfo[EMPID])) { $usercopy = clone $user; $tmp = $usercopy->username; $usercopy->username = $usercopy->idnumber; $usercopy->idnumber = $tmp; connectsync_create_user($usercopy); } if (!empty($options['business_hosts']) and is_business_host($userinfo[EMPID])) { $usercopy = clone $user; $tmp = $usercopy->username; $usercopy->username = $usercopy->idnumber; $usercopy->idnumber = $tmp; $id = connectsync_create_user($usercopy); connectsync_add_user_to_host_group($id); } } } } catch (Exception $e) { $message = "Caught Exception: " . $e->getMessage(); echo $message; $logger->postmessage($message); $logger->setstatus('SUCCESS with some FAILURES'); } } else { $message = "Create user: "******"\n"; echo $message; } }