From b2b76779b94ca7302184b25dbb92a51d012dd892 Mon Sep 17 00:00:00 2001 From: iglocska Date: Tue, 29 Oct 2013 13:45:53 +0100 Subject: [PATCH] More changes to the discussion boards - quote / event tags - anonymised e-mail addresses --- app/Controller/PostsController.php | 1 - app/Controller/ThreadsController.php | 20 ++++++++++++++++-- app/Model/Post.php | 2 +- app/View/Elements/eventdiscussion.ctp | 21 ++++++++++++++++++- app/View/Events/view.ctp | 25 +++++++++++++++++----- app/View/Events/xml/index.ctp | 3 ++- app/View/Helper/CommandHelper.php | 17 +++++++++++++++ app/View/Posts/add.ctp | 20 +++++++++++++++++- app/webroot/css/main.css | 30 ++++++++++++++++++++++++++- 9 files changed, 126 insertions(+), 13 deletions(-) diff --git a/app/Controller/PostsController.php b/app/Controller/PostsController.php index dee64cd8c..7605c100b 100644 --- a/app/Controller/PostsController.php +++ b/app/Controller/PostsController.php @@ -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']; diff --git a/app/Controller/ThreadsController.php b/app/Controller/ThreadsController.php index d0f2cd425..3c783a264 100644 --- a/app/Controller/ThreadsController.php +++ b/app/Controller/ThreadsController.php @@ -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); } diff --git a/app/Model/Post.php b/app/Model/Post.php index 6da910676..5f860fc11 100644 --- a/app/Model/Post.php +++ b/app/Model/Post.php @@ -12,7 +12,7 @@ class Post extends AppModel { public $belongsTo = array( 'Thread', 'User' => array( - 'fields' => array('email', 'org'), + 'fields' => array('email', 'org', 'id'), ) ); diff --git a/app/View/Elements/eventdiscussion.ctp b/app/View/Elements/eventdiscussion.ctp index 441e61f11..2ab691a92 100644 --- a/app/View/Elements/eventdiscussion.ctp +++ b/app/View/Elements/eventdiscussion.ctp @@ -42,7 +42,9 @@ 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;')); ?> @@ -124,8 +126,14 @@
Form->create('Post');?>
+
+ + + +
Form->input('message', array( + 'label' => false, 'type' => 'textarea', 'div' => 'input clear', 'class' => 'input-xxlarge', @@ -144,4 +152,15 @@ ?>
+ Js->writeBuffer();?> diff --git a/app/View/Events/view.ctp b/app/View/Events/view.ctp index 99e322ffe..824177b10 100755 --- a/app/View/Events/view.ctp +++ b/app/View/Events/view.ctp @@ -36,8 +36,6 @@ $mayPublish = ($isAclPublish && $event['Event']['orgc'] == $me['org']);
  • Add Event
  • -
  • -
  • Leave comment
  • @@ -139,11 +137,29 @@ $mayPublish = ($isAclPublish && $event['Event']['orgc'] == $me['org']);
    -

    Pivot Thread

    +
    + +
    +
    1) echo $this->element('pivot'); ?>
    -

    Attributes

    @@ -403,7 +419,6 @@ if (!empty($event['Attribute'])):?>
    -

    Discussion

    element('eventdiscussion'); diff --git a/app/View/Events/xml/index.ctp b/app/View/Events/xml/index.ctp index c677077bb..7c48e8901 100644 --- a/app/View/Events/xml/index.ctp +++ b/app/View/Events/xml/index.ctp @@ -31,4 +31,5 @@ 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. - --> \ No newline at end of file + --> + \ No newline at end of file diff --git a/app/View/Helper/CommandHelper.php b/app/View/Helper/CommandHelper.php index 9ca4eca70..21ee69a25 100644 --- a/app/View/Helper/CommandHelper.php +++ b/app/View/Helper/CommandHelper.php @@ -7,6 +7,23 @@ App::uses('AppHelper', 'View/Helper'); public function convertQuotes($string){ $string = str_ireplace('[QUOTE]', '
    ', $string); $string = str_ireplace('[/QUOTE]', '
    ', $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', ' Event ' . $matches[1] . '', $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', ' Thread ' . $matches[1] . '', $string); + } else { + $string = preg_replace('%\[event\]' . $matches[1] . '\[/event\]%i', '%Malformed_Thread_Link%', $string); + } + $matches = array(); + } return $string; } } diff --git a/app/View/Posts/add.ctp b/app/View/Posts/add.ctp index 3ace83fd0..c6fd2e6ab 100644 --- a/app/View/Posts/add.ctp +++ b/app/View/Posts/add.ctp @@ -2,7 +2,6 @@ Form->create('Post');?>
    Add Post -

    You can quote something in your message by enclosing the quote between [QUOTE] and [/QUOTE] tags.

    +
    + + + +
    + Form->input('message', array( + 'label' => false, 'type' => 'textarea', 'div' => 'input clear', 'class' => 'input-xxlarge', @@ -38,6 +45,17 @@ )); ?>
    + Form->button('Submit', array('class' => 'btn btn-primary')); echo $this->Form->end(); diff --git a/app/webroot/css/main.css b/app/webroot/css/main.css index 2eea305b2..0177f2a47 100755 --- a/app/webroot/css/main.css +++ b/app/webroot/css/main.css @@ -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);} -