/**
 * Deletes a user without any check or warning
 *
 * @param int $id userid
 * @param string $condition php condition string on $user e.g. "return (\$user->block == 1);"
 * @param string $inComprofilerOnly deletes user only in CB, not in Mambo/Joomla
 * @return mixed : "" if user deleted and found ok, null if user not found, false if condition was not met, string error in case of error raised by plugin
 */
function cbDeleteUser($id, $condition = null, $inComprofilerOnly = false)
{
    global $_CB_framework, $_CB_database, $_PLUGINS;
    $msg = null;
    $obj2 = new moscomprofiler($_CB_database);
    $query = "SELECT * FROM #__comprofiler c LEFT JOIN #__users u ON c.id = u.id WHERE c.id = " . (int) $id;
    $_CB_database->setQuery($query);
    $user = $_CB_database->loadObjectList();
    if ($_CB_database->getErrorNum() || count($user) == 0) {
        $query = "SELECT * FROM #__users u LEFT JOIN #__comprofiler c ON c.id = u.id WHERE u.id = " . (int) $id;
        $_CB_database->setQuery($query);
        $user = $_CB_database->loadObjectList();
    }
    if (!$_CB_database->getErrorNum() && count($user) > 0) {
        $user = $user[0];
        if ($condition == null || eval($condition)) {
            $_PLUGINS->loadPluginGroup('user');
            $_PLUGINS->trigger('onBeforeDeleteUser', array($user));
            if ($_PLUGINS->is_errors()) {
                $msg = $_PLUGINS->getErrorMSG();
            } else {
                deleteAvatar($user->avatar);
                $reports = new moscomprofilerUserReport($_CB_database);
                $reports->deleteUserReports($user->id);
                _cbdeleteUserViews($user->id);
                if (!$inComprofilerOnly) {
                    $obj =& $_CB_framework->_getCmsUserObject($id);
                    $obj->delete($id);
                    $msg .= $obj->getError();
                }
                $obj2->delete($id);
                $msg .= $obj2->getError();
                // delete user acounts active sessions
                $query = "DELETE FROM #__session" . "\n WHERE userid = " . (int) $id;
                $_CB_database->setQuery($query);
                $_CB_database->query();
                $_PLUGINS->trigger('onAfterDeleteUser', array($user, true));
            }
        } else {
            $msg = false;
        }
    }
    return $msg;
}