...
 
Commits (15)
<a name="3.5.0"></a>
# [3.5.0](https://git.framasoft.org/agenda-libre/agenda-libre-php/compare/3.4.0...3.5.0) (2018-01-25)
### Bug Fixes
* **sql:** quote in region table ([77e5f36](https://git.framasoft.org/agenda-libre/agenda-libre-php/commit/77e5f36))
* allow only preview when editing new localgroup ([088d619](https://git.framasoft.org/agenda-libre/agenda-libre-php/commit/088d619))
* correct links in RSS subscribed in Firefox ([3c32d75](https://git.framasoft.org/agenda-libre/agenda-libre-php/commit/3c32d75)), closes [#42](https://git.framasoft.org/agenda-libre/agenda-libre-php/issues/42)
* hide context menu when not admin ([db7d422](https://git.framasoft.org/agenda-libre/agenda-libre-php/commit/db7d422))
* remove password from error message ([b329f1e](https://git.framasoft.org/agenda-libre/agenda-libre-php/commit/b329f1e))
* top of the page displayed twice when identification required ([e7140ca](https://git.framasoft.org/agenda-libre/agenda-libre-php/commit/e7140ca))
### Features
* Allow duplicate event. ([a970ff2](https://git.framasoft.org/agenda-libre/agenda-libre-php/commit/a970ff2)), closes [#6](https://git.framasoft.org/agenda-libre/agenda-libre-php/issues/6)
* improvement filter and export events ([f406a52](https://git.framasoft.org/agenda-libre/agenda-libre-php/commit/f406a52)), closes [#25](https://git.framasoft.org/agenda-libre/agenda-libre-php/issues/25)
* make easier purpose new event ([57724fd](https://git.framasoft.org/agenda-libre/agenda-libre-php/commit/57724fd)), closes [#37](https://git.framasoft.org/agenda-libre/agenda-libre-php/issues/37)
<a name="3.4.0"></a>
# [3.4.0](https://git.framasoft.org/agenda-libre/agenda-libre-php/compare/3.3.0...v3.4.0) (2017-06-16)
......
3.5.0-dev
3.6.0-dev
{
"name": "agenda-libre-php",
"version": "3.5.0-dev",
"version": "3.6.0-dev",
"description": "agenda libre is free software written in php that manages collaborative agenda",
"homepage": "https://git.framasoft.org/agenda-libre/agenda-libre-php",
"keywords": [
......
......@@ -50,7 +50,7 @@ SET @s = CONCAT("INSERT INTO ", @tablePrefix, "regions",
(24, 'Guyane'),
(25, 'Martinique'),
(26, 'Réunion'),
(27, 'Territoires d\'outre-mer'),
(27, 'Territoires d''outre-mer'),
(50, 'Autre pays');");
PREPARE stmt FROM @s;
EXECUTE stmt;
......
......@@ -94,9 +94,6 @@ $adl_notenough_message = "Votre évènement a tout à fait sa place dans l'Agend
$adl_double_message = "L'évènement que vous proposez est déjà présent dans ".
"l'Agenda.\n\n";
// rss.php
$adl_url = "http://localhost";
// exportlist.php
$adl_export_intro = "<p>Chaque flux RSS liste les évènements pour les 30 prochains jours en cours dans une région donnée. En vous abonnant à un flux régional, vous recevrez des informations sur les évènements à portée locale, mais également sur les évènements à portée nationale et internationale.</p>";
$adl_rss_more = "<p>Quelques fonctionnalités intéressantes des flux RSS&nbsp;:</p>\n".
......
<?php
/*
* Copyright 2008-2016
* Copyright 2008-2017
* - Thomas Petazzoni <thomas POINT petazzoni CHEZ enix POINT org>
* - Loic Dayot <ldayot CHEZ epnadmin POINT net>
*
......@@ -81,6 +81,8 @@ function updateEvent($user, $newEvent, $oldEvent)
$id = get_safe_integer('id', 0);
$secret = get_safe_hash('secret', false);
$thisTitle = "Édition d'un évènement";
// Get fields and store in $event object
if (isset($_POST['__event_save']) || isset($_POST['__event_preview']))
{
......@@ -94,7 +96,7 @@ if (isset($_POST['__event_save']) || isset($_POST['__event_preview']))
$event = new event($db, $id);
if ($event->error)
{
put_header("édition d'un évènement");
put_header($thisTitle);
error($event->message);
put_footer();
exit;
......@@ -110,7 +112,7 @@ else
{
if ($event->secret != $secret)
{
put_header("Édition d'un évènement");
put_header($thisTitle);
error("Hash d'identification non reconnu");
put_footer();
exit;
......@@ -124,7 +126,7 @@ if (isset($_POST['__event_save']) && $ret)
if ($returnaddr === false)
{
put_header("édition d'un évènement");
put_header($thisTitle);
error ("Problème lors de la sauvegarde de l'évènement <i>".
$_POST['__event_title'] . "</i>");
}
......@@ -142,7 +144,7 @@ if (isset($_POST['__event_save']) && $ret)
exit;
} // end if
put_header("édition d'un évènement");
put_header($thisTitle);
if (isset($message) && $message!="") echo $message;
......@@ -173,7 +175,7 @@ echo ($user ? "<a href=\"moderation.php\">Modération</a>&nbsp;" : "").
"&gt;&gt;&gt;&nbsp;&Eacute;dition de l'évènement";
echo "</p>";
echo '<div class="moderationbox">';
//echo '<div class="moderationbox">';
$posturl = "?id=" . $id. ($user ? "" : "&secret=" . $secret);
......@@ -181,7 +183,7 @@ if (isset($updatedEvent))
$updatedEvent->edit($_preview=true, $_valid=true, $posturl);
else
$event->edit($_preview=true, $_valid=true, $posturl);
echo '</div>';
//echo '</div>';
put_footer();
......
<?php
/*
* Copyright 2015
* Copyright 2015-2017
* - Loic Dayot <ldayot CHEZ epnadmin POINT net>
*
* This file is part of agenda-libre-php.
......@@ -35,18 +35,10 @@ $tagsE = array();
echo "<fieldset><legend>". _("Sélection"). "</legend>";
$export = new exportEvent($db);
$export->get2fields();
// Get tags from form
$export->getTagList('tags');
// Get tags ===
$aTags = (isset($_GET['tags']) ? $_GET['tags'] : array());
foreach ($aTags as $tags)
if (is_array($tags))
foreach ($tags as $tag)
$export->tags[] = $tag;
else
$export->tags[] = $tags;
$export->region = get_safe_integer('region', 'all');
$export->daylimit = get_safe_integer('daylimit', 30);
echo "<ul class='fa-ul'>\n";
echo " <li><i class='fa fa-li fa-rss'></i>&nbsp;Flux RSS 1.0 : <a href=\"". $export->rssUrl(). "\">". $export->rssUrl(). "</a>\n";
......@@ -54,6 +46,7 @@ echo " <li><i class='fa fa-li fa-rss'></i>&nbsp;Flux GeoRSS (sans les détails)
echo " <li><i class='fa fa-li fa-calendar'></i>&nbsp;Calendrier iCal : <a href=\"". $export->iCalUrl(). "\">". $export->iCalUrl(). "</a>\n";
echo " <li><i class='fa fa-li fa-google'></i>&nbsp;Google calendar : <a href=\"". $export->calGoogleUrl(). "\">". $export->calGoogleUrl(). "</a>\n";
echo " <li><i class='fa fa-li fa-code'></i>&nbsp;widget (JavaScript) : <code><a href=\"". $export->jsUrl(). "\">". $export->jsCode(). "</a></code>\n";
echo " <li><i class='fa fa-li fa-share'></i>&nbsp;web (liste dans le navigateur) : <code><a href=\"". $export->webUrl(). "\">". $export->webUrl(). "</a></code>\n";
echo "</ul>\n";
echo "</fieldset>\n";
......@@ -61,7 +54,6 @@ echo "</fieldset>\n";
echo "<form action=\"\" method=\"get\" enctype=\"multipart/form-data\">\n";
echo "<fieldset><legend>". _("Critères de sélection"). "</legend>";
// Select place
// Select place
$region = new region($db);
echo "<strong>". _("Région :") ."</strong> ". $region->selectHTML($export->region). " ";
......@@ -73,15 +65,18 @@ echo $export->selectDurationHTML($export->daylimit). " ";
$tagsHtml = new tagsHtml($db);
echo $tagsHtml->selectTagsHTML($export->tags);
// Select localgroup
$localgroups = new localgroups($db);
$localgroups->localgroup_id = $export->localgroup_id;
echo "<p>". $localgroups->selectHTML('localgroup'). "</p>\n";
echo " <input type=\"submit\" name=\"submit\" value=\"". _("Mettre à jour la sélection"). "\" /> <input type=\"reset\" name=\"reset\" value=\"". _("Réinitialiser"). "\" />\n";
echo "</fieldset>";
echo "</form>\n";
echo "<hr>\n";
echo $adl_rss_more;
echo "<hr>\n";
?>
......
<?php
/*
* Copyright 2004-2015
* Copyright 2004-2017
* - Thomas Petazzoni <thomas POINT petazzoni CHEZ enix POINT org>
* - Loic Dayot <ldayot CHEZ epnadmin POINT net>
*
......@@ -27,12 +27,7 @@ include("inc/main.inc.php");
include("inc/class.export.inc.php");
$eventList = new exportEvent($db);
$eventList->event_id = get_safe_integer('id', 0);
$eventList->region = get_safe_integer('region', 'all');;
$eventList->count = get_safe_integer('count', 10);
$eventList->daylimit = get_safe_integer('daylimit', 30);
$tag = get_safe_string('tag', '');
$eventList->tags = ($tag>'' ? explode(' ', $tag) : array());
$eventList->get2fields();
$list = $eventList->getEventsList();
if ($list == FALSE)
......
......@@ -30,38 +30,43 @@
class db
{
/**
* open a connection to the database
*
* @param $db_host the database server name
* @param $db_user the database login
* @param $db_pass the database password
* @param $db_charset the database charset
* @param $db_name the database name
* @return the database resource or throw an exception
*/
//function sqlConnect($db_host, $db_user, $db_pass, $db_charset = "UTF-8", $db_name)
function db()
{
global $db_host;
global $db_user;
global $db_pass;
//global $db_charset;
$db_charset = "UTF-8";
global $db_name;
if(@mysql_connect($db_host,$db_user,$db_pass)==FALSE)
{
echo "$db_host $db_user $db_pass";
echo "Probleme de connexion à la base de données sur $db_host.\n";
return 0;
}
if(@mysql_select_db($db_name) == FALSE)
{
echo "Problème de selection de la base de données $db_name sur $db_host.\n";
return 0;
}
mysql_query("set names 'utf8'");
try {
$dbResource = new PDO("mysql:host=$db_host;dbname=$db_name", $db_user, $db_pass);
$dbResource->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dbResource->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
$dbResource->exec("SET CHARACTER SET $db_charset");
} catch (PDOException $exception) {
throw $exception;
}
return $dbResource;
}
function query ($query)
{
if( ($result = @mysql_query($query)) == FALSE)
{
echo "Probleme dans la syntaxe de $query : " . mysql_error() . "\n";
return 0;
}
return $result;
$pdoResultSet = $dbResource->query($statement);
return $pdoResultSet;
//$pdoResultSet->closeCursor();
}
function insertid ()
......
......@@ -94,7 +94,7 @@ class event {
$this->end = strtotime($this->end_time);
$this->address = $record->address;
$this->place = $this->address;
$this->postalcode = $record->postalcode;
$this->postalcode = sprintf("%'.05d", $record->postalcode);
$this->city = $record->city;
$this->department = $record->department;
if ($this->department>0)
......@@ -341,11 +341,12 @@ class event {
echo "<form method=\"post\" name='event' action=\"{$postUrl}\">\n";
echo '<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>'.
'<script type="text/javascript" src="js/jquery-ui.min.js"></script>';
if (file_exists("tiny_mce"))
{
?>
<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="js/jquery-ui.min.js"></script>
<script type="text/javascript" src="https://openlayers.org/api/OpenLayers.js"></script>
<!-- tinyMCE -->
<script language="javascript" type="text/javascript" src="tiny_mce/tiny_mce.js"></script>
......@@ -930,10 +931,9 @@ class event {
$ret .= " <dc:date>" . $evt_date . $evt_timezone . "</dc:date>\n";
if ($this->longitude && $this->latitude)
$ret .= " <georss:point>" . $this->latitude . " " . $this->longitude . "</georss:point>\n";
$ret .= " <description>\n";
$ret .= $this->xmlentities(strip_tags($this->formatHTML()));
$ret .= " <description>\n";
$ret .= $this->xmlentities($map ? substr(strip_tags($this->formatHTML()),0,128) : strip_tags($this->formatHTML()));
$ret .= " </description>\n";
if (! $map)
{
......
<?php
/*
* Copyright 2015
* Copyright 2015-2017
* - Loic Dayot <ldayot CHEZ epnadmin POINT net>
*
* This file is part of agenda-libre-php.
......@@ -29,14 +29,15 @@ class exportEvent {
$count, // nombre d'événement
$tags, // tableau des tags
$past, // boolean true si dans le passé
$event_id; // 0 ou un numero ID d'evenement
$event_id, // 0 ou un numero ID d'evenement
$localgroup_id; // 0 ou un numero ID de groupe local
var $event; // objet event
var $error, $message;
var $db;
// -------------------------------------------------------------------
function exportEvent($db)
function __construct($db)
{
$this->region = "all";
$this->delay = 0;
......@@ -57,59 +58,104 @@ class exportEvent {
function getEventsList()
{
if ($this->past)
$sql = "SELECT events.id AS id FROM {$GLOBALS['db_tablename_prefix']}events AS events";
$sqlWhere = " WHERE (moderated=1)";
// event_id
if ($this->event_id != 0)
{
if ($this->daylimit !=0)
$start = time() - ($this->daylimit * 24 * 60 * 60);
$end = time();
$sqlWhere .= " AND (events.id=". $this->db->quote_smart($this->event_id). ")";
$sql .= $sqlWhere;
}
else
{
$start = time();
if ($this->daylimit !=0)
$end = time() + ($this->daylimit * 24 * 60 * 60);
}
$sql = "SELECT events.id as id FROM {$GLOBALS['db_tablename_prefix']}events AS events";
$sqlWhere = " WHERE (moderated=1)";
if (isset($start))
$sqlWhere .= " AND (end_time >= '" . date_timestamp2mysql($start) . "') ";
if (isset($end))
$sqlWhere .= " AND (start_time <= '" . date_timestamp2mysql($end) . "')";
// past/future and daylimit
if ($this->past)
{
if ($this->daylimit !=0)
$start = time() - ($this->daylimit * 24 * 60 * 60);
$end = time();
}
else
{
$start = time();
if ($this->daylimit !=0)
$end = time() + ($this->daylimit * 24 * 60 * 60);
}
if (isset($start))
$sqlWhere .= " AND (end_time >= '" . date_timestamp2mysql($start) . "') ";
if (isset($end))
$sqlWhere .= " AND (start_time <= '" . date_timestamp2mysql($end) . "')";
// tags
if (count($this->tags)>0)
foreach ($this->tags as $categoryId=>$tag)
{
$sqlWhere .= " AND '{$tag}' IN (SELECT name FROM {$GLOBALS['db_tablename_prefix']}tags AS tags".
" LEFT JOIN {$GLOBALS['db_tablename_prefix']}tags_events AS te ON te.tag_id=tags.id WHERE te.event_id=events.id)";
}
// region
if ($this->region != "all")
$sqlWhere .= " AND ((region=" . $this->db->quote_smart($this->region) . ") OR (locality>=1))";
// localgroup_id
if ($this->localgroup_id != 0)
{
$sql .= " 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). ")";
}
if (count($this->tags)>0)
foreach ($this->tags as $categoryId=>$tag)
{
$sqlWhere .= " AND '{$tag}' IN (SELECT name FROM {$GLOBALS['db_tablename_prefix']}tags AS tags".
" LEFT JOIN {$GLOBALS['db_tablename_prefix']}tags_events AS te ON te.tag_id=tags.id WHERE te.event_id=events.id)";
$sql .= $sqlWhere;
if (count($this->tags)>0 || $this->localgroup_id != 0)
$sql .= " GROUP BY events.id";
// past/future
$sql .= " ORDER BY start_time ". ($this->past ? "DESC" : "ASC");
// count
if ($this->count > 0)
$sql .= " LIMIT ". $this->count;
}
if ($this->region != "all")
$sqlWhere .= " AND ((region=" . $this->db->quote_smart($this->region) . ") OR (locality>=1))";
if ($this->event_id != 0)
$sqlWhere .= " AND (events.id=". $this->db->quote_smart($this->event_id). ")";
$sql .= $sqlWhere;
if (count($this->tags)>0)
$sql .= " GROUP BY events.id";
$sql .= " ORDER BY start_time ". ($this->past ? "DESC" : "ASC");
//var_dump($sql);
return $this->db->query($sql);
}
function get2fields($get)
function get2fields()
{
$this->map = get_safe_integer('map', 0);
$this->region = get_safe_integer('region', 'all');
$this->count = get_safe_integer('count', 10);
$this->daylimit = get_safe_integer('daylimit', 30);
$this->event_id = get_safe_integer('event_id', 0);
$this->localgroup_id = get_safe_integer('localgroup_id', 0);
$this->getTagList('tag');
}
function getTagList($fieldName)
{
// Get tags ===
$aTags = (isset($_GET[$fieldName]) ? $_GET[$fieldName] : array());
if (!is_array($aTags))
{
$aTags = explode(' ', $aTags);
}
foreach ($aTags as $tags)
{
if (is_array($tags))
{
foreach ($tags as $tag)
{
$this->tags[] = $tag;
}
}
else
{
$this->tags[] = $tags;
}
}
return;
}
// -------------------------------------------------------------------
private function partOfUrl()
{
// tags
$urltags = "";
$aTags = $this->tags;
foreach ($aTags as $tags)
......@@ -130,11 +176,19 @@ class exportEvent {
}
if ($urltags>"")
$urltags = "&tag=". $urltags;
$url = "region=". $this->region.
($this->daylimit!=30 && isset($_GET["daylimit"]) ? "&daylimit=". $_GET["daylimit"] : "").
$urltags;
// region
$url = "region=". $this->region;
// delay
if (($this->daylimit!=30))
$url .= "&daylimit=". $this->daylimit;
// localgroup
if ($this->localgroup_id>0)
$url .= "&localgroup_id=". $this->localgroup_id;
// event
if ($this->event_id>0)
$url .= "&event_id=". $this->event_id;
$url .= $urltags;
return $url;
}
......@@ -210,6 +264,13 @@ class exportEvent {
$this->jsUrl(). "\"></script>\n");
}
// -------------------------------------------------------------------
function webUrl()
{
return calendar_absolute_url("listevents.php?". $this->partOfUrl());
}
// iCal ------------------------------------------------------------
function icalStartCalendar()
......@@ -275,12 +336,12 @@ class exportEvent {
$ret .= " <title>". $adl_short_title;
if ($this->region != "all")
{
$regionName = region_find($db, $this->region);
$ret .= " [ " . $regionName . " ]";
$region = new region($this->db, $this->region);
$ret .= " [ " . $region->name . " ]";
}
$ret .= "</title>\n".
" <description>". $adl_title." ".$adl_subtitle. "</description>\n".
" <link>{$adl_url}</link>\n".
" <link>". calendar_absolute_url(). "</link>\n".
" <dc:language>fr</dc:language>\n".
" <dc:creator>AgendaDuLibre.org</dc:creator>\n";
......
......@@ -86,7 +86,7 @@ class localgroup {
$this->address = $record->address;
$this->place = $this->address;
$this->postalcode = $record->postalcode;
$this->postalcode = sprintf("%'.05d", $record->postalcode);
$this->city = $record->city;
$this->department = floor($this->postalcode/1000);
if ($this->department==97)
......@@ -452,7 +452,7 @@ MCE;
/* text */
foreach (array('name', 'url', 'place',
'address', 'postalcode', 'city', 'country',
'address', /*'postalcode',*/ 'city', 'country',
'osmId', 'contact', 'phone', 'mail',
'reach', 'submitter') as $fieldName)
{
......@@ -461,6 +461,8 @@ MCE;
}
if (isset($_POST['lg']['lon'])) $this->longitude = $_POST['lg']['lon'];
if (isset($_POST['lg']['lat'])) $this->latitude = $_POST['lg']['lat'];
if (isset($_POST['lg']['postalcode']))
$this->postalcode = sprintf("%'.05d", $_POST['lg']['postalcode']);
/* html code */
$aFieldName = array('comment');
......@@ -1026,7 +1028,7 @@ class localgroups {
$query = $select. $where.
" ORDER BY ". ($this->moderated ? "region_id, department, name" : "region_id, submission_time").
($this->partOfName>"" ? " LIMIT 0,30" : " LIMIT 0,300");
($this->partOfName>"" ? " LIMIT 0,30" : " LIMIT 0,800");
$result = $this->db->query ($query);
while (($record = $this->db->fetchObject($result)))
......@@ -1195,4 +1197,35 @@ class localgroups {
return json_encode($vals);
}
// -----------------------------------------------------------------
// Present part of form to choose one localgroup
function selectHTML()
{
$html = "";
$html .= "<script type='text/javascript' src='js/jquery-3.2.1.min.js'></script>\n";
$html .= "<script type='text/javascript' src='js/jquery-ui.min.js'></script>\n";
$html .= "<script type='text/javascript' src='js/findLocalgroup.js'></script>\n";
$html .= "<strong>". ucfirst($GLOBALS['adl_localgroup']). " :</strong> ";
if ($this->localgroup_id>0)
{
$this->get();
reset($this->localgroups);
$localgroup = current($this->localgroups);
}
$html .="<span id='lg-container'>
<input type='text' placeholder=\"Saisir une partie du nom du {$GLOBALS['adl_localgroup']}\"
id='lg_name' ";
if (isset($localgroup))
{
$html .= "value='{$localgroup->name} ({$localgroup->department})' ";
}
$html .= "/>
</span>
<span id='loading' class='loading' style='display:none;'>
<i class='fa fa-circle-o-notch fa-spin'></i></span>
<input type='hidden' name='localgroup_id' value='{$this->localgroup_id}'/>
</select>\n";
return $html;
}
}
......@@ -49,7 +49,7 @@ class user
}
return $ret;
}
private function get_from_sql($sql)
{
$ret = $this->query($sql);
......@@ -68,7 +68,7 @@ class user
{
$sql =
"SELECT id FROM {$GLOBALS['db_tablename_prefix']}users WHERE login=".
$this->db->quote_smart($login).
$this->db->quote_smart($login).
($exceptId!=null ? " AND id<>". $this->db->quote_smart($exceptId) : "");
$row = $this->get_from_sql($sql);
return is_object($row) ? $row->id : false;
......@@ -88,7 +88,7 @@ class user
function get()
{
$sql = "select * from {$GLOBALS['db_tablename_prefix']}users where id=" .
$sql = "select * from {$GLOBALS['db_tablename_prefix']}users where id=" .
$this->db->quote_smart(!isset($this->id) ? $this->session->value("agenda_libre_id") : $this->id);
$row = $this->get_from_sql($sql);
if (! $row || ! is_object($row)) return false;
......@@ -120,10 +120,10 @@ class user
$this->message = returnError("La requête <i>". $sql. "</i> a échoué");
return false;
}
if (!isset($this->id))
$this->id = $this->db->insertid();
return true;
} // end function save();
......@@ -136,7 +136,7 @@ class user
$this->message = returnError("La requête <i>". $sql. "</i> a échoué");
return false;
}
return true;
} // end function delete();
......@@ -188,6 +188,7 @@ class user
{
if (! isset($_POST['__user_identify']))
{
ob_end_clean();
put_header("Accès réservé");
echo "<h2>Identification</h2>";
......@@ -212,6 +213,7 @@ class user
}
else
{
ob_end_clean();
put_header("Accès réservé");
echo returnError("Mauvais identifiant/mot de passe");
put_footer();
......@@ -220,7 +222,7 @@ class user
}
}
}
/* Presente un formulaire d'edition d'utilisateur */
function edit($postUrl='moderateusers.php')
{
......@@ -249,16 +251,16 @@ class user
echo "<tr><td>Rôle*:</td>".
"<td><label>Le rôle d'administrateur donne le droit de gérer les comptes de tous les utilisateurs</label>".
"<br/><select name='__user_admin'/>".
"<option value='0'". ($this->admin ? '' : ' selected').
"<option value='0'". ($this->admin ? '' : ' selected').
($this->id==$this->session->value("agenda_libre_id") ? ' disabled' : ''). ">modérateur</option>".
"<option value='1'". ($this->admin ? ' selected' : ''). ">administrateur</option>";
"</td></tr>\n";
echo "<tr class='even'><td></td><td><input type=\"submit\" name=\"__user_form\" value=\"Envoyer\"></td></tr>\n";
echo "</table>\n";
echo "</form>\n";
}
/* Presente un formulaire de suppression d'utilisateur */
function delForm($postUrl='moderateusers.php')
{
......@@ -279,7 +281,7 @@ class user
function fromForm()
{
$afieldName = array('id', 'login', 'password',
$afieldName = array('id', 'login', 'password',
'password2', 'email', 'lastname', 'firstname');
foreach ($afieldName as $fieldName)
{
......@@ -288,13 +290,13 @@ class user
else
unset($this->$fieldName);
}
if (isset($_POST['__user_admin']))
$this->admin = ($_POST['__user_admin'] == 1);
return true;
}
function check()
{
if (!isset($_POST['__user_form']))
......@@ -329,7 +331,7 @@ class user
$this->message .= returnError("Identifiant déjà utilisé.");
return (""==$this->message);
}
function checkDel()
{
if (!isset($_POST['__user_delform']))
......@@ -354,7 +356,7 @@ class user
$output .= "<td>". ($this->admin ? 'admin' : ''). "</td>";
return $output;
}
function listHTML()
{
$return = "<table class='stats'>\n";
......@@ -369,7 +371,7 @@ class user
$return .= "<tr". ($impair ? " class='even'" : ""). ">". $this->formatTrHtml();
$return .= "<td>".
"<a href='?op=edit&id={$this->id}'>Editer</a>".
($this->session->value("agenda_libre_id")!=$this->id && !$this->admin ?
($this->session->value("agenda_libre_id")!=$this->id && !$this->admin ?
" - <a href='?op=del&id={$this->id}'>Supprimer</a>" : "").
"</td>";
$return .= "</tr>\n";
......@@ -379,5 +381,5 @@ class user
$return .= "</table>\n";
return $return;
}
}
......@@ -44,6 +44,11 @@ function calendar_absolute_url($url='', $protocol='')
{
global $root;
$root = rtrim ($root, "/");
if ($protocol == '')
{
$protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on') ? 'https:' : 'http:';
}
return $protocol . "//" . $root . "/" . $url;
}
......@@ -474,7 +479,11 @@ global $maxEventsInCalendar;
else
echo " <td class=\"current_month\"><h1>";
calendar_custom_icon($campaigns, $year, $month, $day);
echo $day;
$thisDate = onlyday_timestamp2humanreadable($curtime);
echo "<a href=\"showoneday.php?date=".
substr(date_timestamp2mysql($curtime),0,10). "\" title=\"".
sprintf( _("Les évènements du %s"), $thisDate ). "\">". $day. "</a> ";
echo "<a href='submit.php?start=$curtime' title='Proposer un &eacute;v&eacute;nement'><i class='fa fa-pencil'></i></a>";
echo "</h1>\n";
show_day_events ($db, $day, $month, $year, $region, $maxEventsInCalendar);
echo "</td>\n";
......
<?php
/*
* Copyright 2008-2015
* Copyright 2008-2017
* - Loic Dayot <ldayot CHEZ epnadmin POINT net>
*
* This file is part of agenda-libre-php.
......@@ -31,11 +31,7 @@ include("inc/main.inc.php");
include("inc/class.export.inc.php");
$eventList = new exportEvent($db);
$eventList->region = get_safe_integer('region', 'all');;
$eventList->count = get_safe_integer('count', 10);
$eventList->daylimit = get_safe_integer('daylimit', 30);
$tag = get_safe_string('tag', '');
$eventList->tags = ($tag>'' ? explode(' ', $tag) : array());
$eventList->get2fields();
$list = $eventList->getEventsList();
if ($list == FALSE)
......@@ -47,8 +43,8 @@ if ($list == FALSE)
echo $eventList->jsStartCalendar();
while ($eventList->event->id = $db->getOne($list))
{
$eventList->event->get();
echo $eventList->event->toJs();
$eventList->event->get();
echo $eventList->event->toJs();
}
echo $eventList->jsEndCalendar();
......
<?php
/*
* Copyright 2007-2017
* - Mélanie Bats <melanie POINT bats CHEZ utbm POINT fr>
......@@ -52,29 +51,23 @@ function list_events($events)
echo " </ul>\n";
}
put_header("Liste d'évènements");
$hasevent = FALSE;
/* Fetch region name */
$region_num = get_safe_integer('region', 'all');
if ($region_num != "all")
$region = region_find($db, $region_num);
$eventList = new exportEvent($db);
$eventList->get2fields();
$events = $eventList->getEventsList();
if ($eventList->region != "all")
{
$region = new region($db, $eventList->region);
$region = $region->name;
}
else
$region = $adl_all_region;
$daylimit = get_safe_integer('daylimit', 0);
// Get tags ===
$tag = get_safe_string('tag', '');
$aTags = ($tag>'' ? explode(' ', $tag) : array());
echo "<h2>Les évènements <i>" . $tag . "</i></h2>\n";
$hasevent = FALSE;
put_header("Liste d'évènements");
$eventList = new exportEvent($db);
$eventList->region = $region_num;
$eventList->daylimit = $daylimit;
$eventList->tags = $aTags;
$events = $eventList->getEventsList();
echo "<h2>Les évènements $region <i>" . implode(' ', $eventList->tags) . "</i></h2>\n";
if (! $events)
{
......@@ -86,10 +79,10 @@ if (! $events)
// display exports url
echo "<div class='list-group'>Ces événements en flux ";
echo "<a class='list-group-items' href=\"". $eventList->rssUrl(). "\"><i class='fa fa-rss'></i>&nbsp;RSS</a>&nbsp; ";
echo "<a class='list-group-items' href=\"ical.php?tag=" . $tag ."\"><i class='fa fa-calendar'></i>&nbsp;iCal</a>&nbsp; ";
echo "<a class='list-group-items' href=\"javascript.php?tag=" . $tag ."\"><i class='fa fa-connectdevelop'></i>&nbsp;JavaScript</a>&nbsp; ";
echo "<a class='list-group-items' href=\"http://www.google.com/calendar/render?cid=". calendar_absolute_url("ical.php?tag=".
$tag). "\"><i class='fa fa-google'></i>&nbsp;calendrier Google</a>";
echo "<a class='list-group-items' href=\"". $eventList->icalUrl(). "\"><i class='fa fa-calendar'></i>&nbsp;iCal</a>&nbsp; ";
echo "<a class='list-group-items' href=\"". $eventList->jsUrl(). "\"><i class='fa fa-connectdevelop'></i>&nbsp;JavaScript</a>&nbsp; ";
echo "<a class='list-group-items' href=\"http://www.google.com/calendar/render?cid=".
$eventList->calGoogleUrl(). "\"><i class='fa fa-google'></i>&nbsp;calendrier Google</a>";
echo "</p>";
if ($db->numRows($events))
......@@ -133,7 +126,7 @@ if ($db->numRows($events))
}
if (! $hasevent)
echo "<p>Aucun évènement avec ce tag.</p>";
echo "<p>Aucun évènement avec ce filtre.</p>";
put_footer();
?>
......
......@@ -4,7 +4,7 @@
* Copyright 2004-2017
* - Mélanie Bats <melanie POINT bats CHEZ utbm POINT fr>
* - Thomas Petazzoni <thomas POINT petazzoni CHEZ enix POINT org>
* - Loic Dayot <ldayot CHEZ ouvaton POINT org>
* - Loic Dayot <ldayot CHEZ epnadmin POINT net>
*
* This file is part of agenda-libre-php.
*
......@@ -23,6 +23,7 @@
*/
include("inc/main.inc.php");
include("inc/class.export.inc.php");
$jcode = "
<script src=\"https://openlayers.org/api/OpenLayers.js\"></script>
......@@ -51,17 +52,57 @@ $jcode = "
map.setCenter (lonLat, zoom);
var newl = new OpenLayers.Layer.GeoRSS('AdL', '" . calendar_absolute_url("rss.php?region=all&map=1&daylimit=0") . "');
var newl = new OpenLayers.Layer.GeoRSS('AdL', '%s');
map.addLayer(newl);
";
$oRegion = new region($db);
foreach ($oRegion->getList() as $aRegion)
{
$jcode .= " var newl = new OpenLayers.Layer.Text(\"{$adl_localgroups_acronym}-".
$aRegion['name']. "\", {location: '" .
calendar_absolute_url("localgrouptextlist.php?region={$aRegion['id']}") . "', visibility: false});\n".
" map.addLayer(newl);\n";
}
$jcode .= "
}
</script>\n";
$export = new exportEvent($db);
$export->daylimit = get_safe_integer('daylimit', 30);
$export->getTagList('tags');
$url = $export->rssGeoUrl();
$jcode = sprintf($jcode, $url);
put_header("Carte", $jcode, "init();");
//echo $url;
echo "<h2>Carte des événements</h2>\n";
echo "<form action=\"\" method=\"get\" enctype=\"multipart/form-data\">\n";
echo "<fieldset><legend>". _("Critères de sélection"). "</legend>";
// Select duration
echo $export->selectDurationHTML($export->daylimit). " ";
// Select tags
$tagsHtml = new tagsHtml($db);
echo $tagsHtml->selectTagsHTML($export->tags);
echo " <input type=\"submit\" name=\"submit\" value=\"". _("Mettre à jour la sélection").
"\" /> <input type=\"reset\" name=\"reset\" value=\"". _("Réinitialiser"). "\" />\n";
echo "</fieldset>";
echo "</form>\n";
echo "<hr>\n";
echo "<div style=\"margin: auto; width:70%; height:600px; border: 1px solid black;\" id=\"map\"></div>\n";
put_footer();
......
......@@ -52,6 +52,19 @@ $region_id = get_safe_integer('region', 0);
*
*/
// context links
if ($user->is_admin()) {
echo "<div id=\"localgroup-list\">";
echo "<h1>Actions</h1>\n";
echo "<br/><a href=\"moderatelocalgroups.php\"><i class='fa fa-gavel'></i> ". $adl_localgroups_acronym. " ".
_("en attente de mod&eacute;ration"). "</a>".
"<br/><a href=\"moderatelocalgroups.php?op=list\"><i class='fa fa-list-ul'></i> ".
_("Liste des"). " {$adl_localgroups_acronym}</a>".
"<br/><a href=\"moderatelocalgroups.php?op=new\"><i class='fa fa-plus-square-o'></i> ".
_("Nouveau"). " {$adl_localgroups_acronym}</a></p>\n";
echo "</div>\n";
}
switch ($op) // compute
{
......@@ -199,7 +212,7 @@ switch ($op) // display
{
echo "<h3>Édition d'un nouveau {$adl_localgroup}</h3>";
$localgroup = new localgroup($db, 0);
echo $localgroup->formHtml(false);
echo $localgroup->formHtml(false, true, false);
break;
}
......@@ -207,18 +220,23 @@ switch ($op) // display
{
$localgroup = new localgroup($db, $localgroup_id);
echo "<h3>Édition d'après un {$adl_localgroup} existant</h3>";
echo $localgroup->formHtml(true);
echo $localgroup->formHtml(true, true, false);
break;
}
case 'edit' :
{
// TODO : accept edit with secret code
$user->identify();
$localgroup = new localgroup($db, $localgroup_id);
echo "<h3>Édition</h3>";
echo $localgroup->formHtml(false, true, false);
break;
}
case 'edit2' :
{
echo "<h3>Édition</h3>";
echo $localgroup->formHtml(false);
echo $localgroup->formHtml(false, true, true);
break;
}
......@@ -287,14 +305,6 @@ switch ($op) // display
} // end switch display
// context links
echo "<hr/><p>". ucfirst($adl_localgroups).
" <a href=\"moderatelocalgroups.php\"><i class='fa fa-gavel'></i> ".
_("en attente de mod&eacute;ration"). "</a>".
" - <a href=\"moderatelocalgroups.php?op=list\"><i class='fa fa-list-ul'></i> ".
_("liste"). "</a>".
" - <a href=\"moderatelocalgroups.php?op=new\"><i class='fa fa-plus-square-o'></i> ".
_("nouveau"). "</a></p>\n";
put_footer();
......
<?php
/*
* Copyright 2004-2015
* Copyright 2004-2017
* - Mélanie Bats <melanie POINT bats CHEZ utbm POINT fr>
* - Thomas Petazzoni <thomas POINT petazzoni CHEZ enix POINT org>
* - Loic Dayot <ldayot CHEZ epnadmin POINT net>
......@@ -28,30 +28,12 @@ include("inc/main.inc.php");
include_once("inc/class.event.inc.php");
include_once("inc/class.export.inc.php");
$event_id = get_safe_integer('id', 0);
$eventList = new exportEvent($db);
$eventList->map = get_safe_integer('map', 0);
$eventList->get2fields();
echo $eventList->rssStartCalendar();
/* Generate item list */
if ($event_id==0)
{
$eventList->region = get_safe_integer('region', 'all');
$eventList->count = get_safe_integer('count', 10);
$eventList->daylimit = get_safe_integer('daylimit', 30);
$tag = get_safe_string('tag', '');
$eventList->tags = ($tag>'' ? explode(' ', $tag) : array());
$list = $eventList->getEventsList();
}
else
{
$sql = "SELECT events.id as id ".
"FROM {$GLOBALS['db_tablename_prefix']}events AS events ".
"WHERE id=". $db->quote_smart($event_id). " AND (moderated=1)";
$list = $db->query($sql);
}
$list = $eventList->getEventsList();
if ($list == FALSE)
{
......@@ -65,25 +47,13 @@ while ($eventList->event->id = $db->getOne($list))
}
echo $eventList->rssEndHeaderCalendar();
/* Generate items */
if ($event_id==0)
$list = $eventList->getEventsList();
else
{
$list = $db->query($sql);
}
if ($list == FALSE)
{
echo "Erreur lors de la récupération des évènements";
exit;
}
$list = $eventList->getEventsList();
while ($eventList->event->id = $db->getOne($list))
{
$eventList->event->get();
echo $eventList->event->toRss($eventList->map);
} // end while
}
echo $eventList->rssEndCalendar();
?>
......@@ -57,7 +57,7 @@ regions = {
}
baseUrl = "http://agenda.example.org"
agendaVersion = "3.5.0-dev"
agendaVersion = "3.6.0-dev"
def Usage():
print u"""Soumettre un évènement dans l'Agenda du Libre
......
......@@ -86,7 +86,7 @@ if ($event->latitude>0)
calendar_absolute_url("localgrouptextlist.php?". (isset($r) ? "region={$r}" : "depart={$event->department}")) . "'});
map.addLayer(newl);
var newl = new OpenLayers.Layer.GeoRSS('AdL', '" . calendar_absolute_url("rss.php?map=1&id={$event_id}") . "');
var newl = new OpenLayers.Layer.GeoRSS('AdL', '" . calendar_absolute_url("rss.php?map=1&event_id={$event_id}") . "');
map.addLayer(newl);
}
......@@ -109,7 +109,8 @@ echo $campaigns->returnTagMessage($event->tags);
// Display actions in context div
echo "<h1>Actions</h1>\n";
echo "<a href=\"ical.php?id=". $event_id. "\" title=\"Export au format iCal\"><i class='fa fa-calendar'></i> Ajouter à mon calendrier</a><br/>";
echo "<a href=\"ical.php?event_id=". $event_id. "\" title=\"Export au format iCal\"><i class='fa fa-calendar'></i> Ajouter à mon calendrier</a><br/>";
echo "<a href=\"submit.php?id=" . $event_id . "&new\"><i class='fa fa-files-o'></i> Dupliquer évènement</a><br/>";
if ($session->exists('agenda_libre_id'))
{ // moderateur
echo "<a href=\"editevent.php?id=" . $event_id . "\"><i class='fa fa-pencil'></i> &Eacute;diter évènement</a><br/>";
......
<?php
/*
* Copyright 2004-2015
* Copyright 2004-2017
* - Mélanie Bats <melanie POINT bats CHEZ utbm POINT fr>
* - Thomas Petazzoni <thomas POINT petazzoni CHEZ enix POINT org>
* - Loic Dayot <ldayot CHEZ ouvaton POINT org>
* - Loic Dayot <ldayot CHEZ epnadmin POINT net>
*
* This file is part of agenda-libre-php.
*
......@@ -36,6 +36,14 @@ put_header("Tous les événements du ". $human_date);
echo "<h2>Tous les événements du ". $human_date. "</h2>\n\n";
echo "<div id=\"localgroup-list\">\n";
// Display actions in context div
echo "<h1>Actions</h1>\n";
echo "<a href='submit.php?start=". strtotime($date). "'>".
"<i class='fa fa-pencil'></i>Proposer un &eacute;v&eacute;nement</a>\n";
echo "</h1>";
echo "</div>\n";
show_day_events ($db, $day, $month, $year, $region="all", $count=100);
put_footer();
......
<?php
/*
* Copyright 2004-2015
* Copyright 2004-2017
* - Melanie Bats <melanie POINT bats CHEZ utbm POINT fr>
* - Thomas Petazzoni <thomas POINT petazzoni CHEZ enix POINT org>
* - Loic Dayot <ldayot CHEZ epnadmin POINT net>
......@@ -29,9 +29,14 @@ put_header("Soumettre un évènement");
echo "<h2>Soumettre un évènement</h2>";
$event = new event($db, 0);
$event->start = time();
$event->end = time() + 60*60;
// get id in case of duplicate event request
$id = get_safe_integer('id', 0);
$event = new event($db, $id);
// in case of duplicate event request, forget original id
$event->id = 0;
$event->start = get_safe_integer('start', time());
$event->end = $event->start + 60*60;
function alertModerators ($event)
{
......