From 0c951607982c41ef738c0a281585ac46f37401cf Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Wed, 11 Jan 2012 16:13:08 +0000 Subject: [PATCH] =?UTF-8?q?Chargement=20des=20crit=C3=A8res=20depuis=20la?= =?UTF-8?q?=20base=20de=20donn=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/controllers/IndexController.php | 34 +++++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/application/controllers/IndexController.php b/application/controllers/IndexController.php index 74c2aba9..b7f74022 100644 --- a/application/controllers/IndexController.php +++ b/application/controllers/IndexController.php @@ -11,17 +11,39 @@ class IndexController extends Zend_Controller_Action public function init() { - require_once('Scores/Field.php'); - $auth = Zend_Auth::getInstance(); - $user = $auth->getIdentity(); - $field = new Fields($user->username); - $this->fields = $field; + } public function criteresAction() { $this->view->headScript()->appendFile('/themes/default/scripts/fields.js', 'text/javascript'); - $this->view->fields = $this->fields; + $request = $this->getRequest(); + + $auth = Zend_Auth::getInstance(); + $user = $auth->getIdentity(); + $this->view->fields = $fields; + + //Chargement de la structure des champs et des préférences utilisateurs + require_once 'Scores/Field.php'; + $field = new Fields($user->username); + + // Chargement des critères de ciblage à partir de l'enregistrement en bdd + $id = $request->getParam('id', 0); + if (!empty($id)) { + $db = Zend_Registry::get('db'); + $criteresM = new Application_Model_Criteres(); + $sql = $criteresM->select() + ->columns($criteresM, array('criteres')) + ->where('login = ?', $user->username) + ->where('id = ?', $id); + + $row = $criteresM->fetchRow($sql); + if ($row != null) { + require_once 'Scores/SessionCiblage.php'; + $session = new SessionCiblage(); + $session->setCriteres(json_decode($row->criteres, 'true')); + } + } } public function resetAction()