@@ -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 | /** |
@@ -32,28 +32,28 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | function action_desinstaller_plugin_dist() { |
| 34 | 34 | |
| 35 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 36 | - $arg = $securiser_action(); |
|
| 37 | - list($dir_plugins, $plugin) = explode("::", $arg); |
|
| 38 | - $dir_type = "_DIR_PLUGINS"; |
|
| 39 | - if (defined('_DIR_PLUGINS_SUPPL') and $dir_plugins == _DIR_PLUGINS_SUPPL) { |
|
| 40 | - $dir_type = "_DIR_PLUGINS_SUPPL"; |
|
| 41 | - } |
|
| 42 | - $installer_plugins = charger_fonction('installer', 'plugins'); |
|
| 43 | - $infos = $installer_plugins($plugin, 'uninstall', $dir_type); |
|
| 44 | - if ($infos and !$infos['install_test'][0]) { |
|
| 45 | - include_spip('inc/plugin'); |
|
| 46 | - ecrire_plugin_actifs(array($plugin), false, 'enleve'); |
|
| 47 | - $erreur = ''; |
|
| 48 | - } else { |
|
| 49 | - $erreur = 'erreur_plugin_desinstalation_echouee'; |
|
| 50 | - } |
|
| 51 | - if ($redirect = _request('redirect')) { |
|
| 52 | - include_spip('inc/headers'); |
|
| 53 | - if ($erreur) { |
|
| 54 | - $redirect = parametre_url($redirect, 'erreur', $erreur); |
|
| 55 | - } |
|
| 56 | - $redirect = str_replace('&', '&', $redirect); |
|
| 57 | - redirige_par_entete($redirect); |
|
| 58 | - } |
|
| 35 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 36 | + $arg = $securiser_action(); |
|
| 37 | + list($dir_plugins, $plugin) = explode("::", $arg); |
|
| 38 | + $dir_type = "_DIR_PLUGINS"; |
|
| 39 | + if (defined('_DIR_PLUGINS_SUPPL') and $dir_plugins == _DIR_PLUGINS_SUPPL) { |
|
| 40 | + $dir_type = "_DIR_PLUGINS_SUPPL"; |
|
| 41 | + } |
|
| 42 | + $installer_plugins = charger_fonction('installer', 'plugins'); |
|
| 43 | + $infos = $installer_plugins($plugin, 'uninstall', $dir_type); |
|
| 44 | + if ($infos and !$infos['install_test'][0]) { |
|
| 45 | + include_spip('inc/plugin'); |
|
| 46 | + ecrire_plugin_actifs(array($plugin), false, 'enleve'); |
|
| 47 | + $erreur = ''; |
|
| 48 | + } else { |
|
| 49 | + $erreur = 'erreur_plugin_desinstalation_echouee'; |
|
| 50 | + } |
|
| 51 | + if ($redirect = _request('redirect')) { |
|
| 52 | + include_spip('inc/headers'); |
|
| 53 | + if ($erreur) { |
|
| 54 | + $redirect = parametre_url($redirect, 'erreur', $erreur); |
|
| 55 | + } |
|
| 56 | + $redirect = str_replace('&', '&', $redirect); |
|
| 57 | + redirige_par_entete($redirect); |
|
| 58 | + } |
|
| 59 | 59 | } |
@@ -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'); |
@@ -33,84 +33,84 @@ discard block |
||
| 33 | 33 | * @return void |
| 34 | 34 | */ |
| 35 | 35 | function action_cookie_dist($set_cookie_admin = null, $change_session = null) { |
| 36 | - $redirect_echec = $redirect = null; |
|
| 37 | - $test_echec_cookie = null; |
|
| 38 | - $url = ""; |
|
| 39 | - if (is_null($set_cookie_admin)) { |
|
| 40 | - $set_cookie_admin = _request('cookie_admin'); |
|
| 41 | - $change_session = _request('change_session'); |
|
| 42 | - $test_echec_cookie = _request('test_echec_cookie'); |
|
| 36 | + $redirect_echec = $redirect = null; |
|
| 37 | + $test_echec_cookie = null; |
|
| 38 | + $url = ""; |
|
| 39 | + if (is_null($set_cookie_admin)) { |
|
| 40 | + $set_cookie_admin = _request('cookie_admin'); |
|
| 41 | + $change_session = _request('change_session'); |
|
| 42 | + $test_echec_cookie = _request('test_echec_cookie'); |
|
| 43 | 43 | |
| 44 | - // La cible de notre operation de connexion |
|
| 45 | - $url = securiser_redirect_action(_request('url')); |
|
| 46 | - $redirect = $url ? $url : generer_url_ecrire('accueil'); |
|
| 47 | - $redirect_echec = _request('url_echec'); |
|
| 48 | - if (!isset($redirect_echec)) { |
|
| 49 | - if (strpos($redirect, _DIR_RESTREINT_ABS) !== false) { |
|
| 50 | - $redirect_echec = generer_url_public('login', '', true); |
|
| 51 | - } else { |
|
| 52 | - $redirect_echec = $redirect; |
|
| 53 | - } |
|
| 54 | - } |
|
| 55 | - } |
|
| 44 | + // La cible de notre operation de connexion |
|
| 45 | + $url = securiser_redirect_action(_request('url')); |
|
| 46 | + $redirect = $url ? $url : generer_url_ecrire('accueil'); |
|
| 47 | + $redirect_echec = _request('url_echec'); |
|
| 48 | + if (!isset($redirect_echec)) { |
|
| 49 | + if (strpos($redirect, _DIR_RESTREINT_ABS) !== false) { |
|
| 50 | + $redirect_echec = generer_url_public('login', '', true); |
|
| 51 | + } else { |
|
| 52 | + $redirect_echec = $redirect; |
|
| 53 | + } |
|
| 54 | + } |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | 57 | |
| 58 | - // rejoue le cookie pour renouveler spip_session |
|
| 59 | - if ($change_session == 'oui') { |
|
| 60 | - $session = charger_fonction('session', 'inc'); |
|
| 61 | - $session(true); |
|
| 62 | - spip_log("statut 204 pour " . $_SERVER['REQUEST_URI']); |
|
| 63 | - http_status(204); // No Content |
|
| 64 | - return; |
|
| 65 | - } |
|
| 58 | + // rejoue le cookie pour renouveler spip_session |
|
| 59 | + if ($change_session == 'oui') { |
|
| 60 | + $session = charger_fonction('session', 'inc'); |
|
| 61 | + $session(true); |
|
| 62 | + spip_log("statut 204 pour " . $_SERVER['REQUEST_URI']); |
|
| 63 | + http_status(204); // No Content |
|
| 64 | + return; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - // tentative de connexion en auth_http |
|
| 68 | - if (_request('essai_auth_http') and !$GLOBALS['ignore_auth_http']) { |
|
| 69 | - include_spip('inc/auth'); |
|
| 70 | - if (@$_SERVER['PHP_AUTH_USER'] |
|
| 71 | - and @$_SERVER['PHP_AUTH_PW'] |
|
| 72 | - and $auteur = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) |
|
| 73 | - ) { |
|
| 74 | - auth_loger($auteur); |
|
| 75 | - redirige_par_entete(parametre_url($redirect, 't', time(), '&')); |
|
| 76 | - } else { |
|
| 77 | - ask_php_auth(_T('info_connexion_refusee'), |
|
| 78 | - _T('login_login_pass_incorrect'), |
|
| 79 | - _T('login_retour_site'), |
|
| 80 | - "url=" . rawurlencode($redirect), |
|
| 81 | - _T('login_nouvelle_tentative'), |
|
| 82 | - (strpos($url, _DIR_RESTREINT_ABS) !== false)); |
|
| 83 | - } |
|
| 84 | - } else { |
|
| 67 | + // tentative de connexion en auth_http |
|
| 68 | + if (_request('essai_auth_http') and !$GLOBALS['ignore_auth_http']) { |
|
| 69 | + include_spip('inc/auth'); |
|
| 70 | + if (@$_SERVER['PHP_AUTH_USER'] |
|
| 71 | + and @$_SERVER['PHP_AUTH_PW'] |
|
| 72 | + and $auteur = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) |
|
| 73 | + ) { |
|
| 74 | + auth_loger($auteur); |
|
| 75 | + redirige_par_entete(parametre_url($redirect, 't', time(), '&')); |
|
| 76 | + } else { |
|
| 77 | + ask_php_auth(_T('info_connexion_refusee'), |
|
| 78 | + _T('login_login_pass_incorrect'), |
|
| 79 | + _T('login_retour_site'), |
|
| 80 | + "url=" . rawurlencode($redirect), |
|
| 81 | + _T('login_nouvelle_tentative'), |
|
| 82 | + (strpos($url, _DIR_RESTREINT_ABS) !== false)); |
|
| 83 | + } |
|
| 84 | + } else { |
|
| 85 | 85 | |
| 86 | - // en cas de login sur bonjour=oui, on tente de poser un cookie |
|
| 87 | - // puis de passer au login qui diagnostiquera l'echec de cookie |
|
| 88 | - // le cas echeant. |
|
| 89 | - if ($test_echec_cookie == 'oui') { |
|
| 90 | - spip_setcookie('spip_session', 'test_echec_cookie'); |
|
| 91 | - if ($redirect) { |
|
| 92 | - $redirect = parametre_url(parametre_url($redirect_echec, 'var_echec_cookie', 'oui', '&'), 'url', |
|
| 93 | - rawurlencode($redirect), '&'); |
|
| 94 | - } |
|
| 95 | - } else { |
|
| 86 | + // en cas de login sur bonjour=oui, on tente de poser un cookie |
|
| 87 | + // puis de passer au login qui diagnostiquera l'echec de cookie |
|
| 88 | + // le cas echeant. |
|
| 89 | + if ($test_echec_cookie == 'oui') { |
|
| 90 | + spip_setcookie('spip_session', 'test_echec_cookie'); |
|
| 91 | + if ($redirect) { |
|
| 92 | + $redirect = parametre_url(parametre_url($redirect_echec, 'var_echec_cookie', 'oui', '&'), 'url', |
|
| 93 | + rawurlencode($redirect), '&'); |
|
| 94 | + } |
|
| 95 | + } else { |
|
| 96 | 96 | |
| 97 | - $cook = isset($_COOKIE['spip_admin']) ? $_COOKIE['spip_admin'] : ''; |
|
| 98 | - // Suppression cookie d'admin ? |
|
| 99 | - if ($set_cookie_admin == "non") { |
|
| 100 | - if ($cook) { |
|
| 101 | - spip_setcookie('spip_admin', $cook, time() - 3600 * 24); |
|
| 102 | - } |
|
| 103 | - } // Ajout de cookie d'admin |
|
| 104 | - else { |
|
| 105 | - if ($set_cookie_admin and _DUREE_COOKIE_ADMIN) { |
|
| 106 | - spip_setcookie('spip_admin', $set_cookie_admin, time() + max(_DUREE_COOKIE_ADMIN, 2 * _RENOUVELLE_ALEA)); |
|
| 107 | - } |
|
| 108 | - } |
|
| 109 | - } |
|
| 110 | - } |
|
| 97 | + $cook = isset($_COOKIE['spip_admin']) ? $_COOKIE['spip_admin'] : ''; |
|
| 98 | + // Suppression cookie d'admin ? |
|
| 99 | + if ($set_cookie_admin == "non") { |
|
| 100 | + if ($cook) { |
|
| 101 | + spip_setcookie('spip_admin', $cook, time() - 3600 * 24); |
|
| 102 | + } |
|
| 103 | + } // Ajout de cookie d'admin |
|
| 104 | + else { |
|
| 105 | + if ($set_cookie_admin and _DUREE_COOKIE_ADMIN) { |
|
| 106 | + spip_setcookie('spip_admin', $set_cookie_admin, time() + max(_DUREE_COOKIE_ADMIN, 2 * _RENOUVELLE_ALEA)); |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | - // Redirection finale |
|
| 113 | - if ($redirect) { |
|
| 114 | - redirige_par_entete($redirect, true); |
|
| 115 | - } |
|
| 112 | + // Redirection finale |
|
| 113 | + if ($redirect) { |
|
| 114 | + redirige_par_entete($redirect, true); |
|
| 115 | + } |
|
| 116 | 116 | } |
@@ -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,34 +25,34 @@ discard block |
||
| 25 | 25 | **/ |
| 26 | 26 | function action_instituer_langue_rubrique_dist() { |
| 27 | 27 | |
| 28 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 29 | - $arg = $securiser_action(); |
|
| 30 | - $changer_lang = _request('changer_lang'); |
|
| 31 | - |
|
| 32 | - list($id_rubrique, $id_parent) = preg_split('/\W/', $arg); |
|
| 33 | - |
|
| 34 | - if ($changer_lang |
|
| 35 | - and $id_rubrique > 0 |
|
| 36 | - and $GLOBALS['meta']['multi_rubriques'] == 'oui' |
|
| 37 | - and ($GLOBALS['meta']['multi_secteurs'] == 'non' or $id_parent == 0) |
|
| 38 | - ) { |
|
| 39 | - if ($changer_lang != "herit") { |
|
| 40 | - sql_updateq('spip_rubriques', array('lang' => $changer_lang, 'langue_choisie' => 'oui'), |
|
| 41 | - "id_rubrique=$id_rubrique"); |
|
| 42 | - } else { |
|
| 43 | - if ($id_parent == 0) { |
|
| 44 | - $langue_parent = $GLOBALS['meta']['langue_site']; |
|
| 45 | - } else { |
|
| 46 | - $langue_parent = sql_getfetsel("lang", "spip_rubriques", "id_rubrique=$id_parent"); |
|
| 47 | - } |
|
| 48 | - sql_updateq('spip_rubriques', array('lang' => $langue_parent, 'langue_choisie' => 'non'), |
|
| 49 | - "id_rubrique=$id_rubrique"); |
|
| 50 | - } |
|
| 51 | - include_spip('inc/rubriques'); |
|
| 52 | - calculer_langues_rubriques(); |
|
| 53 | - |
|
| 54 | - // invalider les caches marques de cette rubrique |
|
| 55 | - include_spip('inc/invalideur'); |
|
| 56 | - suivre_invalideur("id='rubrique/$id_rubrique'"); |
|
| 57 | - } |
|
| 28 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 29 | + $arg = $securiser_action(); |
|
| 30 | + $changer_lang = _request('changer_lang'); |
|
| 31 | + |
|
| 32 | + list($id_rubrique, $id_parent) = preg_split('/\W/', $arg); |
|
| 33 | + |
|
| 34 | + if ($changer_lang |
|
| 35 | + and $id_rubrique > 0 |
|
| 36 | + and $GLOBALS['meta']['multi_rubriques'] == 'oui' |
|
| 37 | + and ($GLOBALS['meta']['multi_secteurs'] == 'non' or $id_parent == 0) |
|
| 38 | + ) { |
|
| 39 | + if ($changer_lang != "herit") { |
|
| 40 | + sql_updateq('spip_rubriques', array('lang' => $changer_lang, 'langue_choisie' => 'oui'), |
|
| 41 | + "id_rubrique=$id_rubrique"); |
|
| 42 | + } else { |
|
| 43 | + if ($id_parent == 0) { |
|
| 44 | + $langue_parent = $GLOBALS['meta']['langue_site']; |
|
| 45 | + } else { |
|
| 46 | + $langue_parent = sql_getfetsel("lang", "spip_rubriques", "id_rubrique=$id_parent"); |
|
| 47 | + } |
|
| 48 | + sql_updateq('spip_rubriques', array('lang' => $langue_parent, 'langue_choisie' => 'non'), |
|
| 49 | + "id_rubrique=$id_rubrique"); |
|
| 50 | + } |
|
| 51 | + include_spip('inc/rubriques'); |
|
| 52 | + calculer_langues_rubriques(); |
|
| 53 | + |
|
| 54 | + // invalider les caches marques de cette rubrique |
|
| 55 | + include_spip('inc/invalideur'); |
|
| 56 | + suivre_invalideur("id='rubrique/$id_rubrique'"); |
|
| 57 | + } |
|
| 58 | 58 | } |
@@ -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 | /** |
@@ -33,26 +33,26 @@ discard block |
||
| 33 | 33 | * @see action_cron() URL appelée en asynchrone pour excécuter le cron |
| 34 | 34 | */ |
| 35 | 35 | function action_super_cron_dist() { |
| 36 | - // Si fsockopen est possible, on lance le cron via un socket |
|
| 37 | - // en asynchrone |
|
| 38 | - if (function_exists('fsockopen')) { |
|
| 39 | - $url = generer_url_action('cron'); |
|
| 40 | - $parts = parse_url($url); |
|
| 41 | - $fp = fsockopen($parts['host'], |
|
| 42 | - isset($parts['port']) ? $parts['port'] : 80, |
|
| 43 | - $errno, $errstr, 30); |
|
| 44 | - if ($fp) { |
|
| 45 | - $out = "GET " . $parts['path'] . "?" . $parts['query'] . " HTTP/1.1\r\n"; |
|
| 46 | - $out .= "Host: " . $parts['host'] . "\r\n"; |
|
| 47 | - $out .= "Connection: Close\r\n\r\n"; |
|
| 48 | - fwrite($fp, $out); |
|
| 49 | - fclose($fp); |
|
| 36 | + // Si fsockopen est possible, on lance le cron via un socket |
|
| 37 | + // en asynchrone |
|
| 38 | + if (function_exists('fsockopen')) { |
|
| 39 | + $url = generer_url_action('cron'); |
|
| 40 | + $parts = parse_url($url); |
|
| 41 | + $fp = fsockopen($parts['host'], |
|
| 42 | + isset($parts['port']) ? $parts['port'] : 80, |
|
| 43 | + $errno, $errstr, 30); |
|
| 44 | + if ($fp) { |
|
| 45 | + $out = "GET " . $parts['path'] . "?" . $parts['query'] . " HTTP/1.1\r\n"; |
|
| 46 | + $out .= "Host: " . $parts['host'] . "\r\n"; |
|
| 47 | + $out .= "Connection: Close\r\n\r\n"; |
|
| 48 | + fwrite($fp, $out); |
|
| 49 | + fclose($fp); |
|
| 50 | 50 | |
| 51 | - return; |
|
| 52 | - } |
|
| 53 | - } |
|
| 54 | - // ici lancer le cron par un CURL asynchrone si CURL est présent |
|
| 55 | - // TBD |
|
| 51 | + return; |
|
| 52 | + } |
|
| 53 | + } |
|
| 54 | + // ici lancer le cron par un CURL asynchrone si CURL est présent |
|
| 55 | + // TBD |
|
| 56 | 56 | |
| 57 | - return; |
|
| 57 | + return; |
|
| 58 | 58 | } |
@@ -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 | /** |
@@ -31,17 +31,17 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | function action_debloquer_edition_dist() { |
| 33 | 33 | |
| 34 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 35 | - $arg = $securiser_action(); |
|
| 34 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 35 | + $arg = $securiser_action(); |
|
| 36 | 36 | |
| 37 | - if ($arg) { |
|
| 38 | - include_spip('inc/drapeau_edition'); |
|
| 39 | - if ($arg == 'tous') { |
|
| 40 | - debloquer_tous($GLOBALS['visiteur_session']['id_auteur']); |
|
| 41 | - } else { |
|
| 42 | - $arg = explode("-", $arg); |
|
| 43 | - list($objet, $id_objet) = $arg; |
|
| 44 | - debloquer_edition($GLOBALS['visiteur_session']['id_auteur'], $id_objet, $objet); |
|
| 45 | - } |
|
| 46 | - } |
|
| 37 | + if ($arg) { |
|
| 38 | + include_spip('inc/drapeau_edition'); |
|
| 39 | + if ($arg == 'tous') { |
|
| 40 | + debloquer_tous($GLOBALS['visiteur_session']['id_auteur']); |
|
| 41 | + } else { |
|
| 42 | + $arg = explode("-", $arg); |
|
| 43 | + list($objet, $id_objet) = $arg; |
|
| 44 | + debloquer_edition($GLOBALS['visiteur_session']['id_auteur'], $id_objet, $objet); |
|
| 45 | + } |
|
| 46 | + } |
|
| 47 | 47 | } |
@@ -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,20 +28,20 @@ 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'], array('email' => $arg)); |
|
| 38 | - } |
|
| 39 | - // verifier avant de rediriger pour invalider le message de confirmation |
|
| 40 | - // si ca n'a pas marche |
|
| 41 | - if ($redirect = _request('redirect') and !$arg == sql_getfetsel('email', 'spip_auteurs', |
|
| 42 | - 'id_auteur=' . intval($GLOBALS['visiteur_session'])) |
|
| 43 | - ) { |
|
| 44 | - $GLOBALS['redirect'] = parametre_url($redirect, 'email_modif', ''); |
|
| 45 | - } |
|
| 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'], array('email' => $arg)); |
|
| 38 | + } |
|
| 39 | + // verifier avant de rediriger pour invalider le message de confirmation |
|
| 40 | + // si ca n'a pas marche |
|
| 41 | + if ($redirect = _request('redirect') and !$arg == sql_getfetsel('email', 'spip_auteurs', |
|
| 42 | + 'id_auteur=' . intval($GLOBALS['visiteur_session'])) |
|
| 43 | + ) { |
|
| 44 | + $GLOBALS['redirect'] = parametre_url($redirect, 'email_modif', ''); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | 47 | } |
@@ -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,52 +28,52 @@ 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 ($auteur = auteur_verifier_jeton($jeton) |
|
| 36 | - and $auteur['email'] == $email |
|
| 37 | - and $auteur['statut'] == 'nouveau' |
|
| 38 | - ) { |
|
| 34 | + include_spip('action/inscrire_auteur'); |
|
| 35 | + if ($auteur = auteur_verifier_jeton($jeton) |
|
| 36 | + and $auteur['email'] == $email |
|
| 37 | + and $auteur['statut'] == 'nouveau' |
|
| 38 | + ) { |
|
| 39 | 39 | |
| 40 | - // d'abord on confirme son statut |
|
| 41 | - $auteur = confirmer_statut_inscription($auteur); |
|
| 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 | |
| 79 | 79 | } |
@@ -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/autoriser'); |
@@ -35,33 +35,33 @@ discard block |
||
| 35 | 35 | **/ |
| 36 | 36 | function action_menu_rubriques_dist() { |
| 37 | 37 | |
| 38 | - // si pas acces a ecrire, pas acces au menu |
|
| 39 | - // on renvoi un 401 qui fait echouer la requete ajax silencieusement |
|
| 40 | - if (!autoriser('ecrire')) { |
|
| 41 | - $retour = "<ul class='cols_1'><li class='toutsite'><a href='" . generer_url_ecrire('accueil') . "'>" . _T('public:lien_connecter') . "</a></li></ul>"; |
|
| 42 | - include_spip('inc/actions'); |
|
| 43 | - ajax_retour($retour); |
|
| 44 | - exit; |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - if ($date = intval(_request('date'))) { |
|
| 48 | - header("Last-Modified: " . gmdate("D, d M Y H:i:s", $date) . " GMT"); |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - $r = gen_liste_rubriques(); |
|
| 52 | - if (!$r |
|
| 53 | - and isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) |
|
| 54 | - and !strstr($_SERVER['SERVER_SOFTWARE'], 'IIS/') |
|
| 55 | - ) { |
|
| 56 | - include_spip('inc/headers'); |
|
| 57 | - header('Content-Type: text/html; charset=' . $GLOBALS['meta']['charset']); |
|
| 58 | - http_status(304); |
|
| 59 | - exit; |
|
| 60 | - } else { |
|
| 61 | - include_spip('inc/actions'); |
|
| 62 | - $ret = menu_rubriques(); |
|
| 63 | - ajax_retour($ret); |
|
| 64 | - } |
|
| 38 | + // si pas acces a ecrire, pas acces au menu |
|
| 39 | + // on renvoi un 401 qui fait echouer la requete ajax silencieusement |
|
| 40 | + if (!autoriser('ecrire')) { |
|
| 41 | + $retour = "<ul class='cols_1'><li class='toutsite'><a href='" . generer_url_ecrire('accueil') . "'>" . _T('public:lien_connecter') . "</a></li></ul>"; |
|
| 42 | + include_spip('inc/actions'); |
|
| 43 | + ajax_retour($retour); |
|
| 44 | + exit; |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + if ($date = intval(_request('date'))) { |
|
| 48 | + header("Last-Modified: " . gmdate("D, d M Y H:i:s", $date) . " GMT"); |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + $r = gen_liste_rubriques(); |
|
| 52 | + if (!$r |
|
| 53 | + and isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) |
|
| 54 | + and !strstr($_SERVER['SERVER_SOFTWARE'], 'IIS/') |
|
| 55 | + ) { |
|
| 56 | + include_spip('inc/headers'); |
|
| 57 | + header('Content-Type: text/html; charset=' . $GLOBALS['meta']['charset']); |
|
| 58 | + http_status(304); |
|
| 59 | + exit; |
|
| 60 | + } else { |
|
| 61 | + include_spip('inc/actions'); |
|
| 62 | + $ret = menu_rubriques(); |
|
| 63 | + ajax_retour($ret); |
|
| 64 | + } |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -75,39 +75,39 @@ discard block |
||
| 75 | 75 | * Code HTML présentant la liste des rubriques |
| 76 | 76 | **/ |
| 77 | 77 | function menu_rubriques($complet = true) { |
| 78 | - $ret = "<li class='toutsite'><a href='" . generer_url_ecrire('plan') . "'>" . _T('info_tout_site') . "</a></li>"; |
|
| 79 | - |
|
| 80 | - if (!$complet) { |
|
| 81 | - return "<ul class='cols_1'>$ret\n</ul>\n"; |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - if (!isset($GLOBALS['db_art_cache'])) { |
|
| 85 | - gen_liste_rubriques(); |
|
| 86 | - } |
|
| 87 | - $arr_low = extraire_article(0, $GLOBALS['db_art_cache']); |
|
| 88 | - |
|
| 89 | - $total_lignes = $i = sizeof($arr_low); |
|
| 90 | - |
|
| 91 | - if ($i > 0) { |
|
| 92 | - $nb_col = min(8, ceil($total_lignes / 30)); |
|
| 93 | - if ($nb_col <= 1) { |
|
| 94 | - $nb_col = ceil($total_lignes / 10); |
|
| 95 | - } |
|
| 96 | - foreach ($arr_low as $id_rubrique => $titre_rubrique) { |
|
| 97 | - if (autoriser('voir', 'rubrique', $id_rubrique)) { |
|
| 98 | - $ret .= bandeau_rubrique($id_rubrique, $titre_rubrique, $i); |
|
| 99 | - $i++; |
|
| 100 | - } |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - $ret = "<ul class='cols_$nb_col'>" |
|
| 104 | - . $ret |
|
| 105 | - . "\n</ul>\n"; |
|
| 106 | - } else { |
|
| 107 | - $ret = "<ul class='cols_1'>$ret\n</ul>\n"; |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - return $ret; |
|
| 78 | + $ret = "<li class='toutsite'><a href='" . generer_url_ecrire('plan') . "'>" . _T('info_tout_site') . "</a></li>"; |
|
| 79 | + |
|
| 80 | + if (!$complet) { |
|
| 81 | + return "<ul class='cols_1'>$ret\n</ul>\n"; |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + if (!isset($GLOBALS['db_art_cache'])) { |
|
| 85 | + gen_liste_rubriques(); |
|
| 86 | + } |
|
| 87 | + $arr_low = extraire_article(0, $GLOBALS['db_art_cache']); |
|
| 88 | + |
|
| 89 | + $total_lignes = $i = sizeof($arr_low); |
|
| 90 | + |
|
| 91 | + if ($i > 0) { |
|
| 92 | + $nb_col = min(8, ceil($total_lignes / 30)); |
|
| 93 | + if ($nb_col <= 1) { |
|
| 94 | + $nb_col = ceil($total_lignes / 10); |
|
| 95 | + } |
|
| 96 | + foreach ($arr_low as $id_rubrique => $titre_rubrique) { |
|
| 97 | + if (autoriser('voir', 'rubrique', $id_rubrique)) { |
|
| 98 | + $ret .= bandeau_rubrique($id_rubrique, $titre_rubrique, $i); |
|
| 99 | + $i++; |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + $ret = "<ul class='cols_$nb_col'>" |
|
| 104 | + . $ret |
|
| 105 | + . "\n</ul>\n"; |
|
| 106 | + } else { |
|
| 107 | + $ret = "<ul class='cols_1'>$ret\n</ul>\n"; |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + return $ret; |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | /** |
@@ -126,46 +126,46 @@ discard block |
||
| 126 | 126 | * Code HTML présentant la liste des rubriques |
| 127 | 127 | **/ |
| 128 | 128 | function bandeau_rubrique($id_rubrique, $titre_rubrique, $zdecal) { |
| 129 | - static $zmax = 6; |
|
| 130 | - |
|
| 131 | - $nav = "<a href='" |
|
| 132 | - . generer_url_entite($id_rubrique, 'rubrique', '', '', false) |
|
| 133 | - . "'>" |
|
| 134 | - . supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique)) |
|
| 135 | - . "</a>\n"; |
|
| 136 | - |
|
| 137 | - // Limiter volontairement le nombre de sous-menus |
|
| 138 | - if (!(--$zmax)) { |
|
| 139 | - $zmax++; |
|
| 140 | - |
|
| 141 | - return "\n<li>$nav</li>"; |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - $arr_rub = extraire_article($id_rubrique, $GLOBALS['db_art_cache']); |
|
| 145 | - $i = sizeof($arr_rub); |
|
| 146 | - if (!$i) { |
|
| 147 | - $zmax++; |
|
| 148 | - |
|
| 149 | - return "\n<li>$nav</li>"; |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - |
|
| 153 | - $nb_col = 1; |
|
| 154 | - if ($nb_rub = count($arr_rub)) { |
|
| 155 | - $nb_col = min(10, max(1, ceil($nb_rub / 10))); |
|
| 156 | - } |
|
| 157 | - $ret = "<li class='haschild'>$nav<ul class='cols_$nb_col'>"; |
|
| 158 | - foreach ($arr_rub as $id_rub => $titre_rub) { |
|
| 159 | - if (autoriser('voir', 'rubrique', $id_rub)) { |
|
| 160 | - $titre = supprimer_numero(typo($titre_rub)); |
|
| 161 | - $ret .= bandeau_rubrique($id_rub, $titre, $zdecal + $i); |
|
| 162 | - $i++; |
|
| 163 | - } |
|
| 164 | - } |
|
| 165 | - $ret .= "</ul></li>\n"; |
|
| 166 | - $zmax++; |
|
| 167 | - |
|
| 168 | - return $ret; |
|
| 129 | + static $zmax = 6; |
|
| 130 | + |
|
| 131 | + $nav = "<a href='" |
|
| 132 | + . generer_url_entite($id_rubrique, 'rubrique', '', '', false) |
|
| 133 | + . "'>" |
|
| 134 | + . supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique)) |
|
| 135 | + . "</a>\n"; |
|
| 136 | + |
|
| 137 | + // Limiter volontairement le nombre de sous-menus |
|
| 138 | + if (!(--$zmax)) { |
|
| 139 | + $zmax++; |
|
| 140 | + |
|
| 141 | + return "\n<li>$nav</li>"; |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + $arr_rub = extraire_article($id_rubrique, $GLOBALS['db_art_cache']); |
|
| 145 | + $i = sizeof($arr_rub); |
|
| 146 | + if (!$i) { |
|
| 147 | + $zmax++; |
|
| 148 | + |
|
| 149 | + return "\n<li>$nav</li>"; |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + |
|
| 153 | + $nb_col = 1; |
|
| 154 | + if ($nb_rub = count($arr_rub)) { |
|
| 155 | + $nb_col = min(10, max(1, ceil($nb_rub / 10))); |
|
| 156 | + } |
|
| 157 | + $ret = "<li class='haschild'>$nav<ul class='cols_$nb_col'>"; |
|
| 158 | + foreach ($arr_rub as $id_rub => $titre_rub) { |
|
| 159 | + if (autoriser('voir', 'rubrique', $id_rub)) { |
|
| 160 | + $titre = supprimer_numero(typo($titre_rub)); |
|
| 161 | + $ret .= bandeau_rubrique($id_rub, $titre, $zdecal + $i); |
|
| 162 | + $i++; |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | + $ret .= "</ul></li>\n"; |
|
| 166 | + $zmax++; |
|
| 167 | + |
|
| 168 | + return $ret; |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | * Liste des rubriques enfants de la rubrique (et leur titre) |
| 184 | 184 | **/ |
| 185 | 185 | function extraire_article($id_p, $t) { |
| 186 | - return array_key_exists($id_p, $t) ? $t[$id_p] : array(); |
|
| 186 | + return array_key_exists($id_p, $t) ? $t[$id_p] : array(); |
|
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | /** |
@@ -199,34 +199,34 @@ discard block |
||
| 199 | 199 | **/ |
| 200 | 200 | function gen_liste_rubriques() { |
| 201 | 201 | |
| 202 | - include_spip('inc/config'); |
|
| 203 | - // ici, un petit fichier cache ne fait pas de mal |
|
| 204 | - $last = lire_config('date_calcul_rubriques', 0); |
|
| 205 | - if (lire_fichier(_CACHE_RUBRIQUES, $cache)) { |
|
| 206 | - list($date, $GLOBALS['db_art_cache']) = @unserialize($cache); |
|
| 207 | - if ($date == $last) { |
|
| 208 | - return false; |
|
| 209 | - } // c'etait en cache :-) |
|
| 210 | - } |
|
| 211 | - // se restreindre aux rubriques utilisees recemment +secteurs |
|
| 202 | + include_spip('inc/config'); |
|
| 203 | + // ici, un petit fichier cache ne fait pas de mal |
|
| 204 | + $last = lire_config('date_calcul_rubriques', 0); |
|
| 205 | + if (lire_fichier(_CACHE_RUBRIQUES, $cache)) { |
|
| 206 | + list($date, $GLOBALS['db_art_cache']) = @unserialize($cache); |
|
| 207 | + if ($date == $last) { |
|
| 208 | + return false; |
|
| 209 | + } // c'etait en cache :-) |
|
| 210 | + } |
|
| 211 | + // se restreindre aux rubriques utilisees recemment +secteurs |
|
| 212 | 212 | |
| 213 | - $where = sql_in_select("id_rubrique", "id_rubrique", "spip_rubriques", "", "", "id_parent=0 DESC, date DESC", |
|
| 214 | - _CACHE_RUBRIQUES_MAX); |
|
| 213 | + $where = sql_in_select("id_rubrique", "id_rubrique", "spip_rubriques", "", "", "id_parent=0 DESC, date DESC", |
|
| 214 | + _CACHE_RUBRIQUES_MAX); |
|
| 215 | 215 | |
| 216 | - // puis refaire la requete pour avoir l'ordre alphabetique |
|
| 216 | + // puis refaire la requete pour avoir l'ordre alphabetique |
|
| 217 | 217 | |
| 218 | - $res = sql_select("id_rubrique, titre, id_parent", "spip_rubriques", $where, '', 'id_parent, 0+titre, titre'); |
|
| 218 | + $res = sql_select("id_rubrique, titre, id_parent", "spip_rubriques", $where, '', 'id_parent, 0+titre, titre'); |
|
| 219 | 219 | |
| 220 | - // il ne faut pas filtrer le autoriser voir ici |
|
| 221 | - // car on met le resultat en cache, commun a tout le monde |
|
| 222 | - $GLOBALS['db_art_cache'] = array(); |
|
| 223 | - while ($r = sql_fetch($res)) { |
|
| 224 | - $t = sinon($r['titre'], _T('ecrire:info_sans_titre')); |
|
| 225 | - $GLOBALS['db_art_cache'][$r['id_parent']][$r['id_rubrique']] = supprimer_numero(typo($t)); |
|
| 226 | - } |
|
| 220 | + // il ne faut pas filtrer le autoriser voir ici |
|
| 221 | + // car on met le resultat en cache, commun a tout le monde |
|
| 222 | + $GLOBALS['db_art_cache'] = array(); |
|
| 223 | + while ($r = sql_fetch($res)) { |
|
| 224 | + $t = sinon($r['titre'], _T('ecrire:info_sans_titre')); |
|
| 225 | + $GLOBALS['db_art_cache'][$r['id_parent']][$r['id_rubrique']] = supprimer_numero(typo($t)); |
|
| 226 | + } |
|
| 227 | 227 | |
| 228 | - $t = array($last ? $last : time(), $GLOBALS['db_art_cache']); |
|
| 229 | - ecrire_fichier(_CACHE_RUBRIQUES, serialize($t)); |
|
| 228 | + $t = array($last ? $last : time(), $GLOBALS['db_art_cache']); |
|
| 229 | + ecrire_fichier(_CACHE_RUBRIQUES, serialize($t)); |
|
| 230 | 230 | |
| 231 | - return true; |
|
| 231 | + return true; |
|
| 232 | 232 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | |
| 31 | 31 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 32 | - return; |
|
| 32 | + return; |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | // charger la gestion les rôles sur les objets |
@@ -47,21 +47,21 @@ discard block |
||
| 47 | 47 | * - array(clé primaire, nom de la table de lien) si associable |
| 48 | 48 | */ |
| 49 | 49 | function objet_associable($objet) { |
| 50 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 51 | - $table_sql = table_objet_sql($objet); |
|
| 50 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 51 | + $table_sql = table_objet_sql($objet); |
|
| 52 | 52 | |
| 53 | - $l = ""; |
|
| 54 | - if ($primary = id_table_objet($objet) |
|
| 55 | - and $trouver_table($l = $table_sql . "_liens") |
|
| 56 | - and !preg_match(',[^\w],', $primary) |
|
| 57 | - and !preg_match(',[^\w],', $l) |
|
| 58 | - ) { |
|
| 59 | - return array($primary, $l); |
|
| 60 | - } |
|
| 53 | + $l = ""; |
|
| 54 | + if ($primary = id_table_objet($objet) |
|
| 55 | + and $trouver_table($l = $table_sql . "_liens") |
|
| 56 | + and !preg_match(',[^\w],', $primary) |
|
| 57 | + and !preg_match(',[^\w],', $l) |
|
| 58 | + ) { |
|
| 59 | + return array($primary, $l); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - spip_log("Objet $objet non associable : ne dispose pas d'une cle primaire $primary OU d'une table liens $l"); |
|
| 62 | + spip_log("Objet $objet non associable : ne dispose pas d'une cle primaire $primary OU d'une table liens $l"); |
|
| 63 | 63 | |
| 64 | - return false; |
|
| 64 | + return false; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -87,13 +87,13 @@ discard block |
||
| 87 | 87 | * @return bool|int |
| 88 | 88 | */ |
| 89 | 89 | function objet_associer($objets_source, $objets_lies, $qualif = null) { |
| 90 | - $modifs = objet_traiter_liaisons('lien_insert', $objets_source, $objets_lies, $qualif); |
|
| 90 | + $modifs = objet_traiter_liaisons('lien_insert', $objets_source, $objets_lies, $qualif); |
|
| 91 | 91 | |
| 92 | - if ($qualif) { |
|
| 93 | - objet_qualifier_liens($objets_source, $objets_lies, $qualif); |
|
| 94 | - } |
|
| 92 | + if ($qualif) { |
|
| 93 | + objet_qualifier_liens($objets_source, $objets_lies, $qualif); |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - return $modifs; // pas d'erreur |
|
| 96 | + return $modifs; // pas d'erreur |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | * @return bool|int |
| 128 | 128 | */ |
| 129 | 129 | function objet_dissocier($objets_source, $objets_lies, $cond = null) { |
| 130 | - return objet_traiter_liaisons('lien_delete', $objets_source, $objets_lies, $cond); |
|
| 130 | + return objet_traiter_liaisons('lien_delete', $objets_source, $objets_lies, $cond); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | * @return bool|int |
| 153 | 153 | */ |
| 154 | 154 | function objet_qualifier_liens($objets_source, $objets_lies, $qualif) { |
| 155 | - return objet_traiter_liaisons('lien_set', $objets_source, $objets_lies, $qualif); |
|
| 155 | + return objet_traiter_liaisons('lien_set', $objets_source, $objets_lies, $qualif); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | * Liste des trouvailles |
| 188 | 188 | */ |
| 189 | 189 | function objet_trouver_liens($objets_source, $objets_lies, $cond = null) { |
| 190 | - return objet_traiter_liaisons('lien_find', $objets_source, $objets_lies, $cond); |
|
| 190 | + return objet_traiter_liaisons('lien_find', $objets_source, $objets_lies, $cond); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | * @return int |
| 212 | 212 | */ |
| 213 | 213 | function objet_optimiser_liens($objets_source, $objets_lies) { |
| 214 | - return objet_traiter_liaisons('lien_optimise', $objets_source, $objets_lies); |
|
| 214 | + return objet_traiter_liaisons('lien_optimise', $objets_source, $objets_lies); |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | |
@@ -231,32 +231,32 @@ discard block |
||
| 231 | 231 | * Nombre de liens copiés |
| 232 | 232 | */ |
| 233 | 233 | function objet_dupliquer_liens($objet, $id_source, $id_cible, $types = null, $exclure_types = null) { |
| 234 | - include_spip('base/objets'); |
|
| 235 | - $tables = lister_tables_objets_sql(); |
|
| 236 | - $n = 0; |
|
| 237 | - foreach ($tables as $table_sql => $infos) { |
|
| 238 | - if ( |
|
| 239 | - (is_null($types) or in_array($infos['type'], $types)) |
|
| 240 | - and (is_null($exclure_types) or !in_array($infos['type'], $exclure_types)) |
|
| 241 | - ) { |
|
| 242 | - if (objet_associable($infos['type'])) { |
|
| 243 | - $liens = (($infos['type'] == $objet) ? |
|
| 244 | - objet_trouver_liens(array($objet => $id_source), '*') |
|
| 245 | - : |
|
| 246 | - objet_trouver_liens(array($infos['type'] => '*'), array($objet => $id_source))); |
|
| 247 | - foreach ($liens as $lien) { |
|
| 248 | - $n++; |
|
| 249 | - if ($infos['type'] == $objet) { |
|
| 250 | - objet_associer(array($objet => $id_cible), array($lien['objet'] => $lien[$lien['objet']]), $lien); |
|
| 251 | - } else { |
|
| 252 | - objet_associer(array($infos['type'] => $lien[$infos['type']]), array($objet => $id_cible), $lien); |
|
| 253 | - } |
|
| 254 | - } |
|
| 255 | - } |
|
| 256 | - } |
|
| 257 | - } |
|
| 258 | - |
|
| 259 | - return $n; |
|
| 234 | + include_spip('base/objets'); |
|
| 235 | + $tables = lister_tables_objets_sql(); |
|
| 236 | + $n = 0; |
|
| 237 | + foreach ($tables as $table_sql => $infos) { |
|
| 238 | + if ( |
|
| 239 | + (is_null($types) or in_array($infos['type'], $types)) |
|
| 240 | + and (is_null($exclure_types) or !in_array($infos['type'], $exclure_types)) |
|
| 241 | + ) { |
|
| 242 | + if (objet_associable($infos['type'])) { |
|
| 243 | + $liens = (($infos['type'] == $objet) ? |
|
| 244 | + objet_trouver_liens(array($objet => $id_source), '*') |
|
| 245 | + : |
|
| 246 | + objet_trouver_liens(array($infos['type'] => '*'), array($objet => $id_source))); |
|
| 247 | + foreach ($liens as $lien) { |
|
| 248 | + $n++; |
|
| 249 | + if ($infos['type'] == $objet) { |
|
| 250 | + objet_associer(array($objet => $id_cible), array($lien['objet'] => $lien[$lien['objet']]), $lien); |
|
| 251 | + } else { |
|
| 252 | + objet_associer(array($infos['type'] => $lien[$infos['type']]), array($objet => $id_cible), $lien); |
|
| 253 | + } |
|
| 254 | + } |
|
| 255 | + } |
|
| 256 | + } |
|
| 257 | + } |
|
| 258 | + |
|
| 259 | + return $n; |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | 262 | /** |
@@ -298,38 +298,38 @@ discard block |
||
| 298 | 298 | * @return bool|int|array |
| 299 | 299 | */ |
| 300 | 300 | function objet_traiter_liaisons($operation, $objets_source, $objets_lies, $set = null) { |
| 301 | - // accepter une syntaxe minimale pour supprimer tous les liens |
|
| 302 | - if ($objets_lies == '*') { |
|
| 303 | - $objets_lies = array('*' => '*'); |
|
| 304 | - } |
|
| 305 | - $modifs = 0; // compter le nombre de modifications |
|
| 306 | - $echec = null; |
|
| 307 | - foreach ($objets_source as $objet => $ids) { |
|
| 308 | - if ($a = objet_associable($objet)) { |
|
| 309 | - list($primary, $l) = $a; |
|
| 310 | - if (!is_array($ids)) { |
|
| 311 | - $ids = array($ids); |
|
| 312 | - } elseif (reset($ids) == "NOT") { |
|
| 313 | - // si on demande un array('NOT',...) => recuperer la liste d'ids correspondants |
|
| 314 | - $where = lien_where($primary, $ids, '*', '*'); |
|
| 315 | - $ids = sql_allfetsel($primary, $l, $where); |
|
| 316 | - $ids = array_map('reset', $ids); |
|
| 317 | - } |
|
| 318 | - foreach ($ids as $id) { |
|
| 319 | - $res = $operation($objet, $primary, $l, $id, $objets_lies, $set); |
|
| 320 | - if ($res === false) { |
|
| 321 | - spip_log("objet_traiter_liaisons [Echec] : $operation sur $objet/$primary/$l/$id", _LOG_ERREUR); |
|
| 322 | - $echec = true; |
|
| 323 | - } else { |
|
| 324 | - $modifs = ($modifs ? (is_array($res) ? array_merge($modifs, $res) : $modifs + $res) : $res); |
|
| 325 | - } |
|
| 326 | - } |
|
| 327 | - } else { |
|
| 328 | - $echec = true; |
|
| 329 | - } |
|
| 330 | - } |
|
| 331 | - |
|
| 332 | - return ($echec ? false : $modifs); // pas d'erreur |
|
| 301 | + // accepter une syntaxe minimale pour supprimer tous les liens |
|
| 302 | + if ($objets_lies == '*') { |
|
| 303 | + $objets_lies = array('*' => '*'); |
|
| 304 | + } |
|
| 305 | + $modifs = 0; // compter le nombre de modifications |
|
| 306 | + $echec = null; |
|
| 307 | + foreach ($objets_source as $objet => $ids) { |
|
| 308 | + if ($a = objet_associable($objet)) { |
|
| 309 | + list($primary, $l) = $a; |
|
| 310 | + if (!is_array($ids)) { |
|
| 311 | + $ids = array($ids); |
|
| 312 | + } elseif (reset($ids) == "NOT") { |
|
| 313 | + // si on demande un array('NOT',...) => recuperer la liste d'ids correspondants |
|
| 314 | + $where = lien_where($primary, $ids, '*', '*'); |
|
| 315 | + $ids = sql_allfetsel($primary, $l, $where); |
|
| 316 | + $ids = array_map('reset', $ids); |
|
| 317 | + } |
|
| 318 | + foreach ($ids as $id) { |
|
| 319 | + $res = $operation($objet, $primary, $l, $id, $objets_lies, $set); |
|
| 320 | + if ($res === false) { |
|
| 321 | + spip_log("objet_traiter_liaisons [Echec] : $operation sur $objet/$primary/$l/$id", _LOG_ERREUR); |
|
| 322 | + $echec = true; |
|
| 323 | + } else { |
|
| 324 | + $modifs = ($modifs ? (is_array($res) ? array_merge($modifs, $res) : $modifs + $res) : $res); |
|
| 325 | + } |
|
| 326 | + } |
|
| 327 | + } else { |
|
| 328 | + $echec = true; |
|
| 329 | + } |
|
| 330 | + } |
|
| 331 | + |
|
| 332 | + return ($echec ? false : $modifs); // pas d'erreur |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | |
@@ -358,81 +358,81 @@ discard block |
||
| 358 | 358 | * Nombre d'insertions faites, false si échec. |
| 359 | 359 | */ |
| 360 | 360 | function lien_insert($objet_source, $primary, $table_lien, $id, $objets, $qualif) { |
| 361 | - $ins = 0; |
|
| 362 | - $echec = null; |
|
| 363 | - if (is_null($qualif)) { |
|
| 364 | - $qualif = array(); |
|
| 365 | - } |
|
| 366 | - |
|
| 367 | - foreach ($objets as $objet => $id_objets) { |
|
| 368 | - if (!is_array($id_objets)) { |
|
| 369 | - $id_objets = array($id_objets); |
|
| 370 | - } |
|
| 371 | - |
|
| 372 | - // role, colonne, where par défaut |
|
| 373 | - list($role, $colonne_role, $cond) = |
|
| 374 | - roles_trouver_dans_qualif($objet_source, $objet, $qualif); |
|
| 375 | - |
|
| 376 | - foreach ($id_objets as $id_objet) { |
|
| 377 | - $objet = ($objet == '*') ? $objet : objet_type($objet); # securite |
|
| 378 | - |
|
| 379 | - $insertions = array( |
|
| 380 | - 'id_objet' => $id_objet, |
|
| 381 | - 'objet' => $objet, |
|
| 382 | - $primary => $id |
|
| 383 | - ); |
|
| 384 | - // rôle en plus s'il est défini |
|
| 385 | - if ($role) { |
|
| 386 | - $insertions += array( |
|
| 387 | - $colonne_role => $role |
|
| 388 | - ); |
|
| 389 | - } |
|
| 390 | - $args = array( |
|
| 391 | - 'table_lien' => $table_lien, |
|
| 392 | - 'objet_source' => $objet_source, |
|
| 393 | - 'id_objet_source' => $id, |
|
| 394 | - 'objet' => $objet, |
|
| 395 | - 'id_objet' => $id_objet, |
|
| 396 | - 'role' => $role, |
|
| 397 | - 'colonne_role' => $colonne_role, |
|
| 398 | - 'action' => 'insert', |
|
| 399 | - ); |
|
| 400 | - |
|
| 401 | - // Envoyer aux plugins |
|
| 402 | - $insertions = pipeline('pre_edition_lien', |
|
| 403 | - array( |
|
| 404 | - 'args' => $args, |
|
| 405 | - 'data' => $insertions |
|
| 406 | - ) |
|
| 407 | - ); |
|
| 408 | - $args['id_objet'] = $insertions['id_objet']; |
|
| 409 | - |
|
| 410 | - $where = lien_where($primary, $id, $objet, $id_objet, $cond); |
|
| 411 | - |
|
| 412 | - if ($id_objet = intval($insertions['id_objet']) |
|
| 413 | - and !sql_getfetsel($primary, $table_lien, $where) |
|
| 414 | - ) { |
|
| 415 | - |
|
| 416 | - $e = sql_insertq($table_lien, $insertions); |
|
| 417 | - if ($e !== false) { |
|
| 418 | - $ins++; |
|
| 419 | - lien_propage_date_modif($objet, $id_objet); |
|
| 420 | - lien_propage_date_modif($objet_source, $id); |
|
| 421 | - // Envoyer aux plugins |
|
| 422 | - pipeline('post_edition_lien', |
|
| 423 | - array( |
|
| 424 | - 'args' => $args, |
|
| 425 | - 'data' => $insertions |
|
| 426 | - ) |
|
| 427 | - ); |
|
| 428 | - } else { |
|
| 429 | - $echec = true; |
|
| 430 | - } |
|
| 431 | - } |
|
| 432 | - } |
|
| 433 | - } |
|
| 434 | - |
|
| 435 | - return ($echec ? false : $ins); |
|
| 361 | + $ins = 0; |
|
| 362 | + $echec = null; |
|
| 363 | + if (is_null($qualif)) { |
|
| 364 | + $qualif = array(); |
|
| 365 | + } |
|
| 366 | + |
|
| 367 | + foreach ($objets as $objet => $id_objets) { |
|
| 368 | + if (!is_array($id_objets)) { |
|
| 369 | + $id_objets = array($id_objets); |
|
| 370 | + } |
|
| 371 | + |
|
| 372 | + // role, colonne, where par défaut |
|
| 373 | + list($role, $colonne_role, $cond) = |
|
| 374 | + roles_trouver_dans_qualif($objet_source, $objet, $qualif); |
|
| 375 | + |
|
| 376 | + foreach ($id_objets as $id_objet) { |
|
| 377 | + $objet = ($objet == '*') ? $objet : objet_type($objet); # securite |
|
| 378 | + |
|
| 379 | + $insertions = array( |
|
| 380 | + 'id_objet' => $id_objet, |
|
| 381 | + 'objet' => $objet, |
|
| 382 | + $primary => $id |
|
| 383 | + ); |
|
| 384 | + // rôle en plus s'il est défini |
|
| 385 | + if ($role) { |
|
| 386 | + $insertions += array( |
|
| 387 | + $colonne_role => $role |
|
| 388 | + ); |
|
| 389 | + } |
|
| 390 | + $args = array( |
|
| 391 | + 'table_lien' => $table_lien, |
|
| 392 | + 'objet_source' => $objet_source, |
|
| 393 | + 'id_objet_source' => $id, |
|
| 394 | + 'objet' => $objet, |
|
| 395 | + 'id_objet' => $id_objet, |
|
| 396 | + 'role' => $role, |
|
| 397 | + 'colonne_role' => $colonne_role, |
|
| 398 | + 'action' => 'insert', |
|
| 399 | + ); |
|
| 400 | + |
|
| 401 | + // Envoyer aux plugins |
|
| 402 | + $insertions = pipeline('pre_edition_lien', |
|
| 403 | + array( |
|
| 404 | + 'args' => $args, |
|
| 405 | + 'data' => $insertions |
|
| 406 | + ) |
|
| 407 | + ); |
|
| 408 | + $args['id_objet'] = $insertions['id_objet']; |
|
| 409 | + |
|
| 410 | + $where = lien_where($primary, $id, $objet, $id_objet, $cond); |
|
| 411 | + |
|
| 412 | + if ($id_objet = intval($insertions['id_objet']) |
|
| 413 | + and !sql_getfetsel($primary, $table_lien, $where) |
|
| 414 | + ) { |
|
| 415 | + |
|
| 416 | + $e = sql_insertq($table_lien, $insertions); |
|
| 417 | + if ($e !== false) { |
|
| 418 | + $ins++; |
|
| 419 | + lien_propage_date_modif($objet, $id_objet); |
|
| 420 | + lien_propage_date_modif($objet_source, $id); |
|
| 421 | + // Envoyer aux plugins |
|
| 422 | + pipeline('post_edition_lien', |
|
| 423 | + array( |
|
| 424 | + 'args' => $args, |
|
| 425 | + 'data' => $insertions |
|
| 426 | + ) |
|
| 427 | + ); |
|
| 428 | + } else { |
|
| 429 | + $echec = true; |
|
| 430 | + } |
|
| 431 | + } |
|
| 432 | + } |
|
| 433 | + } |
|
| 434 | + |
|
| 435 | + return ($echec ? false : $ins); |
|
| 436 | 436 | } |
| 437 | 437 | |
| 438 | 438 | /** |
@@ -447,45 +447,45 @@ discard block |
||
| 447 | 447 | * @return array Liste des conditions |
| 448 | 448 | */ |
| 449 | 449 | function lien_where($primary, $id_source, $objet, $id_objet, $cond = array()) { |
| 450 | - if ((!is_array($id_source) and !strlen($id_source)) |
|
| 451 | - or !strlen($objet) |
|
| 452 | - or (!is_array($id_objet) and !strlen($id_objet)) |
|
| 453 | - ) { |
|
| 454 | - return array("0=1"); |
|
| 455 | - } // securite |
|
| 456 | - |
|
| 457 | - $not = ""; |
|
| 458 | - if (is_array($id_source) and reset($id_source) == "NOT") { |
|
| 459 | - $not = array_shift($id_source); |
|
| 460 | - $id_source = reset($id_source); |
|
| 461 | - } |
|
| 462 | - |
|
| 463 | - $where = $cond; |
|
| 464 | - |
|
| 465 | - if ($id_source !== '*') { |
|
| 466 | - $where[] = (is_array($id_source) ? sql_in(addslashes($primary), array_map('intval', $id_source), |
|
| 467 | - $not) : addslashes($primary) . ($not ? "<>" : "=") . intval($id_source)); |
|
| 468 | - } elseif ($not) { |
|
| 469 | - $where[] = "0=1"; |
|
| 470 | - } // idiot mais quand meme |
|
| 471 | - |
|
| 472 | - $not = ""; |
|
| 473 | - if (is_array($id_objet) and reset($id_objet) == "NOT") { |
|
| 474 | - $not = array_shift($id_objet); |
|
| 475 | - $id_objet = reset($id_objet); |
|
| 476 | - } |
|
| 477 | - |
|
| 478 | - if ($objet !== '*') { |
|
| 479 | - $where[] = "objet=" . sql_quote($objet); |
|
| 480 | - } |
|
| 481 | - if ($id_objet !== '*') { |
|
| 482 | - $where[] = (is_array($id_objet) ? sql_in('id_objet', array_map('intval', $id_objet), |
|
| 483 | - $not) : "id_objet" . ($not ? "<>" : "=") . intval($id_objet)); |
|
| 484 | - } elseif ($not) { |
|
| 485 | - $where[] = "0=1"; |
|
| 486 | - } // idiot mais quand meme |
|
| 487 | - |
|
| 488 | - return $where; |
|
| 450 | + if ((!is_array($id_source) and !strlen($id_source)) |
|
| 451 | + or !strlen($objet) |
|
| 452 | + or (!is_array($id_objet) and !strlen($id_objet)) |
|
| 453 | + ) { |
|
| 454 | + return array("0=1"); |
|
| 455 | + } // securite |
|
| 456 | + |
|
| 457 | + $not = ""; |
|
| 458 | + if (is_array($id_source) and reset($id_source) == "NOT") { |
|
| 459 | + $not = array_shift($id_source); |
|
| 460 | + $id_source = reset($id_source); |
|
| 461 | + } |
|
| 462 | + |
|
| 463 | + $where = $cond; |
|
| 464 | + |
|
| 465 | + if ($id_source !== '*') { |
|
| 466 | + $where[] = (is_array($id_source) ? sql_in(addslashes($primary), array_map('intval', $id_source), |
|
| 467 | + $not) : addslashes($primary) . ($not ? "<>" : "=") . intval($id_source)); |
|
| 468 | + } elseif ($not) { |
|
| 469 | + $where[] = "0=1"; |
|
| 470 | + } // idiot mais quand meme |
|
| 471 | + |
|
| 472 | + $not = ""; |
|
| 473 | + if (is_array($id_objet) and reset($id_objet) == "NOT") { |
|
| 474 | + $not = array_shift($id_objet); |
|
| 475 | + $id_objet = reset($id_objet); |
|
| 476 | + } |
|
| 477 | + |
|
| 478 | + if ($objet !== '*') { |
|
| 479 | + $where[] = "objet=" . sql_quote($objet); |
|
| 480 | + } |
|
| 481 | + if ($id_objet !== '*') { |
|
| 482 | + $where[] = (is_array($id_objet) ? sql_in('id_objet', array_map('intval', $id_objet), |
|
| 483 | + $not) : "id_objet" . ($not ? "<>" : "=") . intval($id_objet)); |
|
| 484 | + } elseif ($not) { |
|
| 485 | + $where[] = "0=1"; |
|
| 486 | + } // idiot mais quand meme |
|
| 487 | + |
|
| 488 | + return $where; |
|
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 | /** |
@@ -516,85 +516,85 @@ discard block |
||
| 516 | 516 | */ |
| 517 | 517 | function lien_delete($objet_source, $primary, $table_lien, $id, $objets, $cond = null) { |
| 518 | 518 | |
| 519 | - $retire = array(); |
|
| 520 | - $dels = 0; |
|
| 521 | - $echec = false; |
|
| 522 | - if (is_null($cond)) { |
|
| 523 | - $cond = array(); |
|
| 524 | - } |
|
| 525 | - |
|
| 526 | - foreach ($objets as $objet => $id_objets) { |
|
| 527 | - $objet = ($objet == '*') ? $objet : objet_type($objet); # securite |
|
| 528 | - if (!is_array($id_objets) or reset($id_objets) == "NOT") { |
|
| 529 | - $id_objets = array($id_objets); |
|
| 530 | - } |
|
| 531 | - foreach ($id_objets as $id_objet) { |
|
| 532 | - list($cond, $colonne_role, $role) = roles_creer_condition_role($objet_source, $objet, $cond); |
|
| 533 | - // id_objet peut valoir '*' |
|
| 534 | - $where = lien_where($primary, $id, $objet, $id_objet, $cond); |
|
| 535 | - |
|
| 536 | - // lire les liens existants pour propager la date de modif |
|
| 537 | - $select = "$primary,id_objet,objet"; |
|
| 538 | - if ($colonne_role) { |
|
| 539 | - $select .= ",$colonne_role"; |
|
| 540 | - } |
|
| 541 | - $liens = sql_allfetsel($select, $table_lien, $where); |
|
| 542 | - |
|
| 543 | - // iterer sur les liens pour permettre aux plugins de gerer |
|
| 544 | - foreach ($liens as $l) { |
|
| 545 | - |
|
| 546 | - $args = array( |
|
| 547 | - 'table_lien' => $table_lien, |
|
| 548 | - 'objet_source' => $objet_source, |
|
| 549 | - 'id_objet_source' => $l[$primary], |
|
| 550 | - 'objet' => $l['objet'], |
|
| 551 | - 'id_objet' => $l['id_objet'], |
|
| 552 | - 'colonne_role' => $colonne_role, |
|
| 553 | - 'role' => ($colonne_role ? $l[$colonne_role] : ''), |
|
| 554 | - 'action' => 'delete', |
|
| 555 | - ); |
|
| 556 | - |
|
| 557 | - // Envoyer aux plugins |
|
| 558 | - $l = pipeline('pre_edition_lien', |
|
| 559 | - array( |
|
| 560 | - 'args' => $args, |
|
| 561 | - 'data' => $l |
|
| 562 | - ) |
|
| 563 | - ); |
|
| 564 | - $args['id_objet'] = $id_o = $l['id_objet']; |
|
| 565 | - |
|
| 566 | - if ($id_o = intval($l['id_objet'])) { |
|
| 567 | - $where = lien_where($primary, $l[$primary], $l['objet'], $id_o, $cond); |
|
| 568 | - $e = sql_delete($table_lien, $where); |
|
| 569 | - if ($e !== false) { |
|
| 570 | - $dels += $e; |
|
| 571 | - lien_propage_date_modif($l['objet'], $id_o); |
|
| 572 | - lien_propage_date_modif($objet_source, $l[$primary]); |
|
| 573 | - } else { |
|
| 574 | - $echec = true; |
|
| 575 | - } |
|
| 576 | - $retire[] = array( |
|
| 577 | - 'source' => array($objet_source => $l[$primary]), |
|
| 578 | - 'lien' => array($l['objet'] => $id_o), |
|
| 579 | - 'type' => $l['objet'], |
|
| 580 | - 'role' => ($colonne_role ? $l[$colonne_role] : ''), |
|
| 581 | - 'id' => $id_o |
|
| 582 | - ); |
|
| 583 | - // Envoyer aux plugins |
|
| 584 | - pipeline('post_edition_lien', |
|
| 585 | - array( |
|
| 586 | - 'args' => $args, |
|
| 587 | - 'data' => $l |
|
| 588 | - ) |
|
| 589 | - ); |
|
| 590 | - } |
|
| 591 | - } |
|
| 592 | - } |
|
| 593 | - } |
|
| 594 | - |
|
| 595 | - pipeline('trig_supprimer_objets_lies', $retire); |
|
| 596 | - |
|
| 597 | - return ($echec ? false : $dels); |
|
| 519 | + $retire = array(); |
|
| 520 | + $dels = 0; |
|
| 521 | + $echec = false; |
|
| 522 | + if (is_null($cond)) { |
|
| 523 | + $cond = array(); |
|
| 524 | + } |
|
| 525 | + |
|
| 526 | + foreach ($objets as $objet => $id_objets) { |
|
| 527 | + $objet = ($objet == '*') ? $objet : objet_type($objet); # securite |
|
| 528 | + if (!is_array($id_objets) or reset($id_objets) == "NOT") { |
|
| 529 | + $id_objets = array($id_objets); |
|
| 530 | + } |
|
| 531 | + foreach ($id_objets as $id_objet) { |
|
| 532 | + list($cond, $colonne_role, $role) = roles_creer_condition_role($objet_source, $objet, $cond); |
|
| 533 | + // id_objet peut valoir '*' |
|
| 534 | + $where = lien_where($primary, $id, $objet, $id_objet, $cond); |
|
| 535 | + |
|
| 536 | + // lire les liens existants pour propager la date de modif |
|
| 537 | + $select = "$primary,id_objet,objet"; |
|
| 538 | + if ($colonne_role) { |
|
| 539 | + $select .= ",$colonne_role"; |
|
| 540 | + } |
|
| 541 | + $liens = sql_allfetsel($select, $table_lien, $where); |
|
| 542 | + |
|
| 543 | + // iterer sur les liens pour permettre aux plugins de gerer |
|
| 544 | + foreach ($liens as $l) { |
|
| 545 | + |
|
| 546 | + $args = array( |
|
| 547 | + 'table_lien' => $table_lien, |
|
| 548 | + 'objet_source' => $objet_source, |
|
| 549 | + 'id_objet_source' => $l[$primary], |
|
| 550 | + 'objet' => $l['objet'], |
|
| 551 | + 'id_objet' => $l['id_objet'], |
|
| 552 | + 'colonne_role' => $colonne_role, |
|
| 553 | + 'role' => ($colonne_role ? $l[$colonne_role] : ''), |
|
| 554 | + 'action' => 'delete', |
|
| 555 | + ); |
|
| 556 | + |
|
| 557 | + // Envoyer aux plugins |
|
| 558 | + $l = pipeline('pre_edition_lien', |
|
| 559 | + array( |
|
| 560 | + 'args' => $args, |
|
| 561 | + 'data' => $l |
|
| 562 | + ) |
|
| 563 | + ); |
|
| 564 | + $args['id_objet'] = $id_o = $l['id_objet']; |
|
| 565 | + |
|
| 566 | + if ($id_o = intval($l['id_objet'])) { |
|
| 567 | + $where = lien_where($primary, $l[$primary], $l['objet'], $id_o, $cond); |
|
| 568 | + $e = sql_delete($table_lien, $where); |
|
| 569 | + if ($e !== false) { |
|
| 570 | + $dels += $e; |
|
| 571 | + lien_propage_date_modif($l['objet'], $id_o); |
|
| 572 | + lien_propage_date_modif($objet_source, $l[$primary]); |
|
| 573 | + } else { |
|
| 574 | + $echec = true; |
|
| 575 | + } |
|
| 576 | + $retire[] = array( |
|
| 577 | + 'source' => array($objet_source => $l[$primary]), |
|
| 578 | + 'lien' => array($l['objet'] => $id_o), |
|
| 579 | + 'type' => $l['objet'], |
|
| 580 | + 'role' => ($colonne_role ? $l[$colonne_role] : ''), |
|
| 581 | + 'id' => $id_o |
|
| 582 | + ); |
|
| 583 | + // Envoyer aux plugins |
|
| 584 | + pipeline('post_edition_lien', |
|
| 585 | + array( |
|
| 586 | + 'args' => $args, |
|
| 587 | + 'data' => $l |
|
| 588 | + ) |
|
| 589 | + ); |
|
| 590 | + } |
|
| 591 | + } |
|
| 592 | + } |
|
| 593 | + } |
|
| 594 | + |
|
| 595 | + pipeline('trig_supprimer_objets_lies', $retire); |
|
| 596 | + |
|
| 597 | + return ($echec ? false : $dels); |
|
| 598 | 598 | } |
| 599 | 599 | |
| 600 | 600 | |
@@ -617,56 +617,56 @@ discard block |
||
| 617 | 617 | * @return bool|int |
| 618 | 618 | */ |
| 619 | 619 | function lien_optimise($objet_source, $primary, $table_lien, $id, $objets) { |
| 620 | - include_spip('genie/optimiser'); |
|
| 621 | - $echec = false; |
|
| 622 | - $dels = 0; |
|
| 623 | - foreach ($objets as $objet => $id_objets) { |
|
| 624 | - $objet = ($objet == '*') ? $objet : objet_type($objet); # securite |
|
| 625 | - if (!is_array($id_objets) or reset($id_objets) == "NOT") { |
|
| 626 | - $id_objets = array($id_objets); |
|
| 627 | - } |
|
| 628 | - foreach ($id_objets as $id_objet) { |
|
| 629 | - $where = lien_where($primary, $id, $objet, $id_objet); |
|
| 630 | - # les liens vers un objet inexistant |
|
| 631 | - $r = sql_select("DISTINCT objet", $table_lien, $where); |
|
| 632 | - while ($t = sql_fetch($r)) { |
|
| 633 | - $type = $t['objet']; |
|
| 634 | - $spip_table_objet = table_objet_sql($type); |
|
| 635 | - $id_table_objet = id_table_objet($type); |
|
| 636 | - $res = sql_select("L.$primary AS id,L.id_objet", |
|
| 637 | - // la condition de jointure inclue L.objet='xxx' pour ne joindre que les bonnes lignes |
|
| 638 | - // du coups toutes les lignes avec un autre objet ont un id_xxx=NULL puisque LEFT JOIN |
|
| 639 | - // il faut les eliminier en repetant la condition dans le where L.objet='xxx' |
|
| 640 | - "$table_lien AS L |
|
| 620 | + include_spip('genie/optimiser'); |
|
| 621 | + $echec = false; |
|
| 622 | + $dels = 0; |
|
| 623 | + foreach ($objets as $objet => $id_objets) { |
|
| 624 | + $objet = ($objet == '*') ? $objet : objet_type($objet); # securite |
|
| 625 | + if (!is_array($id_objets) or reset($id_objets) == "NOT") { |
|
| 626 | + $id_objets = array($id_objets); |
|
| 627 | + } |
|
| 628 | + foreach ($id_objets as $id_objet) { |
|
| 629 | + $where = lien_where($primary, $id, $objet, $id_objet); |
|
| 630 | + # les liens vers un objet inexistant |
|
| 631 | + $r = sql_select("DISTINCT objet", $table_lien, $where); |
|
| 632 | + while ($t = sql_fetch($r)) { |
|
| 633 | + $type = $t['objet']; |
|
| 634 | + $spip_table_objet = table_objet_sql($type); |
|
| 635 | + $id_table_objet = id_table_objet($type); |
|
| 636 | + $res = sql_select("L.$primary AS id,L.id_objet", |
|
| 637 | + // la condition de jointure inclue L.objet='xxx' pour ne joindre que les bonnes lignes |
|
| 638 | + // du coups toutes les lignes avec un autre objet ont un id_xxx=NULL puisque LEFT JOIN |
|
| 639 | + // il faut les eliminier en repetant la condition dans le where L.objet='xxx' |
|
| 640 | + "$table_lien AS L |
|
| 641 | 641 | LEFT JOIN $spip_table_objet AS O |
| 642 | 642 | ON (O.$id_table_objet=L.id_objet AND L.objet=" . sql_quote($type) . ")", |
| 643 | - "L.objet=" . sql_quote($type) . " AND O.$id_table_objet IS NULL"); |
|
| 644 | - // sur une cle primaire composee, pas d'autres solutions que de virer un a un |
|
| 645 | - while ($row = sql_fetch($res)) { |
|
| 646 | - $e = sql_delete($table_lien, |
|
| 647 | - array("$primary=" . $row['id'], "id_objet=" . $row['id_objet'], "objet=" . sql_quote($type))); |
|
| 648 | - if ($e != false) { |
|
| 649 | - $dels += $e; |
|
| 650 | - spip_log("Entree " . $row['id'] . "/" . $row['id_objet'] . "/$type supprimee dans la table $table_lien", |
|
| 651 | - _LOG_INFO_IMPORTANTE); |
|
| 652 | - } |
|
| 653 | - } |
|
| 654 | - } |
|
| 655 | - |
|
| 656 | - # les liens depuis un objet inexistant |
|
| 657 | - $table_source = table_objet_sql($objet_source); |
|
| 658 | - // filtrer selon $id, $objet, $id_objet eventuellement fournis |
|
| 659 | - // (en general '*' pour chaque) |
|
| 660 | - $where = lien_where("L.$primary", $id, $objet, $id_objet); |
|
| 661 | - $where[] = "O.$primary IS NULL"; |
|
| 662 | - $res = sql_select("L.$primary AS id", |
|
| 663 | - "$table_lien AS L LEFT JOIN $table_source AS O ON L.$primary=O.$primary", |
|
| 664 | - $where); |
|
| 665 | - $dels += optimiser_sansref($table_lien, $primary, $res); |
|
| 666 | - } |
|
| 667 | - } |
|
| 668 | - |
|
| 669 | - return ($echec ? false : $dels); |
|
| 643 | + "L.objet=" . sql_quote($type) . " AND O.$id_table_objet IS NULL"); |
|
| 644 | + // sur une cle primaire composee, pas d'autres solutions que de virer un a un |
|
| 645 | + while ($row = sql_fetch($res)) { |
|
| 646 | + $e = sql_delete($table_lien, |
|
| 647 | + array("$primary=" . $row['id'], "id_objet=" . $row['id_objet'], "objet=" . sql_quote($type))); |
|
| 648 | + if ($e != false) { |
|
| 649 | + $dels += $e; |
|
| 650 | + spip_log("Entree " . $row['id'] . "/" . $row['id_objet'] . "/$type supprimee dans la table $table_lien", |
|
| 651 | + _LOG_INFO_IMPORTANTE); |
|
| 652 | + } |
|
| 653 | + } |
|
| 654 | + } |
|
| 655 | + |
|
| 656 | + # les liens depuis un objet inexistant |
|
| 657 | + $table_source = table_objet_sql($objet_source); |
|
| 658 | + // filtrer selon $id, $objet, $id_objet eventuellement fournis |
|
| 659 | + // (en general '*' pour chaque) |
|
| 660 | + $where = lien_where("L.$primary", $id, $objet, $id_objet); |
|
| 661 | + $where[] = "O.$primary IS NULL"; |
|
| 662 | + $res = sql_select("L.$primary AS id", |
|
| 663 | + "$table_lien AS L LEFT JOIN $table_source AS O ON L.$primary=O.$primary", |
|
| 664 | + $where); |
|
| 665 | + $dels += optimiser_sansref($table_lien, $primary, $res); |
|
| 666 | + } |
|
| 667 | + } |
|
| 668 | + |
|
| 669 | + return ($echec ? false : $dels); |
|
| 670 | 670 | } |
| 671 | 671 | |
| 672 | 672 | |
@@ -698,70 +698,70 @@ discard block |
||
| 698 | 698 | * Nombre de modifications faites, false si échec. |
| 699 | 699 | */ |
| 700 | 700 | function lien_set($objet_source, $primary, $table_lien, $id, $objets, $qualif) { |
| 701 | - $echec = null; |
|
| 702 | - $ok = 0; |
|
| 703 | - if (!$qualif) { |
|
| 704 | - return false; |
|
| 705 | - } |
|
| 706 | - // nettoyer qualif qui peut venir directement d'un objet_trouver_lien : |
|
| 707 | - unset($qualif[$primary]); |
|
| 708 | - unset($qualif[$objet_source]); |
|
| 709 | - if (isset($qualif['objet'])) { |
|
| 710 | - unset($qualif[$qualif['objet']]); |
|
| 711 | - } |
|
| 712 | - unset($qualif['objet']); |
|
| 713 | - unset($qualif['id_objet']); |
|
| 714 | - foreach ($objets as $objet => $id_objets) { |
|
| 715 | - |
|
| 716 | - // role, colonne, where par défaut |
|
| 717 | - list($role, $colonne_role, $cond) = |
|
| 718 | - roles_trouver_dans_qualif($objet_source, $objet, $qualif); |
|
| 719 | - |
|
| 720 | - $objet = ($objet == '*') ? $objet : objet_type($objet); # securite |
|
| 721 | - if (!is_array($id_objets) or reset($id_objets) == "NOT") { |
|
| 722 | - $id_objets = array($id_objets); |
|
| 723 | - } |
|
| 724 | - foreach ($id_objets as $id_objet) { |
|
| 725 | - |
|
| 726 | - $args = array( |
|
| 727 | - 'table_lien' => $table_lien, |
|
| 728 | - 'objet_source' => $objet_source, |
|
| 729 | - 'id_objet_source' => $id, |
|
| 730 | - 'objet' => $objet, |
|
| 731 | - 'id_objet' => $id_objet, |
|
| 732 | - 'role' => $role, |
|
| 733 | - 'colonne_role' => $colonne_role, |
|
| 734 | - 'action' => 'modifier', |
|
| 735 | - ); |
|
| 736 | - |
|
| 737 | - // Envoyer aux plugins |
|
| 738 | - $qualif = pipeline('pre_edition_lien', |
|
| 739 | - array( |
|
| 740 | - 'args' => $args, |
|
| 741 | - 'data' => $qualif, |
|
| 742 | - ) |
|
| 743 | - ); |
|
| 744 | - $args['id_objet'] = $id_objet; |
|
| 745 | - |
|
| 746 | - $where = lien_where($primary, $id, $objet, $id_objet, $cond); |
|
| 747 | - $e = sql_updateq($table_lien, $qualif, $where); |
|
| 748 | - |
|
| 749 | - if ($e === false) { |
|
| 750 | - $echec = true; |
|
| 751 | - } else { |
|
| 752 | - // Envoyer aux plugins |
|
| 753 | - pipeline('post_edition_lien', |
|
| 754 | - array( |
|
| 755 | - 'args' => $args, |
|
| 756 | - 'data' => $qualif |
|
| 757 | - ) |
|
| 758 | - ); |
|
| 759 | - $ok++; |
|
| 760 | - } |
|
| 761 | - } |
|
| 762 | - } |
|
| 763 | - |
|
| 764 | - return ($echec ? false : $ok); |
|
| 701 | + $echec = null; |
|
| 702 | + $ok = 0; |
|
| 703 | + if (!$qualif) { |
|
| 704 | + return false; |
|
| 705 | + } |
|
| 706 | + // nettoyer qualif qui peut venir directement d'un objet_trouver_lien : |
|
| 707 | + unset($qualif[$primary]); |
|
| 708 | + unset($qualif[$objet_source]); |
|
| 709 | + if (isset($qualif['objet'])) { |
|
| 710 | + unset($qualif[$qualif['objet']]); |
|
| 711 | + } |
|
| 712 | + unset($qualif['objet']); |
|
| 713 | + unset($qualif['id_objet']); |
|
| 714 | + foreach ($objets as $objet => $id_objets) { |
|
| 715 | + |
|
| 716 | + // role, colonne, where par défaut |
|
| 717 | + list($role, $colonne_role, $cond) = |
|
| 718 | + roles_trouver_dans_qualif($objet_source, $objet, $qualif); |
|
| 719 | + |
|
| 720 | + $objet = ($objet == '*') ? $objet : objet_type($objet); # securite |
|
| 721 | + if (!is_array($id_objets) or reset($id_objets) == "NOT") { |
|
| 722 | + $id_objets = array($id_objets); |
|
| 723 | + } |
|
| 724 | + foreach ($id_objets as $id_objet) { |
|
| 725 | + |
|
| 726 | + $args = array( |
|
| 727 | + 'table_lien' => $table_lien, |
|
| 728 | + 'objet_source' => $objet_source, |
|
| 729 | + 'id_objet_source' => $id, |
|
| 730 | + 'objet' => $objet, |
|
| 731 | + 'id_objet' => $id_objet, |
|
| 732 | + 'role' => $role, |
|
| 733 | + 'colonne_role' => $colonne_role, |
|
| 734 | + 'action' => 'modifier', |
|
| 735 | + ); |
|
| 736 | + |
|
| 737 | + // Envoyer aux plugins |
|
| 738 | + $qualif = pipeline('pre_edition_lien', |
|
| 739 | + array( |
|
| 740 | + 'args' => $args, |
|
| 741 | + 'data' => $qualif, |
|
| 742 | + ) |
|
| 743 | + ); |
|
| 744 | + $args['id_objet'] = $id_objet; |
|
| 745 | + |
|
| 746 | + $where = lien_where($primary, $id, $objet, $id_objet, $cond); |
|
| 747 | + $e = sql_updateq($table_lien, $qualif, $where); |
|
| 748 | + |
|
| 749 | + if ($e === false) { |
|
| 750 | + $echec = true; |
|
| 751 | + } else { |
|
| 752 | + // Envoyer aux plugins |
|
| 753 | + pipeline('post_edition_lien', |
|
| 754 | + array( |
|
| 755 | + 'args' => $args, |
|
| 756 | + 'data' => $qualif |
|
| 757 | + ) |
|
| 758 | + ); |
|
| 759 | + $ok++; |
|
| 760 | + } |
|
| 761 | + } |
|
| 762 | + } |
|
| 763 | + |
|
| 764 | + return ($echec ? false : $ok); |
|
| 765 | 765 | } |
| 766 | 766 | |
| 767 | 767 | /** |
@@ -791,23 +791,23 @@ discard block |
||
| 791 | 791 | * @return array |
| 792 | 792 | */ |
| 793 | 793 | function lien_find($objet_source, $primary, $table_lien, $id, $objets, $cond = null) { |
| 794 | - $trouve = array(); |
|
| 795 | - foreach ($objets as $objet => $id_objets) { |
|
| 796 | - $objet = ($objet == '*') ? $objet : objet_type($objet); # securite |
|
| 797 | - // gerer les roles s'il y en a dans $cond |
|
| 798 | - list($cond) = roles_creer_condition_role($objet_source, $objet, $cond, true); |
|
| 799 | - // lien_where prend en charge les $id_objets sous forme int ou array |
|
| 800 | - $where = lien_where($primary, $id, $objet, $id_objets, $cond); |
|
| 801 | - $liens = sql_allfetsel('*', $table_lien, $where); |
|
| 802 | - // ajouter les entrees objet_source et objet cible par convenance |
|
| 803 | - foreach ($liens as $l) { |
|
| 804 | - $l[$objet_source] = $l[$primary]; |
|
| 805 | - $l[$objet] = $l['id_objet']; |
|
| 806 | - $trouve[] = $l; |
|
| 807 | - } |
|
| 808 | - } |
|
| 809 | - |
|
| 810 | - return $trouve; |
|
| 794 | + $trouve = array(); |
|
| 795 | + foreach ($objets as $objet => $id_objets) { |
|
| 796 | + $objet = ($objet == '*') ? $objet : objet_type($objet); # securite |
|
| 797 | + // gerer les roles s'il y en a dans $cond |
|
| 798 | + list($cond) = roles_creer_condition_role($objet_source, $objet, $cond, true); |
|
| 799 | + // lien_where prend en charge les $id_objets sous forme int ou array |
|
| 800 | + $where = lien_where($primary, $id, $objet, $id_objets, $cond); |
|
| 801 | + $liens = sql_allfetsel('*', $table_lien, $where); |
|
| 802 | + // ajouter les entrees objet_source et objet cible par convenance |
|
| 803 | + foreach ($liens as $l) { |
|
| 804 | + $l[$objet_source] = $l[$primary]; |
|
| 805 | + $l[$objet] = $l['id_objet']; |
|
| 806 | + $trouve[] = $l; |
|
| 807 | + } |
|
| 808 | + } |
|
| 809 | + |
|
| 810 | + return $trouve; |
|
| 811 | 811 | } |
| 812 | 812 | |
| 813 | 813 | /** |
@@ -818,25 +818,25 @@ discard block |
||
| 818 | 818 | * @param array|int $ids |
| 819 | 819 | */ |
| 820 | 820 | function lien_propage_date_modif($objet, $ids) { |
| 821 | - static $done = array(); |
|
| 822 | - $hash = md5($objet . serialize($ids)); |
|
| 823 | - |
|
| 824 | - // sql_updateq, peut être un rien lent. |
|
| 825 | - // On évite de l'appeler 2 fois sur les mêmes choses |
|
| 826 | - if (isset($done[$hash])) { |
|
| 827 | - return; |
|
| 828 | - } |
|
| 829 | - |
|
| 830 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 831 | - |
|
| 832 | - $table = table_objet_sql($objet); |
|
| 833 | - if ($desc = $trouver_table($table) |
|
| 834 | - and isset($desc['field']['date_modif']) |
|
| 835 | - ) { |
|
| 836 | - $primary = id_table_objet($objet); |
|
| 837 | - $where = (is_array($ids) ? sql_in($primary, array_map('intval', $ids)) : "$primary=" . intval($ids)); |
|
| 838 | - sql_updateq($table, array('date_modif' => date('Y-m-d H:i:s')), $where); |
|
| 839 | - } |
|
| 840 | - |
|
| 841 | - $done[$hash] = true; |
|
| 821 | + static $done = array(); |
|
| 822 | + $hash = md5($objet . serialize($ids)); |
|
| 823 | + |
|
| 824 | + // sql_updateq, peut être un rien lent. |
|
| 825 | + // On évite de l'appeler 2 fois sur les mêmes choses |
|
| 826 | + if (isset($done[$hash])) { |
|
| 827 | + return; |
|
| 828 | + } |
|
| 829 | + |
|
| 830 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 831 | + |
|
| 832 | + $table = table_objet_sql($objet); |
|
| 833 | + if ($desc = $trouver_table($table) |
|
| 834 | + and isset($desc['field']['date_modif']) |
|
| 835 | + ) { |
|
| 836 | + $primary = id_table_objet($objet); |
|
| 837 | + $where = (is_array($ids) ? sql_in($primary, array_map('intval', $ids)) : "$primary=" . intval($ids)); |
|
| 838 | + sql_updateq($table, array('date_modif' => date('Y-m-d H:i:s')), $where); |
|
| 839 | + } |
|
| 840 | + |
|
| 841 | + $done[$hash] = true; |
|
| 842 | 842 | } |