Skip to content
This repository has been archived by the owner on Jul 7, 2024. It is now read-only.

build: version 3.0.0, compat SPIP 4.1 mini #9

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

[*]
indent_style = tab
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = false
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/phpstan.neon.dist export-ignore
/phpstan-baseline.neon export-ignore
/phpstan-constants.php export-ignore
/.gitignore export-ignore
/.gitattributes export-ignore
/tests/ export-ignore
/phpunit.xml.dist export-ignore
/.php-cs-fixer.dist.php export-ignore
/.editorconfig export-ignore
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/vendor/
/composer.lock
/.phpunit.cache
/phpunit.xml
/.php-cs-fixer.cache
/.php-cs-fixer.php
/phpstan.neon
/bin/
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions action/seenthis_reactiver_flux.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ function action_seenthis_reactiver_flux_dist() {
$id_auteur = intval(_request('id_auteur'));
$cle = _request('cle');

include_spip("inc/securiser_action");
include_spip('inc/securiser_action');
if (verifier_cle_action("seenthis_reactiver_flux,$id_auteur", $cle)) {
// reactiver le flux (s'il commence bien par une étoile)
$s = sql_query("SELECT login,rss FROM spip_auteurs WHERE id_auteur = $id_auteur");
if ($t = sql_fetch($s) and substr($t['rss'], 0, 1) == '*') {
spip_log("reactivation du flux RSS de ". $t['login'] . " (". $id_auteur .") : ". ltrim($t['rss'], '*'), 'flux');
spip_log('reactivation du flux RSS de ' . $t['login'] . ' (' . $id_auteur . ') : ' . ltrim($t['rss'], '*'), 'flux');
// mettre à jour le champ en_ligne à la date courante
sql_updateq('spip_auteurs', array('en_ligne' => date('Y-m-d H:i:s')), 'id_auteur =' . $id_auteur);
sql_updateq('spip_auteurs', ['en_ligne' => date('Y-m-d H:i:s')], 'id_auteur =' . $id_auteur);
// retirer * au début de l'url du flux pour le réactiver
sql_updateq('spip_auteurs', array('rss' => ltrim($t['rss'], '*')), 'id_auteur =' . $id_auteur);
sql_updateq('spip_auteurs', ['rss' => ltrim($t['rss'], '*')], 'id_auteur =' . $id_auteur);
}
// redirect
$GLOBALS['redirect'] = $GLOBALS['meta']['adresse_site'];
} else {
include_spip('inc/minipres');
echo minipres();
}
}
}
18 changes: 10 additions & 8 deletions base/seenthis_importer_flux.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,28 @@
*
*/

if (!defined('_ECRIRE_INC_VERSION')) return;
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}

function seenthis_importer_flux_declarer_champs_extras($champs = array()) {
function seenthis_importer_flux_declarer_champs_extras($champs = []) {

// Table : spip_auteurs
if (!is_array($champs['spip_auteurs'])) {
$champs['spip_auteurs'] = array();
$champs['spip_auteurs'] = [];
}

$champs['spip_auteurs']['rss'] = array (
$champs['spip_auteurs']['rss'] = [
'saisie' => 'input',
'options' => array (
'options' => [
'nom' => 'rss',
'label' => 'RSS',
'sql' => "varchar(256) DEFAULT NULL",
'sql' => 'varchar(256) DEFAULT NULL',
'rechercher' => 1,
'obligatoire' => false,
'versionner' => true
)
);
]
];

return $champs;
}
18 changes: 18 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "seenthis/importer-flux",
"description": "Importation de flux RSS par les auteurs de Seenthis",
"license": "GPL-3.0-or-later",
"type": "spip-plugin",
"authors": [
{
"name": "Fil",
"email": "[email protected]"
}
],
"require": {},
"extra": {
"branch-alias": {
"dev-master": "3.0.x-dev"
}
}
}
14 changes: 7 additions & 7 deletions genie/seenthis_desactiver_flux.php
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
<?php

if (!defined("_ECRIRE_INC_VERSION")) {
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}

function genie_seenthis_desactiver_flux($t){
function genie_seenthis_desactiver_flux($t) {
if (!defined('_SEENTHIS_IMPORTER_FLUX_DELAI_INACTIF')) {
define('_SEENTHIS_IMPORTER_FLUX_DELAI_INACTIF', 86400 * 31 * 6);
}

$mydate = sql_quote(date("Y-m-d H:i:s", time() - _SEENTHIS_IMPORTER_FLUX_DELAI_INACTIF));
$mydate = sql_quote(date('Y-m-d H:i:s', time() - _SEENTHIS_IMPORTER_FLUX_DELAI_INACTIF));

$s = sql_query("SELECT id_auteur,login,en_ligne,email,rss FROM spip_auteurs WHERE rss > '' AND LEFT(rss,1) != '*' AND en_ligne < $mydate ORDER BY en_ligne DESC LIMIT 1");

if ($t = sql_fetch($s)) {
spip_log("desactivation du flux RSS de ". $t['login'] . " (". $t['id_auteur'] .") : ". $t['rss'], 'flux');
spip_log('desactivation du flux RSS de ' . $t['login'] . ' (' . $t['id_auteur'] . ') : ' . $t['rss'], 'flux');
// ajouter une * au début de l'url du flux pour le désactiver
sql_updateq('spip_auteurs', array('rss' => '*' . $t['rss']), 'id_auteur =' . $t['id_auteur']);
sql_updateq('spip_auteurs', ['rss' => '*' . $t['rss']], 'id_auteur =' . $t['id_auteur']);
// preparer le lien vers l'action de reactivation
include_spip('inc/securiser_action');
$cle = calculer_cle_action('seenthis_reactiver_flux,' . $t['id_auteur']);
$url = generer_url_action('seenthis_reactiver_flux', "id_auteur=" . $t['id_auteur'] . "&cle=$cle", true, true);
$url = generer_url_action('seenthis_reactiver_flux', 'id_auteur=' . $t['id_auteur'] . "&cle=$cle", true, true);
// envoyer un email à l'auteur pour le prévenir qu'on a désactivé son flux
include_spip('inc/notifications');
$texte = recuperer_fond('notifications/flux_desactive', array('id_auteur' => $t['id_auteur'], 'url' => $url));
$texte = recuperer_fond('notifications/flux_desactive', ['id_auteur' => $t['id_auteur'], 'url' => $url]);
notifications_envoyer_mails($t['email'], $texte);
}

Expand Down
Loading