<?php
namespace admin\controls;

class Users
{
  public static function user_delete()
  {
    if ( \admin\factory\Users::user_delete( \S::get( 'id' ) ) )
      \S::alert( 'Użytkownik został usunięty.' );
    header( 'Location: /admin/users/view_list/' );
    exit;
  }

  public static function user_save()
  {
    $values = json_decode( \S::get( 'values' ), true );
    $response = \admin\factory\Users::user_save( $values['id'], $values['login'], $values['status'], $values['password'], $values['password_re'], $values['admin'] );
    echo json_encode( $response );
    exit;
  }

  public static function user_edit()
  {
    return \admin\view\Users::user_edit(
              \admin\factory\Users::user_details(
                \S::get( 'id' )
              )
            );
  }

  public static function view_list()
  {
    return \admin\view\Users::users_list();
  }
}
?>
