コード例 #1
0
ファイル: CifUser.php プロジェクト: CIF-Rochester/Panel
        foreach ($fields as $field) {
            $field_name = $field[1];
            // Check if the value is provided, if not use null
            if (array_key_exists($field[0], $attributes) && $attributes[$field[0]] != null) {
                $value = $attributes[$field[0]];
                $ldap_attributes[$field_name] = $value;
            }
        }
        return $ldap_attributes;
    }
    /**
     * Returns a table of CifUser properties and their associated LDAP field names.
     * The format for the returned array is an array of arrays in the format array(CifUserField, LdapField).
     *
     * The given class should have the following constants defined for LDAP fields:
     * FULL_NAME_FIELD, FIRST_NAME_FIELD, LAST_NAME_FIELD, CIFID_FIELD, STUDENT_ID_FIELD, EMAIL_FIELD,
     * YEAR_FIELD, LOGINSHELL_FIELD, UID_FIELD, BUILDING_FIELD, PHONE_FIELD, LCC_FIELD
     * If any of them are null, they will be ignored.
     *
     * @param string $class The name of the class with constant LDAP field properties defined.
     * @return array An array of arrays as specified above.
     */
    private static function get_fields_table($class)
    {
        // The field names should be exactly the same as this class's public properties
        return array(['full_name', $class::FULL_NAME_FIELD], ['first_name', $class::FIRST_NAME_FIELD], ['last_name', $class::LAST_NAME_FIELD], ['cifid', $class::CIFID_FIELD], ['student_id_hash', $class::STUDENT_ID_FIELD], ['email', $class::EMAIL_FIELD], ['year', $class::YEAR_FIELD], ['loginshell', $class::LOGINSHELL_FIELD], ['building', $class::BUILDING_FIELD], ['phone', $class::PHONE_FIELD], ['lcc', $class::LCC_FIELD], ['password', $class::PASSWORD_FIELD]);
    }
}
// Must be called here to initialize the CIF LDAP connection
CifUser::initialize_connections();