Exemplo n.º 1
0
function webservices_account_unban($uid)
{
    if ($parent_uid = user_banned_remove($uid)) {
        $json['status'] = 'OK';
        $json['error'] = '0';
    } else {
        $json['status'] = 'ERR';
        $json['error'] = '614';
    }
    return $json;
}
Exemplo n.º 2
0
     $del_uid = user_username2uid($up['username']);
     // users cannot be removed if they still have subusers
     $subusers = user_getsubuserbyuid($del_uid);
     if (count($subusers) > 0) {
         $ret['error_string'] = _('Unable to delete this user until all subusers under this user have been removed');
     } else {
         $ret = user_remove($del_uid);
     }
     $_SESSION['dialog']['info'][] = $ret['error_string'];
     header("Location: " . _u('index.php?app=main&inc=core_user&route=user_mgmnt&op=user_list&view=' . $view));
     exit;
     break;
 case "user_unban":
     $uid = user_username2uid($_REQUEST['uname']);
     if (user_banned_get($uid)) {
         if (user_banned_remove($uid)) {
             $_SESSION['dialog']['info'][] = _('Account has been unbanned') . ' (' . _('username') . ': ' . $_REQUEST['uname'] . ')';
         } else {
             $_SESSION['dialog']['info'][] = _('Unable to unban account') . ' (' . _('username') . ': ' . $_REQUEST['uname'] . ')';
         }
     } else {
         $_SESSION['dialog']['info'][] = _('User is not on banned users list') . ' (' . _('username') . ': ' . $_REQUEST['uname'] . ')';
     }
     header("Location: " . _u('index.php?app=main&inc=core_user&route=user_mgmnt&op=user_list&view=' . $view));
     exit;
     break;
 case "user_ban":
     $uid = user_username2uid($_REQUEST['uname']);
     if ($uid && ($uid == 1 || $uid == $user_config['uid'])) {
         $_SESSION['dialog']['info'][] = _('Account admin or currently logged in administrator cannot be banned');
     } else {
Exemplo n.º 3
0
/**
 * Delete existing user
 *
 * @param integer $uid
 *        User ID
 * @return array $ret('error_string', 'status')
 */
function user_remove($uid, $forced = FALSE)
{
    global $user_config;
    $ret['error_string'] = _('Unknown error has occurred');
    $ret['status'] = FALSE;
    if ($forced || auth_isadmin() || $user_config['status'] == 3) {
        if ($username = user_uid2username($uid)) {
            if (!($uid == 1)) {
                if ($uid == $user_config['uid']) {
                    $ret['error_string'] = _('Currently logged in user is immune to deletion');
                } else {
                    $subusers = user_getsubuserbyuid($uid);
                    if (count($subusers) > 0) {
                        $ret['error_string'] = _('Unable to delete this user until all subusers under this user have been removed');
                        return $ret;
                    }
                    if ($user_config['status'] == 3) {
                        $parent_uid = user_getparentbyuid($uid);
                        if ($parent_uid != $user_config['uid']) {
                            $ret['error_string'] = _('Unable to delete other users');
                            return $ret;
                        }
                    }
                    if (dba_update(_DB_PREF_ . '_tblUser', array('c_timestamp' => mktime(), 'flag_deleted' => 1), array('flag_deleted' => 0, 'uid' => $uid))) {
                        user_banned_remove($uid);
                        _log('user removed u:' . $username . ' uid:' . $uid, 2, 'user_remove');
                        $ret['error_string'] = _('Account has been removed') . " (" . _('username') . ": " . $username . ")";
                        $ret['status'] = TRUE;
                    }
                }
            } else {
                $ret['error_string'] = _('User is immune to deletion') . " (" . _('username') . ": " . $username . ")";
            }
        } else {
            $ret['error_string'] = _('User does not exist');
        }
    } else {
        $ret['error_string'] = _('User deletion unavailable');
    }
    return $ret;
}