From 4e65c3bc0bccf6be849cceb185aacd18e337f7f4 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 19 May 2016 17:00:35 +0200 Subject: [usermanagement] Merge changes from 'gitlab.c3sl.ufpr.br/cdn/slx-admin.git' --- inc/pagination.inc.php | 47 +++++++++++++++++++++++++++++++++++++++++++++++ inc/user.inc.php | 15 --------------- 2 files changed, 47 insertions(+), 15 deletions(-) create mode 100644 inc/pagination.inc.php (limited to 'inc') diff --git a/inc/pagination.inc.php b/inc/pagination.inc.php new file mode 100644 index 00000000..65785a36 --- /dev/null +++ b/inc/pagination.inc.php @@ -0,0 +1,47 @@ +items = $par1; + $this->page = $par2; + + $this->maxItems = 5; + } + + public function getPagination() + { + $ret = array(); + $n = ceil(count($this->items) / $this->maxItems); + for ($i = 1; $i <= $n; $i++) { + $class = ($i == $this->page) ? 'active' : ''; + $ret[] = array( + 'class' => $class, + 'page' => $i + ); + } + return $ret; + } + + public function getItems() + { + $ret = array(); + $first = ($this->page - 1) * $this->maxItems; + for ($i = 0; $i < $this->maxItems; $i++) { + if ($first + $i < count($this->items)) + $ret[] = $this->items[$first + $i]; + } + return $ret; + } +} \ No newline at end of file diff --git a/inc/user.inc.php b/inc/user.inc.php index 49500aa2..dc603dac 100644 --- a/inc/user.inc.php +++ b/inc/user.inc.php @@ -97,19 +97,4 @@ class User return self::$user['lasteventid']; } - public static function addUser($data){ - Database::exec ( "INSERT INTO user SET login = :login, passwd = :pass, fullname = :name, phone = :phone, email = :email, permissions = 4", $data ); - $ret = Database::queryFirst('SELECT userid FROM user WHERE login = :user LIMIT 1', array('user' => $data['login'])); - $user = array( - 'user' => $ret['userid'] - ); - Database::exec ( "INSERT INTO setting_partition SET partition_id = '44', size = '5G', mount_point = '/tmp', user = :user", $user ); - Database::exec ( "INSERT INTO setting_partition SET partition_id = '43', size = '20G', mount_point = '/boot', options = 'bootable', user = :user", $user ); - Database::exec ( "INSERT INTO setting_partition SET partition_id = '40', size = '20G', mount_point = '/cache/export/dnbd3', user = :user", $user ); - Database::exec ( "INSERT INTO setting_partition SET partition_id = '41', size = '5G', mount_point = '/home', user = :user", $user ); - Database::exec ( "INSERT INTO setting_partition SET partition_id = '82', size = '1G', user = :user", $user ); - Message::addSuccess('add-user'); - EventLog::info ( User::getName () . ' created user ' . $data['login'] ); - } - } -- cgit v1.2.3-55-g7522