...
 
Commits (2)
......@@ -52,6 +52,7 @@ class event {
$secret,
$decision_time,
$submission_time;
var $role; // role of a localgroup for this event
var $tags; // array of tags
var $localgroups; // array of localgroups
var $error, $message;
......@@ -711,15 +712,17 @@ class event {
else
$this->tags = "";
unset($this->localgroups);
$this->localgroups = array();
if (isset($_POST['__event_lg_id']))
{ // get localgroups
$event_lg_id = $_POST['__event_lg_id'];
$event_lg_role = $_POST['__event_lg_role'];
foreach ($_POST['__event_lg_id'] as $form_id=>$lg_id) {
$lg = new localgroup($this->db, $lg_id);
$lg->role = $event_lg_role[$form_id];
$lg = new localgroup($this->db, $lg_id);
$lg->role = $event_lg_role[$form_id];
$this->localgroups[] = $lg;
}
$this->localgroups[] = $lg;
}
return true;
......@@ -1097,6 +1100,25 @@ PARTOFGEOJSON;
echo "</select>\n";
}
function toHtmlList()
{
$this->get();
$result = "<li>";
$result .= "<a href=\"showevent.php?id=" . $this->id . "\">";
$result .= stripslashes($this->title);
$result .= "</a>";
$result .= " en tant que ". $GLOBALS['adl_lg_role'][$this->role];
$startday = onlyday_timestamp2humanreadable(date_mysql2timestamp($this->start_time));
$endday = onlyday_timestamp2humanreadable(date_mysql2timestamp($this->end_time));
$result .= "<br/>";
if ($startday == $endday)
$result .= "le " . $startday . " ";
else
$result .= "du " . $startday . " au " . $endday . " ";
$result .= " à " . $this->city;
$result .= "</li>\n";
return $result;
}
}
?>
......@@ -58,14 +58,15 @@ class exportEvent {
function getEventsList()
{
$sql = "SELECT events.id AS id FROM {$GLOBALS['db_tablename_prefix']}events AS events";
$sqlSelect = "SELECT events.id AS id";
$sqlFrom = " FROM {$GLOBALS['db_tablename_prefix']}events AS events";
$sqlWhere = " WHERE (moderated=1)";
// event_id
if ($this->event_id != 0)
{
$sqlWhere .= " AND (events.id=". $this->db->quote_smart($this->event_id). ")";
$sql .= $sqlWhere;
//$sql .= $sqlWhere;
}
else
{
......@@ -99,11 +100,12 @@ class exportEvent {
// localgroup_id
if ($this->localgroup_id != 0)
{
$sql .= " LEFT JOIN {$GLOBALS['db_tablename_prefix']}localgroups_events AS le ON events.id=le.event_id";
$sqlSelect .= ",role ";
$sqlFrom .= " LEFT JOIN {$GLOBALS['db_tablename_prefix']}localgroups_events AS le ON events.id=le.event_id";
$sqlWhere .= " AND (localgroup_id=". $this->db->quote_smart($this->localgroup_id). ")";
}
$sql .= $sqlWhere;
$sql = $sqlSelect. $sqlFrom. $sqlWhere;
if (count($this->tags)>0 || $this->localgroup_id != 0)
$sql .= " GROUP BY events.id";
// past/future
......@@ -116,6 +118,16 @@ class exportEvent {
return $this->db->query($sql);
}
function htmlListStartCalendar()
{
return " <ul>\n";
}
function htmlListEndCalendar()
{
return " </ul>\n";
}
function get2fields()
{
$this->map = get_safe_integer('map', 0);
......
......@@ -42,7 +42,6 @@ class localgroup {
$department, $region, $region_id,
$reach; // array, department list
var $events; // array of events
var $role;
var $is_preview;
var $error, $message;
......@@ -141,23 +140,6 @@ class localgroup {
$this->reach[] = $this->department;
}
// get events - not loaded
$this->events = array();
$query = "SELECT le.* FROM {$GLOBALS['db_tablename_prefix']}localgroups_events le".
" LEFT JOIN {$GLOBALS['db_tablename_prefix']}events e ON event_id=e.id".
" WHERE (moderated=1) AND (localgroup_id=".
$this->db->quote_smart($this->id). ") ORDER BY e.start_time";
$result = $this->db->query ($query);
while ($record = $this->db->fetchObject($result))
{
$event = new event($this->db);
$event->id = $record->event_id;
$event->role = $record->role;
$this->events[] = $event;
unset($event);
}
$this->db->freeResult($result);
$this->message = "";
$this->error = false;
return true;
......@@ -571,9 +553,9 @@ MCE;
// -------------------------------------------------------------------
/**
* Format an event in an HTML format
* Format an localgroup in an HTML format
*
* @return A HTML description of the event
* @return A HTML description of the localgroup
*/
function formatHtml()
{
......@@ -617,38 +599,15 @@ MCE;
$result .= "<p>Soumetteur&nbsp;: {$submitter}</p>\n";
}
if (count($this->events)>0) {
$result .= "<h3>Le $adl_localgroup participe aux &eacute;v&eacute;nements suivants</h3>";
$result .= "<ul>\n";
foreach ($this->events as $event) {
$event->get();
$result .= "<li>";
$result .= "<a href=\"showevent.php?id=" . $event->id . "\">";
$result .= stripslashes($event->title);
$result .= "</a>";
$result .= " en tant que ". $GLOBALS['adl_lg_role'][$event->role];
$startday = onlyday_timestamp2humanreadable(date_mysql2timestamp($event->start_time));
$endday = onlyday_timestamp2humanreadable(date_mysql2timestamp($event->end_time));
$result .= "<br/>";
if ($startday == $endday)
$result .= "le " . $startday . " ";
else
$result .= "du " . $startday . " au " . $endday . " ";
$result .= " à " . $event->city;
$result .= "</li>\n";
} // endforeach
$result .= "</ul></p>\n";
}
return $result;
}
// -------------------------------------------------------------------
/**
* Format an event in an ASCII format, suitable for e-mails
* Format an localgroup in an ASCII format, suitable for e-mails
*
* @return An ASCII description of the event
* @return An ASCII description of the localgroup
*/
function formatAscii()
{
......@@ -677,7 +636,7 @@ MCE;
// -------------------------------------------------------------------
/**
* Format an event in an CSV format, suitable for OSM
* Format an localgroup in an CSV format, suitable for OSM
*
* @return A CSV description of the event with localisation
* lon\tlat\ttitle\tdescription\ticon\n
......
......@@ -22,6 +22,7 @@
include("inc/main.inc.php");
include_once("inc/class.localgroup.inc.php");
include_once("inc/class.export.inc.php");
$id = get_safe_integer('id', 0);
$localgroup = new localgroup($db, $id);
......@@ -34,6 +35,20 @@ if ($localgroup->error)
exit;
}
function displayEventList($eventList, $list)
{
echo $eventList->htmlListStartCalendar();
while ($event = $eventList->db->fetchObject($list))
{
$eventList->event->id = $event->id;
$eventList->event->role = $event->role;
$eventList->event->get();
echo $eventList->event->toHtmlList();
}
echo $eventList->htmlListEndCalendar();
}
if ($localgroup->latitude>0)
{
$lgUrl = calendar_absolute_url('exportlocalgroups.php');
......@@ -77,9 +92,36 @@ echo $localgroup->actionsHtml();
// Display localgroup details
echo $localgroup->formatHtml();
// Display map
if ($localgroup->latitude>0)
{
echo "<ul class='mist' id='map' style=\"margin: auto; width:70%; height:500px; border: 1px solid black;\"></ul>\n";
echo "<ul class='mist' id='map' style=\"margin: auto; width:70%; height:400px; border: 1px solid black;\"></ul>\n";
}
// Display events in relation with localgroup
$eventList = new exportEvent($db);
$eventList->localgroup_id = $id;
$eventList->daylimit = 90;
if (($list = $eventList->getEventsList()) == FALSE)
{
error ("Erreur lors de la récupération des évènements");
exit;
}
if ($db->numRows($list)>0) {
echo "<h3>Le $adl_localgroup participe aux prochains &eacute;v&eacute;nements suivants</h3>";
displayEventList($eventList, $list);
}
$eventList->past = true;
$eventList->daylimit = 30;
if (($list = $eventList->getEventsList()) == FALSE)
{
error ("Erreur lors de la récupération des évènements");
exit;
}
if ($db->numRows($list)>0) {
echo "<h3>Le $adl_localgroup participait aux &eacute;v&eacute;nements passés suivants</h3>";
displayEventList($eventList, $list);
}
put_footer();
......