mirror of https://github.com/MISP/MISP
Thread creation if it doesn't exist for an event
parent
ea3b62f88a
commit
bec0d0e55f
|
@ -237,27 +237,40 @@ class EventsController extends AppController {
|
|||
'fields' => array('id', 'event_id', 'distribution', 'title')
|
||||
);
|
||||
$thread = $this->Thread->find('first', $params);
|
||||
if (!empty($thread)) {
|
||||
if (empty($thread)) {
|
||||
$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' => $id,
|
||||
'title' => 'Discussion about Event #' . $result['Event']['id'] . ' (' . $result['Event']['info'] . ')',
|
||||
'distribution' => $result['Event']['distribution'],
|
||||
'post_count' => 0,
|
||||
'org' => $result['Event']['orgc']
|
||||
);
|
||||
$this->Thread->save($newThread);
|
||||
$thread = ($this->Thread->read());
|
||||
} else {
|
||||
if ($thread['Thread']['distribution'] != $result['Event']['distribution']) {
|
||||
$this->Thread->saveField('distribution', $result['Event']['distribution']);
|
||||
}
|
||||
$this->loadModel('Post');
|
||||
$this->paginate['Post'] = array(
|
||||
'limit' => 5,
|
||||
'conditions' => array('Post.thread_id' => $thread['Thread']['id']),
|
||||
'contain' => 'User'
|
||||
);
|
||||
$posts = $this->paginate('Post');
|
||||
// Show the discussion
|
||||
$this->set('posts', $posts);
|
||||
$this->set('thread_id', $thread['Thread']['id']);
|
||||
$this->set('myuserid', $this->Auth->user('id'));
|
||||
$this->set('thread_title', $thread['Thread']['title']);
|
||||
if ($this->request->is('ajax')) {
|
||||
$this->disableCache();
|
||||
$this->layout = 'ajax';
|
||||
$this->render('/Elements/eventdiscussion');
|
||||
}
|
||||
}
|
||||
$this->loadModel('Post');
|
||||
$this->paginate['Post'] = array(
|
||||
'limit' => 5,
|
||||
'conditions' => array('Post.thread_id' => $thread['Thread']['id']),
|
||||
'contain' => 'User'
|
||||
);
|
||||
$posts = $this->paginate('Post');
|
||||
// Show the discussion
|
||||
$this->set('posts', $posts);
|
||||
$this->set('thread_id', $thread['Thread']['id']);
|
||||
$this->set('myuserid', $this->Auth->user('id'));
|
||||
$this->set('thread_title', $thread['Thread']['title']);
|
||||
if ($this->request->is('ajax')) {
|
||||
$this->disableCache();
|
||||
$this->layout = 'ajax';
|
||||
$this->render('/Elements/eventdiscussion');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -70,14 +70,11 @@ class ThreadsController extends AppController {
|
|||
|
||||
public function index() {
|
||||
$conditions = null;
|
||||
|
||||
//if (!$this->_isSiteAdmin()) {
|
||||
$conditions['OR'] = array(
|
||||
$conditions['AND']['OR'] = array(
|
||||
'Thread.distribution >' => 0,
|
||||
'Thread.org' => $this->Auth->user('org'),
|
||||
);
|
||||
//$conditions[] = array('Thread.event_id' => 0);
|
||||
//}
|
||||
$conditions['AND'][] = array('Thread.post_count >' => 0);
|
||||
$this->paginate = array(
|
||||
'conditions' => array($conditions),
|
||||
'fields' => array('date_modified', 'date_created', 'org', 'distribution', 'title', 'post_count'),
|
||||
|
|
|
@ -49,16 +49,7 @@
|
|||
<?php
|
||||
if (Configure::read('debug') == 0) echo "style=\"padding-top:100px;\"";
|
||||
?>
|
||||
>
|
||||
<?php
|
||||
// Add locations here that should not have a breadrumb displayed
|
||||
// If we get an error, also, we don't want the breadcrumbs shown
|
||||
if ($this->params['action'] !== 'login' && $this->response->statusCode() < '400'):
|
||||
?>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
|
||||
>
|
||||
<?php echo $this->fetch('content'); ?>
|
||||
</div>
|
||||
<?php
|
||||
|
|
Loading…
Reference in New Issue