@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -28,51 +28,51 @@ discard block |
||
| 28 | 28 | * @return void |
| 29 | 29 | */ |
| 30 | 30 | function action_confirmer_inscription_dist() { |
| 31 | - $jeton = _request('jeton'); |
|
| 32 | - $email = _request('email'); |
|
| 31 | + $jeton = _request('jeton'); |
|
| 32 | + $email = _request('email'); |
|
| 33 | 33 | |
| 34 | - include_spip('action/inscrire_auteur'); |
|
| 35 | - if ( |
|
| 36 | - $auteur = auteur_verifier_jeton($jeton) |
|
| 37 | - and $auteur['email'] == $email |
|
| 38 | - and $auteur['statut'] == 'nouveau' |
|
| 39 | - ) { |
|
| 40 | - // d'abord on confirme son statut |
|
| 41 | - $auteur = confirmer_statut_inscription($auteur); |
|
| 34 | + include_spip('action/inscrire_auteur'); |
|
| 35 | + if ( |
|
| 36 | + $auteur = auteur_verifier_jeton($jeton) |
|
| 37 | + and $auteur['email'] == $email |
|
| 38 | + and $auteur['statut'] == 'nouveau' |
|
| 39 | + ) { |
|
| 40 | + // d'abord on confirme son statut |
|
| 41 | + $auteur = confirmer_statut_inscription($auteur); |
|
| 42 | 42 | |
| 43 | - // OK c'est un nouvel inscrit qui confirme : |
|
| 44 | - // on le loge => ca va confirmer son statut et c'est plus sympa |
|
| 45 | - include_spip('inc/auth'); |
|
| 46 | - auth_loger($auteur); |
|
| 43 | + // OK c'est un nouvel inscrit qui confirme : |
|
| 44 | + // on le loge => ca va confirmer son statut et c'est plus sympa |
|
| 45 | + include_spip('inc/auth'); |
|
| 46 | + auth_loger($auteur); |
|
| 47 | 47 | |
| 48 | - // et on efface son jeton |
|
| 49 | - auteur_effacer_jeton($auteur['id_auteur']); |
|
| 48 | + // et on efface son jeton |
|
| 49 | + auteur_effacer_jeton($auteur['id_auteur']); |
|
| 50 | 50 | |
| 51 | - // si pas de redirection demandee, rediriger vers public ou prive selon le statut de l'auteur |
|
| 52 | - // TODO: ne semble pas marcher si inscrit non visiteur, a debug |
|
| 53 | - if (!_request('redirect')) { |
|
| 54 | - // on passe id_auteur explicite pour forcer une lecture en base de toutes les infos |
|
| 55 | - if (autoriser('ecrire', '', '', $auteur['id_auteur'])) { |
|
| 56 | - // poser un cookie admin aussi |
|
| 57 | - $cookie = charger_fonction('cookie', 'action'); |
|
| 58 | - $cookie('@' . $GLOBALS['visiteur_session']['login']); |
|
| 59 | - $GLOBALS['redirect'] = _DIR_RESTREINT_ABS; |
|
| 60 | - } else { |
|
| 61 | - $GLOBALS['redirect'] = $GLOBALS['meta']['adresse_site']; |
|
| 62 | - } |
|
| 63 | - } |
|
| 64 | - } else { |
|
| 65 | - // lien perime : |
|
| 66 | - if ($GLOBALS['visiteur_session']['id_auteur']) { |
|
| 67 | - // on passe id_auteur explicite pour forcer une lecture en base de toutes les infos |
|
| 68 | - if (autoriser('ecrire', '', '', $GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 69 | - $GLOBALS['redirect'] = _DIR_RESTREINT_ABS; |
|
| 70 | - } else { |
|
| 71 | - $GLOBALS['redirect'] = $GLOBALS['meta']['adresse_site']; |
|
| 72 | - } |
|
| 73 | - } else // rediriger vers la page de login si pas encore loge |
|
| 74 | - { |
|
| 75 | - $GLOBALS['redirect'] = parametre_url(generer_url_public('login', '', false), 'url', _request('redirect')); |
|
| 76 | - } |
|
| 77 | - } |
|
| 51 | + // si pas de redirection demandee, rediriger vers public ou prive selon le statut de l'auteur |
|
| 52 | + // TODO: ne semble pas marcher si inscrit non visiteur, a debug |
|
| 53 | + if (!_request('redirect')) { |
|
| 54 | + // on passe id_auteur explicite pour forcer une lecture en base de toutes les infos |
|
| 55 | + if (autoriser('ecrire', '', '', $auteur['id_auteur'])) { |
|
| 56 | + // poser un cookie admin aussi |
|
| 57 | + $cookie = charger_fonction('cookie', 'action'); |
|
| 58 | + $cookie('@' . $GLOBALS['visiteur_session']['login']); |
|
| 59 | + $GLOBALS['redirect'] = _DIR_RESTREINT_ABS; |
|
| 60 | + } else { |
|
| 61 | + $GLOBALS['redirect'] = $GLOBALS['meta']['adresse_site']; |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | + } else { |
|
| 65 | + // lien perime : |
|
| 66 | + if ($GLOBALS['visiteur_session']['id_auteur']) { |
|
| 67 | + // on passe id_auteur explicite pour forcer une lecture en base de toutes les infos |
|
| 68 | + if (autoriser('ecrire', '', '', $GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 69 | + $GLOBALS['redirect'] = _DIR_RESTREINT_ABS; |
|
| 70 | + } else { |
|
| 71 | + $GLOBALS['redirect'] = $GLOBALS['meta']['adresse_site']; |
|
| 72 | + } |
|
| 73 | + } else // rediriger vers la page de login si pas encore loge |
|
| 74 | + { |
|
| 75 | + $GLOBALS['redirect'] = parametre_url(generer_url_public('login', '', false), 'url', _request('redirect')); |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | 78 | } |
@@ -55,7 +55,7 @@ |
||
| 55 | 55 | if (autoriser('ecrire', '', '', $auteur['id_auteur'])) { |
| 56 | 56 | // poser un cookie admin aussi |
| 57 | 57 | $cookie = charger_fonction('cookie', 'action'); |
| 58 | - $cookie('@' . $GLOBALS['visiteur_session']['login']); |
|
| 58 | + $cookie('@'.$GLOBALS['visiteur_session']['login']); |
|
| 59 | 59 | $GLOBALS['redirect'] = _DIR_RESTREINT_ABS; |
| 60 | 60 | } else { |
| 61 | 61 | $GLOBALS['redirect'] = $GLOBALS['meta']['adresse_site']; |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | include_spip('inc/actions'); |
@@ -29,23 +29,23 @@ discard block |
||
| 29 | 29 | * @return void |
| 30 | 30 | */ |
| 31 | 31 | function action_etre_webmestre_dist() { |
| 32 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 33 | - $time = $securiser_action(); |
|
| 32 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 33 | + $time = $securiser_action(); |
|
| 34 | 34 | |
| 35 | - if ( |
|
| 36 | - time() - $time < 15 * 60 |
|
| 37 | - and $GLOBALS['visiteur_session']['statut'] == '0minirezo' |
|
| 38 | - and $GLOBALS['visiteur_session']['webmestre'] !== 'oui' |
|
| 39 | - ) { |
|
| 40 | - $action = _T('info_admin_etre_webmestre'); |
|
| 41 | - $admin = charger_fonction('admin', 'inc'); |
|
| 42 | - // lance la verif par ftp et l'appel |
|
| 43 | - // a base_etre_webmestre_dist quand c'est OK |
|
| 44 | - if ($r = $admin('etre_webmestre', $action)) { |
|
| 45 | - echo $r; |
|
| 46 | - exit; |
|
| 47 | - } |
|
| 48 | - } |
|
| 35 | + if ( |
|
| 36 | + time() - $time < 15 * 60 |
|
| 37 | + and $GLOBALS['visiteur_session']['statut'] == '0minirezo' |
|
| 38 | + and $GLOBALS['visiteur_session']['webmestre'] !== 'oui' |
|
| 39 | + ) { |
|
| 40 | + $action = _T('info_admin_etre_webmestre'); |
|
| 41 | + $admin = charger_fonction('admin', 'inc'); |
|
| 42 | + // lance la verif par ftp et l'appel |
|
| 43 | + // a base_etre_webmestre_dist quand c'est OK |
|
| 44 | + if ($r = $admin('etre_webmestre', $action)) { |
|
| 45 | + echo $r; |
|
| 46 | + exit; |
|
| 47 | + } |
|
| 48 | + } |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
@@ -54,8 +54,8 @@ discard block |
||
| 54 | 54 | * @return void |
| 55 | 55 | */ |
| 56 | 56 | function base_etre_webmestre_dist() { |
| 57 | - if ($GLOBALS['visiteur_session']['statut'] == '0minirezo' and $GLOBALS['visiteur_session']['webmestre'] !== 'oui') { |
|
| 58 | - include_spip('action/editer_auteur'); |
|
| 59 | - auteur_instituer($GLOBALS['visiteur_session']['id_auteur'], ['webmestre' => 'oui'], true); |
|
| 60 | - } |
|
| 57 | + if ($GLOBALS['visiteur_session']['statut'] == '0minirezo' and $GLOBALS['visiteur_session']['webmestre'] !== 'oui') { |
|
| 58 | + include_spip('action/editer_auteur'); |
|
| 59 | + auteur_instituer($GLOBALS['visiteur_session']['id_auteur'], ['webmestre' => 'oui'], true); |
|
| 60 | + } |
|
| 61 | 61 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -41,54 +41,54 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | function action_referencer_traduction_dist($objet, $id_objet, $id_trad) { |
| 43 | 43 | |
| 44 | - // ne rien faire si id_trad est ambigu |
|
| 45 | - if (!is_numeric($id_trad)) { |
|
| 46 | - return false; |
|
| 47 | - } |
|
| 44 | + // ne rien faire si id_trad est ambigu |
|
| 45 | + if (!is_numeric($id_trad)) { |
|
| 46 | + return false; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - $table_objet_sql = table_objet_sql($objet); |
|
| 50 | - $id_table_objet = id_table_objet($objet); |
|
| 49 | + $table_objet_sql = table_objet_sql($objet); |
|
| 50 | + $id_table_objet = id_table_objet($objet); |
|
| 51 | 51 | |
| 52 | - // on a fourni un id_trad : affectation ou modification du groupe de trad |
|
| 53 | - if ($id_trad) { |
|
| 54 | - // selectionner l'objet cible, qui doit etre different de nous-meme, |
|
| 55 | - // et quitter s'il n'existe pas |
|
| 56 | - $id_lier = sql_getfetsel( |
|
| 57 | - 'id_trad', |
|
| 58 | - $table_objet_sql, |
|
| 59 | - "$id_table_objet=" . intval($id_trad) . " AND NOT($id_table_objet=" . intval($id_objet) . ')' |
|
| 60 | - ); |
|
| 61 | - if ($id_lier === null) { |
|
| 62 | - spip_log("echec lien de trad vers objet $objet/$id_objet incorrect ($id_trad)"); |
|
| 52 | + // on a fourni un id_trad : affectation ou modification du groupe de trad |
|
| 53 | + if ($id_trad) { |
|
| 54 | + // selectionner l'objet cible, qui doit etre different de nous-meme, |
|
| 55 | + // et quitter s'il n'existe pas |
|
| 56 | + $id_lier = sql_getfetsel( |
|
| 57 | + 'id_trad', |
|
| 58 | + $table_objet_sql, |
|
| 59 | + "$id_table_objet=" . intval($id_trad) . " AND NOT($id_table_objet=" . intval($id_objet) . ')' |
|
| 60 | + ); |
|
| 61 | + if ($id_lier === null) { |
|
| 62 | + spip_log("echec lien de trad vers objet $objet/$id_objet incorrect ($id_trad)"); |
|
| 63 | 63 | |
| 64 | - return false; |
|
| 65 | - } |
|
| 64 | + return false; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - // $id_lier est le numero du groupe de traduction |
|
| 68 | - // Si l'objet vise n'est pas deja traduit, son identifiant devient |
|
| 69 | - // le nouvel id_trad de ce nouveau groupe et on l'affecte aux deux |
|
| 70 | - // objets |
|
| 71 | - if ($id_lier == 0) { |
|
| 72 | - sql_updateq($table_objet_sql, ['id_trad' => $id_trad], "$id_table_objet IN ($id_trad, $id_objet)"); |
|
| 73 | - } // si id_lier = id_objet alors on veut changer la reference de tout le groupe de trad |
|
| 74 | - elseif ($id_lier == $id_objet) { |
|
| 75 | - sql_updateq($table_objet_sql, ['id_trad' => $id_trad], "id_trad = $id_lier"); |
|
| 76 | - } // sinon ajouter notre objet dans le groupe |
|
| 77 | - else { |
|
| 78 | - sql_updateq($table_objet_sql, ['id_trad' => $id_lier], "$id_table_objet=" . intval($id_objet)); |
|
| 79 | - } |
|
| 80 | - } // on a fourni un id_trad nul : sortir id_objet du groupe de trad |
|
| 81 | - else { |
|
| 82 | - $old_id_trad = sql_getfetsel('id_trad', $table_objet_sql, "$id_table_objet=" . intval($id_objet)); |
|
| 83 | - // supprimer le lien de traduction |
|
| 84 | - sql_updateq($table_objet_sql, ['id_trad' => 0], "$id_table_objet=" . intval($id_objet)); |
|
| 67 | + // $id_lier est le numero du groupe de traduction |
|
| 68 | + // Si l'objet vise n'est pas deja traduit, son identifiant devient |
|
| 69 | + // le nouvel id_trad de ce nouveau groupe et on l'affecte aux deux |
|
| 70 | + // objets |
|
| 71 | + if ($id_lier == 0) { |
|
| 72 | + sql_updateq($table_objet_sql, ['id_trad' => $id_trad], "$id_table_objet IN ($id_trad, $id_objet)"); |
|
| 73 | + } // si id_lier = id_objet alors on veut changer la reference de tout le groupe de trad |
|
| 74 | + elseif ($id_lier == $id_objet) { |
|
| 75 | + sql_updateq($table_objet_sql, ['id_trad' => $id_trad], "id_trad = $id_lier"); |
|
| 76 | + } // sinon ajouter notre objet dans le groupe |
|
| 77 | + else { |
|
| 78 | + sql_updateq($table_objet_sql, ['id_trad' => $id_lier], "$id_table_objet=" . intval($id_objet)); |
|
| 79 | + } |
|
| 80 | + } // on a fourni un id_trad nul : sortir id_objet du groupe de trad |
|
| 81 | + else { |
|
| 82 | + $old_id_trad = sql_getfetsel('id_trad', $table_objet_sql, "$id_table_objet=" . intval($id_objet)); |
|
| 83 | + // supprimer le lien de traduction |
|
| 84 | + sql_updateq($table_objet_sql, ['id_trad' => 0], "$id_table_objet=" . intval($id_objet)); |
|
| 85 | 85 | |
| 86 | - // Verifier si l'ancien groupe ne comporte plus qu'un seul objet. Alors mettre a zero. |
|
| 87 | - $cpt = sql_countsel($table_objet_sql, 'id_trad=' . intval($old_id_trad)); |
|
| 88 | - if ($cpt == 1) { |
|
| 89 | - sql_updateq($table_objet_sql, ['id_trad' => 0], 'id_trad=' . intval($old_id_trad)); |
|
| 90 | - } |
|
| 91 | - } |
|
| 86 | + // Verifier si l'ancien groupe ne comporte plus qu'un seul objet. Alors mettre a zero. |
|
| 87 | + $cpt = sql_countsel($table_objet_sql, 'id_trad=' . intval($old_id_trad)); |
|
| 88 | + if ($cpt == 1) { |
|
| 89 | + sql_updateq($table_objet_sql, ['id_trad' => 0], 'id_trad=' . intval($old_id_trad)); |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - return true; |
|
| 93 | + return true; |
|
| 94 | 94 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | $id_lier = sql_getfetsel( |
| 57 | 57 | 'id_trad', |
| 58 | 58 | $table_objet_sql, |
| 59 | - "$id_table_objet=" . intval($id_trad) . " AND NOT($id_table_objet=" . intval($id_objet) . ')' |
|
| 59 | + "$id_table_objet=".intval($id_trad)." AND NOT($id_table_objet=".intval($id_objet).')' |
|
| 60 | 60 | ); |
| 61 | 61 | if ($id_lier === null) { |
| 62 | 62 | spip_log("echec lien de trad vers objet $objet/$id_objet incorrect ($id_trad)"); |
@@ -75,18 +75,18 @@ discard block |
||
| 75 | 75 | sql_updateq($table_objet_sql, ['id_trad' => $id_trad], "id_trad = $id_lier"); |
| 76 | 76 | } // sinon ajouter notre objet dans le groupe |
| 77 | 77 | else { |
| 78 | - sql_updateq($table_objet_sql, ['id_trad' => $id_lier], "$id_table_objet=" . intval($id_objet)); |
|
| 78 | + sql_updateq($table_objet_sql, ['id_trad' => $id_lier], "$id_table_objet=".intval($id_objet)); |
|
| 79 | 79 | } |
| 80 | 80 | } // on a fourni un id_trad nul : sortir id_objet du groupe de trad |
| 81 | 81 | else { |
| 82 | - $old_id_trad = sql_getfetsel('id_trad', $table_objet_sql, "$id_table_objet=" . intval($id_objet)); |
|
| 82 | + $old_id_trad = sql_getfetsel('id_trad', $table_objet_sql, "$id_table_objet=".intval($id_objet)); |
|
| 83 | 83 | // supprimer le lien de traduction |
| 84 | - sql_updateq($table_objet_sql, ['id_trad' => 0], "$id_table_objet=" . intval($id_objet)); |
|
| 84 | + sql_updateq($table_objet_sql, ['id_trad' => 0], "$id_table_objet=".intval($id_objet)); |
|
| 85 | 85 | |
| 86 | 86 | // Verifier si l'ancien groupe ne comporte plus qu'un seul objet. Alors mettre a zero. |
| 87 | - $cpt = sql_countsel($table_objet_sql, 'id_trad=' . intval($old_id_trad)); |
|
| 87 | + $cpt = sql_countsel($table_objet_sql, 'id_trad='.intval($old_id_trad)); |
|
| 88 | 88 | if ($cpt == 1) { |
| 89 | - sql_updateq($table_objet_sql, ['id_trad' => 0], 'id_trad=' . intval($old_id_trad)); |
|
| 89 | + sql_updateq($table_objet_sql, ['id_trad' => 0], 'id_trad='.intval($old_id_trad)); |
|
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -28,23 +28,23 @@ discard block |
||
| 28 | 28 | * @return void |
| 29 | 29 | */ |
| 30 | 30 | function action_confirmer_email_dist() { |
| 31 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 32 | - $arg = $securiser_action(); |
|
| 31 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 32 | + $arg = $securiser_action(); |
|
| 33 | 33 | |
| 34 | - include_spip('inc/filtres'); |
|
| 35 | - if ($GLOBALS['visiteur_session']['id_auteur'] and email_valide($arg)) { |
|
| 36 | - include_spip('action/editer_auteur'); |
|
| 37 | - auteur_modifier($GLOBALS['visiteur_session']['id_auteur'], ['email' => $arg]); |
|
| 38 | - } |
|
| 39 | - // verifier avant de rediriger pour invalider le message de confirmation |
|
| 40 | - // si ca n'a pas marche |
|
| 41 | - if ( |
|
| 42 | - $redirect = _request('redirect') and !$arg == sql_getfetsel( |
|
| 43 | - 'email', |
|
| 44 | - 'spip_auteurs', |
|
| 45 | - 'id_auteur=' . intval($GLOBALS['visiteur_session']) |
|
| 46 | - ) |
|
| 47 | - ) { |
|
| 48 | - $GLOBALS['redirect'] = parametre_url($redirect, 'email_modif', ''); |
|
| 49 | - } |
|
| 34 | + include_spip('inc/filtres'); |
|
| 35 | + if ($GLOBALS['visiteur_session']['id_auteur'] and email_valide($arg)) { |
|
| 36 | + include_spip('action/editer_auteur'); |
|
| 37 | + auteur_modifier($GLOBALS['visiteur_session']['id_auteur'], ['email' => $arg]); |
|
| 38 | + } |
|
| 39 | + // verifier avant de rediriger pour invalider le message de confirmation |
|
| 40 | + // si ca n'a pas marche |
|
| 41 | + if ( |
|
| 42 | + $redirect = _request('redirect') and !$arg == sql_getfetsel( |
|
| 43 | + 'email', |
|
| 44 | + 'spip_auteurs', |
|
| 45 | + 'id_auteur=' . intval($GLOBALS['visiteur_session']) |
|
| 46 | + ) |
|
| 47 | + ) { |
|
| 48 | + $GLOBALS['redirect'] = parametre_url($redirect, 'email_modif', ''); |
|
| 49 | + } |
|
| 50 | 50 | } |
@@ -42,7 +42,7 @@ |
||
| 42 | 42 | $redirect = _request('redirect') and !$arg == sql_getfetsel( |
| 43 | 43 | 'email', |
| 44 | 44 | 'spip_auteurs', |
| 45 | - 'id_auteur=' . intval($GLOBALS['visiteur_session']) |
|
| 45 | + 'id_auteur='.intval($GLOBALS['visiteur_session']) |
|
| 46 | 46 | ) |
| 47 | 47 | ) { |
| 48 | 48 | $GLOBALS['redirect'] = parametre_url($redirect, 'email_modif', ''); |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -25,25 +25,25 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | function action_auth_dist() { |
| 27 | 27 | |
| 28 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 29 | - $arg = $securiser_action(); |
|
| 30 | - |
|
| 31 | - if (!preg_match(',^(\w+)[/](.+)$,', $arg, $r)) { |
|
| 32 | - spip_log("action_auth_dist $arg pas compris"); |
|
| 33 | - } else { |
|
| 34 | - $auth_methode = $r[1]; |
|
| 35 | - $login = $r[2]; |
|
| 36 | - include_spip('inc/auth'); |
|
| 37 | - $res = auth_terminer_identifier_login($auth_methode, $login); |
|
| 38 | - |
|
| 39 | - if (is_string($res)) { // Erreur |
|
| 40 | - $redirect = _request('redirect'); |
|
| 41 | - $redirect = parametre_url($redirect, 'var_erreur', $res, '&'); |
|
| 42 | - include_spip('inc/headers'); |
|
| 43 | - redirige_par_entete($redirect); |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - // sinon on loge l'auteur identifie, et on finit (redirection automatique) |
|
| 47 | - auth_loger($res); |
|
| 48 | - } |
|
| 28 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 29 | + $arg = $securiser_action(); |
|
| 30 | + |
|
| 31 | + if (!preg_match(',^(\w+)[/](.+)$,', $arg, $r)) { |
|
| 32 | + spip_log("action_auth_dist $arg pas compris"); |
|
| 33 | + } else { |
|
| 34 | + $auth_methode = $r[1]; |
|
| 35 | + $login = $r[2]; |
|
| 36 | + include_spip('inc/auth'); |
|
| 37 | + $res = auth_terminer_identifier_login($auth_methode, $login); |
|
| 38 | + |
|
| 39 | + if (is_string($res)) { // Erreur |
|
| 40 | + $redirect = _request('redirect'); |
|
| 41 | + $redirect = parametre_url($redirect, 'var_erreur', $res, '&'); |
|
| 42 | + include_spip('inc/headers'); |
|
| 43 | + redirige_par_entete($redirect); |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + // sinon on loge l'auteur identifie, et on finit (redirection automatique) |
|
| 47 | + auth_loger($res); |
|
| 48 | + } |
|
| 49 | 49 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | include_spip('inc/charsets'); # pour le nom de fichier |
@@ -30,45 +30,45 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | function action_supprimer_rubrique_dist($id_rubrique = null) { |
| 32 | 32 | |
| 33 | - if (is_null($id_rubrique)) { |
|
| 34 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 35 | - $id_rubrique = $securiser_action(); |
|
| 36 | - } |
|
| 33 | + if (is_null($id_rubrique)) { |
|
| 34 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 35 | + $id_rubrique = $securiser_action(); |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - if (intval($id_rubrique)) { |
|
| 39 | - sql_delete('spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 40 | - // Les admin restreints qui n'administraient que cette rubrique |
|
| 41 | - // deviennent redacteurs |
|
| 42 | - // (il y a sans doute moyen de faire ca avec un having) |
|
| 38 | + if (intval($id_rubrique)) { |
|
| 39 | + sql_delete('spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 40 | + // Les admin restreints qui n'administraient que cette rubrique |
|
| 41 | + // deviennent redacteurs |
|
| 42 | + // (il y a sans doute moyen de faire ca avec un having) |
|
| 43 | 43 | |
| 44 | - $q = sql_select('id_auteur', 'spip_auteurs_liens', "objet='rubrique' AND id_objet=" . intval($id_rubrique)); |
|
| 45 | - while ($r = sql_fetch($q)) { |
|
| 46 | - $id_auteur = $r['id_auteur']; |
|
| 47 | - // degrader avant de supprimer la restriction d'admin |
|
| 48 | - // section critique sur les droits |
|
| 49 | - $n = sql_countsel( |
|
| 50 | - 'spip_auteurs_liens', |
|
| 51 | - "objet='rubrique' AND id_objet!=" . intval($id_rubrique) . ' AND id_auteur=' . intval($id_auteur) |
|
| 52 | - ); |
|
| 53 | - if (!$n) { |
|
| 54 | - include_spip('action/editer_auteur'); |
|
| 55 | - auteur_modifier($id_auteur, ['statut' => '1comite']); |
|
| 56 | - } |
|
| 57 | - sql_delete( |
|
| 58 | - 'spip_auteurs_liens', |
|
| 59 | - "objet='rubrique' AND id_objet=" . intval($id_rubrique) . ' AND id_auteur=' . intval($id_auteur) |
|
| 60 | - ); |
|
| 61 | - } |
|
| 62 | - // menu_rubriques devra recalculer |
|
| 63 | - effacer_meta('date_calcul_rubriques'); |
|
| 44 | + $q = sql_select('id_auteur', 'spip_auteurs_liens', "objet='rubrique' AND id_objet=" . intval($id_rubrique)); |
|
| 45 | + while ($r = sql_fetch($q)) { |
|
| 46 | + $id_auteur = $r['id_auteur']; |
|
| 47 | + // degrader avant de supprimer la restriction d'admin |
|
| 48 | + // section critique sur les droits |
|
| 49 | + $n = sql_countsel( |
|
| 50 | + 'spip_auteurs_liens', |
|
| 51 | + "objet='rubrique' AND id_objet!=" . intval($id_rubrique) . ' AND id_auteur=' . intval($id_auteur) |
|
| 52 | + ); |
|
| 53 | + if (!$n) { |
|
| 54 | + include_spip('action/editer_auteur'); |
|
| 55 | + auteur_modifier($id_auteur, ['statut' => '1comite']); |
|
| 56 | + } |
|
| 57 | + sql_delete( |
|
| 58 | + 'spip_auteurs_liens', |
|
| 59 | + "objet='rubrique' AND id_objet=" . intval($id_rubrique) . ' AND id_auteur=' . intval($id_auteur) |
|
| 60 | + ); |
|
| 61 | + } |
|
| 62 | + // menu_rubriques devra recalculer |
|
| 63 | + effacer_meta('date_calcul_rubriques'); |
|
| 64 | 64 | |
| 65 | - // Une rubrique supprimable n'avait pas le statut "publie" |
|
| 66 | - // donc rien de neuf pour la rubrique parente |
|
| 67 | - include_spip('inc/rubriques'); |
|
| 68 | - calculer_langues_rubriques(); |
|
| 65 | + // Une rubrique supprimable n'avait pas le statut "publie" |
|
| 66 | + // donc rien de neuf pour la rubrique parente |
|
| 67 | + include_spip('inc/rubriques'); |
|
| 68 | + calculer_langues_rubriques(); |
|
| 69 | 69 | |
| 70 | - // invalider les caches marques de cette rubrique |
|
| 71 | - include_spip('inc/invalideur'); |
|
| 72 | - suivre_invalideur("id='rubrique/$id_rubrique'"); |
|
| 73 | - } |
|
| 70 | + // invalider les caches marques de cette rubrique |
|
| 71 | + include_spip('inc/invalideur'); |
|
| 72 | + suivre_invalideur("id='rubrique/$id_rubrique'"); |
|
| 73 | + } |
|
| 74 | 74 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | return; |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | -include_spip('inc/charsets'); # pour le nom de fichier |
|
| 23 | +include_spip('inc/charsets'); # pour le nom de fichier |
|
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * Effacer une rubrique |
@@ -36,19 +36,19 @@ discard block |
||
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | if (intval($id_rubrique)) { |
| 39 | - sql_delete('spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 39 | + sql_delete('spip_rubriques', 'id_rubrique='.intval($id_rubrique)); |
|
| 40 | 40 | // Les admin restreints qui n'administraient que cette rubrique |
| 41 | 41 | // deviennent redacteurs |
| 42 | 42 | // (il y a sans doute moyen de faire ca avec un having) |
| 43 | 43 | |
| 44 | - $q = sql_select('id_auteur', 'spip_auteurs_liens', "objet='rubrique' AND id_objet=" . intval($id_rubrique)); |
|
| 44 | + $q = sql_select('id_auteur', 'spip_auteurs_liens', "objet='rubrique' AND id_objet=".intval($id_rubrique)); |
|
| 45 | 45 | while ($r = sql_fetch($q)) { |
| 46 | 46 | $id_auteur = $r['id_auteur']; |
| 47 | 47 | // degrader avant de supprimer la restriction d'admin |
| 48 | 48 | // section critique sur les droits |
| 49 | 49 | $n = sql_countsel( |
| 50 | 50 | 'spip_auteurs_liens', |
| 51 | - "objet='rubrique' AND id_objet!=" . intval($id_rubrique) . ' AND id_auteur=' . intval($id_auteur) |
|
| 51 | + "objet='rubrique' AND id_objet!=".intval($id_rubrique).' AND id_auteur='.intval($id_auteur) |
|
| 52 | 52 | ); |
| 53 | 53 | if (!$n) { |
| 54 | 54 | include_spip('action/editer_auteur'); |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | } |
| 57 | 57 | sql_delete( |
| 58 | 58 | 'spip_auteurs_liens', |
| 59 | - "objet='rubrique' AND id_objet=" . intval($id_rubrique) . ' AND id_auteur=' . intval($id_auteur) |
|
| 59 | + "objet='rubrique' AND id_objet=".intval($id_rubrique).' AND id_auteur='.intval($id_auteur) |
|
| 60 | 60 | ); |
| 61 | 61 | } |
| 62 | 62 | // menu_rubriques devra recalculer |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -26,22 +26,22 @@ discard block |
||
| 26 | 26 | * @return void |
| 27 | 27 | */ |
| 28 | 28 | function action_relancer_inscription_dist() { |
| 29 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 30 | - $id_auteur = $securiser_action(); |
|
| 29 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 30 | + $id_auteur = $securiser_action(); |
|
| 31 | 31 | |
| 32 | - if (intval($id_auteur) and autoriser('relancer', 'inscription')) { |
|
| 33 | - $auteur = sql_fetsel('prefs, email, nom, statut', 'spip_auteurs', "id_auteur=$id_auteur"); |
|
| 34 | - if ($auteur['statut'] == 'nouveau') { |
|
| 35 | - include_spip('action/inscrire_auteur'); |
|
| 36 | - action_inscrire_auteur_dist($auteur['prefs'], $auteur['email'], $auteur['nom'], ['force_nouveau' => true]); |
|
| 37 | - } |
|
| 38 | - } elseif ($id_auteur === '*' and autoriser('relancer', 'inscription')) { |
|
| 39 | - $auteurs = sql_allfetsel('prefs, email, nom', 'spip_auteurs', "statut='nouveau'"); |
|
| 40 | - if (is_array($auteurs)) { |
|
| 41 | - include_spip('action/inscrire_auteur'); |
|
| 42 | - while ($row = array_pop($auteurs)) { |
|
| 43 | - action_inscrire_auteur_dist($row['prefs'], $row['email'], $row['nom'], ['force_nouveau' => true]); |
|
| 44 | - } |
|
| 45 | - } |
|
| 46 | - } |
|
| 32 | + if (intval($id_auteur) and autoriser('relancer', 'inscription')) { |
|
| 33 | + $auteur = sql_fetsel('prefs, email, nom, statut', 'spip_auteurs', "id_auteur=$id_auteur"); |
|
| 34 | + if ($auteur['statut'] == 'nouveau') { |
|
| 35 | + include_spip('action/inscrire_auteur'); |
|
| 36 | + action_inscrire_auteur_dist($auteur['prefs'], $auteur['email'], $auteur['nom'], ['force_nouveau' => true]); |
|
| 37 | + } |
|
| 38 | + } elseif ($id_auteur === '*' and autoriser('relancer', 'inscription')) { |
|
| 39 | + $auteurs = sql_allfetsel('prefs, email, nom', 'spip_auteurs', "statut='nouveau'"); |
|
| 40 | + if (is_array($auteurs)) { |
|
| 41 | + include_spip('action/inscrire_auteur'); |
|
| 42 | + while ($row = array_pop($auteurs)) { |
|
| 43 | + action_inscrire_auteur_dist($row['prefs'], $row['email'], $row['nom'], ['force_nouveau' => true]); |
|
| 44 | + } |
|
| 45 | + } |
|
| 46 | + } |
|
| 47 | 47 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | } |
| 69 | 69 | $dir = constant($dir); |
| 70 | 70 | foreach ($infos['install'] as $file) { |
| 71 | - $file = $dir . $plug . '/' . trim($file); |
|
| 71 | + $file = $dir.$plug.'/'.trim($file); |
|
| 72 | 72 | if (file_exists($file)) { |
| 73 | 73 | include_once($file); |
| 74 | 74 | } |
@@ -81,10 +81,10 @@ discard block |
||
| 81 | 81 | // S'assurer que les metas de la table spécifique sont bien accessibles dans la globale |
| 82 | 82 | lire_metas($table); |
| 83 | 83 | } |
| 84 | - $nom_meta = $infos['prefix'] . '_base_version'; |
|
| 84 | + $nom_meta = $infos['prefix'].'_base_version'; |
|
| 85 | 85 | |
| 86 | 86 | // Détermination de la fonction à appeler et de ses arguments |
| 87 | - $f = $infos['prefix'] . '_install'; |
|
| 87 | + $f = $infos['prefix'].'_install'; |
|
| 88 | 88 | if (!function_exists($f)) { |
| 89 | 89 | $f = isset($infos['schema']) ? 'spip_plugin_install' : ''; |
| 90 | 90 | $arg = $infos; |
@@ -168,12 +168,12 @@ discard block |
||
| 168 | 168 | and spip_version_compare($GLOBALS[$table][$nom_meta], $version_cible, '>=')); |
| 169 | 169 | break; |
| 170 | 170 | case 'install': |
| 171 | - if (function_exists($upgrade = $infos['prefix'] . '_upgrade')) { |
|
| 171 | + if (function_exists($upgrade = $infos['prefix'].'_upgrade')) { |
|
| 172 | 172 | $upgrade($nom_meta, $version_cible, $table); |
| 173 | 173 | } |
| 174 | 174 | break; |
| 175 | 175 | case 'uninstall': |
| 176 | - if (function_exists($vider_tables = $infos['prefix'] . '_vider_tables')) { |
|
| 176 | + if (function_exists($vider_tables = $infos['prefix'].'_vider_tables')) { |
|
| 177 | 177 | $vider_tables($nom_meta, $table); |
| 178 | 178 | } |
| 179 | 179 | break; |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -54,96 +54,96 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | function plugins_installer_dist($plug, $action, $dir_type = '_DIR_PLUGINS') { |
| 56 | 56 | |
| 57 | - // Charger les informations du XML du plugin et vérification de l'existence d'une installation |
|
| 58 | - $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 59 | - $infos = $get_infos($plug, false, constant($dir_type)); |
|
| 60 | - if (!isset($infos['install']) or !$infos['install']) { |
|
| 61 | - return false; |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - // Passer en chemin absolu si possible, c'est plus efficace |
|
| 65 | - $dir = str_replace('_DIR_', '_ROOT_', $dir_type); |
|
| 66 | - if (!defined($dir)) { |
|
| 67 | - $dir = $dir_type; |
|
| 68 | - } |
|
| 69 | - $dir = constant($dir); |
|
| 70 | - foreach ($infos['install'] as $file) { |
|
| 71 | - $file = $dir . $plug . '/' . trim($file); |
|
| 72 | - if (file_exists($file)) { |
|
| 73 | - include_once($file); |
|
| 74 | - } |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - // Détermination de la table meta et du nom de la meta plugin |
|
| 78 | - $table = 'meta'; |
|
| 79 | - if (isset($infos['meta']) and ($infos['meta'] !== 'meta')) { |
|
| 80 | - $table = $infos['meta']; |
|
| 81 | - // S'assurer que les metas de la table spécifique sont bien accessibles dans la globale |
|
| 82 | - lire_metas($table); |
|
| 83 | - } |
|
| 84 | - $nom_meta = $infos['prefix'] . '_base_version'; |
|
| 85 | - |
|
| 86 | - // Détermination de la fonction à appeler et de ses arguments |
|
| 87 | - $f = $infos['prefix'] . '_install'; |
|
| 88 | - if (!function_exists($f)) { |
|
| 89 | - $f = isset($infos['schema']) ? 'spip_plugin_install' : ''; |
|
| 90 | - $arg = $infos; |
|
| 91 | - // On passe la table et la meta pour éviter de les recalculer dans la fonction appelée |
|
| 92 | - $arg['meta'] = $table; |
|
| 93 | - $arg['nom_meta'] = $nom_meta; |
|
| 94 | - } else { |
|
| 95 | - // Ancienne méthode d'installation - TODO à supprimer à terme |
|
| 96 | - // stupide: info deja dans le nom |
|
| 97 | - $arg = $infos['prefix']; |
|
| 98 | - } |
|
| 99 | - $version = $infos['schema'] ?? ''; |
|
| 100 | - |
|
| 101 | - if (!$f) { |
|
| 102 | - // installation sans operation particuliere |
|
| 103 | - $infos['install_test'] = [true, '']; |
|
| 104 | - return $infos; |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - // Tester si l'action demandée est nécessaire ou pas. |
|
| 108 | - $test = $f('test', $arg, $version); |
|
| 109 | - if ($action == 'uninstall') { |
|
| 110 | - $test = !$test; |
|
| 111 | - } |
|
| 112 | - // Si deja fait, on ne fait rien et on ne dit rien |
|
| 113 | - if ($test) { |
|
| 114 | - return true; |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - // Si install et que l'on a la meta d'installation, c'est un upgrade. On le consigne dans $infos |
|
| 118 | - // pour renvoyer le bon message en retour de la fonction. |
|
| 119 | - if ($action == 'install' && !empty($GLOBALS[$table][$nom_meta])) { |
|
| 120 | - $infos['upgrade'] = true; |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - // executer l'installation ou l'inverse |
|
| 124 | - // et renvoyer la trace (mais il faudrait passer en AJAX plutot) |
|
| 125 | - ob_start(); |
|
| 126 | - $f($action, $arg, $version); |
|
| 127 | - $aff = ob_get_contents(); |
|
| 128 | - ob_end_clean(); |
|
| 129 | - |
|
| 130 | - // vider le cache des descriptions de tables a chaque (de)installation |
|
| 131 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 132 | - $trouver_table(''); |
|
| 133 | - $infos['install_test'] = [$f('test', $arg, $version), $aff]; |
|
| 134 | - |
|
| 135 | - // Si la table meta n'est pas spip_meta et qu'on est dans la première installation du plugin |
|
| 136 | - // on force la création du fichier cache à la date du moment. |
|
| 137 | - // On relit les metas de la table pour être sur que la globale soit à jour pour touch_meta. |
|
| 138 | - if ( |
|
| 139 | - ($table !== 'meta') |
|
| 140 | - and ($action == 'install') |
|
| 141 | - and empty($infos['upgrade']) |
|
| 142 | - ) { |
|
| 143 | - touch_meta(false, $table); |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - return $infos; |
|
| 57 | + // Charger les informations du XML du plugin et vérification de l'existence d'une installation |
|
| 58 | + $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 59 | + $infos = $get_infos($plug, false, constant($dir_type)); |
|
| 60 | + if (!isset($infos['install']) or !$infos['install']) { |
|
| 61 | + return false; |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + // Passer en chemin absolu si possible, c'est plus efficace |
|
| 65 | + $dir = str_replace('_DIR_', '_ROOT_', $dir_type); |
|
| 66 | + if (!defined($dir)) { |
|
| 67 | + $dir = $dir_type; |
|
| 68 | + } |
|
| 69 | + $dir = constant($dir); |
|
| 70 | + foreach ($infos['install'] as $file) { |
|
| 71 | + $file = $dir . $plug . '/' . trim($file); |
|
| 72 | + if (file_exists($file)) { |
|
| 73 | + include_once($file); |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + // Détermination de la table meta et du nom de la meta plugin |
|
| 78 | + $table = 'meta'; |
|
| 79 | + if (isset($infos['meta']) and ($infos['meta'] !== 'meta')) { |
|
| 80 | + $table = $infos['meta']; |
|
| 81 | + // S'assurer que les metas de la table spécifique sont bien accessibles dans la globale |
|
| 82 | + lire_metas($table); |
|
| 83 | + } |
|
| 84 | + $nom_meta = $infos['prefix'] . '_base_version'; |
|
| 85 | + |
|
| 86 | + // Détermination de la fonction à appeler et de ses arguments |
|
| 87 | + $f = $infos['prefix'] . '_install'; |
|
| 88 | + if (!function_exists($f)) { |
|
| 89 | + $f = isset($infos['schema']) ? 'spip_plugin_install' : ''; |
|
| 90 | + $arg = $infos; |
|
| 91 | + // On passe la table et la meta pour éviter de les recalculer dans la fonction appelée |
|
| 92 | + $arg['meta'] = $table; |
|
| 93 | + $arg['nom_meta'] = $nom_meta; |
|
| 94 | + } else { |
|
| 95 | + // Ancienne méthode d'installation - TODO à supprimer à terme |
|
| 96 | + // stupide: info deja dans le nom |
|
| 97 | + $arg = $infos['prefix']; |
|
| 98 | + } |
|
| 99 | + $version = $infos['schema'] ?? ''; |
|
| 100 | + |
|
| 101 | + if (!$f) { |
|
| 102 | + // installation sans operation particuliere |
|
| 103 | + $infos['install_test'] = [true, '']; |
|
| 104 | + return $infos; |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + // Tester si l'action demandée est nécessaire ou pas. |
|
| 108 | + $test = $f('test', $arg, $version); |
|
| 109 | + if ($action == 'uninstall') { |
|
| 110 | + $test = !$test; |
|
| 111 | + } |
|
| 112 | + // Si deja fait, on ne fait rien et on ne dit rien |
|
| 113 | + if ($test) { |
|
| 114 | + return true; |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + // Si install et que l'on a la meta d'installation, c'est un upgrade. On le consigne dans $infos |
|
| 118 | + // pour renvoyer le bon message en retour de la fonction. |
|
| 119 | + if ($action == 'install' && !empty($GLOBALS[$table][$nom_meta])) { |
|
| 120 | + $infos['upgrade'] = true; |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + // executer l'installation ou l'inverse |
|
| 124 | + // et renvoyer la trace (mais il faudrait passer en AJAX plutot) |
|
| 125 | + ob_start(); |
|
| 126 | + $f($action, $arg, $version); |
|
| 127 | + $aff = ob_get_contents(); |
|
| 128 | + ob_end_clean(); |
|
| 129 | + |
|
| 130 | + // vider le cache des descriptions de tables a chaque (de)installation |
|
| 131 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 132 | + $trouver_table(''); |
|
| 133 | + $infos['install_test'] = [$f('test', $arg, $version), $aff]; |
|
| 134 | + |
|
| 135 | + // Si la table meta n'est pas spip_meta et qu'on est dans la première installation du plugin |
|
| 136 | + // on force la création du fichier cache à la date du moment. |
|
| 137 | + // On relit les metas de la table pour être sur que la globale soit à jour pour touch_meta. |
|
| 138 | + if ( |
|
| 139 | + ($table !== 'meta') |
|
| 140 | + and ($action == 'install') |
|
| 141 | + and empty($infos['upgrade']) |
|
| 142 | + ) { |
|
| 143 | + touch_meta(false, $table); |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + return $infos; |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | /** |
@@ -159,25 +159,25 @@ discard block |
||
| 159 | 159 | * @return bool|void |
| 160 | 160 | */ |
| 161 | 161 | function spip_plugin_install($action, $infos, $version_cible) { |
| 162 | - $nom_meta = $infos['nom_meta']; |
|
| 163 | - $table = $infos['meta']; |
|
| 164 | - switch ($action) { |
|
| 165 | - case 'test': |
|
| 166 | - return (isset($GLOBALS[$table]) |
|
| 167 | - and isset($GLOBALS[$table][$nom_meta]) |
|
| 168 | - and spip_version_compare($GLOBALS[$table][$nom_meta], $version_cible, '>=')); |
|
| 169 | - break; |
|
| 170 | - case 'install': |
|
| 171 | - if (function_exists($upgrade = $infos['prefix'] . '_upgrade')) { |
|
| 172 | - $upgrade($nom_meta, $version_cible, $table); |
|
| 173 | - } |
|
| 174 | - break; |
|
| 175 | - case 'uninstall': |
|
| 176 | - if (function_exists($vider_tables = $infos['prefix'] . '_vider_tables')) { |
|
| 177 | - $vider_tables($nom_meta, $table); |
|
| 178 | - } |
|
| 179 | - break; |
|
| 180 | - } |
|
| 162 | + $nom_meta = $infos['nom_meta']; |
|
| 163 | + $table = $infos['meta']; |
|
| 164 | + switch ($action) { |
|
| 165 | + case 'test': |
|
| 166 | + return (isset($GLOBALS[$table]) |
|
| 167 | + and isset($GLOBALS[$table][$nom_meta]) |
|
| 168 | + and spip_version_compare($GLOBALS[$table][$nom_meta], $version_cible, '>=')); |
|
| 169 | + break; |
|
| 170 | + case 'install': |
|
| 171 | + if (function_exists($upgrade = $infos['prefix'] . '_upgrade')) { |
|
| 172 | + $upgrade($nom_meta, $version_cible, $table); |
|
| 173 | + } |
|
| 174 | + break; |
|
| 175 | + case 'uninstall': |
|
| 176 | + if (function_exists($vider_tables = $infos['prefix'] . '_vider_tables')) { |
|
| 177 | + $vider_tables($nom_meta, $table); |
|
| 178 | + } |
|
| 179 | + break; |
|
| 180 | + } |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | |
@@ -196,29 +196,29 @@ discard block |
||
| 196 | 196 | * @return array Tableau des plugins actifs |
| 197 | 197 | **/ |
| 198 | 198 | function liste_plugin_actifs() { |
| 199 | - $liste = $GLOBALS['meta']['plugin'] ?? ''; |
|
| 200 | - if (!$liste) { |
|
| 201 | - return []; |
|
| 202 | - } |
|
| 203 | - if (!is_array($liste = unserialize($liste))) { |
|
| 204 | - // compatibilite pre 1.9.2, mettre a jour la meta |
|
| 205 | - spip_log("MAJ meta plugin vieille version : $liste", 'plugin'); |
|
| 206 | - $new = true; |
|
| 207 | - [, $liste] = liste_plugin_valides(explode(',', $liste)); |
|
| 208 | - } else { |
|
| 209 | - $new = false; |
|
| 210 | - // compat au moment d'une migration depuis version anterieure |
|
| 211 | - // si pas de dir_type, alors c'est _DIR_PLUGINS |
|
| 212 | - foreach ($liste as $prefix => $infos) { |
|
| 213 | - if (!isset($infos['dir_type'])) { |
|
| 214 | - $liste[$prefix]['dir_type'] = '_DIR_PLUGINS'; |
|
| 215 | - $new = true; |
|
| 216 | - } |
|
| 217 | - } |
|
| 218 | - } |
|
| 219 | - if ($new) { |
|
| 220 | - ecrire_meta('plugin', serialize($liste)); |
|
| 221 | - } |
|
| 222 | - |
|
| 223 | - return $liste; |
|
| 199 | + $liste = $GLOBALS['meta']['plugin'] ?? ''; |
|
| 200 | + if (!$liste) { |
|
| 201 | + return []; |
|
| 202 | + } |
|
| 203 | + if (!is_array($liste = unserialize($liste))) { |
|
| 204 | + // compatibilite pre 1.9.2, mettre a jour la meta |
|
| 205 | + spip_log("MAJ meta plugin vieille version : $liste", 'plugin'); |
|
| 206 | + $new = true; |
|
| 207 | + [, $liste] = liste_plugin_valides(explode(',', $liste)); |
|
| 208 | + } else { |
|
| 209 | + $new = false; |
|
| 210 | + // compat au moment d'une migration depuis version anterieure |
|
| 211 | + // si pas de dir_type, alors c'est _DIR_PLUGINS |
|
| 212 | + foreach ($liste as $prefix => $infos) { |
|
| 213 | + if (!isset($infos['dir_type'])) { |
|
| 214 | + $liste[$prefix]['dir_type'] = '_DIR_PLUGINS'; |
|
| 215 | + $new = true; |
|
| 216 | + } |
|
| 217 | + } |
|
| 218 | + } |
|
| 219 | + if ($new) { |
|
| 220 | + ecrire_meta('plugin', serialize($liste)); |
|
| 221 | + } |
|
| 222 | + |
|
| 223 | + return $liste; |
|
| 224 | 224 | } |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | if (is_null($p)) { |
| 51 | - $arbre = ['erreur' => [_T('erreur_plugin_tag_plugin_absent') . " : $plug"]]; |
|
| 51 | + $arbre = ['erreur' => [_T('erreur_plugin_tag_plugin_absent')." : $plug"]]; |
|
| 52 | 52 | $silence = true; |
| 53 | 53 | } else { |
| 54 | 54 | $arbre = $p; |
@@ -83,15 +83,15 @@ discard block |
||
| 83 | 83 | if (isset($arbre['etat'])) { |
| 84 | 84 | $etat = trim(end($arbre['etat'])); |
| 85 | 85 | if (!in_array($etat, $etats)) { |
| 86 | - $arbre['erreur'][] = _T('erreur_plugin_etat_inconnu') . " : '$etat'"; |
|
| 86 | + $arbre['erreur'][] = _T('erreur_plugin_etat_inconnu')." : '$etat'"; |
|
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | if (isset($arbre['options'])) { |
| 90 | 90 | foreach ($arbre['options'] as $optfile) { |
| 91 | 91 | $optfile = trim($optfile); |
| 92 | - if (!@is_readable($dir_plugins . "$plug/$optfile")) { |
|
| 92 | + if (!@is_readable($dir_plugins."$plug/$optfile")) { |
|
| 93 | 93 | if (!$silence) { |
| 94 | - $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile"; |
|
| 94 | + $arbre['erreur'][] = _T('erreur_plugin_fichier_absent')." : $optfile"; |
|
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | } |
@@ -99,9 +99,9 @@ discard block |
||
| 99 | 99 | if (isset($arbre['fonctions'])) { |
| 100 | 100 | foreach ($arbre['fonctions'] as $optfile) { |
| 101 | 101 | $optfile = trim($optfile); |
| 102 | - if (!@is_readable($dir_plugins . "$plug/$optfile")) { |
|
| 102 | + if (!@is_readable($dir_plugins."$plug/$optfile")) { |
|
| 103 | 103 | if (!$silence) { |
| 104 | - $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile"; |
|
| 104 | + $arbre['erreur'][] = _T('erreur_plugin_fichier_absent')." : $optfile"; |
|
| 105 | 105 | } |
| 106 | 106 | } |
| 107 | 107 | } |
@@ -135,14 +135,14 @@ discard block |
||
| 135 | 135 | // verif que la methode a un nom autorise |
| 136 | 136 | if (in_array(strtolower($action), $liste_methodes_reservees)) { |
| 137 | 137 | if (!$silence) { |
| 138 | - $arbre['erreur'][] = _T('erreur_plugin_nom_fonction_interdit') . " : $action"; |
|
| 138 | + $arbre['erreur'][] = _T('erreur_plugin_nom_fonction_interdit')." : $action"; |
|
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | 141 | if (isset($pipe['inclure'])) { |
| 142 | - $inclure = $dir_plugins . "$plug/" . $pipe['inclure']; |
|
| 142 | + $inclure = $dir_plugins."$plug/".$pipe['inclure']; |
|
| 143 | 143 | if (!@is_readable($inclure)) { |
| 144 | 144 | if (!$silence) { |
| 145 | - $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $inclure"; |
|
| 145 | + $arbre['erreur'][] = _T('erreur_plugin_fichier_absent')." : $inclure"; |
|
| 146 | 146 | } |
| 147 | 147 | } |
| 148 | 148 | } |
@@ -212,9 +212,9 @@ discard block |
||
| 212 | 212 | foreach ($arbre['noisette'] as $k => $nut) { |
| 213 | 213 | $nut = preg_replace(',[.]html$,uims', '', trim($nut)); |
| 214 | 214 | $arbre['noisette'][$k] = $nut; |
| 215 | - if (!@is_readable($dir_plugins . "$plug/$nut.html")) { |
|
| 215 | + if (!@is_readable($dir_plugins."$plug/$nut.html")) { |
|
| 216 | 216 | if (!$silence) { |
| 217 | - $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $nut"; |
|
| 217 | + $arbre['erreur'][] = _T('erreur_plugin_fichier_absent')." : $nut"; |
|
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | 220 | } |
@@ -11,225 +11,225 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_spip('inc/xml'); |
| 18 | 18 | include_spip('inc/plugin'); |
| 19 | 19 | |
| 20 | 20 | function plugins_verifie_conformite_dist($plug, &$arbre, $dir_plugins = _DIR_PLUGINS) { |
| 21 | - $needs = null; |
|
| 22 | - $compat_spip = null; |
|
| 23 | - $uses = null; |
|
| 24 | - $paths = null; |
|
| 25 | - $trads = null; |
|
| 26 | - static $etats = ['dev', 'experimental', 'test', 'stable']; |
|
| 21 | + $needs = null; |
|
| 22 | + $compat_spip = null; |
|
| 23 | + $uses = null; |
|
| 24 | + $paths = null; |
|
| 25 | + $trads = null; |
|
| 26 | + static $etats = ['dev', 'experimental', 'test', 'stable']; |
|
| 27 | 27 | |
| 28 | - $matches = []; |
|
| 29 | - $silence = false; |
|
| 30 | - $p = null; |
|
| 31 | - // chercher la declaration <plugin spip='...'> a prendre pour cette version de SPIP |
|
| 32 | - if ($n = spip_xml_match_nodes(',^plugin(\s|$),', $arbre, $matches)) { |
|
| 33 | - // version de SPIP |
|
| 34 | - $vspip = $GLOBALS['spip_version_branche']; |
|
| 35 | - foreach ($matches as $tag => $sous) { |
|
| 36 | - [$tagname, $atts] = spip_xml_decompose_tag($tag); |
|
| 37 | - if ($tagname == 'plugin' and is_array($sous)) { |
|
| 38 | - // On rajoute la condition sur $n : |
|
| 39 | - // -- en effet si $n==1 on a pas plus a choisir la balise que l'on ait |
|
| 40 | - // un attribut spip ou pas. Cela permet de traiter tous les cas mono-balise |
|
| 41 | - // de la meme facon. |
|
| 42 | - if ( |
|
| 43 | - !isset($atts['spip']) |
|
| 44 | - or $n == 1 |
|
| 45 | - or plugin_version_compatible($atts['spip'], $vspip, 'spip') |
|
| 46 | - ) { |
|
| 47 | - // on prend la derniere declaration avec ce nom |
|
| 48 | - $p = end($sous); |
|
| 49 | - $compat_spip = $atts['spip'] ?? ''; |
|
| 50 | - } |
|
| 51 | - } |
|
| 52 | - } |
|
| 53 | - } |
|
| 54 | - if (is_null($p)) { |
|
| 55 | - $arbre = ['erreur' => [_T('erreur_plugin_tag_plugin_absent') . " : $plug"]]; |
|
| 56 | - $silence = true; |
|
| 57 | - } else { |
|
| 58 | - $arbre = $p; |
|
| 59 | - } |
|
| 60 | - if (!is_array($arbre)) { |
|
| 61 | - $arbre = []; |
|
| 62 | - } |
|
| 63 | - // verification de la conformite du plugin avec quelques |
|
| 64 | - // precautions elementaires |
|
| 65 | - if (!isset($arbre['nom'])) { |
|
| 66 | - if (!$silence) { |
|
| 67 | - $arbre['erreur'][] = _T('erreur_plugin_nom_manquant'); |
|
| 68 | - } |
|
| 69 | - $arbre['nom'] = ['']; |
|
| 70 | - } |
|
| 71 | - if (!isset($arbre['version'])) { |
|
| 72 | - if (!$silence) { |
|
| 73 | - $arbre['erreur'][] = _T('erreur_plugin_version_manquant'); |
|
| 74 | - } |
|
| 75 | - $arbre['version'] = ['']; |
|
| 76 | - } |
|
| 77 | - if (!isset($arbre['prefix'])) { |
|
| 78 | - if (!$silence) { |
|
| 79 | - $arbre['erreur'][] = _T('erreur_plugin_prefix_manquant'); |
|
| 80 | - } |
|
| 81 | - $arbre['prefix'] = ['']; |
|
| 82 | - } else { |
|
| 83 | - $prefix = trim(end($arbre['prefix'])); |
|
| 84 | - if (strtoupper($prefix) == 'SPIP' and $plug != './') { |
|
| 85 | - $arbre['erreur'][] = _T('erreur_plugin_prefix_interdit'); |
|
| 86 | - } |
|
| 87 | - if (isset($arbre['etat'])) { |
|
| 88 | - $etat = trim(end($arbre['etat'])); |
|
| 89 | - if (!in_array($etat, $etats)) { |
|
| 90 | - $arbre['erreur'][] = _T('erreur_plugin_etat_inconnu') . " : '$etat'"; |
|
| 91 | - } |
|
| 92 | - } |
|
| 93 | - if (isset($arbre['options'])) { |
|
| 94 | - foreach ($arbre['options'] as $optfile) { |
|
| 95 | - $optfile = trim($optfile); |
|
| 96 | - if (!@is_readable($dir_plugins . "$plug/$optfile")) { |
|
| 97 | - if (!$silence) { |
|
| 98 | - $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile"; |
|
| 99 | - } |
|
| 100 | - } |
|
| 101 | - } |
|
| 102 | - } |
|
| 103 | - if (isset($arbre['fonctions'])) { |
|
| 104 | - foreach ($arbre['fonctions'] as $optfile) { |
|
| 105 | - $optfile = trim($optfile); |
|
| 106 | - if (!@is_readable($dir_plugins . "$plug/$optfile")) { |
|
| 107 | - if (!$silence) { |
|
| 108 | - $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile"; |
|
| 109 | - } |
|
| 110 | - } |
|
| 111 | - } |
|
| 112 | - } |
|
| 113 | - $fonctions = []; |
|
| 114 | - if (isset($arbre['fonctions'])) { |
|
| 115 | - $fonctions = $arbre['fonctions']; |
|
| 116 | - } |
|
| 117 | - $liste_methodes_reservees = [ |
|
| 118 | - '__construct', |
|
| 119 | - '__destruct', |
|
| 120 | - 'plugin', |
|
| 121 | - 'install', |
|
| 122 | - 'uninstall', |
|
| 123 | - strtolower($prefix) |
|
| 124 | - ]; |
|
| 28 | + $matches = []; |
|
| 29 | + $silence = false; |
|
| 30 | + $p = null; |
|
| 31 | + // chercher la declaration <plugin spip='...'> a prendre pour cette version de SPIP |
|
| 32 | + if ($n = spip_xml_match_nodes(',^plugin(\s|$),', $arbre, $matches)) { |
|
| 33 | + // version de SPIP |
|
| 34 | + $vspip = $GLOBALS['spip_version_branche']; |
|
| 35 | + foreach ($matches as $tag => $sous) { |
|
| 36 | + [$tagname, $atts] = spip_xml_decompose_tag($tag); |
|
| 37 | + if ($tagname == 'plugin' and is_array($sous)) { |
|
| 38 | + // On rajoute la condition sur $n : |
|
| 39 | + // -- en effet si $n==1 on a pas plus a choisir la balise que l'on ait |
|
| 40 | + // un attribut spip ou pas. Cela permet de traiter tous les cas mono-balise |
|
| 41 | + // de la meme facon. |
|
| 42 | + if ( |
|
| 43 | + !isset($atts['spip']) |
|
| 44 | + or $n == 1 |
|
| 45 | + or plugin_version_compatible($atts['spip'], $vspip, 'spip') |
|
| 46 | + ) { |
|
| 47 | + // on prend la derniere declaration avec ce nom |
|
| 48 | + $p = end($sous); |
|
| 49 | + $compat_spip = $atts['spip'] ?? ''; |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | + } |
|
| 54 | + if (is_null($p)) { |
|
| 55 | + $arbre = ['erreur' => [_T('erreur_plugin_tag_plugin_absent') . " : $plug"]]; |
|
| 56 | + $silence = true; |
|
| 57 | + } else { |
|
| 58 | + $arbre = $p; |
|
| 59 | + } |
|
| 60 | + if (!is_array($arbre)) { |
|
| 61 | + $arbre = []; |
|
| 62 | + } |
|
| 63 | + // verification de la conformite du plugin avec quelques |
|
| 64 | + // precautions elementaires |
|
| 65 | + if (!isset($arbre['nom'])) { |
|
| 66 | + if (!$silence) { |
|
| 67 | + $arbre['erreur'][] = _T('erreur_plugin_nom_manquant'); |
|
| 68 | + } |
|
| 69 | + $arbre['nom'] = ['']; |
|
| 70 | + } |
|
| 71 | + if (!isset($arbre['version'])) { |
|
| 72 | + if (!$silence) { |
|
| 73 | + $arbre['erreur'][] = _T('erreur_plugin_version_manquant'); |
|
| 74 | + } |
|
| 75 | + $arbre['version'] = ['']; |
|
| 76 | + } |
|
| 77 | + if (!isset($arbre['prefix'])) { |
|
| 78 | + if (!$silence) { |
|
| 79 | + $arbre['erreur'][] = _T('erreur_plugin_prefix_manquant'); |
|
| 80 | + } |
|
| 81 | + $arbre['prefix'] = ['']; |
|
| 82 | + } else { |
|
| 83 | + $prefix = trim(end($arbre['prefix'])); |
|
| 84 | + if (strtoupper($prefix) == 'SPIP' and $plug != './') { |
|
| 85 | + $arbre['erreur'][] = _T('erreur_plugin_prefix_interdit'); |
|
| 86 | + } |
|
| 87 | + if (isset($arbre['etat'])) { |
|
| 88 | + $etat = trim(end($arbre['etat'])); |
|
| 89 | + if (!in_array($etat, $etats)) { |
|
| 90 | + $arbre['erreur'][] = _T('erreur_plugin_etat_inconnu') . " : '$etat'"; |
|
| 91 | + } |
|
| 92 | + } |
|
| 93 | + if (isset($arbre['options'])) { |
|
| 94 | + foreach ($arbre['options'] as $optfile) { |
|
| 95 | + $optfile = trim($optfile); |
|
| 96 | + if (!@is_readable($dir_plugins . "$plug/$optfile")) { |
|
| 97 | + if (!$silence) { |
|
| 98 | + $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile"; |
|
| 99 | + } |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | + if (isset($arbre['fonctions'])) { |
|
| 104 | + foreach ($arbre['fonctions'] as $optfile) { |
|
| 105 | + $optfile = trim($optfile); |
|
| 106 | + if (!@is_readable($dir_plugins . "$plug/$optfile")) { |
|
| 107 | + if (!$silence) { |
|
| 108 | + $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile"; |
|
| 109 | + } |
|
| 110 | + } |
|
| 111 | + } |
|
| 112 | + } |
|
| 113 | + $fonctions = []; |
|
| 114 | + if (isset($arbre['fonctions'])) { |
|
| 115 | + $fonctions = $arbre['fonctions']; |
|
| 116 | + } |
|
| 117 | + $liste_methodes_reservees = [ |
|
| 118 | + '__construct', |
|
| 119 | + '__destruct', |
|
| 120 | + 'plugin', |
|
| 121 | + 'install', |
|
| 122 | + 'uninstall', |
|
| 123 | + strtolower($prefix) |
|
| 124 | + ]; |
|
| 125 | 125 | |
| 126 | - $extraire_pipelines = charger_fonction('extraire_pipelines', 'plugins'); |
|
| 127 | - $arbre['pipeline'] = $extraire_pipelines($arbre); |
|
| 128 | - foreach ($arbre['pipeline'] as $pipe) { |
|
| 129 | - if (!isset($pipe['nom'])) { |
|
| 130 | - if (!$silence) { |
|
| 131 | - $arbre['erreur'][] = _T('erreur_plugin_nom_pipeline_non_defini'); |
|
| 132 | - } |
|
| 133 | - } |
|
| 134 | - if (isset($pipe['action'])) { |
|
| 135 | - $action = $pipe['action']; |
|
| 136 | - } else { |
|
| 137 | - $action = $pipe['nom']; |
|
| 138 | - } |
|
| 139 | - // verif que la methode a un nom autorise |
|
| 140 | - if (in_array(strtolower($action), $liste_methodes_reservees)) { |
|
| 141 | - if (!$silence) { |
|
| 142 | - $arbre['erreur'][] = _T('erreur_plugin_nom_fonction_interdit') . " : $action"; |
|
| 143 | - } |
|
| 144 | - } |
|
| 145 | - if (isset($pipe['inclure'])) { |
|
| 146 | - $inclure = $dir_plugins . "$plug/" . $pipe['inclure']; |
|
| 147 | - if (!@is_readable($inclure)) { |
|
| 148 | - if (!$silence) { |
|
| 149 | - $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $inclure"; |
|
| 150 | - } |
|
| 151 | - } |
|
| 152 | - } |
|
| 153 | - } |
|
| 154 | - $necessite = []; |
|
| 155 | - $spip_trouve = false; |
|
| 156 | - if (spip_xml_match_nodes(',^necessite,', $arbre, $needs)) { |
|
| 157 | - foreach (array_keys($needs) as $tag) { |
|
| 158 | - [$tag, $att] = spip_xml_decompose_tag($tag); |
|
| 159 | - if (!isset($att['id'])) { |
|
| 160 | - if (!$silence) { |
|
| 161 | - $arbre['erreur'][] = _T( |
|
| 162 | - 'erreur_plugin_attribut_balise_manquant', |
|
| 163 | - ['attribut' => 'id', 'balise' => $att] |
|
| 164 | - ); |
|
| 165 | - } |
|
| 166 | - } else { |
|
| 167 | - $necessite[] = $att; |
|
| 168 | - } |
|
| 169 | - if (strtolower($att['id']) == 'spip') { |
|
| 170 | - $spip_trouve = true; |
|
| 171 | - } |
|
| 172 | - } |
|
| 173 | - } |
|
| 174 | - if ($compat_spip and !$spip_trouve) { |
|
| 175 | - $necessite[] = ['id' => 'spip', 'version' => $compat_spip]; |
|
| 176 | - } |
|
| 177 | - $arbre['necessite'] = $necessite; |
|
| 178 | - $utilise = []; |
|
| 179 | - if (spip_xml_match_nodes(',^utilise,', $arbre, $uses)) { |
|
| 180 | - foreach (array_keys($uses) as $tag) { |
|
| 181 | - [$tag, $att] = spip_xml_decompose_tag($tag); |
|
| 182 | - if (!isset($att['id'])) { |
|
| 183 | - if (!$silence) { |
|
| 184 | - $arbre['erreur'][] = _T( |
|
| 185 | - 'erreur_plugin_attribut_balise_manquant', |
|
| 186 | - ['attribut' => 'id', 'balise' => $att] |
|
| 187 | - ); |
|
| 188 | - } |
|
| 189 | - } else { |
|
| 190 | - $utilise[] = $att; |
|
| 191 | - } |
|
| 192 | - } |
|
| 193 | - } |
|
| 194 | - $arbre['utilise'] = $utilise; |
|
| 195 | - $procure = []; |
|
| 196 | - if (spip_xml_match_nodes(',^procure,', $arbre, $uses)) { |
|
| 197 | - foreach (array_keys($uses) as $tag) { |
|
| 198 | - [$tag, $att] = spip_xml_decompose_tag($tag); |
|
| 199 | - $procure[] = $att; |
|
| 200 | - } |
|
| 201 | - } |
|
| 202 | - $arbre['procure'] = $procure; |
|
| 203 | - $path = []; |
|
| 204 | - if (spip_xml_match_nodes(',^chemin,', $arbre, $paths)) { |
|
| 205 | - foreach (array_keys($paths) as $tag) { |
|
| 206 | - [$tag, $att] = spip_xml_decompose_tag($tag); |
|
| 207 | - $att['path'] = $att['dir']; // ancienne syntaxe |
|
| 208 | - $path[] = $att; |
|
| 209 | - } |
|
| 210 | - } else { |
|
| 211 | - $path = [['dir' => '']]; |
|
| 212 | - } // initialiser par defaut |
|
| 213 | - $arbre['path'] = $path; |
|
| 214 | - // exposer les noisettes |
|
| 215 | - if (isset($arbre['noisette'])) { |
|
| 216 | - foreach ($arbre['noisette'] as $k => $nut) { |
|
| 217 | - $nut = preg_replace(',[.]html$,uims', '', trim($nut)); |
|
| 218 | - $arbre['noisette'][$k] = $nut; |
|
| 219 | - if (!@is_readable($dir_plugins . "$plug/$nut.html")) { |
|
| 220 | - if (!$silence) { |
|
| 221 | - $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $nut"; |
|
| 222 | - } |
|
| 223 | - } |
|
| 224 | - } |
|
| 225 | - } |
|
| 226 | - $traduire = []; |
|
| 227 | - if (spip_xml_match_nodes(',^traduire,', $arbre, $trads)) { |
|
| 228 | - foreach (array_keys($trads) as $tag) { |
|
| 229 | - [$tag, $att] = spip_xml_decompose_tag($tag); |
|
| 230 | - $traduire[] = $att; |
|
| 231 | - } |
|
| 232 | - } |
|
| 233 | - $arbre['traduire'] = $traduire; |
|
| 234 | - } |
|
| 126 | + $extraire_pipelines = charger_fonction('extraire_pipelines', 'plugins'); |
|
| 127 | + $arbre['pipeline'] = $extraire_pipelines($arbre); |
|
| 128 | + foreach ($arbre['pipeline'] as $pipe) { |
|
| 129 | + if (!isset($pipe['nom'])) { |
|
| 130 | + if (!$silence) { |
|
| 131 | + $arbre['erreur'][] = _T('erreur_plugin_nom_pipeline_non_defini'); |
|
| 132 | + } |
|
| 133 | + } |
|
| 134 | + if (isset($pipe['action'])) { |
|
| 135 | + $action = $pipe['action']; |
|
| 136 | + } else { |
|
| 137 | + $action = $pipe['nom']; |
|
| 138 | + } |
|
| 139 | + // verif que la methode a un nom autorise |
|
| 140 | + if (in_array(strtolower($action), $liste_methodes_reservees)) { |
|
| 141 | + if (!$silence) { |
|
| 142 | + $arbre['erreur'][] = _T('erreur_plugin_nom_fonction_interdit') . " : $action"; |
|
| 143 | + } |
|
| 144 | + } |
|
| 145 | + if (isset($pipe['inclure'])) { |
|
| 146 | + $inclure = $dir_plugins . "$plug/" . $pipe['inclure']; |
|
| 147 | + if (!@is_readable($inclure)) { |
|
| 148 | + if (!$silence) { |
|
| 149 | + $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $inclure"; |
|
| 150 | + } |
|
| 151 | + } |
|
| 152 | + } |
|
| 153 | + } |
|
| 154 | + $necessite = []; |
|
| 155 | + $spip_trouve = false; |
|
| 156 | + if (spip_xml_match_nodes(',^necessite,', $arbre, $needs)) { |
|
| 157 | + foreach (array_keys($needs) as $tag) { |
|
| 158 | + [$tag, $att] = spip_xml_decompose_tag($tag); |
|
| 159 | + if (!isset($att['id'])) { |
|
| 160 | + if (!$silence) { |
|
| 161 | + $arbre['erreur'][] = _T( |
|
| 162 | + 'erreur_plugin_attribut_balise_manquant', |
|
| 163 | + ['attribut' => 'id', 'balise' => $att] |
|
| 164 | + ); |
|
| 165 | + } |
|
| 166 | + } else { |
|
| 167 | + $necessite[] = $att; |
|
| 168 | + } |
|
| 169 | + if (strtolower($att['id']) == 'spip') { |
|
| 170 | + $spip_trouve = true; |
|
| 171 | + } |
|
| 172 | + } |
|
| 173 | + } |
|
| 174 | + if ($compat_spip and !$spip_trouve) { |
|
| 175 | + $necessite[] = ['id' => 'spip', 'version' => $compat_spip]; |
|
| 176 | + } |
|
| 177 | + $arbre['necessite'] = $necessite; |
|
| 178 | + $utilise = []; |
|
| 179 | + if (spip_xml_match_nodes(',^utilise,', $arbre, $uses)) { |
|
| 180 | + foreach (array_keys($uses) as $tag) { |
|
| 181 | + [$tag, $att] = spip_xml_decompose_tag($tag); |
|
| 182 | + if (!isset($att['id'])) { |
|
| 183 | + if (!$silence) { |
|
| 184 | + $arbre['erreur'][] = _T( |
|
| 185 | + 'erreur_plugin_attribut_balise_manquant', |
|
| 186 | + ['attribut' => 'id', 'balise' => $att] |
|
| 187 | + ); |
|
| 188 | + } |
|
| 189 | + } else { |
|
| 190 | + $utilise[] = $att; |
|
| 191 | + } |
|
| 192 | + } |
|
| 193 | + } |
|
| 194 | + $arbre['utilise'] = $utilise; |
|
| 195 | + $procure = []; |
|
| 196 | + if (spip_xml_match_nodes(',^procure,', $arbre, $uses)) { |
|
| 197 | + foreach (array_keys($uses) as $tag) { |
|
| 198 | + [$tag, $att] = spip_xml_decompose_tag($tag); |
|
| 199 | + $procure[] = $att; |
|
| 200 | + } |
|
| 201 | + } |
|
| 202 | + $arbre['procure'] = $procure; |
|
| 203 | + $path = []; |
|
| 204 | + if (spip_xml_match_nodes(',^chemin,', $arbre, $paths)) { |
|
| 205 | + foreach (array_keys($paths) as $tag) { |
|
| 206 | + [$tag, $att] = spip_xml_decompose_tag($tag); |
|
| 207 | + $att['path'] = $att['dir']; // ancienne syntaxe |
|
| 208 | + $path[] = $att; |
|
| 209 | + } |
|
| 210 | + } else { |
|
| 211 | + $path = [['dir' => '']]; |
|
| 212 | + } // initialiser par defaut |
|
| 213 | + $arbre['path'] = $path; |
|
| 214 | + // exposer les noisettes |
|
| 215 | + if (isset($arbre['noisette'])) { |
|
| 216 | + foreach ($arbre['noisette'] as $k => $nut) { |
|
| 217 | + $nut = preg_replace(',[.]html$,uims', '', trim($nut)); |
|
| 218 | + $arbre['noisette'][$k] = $nut; |
|
| 219 | + if (!@is_readable($dir_plugins . "$plug/$nut.html")) { |
|
| 220 | + if (!$silence) { |
|
| 221 | + $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $nut"; |
|
| 222 | + } |
|
| 223 | + } |
|
| 224 | + } |
|
| 225 | + } |
|
| 226 | + $traduire = []; |
|
| 227 | + if (spip_xml_match_nodes(',^traduire,', $arbre, $trads)) { |
|
| 228 | + foreach (array_keys($trads) as $tag) { |
|
| 229 | + [$tag, $att] = spip_xml_decompose_tag($tag); |
|
| 230 | + $traduire[] = $att; |
|
| 231 | + } |
|
| 232 | + } |
|
| 233 | + $arbre['traduire'] = $traduire; |
|
| 234 | + } |
|
| 235 | 235 | } |