From 6558ec10d2f93f10f2403d80361d3869a075c590 Mon Sep 17 00:00:00 2001 From: Phyks Date: Fri, 6 Sep 2013 23:21:05 +0200 Subject: [PATCH] Edit_user JSON view ok --- TODO | 2 +- inc/User.class.php | 9 +++++++-- tpl/json/edit_users.html | 28 +++------------------------- 3 files changed, 11 insertions(+), 28 deletions(-) diff --git a/TODO b/TODO index 7d74cd4..03d9367 100755 --- a/TODO +++ b/TODO @@ -1,5 +1,5 @@ * Don't cache the username -* JSON output => finish the template +* JSON output => do index view * API inc/Invoices.class.php : diff --git a/inc/User.class.php b/inc/User.class.php index ce1fb5c..a78b36b 100644 --- a/inc/User.class.php +++ b/inc/User.class.php @@ -97,8 +97,13 @@ class User extends Storage { // Session storage // =============== - public function sessionStore() { - return serialize(array('id'=>$this->id, 'login'=>$this->login, 'display_name'=>$this->display_name, 'password'=>$this->password, 'admin'=>$this->admin, 'json_token'=>$this->json_token)); + public function sessionStore($serialize = true) { + if($serialize) { + return serialize(array('id'=>$this->id, 'login'=>$this->login, 'display_name'=>$this->display_name, 'password'=>$this->password, 'admin'=>$this->admin, 'json_token'=>$this->json_token)); + } + else { + return array('id'=>$this->id, 'login'=>$this->login, 'display_name'=>$this->display_name, 'password'=>$this->password, 'admin'=>$this->admin, 'json_token'=>$this->json_token); + } } public function sessionRestore($data, $serialized = false) { diff --git a/tpl/json/edit_users.html b/tpl/json/edit_users.html index 9896e63..0ef113f 100644 --- a/tpl/json/edit_users.html +++ b/tpl/json/edit_users.html @@ -3,29 +3,7 @@ {/if} {if condition="$view == 'list_users'"} -TODO *** -

List of users

-

You can also add a user.

- - - - - - - - - - {loop="users"} - - - - - - - - - {/loop} -
IdLoginDisplay NameIs admin ?EditDelete
{$value->getId()}{$value->getLogin()}{$value->getDisplayName()}{$value->getAdmin() ? "Yes" : "No"}Edit{if condition="$value->getId() != $current_user->getId()"}Delete{/if}
+ {function="json_encode(array_map(function($obj) { return $obj->sessionStore(false);}, $users))"} {else} - {if condition="LANG == 'en'}Nothing to show.{else}Il n'y a rien à afficher.{/if} -{/else} + {if condition="LANG == 'en'"}Nothing to show.{else}Il n'y a rien à afficher.{/if} +{/if}