odea/application/controllers/IndexController.php

67 lines
1.6 KiB
PHP

<?php
class IndexController extends Zend_Controller_Action
{
protected $fields;
public function indexAction(){}
public function selectionAction(){}
public function historiqueAction(){}
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;
}
public function resetAction()
{
require_once 'Scores/SessionCiblage.php';
$session = new SessionCiblage();
$session->clearCiblage();
$this->_redirect('./');
}
public function saveAction()
{
$this->_helper->layout()->disableLayout();
$this->_helper->viewRenderer->setNoRender();
$field = $this->getRequest()->getParam('name');
$fields = $this->fields->getFields();
$fields[$field]['activated'] = (($fields[$field]['activated'] == false)?true:false);
$auth = Zend_Auth::getInstance();
$user = $auth->getIdentity();
$db = Zend_Registry::get('db');
$prefsModel = new Application_Model_Prefs($db);
$data = array(
'login' => $user->username,
'json' => $this->fields->getNotActivated($fields),
);
$prefsModel->select()->where('login = "?"', $user->username);
$rows =$prefsModel->fetchRow();
$rows = $rows->toArray();
if (count($rows) > 0) {
$prefsModel->update($data, 'login = "'.$user->unsername.'"');
} else {
$prefsModel->insert($data);
}
$this->_redirect('./');
}
}