[6] | 1 | <?php |
---|
| 2 | |
---|
| 3 | function e_set_spotlights($env) |
---|
| 4 | { if($env->data->is_admin($env->pun_user["id"])) |
---|
| 5 | { $env->a = $_GET[$env->param("action")] ? $_GET[$env->param("action")] : "spotlights"; |
---|
| 6 | $function = "a_".$env->a; |
---|
| 7 | if(function_exists($function)) $function($env); |
---|
| 8 | } |
---|
| 9 | else $env->erreur = "Vous devez être administrateur pour accéder à cette page."; |
---|
| 10 | } |
---|
| 11 | |
---|
| 12 | # ------------------------------------------------------------------------------ |
---|
| 13 | # actions |
---|
| 14 | # |
---|
| 15 | |
---|
| 16 | function a_spotlights($env) |
---|
| 17 | { if(($env->out["spotlights"] = $env->data->spotlights($env->start)) !== false) |
---|
| 18 | { |
---|
| 19 | } |
---|
| 20 | else $env->erreur = "Impossible de lire les spotlights"; |
---|
| 21 | } |
---|
| 22 | |
---|
| 23 | function a_add_spotlight($env) |
---|
| 24 | { if($_POST) |
---|
| 25 | { if($_POST["preview"]) |
---|
| 26 | { $env->out["preview"] = array |
---|
| 27 | ( "titre" => $_POST["titre"], |
---|
| 28 | "contenu" => $_POST["spotlight"], |
---|
| 29 | "auteur" => $env->pun_user["username"], |
---|
| 30 | "date_publication" => $_POST["date_publication"], |
---|
| 31 | "public" => $_POST["public"] ? 1 : 0 |
---|
| 32 | ); |
---|
| 33 | } |
---|
| 34 | else |
---|
| 35 | { if |
---|
| 36 | ( $env->data->add_spotlight |
---|
| 37 | ( $_POST["titre"], |
---|
| 38 | $_POST["spotlight"], |
---|
| 39 | $env->pun_user["id"], |
---|
| 40 | $_POST["date_publication"], |
---|
| 41 | $_POST["public"] ? 1 : 0 |
---|
| 42 | ) |
---|
| 43 | ) |
---|
| 44 | { _redirect |
---|
| 45 | ( $env, |
---|
| 46 | $env->url(array("e" => "set_spotlights")), |
---|
| 47 | "Le spotlight a été ajouté" |
---|
| 48 | ); |
---|
| 49 | } |
---|
| 50 | else $env->erreur = "Impossible d'ajouter le spotlight."; |
---|
| 51 | } |
---|
| 52 | } |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | function a_set_spotlight($env) |
---|
| 56 | { if($_POST) |
---|
| 57 | { if($_POST["preview"]) |
---|
| 58 | { $env->out["preview"] = array |
---|
| 59 | ( "titre" => $_POST["titre"], |
---|
| 60 | "contenu" => $_POST["spotlight"], |
---|
| 61 | "auteur" => $env->pun_user["username"], |
---|
| 62 | "date_publication" => $_POST["date_publication"], |
---|
| 63 | "public" => $_POST["public"] ? 1 : 0 |
---|
| 64 | ); |
---|
| 65 | } |
---|
| 66 | else |
---|
| 67 | { if |
---|
| 68 | ( $env->data->set_spotlight |
---|
| 69 | ( $_GET[$env->param("spotlight")], |
---|
| 70 | $_POST["titre"], |
---|
| 71 | $_POST["spotlight"], |
---|
| 72 | $env->pun_user["id"], |
---|
| 73 | $_POST["date_publication"], |
---|
| 74 | $_POST["public"] ? 1 : 0 |
---|
| 75 | ) |
---|
| 76 | ) |
---|
| 77 | { _redirect |
---|
| 78 | ( $env, |
---|
| 79 | $env->url(array("e" => "set_spotlights")), |
---|
| 80 | "Le spotlight a été modifié" |
---|
| 81 | ); |
---|
| 82 | } |
---|
| 83 | else $env->erreur = "Impossible de modifier le spotlight."; |
---|
| 84 | } |
---|
| 85 | } |
---|
| 86 | else |
---|
| 87 | { if(($env->out["_spotlight"] = $env->data->spotlight($_GET[$env->param("spotlight")])) === false) |
---|
| 88 | { $env->erreur = "Impossible de lire le spotlight."; |
---|
| 89 | } |
---|
| 90 | } |
---|
| 91 | } |
---|
| 92 | |
---|
| 93 | function a_del_spotlight($env) |
---|
| 94 | { if($env->data->del_spotlight($_GET[$env->param("spotlight")]) !== false) |
---|
| 95 | { _redirect |
---|
| 96 | ( $env, |
---|
| 97 | $env->url(array("e" => "set_spotlights")), |
---|
| 98 | "Le spotlight a été supprimé" |
---|
| 99 | ); |
---|
| 100 | } |
---|
| 101 | else $env->erreur = "Impossible de supprimer le spotlight."; |
---|
| 102 | } |
---|
| 103 | |
---|
| 104 | ?> |
---|