mirror of https://github.com/MISP/MISP
Discussion boards
- First fully working version - Create threads or create a thread attached to an event - Add posts to threads / edit them / delete thempull/217/head
parent
62bec39759
commit
1ad3a8ffd6
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
App::uses('AppController', 'Controller');
|
||||
App::uses('Xml', 'Utility');
|
||||
|
||||
/**
|
||||
* Events Controller
|
||||
*
|
||||
|
@ -233,7 +232,17 @@ class EventsController extends AppController {
|
|||
$this->set('allPivots', $this->Session->read('pivot_thread'));
|
||||
// Show the discussion
|
||||
$this->loadModel('Thread');
|
||||
$thread = $this->Thread->find('first', array('conditions' => array('event_id' => $id)));
|
||||
$params = array('conditions' => array('event_id' => $id),
|
||||
'contain' => array(
|
||||
'Post' => array(
|
||||
'User',
|
||||
),
|
||||
)
|
||||
);
|
||||
$thread = $this->Thread->find('first', $params);
|
||||
if (empty($thread)) {
|
||||
$thread['Post'] = array();
|
||||
}
|
||||
$this->set('posts', $thread['Post']);
|
||||
$this->set('myuserid', $this->Auth->user('id'));
|
||||
}
|
||||
|
|
|
@ -0,0 +1,261 @@
|
|||
<?php
|
||||
|
||||
App::uses('AppController', 'Controller');
|
||||
|
||||
/**
|
||||
* Posts Controller
|
||||
*
|
||||
*/
|
||||
class PostsController extends AppController {
|
||||
|
||||
public $components = array(
|
||||
'Security',
|
||||
'Session',
|
||||
);
|
||||
|
||||
public $paginate = array(
|
||||
'limit' => 60,
|
||||
);
|
||||
|
||||
public function beforeFilter() {
|
||||
parent::beforeFilter();
|
||||
}
|
||||
|
||||
// Find the thread_id and post_id in advance. If a user clicks post comment on the event view, send the event's related thread's ID
|
||||
// Usage:
|
||||
// /posts/add : Creates new thread with the added post as the first post. Title set by user
|
||||
// /posts/add/event/id : Checks if the event already has a thread, if no it creates one. The post is added to the event's thread
|
||||
// /posts/add/thread/id : Adds a post to the thread specified
|
||||
// /posts/add/post/id : Adds a post as a reply to another post. The system finds the appropriate thread, adds the post to the thread and links to the post that is being replied to.
|
||||
public function add($target_type = null, $target_id = null) {
|
||||
$this->loadModel('Thread');
|
||||
$this->Thread->recursive = -1;
|
||||
$distribution = 1;
|
||||
$event_id = 0;
|
||||
$post_id = 0;
|
||||
// we have a target type and a target id. The target id defines what type of object we want to attach this event to (is it a reply to another post,
|
||||
// did someone add a post to a thread, does a thread for the event exist already, etc.
|
||||
switch ($target_type) {
|
||||
case 'event' :
|
||||
$this->loadModel('Event');
|
||||
$this->Event->recursive = -1;
|
||||
$this->Event->read(null, $target_id);
|
||||
$eventDiscussionTitle = 'Discussion about Event #' . $this->Event->data['Event']['id'] . ' (' . $this->Event->data['Event']['info'] . ')';
|
||||
if (!$this->Event->exists()) {
|
||||
throw new NotFoundException(__('Invalid event'));
|
||||
}
|
||||
if (!$this->_isSiteAdmin()) {
|
||||
if ($this->Event->data['Event']['distribution'] == 0 && $this->Event->data['Event']['org'] != $this->Auth->user('org')) {
|
||||
throw new MethodNotAllowedException('You don\'t have permission to do that.');
|
||||
}
|
||||
}
|
||||
$thread = $this->Thread->find('first', array('conditions' => array('event_id' => $target_id)));
|
||||
$title = $eventDiscussionTitle;
|
||||
if (isset($thread['Thread']['id'])) {
|
||||
$target_thread_id = $thread['Thread']['id'];
|
||||
} else {
|
||||
$target_thread_id = null;
|
||||
}
|
||||
$distribution = $this->Event->data['Event']['distribution'];
|
||||
$org = $this->Event->data['Event']['org'];
|
||||
break;
|
||||
case 'thread' :
|
||||
$target_thread_id = $target_id;
|
||||
if ($target_id != null) {
|
||||
$thread = $this->Thread->read(null, $target_thread_id);
|
||||
if ($thread == null) {
|
||||
throw new NotFoundException(__('Invalid thread'));
|
||||
}
|
||||
if (!$this->_isSiteAdmin()) {
|
||||
if ($thread['Thread']['distribution'] == 0 && $this->Auth->user('org') != $thread['Thread']['org']) {
|
||||
throw new MethodNotAllowedException('You don\'t have permission to do that.');
|
||||
}
|
||||
}
|
||||
$title = $this->Thread->data['Thread']['title'];
|
||||
}
|
||||
break;
|
||||
case 'post' :
|
||||
$this->Post->read(null, $target_id);
|
||||
$target_thread_id = $this->Post->data['Post']['thread_id'];
|
||||
$thread = $this->Thread->read(null, $target_thread_id);
|
||||
if (!$this->_isSiteAdmin()) {
|
||||
if ($thread['Thread']['distribution'] == 0 && $this->Auth->user('org') != $thread['Thread']['org']) {
|
||||
throw new MethodNotAllowedException('You don\'t have permission to do that.');
|
||||
}
|
||||
}
|
||||
$title = $this->Thread->data['Thread']['title'];
|
||||
$previousPost = $this->_grabPreviousPost($target_id);
|
||||
$distribution = $previousPost['Thread']['distribution'];
|
||||
$event_id = $previousPost['Thread']['event_id'];
|
||||
$post_id = $target_id;
|
||||
$target_thread_id = $previousPost['Thread']['id'];
|
||||
break;
|
||||
default:
|
||||
$target_thread_id = null;
|
||||
break;
|
||||
}
|
||||
|
||||
if ($this->request->is('post')) {
|
||||
// Set the default values that we'll alter before actually saving data. These are the default values unless specifically modified.
|
||||
// By default, all discussions will be visibile to everyone on the platform
|
||||
$org = $this->Auth->user('org');
|
||||
// Set the title if it is setable in the add view.
|
||||
if (empty($thread_id) && empty($target_type)) {
|
||||
$title = $this->request->data['Post']['title'];
|
||||
}
|
||||
|
||||
if ($target_thread_id == null) {
|
||||
// We have a post that was posted in a new thread. This could also mean that someone created the first post related to an event!
|
||||
$this->Thread->create();
|
||||
// Take the title from above and the id of the event as event_id if we are adding a post to an event.
|
||||
debug($this->request->data);
|
||||
if ($target_type === 'event') {
|
||||
$title = $eventDiscussionTitle;
|
||||
$event_id = $this->Event->data['Event']['id'];
|
||||
}
|
||||
$newThread = array(
|
||||
'date_created' => date('Y/m/d h:i:s'),
|
||||
'date_modified' => date('Y/m/d h:i:s'),
|
||||
'user_id' => $this->Auth->user('id'),
|
||||
'event_id' => $event_id,
|
||||
'title' => $title,
|
||||
'distribution' => $distribution,
|
||||
'post_count' => 1,
|
||||
'org' => $org
|
||||
);
|
||||
$this->Thread->save($newThread);
|
||||
$target_thread_id = $this->Thread->getId();
|
||||
} else {
|
||||
// In this case, we have a post that was posted in an already existing thread. Update the thread!
|
||||
$this->Thread->read(null, $target_thread_id);
|
||||
$this->Thread->data['Thread']['date_modified'] = date('Y/m/d h:i:s');
|
||||
$this->Thread->save();
|
||||
}
|
||||
|
||||
|
||||
// Time to create our post!
|
||||
$this->Post->create();
|
||||
$newPost = array(
|
||||
'date_created' => date('Y/m/d h:i:s'),
|
||||
'date_modified' => date('Y/m/d h:i:s'),
|
||||
'user_id' => $this->Auth->user('id'),
|
||||
'contents' => $this->request->data['Post']['message'],
|
||||
'post_id' => $post_id,
|
||||
'thread_id' => $target_thread_id,
|
||||
);
|
||||
if ($this->Post->save($newPost)) {
|
||||
$this->Thread->recursive = 0;
|
||||
$this->Thread->contain('Post');
|
||||
$this->Thread->read(null, $target_thread_id);
|
||||
$this->Thread->updateAfterPostChange(true);
|
||||
$this->Session->setFlash(__('Post added'));
|
||||
$this->redirect(array('action' => 'view', $this->Post->getId()));
|
||||
} else {
|
||||
$this->Session->setFlash('The post could not be added.');
|
||||
}
|
||||
}
|
||||
if ($target_type === 'post') {
|
||||
$this->set('previous', $previousPost['Post']['contents']);
|
||||
}
|
||||
$this->set('thread_id', $target_thread_id);
|
||||
$this->set('target_type', $target_type);
|
||||
$this->set('target_id', $target_id);
|
||||
if (isset($title)) {
|
||||
$this->set('title', $title);
|
||||
}
|
||||
}
|
||||
|
||||
public function edit($post_id) {
|
||||
$this->Post->id = $post_id;
|
||||
if (!$this->Post->exists()) {
|
||||
throw new NotFoundException(__('Invalid post'));
|
||||
}
|
||||
$this->Post->recursive = 1;
|
||||
$this->Post->read(null, $post_id);
|
||||
if (!$this->_isSiteAdmin() && $this->Auth->user('id') != $this->Post->data['Post']['user_id']) {
|
||||
throw new MethodNotAllowedException('This is not your event.');
|
||||
}
|
||||
if ($this->request->is('post') || $this->request->is('put')) {
|
||||
$this->request->data['Post']['date_modified'] = date('Y/m/d h:i:s');
|
||||
$fieldList = array('date_modified', 'contents');
|
||||
if ($this->Post->save($this->request->data, true, $fieldList)) {
|
||||
$this->Session->setFlash('Post edited');
|
||||
$this->loadModel('Thread');
|
||||
$this->Thread->recursive = 0;
|
||||
$this->Thread->contain('Post');
|
||||
$this->Thread->read(null, $this->Post->data['Post']['thread_id']);
|
||||
$this->Thread->updateAfterPostChange();
|
||||
$this->redirect(array('action' => 'view', $post_id));
|
||||
} else {
|
||||
$this->Session->setFlash('The Post could not be edited. Please, try again.');
|
||||
}
|
||||
}
|
||||
$this->set('title', $this->Post->data['Thread']['title']);
|
||||
$this->set('contents', $this->Post->data['Post']['contents']);
|
||||
$this->set('id', $post_id);
|
||||
}
|
||||
|
||||
public function delete($post_id) {
|
||||
if (!$this->request->is('post')) {
|
||||
throw new MethodNotAllowedException();
|
||||
}
|
||||
$this->Post->id = $post_id;
|
||||
if (!$this->Post->exists()) {
|
||||
throw new NotFoundException(__('Invalid post'));
|
||||
}
|
||||
$this->Post->read();
|
||||
$temp = $this->Post->data;
|
||||
if ($this->Auth->user('id') != $this->Post->data['Post']['user_id'] && !$this->_isSiteAdmin()) {
|
||||
throw new MethodNotAllowedException('This post doesn\'t belong to you, so you cannot delete it.');
|
||||
}
|
||||
if ($this->Post->delete()) {
|
||||
$this->loadModel('Thread');
|
||||
$this->Thread->recursive = 0;
|
||||
$this->Thread->contain('Post');
|
||||
$this->Thread->read(null, $this->Post->data['Thread']['id']);
|
||||
$thread = $this->Thread->data['Thread']['id'];
|
||||
if (!$this->Thread->updateAfterPostChange()) {
|
||||
$this->Session->setFlash('Post and thread deleted');
|
||||
$this->redirect(array('controller' => 'threads', 'action' => 'index'));
|
||||
} else {
|
||||
$this->Session->setFlash('Post deleted');
|
||||
}
|
||||
}
|
||||
$this->redirect(array('controller' => 'threads', 'action' => 'view', $thread));
|
||||
|
||||
}
|
||||
|
||||
public function index($thread_id) {
|
||||
$this->loadModel('Thread');
|
||||
$this->Thread->id = $thread_id;
|
||||
if (!$this->Thread->exists()) {
|
||||
throw new NotFoundException(__('Invalid thread'));
|
||||
}
|
||||
}
|
||||
|
||||
// Views the proper context for the post
|
||||
public function view($post_id) {
|
||||
$this->Post->id = $post_id;
|
||||
if (!$this->Post->exists()) {
|
||||
throw new NotFoundException(__('Invalid post'));
|
||||
}
|
||||
$this->Post->read();
|
||||
// We don't know what the context was, so let's try to guess what the user wants to see!
|
||||
// If the post belongs to an event's discussion thread, redirect the user to the event's view
|
||||
if ($this->Post->data['Thread']['event_id'] != 0) {
|
||||
$this->redirect(array('controller' => 'events', 'action' => 'view', $this->Post->data['Thread']['event_id']));
|
||||
} else {
|
||||
//Otherwise send the user to the thread's index.
|
||||
$this->redirect(array('controller' => 'threads', 'action' => 'view', $this->Post->data['Thread']['id']));
|
||||
}
|
||||
}
|
||||
|
||||
private function _grabPreviousPost($post_id) {
|
||||
$this->Post->id = $post_id;
|
||||
$this->Post->read();
|
||||
return $this->Post->data;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
|
||||
App::uses('AppController', 'Controller');
|
||||
|
||||
/**
|
||||
* Thread Controller
|
||||
*
|
||||
*/
|
||||
class ThreadsController extends AppController {
|
||||
|
||||
public $components = array(
|
||||
'Security',
|
||||
'Session',
|
||||
);
|
||||
|
||||
public $paginate = array(
|
||||
'limit' => 60,
|
||||
);
|
||||
|
||||
public function beforeFilter() {
|
||||
parent::beforeFilter();
|
||||
}
|
||||
|
||||
|
||||
public function view($thread_id = null) {
|
||||
if ($thread_id != null) {
|
||||
$this->Thread->id = $thread_id;
|
||||
if (!$this->Thread->exists()) {
|
||||
throw new NotFoundException(__('Invalid thread'));
|
||||
}
|
||||
$params = array('conditions' => array('id' => $thread_id),
|
||||
'contain' => array(
|
||||
'Post' => array(
|
||||
'User',
|
||||
),
|
||||
)
|
||||
);
|
||||
$thread = $this->Thread->find('first', $params);
|
||||
$this->set('thread_id', $thread_id);
|
||||
$this->set('posts', $thread['Post']);
|
||||
$this->set('myuserid', $this->Auth->user('id'));
|
||||
$this->set('context', 'threads');
|
||||
$this->set('thread_title', $thread['Thread']['title']);
|
||||
}
|
||||
}
|
||||
|
||||
public function index() {
|
||||
$conditions = null;
|
||||
|
||||
//if (!$this->_isSiteAdmin()) {
|
||||
$conditions['OR'] = array(
|
||||
'Thread.distribution >' => 0,
|
||||
'Thread.org' => $this->Auth->user('org'),
|
||||
);
|
||||
//$conditions[] = array('Thread.event_id' => 0);
|
||||
//}
|
||||
$this->paginate = array(
|
||||
'conditions' => array($conditions),
|
||||
'fields' => array('date_modified', 'date_created', 'org', 'distribution', 'title', 'post_count'),
|
||||
'contain' => array(
|
||||
'Post' =>array(
|
||||
'fields' => array(),
|
||||
'User' => array(
|
||||
'fields' => array('email', 'org')
|
||||
)
|
||||
),
|
||||
),
|
||||
'order' => array('Thread.date_modified' => 'desc'),
|
||||
'recursive' => 1
|
||||
);
|
||||
$this->set('threads', $this->paginate());
|
||||
$this->loadModel('Event');
|
||||
$this->set('distributionLevels', $this->Event->distributionLevels);
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
App::uses('AppModel', 'Model');
|
||||
|
||||
/**
|
||||
* Post Model
|
||||
*
|
||||
*/
|
||||
class Post extends AppModel {
|
||||
public $actsAs = array('Containable');
|
||||
|
||||
public $belongsTo = array(
|
||||
'Thread',
|
||||
'User' => array(
|
||||
'fields' => array('email', 'org'),
|
||||
|
||||
)
|
||||
);
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
App::uses('AppModel', 'Model');
|
||||
|
||||
/**
|
||||
* Thread Model
|
||||
*
|
||||
*/
|
||||
class Thread extends AppModel {
|
||||
public $actsAs = array('Containable');
|
||||
public $hasMany = 'Post';
|
||||
public $belongsTo = 'Event';
|
||||
|
||||
public function updateAfterPostChange($add = false) {
|
||||
$count = count($this->data['Post']);
|
||||
// If we have 0 posts left, delete the thread!
|
||||
if ($count == 0) {
|
||||
$this->delete();
|
||||
return false;
|
||||
} else {
|
||||
$this->data['Thread']['post_count'] = $count;
|
||||
if ($add) {
|
||||
$this->data['Thread']['date_modified'] = date('Y/m/d h:i:s');
|
||||
}
|
||||
$this->save($this->data);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -227,6 +227,8 @@ class User extends AppModel {
|
|||
'exclusive' => '',
|
||||
'finderQuery' => '',
|
||||
'counterQuery' => ''
|
||||
),
|
||||
'Post' => array(
|
||||
)
|
||||
);
|
||||
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
<div id="top">
|
||||
<?php
|
||||
foreach ($posts as $post) {
|
||||
?>
|
||||
<table class="discussionBox" id=<?php echo '"' . h($post['id']) . '"';?> >
|
||||
<tr>
|
||||
<td class="discussionBoxTD discussionBoxTDtop" colspan="2">
|
||||
<div>
|
||||
<table style="width:100%">
|
||||
<tr>
|
||||
<td>
|
||||
<?php
|
||||
echo 'Date: ' . h($post['date_created']);
|
||||
?>
|
||||
</td>
|
||||
<td style="text-align:right">
|
||||
<a href = #top class = "whitelink">Top</a> |
|
||||
<a href = #<?php echo $post['id']; ?> class = "whitelink">#<?php echo h($post['id'])?></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="discussionBoxTD discussionBoxTDMid discussionBoxTDMidLeft">
|
||||
<?php
|
||||
echo $this->Html->image('orgs/' . h($post['User']['org']) . '.png', array('alt' => h($post['User']['org']), 'title' => h($post['User']['org']), 'style' => 'width:48px; height:48px'));
|
||||
?>
|
||||
</td>
|
||||
<td class="discussionBoxTD discussionBoxTDMid discussionBoxTDMidRight">
|
||||
<?php
|
||||
echo $this->Command->convertQuotes(nl2br(h($post['contents'])));
|
||||
if ($post['post_id'] !=0 || ($post['date_created'] != $post['date_modified'])) {
|
||||
?>
|
||||
<br /><br />
|
||||
<?php
|
||||
}
|
||||
if ($post['post_id'] != 0) {
|
||||
?>
|
||||
<span style="font-style:italic">
|
||||
In reply to post
|
||||
<a href = #<?php echo h($post['post_id']); ?>>#<?php echo h($post['post_id'])?></a>
|
||||
</span>
|
||||
<?php
|
||||
}
|
||||
if ($post['date_created'] != $post['date_modified']) {
|
||||
echo '<span style="font-style:italic">Message edited at ' . h($post['date_modified']) . '<span>';
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="discussionBoxTD discussionBoxTDbottom" colspan = "2">
|
||||
<table style="width:100%">
|
||||
<tr>
|
||||
<td>
|
||||
<?php echo h($post['User']['email']); ?>
|
||||
</td>
|
||||
<td style="text-align:right">
|
||||
<?php
|
||||
if (!$isSiteAdmin) {
|
||||
if ($post['user_id'] == $myuserid) {
|
||||
echo $this->Html->link('', array('controller' => 'posts', 'action' => 'edit', h($post['id'])), array('class' => 'icon-edit', 'title' => 'Edit'));
|
||||
echo $this->Form->postLink('', array('controller' => 'posts', 'action' => 'delete', h($post['id'])), array('class' => 'icon-trash', 'title' => 'Delete'), __('Are you sure you want to delete this post?'));
|
||||
} else {
|
||||
?>
|
||||
<a href = "<?php echo Configure::read('CyDefSIG.baseurl') . '/posts/add/post/' . h($post['id']); ?>" class="icon-comment" title = "Reply"></a>
|
||||
<?php
|
||||
}
|
||||
} else {
|
||||
echo $this->Html->link('', array('controller' => 'posts', 'action' => 'edit', h($post['id'])), array('class' => 'icon-edit', 'title' => 'Edit'));
|
||||
echo $this->Form->postLink('', array('controller' => 'posts', 'action' => 'delete', h($post['id'])), array('class' => 'icon-trash', 'title' => 'Delete'), __('Are you sure you want to delete this post?'));
|
||||
?>
|
||||
<a href = "<?php echo Configure::read('CyDefSIG.baseurl') . '/posts/add/post/' . h($post['id']); ?>" class="icon-comment" title = "Reply"></a>
|
||||
<?php
|
||||
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br />
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
|
@ -110,7 +110,16 @@
|
|||
</ul>
|
||||
</li>
|
||||
<?php endif;?>
|
||||
|
||||
<li class="dropdown">
|
||||
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
|
||||
Discussions
|
||||
<b class="caret"></b>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="/threads/index">List Discussions</a></li>
|
||||
<li><a href="/posts/add">Start Discussion</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="nav-collapse collapse pull-right">
|
||||
|
|
|
@ -410,9 +410,13 @@ if (!empty($event['Attribute'])):?>
|
|||
<?php
|
||||
endif; ?>
|
||||
</div>
|
||||
<?php
|
||||
echo $this->element('eventdiscussion');
|
||||
?>
|
||||
<h3>Discussion</h3>
|
||||
<div id="discussion">
|
||||
<?php
|
||||
echo $this->element('eventdiscussion');
|
||||
?>
|
||||
<a href = <?php echo Configure::read('CyDefSIG.baseurl') . '/posts/add/event/' . $event['Event']['id']; ?>><span class="btn btn-primary">Add comment</span></a>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
// tooltips
|
||||
|
@ -422,5 +426,7 @@ $(document).ready(function () {
|
|||
'container' : 'body',
|
||||
delay: { show: 500, hide: 100 }
|
||||
});
|
||||
$('#discussion').hide();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
App::uses('AppHelper', 'View/Helper');
|
||||
|
||||
//this helper simply replaces quotes between [QUOTE][/QUOTE] with div tags.
|
||||
|
||||
class CommandHelper extends AppHelper {
|
||||
public function convertQuotes($string){
|
||||
$string = str_ireplace('[QUOTE]', '<div class="quote">', $string);
|
||||
$string = str_ireplace('[/QUOTE]', '</div>', $string);
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,58 @@
|
|||
<div class="posts form">
|
||||
<?php echo $this->Form->create('Post');?>
|
||||
<fieldset>
|
||||
<legend>Add Post</legend>
|
||||
<p>You can quote something in your message by enclosing the quote between [QUOTE] and [/QUOTE] tags.</p>
|
||||
<?php
|
||||
$quote = '';
|
||||
// If it is a new thread, let the user enter a subject
|
||||
if (empty($thread_id) && empty($target_type)) {
|
||||
echo $this->Form->input('title', array(
|
||||
'label' => 'Thread Subject',
|
||||
'class' => 'input-xxlarge'
|
||||
));
|
||||
} else {
|
||||
echo $this->Form->input('title', array(
|
||||
'label' => 'Thread Subject',
|
||||
'class' => 'input-xxlarge',
|
||||
'disabled' => 'true',
|
||||
'default' => $title
|
||||
));
|
||||
}
|
||||
if ($target_type === 'post') {
|
||||
echo $this->Form->input('responseTo', array(
|
||||
'label' => 'In response to',
|
||||
'type' => 'textarea',
|
||||
'div' => 'input clear',
|
||||
'class' => 'input-xxlarge',
|
||||
'disabled' => 'true',
|
||||
'default' => h($previous)
|
||||
));
|
||||
$quote = '[QUOTE]' . $previous . '[/QUOTE]' . "\n";
|
||||
}
|
||||
echo $this->Form->input('message', array(
|
||||
'type' => 'textarea',
|
||||
'div' => 'input clear',
|
||||
'class' => 'input-xxlarge',
|
||||
'default' => h($quote)
|
||||
));
|
||||
?>
|
||||
</fieldset>
|
||||
<?php
|
||||
echo $this->Form->button('Submit', array('class' => 'btn btn-primary'));
|
||||
echo $this->Form->end();
|
||||
?>
|
||||
</div>
|
||||
<div class="actions <?php echo $debugMode;?>">
|
||||
<ul class="nav nav-list">
|
||||
<?php if (!(empty($thread_id) && empty($target_type))) {
|
||||
?>
|
||||
<li><?php echo $this->Html->link('View Thread', array('controller' => 'threads', 'action' => 'view', $thread_id));?></li>
|
||||
<li class="divider"></li>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<li><?php echo $this->Html->link('List Threads', array('controller' => 'threads', 'action' => 'index'));?></li>
|
||||
<li class="active"><a href = "<?php echo Configure::read('CyDefSIG.baseurl');?>/posts/add/">New Thread</a></li>
|
||||
</ul>
|
||||
</div>
|
|
@ -0,0 +1,32 @@
|
|||
<div class="posts form">
|
||||
<?php echo $this->Form->create('Post');?>
|
||||
<fieldset>
|
||||
<legend>Edit Post</legend>
|
||||
<?php
|
||||
echo $this->Form->input('title', array(
|
||||
'label' => 'Thread Subject',
|
||||
'class' => 'input-xxlarge',
|
||||
'disabled' => 'true',
|
||||
'default' => $title
|
||||
));
|
||||
echo $this->Form->input('contents', array(
|
||||
'type' => 'textarea',
|
||||
'div' => 'input clear',
|
||||
'class' => 'input-xxlarge',
|
||||
'default' => $contents
|
||||
));
|
||||
?>
|
||||
</fieldset>
|
||||
<?php
|
||||
echo $this->Form->button('Submit', array('class' => 'btn btn-primary'));
|
||||
echo $this->Form->end();
|
||||
?>
|
||||
</div>
|
||||
<div class="actions <?php echo $debugMode;?>">
|
||||
<ul class="nav nav-list">
|
||||
<li class="active"><?php echo $this->Html->link('Edit Post', array('controller' => 'threads', 'action' => 'view', $id));?></li>
|
||||
<li class="divider"></li>
|
||||
<li><?php echo $this->Html->link('List Threads', array('controller' => 'threads', 'action' => 'index'));?></li>
|
||||
<li><a href = "<?php echo Configure::read('CyDefSIG.baseurl');?>/posts/add">New Thread</a></li>
|
||||
</ul>
|
||||
</div>
|
|
@ -0,0 +1,104 @@
|
|||
<div class="threads index">
|
||||
<h2>Discussions</h2>
|
||||
<div class="pagination">
|
||||
<ul>
|
||||
<?php
|
||||
$this->Paginator->options(array(
|
||||
'update' => '.span12',
|
||||
'evalScripts' => true,
|
||||
'before' => '$(".progress").show()',
|
||||
'complete' => '$(".progress").hide()',
|
||||
));
|
||||
|
||||
echo $this->Paginator->prev('« ' . __('previous'), array('tag' => 'li', 'escape' => false), null, array('tag' => 'li', 'class' => 'prev disabled', 'escape' => false, 'disabledTag' => 'span'));
|
||||
echo $this->Paginator->numbers(array('modulus' => 20, 'separator' => '', 'tag' => 'li', 'currentClass' => 'active', 'currentTag' => 'span'));
|
||||
echo $this->Paginator->next(__('next') . ' »', array('tag' => 'li', 'escape' => false), null, array('tag' => 'li', 'class' => 'next disabled', 'escape' => false, 'disabledTag' => 'span'));
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
<table class="table table-striped table-hover table-condensed">
|
||||
<tr>
|
||||
<th><?php echo $this->Paginator->sort('org');?></th>
|
||||
<th>Title</th>
|
||||
<th><?php echo $this->Paginator->sort('date_modified', 'Last Post On');?></th>
|
||||
<th>Last Post By</th>
|
||||
<th><?php echo $this->Paginator->sort('date_created', 'Thread started On');?></th>
|
||||
<th>Posts</th>
|
||||
<th>Distribution</th>
|
||||
</tr>
|
||||
<?php
|
||||
$url = Configure::read('CyDefSIG.baseurl');
|
||||
foreach ($threads as $thread):
|
||||
$lastPost = end($thread['Post']);
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<td class="short" style="text-align: left;" onclick="document.location.href ='<?php echo $url;?>/threads/view/<?php echo $thread['Thread']['id'];?>'">
|
||||
<?php
|
||||
$imgRelativePath = 'orgs' . DS . h($thread['Thread']['org']) . '.png';
|
||||
$imgAbsolutePath = APP . WEBROOT_DIR . DS . 'img' . DS . $imgRelativePath;
|
||||
if (file_exists($imgAbsolutePath)) echo $this->Html->image('orgs/' . h($thread['Thread']['org']) . '.png', array('alt' => h($thread['Thread']['org']), 'title' => h($thread['Thread']['org']), 'style' => 'width:24px; height:24px'));
|
||||
else echo $this->Html->tag('span', h($thread['Thread']['org']), array('class' => 'welcome', 'style' => 'float:left;'));
|
||||
?>
|
||||
|
||||
</td>
|
||||
<td onclick="document.location.href ='<?php echo $url;?>/threads/view/<?php echo $thread['Thread']['id'];?>'">
|
||||
<?php
|
||||
echo h($thread['Thread']['title']);
|
||||
?>
|
||||
</td>
|
||||
<td class="short" style="text-align: center;" onclick="document.location.href ='<?php echo $url;?>/threads/view/<?php echo $thread['Thread']['id'];?>'">
|
||||
<?php
|
||||
echo h($thread['Thread']['date_modified']);
|
||||
?>
|
||||
|
||||
</td>
|
||||
<td class="short" style="text-align: center;" onclick="document.location.href ='<?php echo $url;?>/threads/view/<?php echo $thread['Thread']['id'];?>'">
|
||||
<?php
|
||||
echo h($lastPost['User']['email']);
|
||||
?>
|
||||
|
||||
</td>
|
||||
<td class="short" style="text-align: center;" onclick="document.location.href ='<?php echo $url;?>/threads/view/<?php echo $thread['Thread']['id'];?>'">
|
||||
<?php
|
||||
echo h($thread['Thread']['date_created']);
|
||||
?>
|
||||
</td>
|
||||
<td class="short" onclick="document.location.href ='<?php echo $url;?>/threads/view/<?php echo $thread['Thread']['id'];?>'">
|
||||
<?php
|
||||
echo h($thread['Thread']['post_count']);
|
||||
?>
|
||||
</td>
|
||||
<td class="short" onclick="document.location.href ='<?php echo $url;?>/threads/view/<?php echo $thread['Thread']['id'];?>'">
|
||||
<?php
|
||||
echo $distributionLevels[$thread['Thread']['distribution']];
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
endforeach; ?>
|
||||
</table>
|
||||
<p>
|
||||
<?php
|
||||
echo $this->Paginator->counter(array(
|
||||
'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}')
|
||||
));
|
||||
?>
|
||||
</p>
|
||||
<div class="pagination">
|
||||
<ul>
|
||||
<?php
|
||||
echo $this->Paginator->prev('« ' . __('previous'), array('tag' => 'li', 'escape' => false), null, array('tag' => 'li', 'class' => 'prev disabled', 'escape' => false, 'disabledTag' => 'span'));
|
||||
echo $this->Paginator->numbers(array('modulus' => 20, 'separator' => '', 'tag' => 'li', 'currentClass' => 'active', 'currentTag' => 'span'));
|
||||
echo $this->Paginator->next(__('next') . ' »', array('tag' => 'li', 'escape' => false), null, array('tag' => 'li', 'class' => 'next disabled', 'escape' => false, 'disabledTag' => 'span'));
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="actions <?php echo $debugMode;?>">
|
||||
<ul class="nav nav-list">
|
||||
<li class="active"><?php echo $this->Html->link('List Threads', array('controller' => 'threads', 'action' => 'index'));?></li>
|
||||
<li><a href = "<?php echo Configure::read('CyDefSIG.baseurl');?>/posts/add">New Thread</a></li>
|
||||
</ul>
|
||||
</div>
|
|
@ -0,0 +1,18 @@
|
|||
<div class="threads view">
|
||||
<h3><?php echo $thread_title; ?></h3>
|
||||
<?php
|
||||
echo $this->element('eventdiscussion');
|
||||
?>
|
||||
<div>
|
||||
<a href = <?php echo Configure::read('CyDefSIG.baseurl') . '/posts/add/thread/' . $thread_id; ?>><span class="btn btn-primary">Add comment</span></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="actions <?php echo $debugMode;?>">
|
||||
<ul class="nav nav-list">
|
||||
<li class="active"><?php echo $this->Html->link('View Thread', array('controller' => 'threads', 'action' => 'view', $thread_id));?></li>
|
||||
<li><?php echo $this->Html->link('Add Post', array('controller' => 'posts', 'action' => 'add', 'thread', $thread_id));?></li>
|
||||
<li class="divider"></li>
|
||||
<li><?php echo $this->Html->link('List Threads', array('controller' => 'threads', 'action' => 'index'));?></li>
|
||||
<li><a href = "<?php echo Configure::read('CyDefSIG.baseurl');?>/posts/add/">New Thread</a></li>
|
||||
</ul>
|
||||
</div>
|
|
@ -466,41 +466,61 @@ dd {
|
|||
}
|
||||
|
||||
.discussionBox {
|
||||
|
||||
border-collapse: separate;
|
||||
box-shadow: 5px 5px 5px #888888;
|
||||
width:100%;
|
||||
max-width:900px;
|
||||
}
|
||||
|
||||
.discussionBoxTD {
|
||||
line-height: 20px;
|
||||
padding-right: 8px;
|
||||
padding-left: 8px;
|
||||
padding-bottom: 4px;
|
||||
border-color: #b2b2b2;
|
||||
border-style: solid;
|
||||
border-width: 1px;
|
||||
border-width: 0px;
|
||||
|
||||
}
|
||||
|
||||
.discussionBoxTDtop {
|
||||
padding-top: 8px;
|
||||
border-top-left-radius:7px;
|
||||
border-top-right-radius:7px;
|
||||
background-color: #F0F0F0;
|
||||
}
|
||||
|
||||
.discussionBoxTDMid {
|
||||
padding-top: 8px;
|
||||
border-top: 0px;
|
||||
border-bottom: 0px;
|
||||
color: #ffffff;
|
||||
background-color: #cccccc;
|
||||
}
|
||||
|
||||
.discussionBoxTDbottom {
|
||||
border-bottom-left-radius:7px;
|
||||
border-bottom-right-radius:7px;
|
||||
background-color: #F0F0F0;
|
||||
background-color: #eeeeee;
|
||||
padding-left: 8px;
|
||||
padding-bottom: 4px;
|
||||
padding-top: 4px;
|
||||
}
|
||||
|
||||
.discussionBoxTDMid {
|
||||
padding-top: 8px;
|
||||
height: 100px;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.discussionBoxTDMidLeft {
|
||||
background-color: #eeeeee;
|
||||
width: 80px;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
.discussionBoxTDMidRight {
|
||||
}
|
||||
|
||||
.whitelink {
|
||||
color:#ffffff;
|
||||
}
|
||||
|
||||
.quote {
|
||||
margin: 0 10px;
|
||||
margin-bottom: 10px;
|
||||
-moz-border-radius: 0px;
|
||||
-webkit-border-radius: 0px;
|
||||
background: #f2f6f8 none;
|
||||
border-radius: 0px;
|
||||
border: 1px solid #417394;
|
||||
position: relative;
|
||||
top: 0;
|
||||
padding: 4px;
|
||||
}
|
||||
|
Loading…
Reference in New Issue