示例#1
0
function build_alpha_pages()
{
    global $alphabet;
    $query = "select userid from profile";
    $result = mysql_query($query);
    $numIds = 0;
    while ($profile = mysql_fetch_object($result)) {
        $user = lookup_user_id($profile->userid);
        if (!$user) {
            continue;
        }
        if ($user->name) {
            $name = ltrim($user->name);
            $members[strtoupper($name[0])][] = $user->id;
            $numIds++;
        }
    }
    mysql_free_result($result);
    //echo "$numIds users have profiles AND non-null country entries.<br>";
    $letters = array_keys($members);
    foreach ($letters as $letter) {
        // NOTE: Array indexing is case sensitive.
        $filePath = PROFILE_PATH;
        if (in_array($letter, $alphabet)) {
            build_profile_pages($members[$letter], "User Profiles - Names beginning with {$letter}", "Names beginning with {$letter}", 5, 2, $filePath, "profile_{$letter}");
        } else {
            build_profile_pages($members[$letter], "User Profiles - Names beginning with other characters", "Names beginning with other characters", 5, 2, $filePath, "profile_other");
        }
        $letters_used[$letter] = 1;
    }
    build_alpha_summary_page($letters_used);
}
function build_alpha_pages()
{
    print_debug_msg("Beginning to build alphabetical pages...");
    global $alphabet;
    $profiles = BoincProfile::enum_fields('userid');
    $numIds = 0;
    $members = array();
    foreach ($profiles as $profile) {
        $user = BoincUser::lookup_id($profile->userid);
        if (!$user) {
            continue;
        }
        // maybe we should delete the profile if user is non-existent anymore?
        if ($user->name) {
            $name = ltrim($user->name);
            $members[strtoupper($name[0])][] = $user->id;
            $numIds++;
        }
    }
    print_debug_msg("{$numIds} users have profiles AND names.");
    $letters = array_keys($members);
    foreach ($letters as $letter) {
        // NOTE: Array indexing is case sensitive.
        $filePath = PROFILE_PATH;
        if (in_array($letter, $alphabet)) {
            build_profile_pages($members[$letter], "User Profiles - Names beginning with {$letter}", "Names beginning with {$letter}", 5, 2, $filePath, "profile_{$letter}");
        } else {
            build_profile_pages($members[$letter], "User Profiles - Names beginning with other characters", "Names beginning with other characters", 5, 2, $filePath, "profile_other");
        }
        $letters_used[$letter] = 1;
    }
    build_alpha_summary_page($letters_used);
    print_debug_msg("done building alphabetical pages");
}