This repository has been archived by the owner on Dec 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ClubController.php
112 lines (102 loc) · 4.45 KB
/
ClubController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
class ClubController extends My_Controller_Action_CustomContent {
public function init() {
$this->_title = 'Le club';
$this->_styleSheets = array('/css/club/club.css');
parent::init();
}
public function indexAction() {
$auth = Zend_Auth::getInstance();
if ($auth->hasIdentity()
&& $auth->getIdentity()->getRoleId() == Application_Model_Acl::ROLE_ADMIN) {
$this->view->headScript()->appendFile('/js/category.js')
->appendFile('/js/tinymce/jquery.tinymce.min.js')
->appendFile('/js/jquery/jquery.TimeCircles.js');
}
$request = $this->getRequest();
$id = $request->getParam('id', 1);
$clubMapper = new Application_Model_Mapper_Club();
$this->view->sections = $clubMapper->fetchAll();
// Recherche de la section courante
foreach ($this->view->sections as $section) {
if ($id == $section->id) {
$this->view->club = $section;
break;
}
}
// Si on affiche le trombinoscope
if ($id == 3) {
$this->view->headLink()->appendStylesheet('/css/membres/trombi.css');
$profilMapper = new Application_Model_Mapper_Profil();
$everybody = array();
$profils = $profilMapper->findAncien(false);
if (count($profils) > 0) {
$everybody["Sesquis d'aujourd'hui"] = array();
}
foreach ($profils as $profil) {
$everybody["Sesquis d'aujourd'hui"][] = $profil;
}
$profils = $profilMapper->findAncien();
if (count($profils) > 0) {
$everybody["Sesquis d'hier"] = array();
}
foreach ($profils as $profil) {
$everybody["Sesquis d'hier"][] = $profil;
}
$this->view->everybody = $everybody;
} else if ($id == 5) { // Si on affiche les lieux d'entraînement
$this->view->headScript()
->appendFile('http://maps.google.com/maps/api/js?sensor=false')
->appendFile('/js/jquery/gmap3.min.js')
->appendFile('/js/jquery/jquery.form.js')
->appendFile('/js/jquery/jquery.validate.min.js')
->appendFile('/js/jquery/jquery.validate.localization/messages_fr.js')
->appendFile('/js/lieux_admin.js');
$lieuxMapper = new Application_Model_Mapper_LieuUltimate();
$this->view->lieux = $lieuxMapper->fetchEntrainements();
}
}
public function modifierAction() {
$request = $this->getRequest();
$id = $request->getParam('id', 1);
$clubMapper = new Application_Model_Mapper_Club();
// Enregistrement du nouveau contenu s'il est présent
if (!is_null($content = $request->getParam('content')) && !is_null($title = $request->getParam('title'))) {
$club = new Application_Model_Club(array(
'id' => $id,
'titre' => $title,
'contenu' => $content,
));
$clubMapper->save($club);
$this->_helper->flashMessenger('Modification du contenu réussi');
}
$this->_redirect('/club/index/id/'.$id);
}
public function ajouterAction() {
$request = $this->getRequest();
$id = $request->getParam('id', 1);
$clubMapper = new Application_Model_Mapper_Club();
// Enregistrement du nouveau contenu s'il est présent
if (!is_null($title = $request->getParam('addTitle'))) {
$club = new Application_Model_Club(array(
'titre' => $title,
'contenu' => ''));
$clubMapper->save($club);
$this->_helper->flashMessenger('Catégorie ajoutée avec succès');
}
$this->_redirect('/club/index/id/'.$id);
}
public function supprimerAction() {
$request = $this->getRequest();
$id = $request->getParam('id', 1);
$clubMapper = new Application_Model_Mapper_Club();
if (!is_null($idDelCat = $request->getParam('delCat'))) {
$clubMapper->getDbTable()->delete(array('id = ?' => $idDelCat));
$this->_helper->flashMessenger('Catégorie supprimée avec succès');
if ($id == $idDelCat) {
$id = 1;
}
}
$this->_redirect('/club/index/id/'.$id);
}
}