Permalink
Browse files

added event commenting

  • Loading branch information...
mikevalstar committed Jan 22, 2013
1 parent c6aae43 commit 0e27053973f646f37fe9f6b714f834e1eed6e708
View
@@ -16,7 +16,7 @@ class event extends basedata{
var $_editwhencol = 'modified_when';
static function static_load($id){
- return new game($id);
+ return new event($id);
}
function coordinator(){
@@ -114,4 +114,24 @@ function send_invite($type){
$results = DBQ::prepare_execute($sql, $par);
}
+ /* Comments */
+ function comments(){
+ return new event_commentlist($this->id);
+ }
+
+ function post_comment($user, $comment_text){
+ if(trim($comment_text) == '') return;
+
+ $comment = new event_comment();
+ $comment->save(array('event_fk' => $this->id, 'author' => $user->name_first . ' ' . $user->name_last, 'comment' => $comment_text));
+
+ $subject = "KG Game Knight: {$user->name_first} {$user->name_last} commented on: " . $this->event_name;
+ $message = "{$user->name_first} {$user->name_last} wrote: \r\n\r\n {$comment_text}";
+ foreach($this->participants() as $v){
+ if($user->id != $v['user_pk']){
+ email::send($v['email'], $v['name_first'] . ' ' . $v['name_last'], $subject, $message);
+ }
+ }
+ }
+
}
@@ -0,0 +1,22 @@
+<?PHP
+
+class event_comment extends basedata{
+ var $_table = 'event_comment';
+ var $_keycol = 'event_comment_pk';
+ var $_cols = array('event_fk', 'author', 'comment');
+
+ /* Messaging vars */
+ var $_msg_obj_replace = "Event Comment";
+
+ var $_createbycol = 'created_by';
+ var $_createwhencol = 'created_when';
+ var $_delbycol = 'deleted_by';
+ var $_delwhencol = 'deleted_when';
+ var $_editbycol = 'modified_by';
+ var $_editwhencol = 'modified_when';
+
+ static function static_load($id){
+ return new event_comment($id);
+ }
+
+}
@@ -0,0 +1,22 @@
+<?PHP
+
+class event_commentlist extends baselist{
+
+ var $_table = 'event_comment';
+ var $_idcol = 'event_comment_pk';
+ var $_filter_cols = array('event_comment_pk');
+ var $_display_cols = array('author', 'comment', 'created_when');
+ var $_del_col = 'deleted_when';
+
+ /* settable properties / default values / Set as needed */
+ var $rows = 100;
+ var $orderby = 'created_when';
+ var $direction = 'asc';
+
+ function __construct($for_event = false){
+ if($for_event){
+ $this->_ext_where[] = " AND `event_fk` = ".intval($for_event)." ";
+ }
+ }
+
+}
View
@@ -135,4 +135,19 @@ ALTER TABLE `user` ADD `ranking` INT( 8 ) NOT NULL DEFAULT '2000' AFTER `nam
ALTER TABLE `play_player` ADD UNIQUE (
`play_fk` ,
`user_fk`
+);
+
+DROP TABLE IF EXISTS `event_comment`;
+CREATE TABLE `event_comment` (
+ `event_comment_pk` int(11) unsigned NOT NULL AUTO_INCREMENT,
+ `event_fk` int(11) unsigned NOT NULL,
+ `author` varchar(250) NOT NULL,
+ `comment` text NOT NULL,
+ `created_by` int(11) unsigned NOT NULL,
+ `created_when` datetime NOT NULL,
+ `deleted_by` int(11) unsigned DEFAULT NULL,
+ `deleted_when` datetime DEFAULT NULL,
+ `modified_by` int(11) unsigned NOT NULL,
+ `modified_when` datetime NOT NULL,
+ PRIMARY KEY (`event_comment_pk`)
);
View
@@ -3,3 +3,7 @@
function x($string) {
return htmlspecialchars($string);
}
+
+function xnl2br($string) {
+ return nl2br(htmlspecialchars($string));
+}
View
@@ -4,7 +4,8 @@
@import "timepicker.less";
.b{ font-weight: bold; }
-
+.tr{ text-align: right; }
+.gray{ color: #CCC; }
.small{
font-size: 0.85em;
}
@@ -54,6 +55,12 @@
min-height: 50em;
}
+.comment{
+ padding: 0.25em 0.5em;
+ margin: 0.5em 0;
+ border: 1px solid #EEE;
+}
+
footer{
border-top: 7px solid #000;
background: #777777;
@@ -41,6 +41,11 @@
header('location: /events/' . $event->id . '/'. prettyurlencode($event->event_name));
die();
break;
+ case 'comment':
+ $event->post_comment($_SESSION['user'], $_POST['comment']);
+ header('location: /events/' . $event->id . '/'. prettyurlencode($event->event_name));
+ die();
+ break;
}
}
@@ -168,4 +168,24 @@
</div>
</div>
</div>
+
+<div class="row">
+ <div class="span12"><div id="comments">
+ <h2>Comments</h2>
+
+ {foreach from=$event->comments()->results_all() item=row}
+ <div class="comment">
+ <div class="pull-right gray small">{$row['created_when']}</div>
+ <h4>{$row['author']} <small>wrote</small></h4>
+ <p class="small">{$row['comment']|xnl2br}</p>
+ </div>
+ {/foreach}
+
+ <form method="post">
+ <input type="hidden" name="action" value="comment" />
+ <textarea name="comment" placeholder="Comment on this event..." style="width: 99%; height: 6em;"></textarea>
+ <input type="submit" class="btn" value="Post Comment" />
+ </form>
+ </div></div>
+</div>
{/block}

0 comments on commit 0e27053

Please sign in to comment.