mirror of https://github.com/MISP/MISP
More changes to the discussion boards
- quote / event tags - anonymised e-mail addressespull/217/head
parent
6895548877
commit
b2b76779b9
|
@ -111,7 +111,6 @@ class PostsController extends AppController {
|
|||
// 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'];
|
||||
|
|
|
@ -58,6 +58,13 @@ class ThreadsController extends AppController {
|
|||
'contain' => 'User'
|
||||
);
|
||||
$posts = $this->paginate('Post');
|
||||
if (!$this->_isSiteAdmin()) {
|
||||
foreach ($posts as &$post) {
|
||||
if ($post['User']['org'] != $this->Auth->user('org')) {
|
||||
$post['User']['email'] = 'User ' . $post['User']['id'] . ' (' . $post['User']['org'] . ')';
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->set('posts', $posts);
|
||||
$this->set('thread_id', $thread_id);
|
||||
$this->set('myuserid', $this->Auth->user('id'));
|
||||
|
@ -69,6 +76,7 @@ class ThreadsController extends AppController {
|
|||
}
|
||||
|
||||
public function index() {
|
||||
$this->loadModel('Posts');
|
||||
$conditions = null;
|
||||
$conditions['AND']['OR'] = array(
|
||||
'Thread.distribution >' => 0,
|
||||
|
@ -81,15 +89,23 @@ class ThreadsController extends AppController {
|
|||
'contain' => array(
|
||||
'Post' =>array(
|
||||
'fields' => array(),
|
||||
'limit' => 1,
|
||||
'order' => 'Post.date_modified DESC',
|
||||
'User' => array(
|
||||
'fields' => array('email', 'org')
|
||||
'fields' => array('id','email', 'org'),
|
||||
)
|
||||
),
|
||||
),
|
||||
'order' => array('Thread.date_modified' => 'desc'),
|
||||
'recursive' => 1
|
||||
);
|
||||
$this->set('threads', $this->paginate());
|
||||
$threadsBeforeEmailRemoval = $this->paginate();
|
||||
if (!$this->_isSiteAdmin()) {
|
||||
foreach ($threadsBeforeEmailRemoval as &$thread) {
|
||||
if ($thread['Post'][0]['User']['org'] != $this->Auth->user('org')) $thread['Post'][0]['User']['email'] = 'User ' . $thread['Post'][0]['User']['id'] . " (" . $thread['Post'][0]['User']['org'] . ")";
|
||||
}
|
||||
}
|
||||
$this->set('threads', $threadsBeforeEmailRemoval);
|
||||
$this->loadModel('Event');
|
||||
$this->set('distributionLevels', $this->Event->distributionLevels);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ class Post extends AppModel {
|
|||
public $belongsTo = array(
|
||||
'Thread',
|
||||
'User' => array(
|
||||
'fields' => array('email', 'org'),
|
||||
'fields' => array('email', 'org', 'id'),
|
||||
|
||||
)
|
||||
);
|
||||
|
|
|
@ -42,7 +42,9 @@
|
|||
<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'));
|
||||
$imgAbsolutePath = APP . WEBROOT_DIR . DS . 'img' . DS . 'orgs' . DS . h($post['User']['org']) . '.png';
|
||||
if (file_exists($imgAbsolutePath)) 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'));
|
||||
else echo $this->Html->tag('span', h($post['User']['org']), array('class' => 'welcome', 'style' => 'float:center;'));
|
||||
?>
|
||||
</td>
|
||||
<td class="discussionBoxTD discussionBoxTDMid discussionBoxTDMidRight">
|
||||
|
@ -124,8 +126,14 @@
|
|||
<div class="comment">
|
||||
<?php echo $this->Form->create('Post');?>
|
||||
<fieldset>
|
||||
<div class="input clear">
|
||||
<button type="button" title="Insert a quote - just paste your quote between the [quote][/quote] tags." class="toggle-left btn btn-inverse qet" id = "quote" onclick="insertQuote()">Quote</button>
|
||||
<button type="button" title="Insert a link to an event - just enter the event ID between the [event][/event] tags." class="toggle btn btn-inverse qet" id = "event" onclick="insertEvent()">Event</button>
|
||||
<button type="button" title="Insert a link to a discussion thread - enter the thread's ID between the [thread][/thread] tags." class="toggle-right btn btn-inverse qet" id = "thread" onclick="insertThread()">Thread</button>
|
||||
</div>
|
||||
<?php
|
||||
echo $this->Form->input('message', array(
|
||||
'label' => false,
|
||||
'type' => 'textarea',
|
||||
'div' => 'input clear',
|
||||
'class' => 'input-xxlarge',
|
||||
|
@ -144,4 +152,15 @@
|
|||
?>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
function insertQuote() {
|
||||
document.getElementById("PostMessage").value+="[Quote][/Quote]";
|
||||
}
|
||||
function insertEvent() {
|
||||
document.getElementById("PostMessage").value+="[Event][/Event]";
|
||||
}
|
||||
function insertThread() {
|
||||
document.getElementById("PostMessage").value+="[Thread][/Thread]";
|
||||
}
|
||||
</script>
|
||||
<?php echo $this->Js->writeBuffer();?>
|
||||
|
|
|
@ -36,8 +36,6 @@ $mayPublish = ($isAclPublish && $event['Event']['orgc'] == $me['org']);
|
|||
<?php if ($isAclAdd): ?>
|
||||
<li><a href="/events/add">Add Event</a></li>
|
||||
<?php endif; ?>
|
||||
<li class="divider"></li>
|
||||
<li><a href="/posts/add/null/null/event/<?php echo $event['Event']['id'];?>">Leave comment</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
@ -139,11 +137,29 @@ $mayPublish = ($isAclPublish && $event['Event']['orgc'] == $me['org']);
|
|||
<?php endif; ?>
|
||||
</div>
|
||||
<br />
|
||||
<h3><span id="pivots_active" class="icon-minus"></span><span id="pivots_inactive" class="icon-plus" style="display:none;"></span>Pivot Thread</h3>
|
||||
<div>
|
||||
<button class="btn btn-inverse toggle-left btn.active" id="pivots_active">
|
||||
<span class="icon-minus icon-white" style="vertical-align:top;"></span>
|
||||
Pivots
|
||||
</button><button class="btn btn-inverse toggle-left" style="display:none;" id="pivots_inactive">
|
||||
<span class="icon-plus icon-white" style="vertical-align:top;"></span>
|
||||
Pivots
|
||||
</button><button class="btn btn-inverse toggle" id="attributes_active">
|
||||
<span class="icon-minus icon-white" style="vertical-align:top;"></span>
|
||||
Attributes
|
||||
</button><button class="btn btn-inverse toggle" id="attributes_inactive" style="display:none;">
|
||||
<span class="icon-plus icon-white" style="vertical-align:top;"></span>
|
||||
Attributes
|
||||
</button><button class="btn btn-inverse toggle-right" id="discussions_active">
|
||||
<span class="icon-minus icon-white" style="vertical-align:top;"></span>Discussion
|
||||
</button><button class="btn btn-inverse toggle-right" id="discussions_inactive" style="display:none;">
|
||||
<span class="icon-plus icon-white" style="vertical-align:top;"></span>Discussion
|
||||
</button>
|
||||
</div>
|
||||
<br />
|
||||
<div id="pivots_div">
|
||||
<?php if (sizeOf($allPivots) > 1) echo $this->element('pivot'); ?>
|
||||
</div>
|
||||
<h3><span id="attributes_active" class="icon-minus"></span><span id="attributes_inactive" class="icon-plus" style="display:none;"></span>Attributes</h3>
|
||||
<div id="attributes_div">
|
||||
<?php
|
||||
if (!empty($event['Attribute'])):?>
|
||||
|
@ -403,7 +419,6 @@ if (!empty($event['Attribute'])):?>
|
|||
<?php
|
||||
endif; ?>
|
||||
</div>
|
||||
<h3><span id="discussions_active" class="icon-minus"></span><span id="discussions_inactive" class="icon-plus" style="display:none;"></span>Discussion</h3>
|
||||
<div id="discussions_div">
|
||||
<?php
|
||||
echo $this->element('eventdiscussion');
|
||||
|
|
|
@ -32,3 +32,4 @@ You can for example ask: /events/index/limit:999.xml to get the 999 first record
|
|||
|
||||
To export all the events at once, with their attributes, use the export functionality.
|
||||
-->
|
||||
|
|
@ -7,6 +7,23 @@ App::uses('AppHelper', 'View/Helper');
|
|||
public function convertQuotes($string){
|
||||
$string = str_ireplace('[QUOTE]', '<div class="quote">', $string);
|
||||
$string = str_ireplace('[/QUOTE]', '</div>', $string);
|
||||
$matches = array();
|
||||
while (preg_match ('%\[event\](.*?)\[/event\]%is', $string, $matches)) {
|
||||
if (!empty($matches) && is_numeric($matches[1])) {
|
||||
$string = preg_replace('%\[event\]' . $matches[1] . '\[/event\]%i', '<a href=/events/view/' . $matches[1] . '> Event ' . $matches[1] . '</a>', $string);
|
||||
} else {
|
||||
$string = preg_replace('%\[event\]' . $matches[1] . '\[/event\]%i', '%Malformed_Event_Link%', $string);
|
||||
}
|
||||
}
|
||||
$matches = array();
|
||||
while (preg_match ('%\[thread\](.*?)\[/thread\]%is', $string, $matches)) {
|
||||
if (!empty($matches) && is_numeric($matches[1])) {
|
||||
$string = preg_replace('%\[thread\]' . $matches[1] . '\[/thread\]%i', '<a href=/threads/view/' . $matches[1] . '> Thread ' . $matches[1] . '</a>', $string);
|
||||
} else {
|
||||
$string = preg_replace('%\[event\]' . $matches[1] . '\[/event\]%i', '%Malformed_Thread_Link%', $string);
|
||||
}
|
||||
$matches = array();
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
<?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
|
||||
|
@ -30,7 +29,15 @@
|
|||
));
|
||||
$quote = '[QUOTE]' . $previous . '[/QUOTE]' . "\n";
|
||||
}
|
||||
?>
|
||||
<div class="input clear">
|
||||
<button type="button" title="Insert a quote - just paste your quote between the [quote][/quote] tags." class="toggle-left btn btn-inverse qet" id = "quote" onclick="insertQuote()">Quote</button>
|
||||
<button type="button" title="Insert a link to an event - just enter the event ID between the [event][/event] tags." class="toggle btn btn-inverse qet" id = "event" onclick="insertEvent()">Event</button>
|
||||
<button type="button" title="Insert a link to a discussion thread - enter the thread's ID between the [thread][/thread] tags." class="toggle-right btn btn-inverse qet" id = "thread" onclick="insertThread()">Thread</button>
|
||||
</div>
|
||||
<?php
|
||||
echo $this->Form->input('message', array(
|
||||
'label' => false,
|
||||
'type' => 'textarea',
|
||||
'div' => 'input clear',
|
||||
'class' => 'input-xxlarge',
|
||||
|
@ -38,6 +45,17 @@
|
|||
));
|
||||
?>
|
||||
</fieldset>
|
||||
<script type="text/javascript">
|
||||
function insertQuote() {
|
||||
document.getElementById("PostMessage").value+="[Quote][/Quote]";
|
||||
}
|
||||
function insertEvent() {
|
||||
document.getElementById("PostMessage").value+="[Event][/Event]";
|
||||
}
|
||||
function insertThread() {
|
||||
document.getElementById("PostMessage").value+="[Thread][/Thread]";
|
||||
}
|
||||
</script>
|
||||
<?php
|
||||
echo $this->Form->button('Submit', array('class' => 'btn btn-primary'));
|
||||
echo $this->Form->end();
|
||||
|
|
|
@ -510,6 +510,29 @@ dd {
|
|||
top: -45px;
|
||||
left: 13px;
|
||||
}
|
||||
.toggle {
|
||||
border-radius: 0px !important;
|
||||
-webkit-border-radius: 0px !important;
|
||||
-moz-border-radius: 0px !important;
|
||||
}
|
||||
|
||||
.toggle-left {
|
||||
border-bottom-right-radius: 0px !important;
|
||||
-webkit-bottom-right-radius: 0px !important;
|
||||
-moz-border-bottom-right-radius: 0px !important;
|
||||
border-top-right-radius: 0px !important;
|
||||
-webkit-top-right-radius: 0px !important;
|
||||
-moz-border-top-right-radius: 0px !important;
|
||||
}
|
||||
|
||||
.toggle-right {
|
||||
border-bottom-left-radius: 0px !important;
|
||||
-webkit-bottom-left-radius: 0px !important;
|
||||
-moz-border-bottom-left-radius: 0px !important;
|
||||
border-top-left-radius: 0px !important;
|
||||
-webkit-top-left-radius: 0px !important;
|
||||
-moz-border-top-left-radius: 0px !important;
|
||||
}
|
||||
|
||||
.spinner {
|
||||
height:60px;
|
||||
|
@ -539,6 +562,12 @@ dd {
|
|||
border-radius:100%;
|
||||
}
|
||||
|
||||
.qet {
|
||||
padding:1px 1px;
|
||||
font-size:12px;
|
||||
float:left;
|
||||
}
|
||||
|
||||
@-webkit-keyframes rotation {
|
||||
from {-webkit-transform: rotate(0deg);}
|
||||
to {-webkit-transform: rotate(359deg);}
|
||||
|
@ -554,4 +583,3 @@ dd {
|
|||
@keyframes rotation {
|
||||
from {transform: rotate(0deg);}
|
||||
to {transform: rotate(359deg);}
|
||||
|
||||
|
|
Loading…
Reference in New Issue