Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 268a723
Showing
17 changed files
with
716 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
EdpDiscuss | ||
======== | ||
Version 0.0.1 | ||
|
||
Introduction | ||
------------ | ||
EdpDiscuss is a module for Zend Framework 2. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?php | ||
return array(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?php | ||
spl_autoload_register(include __DIR__ . '/autoload_function.php'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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', | ||
), | ||
), | ||
), | ||
), | ||
), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
Oops, something went wrong.