Exemplo n.º 1
0
function run_import_users($task, $args)
{
    if (!isset($args[0])) {
        pake_echo_error('usage: pake i "users.yml"');
        return false;
    }
    pake_echo_comment("Reading file. It can take awhile…");
    $str = file_get_contents($args[0]);
    $data = pakeYaml::loadString($str);
    pake_echo_comment("Starting import…");
    $len = count($data);
    for ($i = 0; $i < $len; $i++) {
        $row = $data[$i];
        if (_create_user($row['login'], $row['password'], $row['data'])) {
            pake_echo_action('user+', "({$i} of {$len}) " . $row['login']);
        } else {
            pake_echo_comment('already exists: ' . "({$i} of {$len}) " . $row['login']);
        }
    }
}