From cc7242f0c906a95798e19d1564fe924653827d78 Mon Sep 17 00:00:00 2001 From: iglocska Date: Sat, 27 Aug 2016 23:53:41 +0200 Subject: [PATCH] new: Add e-mail in event history view, fixes #1389 - Only visible to site admins and org members --- app/Controller/LogsController.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/app/Controller/LogsController.php b/app/Controller/LogsController.php index 4673125b6..57185b655 100644 --- a/app/Controller/LogsController.php +++ b/app/Controller/LogsController.php @@ -104,15 +104,26 @@ class LogsController extends AppController { $conditions['OR'][] = array('AND' => array ('Log.model LIKE' => 'Attribute', 'Log.title LIKE' => '%Event (' . $id . ')%')); } $conditions['OR'][] = array('AND' => array ('Log.model LIKE' => 'ShadowAttribute', 'Log.title LIKE' => '%Event (' . $id . ')%')); - $fieldList = array('title', 'created', 'model', 'model_id', 'action', 'change', 'org'); + $fieldList = array('title', 'created', 'model', 'model_id', 'action', 'change', 'org', 'email'); $this->paginate = array( 'limit' => 60, 'conditions' => $conditions, 'order' => array('Log.id' => 'DESC'), 'fields' => $fieldList ); + $list = $this->paginate(); + if (!$this->_isSiteAdmin()) { + $this->loadModel('User'); + $emails = $this->User->find('list', array( + 'conditions' => array('User.org_id' => $this->Auth->user('org_id')), + 'fields' => array('User.id', 'User.email') + )); + foreach ($list as &$item) { + if (!in_array($item['Log']['email'], $emails)) $item['Log']['email'] = ''; + } + } $this->set('event', $this->Event->data); - $this->set('list', $this->paginate()); + $this->set('list', $list); $this->set('eventId', $id); $this->set('mayModify', $mayModify); }