Example #1
0
    $mail_oggetto = "Hai finanziato un'idea!";
    $title = "Hai finanziato l'idea {$idea['Idea']['nome']}";
    $body = "Complimenti! Hai finanziato l'idea {$idea['Idea']['nome']}! Mettiti in contatto con l'ideatore tramite l'email: {$userIdea['email']}";
    sendMail($mail_destinatario, $mail_oggetto, $title, $body);
    $text = "Hai finanziato la idea {$idea['Idea']['nome']}";
    insertNotice($mail_destinatario, $idIdea, $text, "Financier", 0);
    /* ideatore */
    $mail_destinatario = "{$userIdea['email']}";
    $mail_oggetto = "Hai ottenuto un finanziamento per una tua idea!";
    $title = "Hai ottenuto un finanziamento per l'idea {$idea['Idea']['nome']}";
    $body = "Complimenti! Hai ottenuto un finanziamento per l'idea {$idea['Idea']['nome']}! Mettiti in contatto con il finanziatore tramite l'email: {$userFinancier['User']['email']}";
    sendMail($mail_destinatario, $mail_oggetto, $title, $body);
    $text = "Idea {$idea['Idea']['nome']} finanziata!";
    insertNotice($mail_destinatario, $idIdea, $text, "Financier");
    /* followers */
    $followers = getFollowersByIdIdea($idIdea);
    foreach ($followers as $follower) {
        if ($follower['idUser'] != $idFinancier) {
            $mail_destinatario = "{$follower['idUser']}";
            $mail_oggetto = "Un'idea che stai seguendo ha ottenuto un finanziamento!";
            $title = "L'idea {$idea['Idea']['nome']} ha ottenuto un finanziamento!";
            $body = "L'idea {$idea['Idea']['nome']} ha ottenuto un finanziamento!";
            $text = "La idea {$idea['Idea']['nome']} ha un finanziatore!";
            insertNotice($mail_destinatario, $idIdea, $text, "Financier");
            sendMail($mail_destinatario, $mail_oggetto, $title, $body);
        }
    }
    echo "Hai finanziato l'idea con successo!";
} else {
    echo "Ci sono problemi nel database. Ci scusiamo per il disagio";
}
Example #2
0
<?php

/** 
 * @author Amedeo Leo
 */
session_start();
require 'manageDB.php';
$idButton = $_POST['idButton'];
$idIdea = $_POST['idIdea'];
$idUser = $_SESSION['email'];
if ($idButton = "followIt") {
    $result = insertFollower($idUser, $idIdea);
    if ($result == NULL) {
        return "Non puoi seguire una tua idea";
    } else {
        $user_follower = getUserById($idUser);
        $nameSurname = $user_follower['User']['name'] . " " . $user_follower['User']['surname'];
        $idea = getIdeaById($idIdea);
        $id_user_idea = $idea['User']['email'];
        $text_idea = $idea['Idea']['nome'];
        $text = "La tua idea " . $text_idea . " ha un nuovo follower: {$nameSurname}.";
        $mail_destinatario = $id_user_idea;
        $mail_oggetto = "La tua idea " . $text_idea . " ha un nuovo follower: {$nameSurname}.";
        $title = "Nuovo follower per la idea " . $text_idea;
        $body = $text;
        sendMail($mail_destinatario, $mail_oggetto, $title, $body);
        $text = "La tua idea " . $text_idea . " ha un nuovo follower!";
        insertNotice($id_user_idea, $idIdea, $text, "Follower");
        echo "<button type='button' onClick='notFollowIt();' id='notFollowIt' class='btn btn-default btn-lg' style='background: red'><span class='glyphicon glyphicon-remove' aria-hidden='true' ></span> Unfollow</button>";
    }
}
Example #3
0
        $body = "L'idea {$idea['Idea']['nome']} ha un nuovo commento: [{$nameSurname}]: {$content}";
        $alreadySent[] = $follower['idUser'];
        $text_idea = $idea['Idea']['nome'];
        $text = "La idea " . $text_idea . " che stai seguendo ha un nuovo commento:[" . $nameSurname . "]: " . $content;
        /* togliere i commenti! invia la mail! */
        //sendMail($mail_destinatario, $mail_oggetto, $title, $body);
        insertNotice($follower['idUser'], $idIdea, $text, "Comment");
    }
}
$writers = getWritersOfIdea($idIdea);
foreach ($writers as $writer) {
    if ($writer != $idUser) {
        if (!in_array($writer, $alreadySent)) {
            $text_idea = $idea['Idea']['nome'];
            $text = "La idea " . $text_idea . " che hai commentato ha un nuovo commento:[" . $nameSurname . "]: " . $content;
            insertNotice($writer, $idIdea, $text, "Comment");
        }
    }
}
function getScore($comment)
{
    require __DIR__ . '/vendor/autoload.php';
    require_once __DIR__ . '/libs/sentimentAnalysis/autoload.php';
    //Translate first
    $tr = new TranslateClient();
    // Default is from 'auto' to 'en'
    //$tr->setSource('it');
    //$tr->setTarget('en');
    $comment = $tr->translate($comment);
    //Calculate sentiment
    $sentiment = new \PHPInsight\Sentiment();