コード例 #1
0
ファイル: Tema.php プロジェクト: einorler/DB-namu-darbai
 /**
  * @return array
  */
 public static function loadAll()
 {
     $dbWrapper = new DatabaseWrapper();
     $connection = $dbWrapper->getConnection();
     $query = "SELECT * FROM temos;";
     $temos = [];
     foreach ($connection->query($query) as $row) {
         $tema = new Tema($connection);
         $tema->setId($row['id']);
         $tema->setDate($row['subject_date']);
         $tema->setName($row['name']);
         $query = 'SELECT * FROM comments INNER JOIN temos ON comments.subjectId = ' . $row['id'] . " AND temos.id = " . $row['id'] . ";";
         $comments = [];
         foreach ($connection->query($query) as $i) {
             $comment = new Comment($connection);
             $comment->setId($i['id']);
             $comment->setsubjectId($i['subjectId']);
             $comment->setText($i['text']);
             $comment->setDate($i['date']);
             $comment->setAuthor($i['author']);
             $comments[] = $comment;
         }
         foreach ($comments as $comment) {
             $tema->setComments($comment);
         }
         $temos[] = $tema;
     }
     return $temos;
 }
コード例 #2
0
ファイル: saveComment.php プロジェクト: laiello/dp-navigator
function saveComment($comment)
{
    $dpComment = new Comment();
    $dpComment->setDp($comment['dp']);
    $dpComment->setComment($comment['comment']);
    $dpComment->setAutor($comment['autor']);
    $dpComment->setDate(time());
    $commentId = $dpComment->saveDpComment();
    return $commentId;
}
コード例 #3
0
 private function makeComment(CommentFO $fo, $type, $typeId)
 {
     $user = Session::get('user');
     $comment = new Comment();
     $comment->setContent($fo->getComment());
     $comment->setType($type);
     $comment->setTypeId($typeId);
     $comment->setDate(null);
     $comment->setUserId($user->getId());
     return $comment;
 }
コード例 #4
0
 public function getAllBySubjectId($subId)
 {
     $query = "SELECT * FROM comments WHERE subjectId = {$subId}";
     $comments = [];
     foreach ($this->connection->query($query) as $row) {
         $comment = new Comment();
         $comment->setSubjectId($row['subjectId']);
         $comment->setDate($row['date']);
         $comment->setText($row['text']);
         $comment->setAuthor($row['author']);
         $comments[] = $comment;
     }
     return $comments;
 }
コード例 #5
0
 public function controlerJob($maincont)
 {
     if (isset($_POST["author"])) {
         //print_r($_POST);
         $p = new Comment();
         $p->setAuthor($_POST["author"]);
         $p->setBody($_POST["body"]);
         $p->setHour(date("h:i:s"));
         $p->setDate(date("Y-m-d"));
         $p->setPublished("0");
         $p->setPostid($_POST["postid"]);
     }
     $maincont->goModule("home", "display");
 }
コード例 #6
0
 /**
  * Metodo del controlador Comments cuya funcionalidad es insertar un comentario
  * en un post.
  * Verifica que el usuario ha iniciado sesion y que el post existe
  *
  * @throws Exception Si el usuario no inicio sesion
  * @return void
  */
 public function add()
 {
     if (!isset($this->currentUser)) {
         throw new Exception("Not in session. Adding comments requires login");
     }
     if (isset($_GET["id"])) {
         // reaching via HTTP Post...
         // Se obtiene el post de la BD
         $idPost = $_GET["id"];
         $post = $this->postDAO->findByIdPost($idPost);
         // Si no existe el post lanza una excepcion
         if ($post == NULL) {
             throw new Exception("no such post with id: " . $idPost);
         }
         // Crea el objeto Comment
         $comment = new Comment();
         $comment->setDate(date("Y-m-d H:i:s"));
         $comment->setContent($_POST["content"]);
         $comment->setAuthor($this->currentUser->getEmail());
         $comment->setIdPost($post->getIdPost());
         try {
             // Valida el comentario, si falla lanza una excepcion
             $comment->checkIsValidForCreate();
             // Guarda el comentario en la BD
             $this->commentDAO->save($comment);
             // Redirige al post
             $this->view->redirect("posts", "viewPosts", "id=" . $post->getIdPost());
         } catch (ValidationException $ex) {
             $errors = $ex->getErrors();
             $this->view->setVariable("comment", $comment, true);
             $this->view->setVariable("errors", $errors, true);
             $this->view->redirect("posts", "viewPosts", "id=" . $post->getIdPost());
         }
     } else {
         throw new Exception("No such post id");
     }
 }
コード例 #7
0
ファイル: comments.php プロジェクト: GiGis971/evoyage
 public function addComment($id_membre, $id_salle)
 {
     $msg = "";
     if ($_POST) {
         $comment = htmlentities($_POST['comment'], ENT_QUOTES, "utf-8");
         $note = htmlentities($_POST['note'], ENT_QUOTES, "utf-8");
         $dateNow = new DateTime("now");
         $date = $dateNow->format('Y-m-d H:i:s');
         $commentaire = new Comment();
         $commentaire->setIdMembre($id_membre);
         $commentaire->setIdSalle($id_salle);
         $commentaire->setComment($comment);
         $commentaire->setNote($note);
         $commentaire->setDate($date);
         //Vérifications si besoin avant entrée en base
         $msgError = "";
         //Entrée en base
         if ($msgError == "") {
             $commentaire->addComment();
         } else {
             $msg .= $msgError;
         }
     }
 }
コード例 #8
0
ファイル: Add.php プロジェクト: semaska-tomas/mysql-nd3
<?php

namespace Akademija\ActiveRecord;

include_once 'Theme.php';
include_once 'Comment.php';
include_once 'dbConnection.php';
if (isset($_POST["themeId"])) {
    $db = new dbConnection('localhost', 'root', '', 'akademija-nd');
    $db = $db->connect();
    $themeId = (int) $_POST["themeId"];
    $theme = new Theme($db);
    $theme = $theme->load($themeId);
    $comment = new Comment($db);
    $comment->setThemeId($themeId);
    $comment->setDate(date("Y-m-d H:i:s"));
    $comment->setAuthor($_POST["author"]);
    $comment->setComment($_POST["comment"]);
    $theme->addComments($comment);
    echo "<h2>Komentaras pridetas!</h2>";
} else {
    echo "<h2>Klaida!</h2>";
}
//header( "Refresh:15; url=List.php", true, 303);
echo '<a href="List.php"><- Atgal</a>';
コード例 #9
0
ファイル: add.php プロジェクト: sedvis/mysql-nd
<?php

require_once '../entity/CommentRep.php';
require_once '../entity/ThemeRep.php';
if (isset($_GET['theme_id']) && is_numeric($_GET['theme_id'])) {
    $comment = new Comment();
    $comment->setDate((new DateTime('now'))->format('Y-m-d H:i:s'));
    $comment->setAuthor(isset($_GET['author']) ? $_GET['author'] : 'bet koks autorius');
    $comment->setComment(isset($_GET['comment']) ? $_GET['comment'] : 'bet koks komentaras');
    $comment->setThemeId($_GET['theme_id']);
    $themeRep = new ThemeRep();
    $theme = $themeRep->findById($_GET['theme_id']);
    if (empty($theme)) {
        echo 'Tema su id ' . $_GET['theme_id'] . ' neegzistuoja';
        return;
    }
    $themeRep->increaseCommentCount($theme);
    $commentRep = new CommentRep();
    $commentRep->save($comment);
    echo 'Komentaras pridetas.';
} else {
    echo 'Reikalingas temos id.';
}
コード例 #10
0
	public function loadComments($survey, $arrayComments){

		/* TODO START */
		/* TODO END */
		
		$comments = array();

		for($i=0; $i < count($arrayComments) ; $i++ ){	
			 $comment = new Comment($arrayComments[$i]['id_survey'],$arrayComments[$i]['message'],$arrayComments[$i]['owner']);
			 $comment->setId($arrayComments[$i]['ID']);
			 $comment->setDate($arrayComments[$i]['date']);
			 $comments[] = $comment;
		}
		
		return $comments;
	}