extranet/includes/user/preferences.php
2010-05-04 16:18:40 +00:00

34 lines
1.3 KiB
PHP

<?php
$definePref = array(
'NAF4' => array( 'init' => '', 'txt' => 'Afficher les anciens NAF'),
'NACE' => array( 'init' => '', 'txt' => 'Afficher les codes NACES'),
'NEWS' => array( 'init' => '', 'txt' => 'Afficher les news Google&copy;'),
'MAPPY' => array( 'init' => '', 'txt' => 'Afficher les fa&ccedil;ades d\'immeubles'),
'CARTES' => array( 'init' => '', 'txt' => 'Afficher les cartes et les plans'),
'VOIRSURV' => array( 'init' => '', 'txt' => 'Afficher les entités sous surveillances'),
);
function hasPref($name, $userInfo = ''){
$return = FALSE;
if($userInfo == '' && isset($_SESSION['tabInfo']['pref']) ){
$userInfo = $_SESSION['tabInfo'];
}elseif($userInfo == '' && !isset($_SESSION['tabInfo']['pref']) ||
!isset($userInfo['pref'])){
$userInfo = array( 'pref' => '' );
}
if (preg_match('/\b'.$name.'\b/i', $userInfo['pref'])) $return = TRUE;
return $return;
}
function formElementPref($userInfo){
global $definePref;
$inputElements = '';
foreach($definePref as $pref => $infos){
(hasPref($pref, $userInfo)==TRUE) ? $checked = 'checked' : $checked = $infos['init'];
$inputElements.= '<input type="checkbox" name="frmOptions[pref][]" value="'.strtolower($pref).'" '.$checked.' class="noborder"/> '.$infos['txt'].'<br/>'."\n";
}
return $inputElements;
}
?>