Esempio n. 1
0
function user_get_relationships($uid, $page = 1)
{
    if (!($db = db::get())) {
        return false;
    }
    $user_get_peers_array = array();
    if (!is_numeric($uid)) {
        return false;
    }
    if (!is_numeric($page) || $page < 1) {
        $page = 1;
    }
    $offset = calculate_page_offset($page, 10);
    if (!($table_prefix = get_table_prefix())) {
        return false;
    }
    $sql = "SELECT SQL_CALC_FOUND_ROWS USER.UID, USER.LOGON, USER.NICKNAME, ";
    $sql .= "USER_PEER.PEER_NICKNAME, USER_PEER.RELATIONSHIP, USER_PEER.PEER_NICKNAME ";
    $sql .= "FROM `{$table_prefix}USER_PEER` USER_PEER ";
    $sql .= "LEFT JOIN USER USER ON (USER.UID = USER_PEER.PEER_UID) ";
    $sql .= "WHERE USER_PEER.UID = '{$uid}' AND USER.UID IS NOT NULL ";
    $sql .= "LIMIT {$offset}, 10";
    if (!($result = $db->query($sql))) {
        return false;
    }
    $sql = "SELECT FOUND_ROWS() AS ROW_COUNT";
    if (!($result_count = $db->query($sql))) {
        return false;
    }
    list($user_get_peers_count) = $result_count->fetch_row();
    if ($result->num_rows == 0 && $user_get_peers_count > 0 && $page > 1) {
        return user_get_relationships($uid, $page - 1);
    }
    while (($user_data = $result->fetch_assoc()) !== null) {
        if (isset($user_data['LOGON']) && isset($user_data['PEER_NICKNAME'])) {
            if (!is_null($user_data['PEER_NICKNAME']) && strlen($user_data['PEER_NICKNAME']) > 0) {
                $user_data['NICKNAME'] = $user_data['PEER_NICKNAME'];
            }
        }
        if (!isset($user_data['LOGON'])) {
            $user_data['LOGON'] = gettext("Unknown user");
        }
        if (!isset($user_data['NICKNAME'])) {
            $user_data['NICKNAME'] = "";
        }
        $user_get_peers_array[$user_data['UID']] = $user_data;
    }
    return array('user_count' => $user_get_peers_count, 'user_array' => $user_get_peers_array);
}
Esempio n. 2
0
                    $error_msg_array[] = gettext("Failed to remove selected relationship");
                }
            }
        }
        if ($valid) {
            $redirect = "edit_relations.php?webtag={$webtag}&relupdated=true";
            header_redirect($redirect, gettext("Relationships Updated!"));
            exit;
        }
    }
}
// Check if we're searching for a user or simply listing the existing relationships.
if (isset($search_keyword) && strlen(trim($search_keyword)) > 0) {
    $user_peers_array = user_search_relationships($search_keyword, $page, $uid);
} else {
    $user_peers_array = user_get_relationships($uid, $page);
}
// Output any messages.
if (isset($error_msg_array) && sizeof($error_msg_array) > 0) {
    html_display_error_array($error_msg_array, '600', 'left');
} else {
    if (isset($_GET['relupdated'])) {
        html_display_success_msg(gettext("Relationships Updated!"), '600', 'left');
    } else {
        if (sizeof($user_peers_array['user_array']) < 1) {
            if (isset($search_keyword) && strlen(trim($search_keyword)) > 0) {
                html_display_warning_msg(gettext("Search Returned No Results"), '600', 'left');
            } else {
                html_display_warning_msg(gettext("You have no user relationships set up. Add a new user by searching below."), '600', 'left');
            }
        }
Esempio n. 3
0
                    $valid = false;
                    $error_msg_array[] = gettext("Failed to remove selected relationship");
                }
            }
        }
        if ($valid) {
            header_redirect($redirect = "edit_relations.php?webtag={$webtag}&relupdated=true");
            exit;
        }
    }
}
// Check if we're searching for a user or simply listing the existing relationships.
if (isset($search_keyword) && strlen(trim($search_keyword)) > 0) {
    $user_peers_array = user_search_relationships($search_keyword, $page, $_SESSION['UID']);
} else {
    $user_peers_array = user_get_relationships($_SESSION['UID'], $page);
}
// Output any messages.
if (isset($error_msg_array) && sizeof($error_msg_array) > 0) {
    html_display_error_array($error_msg_array, '700', 'left');
} else {
    if (isset($_GET['relupdated'])) {
        html_display_success_msg(gettext("Relationships Updated!"), '700', 'left');
    } else {
        if (sizeof($user_peers_array['user_array']) < 1) {
            if (isset($search_keyword) && strlen(trim($search_keyword)) > 0) {
                html_display_warning_msg(gettext("Search Returned No Results"), '700', 'left');
            } else {
                html_display_warning_msg(gettext("You have no user relationships set up. Add a new user by searching below."), '700', 'left');
            }
        }