data->is_admin($env->pun_user["id"])) { $env->a = $_GET[$env->param("action")] ? $_GET[$env->param("action")] : "spotlights"; $function = "a_".$env->a; if(function_exists($function)) $function($env); } else $env->erreur = "Vous devez être administrateur pour accéder à cette page."; } # ------------------------------------------------------------------------------ # actions # function a_spotlights($env) { if(($env->out["spotlights"] = $env->data->spotlights($env->start)) !== false) { } else $env->erreur = "Impossible de lire les spotlights"; } function a_add_spotlight($env) { if($_POST) { if($_POST["preview"]) { $env->out["preview"] = array ( "titre" => $_POST["titre"], "contenu" => $_POST["spotlight"], "auteur" => $env->pun_user["username"], "date_publication" => $_POST["date_publication"], "public" => $_POST["public"] ? 1 : 0 ); } else { if ( $env->data->add_spotlight ( $_POST["titre"], $_POST["spotlight"], $env->pun_user["id"], $_POST["date_publication"], $_POST["public"] ? 1 : 0 ) ) { _redirect ( $env, $env->url(array("e" => "set_spotlights")), "Le spotlight a été ajouté" ); } else $env->erreur = "Impossible d'ajouter le spotlight."; } } } function a_set_spotlight($env) { if($_POST) { if($_POST["preview"]) { $env->out["preview"] = array ( "titre" => $_POST["titre"], "contenu" => $_POST["spotlight"], "auteur" => $env->pun_user["username"], "date_publication" => $_POST["date_publication"], "public" => $_POST["public"] ? 1 : 0 ); } else { if ( $env->data->set_spotlight ( $_GET[$env->param("spotlight")], $_POST["titre"], $_POST["spotlight"], $env->pun_user["id"], $_POST["date_publication"], $_POST["public"] ? 1 : 0 ) ) { _redirect ( $env, $env->url(array("e" => "set_spotlights")), "Le spotlight a été modifié" ); } else $env->erreur = "Impossible de modifier le spotlight."; } } else { if(($env->out["_spotlight"] = $env->data->spotlight($_GET[$env->param("spotlight")])) === false) { $env->erreur = "Impossible de lire le spotlight."; } } } function a_del_spotlight($env) { if($env->data->del_spotlight($_GET[$env->param("spotlight")]) !== false) { _redirect ( $env, $env->url(array("e" => "set_spotlights")), "Le spotlight a été supprimé" ); } else $env->erreur = "Impossible de supprimer le spotlight."; } ?>