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}