Permalink
Browse files

Entite gestion des messages non lu/lu

  • Loading branch information...
1 parent d6749e8 commit 9be2db092618187339f4f7d515da8e5a2c31392e @Orkin committed Nov 10, 2012
Showing with 252 additions and 1 deletion.
  1. +112 −0 src/ZfrForum/Entity/CategoryTrack.php
  2. +1 −1 src/ZfrForum/Entity/Post.php
  3. +139 −0 src/ZfrForum/Entity/ThreadTrack.php
@@ -0,0 +1,112 @@
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license.
+ */
+
+namespace ZfrForum\Entity;
+
+use DateTime;
+use Doctrine\ORM\Mapping as ORM;
+use ZfrForum\Entity\UserInterface;
+use ZfrForum\Entity\Category;
+
+/**
+ * @ORM\Entity
+ * @ORM\Table(name="CategoriesTrack")
+ */
+class CategoryTrack
+{
+ /**
+ * @var UserInterface
+ *
+ * @ORM\Id
+ * @ORM\ManyToOne(targetEntity="ZfrForum\Entity\UserInterface")
+ */
+ protected $user;
+
+ /**
+ * @var Category
+ *
+ * @ORM\Id
+ * @ORM\ManyToOne(targetEntity="ZfrForum\Entity\Category")
+ */
+ protected $category;
+
+ /**
+ * @var DateTime
+ *
+ * @ORM\Column(type="datetime", nullable=false)
+ */
+ protected $markTime;
+
+ /**
+ * Constructor
+ *
+ * @param UserInterface $user
+ * @param Category $category
+ */
+ function __construct(UserInterface $user, Category $category)
+ {
+ $this->category = $category;
+ $this->user = $user;
+ $this->markTime = new DateTime();
+ }
+
+
+ /**
+ * Set when all thread of the category was read
+ *
+ * @param DateTime $markTime
+ * @return ForumTrack
+ */
+ public function setMarkTime(DateTime $markTime)
+ {
+ $this->markTime = clone $markTime;
+ return $this;
+ }
+
+ /**
+ * Return the markTime
+ *
+ * @return DateTime
+ */
+ public function getMarkTime()
+ {
+ return $this->markTime;
+ }
+
+ /**
+ * Return the category
+ *
+ * @return Category
+ */
+ public function getCategory()
+ {
+ return $this->category;
+ }
+
+ /**
+ * Return the user
+ *
+ * @return UserInterface
+ */
+ public function getUser()
+ {
+ return $this->user;
+ }
+
+
+}
@@ -192,7 +192,7 @@ public function getContent()
/**
* Set when this post was sent for the first time
*
- * @param DateTime $sentAt
+ * @param DateTime $sentAt
* @return Post
*/
public function setSentAt(DateTime $sentAt)
@@ -0,0 +1,139 @@
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license.
+ */
+
+use DateTime;
+use Doctrine\ORM\Mapping as ORM;
+use ZfrForum\Entity\UserInterface;
+use ZfrForum\Entity\Thread;
+use ZfrForum\Entity\Category;
+
+/**
+ * @ORM\Entity
+ * @ORM\Table(name="ThreadsTrack")
+ */
+class ThreadTrack
+{
+ /**
+ * @var UserInterface
+ *
+ * @ORM\Id
+ * @ORM\ManyToOne(targetEntity="ZfrForum\Entity\UserInterface")
+ */
+ protected $user;
+
+ /**
+ * @var Thread
+ *
+ * @ORM\Id
+ * @ORM\ManyToOne(targetEntity="ZfrForum\Entity\Thread")
+ */
+ protected $thread;
+
+ /**
+ * @var Category
+ *
+ * @ORM\ManyToOne(targetEntity="ZfrForum\Entity\Category")
+ */
+ protected $category;
+
+ /**
+ * @var DateTime
+ *
+ * @ORM\Column(type="datetime", nullable=false)
+ */
+ protected $markTime;
+
+ /**
+ * Constructor
+ *
+ * @param UserInterface $user
+ * @param Thread $thread
+ * @param Category $category
+ */
+ function __construct(UserInterface $user, Thread $thread, Category $category)
+ {
+ $this->user = $user;
+ $this->thread = $thread;
+ $this->category = $category;
+ $this->markTime = $thread->getLastPost()->getSentAt();
+ }
+
+ /**
+ * Return the user
+ *
+ * @return UserInterface
+ */
+ public function getUser()
+ {
+ return $this->user;
+ }
+
+ /**
+ * Return the thread
+ *
+ * @return Thread
+ */
+ public function getThread()
+ {
+ return $this->thread;
+ }
+
+ /**
+ * Set the category of the thread
+ *
+ * @param Category $category
+ * @return ThreadTrack
+ */
+ public function setCategory($category)
+ {
+ $this->category = $category;
+ return $this;
+ }
+
+ /**
+ * Return the category of the thread
+ *
+ * @return Category
+ */
+ public function getCategory()
+ {
+ return $this->category;
+ }
+
+ /**
+ * Set the created date of the lasted post of the thread
+ *
+ * @param DateTime $markTime
+ * @return ThreadTrack
+ */
+ public function setMarkTime(DateTime $markTime)
+ {
+ $this->markTime = clone $markTime;
+ return $this;
+ }
+
+ /**
+ * Return the date of the lasted post of the thread
+ * @return DateTime
+ */
+ public function getMarkTime()
+ {
+ return $this->markTime;
+ }
+
+}

0 comments on commit 9be2db0

Please sign in to comment.