}
if ($userHasWall) {
    $objWall = $wallResult->fetch_object();
    $privacidad = $objWall->privacidad;
    $idMuro = $objWall->id_muro;
    $anonimoLectura = $objWall->flag_anonimo_lectura;
    $anonimoEscritura = $objWall->flag_anonimo_escritura;
    $limiteMuro = $objWall->limite_muro;
    $objLimit = $MessageLimitResult->fetch_object();
    $limitPrivateMsg = $objLimit->limite;
    //limite de mensaje de la bandeja de entrada $limiteMensajePri
    $IdBandeja = $objLimit->id_bandeja;
    $totalPrivateMsg = $MessageNumResult;
    //cantidad de mensajes en bandeja de entrada
    $wall = new Wall();
    $messages = $wall->getMessages($limiteMuro, $idUsuario);
    if ($messages != null) {
        foreach ($messages as $obj) {
            $mensajes[] = $obj->contenido;
            $nombre = $obj->nombre;
            $apellido = $obj->apellido;
            $rows[] = $obj;
        }
    }
    if (isset($_SESSION["id"])) {
        $results = $wall->isInWhiteList($idMuro, $_SESSION["id"]);
        if ($results->num_rows > 0) {
            $userAllow = true;
        } else {
            $userAllow = false;
        }
$mysession->initSession();
$content = $_POST["content"];
$toWall = $_POST["toWall"];
$patron = "/^[[:digit:]]+\$/";
if (isset($_SESSION['id']) and preg_match($patron, $_SESSION['id'])) {
    $fromUser = $_SESSION['id'];
} else {
    //El id 1 pertenece al usuario anonimo
    $fromUser = 1;
}
if (isset($_POST["toUser"]) and preg_match($patron, $_POST["toUser"])) {
    $toUser = $_POST["toUser"];
} else {
    header('location:index.php?error=4');
    exit;
}
echo "string";
$wallRepo = new WallRepositoryService();
$wallResult = $wallRepo->getWallByUserId($toUser);
if ($row = $wallResult->fetch_object()) {
    $wall = new Wall();
    $messages = $wall->getMessages($row->limite_muro, $toUser);
    if (count($messages) < $row->limite_muro) {
        $cbcCipher = new CbcCipher($content);
        $content = $cbcCipher->encrypt();
        $message = new Message($content, $toWall, $fromUser);
        header('location: ../../index.php?usuario=' . $toUser);
    } else {
        header('location: ../../index.php?usuario=' . $toUser . '&alert');
    }
}