Example #1
0
function do_ignore($string)
{
    global $db, $current_user;
    require_once mnminclude . 'user.php';
    $array = preg_split('/\\s+/', $string);
    if (count($array) >= 2) {
        $user_login = $db->escape($array[1]);
        $user_id = $db->get_var("select user_id from users where user_login='******'");
        if ($user_id > 0 && $user_id != $current_user->user_id) {
            friend_insert($current_user->user_id, $user_id, -1);
            $comment = _('Usuario') . ' <em>' . htmlentities($array[1]) . '</em> ' . _('agregado a la lista de ignorados');
        }
    } else {
        $users = $db->get_col("select user_login from users, friends where friend_type='manual' and friend_from={$current_user->user_id} and friend_value < 0 and user_id = friend_to order by user_login asc");
        $comment = '<strong>' . _('Usuarios ignorados') . '</strong>: ';
        if ($users) {
            foreach ($users as $user) {
                $comment .= $user . ' ';
            }
        }
    }
    return $comment;
}
Example #2
0
function friend_add_delete($from, $to)
{
    if ($from == $to) {
        return '';
    }
    switch (friend_exists($from, $to)) {
        case 0:
            friend_insert($from, $to);
            return FRIEND_YES;
        case 1:
            friend_insert($from, $to, -1);
            return FRIEND_IGNORE;
        case -1:
            friend_delete($from, $to);
            return FRIEND_NO;
    }
}