コード例 #1
0
ファイル: mysql.php プロジェクト: sheldon/dejavu
/**
 * Add a buddy for a user.
 *
 * @param integer $buddy_user_id
 *     The user_id that has to be added as a buddy.
 *
 * @param mixed $user_id
 *     The user_id the buddy has to be added for
 *     or NULL to use the active Phorum user (default).
 *
 * @return mixed
 *     The id that was assigned to the new buddy or the existing id if
 *     the buddy already existed. If no user can be found for the
 *     $buddy_user_id parameter, then NULL will be returned.
 */
function phorum_db_pm_buddy_add($buddy_user_id, $user_id = NULL)
{
    $PHORUM = $GLOBALS['PHORUM'];
    settype($buddy_user_id, 'int');
    if ($user_id === NULL) {
        $user_id = $PHORUM['user']['user_id'];
    }
    settype($user_id, 'int');
    // Check if the buddy_user_id is a valid user_id.
    $valid = phorum_db_user_get($buddy_user_id, FALSE);
    if (!$valid) {
        return NULL;
    }
    // See if the user is already a buddy.
    $pm_buddy_id = phorum_db_pm_is_buddy($buddy_user_id);
    // If not, then create insert a new buddy relation.
    if ($pm_buddy_id === NULL) {
        $pm_buddy_id = phorum_db_interact(DB_RETURN_NEWID, "INSERT INTO {$PHORUM['pm_buddies_table']}\n                    (user_id, buddy_user_id)\n             VALUES ({$user_id}, {$buddy_user_id})", NULL, DB_MASTERQUERY);
    }
    return $pm_buddy_id;
}
コード例 #2
0
ファイル: postgresql.php プロジェクト: nistormihai/Newscoop
/**
 * This function adds a buddy for a user. It will return the
 * pm_buddy_id for the new buddy. If the buddy already exists,
 * it will return the existing pm_buddy_id. If a non existant
 * user_id is used for the buddy_user_id, the function will
 * return NULL.
 * @param buddy_user_id - The user_id that has to be added as a buddy.
 * @param user_id - The user_id the buddy has to be added for or
 *                  NULL to use the current user (default).
 */
function phorum_db_pm_buddy_add($buddy_user_id, $user_id = NULL)
{
    $PHORUM = $GLOBALS['PHORUM'];
    $conn = phorum_db_postgresql_connect();
    settype($buddyuser_id, "int");
    if (is_null($user_id)) $user_id = $PHORUM["user"]["user_id"];
    settype($user_id, "int");

    // Check if the buddy_user_id is a valid user_id.
    $valid = phorum_db_user_get($buddy_user_id, false);
    if (!$valid) return NULL;

    $pm_buddy_id = phorum_db_pm_is_buddy($buddy_user_id);
    if (is_null($pm_buddy_id)) {
        $sql = "INSERT INTO {$PHORUM["pm_buddies_table"]} (user_id, buddy_user_id) " .
               "values($user_id, $buddy_user_id)";
        $res = pg_query($conn, $sql);
        if ($err = pg_last_error()) phorum_db_pg_last_error("$err: $sql");
        $pm_buddy_id = pgsql_insert_id($conn, "{$PHORUM["pm_buddies_table"]}_pm_buddy_id_seq");
    }

    return $pm_buddy_id;
}
コード例 #3
0
ファイル: profile.php プロジェクト: sleepy909/cpassman
$PHORUM["DATA"]["PROFILE"]["date_added"] = phorum_date($PHORUM['short_date_time'], $PHORUM["DATA"]["PROFILE"]["date_added"]);
if (empty($PHORUM['hide_email_addr']) && !$user['hide_email'] || !empty($PHORUM["user"]["admin"]) || phorum_api_user_check_access(PHORUM_USER_ALLOW_MODERATE_MESSAGES) && PHORUM_MOD_EMAIL_VIEW || phorum_api_user_check_access(PHORUM_USER_ALLOW_MODERATE_USERS) && PHORUM_MOD_EMAIL_VIEW) {
    $PHORUM["DATA"]["PROFILE"]["email"] = phorum_html_encode($user["email"]);
} else {
    $PHORUM["DATA"]["PROFILE"]["email"] = $PHORUM["DATA"]["LANG"]["Hidden"];
}
if ($PHORUM["track_user_activity"] && (!empty($PHORUM["user"]["admin"]) || phorum_api_user_check_access(PHORUM_USER_ALLOW_MODERATE_MESSAGES) || phorum_api_user_check_access(PHORUM_USER_ALLOW_MODERATE_USERS) || !$user["hide_activity"])) {
    $PHORUM["DATA"]["PROFILE"]["raw_date_last_active"] = $PHORUM["DATA"]["PROFILE"]["date_last_active"];
    $PHORUM["DATA"]["PROFILE"]["date_last_active"] = phorum_date($PHORUM['short_date_time'], $PHORUM["DATA"]["PROFILE"]["date_last_active"]);
} else {
    unset($PHORUM["DATA"]["PROFILE"]["date_last_active"]);
}
$PHORUM["DATA"]["PROFILE"]["posts"] = number_format($PHORUM["DATA"]["PROFILE"]["posts"], 0, "", $PHORUM["thous_sep"]);
$PHORUM["DATA"]["PROFILE"]["URL"]["PM"] = phorum_get_url(PHORUM_PM_URL, "page=send", "to_id=" . urlencode($user["user_id"]));
$PHORUM["DATA"]["PROFILE"]["URL"]["ADD_BUDDY"] = phorum_get_url(PHORUM_PM_URL, "page=buddies", "action=addbuddy", "addbuddy_id=" . urlencode($user["user_id"]));
$PHORUM["DATA"]["PROFILE"]["is_buddy"] = phorum_db_pm_is_buddy($user["user_id"]);
// unset($PHORUM["DATA"]["PROFILE"]["signature"]);
$PHORUM["DATA"]["PROFILE"]["URL"]["SEARCH"] = phorum_get_url(PHORUM_SEARCH_URL, "author=" . urlencode($PHORUM["DATA"]["PROFILE"]["user_id"]), "match_type=USER_ID", "match_dates=0", "match_threads=0");
$PHORUM["DATA"]["PROFILE"]["username"] = htmlspecialchars($PHORUM["DATA"]["PROFILE"]["username"], ENT_COMPAT, $PHORUM["DATA"]["HCHARSET"]);
if (isset($PHORUM["DATA"]["PROFILE"]["real_name"])) {
    $PHORUM["DATA"]["PROFILE"]["real_name"] = htmlspecialchars($PHORUM["DATA"]["PROFILE"]["real_name"], ENT_COMPAT, $PHORUM["DATA"]["HCHARSET"]);
}
if (empty($PHORUM["custom_display_name"])) {
    $PHORUM["DATA"]["PROFILE"]["display_name"] = htmlspecialchars($PHORUM["DATA"]["PROFILE"]["display_name"], ENT_COMPAT, $PHORUM["DATA"]["HCHARSET"]);
}
if (isset($PHORUM["hooks"]["profile"])) {
    $PHORUM["DATA"]["PROFILE"] = phorum_hook("profile", $PHORUM["DATA"]["PROFILE"]);
}
$PHORUM["DATA"]["HEADING"] = $PHORUM["DATA"]["LANG"]["UserProfile"];
$PHORUM["DATA"]["DESCRIPTION"] = "";
$PHORUM['DATA']['HTML_DESCRIPTION'] = '';
コード例 #4
0
ファイル: mysql.php プロジェクト: nistormihai/Newscoop
/**
 * Add a buddy for a user. It will return the
 * pm_buddy_id for the new buddy. If the buddy already exists,
 * it will return the existing pm_buddy_id. If a non-existant
 * user_id is used for the buddy_user_id, the function will
 * return NULL.
 *
 * @param int $buddy_user_id - The user_id that has to be added as a buddy.
 * @param int $user_id - The user_id the buddy has to be added for or
 *                  NULL to use the current user (default).
 *
 * @return mixed
 */
function phorum_db_pm_buddy_add($buddy_user_id, $user_id = NULL)
{
    $PHORUM = $GLOBALS['PHORUM'];
    $conn = phorum_db_mysql_connect();
    settype($buddyuser_id, "int");
    if (is_null($user_id)) $user_id = $PHORUM["user"]["user_id"];
    settype($user_id, "int");

    // Check if the buddy_user_id is a valid user_id.
    $valid = phorum_db_user_get($buddy_user_id, false);
    if (! $valid) return NULL;

    $pm_buddy_id = phorum_db_pm_is_buddy($buddy_user_id);
    if (is_null($pm_buddy_id)) {
        $sql = "INSERT INTO {$PHORUM["pm_buddies_table"]} SET " .
               "user_id = $user_id, " .
               "buddy_user_id = $buddy_user_id";
        $res = mysql_query($sql, $conn);
        if ($err = mysql_error()) phorum_db_mysql_error("$err: $sql");
        $pm_buddy_id = mysql_insert_id($conn);
    }

    return $pm_buddy_id;
}