Related events

- Implemented on request: related events created by the same organisation are now coloured red
pull/64/merge
iglocska 2013-03-19 10:30:32 +01:00
parent cdb3c908eb
commit ef93e61efb
3 changed files with 24 additions and 4 deletions

View File

@ -235,11 +235,13 @@ class EventsController extends AppController {
$relatedEventsDates[$item['Attribute']['event_id']] = $item['Attribute']['date'];
$temp = $this->Event->find('first', array(
'conditions' => array('Event.id' => $item['Attribute']['event_id']),
'fields' => array('info'),
'fields' => array('info', 'orgc'),
'recursive' => 0,
));
$item['Attribute']['event_info'] = $temp['Event']['info'];
$item['Attribute']['relatedOrg'] = $temp['Event']['orgc'];
$relatedEventInfos[$item['Attribute']['event_id']] = $temp['Event']['info'];
$relatedEventOrgs[$item['Attribute']['event_id']] = $temp['Event']['orgc'];
}
}
if (isset($relatedEventsDates)) {
@ -251,6 +253,11 @@ class EventsController extends AppController {
$relatedEvents[$i]['Event']['info'] = $info;
$i++;
}
$i = 0;
foreach ($relatedEventOrgs as $org) {
$relatedEvents[$i]['Event']['org'] = $org;
$i++;
}
}
usort($relatedEvents, array($this, 'compareRelatedEvents'));
}
@ -293,7 +300,7 @@ class EventsController extends AppController {
$findParams = array(
'conditions' => array('OR' => array('Event.id' => $relatedEventsIds)), //array of conditions
'recursive' => 0, //int
'fields' => array('Event.id', 'Event.date', 'Event.uuid', 'Event.info'), //array of field names
'fields' => array('Event.id', 'Event.date', 'Event.uuid', 'Event.info', 'Event.orgc'), //array of field names
'order' => array('Event.date DESC'), //string or array defining order
);
$relatedEvents = $this->Event->find('all', $findParams);

View File

@ -118,7 +118,11 @@ if (!empty($relatedEvents)):?>
<li><?php
$linkText = $relatedEvent['Event']['date'] . ' (' . $relatedEvent['Event']['id'] . ')';
echo "<div \" title = \"".$relatedEvent['Event']['info']."\">";
echo $this->Html->link($linkText, array('controller' => 'events', 'action' => 'view', $relatedEvent['Event']['id']));
if ($relatedEvent['Event']['org'] == $me['org']) {
echo $this->Html->link($linkText, array('controller' => 'events', 'action' => 'view', $relatedEvent['Event']['id']), array('class' => 'SameOrgLink'));
} else {
echo $this->Html->link($linkText, array('controller' => 'events', 'action' => 'view', $relatedEvent['Event']['id']));
}
?></li>
<?php
endforeach; ?>
@ -202,7 +206,12 @@ if (!empty($event['Attribute'])):?>
if (isset($relatedAttributes[$attribute['id']]) && (null != $relatedAttributes[$attribute['id']])) {
foreach ($relatedAttributes[$attribute['id']] as $relatedAttribute) {
echo "<span title = \"".$relatedAttribute['Attribute']['event_info']."\">";
echo $this->Html->link($relatedAttribute['Attribute']['event_id'], array('controller' => 'events', 'action' => 'view', $relatedAttribute['Attribute']['event_id']));
if ($relatedAttribute['Attribute']['relatedOrg'] == $me['org']) {
echo $this->Html->link($relatedAttribute['Attribute']['event_id'], array('controller' => 'events', 'action' => 'view', $relatedAttribute['Attribute']['event_id']), array ('class' => 'SameOrgLink'));
} else {
echo $this->Html->link($relatedAttribute['Attribute']['event_id'], array('controller' => 'events', 'action' => 'view', $relatedAttribute['Attribute']['event_id']));
}
echo "</span>";
echo ' ';
}

View File

@ -34,6 +34,10 @@ a {
text-decoration: underline;
font-weight: bold;
}
a.SameOrgLink {
color: red;
text-decoration: underline;
}
a:hover {
color: #367889;
text-decoration:none;