Edit_user JSON view ok

This commit is contained in:
Phyks 2013-09-06 23:21:05 +02:00
parent 6bbad05b36
commit 6558ec10d2
3 changed files with 11 additions and 28 deletions

2
TODO
View File

@ -1,5 +1,5 @@
* Don't cache the username
* JSON output => finish the template
* JSON output => do index view
* API
inc/Invoices.class.php :

View File

@ -97,9 +97,14 @@ class User extends Storage {
// Session storage
// ===============
public function sessionStore() {
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) {
if($serialized)

View File

@ -3,29 +3,7 @@
{/if}
{if condition="$view == 'list_users'"}
TODO ***
<h2>List of users</h2>
<p class="center">You can also <a href="?do=add_user">add a user</a>.</p>
<table id="edit_users">
<tr>
<th>Id</th>
<th>Login</th>
<th>Display Name</th>
<th>Is admin ?</th>
<th>Edit</th>
<th>Delete</th>
</tr>
{loop="users"}
<tr>
<td>{$value->getId()}</td>
<td>{$value->getLogin()}</td>
<td>{$value->getDisplayName()}</td>
<td>{$value->getAdmin() ? "Yes" : "No"}</td>
<td><a href="index.php?do=edit_users&user_id={$value->getId()}">Edit</a></td>
<td>{if condition="$value->getId() != $current_user->getId()"}<a href="index.php?do=delete_user&user_id={$value->getId()}">Delete</a>{/if}</td>
</tr>
{/loop}
</table>
{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}