mirror of
https://github.com/mclueppers/xo-server.git
synced 2025-04-08 20:55:02 +02:00
Various updates.
This commit is contained in:
parent
1209143de7
commit
0ab5c33ddf
8
composer.lock
generated
8
composer.lock
generated
@ -188,12 +188,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/vatesfr/rekodi.git",
|
||||
"reference": "608abef5d01a09c5122905a6b99c5197140745a0"
|
||||
"reference": "7a8d126055acfe4e3dbbdf01d50e3143952b8b77"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/vatesfr/rekodi/zipball/608abef5d01a09c5122905a6b99c5197140745a0",
|
||||
"reference": "608abef5d01a09c5122905a6b99c5197140745a0",
|
||||
"url": "https://api.github.com/repos/vatesfr/rekodi/zipball/7a8d126055acfe4e3dbbdf01d50e3143952b8b77",
|
||||
"reference": "7a8d126055acfe4e3dbbdf01d50e3143952b8b77",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -222,7 +222,7 @@
|
||||
"keywords": [
|
||||
"event"
|
||||
],
|
||||
"time": "2013-02-17 16:58:01"
|
||||
"time": "2013-03-03 13:25:27"
|
||||
}
|
||||
],
|
||||
"packages-dev": null,
|
||||
|
47
lib/Bean/User.php
Normal file
47
lib/Bean/User.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
namespace Bean;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class User extends \Rekodi\Bean
|
||||
{
|
||||
/**
|
||||
* This function is not necessary but allow us to dynamically
|
||||
* initialize our bean.
|
||||
*/
|
||||
static function init()
|
||||
{
|
||||
self::$_fields = array_flip(array(
|
||||
'id',
|
||||
'name',
|
||||
'password',
|
||||
));
|
||||
}
|
||||
|
||||
protected static $_fields;
|
||||
}
|
||||
User::init();
|
113
lib/Model/Users.php
Normal file
113
lib/Model/Users.php
Normal file
@ -0,0 +1,113 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is a part of Xen Orchestra Server.
|
||||
*
|
||||
* Xen Orchestra Server is free software: you can redistribute it
|
||||
* and/or modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* Xen Orchestra Server is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Xen Orchestra Server. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* @author Julien Fontanet <julien.fontanet@vates.fr>
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0-standalone.html GPLv3
|
||||
*
|
||||
* @package Xen Orchestra Server
|
||||
*/
|
||||
|
||||
namespace Model;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
final class Users
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function __construct(\Rekodi\Manager $manager)
|
||||
{
|
||||
$this->_manager = $manager;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function delete($id)
|
||||
{
|
||||
$n = $this->_manager->delete(array('id' => $id));
|
||||
|
||||
if ($n !== 1)
|
||||
{
|
||||
trigger_error(
|
||||
'unexpected number of deleted users ('.$n.')',
|
||||
E_USER_ERROR
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id
|
||||
* @param mixed $default
|
||||
*
|
||||
* @return User
|
||||
*/
|
||||
function get($id, $default = 'fatal error')
|
||||
{
|
||||
$users = $this->_manager->get(array('id' => $id));
|
||||
|
||||
if ($users)
|
||||
{
|
||||
return $users[0];
|
||||
}
|
||||
|
||||
if (func_num_args() >= 2)
|
||||
{
|
||||
return $default;
|
||||
}
|
||||
|
||||
trigger_error(
|
||||
'no such user (id = '.$id.')',
|
||||
E_USER_ERROR
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function save(User $user)
|
||||
{
|
||||
if (!isset($user->id))
|
||||
{
|
||||
|
||||
// @todo Fills the user with its generated id.
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$n = $this->_manager->update(
|
||||
$user->getOriginals(),
|
||||
$user->getDirty()
|
||||
);
|
||||
|
||||
if ($n !== 1)
|
||||
{
|
||||
trigger_error(
|
||||
'unexpected number of updated users ('.$n.')',
|
||||
E_USER_ERROR
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @var \Rekodi\Manager
|
||||
*/
|
||||
private $_manager;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user