Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanDotPro committed Mar 12, 2012
0 parents commit 268a723
Show file tree
Hide file tree
Showing 17 changed files with 716 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Module.php
@@ -0,0 +1,27 @@
<?php

namespace EdpDiscuss;

use Zend\Module\Consumer\AutoloaderProvider;

class Module implements AutoloaderProvider
{
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\ClassMapAutoloader' => array(
__DIR__ . '/autoload_classmap.php',
),
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
),
),
);
}

public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
}
7 changes: 7 additions & 0 deletions README.md
@@ -0,0 +1,7 @@
EdpDiscuss
========
Version 0.0.1

Introduction
------------
EdpDiscuss is a module for Zend Framework 2.
2 changes: 2 additions & 0 deletions autoload_classmap.php
@@ -0,0 +1,2 @@
<?php
return array();
12 changes: 12 additions & 0 deletions autoload_function.php
@@ -0,0 +1,12 @@
<?php
return function ($class) {
static $map;
if (!$map) {
$map = include __DIR__ . '/autoload_classmap.php';
}

if (!isset($map[$class])) {
return false;
}
return include $map[$class];
};
2 changes: 2 additions & 0 deletions autoload_register.php
@@ -0,0 +1,2 @@
<?php
spl_autoload_register(include __DIR__ . '/autoload_function.php');
17 changes: 17 additions & 0 deletions config/module.config.php
@@ -0,0 +1,17 @@
<?php
return array(
'di' => array(
'instance' => array(
'alias' => array(
'edpdiscuss' => 'EdpDiscuss\Controller\IndexController',
),
'Zend\View\Resolver\TemplatePathStack' => array(
'parameters' => array(
'paths' => array(
'edpdiscuss' => __DIR__ . '/../view',
),
),
),
),
),
);
39 changes: 39 additions & 0 deletions data/schema.sql
@@ -0,0 +1,39 @@
CREATE TABLE discuss_thread
(
thread_id INTEGER PRIMARY KEY AUTO_INCREMENT NOT NULL,
subject VARCHAR(1000) NOT NULL,
first_message_id INTEGER DEFAULT NULL,
latest_message_id INTEGER DEFAULT NULL
) ENGINE=InnoDB;

CREATE TABLE discuss_message
(
message_id INTEGER PRIMARY KEY AUTO_INCREMENT NOT NULL,
post_time DATETIME NOT NULL,
author_user_id INTEGER DEFAULT NULL,
author_email VARCHAR(255) DEFAULT NULL UNIQUE,
author_name VARCHAR(50) DEFAULT NULL,
thread_id INTEGER NOT NULL,
parent_message_id INTEGER DEFAULT NULL,
message TEXT NOT NULL,
FOREIGN KEY (author_user_id) REFERENCES user (user_id),
FOREIGN KEY (thread_id) REFERENCES thread (thread_id) ON DELETE CASCADE,
FOREIGN KEY (parent_message_id) REFERENCES thread_message (message_id)
) ENGINE=InnoDB;

ALTER TABLE thread ADD CONSTRAINT first_message_fk FOREIGN KEY (first_message_id) REFERENCES thread_message (message_id);
ALTER TABLE thread ADD CONSTRAINT latest_message_fk FOREIGN KEY (latest_message_id) REFERENCES thread_message (message_id);

DELIMITER |

CREATE TRIGGER latest_post_time AFTER INSERT ON thread_message
FOR EACH ROW BEGIN
UPDATE thread SET latest_message_id = NEW.message_id WHERE thread.thread_id = NEW.thread_id;
SET @threadMsg = (SELECT message_id FROM thread_message WHERE thread_id = NEW.thread_id LIMIT 1);
IF @threadMsg = 0 THEN
UPDATE thread SET first_message_id = NEW.message_id WHERE thread.thread_id = NEW.thread_id;
END IF;
END;
|

DELIMITER ;
14 changes: 14 additions & 0 deletions src/EdpDiscuss/Controller/IndexController.php
@@ -0,0 +1,14 @@
<?php

namespace EdpDiscuss\Controller;

use Zend\Mvc\Controller\ActionController,
Zend\View\Model\ViewModel;

class IndexController extends ActionController
{
public function indexAction()
{
return new ViewModel();
}
}
192 changes: 192 additions & 0 deletions src/EdpDiscuss/Model/Message/Message.php
@@ -0,0 +1,192 @@
<?php

namespace EdpDiscuss\Model\Message;

use ZfcBase\Model\ModelAbstract,
ZfcUser\Model\UserInterface,
DateTime;

class Message extends ModelAbstract implements MessageInterface
{
/**
* @var int
*/
protected $messageId;

/**
* @var DateTime
*/
protected $postTime;

/**
* @var string
*/
protected $authorName;

/**
* @var string
*/
protected $authorEmail;

/**
* @var UserInterface
*/
protected $authorUser;

/**
* @var string
*/
protected $message;

/**
* @var int
*/
protected $parentMessageId;

/**
* Get messageId.
*
* @return int
*/
public function getMessageId()
{
return $this->messageId;
}

/**
* Set messageId.
*
* @param int $messageId the value to be set
*/
public function setMessageId($messageId)
{
$this->messageId = $messageId;
return $this;
}

/**
* Get postTime.
*
* @return DateTime
*/
public function getPostTime()
{
return $this->postTime;
}

/**
* Set postTime.
*
* @param DateTime $postTime the value to be set
*/
public function setPostTime(DateTime $postTime)
{
$this->postTime = $postTime;
return $this;
}

/**
* Get authorName.
*
* @return sring
*/
public function getAuthorName()
{
return $this->authorName;
}

/**
* Set authorName.
*
* @param string $authorName the value to be set
*/
public function setAuthorName($authorName)
{
$this->authorName = $authorName;
return $this;
}

/**
* Get authorEmail.
*
* @return string
*/
public function getAuthorEmail()
{
return $this->authorEmail;
}

/**
* Set authorEmail.
*
* @param string $authorEmail the value to be set
*/
public function setAuthorEmail($authorEmail)
{
$this->authorEmail = $authorEmail;
return $this;
}

/**
* Get authorUser.
*
* @return UserInterface
*/
public function getAuthorUser()
{
return $this->authorUser;
}

/**
* Set authorUser.
*
* @param UserInterface $authorUser the value to be set
*/
public function setAuthorUser(UserInterface $authorUser)
{
$this->authorUser = $authorUser;
return $this;
}

/**
* Get message.
*
* @return string
*/
public function getMessage()
{
return $this->message;
}

/**
* Set message.
*
* @param string $message the value to be set
*/
public function setMessage($message)
{
$this->message = $message;
return $this;
}

/**
* Get parentMessageId.
*
* @return int
*/
public function getParentMessageId()
{
return $this->parentMessageId;
}

/**
* Set parentMessageId.
*
* @param int $parentMessageId the value to be set
*/
public function setParentMessageId($parentMessageId)
{
$this->parentMessageId = $parentMessageId;
return $this;
}
}

0 comments on commit 268a723

Please sign in to comment.