41 lines
1.0 KiB
PHP
41 lines
1.0 KiB
PHP
<?php
|
|
class PreferencesController extends Zend_Controller_Action
|
|
{
|
|
public function saveAction()
|
|
{
|
|
$this->_helper->layout()->disableLayout();
|
|
$this->_helper->viewRenderer->setNoRender();
|
|
|
|
$fields = $this->getRequest()->getParam('fields');
|
|
$auth = Zend_Auth::getInstance();
|
|
$user = $auth->getIdentity();
|
|
|
|
$db = Zend_Registry::get('db');
|
|
|
|
$prefsModel = new Application_Model_Prefs($db);
|
|
$data = array(
|
|
'login' => $user->username,
|
|
'json' => json_encode($this->getNotActivated(json_decode($fields))),
|
|
);
|
|
$sql = $prefsModel->select()->where('login = ?', $user->username);
|
|
$rows = $prefsModel->fetchAll($sql);
|
|
if (count($rows)>0) {
|
|
$prefsModel->update($data, 'login = '.$user->unsername);
|
|
} else {
|
|
$prefsModel->insert($data);
|
|
}
|
|
|
|
$this->_redirect('./');
|
|
}
|
|
|
|
public function getNotActivated($fields)
|
|
{
|
|
foreach($fields as $name => $field)
|
|
{
|
|
if(!$field['activated']) {
|
|
$desactivated[] = array($name => "");
|
|
}
|
|
}
|
|
return ($desactivated);
|
|
}
|
|
} |