Beispiel #1
0
$result = $pdo->query('select username,authenticationMethod,firstname,lastname from users u,people p where p.id=u.person_id');
foreach ($result->fetchAll(PDO::FETCH_ASSOC) as $row) {
    try {
        $person = new Person($row['username']);
    } catch (Exception $e) {
        // print_r($e);
        $person = new Person();
        $person->setUsername($row['username']);
        $person->setAuthenticationMethod($row['authenticationMethod']);
        $person->addRole('Staff');
        if ($row['authenticationMethod'] == 'LDAP') {
            try {
                $ldap = new LDAPEntry($person->getUsername());
                $person->setFirstname($ldap->getFirstname());
                $person->setLastname($ldap->getLastname());
                $person->setEmail($ldap->getEmail());
                // $person->setDepartment($ldap->getDepartment());
            } catch (Exception $e) {
                // print_r($e);
                $person->setEmail($row['username'] . '@bloomington.in.gov');
            }
        } else {
            $person->setFirstname($row['firstname']);
            $person->setLastname($row['lastname']);
        }
        try {
            $person->save();
        } catch (Exception $e) {
            print_r($e);
            print_r($person);
            exit;