Gestion des paramètres du service
This commit is contained in:
parent
71c809c55f
commit
387e906522
@ -1,6 +1,14 @@
|
||||
<?php
|
||||
class Admin_ServiceController extends Zend_Controller_Action
|
||||
{
|
||||
protected $theme;
|
||||
|
||||
public function init()
|
||||
{
|
||||
// --- Theme
|
||||
$this->theme = Zend_Registry::get('theme');
|
||||
}
|
||||
|
||||
public function indexAction()
|
||||
{
|
||||
$ws = new Scores_Ws_Client('account', '0.1');
|
||||
@ -10,6 +18,9 @@ class Admin_ServiceController extends Zend_Controller_Action
|
||||
|
||||
public function detailAction()
|
||||
{
|
||||
$this->view->headScript()
|
||||
->appendFile($this->theme->pathScript.'/service.js', 'text/javascript');
|
||||
|
||||
$request = $this->getRequest();
|
||||
$code = $request->getParam('code');
|
||||
|
||||
@ -28,4 +39,37 @@ class Admin_ServiceController extends Zend_Controller_Action
|
||||
$this->view->Access[$item->Code] = $item->Label;
|
||||
}
|
||||
}
|
||||
|
||||
public function accessAction()
|
||||
{
|
||||
$this->_helper->layout()->disableLayout();
|
||||
$request = $this->getRequest();
|
||||
$id = $request->getParam('id');
|
||||
$this->view->id = $id;
|
||||
$name = $request->getParam('name');
|
||||
$this->view->name = $name;
|
||||
$delete = $request->getParam('delete', 0);
|
||||
$this->view->delete = $delete;
|
||||
|
||||
$params = new stdClass();
|
||||
$params->type = 'acces';
|
||||
$params->value = $name;
|
||||
$params->id = $id;
|
||||
if ($delete == 1) {
|
||||
$params->delete = true;
|
||||
} else {
|
||||
$params->delete = false;
|
||||
}
|
||||
|
||||
$ws = new Scores_Ws_Client('account', '0.1');
|
||||
$response = $ws->setServiceParam($params);
|
||||
Zend_Registry::get('firebug')->info($response);
|
||||
if ($response === true) {
|
||||
// Do nothing
|
||||
}
|
||||
else {
|
||||
$this->view->error = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
<?php if ($this->error === true) {?>
|
||||
<span class="bg-danger">Erreur !</span>
|
||||
<?php } else {?>
|
||||
<?php if ($this->delete === 1) {?>
|
||||
<span class="label label-warning">Désactivé</span>
|
||||
<script>
|
||||
$('div#<?=$this->name?>-action span')
|
||||
.data('url', "<?=$this->url(array('module'=>'admin', 'controller'=>'service', 'action'=>'access', 'id'=>$this->id, 'name'=>$this->name), 'default', true)?>")
|
||||
.removeClass('glyphicon-remove').addClass('glyphicon-plus');
|
||||
</script>
|
||||
<?php } else {?>
|
||||
<span class="label label-success">Activé</span>
|
||||
<script>
|
||||
$('div#<?=$this->name?>-action span')
|
||||
.data('url', "<?=$this->url(array('module'=>'admin', 'controller'=>'service', 'action'=>'access', 'id'=>$this->id, 'name'=>$this->name, 'delete'=>1), 'default', true)?>")
|
||||
.removeClass('glyphicon-plus').addClass('glyphicon-remove');
|
||||
</script>
|
||||
<?php }?>
|
||||
<?php }?>
|
||||
|
||||
|
||||
|
||||
|
@ -41,7 +41,7 @@
|
||||
|
||||
<h2>Droits d'accès</h2>
|
||||
<?php if (count($this->Info->Acces->item) == 0) {?>
|
||||
<p class="bg-classes bg-danger"><strong>Attention !</strong> Aucun paramètre d'accès défini.
|
||||
<p class="bg-classes bg-danger"><strong>Attention !</strong> Aucun paramètre d'accès défini.
|
||||
Les utilisateurs ne pourront pas accèder au service.</p>
|
||||
<?php }?>
|
||||
<?php foreach ($this->Categories as $c => $item) {?>
|
||||
@ -57,20 +57,34 @@ Les utilisateurs ne pourront pas accèder au service.</p>
|
||||
}
|
||||
} ?>
|
||||
<li class="list-group-item<?php if ($exist == 1) { echo " list-group-item-success"; }?>">
|
||||
<div class="row">
|
||||
<div class="row" id="<?=$a?>-row">
|
||||
<div class="col-md-6">
|
||||
<?php if (array_key_exists($a, $this->Access)) {?>
|
||||
<?=$this->Access[$a]?>
|
||||
<?php } else {?>
|
||||
<?=$a?>
|
||||
<?php }?>
|
||||
<?php }?>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<?php if ($exist == 0) {?>
|
||||
<div id="<?=$a?>-status" class="col-md-3">
|
||||
<?php if ($exist == 0) {?>
|
||||
<span class="label label-warning">Désactivé</span>
|
||||
<span class="glyphicon glyphicon-plus pull-right"></span>
|
||||
<?php } else {?>
|
||||
<span class="glyphicon glyphicon-remove pull-right"></span>
|
||||
<?php }?>
|
||||
</div>
|
||||
<div id="<?=$a?>-action" class="col-md-3 access-action">
|
||||
<?php if ($exist == 0) {?>
|
||||
<?php if ($this->Info->Editable == 1) {?>
|
||||
<span data-name="<?=$a?>" data-url="<?=$this->url(array(
|
||||
'module'=>'admin', 'controller'=>'service', 'action'=>'access',
|
||||
'id'=>$this->Info->id, 'name'=>$a), 'default', true)?>"
|
||||
class="glyphicon glyphicon-plus"></span>
|
||||
<?php }?>
|
||||
<?php } else {?>
|
||||
<?php if ($this->Info->Editable == 1) {?>
|
||||
<span data-name="<?=$a?>" data-url="<?=$this->url(array(
|
||||
'module'=>'admin', 'controller'=>'service', 'action'=>'access',
|
||||
'id'=>$this->Info->id, 'name'=>$a, 'delete'=>1), 'default', true)?>"
|
||||
class="glyphicon glyphicon-remove"></span>
|
||||
<?php }?>
|
||||
<?php }?>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -4,7 +4,7 @@ return array(
|
||||
'getAuthLog' => array(
|
||||
'debug' => true,
|
||||
),
|
||||
'getCategory' => null,
|
||||
'getCategory' => null,
|
||||
'getAccess' => null,
|
||||
'getClient' => null,
|
||||
'getClientServices' => null,
|
||||
@ -26,7 +26,9 @@ return array(
|
||||
'loginAuthenticate' => null,
|
||||
'setCGU' => null,
|
||||
'setService' => null,
|
||||
'setServiceParam' => null,
|
||||
'setServiceParam' => array(
|
||||
'debug' => true,
|
||||
),
|
||||
'setUser' => array(
|
||||
'debug' => true,
|
||||
'errorMsg' => array('env:Receiver','ERR'),
|
||||
|
13
public/themes/default/scripts/service.js
Normal file
13
public/themes/default/scripts/service.js
Normal file
@ -0,0 +1,13 @@
|
||||
$(function() {
|
||||
$('div.access-action span').on('click', function(e){
|
||||
e.preventDefault();
|
||||
var url = $(this).data('url');
|
||||
var name = $(this).data('name');
|
||||
$('div#'+name+'-status').html("Activation en cours ...");
|
||||
$.post(url, function(data) {
|
||||
$('div#'+name+'-status').html(data);
|
||||
}).fail(function() {
|
||||
$('div#'+name+'-status').html("Erreur.");
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user