Merge branch 'master' of disposed.de:scattport
This commit is contained in:
@@ -1,45 +1,206 @@
|
||||
<?php defined('BASEPATH') || exit("No direct script access allowed");
|
||||
|
||||
$config = array(
|
||||
'users' => array(
|
||||
array(
|
||||
'field' => 'username',
|
||||
'label' => _('Username'),
|
||||
'rules' => 'trim|required|min_length[4]|max_length[20]|unique[users.username]',
|
||||
),
|
||||
array(
|
||||
'field' => 'password',
|
||||
'label' => _('Password'),
|
||||
'rules' => 'required|min_length[6]|matches[password_confirm]',
|
||||
),
|
||||
array(
|
||||
'field' => 'password_confirm',
|
||||
'label' => _('Confirm password'),
|
||||
),
|
||||
array(
|
||||
'field' => 'firstname',
|
||||
'label' => _('First name'),
|
||||
'rules' => 'trim|required|max_length[50]',
|
||||
),
|
||||
array(
|
||||
'field' => 'lastname',
|
||||
'label' => _('Last name'),
|
||||
'rules' => 'trim|required|max_length[50]',
|
||||
),
|
||||
array(
|
||||
'field' => 'email',
|
||||
'label' => _('Email address'),
|
||||
'rules' => 'trim|required|valid_email',
|
||||
),
|
||||
array(
|
||||
'field' => 'institution',
|
||||
'label' => _('Institution'),
|
||||
'rules' => 'trim|max_length[100]',
|
||||
),
|
||||
array(
|
||||
'field' => 'phone',
|
||||
'label' => _('Phone number'),
|
||||
'rules' => 'trim|regex_match[/^\+\d{2,4}\s\d{2,4}\s\d{3,10}+$/i]',
|
||||
)
|
||||
)
|
||||
);
|
||||
/**
|
||||
* Rules for login page.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
$config['auth/login'] = array(
|
||||
array(
|
||||
'field' => 'username',
|
||||
'label' => _('Username'),
|
||||
'rules' => 'required|trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'password',
|
||||
'label' => _('Password'),
|
||||
'rules' => 'required|trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'remember',
|
||||
'label' => _('Remember me on this computer'),
|
||||
'rules' => 'integer',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Rules for forgotten password page.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
$config['auth/forgot_password'] = array(
|
||||
array(
|
||||
'field' => 'email',
|
||||
'label' => _('Email address'),
|
||||
'rules' => 'required|valid_email|trim',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Rules for the settings page.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
$config['auth/settings'] = array(
|
||||
array(
|
||||
'field' => 'firstname',
|
||||
'label' => _('First name'),
|
||||
'rules' => 'required|max_length[50]|trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'lastname',
|
||||
'label' => _('Last name'),
|
||||
'rules' => 'required|max_length[50]|trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'email',
|
||||
'label' => _('Email address'),
|
||||
'rules' => 'required|valid_email|trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'institution',
|
||||
'label' => _('Institution'),
|
||||
'rules' => 'max_length[100]|trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'phone',
|
||||
'label' => _('Phone number'),
|
||||
'rules' => 'regex_match[/^\+\d{2,4}\s\d{2,4}\s\d{3,10}+$/i]|trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'new_password',
|
||||
'label' => _('New password'),
|
||||
'rules' => 'min_length[6]|matches[new_password_confirm]',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Rules for creating users.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
$config['users/create'] = array(
|
||||
array(
|
||||
'field' => 'username',
|
||||
'label' => _('Username'),
|
||||
'rules' => 'required|min_length[4]|max_length[20]|unique[users.username]|trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'email',
|
||||
'label' => _('Email address'),
|
||||
'rules' => 'required|valid_email|trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'password',
|
||||
'label' => _('Password'),
|
||||
'rules' => 'required|min_length[6]|matches[password_confirm]',
|
||||
),
|
||||
array(
|
||||
'field' => 'password_confirm',
|
||||
'label' => _('Confirm password'),
|
||||
'rules' => 'required',
|
||||
),
|
||||
array(
|
||||
'field' => 'firstname',
|
||||
'label' => _('First name'),
|
||||
'rules' => 'required|max_length[50]|trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'lastname',
|
||||
'label' => _('Last name'),
|
||||
'rules' => 'required|max_length[50]|trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'institution',
|
||||
'label' => _('Institution'),
|
||||
'rules' => 'max_length[100]|trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'phone',
|
||||
'label' => _('Phone number'),
|
||||
'rules' => 'regex_match[/^\+\d{2,4}\s\d{2,4}\s\d{3,10}+$/i]|trim',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Rules for editing users.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
$config['users/edit'] = array(
|
||||
array(
|
||||
'field' => 'firstname',
|
||||
'label' => _('First name'),
|
||||
'rules' => 'required|max_length[50]|trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'lastname',
|
||||
'label' => _('Last name'),
|
||||
'rules' => 'required|max_length[50]|trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'email',
|
||||
'label' => _('Email address'),
|
||||
'rules' => 'required|valid_email|trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'institution',
|
||||
'label' => _('Institution'),
|
||||
'rules' => 'max_length[100]|trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'phone',
|
||||
'label' => _('Phone number'),
|
||||
'rules' => 'regex_match[/^\+\d{2,4}\s\d{2,4}\s\d{3,10}+$/i]|trim',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Rules for editing programs.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
$config['programs/edit'] = array(
|
||||
array(
|
||||
'field' => 'name',
|
||||
'label' => _('Name of the program'),
|
||||
'rules' => 'required|max_length[100]|trim',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Rules for creating parameters.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
$config['parameters/create'] = array(
|
||||
array(
|
||||
'field' => 'name',
|
||||
'label' => _('Name'),
|
||||
'rules' => 'required|max_length[255]|trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'readable',
|
||||
'label' => _('Human-readable name'),
|
||||
'rules' => 'required|max_length[100]|trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'unit',
|
||||
'label' => _('Name'),
|
||||
'rules' => 'max_length[20]|trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'default_value',
|
||||
'label' => _('Default value'),
|
||||
'rules' => 'max_length[255]|trim',
|
||||
),
|
||||
array(
|
||||
'field' => 'type',
|
||||
'label' => _('Type'),
|
||||
'rules' => 'required|max_length[20]|trim',
|
||||
),
|
||||
);
|
||||
|
||||
/* End of file form_validation.php */
|
||||
/* Location: ./application/config/form_validation.php */
|
||||
|
||||
|
||||
133
application/controllers/admin/parameters.php
Normal file
133
application/controllers/admin/parameters.php
Normal file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (c) 2011 Eike Foken <kontakt@eikefoken.de>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
require_once APPPATH . 'core/Admin_Controller.php';
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Eike Foken <kontakt@eikefoken.de>
|
||||
*/
|
||||
class Parameters extends Admin_Controller {
|
||||
|
||||
/**
|
||||
* Calls the parent constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->load->model('parameter');
|
||||
$this->load->model('program');
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows admins to create a new parameter.
|
||||
*
|
||||
* @param string $programId
|
||||
*/
|
||||
public function create($programId = '') {
|
||||
$program = $this->program->getByID($programId);
|
||||
|
||||
if (empty($programId) || !isset($program['id'])) {
|
||||
show_404();
|
||||
}
|
||||
|
||||
if ($this->form_validation->run('parameters/create') === true) {
|
||||
$paramName = $this->input->post('name');
|
||||
|
||||
$data = array(
|
||||
'program_id' => $program['id'],
|
||||
'name' => $paramName,
|
||||
'readable' => $this->input->post('readable'),
|
||||
'unit' => $this->input->post('unit'),
|
||||
'description' => $this->input->post('description'),
|
||||
'type' => $this->input->post('type'),
|
||||
'default_value' => $this->input->post('default_value'),
|
||||
);
|
||||
|
||||
if ($this->parameter->create($data)) {
|
||||
$this->messages->add(sprintf(_("The parameter '%s' has been successfully created."), $paramName), 'success');
|
||||
redirect('admin/programs/edit/' . $program['id'], 303);
|
||||
}
|
||||
}
|
||||
|
||||
$data = array(); // empty the data array
|
||||
$data['types'] = $this->parameter->getTypes();
|
||||
$data['program'] = $program;
|
||||
|
||||
$this->load->view('admin/parameters/create', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows admins to edit a parameter.
|
||||
*
|
||||
* @param string $id
|
||||
*/
|
||||
public function edit($id = '') {
|
||||
$parameter = $this->parameter->getByID($id);
|
||||
|
||||
if (empty($id) || !isset($parameter['id'])){
|
||||
show_404();
|
||||
}
|
||||
|
||||
if ($this->form_validation->run('parameters/create') === true) {
|
||||
$data = array(
|
||||
'name' => $this->input->post('name'),
|
||||
'readable' => $this->input->post('readable'),
|
||||
'unit' => $this->input->post('unit'),
|
||||
'description' => $this->input->post('description'),
|
||||
'type' => $this->input->post('type'),
|
||||
'default_value' => $this->input->post('default_value'),
|
||||
);
|
||||
|
||||
if ($this->parameter->update($data, $id)) {
|
||||
$this->messages->add(sprintf(_("The parameter '%s' has been successfully updated."), $parameter['name']), 'success');
|
||||
redirect('admin/programs/edit/' . $parameter['program_id'], 303);
|
||||
}
|
||||
}
|
||||
|
||||
$data = array(); // empty the data array
|
||||
$data['types'] = $this->parameter->getTypes();
|
||||
$data['parameter'] = $parameter;
|
||||
|
||||
$this->load->view('admin/parameters/edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows admins to delete a parameter.
|
||||
*
|
||||
* @param string $id
|
||||
*/
|
||||
public function delete($id = '') {
|
||||
$parameter = $this->parameter->getByID($id);
|
||||
|
||||
if (empty($id) || !isset($parameter['id'])) {
|
||||
show_404();
|
||||
} else {
|
||||
if ($this->parameter->delete($parameter['id'])) {
|
||||
$this->messages->add(_('The selected parameter has been successfully deleted.'), 'success');
|
||||
}
|
||||
redirect('admin/programs/edit/' . $parameter['program_id'], 303);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* End of file parameters.php */
|
||||
/* Location: ./application/controllers/admin/parameters.php */
|
||||
52
application/controllers/admin/programs.php
Normal file
52
application/controllers/admin/programs.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Eike Foken <kontakt@eikefoken.de>
|
||||
*/
|
||||
class Programs extends CI_Controller {
|
||||
|
||||
/**
|
||||
* Calls the parent constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->load->library('form_validation');
|
||||
$this->load->model('program');
|
||||
$this->load->model('parameter');
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows a list of all available programs.
|
||||
*/
|
||||
public function index() {
|
||||
$data['programs'] = $this->program->getAll();
|
||||
$this->load->view('admin/programs/list', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows admins to edit a program.
|
||||
*
|
||||
* @param string $id
|
||||
*/
|
||||
public function edit($id = '') {
|
||||
$program = $this->program->getByID($id);
|
||||
|
||||
if (!isset($program) || !is_array($program)){
|
||||
show_404();
|
||||
}
|
||||
|
||||
if ($this->form_validation->run('programs/edit') === true) {
|
||||
if ($this->program->update($this->input->post('name'), $id)) {
|
||||
$this->messages->add(sprintf(_("The program '%s' has been updated successfully"), $this->input->post('name')), 'success');
|
||||
redirect('admin/programs', 303);
|
||||
}
|
||||
}
|
||||
|
||||
$data['program'] = $program;
|
||||
$data['parameters'] = $this->parameter->getAll($program['id']);
|
||||
|
||||
$this->load->view('admin/programs/edit', $data);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,56 +22,13 @@ class Users extends CI_Controller {
|
||||
*/
|
||||
public function index() {
|
||||
$data['users'] = $this->user->getAll();
|
||||
$this->load->view('admin/users/index', $data);
|
||||
$this->load->view('admin/users/list', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows admins to create a new user.
|
||||
*/
|
||||
public function create() {
|
||||
$config = array(
|
||||
array(
|
||||
'field' => 'username',
|
||||
'label' => _('Username'),
|
||||
'rules' => 'trim|required|min_length[4]|max_length[20]|unique[users.username]',
|
||||
),
|
||||
array(
|
||||
'field' => 'password',
|
||||
'label' => _('Password'),
|
||||
'rules' => 'required|min_length[6]|matches[password_confirm]',
|
||||
),
|
||||
array(
|
||||
'field' => 'password_confirm',
|
||||
'label' => _('Confirm password'),
|
||||
),
|
||||
array(
|
||||
'field' => 'firstname',
|
||||
'label' => _('First name'),
|
||||
'rules' => 'trim|required|max_length[50]',
|
||||
),
|
||||
array(
|
||||
'field' => 'lastname',
|
||||
'label' => _('Last name'),
|
||||
'rules' => 'trim|required|max_length[50]',
|
||||
),
|
||||
array(
|
||||
'field' => 'email',
|
||||
'label' => _('Email address'),
|
||||
'rules' => 'trim|required|valid_email',
|
||||
),
|
||||
array(
|
||||
'field' => 'institution',
|
||||
'label' => _('Institution'),
|
||||
'rules' => 'trim|max_length[100]',
|
||||
),
|
||||
array(
|
||||
'field' => 'phone',
|
||||
'label' => _('Phone number'),
|
||||
'rules' => 'trim|regex_match[/^\+\d{2,4}\s\d{2,4}\s\d{3,10}+$/i]',
|
||||
)
|
||||
);
|
||||
$this->form_validation->set_rules($config);
|
||||
|
||||
if ($this->form_validation->run() === true) {
|
||||
$username = $this->input->post('username');
|
||||
|
||||
@@ -83,7 +40,7 @@ class Users extends CI_Controller {
|
||||
);
|
||||
|
||||
if ($this->user->register($username, $this->input->post('password'), $this->input->post('email'), $data)) {
|
||||
$this->messages->add(sprintf(_("The user '%s' was created"), $username), 'success');
|
||||
$this->messages->add(sprintf(_("The user '%s' has been created successfully"), $username), 'success');
|
||||
redirect('admin/users', 303);
|
||||
}
|
||||
}
|
||||
@@ -103,36 +60,7 @@ class Users extends CI_Controller {
|
||||
show_404();
|
||||
}
|
||||
|
||||
$config = array(
|
||||
array(
|
||||
'field' => 'firstname',
|
||||
'label' => _('First name'),
|
||||
'rules' => 'trim|required|max_length[50]',
|
||||
),
|
||||
array(
|
||||
'field' => 'lastname',
|
||||
'label' => _('Last name'),
|
||||
'rules' => 'trim|required|max_length[50]',
|
||||
),
|
||||
array(
|
||||
'field' => 'email',
|
||||
'label' => _('Email address'),
|
||||
'rules' => 'trim|required|valid_email',
|
||||
),
|
||||
array(
|
||||
'field' => 'institution',
|
||||
'label' => _('Institution'),
|
||||
'rules' => 'trim|max_length[100]',
|
||||
),
|
||||
array(
|
||||
'field' => 'phone',
|
||||
'label' => _('Phone number'),
|
||||
'rules' => 'trim|regex_match[/^\+\d{2,4}\s\d{2,4}\s\d{3,10}+$/i]',
|
||||
)
|
||||
);
|
||||
$this->form_validation->set_rules($config);
|
||||
|
||||
if ($this->form_validation->run() === true) {
|
||||
if ($this->form_validation->run('users/edit') === true) {
|
||||
$data = array(
|
||||
'email' => $this->input->post('email'),
|
||||
'firstname' => $this->input->post('firstname'),
|
||||
@@ -142,7 +70,7 @@ class Users extends CI_Controller {
|
||||
);
|
||||
|
||||
if ($this->user->update($user['id'], $data)) {
|
||||
$this->messages->add(sprintf(_("The user '%s' was updated"), $user['username']), 'success');
|
||||
$this->messages->add(sprintf(_("The user '%s' has been updated successfully"), $user['username']), 'success');
|
||||
redirect('admin/users', 303);
|
||||
}
|
||||
}
|
||||
@@ -162,7 +90,7 @@ class Users extends CI_Controller {
|
||||
show_404();
|
||||
} else {
|
||||
$this->user->delete($user['id']);
|
||||
$this->messages->add(_("The selected user was deleted"), 'success');
|
||||
$this->messages->add(_("The selected user has been deleted successfully"), 'success');
|
||||
redirect('admin/users', 303);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,4 +55,13 @@ class Ajax extends CI_Controller {
|
||||
$data['description'] = $this->input->post('content');
|
||||
$this->project->update($this->session->userdata('active_project'), $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts a programs parameters.
|
||||
*/
|
||||
public function sort_parameters() {
|
||||
$this->load->model('parameter');
|
||||
$this->parameter->sort($this->input->post('parameters'));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -33,30 +33,23 @@ class Auth extends CI_Controller {
|
||||
*/
|
||||
public function login() {
|
||||
if ($this->access->loggedIn()) {
|
||||
redirect();
|
||||
redirect('dashboard');
|
||||
}
|
||||
|
||||
// validate form input
|
||||
$this->form_validation->set_rules('username', _('Username'), 'required');
|
||||
$this->form_validation->set_rules('password', _('Password'), 'required');
|
||||
$data['messages'] = $this->messages->get('success');
|
||||
|
||||
if ($this->form_validation->run() == true) {
|
||||
if ($this->form_validation->run() === true) {
|
||||
// check for "remember me"
|
||||
$remember = (boolean) $this->input->post('remember');
|
||||
|
||||
if ($this->access->login($this->input->post('username'), $this->input->post('password'), $remember)) {
|
||||
$this->data['success'] = true;
|
||||
redirect('dashboard', 'refresh');
|
||||
redirect('dashboard', 303);
|
||||
} else { // if the login was un-successful
|
||||
$this->data['success'] = false;
|
||||
$this->data['message'] = $this->access->errors();
|
||||
$data['errors'] = $this->messages->get('error');
|
||||
}
|
||||
} else {
|
||||
$this->data['message'] = validation_errors() ? validation_errors() : null;
|
||||
$this->data['username'] = $this->form_validation->set_value('username');
|
||||
|
||||
$this->load->view('auth/login', $this->data);
|
||||
}
|
||||
|
||||
$this->load->view('auth/login', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,8 +57,7 @@ class Auth extends CI_Controller {
|
||||
*/
|
||||
public function logout() {
|
||||
$logout = $this->access->logout();
|
||||
|
||||
redirect(base_url(), 'refresh');
|
||||
redirect('auth/login');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,85 +106,66 @@ class Auth extends CI_Controller {
|
||||
* Allows users to edit their settings.
|
||||
*/
|
||||
public function settings() {
|
||||
if (!$this->access->loggedIn()) {
|
||||
redirect('auth/login', 'refresh');
|
||||
}
|
||||
$user = $this->access->getCurrentUser();
|
||||
|
||||
// validate the form
|
||||
$this->form_validation->set_rules('new_password', _('New password'), 'min_length[' . $this->config->item('min_password_length', 'auth') . ']|max_length[' . $this->config->item('max_password_length', 'access') . ']|matches[new_password_confirm]');
|
||||
|
||||
if ($this->form_validation->run() == true) {
|
||||
if ($this->form_validation->run() === true) {
|
||||
// change password if needed
|
||||
if ($this->input->post('new_password') != '') {
|
||||
$username = $this->session->userdata('username');
|
||||
$change = $this->access->changePassword($username, $this->input->post('old_password'), $this->input->post('new_password'));
|
||||
|
||||
if ($change) {
|
||||
$this->logout();
|
||||
}
|
||||
// if ($change) {
|
||||
// $this->logout();
|
||||
// }
|
||||
}
|
||||
|
||||
// update user
|
||||
$updateData = array(
|
||||
'firstname' => $this->input->post('firstname'),
|
||||
'lastname' => $this->input->post('lastname'),
|
||||
'institution' => $this->input->post('institution'),
|
||||
'phone' => $this->input->post('phone'),
|
||||
'email' => $this->input->post('email'),
|
||||
// update users table
|
||||
$data = array(
|
||||
'email' => $this->input->post('email'),
|
||||
'firstname' => $this->input->post('firstname'),
|
||||
'lastname' => $this->input->post('lastname'),
|
||||
'institution' => $this->input->post('institution'),
|
||||
'phone' => $this->input->post('phone')
|
||||
);
|
||||
$this->access->updateUser($this->session->userdata('user_id'), $updateData);
|
||||
|
||||
// output JSON data
|
||||
$this->output->set_content_type('application/json')
|
||||
->set_output(json_encode(array('success' => true)));
|
||||
} else {
|
||||
$data['success'] = true;
|
||||
$data['data'] = $this->access->getCurrentUser();
|
||||
|
||||
// output JSON data
|
||||
$this->output->set_content_type('application/json')
|
||||
->set_output(json_encode($data));
|
||||
if ($this->user->update($user['id'], $data)) {
|
||||
$this->messages->add(_("Settings saved successfully"), 'success');
|
||||
redirect('auth/settings', 303);
|
||||
}
|
||||
}
|
||||
|
||||
$this->load->view('auth/settings', $user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows users to request a new password.
|
||||
*/
|
||||
public function forgot_password() {
|
||||
$this->form_validation->set_rules('email', _('eMail address'), 'required');
|
||||
if ($this->form_validation->run() == false) {
|
||||
//setup the input
|
||||
$this->data['email'] = array('name' => 'email',
|
||||
'id' => 'email',
|
||||
);
|
||||
//set any errors and display the form
|
||||
$this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
|
||||
$this->load->view('auth/forgot_password', $this->data);
|
||||
} else {
|
||||
//run the forgotten password method to email an activation code to the user
|
||||
$forgotten = $this->access->forgotten_password($this->input->post('email'));
|
||||
if ($this->form_validation->run() === true) {
|
||||
// run the forgotten password method to email an activation code to the user
|
||||
$forgotten = $this->access->forgottenPassword($this->input->post('email'));
|
||||
|
||||
if ($forgotten) { //if there were no errors
|
||||
$this->session->set_flashdata('message', $this->access->messages());
|
||||
redirect("auth/login", 'refresh'); //we should display a confirmation page here instead of the login page
|
||||
if ($forgotten) { // if there were no errors
|
||||
redirect('auth/login'); // TODO Display a confirmation page here instead of the login page
|
||||
} else {
|
||||
$this->session->set_flashdata('message', $this->access->errors());
|
||||
redirect("auth/forgot_password", 'refresh');
|
||||
redirect('auth/forgot_password');
|
||||
}
|
||||
}
|
||||
|
||||
$data['messages'] = $this->messages->get('success');
|
||||
$data['errors'] = $this->messages->get('error');
|
||||
|
||||
$this->load->view('auth/forgot_password', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Final step for forgotten password.
|
||||
*/
|
||||
public function reset_password($code) {
|
||||
$reset = $this->access->forgotten_password_complete($code);
|
||||
$reset = $this->access->forgottenPasswordComplete($code);
|
||||
|
||||
if ($reset) { //if the reset worked then send them to the login page
|
||||
$this->session->set_flashdata('message', $this->access->messages());
|
||||
if ($reset) { // if the reset worked then send them to the login page
|
||||
redirect('auth/login');
|
||||
} else { //if the reset didnt work then send them back to the forgot password page
|
||||
$this->session->set_flashdata('message', $this->access->errors());
|
||||
} else { // if the reset didn't work then send them back to the forgot password page
|
||||
redirect('auth/forgot_password');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011 Karsten Heiken <karsten@disposed.de>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @author Karsten Heiken <karsten@disposed.de>
|
||||
*/
|
||||
class Settings extends CI_Controller {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->load->model('program');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a list of all available programs.
|
||||
*/
|
||||
public function index() {
|
||||
$profile = $this->user->profile();
|
||||
$profile_fields = array(
|
||||
array('firstname', _('First name'), 'text'),
|
||||
array('lastname', _('Last name'), 'text'),
|
||||
array('intitution', _('Institution'), 'text'),
|
||||
);
|
||||
$tpl['profile'] = $profile;
|
||||
$tpl['profile_fields'] = $profile_fields;
|
||||
$this->load->view('user/settings', $tpl);
|
||||
}
|
||||
}
|
||||
44
application/core/Admin_Controller.php
Normal file
44
application/core/Admin_Controller.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php defined('BASEPATH') || exit('No direct script access allowed');
|
||||
/*
|
||||
* Copyright (c) 2011 Eike Foken <kontakt@eikefoken.de>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Simple controller for admin pages.
|
||||
*
|
||||
* @author Eike Foken <kontakt@eikefoken.de>
|
||||
*/
|
||||
class Admin_Controller extends CI_Controller {
|
||||
|
||||
/**
|
||||
* Calls the parent constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
|
||||
if (!$this->access->isAdmin()) {
|
||||
show_error(_('Shove off, this is for admins.'), 403);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* End of file Admin_Controller.php */
|
||||
/* Location: ./application/core/Admin_Controller.php */
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php defined('BASEPATH') || exit("No direct script access allowed");
|
||||
|
||||
/**
|
||||
* Extends CI's controller class.
|
||||
*
|
||||
* @author Eike Foken <kontakt@eikefoken.de>
|
||||
*/
|
||||
class MY_Controller extends CI_Controller {
|
||||
|
||||
/**
|
||||
* Calls the parent constructor and loads the relevant language file.
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
|
||||
// load relevant language file
|
||||
$this->lang->load(strtolower($this->router->class));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011 Karsten Heiken <karsten@disposed.de>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Headings
|
||||
*/
|
||||
$lang['location'] = 'Location';
|
||||
$lang['owner'] = 'Owner';
|
||||
$lang['actions'] = 'Actions';
|
||||
$lang['technical_info'] = 'Technical information';
|
||||
$lang['hardware_os'] = 'Hardware & OS';
|
||||
$lang['scattport_stats'] = 'ScattPort statistics';
|
||||
|
||||
/*
|
||||
* server status
|
||||
*/
|
||||
$lang['busy'] = 'busy';
|
||||
$lang['offline'] = 'offline';
|
||||
$lang['available'] = 'available';
|
||||
|
||||
$lang['workload'] = 'Workload';
|
||||
$lang['completed_jobs'] = 'Completed jobs';
|
||||
@@ -1,74 +0,0 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2011-08-10 21:25+0200\n"
|
||||
"PO-Revision-Date: 2011-08-10 22:00+0200\n"
|
||||
"Last-Translator: Karsten Heiken <karsten@disposed.de>\n"
|
||||
"Language-Team: German <>\n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n!=1);\n"
|
||||
|
||||
msgid "Users"
|
||||
msgstr "Benutzer"
|
||||
|
||||
msgid "Available users"
|
||||
msgstr "Alle verfügbaren Benutzer"
|
||||
|
||||
msgid "Username"
|
||||
msgstr "Benutzername"
|
||||
|
||||
msgid "Full name"
|
||||
msgstr "Vollständiger Name"
|
||||
|
||||
msgid "Actions"
|
||||
msgstr "Aktionen"
|
||||
|
||||
msgid "Edit"
|
||||
msgstr "Bearbeiten"
|
||||
|
||||
msgid "Delete"
|
||||
msgstr "Löschen"
|
||||
|
||||
msgid "Create new user"
|
||||
msgstr "Neuen Benutzer erstellen"
|
||||
|
||||
msgid "Edit user '%s'"
|
||||
msgstr "Benutzer »%s« bearbeiten"
|
||||
|
||||
msgid "Required information"
|
||||
msgstr "Erforderliche Angaben"
|
||||
|
||||
msgid "Optional information"
|
||||
msgstr "Optionale Angaben"
|
||||
|
||||
msgid "Email address"
|
||||
msgstr "E-Mail-Adresse"
|
||||
|
||||
msgid "First name"
|
||||
msgstr "Vorname"
|
||||
|
||||
msgid "Last name"
|
||||
msgstr "Nachname"
|
||||
|
||||
msgid "Institution"
|
||||
msgstr "Institution"
|
||||
|
||||
msgid "Phone number"
|
||||
msgstr "Telefonnummer"
|
||||
|
||||
msgid "Language"
|
||||
msgstr "Sprache"
|
||||
|
||||
msgid "Example"
|
||||
msgstr "Beispiel"
|
||||
|
||||
msgid "Save"
|
||||
msgstr "Speichern"
|
||||
|
||||
msgid "Cancel"
|
||||
msgstr "Abbrechen"
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2011-08-10 21:25+0200\n"
|
||||
"PO-Revision-Date: 2011-08-10 22:00+0200\n"
|
||||
"Last-Translator: Karsten Heiken <karsten@disposed.de>\n"
|
||||
"Language-Team: English <>\n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n!=1);\n"
|
||||
|
||||
msgid "users"
|
||||
msgstr "Users"
|
||||
|
||||
msgid "available_users"
|
||||
msgstr "Available users"
|
||||
|
||||
msgid "username"
|
||||
msgstr "Username"
|
||||
|
||||
msgid "realname"
|
||||
msgstr "Name"
|
||||
|
||||
msgid "options"
|
||||
msgstr "Options"
|
||||
|
||||
msgid "user_edit"
|
||||
msgstr "Edit"
|
||||
|
||||
msgid "user_create"
|
||||
msgstr "Create new user"
|
||||
|
||||
msgid "user_delete"
|
||||
msgstr "Delete"
|
||||
|
||||
msgid "create_user"
|
||||
msgstr "Create a new user"
|
||||
|
||||
msgid "edit_user"
|
||||
msgstr "Edit user"
|
||||
|
||||
msgid "field_username"
|
||||
msgstr "Username"
|
||||
|
||||
msgid "field_password"
|
||||
msgstr "Password"
|
||||
|
||||
msgid "field_password_confirm"
|
||||
msgstr "Confirm password"
|
||||
|
||||
msgid "field_firstname"
|
||||
msgstr "First name"
|
||||
|
||||
msgid "field_lastname"
|
||||
msgstr "Last name"
|
||||
|
||||
msgid "field_email"
|
||||
msgstr "Email address"
|
||||
|
||||
msgid "field_institution"
|
||||
msgstr "Institution"
|
||||
|
||||
msgid "field_phone"
|
||||
msgstr "Phone number"
|
||||
@@ -7,279 +7,240 @@
|
||||
*/
|
||||
class Access {
|
||||
|
||||
/**
|
||||
* Contains the CI instance.
|
||||
*/
|
||||
protected $ci;
|
||||
/**
|
||||
* Contains the CI instance.
|
||||
*/
|
||||
protected $ci;
|
||||
|
||||
/**
|
||||
* Contains occured messages (using the language file).
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $messages = array();
|
||||
/**
|
||||
* Contains occured messages (using the language file).
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $messages = array();
|
||||
|
||||
/**
|
||||
* Contains occured errors (using the language file).
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $errors = array();
|
||||
/**
|
||||
* Contains occured errors (using the language file).
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $errors = array();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->ci =& get_instance();
|
||||
$this->ci->load->config('auth', true);
|
||||
$this->ci->load->library('email');
|
||||
$this->ci->lang->load('auth');
|
||||
$this->ci->load->model('user');
|
||||
$this->ci->load->model('group');
|
||||
$this->ci->load->helper('cookie');
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->ci =& get_instance();
|
||||
$this->ci->load->config('auth', true);
|
||||
$this->ci->load->library('email');
|
||||
$this->ci->lang->load('auth');
|
||||
$this->ci->load->model('user');
|
||||
$this->ci->load->model('group');
|
||||
$this->ci->load->helper('cookie');
|
||||
|
||||
// auto-login the user if they are remembered
|
||||
if (!$this->loggedIn() && get_cookie('username') && get_cookie('remember_code')) {
|
||||
$this->ci->access = $this;
|
||||
$this->ci->user->loginRememberedUser();
|
||||
}
|
||||
}
|
||||
// auto-login the user if they are remembered
|
||||
if (!$this->loggedIn() && get_cookie('username') && get_cookie('remember_code')) {
|
||||
$this->ci->access = $this;
|
||||
$this->ci->user->loginRememberedUser();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes a users password.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function changePassword($username, $old, $new) {
|
||||
if ($this->ci->user->changePassword($username, $old, $new)) {
|
||||
$this->setMessage(_('Password successfully changed'));
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Changes a users password.
|
||||
*
|
||||
* @param string $username
|
||||
* @param string $old
|
||||
* @param string $new
|
||||
* @return boolean
|
||||
*/
|
||||
public function changePassword($username, $old, $new) {
|
||||
if ($this->ci->user->changePassword($username, $old, $new)) {
|
||||
$this->ci->messages->add(_('Password successfully changed'), 'success');
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->setError(_('Unable to change password'));
|
||||
return false;
|
||||
}
|
||||
$this->ci->messages->add(_('Unable to change password'), 'error');
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* forgotten password feature
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function forgottenPassword($username) {
|
||||
if ($this->ci->user->forgottenPassword($username)) {
|
||||
// get user information
|
||||
$user = $this->getUserByUsername($username);
|
||||
/**
|
||||
* forgotten password feature
|
||||
*
|
||||
* @param string $email
|
||||
* @return void
|
||||
*/
|
||||
public function forgottenPassword($email) {
|
||||
if ($this->ci->user->forgottenPassword($email)) {
|
||||
// get user information
|
||||
$user = $this->ci->user->getUserByEmail($email);
|
||||
|
||||
$data = array(
|
||||
$data = array(
|
||||
'username' => $user['username'],
|
||||
'forgotten_password_code' => $user['forgotten_password_code']
|
||||
);
|
||||
'forgotten_password_code' => $user['forgotten_password_code'],
|
||||
);
|
||||
|
||||
$message = $this->ci->load->view($this->ci->config->item('email_templates', 'auth') . $this->ci->config->item('email_forgot_password', 'auth'), $data, true);
|
||||
$this->ci->email->clear();
|
||||
$config['mailtype'] = $this->ci->config->item('email_type', 'auth');
|
||||
$this->ci->email->initialize($config);
|
||||
$this->ci->email->set_newline("\r\n");
|
||||
$this->ci->email->from($this->ci->config->item('admin_email', 'auth'), 'Scattport');
|
||||
$this->ci->email->to($user['email']);
|
||||
$this->ci->email->subject('Scattport - Forgotten Password Verification');
|
||||
$this->ci->email->message($message);
|
||||
$message = $this->ci->load->view('auth/email/forgot_password', $data, true);
|
||||
$this->ci->email->clear();
|
||||
$config['mailtype'] = $this->ci->config->item('email_type', 'auth');
|
||||
$this->ci->email->initialize($config);
|
||||
$this->ci->email->set_newline("\r\n");
|
||||
$this->ci->email->from($this->ci->config->item('admin_email', 'auth'), 'Scattport');
|
||||
$this->ci->email->to($user['email']);
|
||||
$this->ci->email->subject('ScattPort - Forgotten Password Verification');
|
||||
$this->ci->email->message($message);
|
||||
|
||||
if ($this->ci->email->send()) {
|
||||
$this->setMessage(_('Password reset email sent'));
|
||||
return true;
|
||||
} else {
|
||||
$this->setError(_('Unable to reset password'));
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
$this->setError(_('Unable to reset password'));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ($this->ci->email->send()) {
|
||||
$this->ci->messages->add(_('Password reset email sent'), 'success');
|
||||
return true;
|
||||
} else {
|
||||
$this->ci->messages->add(_('Unable to send password reset email'), 'error');
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
$this->ci->messages->add(_('This email address is not registered'), 'error');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* forgotten_password_complete
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function forgottenPasswordComplete($code) {
|
||||
$profile = $this->ci->user->profile($code, true); // pass the code to profile
|
||||
/**
|
||||
* forgotten_password_complete
|
||||
*
|
||||
* @param string $code
|
||||
* @return void
|
||||
*/
|
||||
public function forgottenPasswordComplete($code) {
|
||||
$profile = $this->ci->user->profile($code, true); // pass the code to profile
|
||||
|
||||
if (!is_object($profile)) {
|
||||
$this->setError(_('Unable to change password'));
|
||||
return false;
|
||||
}
|
||||
if (!is_object($profile)) {
|
||||
$this->ci->messages->add(_('Unable to change password'), 'error');
|
||||
return false;
|
||||
}
|
||||
|
||||
$new_password = $this->ci->user->forgottenPasswordComplete($code, $profile->salt);
|
||||
$new_password = $this->ci->user->forgottenPasswordComplete($code, $profile->salt);
|
||||
|
||||
if ($new_password) {
|
||||
$data = array(
|
||||
if ($new_password) {
|
||||
$data = array(
|
||||
'username' => $profile->username,
|
||||
'new_password' => $new_password
|
||||
);
|
||||
);
|
||||
|
||||
$message = $this->ci->load->view($this->ci->config->item('email_templates', 'ion_auth').$this->ci->config->item('email_forgot_password_complete', 'ion_auth'), $data, true);
|
||||
$message = $this->ci->load->view('auth/email/forgot_password_complete', $data, true);
|
||||
|
||||
$this->ci->email->clear();
|
||||
$config['mailtype'] = $this->ci->config->item('email_type', 'ion_auth');
|
||||
$this->ci->email->initialize($config);
|
||||
$this->ci->email->set_newline("\r\n");
|
||||
$this->ci->email->from($this->ci->config->item('admin_email', 'ion_auth'), $this->ci->config->item('site_title', 'ion_auth'));
|
||||
$this->ci->email->to($profile->email);
|
||||
$this->ci->email->subject($this->ci->config->item('site_title', 'ion_auth') . ' - New Password');
|
||||
$this->ci->email->message($message);
|
||||
$this->ci->email->clear();
|
||||
$config['mailtype'] = $this->ci->config->item('email_type', 'auth');
|
||||
$this->ci->email->initialize($config);
|
||||
$this->ci->email->set_newline("\r\n");
|
||||
$this->ci->email->from($this->ci->config->item('admin_email', 'auth'), $this->ci->config->item('site_title', 'auth'));
|
||||
$this->ci->email->to($profile->email);
|
||||
$this->ci->email->subject('ScattPort - New Password');
|
||||
$this->ci->email->message($message);
|
||||
|
||||
if ($this->ci->email->send()) {
|
||||
$this->setMessage(_('Password successfully changed'));
|
||||
return true;
|
||||
} else {
|
||||
$this->setError(_('Unable to change password'));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ($this->ci->email->send()) {
|
||||
$this->ci->messages->add(_('Password successfully changed'), 'success');
|
||||
return true;
|
||||
} else {
|
||||
$this->ci->messages->add(_('Unable to change password'), 'error');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$this->setError(_('Unable to change password'));
|
||||
return false;
|
||||
}
|
||||
$this->ci->messages->add(_('Unable to change password'), 'error');
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs the user in.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function login($username, $password, $remember = false) {
|
||||
if ($this->ci->user->login($username, $password, $remember)) {
|
||||
$this->setMessage(_('Logged in successfully'));
|
||||
return true;
|
||||
} else {
|
||||
$this->setError(_('Incorrect username or password'));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Logs the user in.
|
||||
*
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @param boolean $remember
|
||||
* @return boolean
|
||||
*/
|
||||
public function login($username, $password, $remember = false) {
|
||||
if ($this->ci->user->login($username, $password, $remember)) {
|
||||
$this->ci->messages->add(_('Logged in successfully'), 'success');
|
||||
return true;
|
||||
} else {
|
||||
$this->ci->messages->add(_('Incorrect username or password'), 'error');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs the user out.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function logout() {
|
||||
$this->ci->session->unset_userdata('username');
|
||||
$this->ci->session->unset_userdata('group');
|
||||
$this->ci->session->unset_userdata('user_id');
|
||||
/**
|
||||
* Logs the user out.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function logout() {
|
||||
$this->ci->session->unset_userdata('username');
|
||||
$this->ci->session->unset_userdata('group');
|
||||
$this->ci->session->unset_userdata('user_id');
|
||||
|
||||
// delete the remember cookies if they exist
|
||||
if (get_cookie('username')) {
|
||||
delete_cookie('username');
|
||||
} if (get_cookie('remember_code')) {
|
||||
delete_cookie('remember_code');
|
||||
}
|
||||
// delete the remember cookies if they exist
|
||||
if (get_cookie('username')) {
|
||||
delete_cookie('username');
|
||||
} if (get_cookie('remember_code')) {
|
||||
delete_cookie('remember_code');
|
||||
}
|
||||
|
||||
$this->ci->session->sess_destroy();
|
||||
$this->ci->session->sess_destroy();
|
||||
|
||||
$this->setMessage(_('Logged out successfully'));
|
||||
return true;
|
||||
}
|
||||
$this->ci->messages->add(_('Logged out successfully'), 'success');
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the user is logged in.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function loggedIn() {
|
||||
return (boolean) $this->ci->session->userdata('username');
|
||||
}
|
||||
/**
|
||||
* Checks if the user is logged in.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function loggedIn() {
|
||||
return (boolean) $this->ci->session->userdata('username');
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the user is an admin.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isAdmin() {
|
||||
$adminGroup = 'admins';
|
||||
$userGroup = $this->ci->session->userdata('group');
|
||||
return $userGroup == $adminGroup;
|
||||
}
|
||||
/**
|
||||
* Checks if the user is an admin.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isAdmin() {
|
||||
$adminGroup = 'admins';
|
||||
$userGroup = $this->ci->session->userdata('group');
|
||||
return $userGroup == $adminGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the current user is assigned to the specified group.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isGroup($checkGroup) {
|
||||
$userGroup = $this->ci->session->userdata('group');
|
||||
/**
|
||||
* Checks if the current user is assigned to the specified group.
|
||||
*
|
||||
* @param string $checkGroup
|
||||
* @return boolean
|
||||
*/
|
||||
public function isGroup($checkGroup) {
|
||||
$userGroup = $this->ci->session->userdata('group');
|
||||
|
||||
if (is_array($checkGroup)) {
|
||||
return in_array($userGroup, $checkGroup);
|
||||
}
|
||||
return $userGroup == $checkGroup;
|
||||
}
|
||||
if (is_array($checkGroup)) {
|
||||
return in_array($userGroup, $checkGroup);
|
||||
}
|
||||
return $userGroup == $checkGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current logged in user.
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function getCurrentUser() {
|
||||
return $this->ci->user->getUserByID($this->ci->session->userdata('user_id'));
|
||||
}
|
||||
/**
|
||||
* Gets the current logged in user.
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
public function getCurrentUser() {
|
||||
return $this->ci->user->getUserByID($this->ci->session->userdata('user_id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the profile of the current user.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function profile() {
|
||||
return $this->ci->user->profile($this->ci->session->userdata('username'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a message.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function setMessage($message) {
|
||||
$this->messages[] = $message;
|
||||
return $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all messages.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function messages() {
|
||||
$output = '';
|
||||
foreach ($this->messages as $message) {
|
||||
$output .= $message . '<br />';
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an error message.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setError($error) {
|
||||
$this->errors[] = $error;
|
||||
return $error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all error messages.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function errors() {
|
||||
$output = '';
|
||||
foreach ($this->errors as $error) {
|
||||
$output .= $error . '<br />';
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
/**
|
||||
* Gets the profile of the current user.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function profile() {
|
||||
return $this->ci->user->profile($this->ci->session->userdata('username'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,44 @@ class MY_Session extends CI_Session {
|
||||
return sha1(uniqid(microtime() . $this->CI->input->ip_address(), true));
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the session data.
|
||||
*
|
||||
* @see CI_Session::sess_write()
|
||||
*/
|
||||
public function sess_write() {
|
||||
// are we saving custom data to the DB? If not, all we do is update the cookie
|
||||
if ($this->sess_use_database === false) {
|
||||
$this->_set_cookie();
|
||||
return;
|
||||
}
|
||||
|
||||
// set the custom userdata, the session data we will set in a second
|
||||
$customUserdata = $this->userdata;
|
||||
$cookieUserdata = array();
|
||||
|
||||
// before continuing, we need to determine if there is any custom data to deal with.
|
||||
foreach (array('session_id', 'user_id', 'ip_address', 'user_agent', 'last_activity') as $val) {
|
||||
unset($customUserdata[$val]);
|
||||
$cookieUserdata[$val] = $this->userdata[$val];
|
||||
}
|
||||
|
||||
// did we find any custom data? If not, we turn the empty array into a string
|
||||
if (count($customUserdata) === 0) {
|
||||
$customUserdata = '';
|
||||
} else {
|
||||
// serialize the custom data array so we can store it
|
||||
$customUserdata = $this->_serialize($customUserdata);
|
||||
}
|
||||
|
||||
// run the update query
|
||||
$this->CI->db->where('session_id', $this->userdata['session_id']);
|
||||
$this->CI->db->update($this->sess_table_name, array('last_activity' => $this->userdata['last_activity'], 'user_id' => $this->userdata['user_id'], 'user_data' => $customUserdata));
|
||||
|
||||
// write the cookie.
|
||||
$this->_set_cookie($cookieUserdata);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new session.
|
||||
*
|
||||
@@ -33,7 +71,8 @@ class MY_Session extends CI_Session {
|
||||
'session_id' => $this->generateHash(),
|
||||
'ip_address' => $this->CI->input->ip_address(),
|
||||
'user_agent' => substr($this->CI->input->user_agent(), 0, 50),
|
||||
'last_activity' => $this->now
|
||||
'last_activity' => $this->now,
|
||||
'user_id' => null,
|
||||
);
|
||||
|
||||
// save data to the DB if needed
|
||||
@@ -61,6 +100,7 @@ class MY_Session extends CI_Session {
|
||||
|
||||
$this->userdata['session_id'] = $newSessionID;
|
||||
$this->userdata['last_activity'] = $this->now;
|
||||
$this->userdata['user_id'] = array_key_exists('user_id', $this->userdata) ? $this->userdata['user_id'] : null;
|
||||
|
||||
$cookieData = null;
|
||||
|
||||
@@ -75,7 +115,7 @@ class MY_Session extends CI_Session {
|
||||
$this->CI->db->update($this->sess_table_name, array('last_activity' => $this->now, 'user_id' => $this->userdata['user_id'], 'session_id' => $newSessionID), array('session_id' => $oldSessionID));
|
||||
|
||||
// update users table if user is logged in
|
||||
if (array_key_exists('user_id', $this->userdata) && $this->userdata['user_id'] > 0) {
|
||||
if (array_key_exists('user_id', $this->userdata) && !is_null($this->userdata['user_id'])) {
|
||||
$this->CI->db->update('users', array('last_activity' => $this->now), array('id' => $this->userdata['user_id']));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,41 +8,40 @@
|
||||
class Group extends CI_Model {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* Calls the parent constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* get
|
||||
* Gets all groups.
|
||||
*
|
||||
* @return object
|
||||
* @return array
|
||||
*/
|
||||
public function get() {
|
||||
return $this->db->get('groups')->result_array();
|
||||
}
|
||||
|
||||
/**
|
||||
* getGroupByID
|
||||
* Gets a specific group.
|
||||
*
|
||||
* @return object
|
||||
* @param string $id
|
||||
* @return array
|
||||
*/
|
||||
public function getGroupByID($id) {
|
||||
$this->db->where('id', $id);
|
||||
return $this->db->get('groups')->row_array();
|
||||
public function getByID($id) {
|
||||
return $this->db->get_where('groups', array('id' => $id))->row_array();
|
||||
}
|
||||
|
||||
/**
|
||||
* getGroupByName
|
||||
* Gets a specific group by it's name.
|
||||
*
|
||||
* @return object
|
||||
* @param string $name
|
||||
* @return array
|
||||
*/
|
||||
public function getGroupByName($name) {
|
||||
$this->db->where('name', $name);
|
||||
return $this->db->get('groups')->row_array();
|
||||
public function getByName($name) {
|
||||
return $this->db->get_where('groups', array('name' => $name))->row_array();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* End of file group.php */
|
||||
|
||||
140
application/models/parameter.php
Normal file
140
application/models/parameter.php
Normal file
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (c) 2011 Eike Foken <kontakt@eikefoken.de>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Model for parameters.
|
||||
*
|
||||
* Each program has many parameters used for configuration of trials.
|
||||
*
|
||||
* @author Eike Foken <kontakt@eikefoken.de>
|
||||
*/
|
||||
class Parameter extends CI_Model {
|
||||
|
||||
/**
|
||||
* Contains the possible types for parameters.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $availableTypes = array('boolean', 'integer', 'float', 'string', 'array');
|
||||
|
||||
/**
|
||||
* Calls the parent constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all available parameters for a program.
|
||||
*
|
||||
* @param string $programId
|
||||
* @return array
|
||||
*/
|
||||
public function getAll($programId) {
|
||||
return $this->db->order_by('sort_number ASC')
|
||||
->get_where('parameters', array('program_id' => $programId))->result_array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a specific parameter.
|
||||
*
|
||||
* @param string $id
|
||||
*/
|
||||
public function getById($id) {
|
||||
return $this->db->get_where('parameters', array('id' => $id))->row_array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the possible parameter types.
|
||||
*/
|
||||
public function getTypes() {
|
||||
return $this->availableTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new parameter.
|
||||
*
|
||||
* @param array $data
|
||||
* @return mixed Returns the ID of the created parameter, or FALSE if
|
||||
* the insert was unsuccessful.
|
||||
*/
|
||||
public function create($data) {
|
||||
$this->load->helper('hash');
|
||||
|
||||
if (!isset($data['program_id'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
do { // generate unique hash
|
||||
$data['id'] = random_hash('16');
|
||||
} while ($this->db->where('id', $data['id'])->from('parameters')->count_all_results() > 0);
|
||||
|
||||
// put new parameter to the end
|
||||
$data['sort_number'] = $this->db->select_max('sort_number')
|
||||
->get_where('parameters', array('program_id' => $data['program_id']))
|
||||
->row()->sort_number + 1;
|
||||
|
||||
$this->db->insert('parameters', $data);
|
||||
return $this->db->affected_rows() > 0 ? $data['id'] : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a parameter.
|
||||
*
|
||||
* @param array $data
|
||||
* @param string $id
|
||||
* @return boolean Returns TRUE if the update was successful.
|
||||
*/
|
||||
public function update($data, $id) {
|
||||
$this->db->update('parameters', $data, array('id' => $id));
|
||||
return $this->db->affected_rows() == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a specified parameter.
|
||||
*
|
||||
* @param string $id
|
||||
* @return boolean Returns TRUE if the deletion was successful.
|
||||
*/
|
||||
public function delete($id) {
|
||||
$this->db->delete('parameters', array('id' => $id));
|
||||
return $this->db->affected_rows() == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the order of an array of parameters.
|
||||
*
|
||||
* @param array $parameters
|
||||
* @return boolean Returns TRUE if the new order was successfully saved.
|
||||
*/
|
||||
public function sort($parameters) {
|
||||
foreach ($parameters as $number => $id) {
|
||||
$this->db->update('parameters', array('sort_number' => $number), array('id' => $id));
|
||||
}
|
||||
|
||||
return $this->db->affected_rows() > 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* End of file parameter.php */
|
||||
/* Location: ./application/models/parameter.php */
|
||||
@@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011 Karsten Heiken <karsten@disposed.de>
|
||||
*
|
||||
@@ -24,29 +23,58 @@
|
||||
|
||||
/**
|
||||
* Programs are used to do the actual calculation of a trial.
|
||||
*
|
||||
*
|
||||
* @author Karsten Heiken <karsten@disposed.de>
|
||||
* @author Eike Foken <kontakt@eikefoken.de>
|
||||
*/
|
||||
class Program extends CI_Model {
|
||||
|
||||
/**
|
||||
* Create a new program.
|
||||
*
|
||||
* @param array $data the data of the new program
|
||||
* @return bool was the insert successful
|
||||
* Calls the parent constructor.
|
||||
*/
|
||||
public function create($data) {
|
||||
// TODO: stub
|
||||
return FALSE;
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a program.
|
||||
* @param string the program id to delete
|
||||
* @return bool was the deletion successful
|
||||
* Creates a new program.
|
||||
*
|
||||
* @param string $name The name of the new program
|
||||
* @return string|boolean Returns the ID of the new program, or FALSE if
|
||||
* the insert was unsuccessful.
|
||||
*/
|
||||
public function delete($program_id) {
|
||||
return $this->db->delete('programs', array('id' => $program_id));
|
||||
public function create($name) {
|
||||
$this->load->helper('hash');
|
||||
|
||||
do { // generate unique hash
|
||||
$id = random_hash('16');
|
||||
} while ($this->db->where('id', $id)->from('programs')->count_all_results() > 0);
|
||||
|
||||
$this->db->insert('programs', array('id' => $id, 'name' => $name));
|
||||
|
||||
return $this->db->affected_rows() > 0 ? $id : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a program.
|
||||
*
|
||||
* @param string $name The new name of the program
|
||||
* @param string $id The ID of the program to update
|
||||
* @return boolean Returns TRUE if the update was successful
|
||||
*/
|
||||
public function update($name, $id) {
|
||||
$this->db->update('programs', array('name' => $name), array('id' => $id));
|
||||
return $this->db->affected_rows() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a program.
|
||||
*
|
||||
* @param string $programId The program ID to delete
|
||||
* @return boolean Returns TRUE if the deletion was successful
|
||||
*/
|
||||
public function delete($programId) {
|
||||
return $this->db->delete('programs', array('id' => $programId));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,13 +87,13 @@ class Program extends CI_Model {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a specific program.
|
||||
* Gets a specific program.
|
||||
*
|
||||
* @param string $prg_id The id of the program to get from the database
|
||||
* @param string $id The id of the program to get from the database
|
||||
* @return array Declarative array with all available information of the program.
|
||||
*/
|
||||
public function getById($prg_id) {
|
||||
return $this->db->get_where('programs', array('id' => $prg_id))->row_array();
|
||||
public function getById($id) {
|
||||
return $this->db->get_where('programs', array('id' => $id))->row_array();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,13 +115,13 @@ class Program extends CI_Model {
|
||||
* )
|
||||
* )
|
||||
*
|
||||
* @param type $program_id The program for which we want to get the parameters.
|
||||
* @param string $id The program for which we want to get the parameters.
|
||||
* @return array The parameters
|
||||
*/
|
||||
public function getParameters($program_id) {
|
||||
$query = $this->db->select('id, fieldname, readable, unit, description, type')
|
||||
->get_where('configuration_fields', array('program_id' => $program_id));
|
||||
public function getParameters($id) {
|
||||
$query = $this->db->order_by('sort_number ASC')
|
||||
->get_where('parameters', array('program_id' => $id));
|
||||
|
||||
return $query->result_array();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php defined('BASEPATH') || exit("No direct script access allowed");
|
||||
<?php defined('BASEPATH') || exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* User model.
|
||||
@@ -7,6 +7,20 @@
|
||||
*/
|
||||
class User extends CI_Model {
|
||||
|
||||
/**
|
||||
* Should the salt be stored in the database?
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $storeSalt;
|
||||
|
||||
/**
|
||||
* Contains the salt length.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
private $saltLength;
|
||||
|
||||
/**
|
||||
* Contains the forgotten password key.
|
||||
*
|
||||
@@ -104,7 +118,7 @@ class User extends CI_Model {
|
||||
$new = $this->hashPassword($new, $result->salt);
|
||||
|
||||
if ($dbPassword === $old) {
|
||||
// store the new password and reset the remember code so all remembered instances have to re-login
|
||||
// reset the remember code so all remembered instances have to re-login
|
||||
$data = array('password' => $new, 'remember_code' => '');
|
||||
|
||||
$this->db->update('users', $data, array('username' => $username));
|
||||
@@ -117,6 +131,7 @@ class User extends CI_Model {
|
||||
/**
|
||||
* Checks entered usernames.
|
||||
*
|
||||
* @param string $username
|
||||
* @return boolean
|
||||
*/
|
||||
public function checkUsername($username = '') {
|
||||
@@ -129,6 +144,7 @@ class User extends CI_Model {
|
||||
/**
|
||||
* Checks entered emails.
|
||||
*
|
||||
* @param string $email
|
||||
* @return boolean
|
||||
*/
|
||||
public function checkEmail($email = '') {
|
||||
@@ -141,6 +157,7 @@ class User extends CI_Model {
|
||||
/**
|
||||
* Inserts a forgotten password key.
|
||||
*
|
||||
* @param string $email
|
||||
* @return boolean
|
||||
*/
|
||||
public function forgottenPassword($email = '') {
|
||||
@@ -158,8 +175,10 @@ class User extends CI_Model {
|
||||
}
|
||||
|
||||
/**
|
||||
* Forgotten Password Complete
|
||||
* Completes the forgotten password procedure.
|
||||
*
|
||||
* @param string $code
|
||||
* @param boolean $salt
|
||||
* @return string
|
||||
*/
|
||||
public function forgottenPasswordComplete($code, $salt = false) {
|
||||
@@ -174,7 +193,7 @@ class User extends CI_Model {
|
||||
|
||||
$data = array(
|
||||
'password' => $this->hashPassword($password, $salt),
|
||||
'forgotten_password_code' => null
|
||||
'forgotten_password_code' => null,
|
||||
);
|
||||
|
||||
$this->db->update('users', $data, array('forgotten_password_code' => $code));
|
||||
@@ -185,15 +204,18 @@ class User extends CI_Model {
|
||||
}
|
||||
|
||||
/**
|
||||
* profile
|
||||
* Gets a users profile.
|
||||
*
|
||||
* @return boolean|object
|
||||
* @param string $username
|
||||
* @param boolean $isCode
|
||||
* @return mixed
|
||||
*/
|
||||
public function profile($username = '', $isCode = false) {
|
||||
if (empty($username)) {
|
||||
@$username = $this->session->userdata('username');
|
||||
if(empty($username))
|
||||
return FALSE;
|
||||
if (empty($username)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->select('users.*, groups.name AS `group`, groups.description AS `group_description`');
|
||||
@@ -207,7 +229,7 @@ class User extends CI_Model {
|
||||
|
||||
$query = $this->db->limit(1)->get('users');
|
||||
|
||||
return $query->num_rows > 0 ? $query->row() : false;
|
||||
return $query->num_rows() > 0 ? $query->row_array() : false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -251,7 +273,6 @@ class User extends CI_Model {
|
||||
if ($this->storeSalt) {
|
||||
$data['salt'] = $salt;
|
||||
}
|
||||
print_r($data);
|
||||
|
||||
$this->db->insert('users', array_merge($data, $additionalData));
|
||||
|
||||
@@ -259,8 +280,11 @@ class User extends CI_Model {
|
||||
}
|
||||
|
||||
/**
|
||||
* login
|
||||
* Validates the given password against the username.
|
||||
*
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @param boolean $remember
|
||||
* @return boolean
|
||||
*/
|
||||
public function login($username, $password, $remember = false) {
|
||||
@@ -300,8 +324,11 @@ class User extends CI_Model {
|
||||
}
|
||||
|
||||
/**
|
||||
* get
|
||||
* Gets users.
|
||||
*
|
||||
* @param mixed $group
|
||||
* @param integer $limit
|
||||
* @param integer $offset
|
||||
* @return object
|
||||
*/
|
||||
public function get($group = false, $limit = null, $offset = null) {
|
||||
@@ -332,6 +359,7 @@ class User extends CI_Model {
|
||||
/**
|
||||
* Returns the number of users.
|
||||
*
|
||||
* @param mixed $group
|
||||
* @return integer The number of users
|
||||
*/
|
||||
public function count($group = false) {
|
||||
@@ -346,6 +374,7 @@ class User extends CI_Model {
|
||||
/**
|
||||
* Gets a user by ID.
|
||||
*
|
||||
* @param string $id
|
||||
* @return array
|
||||
*/
|
||||
public function getUserByID($id = false) {
|
||||
@@ -353,74 +382,72 @@ class User extends CI_Model {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->db->where('users.id', $id);
|
||||
$this->db->limit(1);
|
||||
$this->db->where('users.id', $id)->limit(1);
|
||||
|
||||
return $this->get()->row_array();
|
||||
}
|
||||
|
||||
/**
|
||||
* getUserByEmail
|
||||
* Gets a user by email.
|
||||
*
|
||||
* @return object
|
||||
* @param string $email
|
||||
* @return array
|
||||
*/
|
||||
public function getUserByEmail($email) {
|
||||
$this->db->where('users.email', $email);
|
||||
$this->db->limit(1);
|
||||
return $this->get();
|
||||
$this->db->where('users.email', $email)->limit(1);
|
||||
return $this->get()->row_array();
|
||||
}
|
||||
|
||||
/**
|
||||
* getUserByUsername
|
||||
* Gets a user by username.
|
||||
*
|
||||
* @return object
|
||||
* @param string $username
|
||||
* @return array
|
||||
*/
|
||||
public function getUserByUsername($username) {
|
||||
$this->db->where('users.username', $username);
|
||||
$this->db->limit(1);
|
||||
return $this->get();
|
||||
$this->db->where('users.username', $username)->limit(1);
|
||||
return $this->get()->row_array();
|
||||
}
|
||||
|
||||
/**
|
||||
* getNewestUsers
|
||||
* Gets a specified number of new users.
|
||||
*
|
||||
* @return object
|
||||
* @param integer $limit
|
||||
* @return array
|
||||
*/
|
||||
public function getNewestUsers($limit = 10) {
|
||||
$this->db->order_by('users.created_on DESC');
|
||||
$this->db->limit($limit);
|
||||
return $this->get();
|
||||
$this->db->order_by('users.created_on DESC')->limit($limit);
|
||||
return $this->get()->result_array();
|
||||
}
|
||||
|
||||
/**
|
||||
* getUsersGroup
|
||||
* Gets a users group.
|
||||
*
|
||||
* @return object
|
||||
* @param string $id
|
||||
* @return array
|
||||
*/
|
||||
public function getUsersGroup($id = false) {
|
||||
// if no ID was passed use the current users ID
|
||||
$id || $id = $this->session->userdata('user_id');
|
||||
|
||||
$user = $this->db->select('group_id')->where('id', $id)->get('users')
|
||||
->row();
|
||||
$user = $this->db->select('group_id')->where('id', $id)->get('users')->row();
|
||||
|
||||
return $this->db->select('name, description')
|
||||
->where('id', $user->group_id)->get('groups')->row();
|
||||
->where('id', $user->group_id)->get('groups')->row_array();
|
||||
}
|
||||
|
||||
/**
|
||||
* update
|
||||
* Updates a user.
|
||||
*
|
||||
* @return boolean
|
||||
* @param string $id
|
||||
* @param array $data
|
||||
* @return boolean Returns TRUE if the update was successful.
|
||||
*/
|
||||
public function update($id, $data) {
|
||||
$user = $this->getUserByID($id);
|
||||
|
||||
$this->db->trans_begin();
|
||||
|
||||
if (array_key_exists('username', $data) && $this->checkUsername($data['username']) && $user['username'] !== $data['username']) {
|
||||
$this->db->trans_rollback();
|
||||
$this->access->setError('account_creation_duplicate_username');
|
||||
$this->messages->add(_('The entered username is already in use.'), 'error');
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -432,38 +459,25 @@ class User extends CI_Model {
|
||||
$this->db->update('users', $data, array('id' => $id));
|
||||
}
|
||||
|
||||
if ($this->db->trans_status() === false) {
|
||||
$this->db->trans_rollback();
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
return true;
|
||||
return $this->db->affected_rows() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the specified user.
|
||||
* Deletes a specified user.
|
||||
*
|
||||
* @return boolean
|
||||
* @param string $id
|
||||
* @return boolean Returns TRUE if the deletion was successful.
|
||||
*/
|
||||
public function delete($id) {
|
||||
$this->db->trans_begin();
|
||||
|
||||
$this->db->delete('users', array('id' => $id));
|
||||
|
||||
if ($this->db->trans_status() === false) {
|
||||
$this->db->trans_rollback();
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
return true;
|
||||
return $this->db->affected_rows() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* updateLastLogin
|
||||
* Updates a users last login time.
|
||||
*
|
||||
* @return boolean
|
||||
* @param string $id
|
||||
* @return boolean Returns TRUE if the update was successful.
|
||||
*/
|
||||
public function updateLastLogin($id) {
|
||||
$this->db->update('users', array('last_login' => now()), array('id' => $id));
|
||||
@@ -471,7 +485,7 @@ class User extends CI_Model {
|
||||
}
|
||||
|
||||
/**
|
||||
* loginRemembedUser
|
||||
* Logs a remembed user in.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
@@ -512,8 +526,9 @@ class User extends CI_Model {
|
||||
}
|
||||
|
||||
/**
|
||||
* rememberUser
|
||||
* Remembers a user.
|
||||
*
|
||||
* @param string $id
|
||||
* @return boolean
|
||||
*/
|
||||
private function rememberUser($id) {
|
||||
@@ -542,7 +557,6 @@ class User extends CI_Model {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* End of file user.php */
|
||||
|
||||
73
application/views/admin/parameters/create.php
Normal file
73
application/views/admin/parameters/create.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php $this->load->view('header');?>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<div class="title">
|
||||
<h2><?=_('Add a new parameter');?></h2>
|
||||
</div>
|
||||
|
||||
<div class="box">
|
||||
<form name="addParameter" method="post" action="<?=site_url('admin/parameters/create/' . $program['id']);?>">
|
||||
<ul>
|
||||
<li>
|
||||
<?=form_label(_('Name'), 'name');?>
|
||||
<span class="req">*</span>
|
||||
<div>
|
||||
<input type="text" name="name" id="name" class="short text" value="<?=set_value('name');?>" />
|
||||
<?=form_error('name');?>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<?=form_label(_('Human-readable name'), 'readable');?>
|
||||
<span class="req">*</span>
|
||||
<div>
|
||||
<input type="text" name="readable" id="readable" class="medium text" value="<?=set_value('readable');?>" />
|
||||
<?=form_error('readable');?>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<?=form_label(_('Unit'), 'unit');?>
|
||||
<div>
|
||||
<input type="text" name="unit" id="unit" class="short text" value="<?=set_value('unit');?>" />
|
||||
<?=form_error('unit');?>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<?=form_label(_('Description'), 'description');?>
|
||||
<div>
|
||||
<textarea name="description" id="description" rows="6" cols="60" class="textarea"><?=set_value('description');?></textarea>
|
||||
<?=form_error('description');?>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<?=form_label(_('Type'), 'type');?>
|
||||
<span class="req">*</span>
|
||||
<div>
|
||||
<select name="type" id="type" class="drop">
|
||||
<?php
|
||||
foreach ($types as $type):
|
||||
?>
|
||||
<option value="<?=$type;?>" <?=set_select('type', $type);?>><?=$type;?></option>
|
||||
<?php
|
||||
endforeach;
|
||||
?>
|
||||
</select>
|
||||
<?=form_error('type');?>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<?=form_label(_('Default value'), 'default_value');?>
|
||||
<div>
|
||||
<input type="text" name="default_value" id="default_value" class="short text" value="<?=set_value('default_value');?>" />
|
||||
<?=form_error('default_value');?>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<p>
|
||||
<a class="button save" href="javascript:void(0);" onclick="$('form[name=addParameter]').submit();"><?=_('Save');?></a>
|
||||
</p>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php $this->load->view('footer');?>
|
||||
74
application/views/admin/parameters/edit.php
Normal file
74
application/views/admin/parameters/edit.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php $this->load->view('header');?>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<div class="title">
|
||||
<h2><?php printf(_("Edit parameter '%s'"), $parameter['name']);?></h2>
|
||||
</div>
|
||||
|
||||
<div class="box">
|
||||
<form name="editParameter" method="post" action="<?=site_url('admin/parameters/edit/' . $parameter['id']);?>">
|
||||
<ul>
|
||||
<li>
|
||||
<?=form_label(_('Name'), 'name');?>
|
||||
<span class="req">*</span>
|
||||
<div>
|
||||
<input type="text" name="name" id="name" class="short text" value="<?=set_value('name', $parameter['name']);?>" />
|
||||
<?=form_error('name');?>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<?=form_label(_('Human-readable name'), 'readable');?>
|
||||
<span class="req">*</span>
|
||||
<div>
|
||||
<input type="text" name="readable" id="readable" class="medium text" value="<?=set_value('readable', $parameter['readable']);?>" />
|
||||
<?=form_error('readable');?>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<?=form_label(_('Unit'), 'unit');?>
|
||||
<div>
|
||||
<input type="text" name="unit" id="unit" class="short text" value="<?=set_value('unit', $parameter['unit']);?>" />
|
||||
<?=form_error('unit');?>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<?=form_label(_('Description'), 'description');?>
|
||||
<div>
|
||||
<textarea name="description" id="description" rows="6" cols="60" class="textarea"><?=set_value('description', $parameter['description']);?></textarea>
|
||||
<?=form_error('description');?>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<?=form_label(_('Type'), 'type');?>
|
||||
<span class="req">*</span>
|
||||
<div>
|
||||
<select name="type" id="type" class="drop">
|
||||
<?php
|
||||
foreach ($types as $type):
|
||||
?>
|
||||
<option value="<?=$type;?>" <?=set_select('type', $type, $parameter['type'] == $type);?>><?=$type;?></option>
|
||||
<?php
|
||||
endforeach;
|
||||
?>
|
||||
</select>
|
||||
<?=form_error('type');?>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<?=form_label(_('Default value'), 'default_value');?>
|
||||
<div>
|
||||
<input type="text" name="default_value" id="default_value" class="short text" value="<?=set_value('default_value', $parameter['default_value']);?>" />
|
||||
<?=form_error('default_value');?>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<p>
|
||||
<a class="button save" href="javascript:void(0);" onclick="$('form[name=editParameter]').submit();"><?=_('Save');?></a>
|
||||
<a class="button cancel" href="<?=site_url('admin/programs/edit/' . $parameter['program_id']);?>"><?=_('Cancel');?></a>
|
||||
</p>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php $this->load->view('footer');?>
|
||||
74
application/views/admin/programs/edit.php
Normal file
74
application/views/admin/programs/edit.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php $this->load->view('header');?>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#parameters').tableDnD({
|
||||
onDrop: function(table, row) {
|
||||
$.post(SITE_URL + 'ajax/sort_parameters', $.tableDnD.serialize());
|
||||
},
|
||||
dragHandle: 'drag_handle'
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<div id="debug"></div>
|
||||
|
||||
<div class="title">
|
||||
<h2><?php printf(_("Edit program '%s'"), $program['name']);?></h2>
|
||||
</div>
|
||||
|
||||
<div class="box">
|
||||
<form name="createUser" method="post" action="<?=site_url('admin/programs/edit/' . $program['id'])?>">
|
||||
<h3><?=_('Required information');?></h3>
|
||||
<ul>
|
||||
<li>
|
||||
<?=form_label(_('Name of the program'), 'name');?>
|
||||
<span class="req">*</span>
|
||||
<div>
|
||||
<input type="text" name="name" id="name" class="medium text" value="<?=set_value('name', $program['name']);?>" />
|
||||
<?=form_error('name')?>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<p>
|
||||
<a class="button save" href="javascript:void(0);" onclick="$('form[name=createUser]').submit();"><?=_('Save');?></a>
|
||||
<a class="button cancel" href="<?=site_url('admin/programs');?>"><?=_('Cancel');?></a>
|
||||
</p>
|
||||
|
||||
<h3><?=_('Parameters');?></h3>
|
||||
<table class="tableList sortable" id="parameters">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col"> </th>
|
||||
<th scope="col"><?=_('Readable name');?></th>
|
||||
<th scope="col"><?=_('Unit');?></th>
|
||||
<th scope="col"><?=_('Type');?></th>
|
||||
<th scope="col"><?=_('Actions');?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
foreach ($parameters as $parameter):
|
||||
?>
|
||||
<tr id="<?=$parameter['id'];?>">
|
||||
<td class="drag_handle"></td>
|
||||
<td><?=$parameter['readable'];?></td>
|
||||
<td><?=$parameter['unit'];?></td>
|
||||
<td><?=$parameter['type'];?></td>
|
||||
<td><?=anchor('admin/parameters/edit/' . $parameter['id'], _('Edit'));?> | <a href="javascript:deleteConfirm('<?=site_url('admin/parameters/delete/' . $parameter['id']);?>');"><?=_('Delete');?></a></td>
|
||||
</tr>
|
||||
<?php
|
||||
endforeach;
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>
|
||||
<a class="button add" href="<?=site_url('admin/parameters/create/' . $program['id']);?>"><?=_('Add new parameter');?></a>
|
||||
</p>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php $this->load->view('footer');?>
|
||||
36
application/views/admin/programs/list.php
Normal file
36
application/views/admin/programs/list.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php $this->load->view('header');?>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<div class="title">
|
||||
<h2><?=_('Programs');?></h2>
|
||||
</div>
|
||||
|
||||
<div class="box">
|
||||
<h3><?=_('Available programs');?></h3>
|
||||
<table class="tableList paginated">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col"><?=_('Name');?></th>
|
||||
<th scope="col"><?=_('Actions');?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
foreach ($programs as $program):
|
||||
?>
|
||||
<tr>
|
||||
<td><?=$program['name'];?></td>
|
||||
<td><?=anchor('admin/programs/edit/' . $program['id'], _('Edit'));?> | <a href="javascript:deleteConfirm('<?=site_url('admin/programs/delete/' . $program['id']);?>');"><?=_('Delete');?></a></td>
|
||||
</tr>
|
||||
<?php
|
||||
endforeach;
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p><a class="button add" href="<?=site_url('admin/programs/create')?>"><?=_('Add program')?></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php $this->load->view('footer');?>
|
||||
@@ -12,6 +12,7 @@
|
||||
<ul>
|
||||
<li>
|
||||
<?=form_label(_('Username'), 'username');?>
|
||||
<span class="req">*</span>
|
||||
<div>
|
||||
<input type="text" name="username" id="username" class="short text" value="<?=set_value('username');?>" />
|
||||
<?=form_error('username')?>
|
||||
@@ -20,6 +21,7 @@
|
||||
</li>
|
||||
<li>
|
||||
<?=form_label(_('Email address'), 'email');?>
|
||||
<span class="req">*</span>
|
||||
<div>
|
||||
<input type="text" name="email" id="email" class="medium text" value="<?=set_value('email');?>" />
|
||||
<?=form_error('email')?>
|
||||
@@ -27,6 +29,7 @@
|
||||
</li>
|
||||
<li>
|
||||
<?=form_label(_('Password'), 'password');?>
|
||||
<span class="req">*</span>
|
||||
<div>
|
||||
<input type="password" name="password" id="password" class="short text" />
|
||||
<?=form_error('password')?>
|
||||
@@ -34,6 +37,7 @@
|
||||
</li>
|
||||
<li>
|
||||
<?=form_label(_('Confirm password'), 'password_confirm');?>
|
||||
<span class="req">*</span>
|
||||
<div>
|
||||
<input type="password" name="password_confirm" id="password_confirm" class="short text" />
|
||||
<?=form_error('password_confirm')?>
|
||||
@@ -41,6 +45,7 @@
|
||||
</li>
|
||||
<li>
|
||||
<?=form_label(_('First name'), 'firstname');?>
|
||||
<span class="req">*</span>
|
||||
<div>
|
||||
<input type="text" name="firstname" id="firstname" class="short text" value="<?=set_value('firstname');?>" />
|
||||
<?=form_error('firstname')?>
|
||||
@@ -48,6 +53,7 @@
|
||||
</li>
|
||||
<li>
|
||||
<?=form_label(_('Last name'), 'lastname');?>
|
||||
<span class="req">*</span>
|
||||
<div>
|
||||
<input type="text" name="lastname" id="lastname" class="short text" value="<?=set_value('lastname');?>" />
|
||||
<?=form_error('lastname')?>
|
||||
@@ -71,13 +77,6 @@
|
||||
</div>
|
||||
<label class="note"><?=('Example');?>: +49 123 456789</label>
|
||||
</li>
|
||||
<li>
|
||||
<?=form_label(_('Language'), 'language');?>
|
||||
<div>
|
||||
<?=form_dropdown('language', array('English'), null, 'id="language" class="drop"');?>
|
||||
<?=form_error('language')?>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<p>
|
||||
<a class="button save" href="javascript:void(0);" onclick="$('form[name=createUser]').submit();"><?=_('Save');?></a>
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
<ul>
|
||||
<li>
|
||||
<?=form_label(_('Email address'), 'email');?>
|
||||
<span class="req">*</span>
|
||||
<div>
|
||||
<input type="text" name="email" id="email" class="medium text" value="<?=set_value('email', $user['email']);?>" />
|
||||
<?=form_error('email')?>
|
||||
@@ -19,6 +20,7 @@
|
||||
</li>
|
||||
<li>
|
||||
<?=form_label(_('First name'), 'firstname');?>
|
||||
<span class="req">*</span>
|
||||
<div>
|
||||
<input type="text" name="firstname" id="firstname" class="short text" value="<?=set_value('firstname', $user['firstname']);?>" />
|
||||
<?=form_error('firstname')?>
|
||||
@@ -26,6 +28,7 @@
|
||||
</li>
|
||||
<li>
|
||||
<?=form_label(_('Last name'), 'lastname');?>
|
||||
<span class="req">*</span>
|
||||
<div>
|
||||
<input type="text" name="lastname" id="lastname" class="short text" value="<?=set_value('lastname', $user['lastname']);?>" />
|
||||
<?=form_error('lastname')?>
|
||||
@@ -49,13 +52,6 @@
|
||||
</div>
|
||||
<label class="note"><?=_('Example');?>: +49 123 456789</label>
|
||||
</li>
|
||||
<li>
|
||||
<?=form_label(_('Language'), 'language');?>
|
||||
<div>
|
||||
<?=form_dropdown('language', array('English'), null, 'id="language" class="drop"');?>
|
||||
<?=form_error('language')?>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<p>
|
||||
<a class="button save" href="javascript:void(0);" onclick="$('form[name=createUser]').submit();"><?=_('Save');?></a>
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
<th scope="col"><?=_('Actions');?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
foreach ($users as $user):
|
||||
?>
|
||||
@@ -27,7 +28,6 @@
|
||||
<?php
|
||||
endforeach;
|
||||
?>
|
||||
<tbody>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
11
application/views/auth/email/forgot_password.php
Normal file
11
application/views/auth/email/forgot_password.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?=$username?>,
|
||||
|
||||
To reset your password, please go to the following page:
|
||||
|
||||
{unwrap}<?=site_url('auth/reset_password' . $forgotten_password_code);?>{/unwrap}
|
||||
|
||||
Your password will be automatically reset, and a new password will be emailed to you.
|
||||
|
||||
If you do not wish to reset your password, ignore this message. It will expire in 24 hours.
|
||||
|
||||
Thank you!
|
||||
@@ -0,0 +1,8 @@
|
||||
<?=$username?>,
|
||||
|
||||
Here is your new login information:
|
||||
|
||||
Username: <?=$username?>
|
||||
Password: <?=$password?>
|
||||
|
||||
Thank you!
|
||||
57
application/views/auth/forgot_password.php
Normal file
57
application/views/auth/forgot_password.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="<?=substr($this->config->item('language'), 0, 2);?>">
|
||||
<head>
|
||||
|
||||
<meta charset="utf-8" />
|
||||
|
||||
<title>ScattPort | <?=_('Login');?></title>
|
||||
|
||||
<?=link_tag('assets/css/login.css');?>
|
||||
<?=link_tag('assets/css/form.css');?>
|
||||
|
||||
<?=script_tag('assets/js/minmax.js');?>
|
||||
<?=script_tag('https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js');?>
|
||||
<?=script_tag('assets/js/scattport.js');?>
|
||||
<script type="text/javascript">
|
||||
var SITE_URL = '<?=site_url()?>';
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="wrapper">
|
||||
|
||||
<div id="box">
|
||||
<h2>Scattport <span class="light"><?=_('Login');?></span></h2>
|
||||
|
||||
<?php
|
||||
if (isset($errors) && is_array($errors)) {
|
||||
foreach ($errors as $e) {
|
||||
echo "<p class=\"error\"><strong>" . _('Error') . ":</strong> " . $e . "</p>";
|
||||
}
|
||||
} else if (isset($messages) && is_array($messages)) {
|
||||
foreach ($messages as $m) {
|
||||
echo "<p class=\"success\"><strong>" . _('Success') . ":</strong> " . $m . "</p>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
<form name="password" action="<?= site_url('auth/forgot_password') ?>"
|
||||
method="post">
|
||||
<ul>
|
||||
<li>
|
||||
<label><?=form_label(_('Email address'), 'email');?></label>
|
||||
<div>
|
||||
<input type="text" name="email" id="email" class="text max" value="<?=set_value('email');?>" />
|
||||
<?=form_error('email');?>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<input type="submit" class="button" name="forgot_password" value="<?=_('Submit');?>" />
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</form>
|
||||
|
||||
<p><?=anchor('auth/login', _('Back to login page'));?></p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,60 +1,72 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<!DOCTYPE html>
|
||||
<html lang="<?=substr($this->config->item('language'), 0, 2);?>">
|
||||
<head>
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta charset="utf-8" />
|
||||
|
||||
<title>ScattPort | Login</title>
|
||||
<title>ScattPort | <?=_('Login');?></title>
|
||||
|
||||
<?= link_tag('assets/css/login.css'); ?>
|
||||
<?= link_tag('assets/css/form.css'); ?>
|
||||
|
||||
<?= script_tag('assets/js/minmax.js'); ?>
|
||||
<?= script_tag('https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js'); ?>
|
||||
<?= script_tag('assets/js/scattport.js'); ?>
|
||||
<?= link_tag('assets/css/login.css'); ?>
|
||||
<?= link_tag('assets/css/form.css'); ?>
|
||||
|
||||
<?= script_tag('assets/js/minmax.js'); ?>
|
||||
<?= script_tag('https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js'); ?>
|
||||
<?= script_tag('assets/js/scattport.js'); ?>
|
||||
<script type="text/javascript">
|
||||
var SITE_URL = '<?=site_url()?>';
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="wrapper">
|
||||
<div id="wrapper">
|
||||
|
||||
<div id="box">
|
||||
<h2>Scattport <span class="light">Login</span></h2>
|
||||
<div id="box">
|
||||
<h2>Scattport <span class="light"><?=_('Login');?></span></h2>
|
||||
|
||||
<p>
|
||||
<?php
|
||||
if (isset($error))
|
||||
foreach ($error as $e)
|
||||
echo "<div class=\"error\">" . $e . "</div>";
|
||||
if (isset($notice))
|
||||
foreach ($notice as $n)
|
||||
echo "<div class=\"notice\">" . $n . "</div>";
|
||||
if (isset($success))
|
||||
foreach ($success as $s)
|
||||
echo "<div class=\"success\">" . $s . "</div>";
|
||||
?>
|
||||
</p>
|
||||
<?php
|
||||
if (isset($errors)) {
|
||||
foreach ($errors as $e) {
|
||||
echo "<p class=\"error\"><strong>" . _('Error') . ":</strong> " . $e . "</p>";
|
||||
}
|
||||
} else if (isset($messages) && is_array($messages)) {
|
||||
foreach ($messages as $m) {
|
||||
echo "<p class=\"success\"><strong>" . _('Success') . ":</strong> " . $m . "</p>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
<form action="<?= site_url('auth/login') ?>" method="post" name="loginform">
|
||||
<ul>
|
||||
<li>
|
||||
<?=form_label(_('Username'), 'username');?>
|
||||
<div>
|
||||
<input type="text" name="username" id="username" class="text max" value="<?=set_value('username');?>" />
|
||||
<?=form_error('username');?>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<?=form_label(_('Password'), 'password');?>
|
||||
<div>
|
||||
<input type="password" name="password" id="password" class="text max" />
|
||||
<?=form_error('password');?>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<input type="checkbox" name="remember" id="remember" class="radio" value="1"<?=set_checkbox('remember', 1);?> />
|
||||
<label for="remember" class="choice"><?=_('Remember me on this computer')?></label>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<input type="submit" class="button" name="login" value="<?=_('Log in');?>" />
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</form>
|
||||
|
||||
<form action="<?= site_url('auth/login') ?>" method="post" name="loginform">
|
||||
<ul>
|
||||
<li>
|
||||
<label>Benutzername</label>
|
||||
<div><input type="text" name="username" class="text medium" /></div>
|
||||
</li>
|
||||
<li>
|
||||
<label>Passwort</label>
|
||||
<div><input type="password" name="password" class="text medium" /></div>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
<input type="submit" class="button" name="login" value="Einloggen" />
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</form>
|
||||
|
||||
<p><a href="#">Passwort vergessen?</a></p>
|
||||
</div>
|
||||
<p><?=anchor('auth/forgot_password', _('Forgotten password?'));?></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
100
application/views/auth/settings.php
Normal file
100
application/views/auth/settings.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php $this->load->view('header');?>
|
||||
|
||||
<div id="content">
|
||||
<form name="settings" action="<?=site_url('auth/settings');?>" method="post">
|
||||
<div class="title">
|
||||
<h2><?=_('Settings');?></h2>
|
||||
</div>
|
||||
<ul class="tabs">
|
||||
<li class="active"><a href="#personal"><?=_('Personal information');?></a></li>
|
||||
<li><a href="#settings"><?=_('Settings');?></a></li>
|
||||
<li><a href="#password"><?=_('Password');?></a></li>
|
||||
</ul>
|
||||
|
||||
<div class="tab_container">
|
||||
<div id="personal" class="tab_content">
|
||||
<ul>
|
||||
<li>
|
||||
<?=form_label(_('First name'), 'firstname');?>
|
||||
<span class="req">*</span>
|
||||
<div>
|
||||
<input type="text" name="firstname" id="firstname" class="short text" value="<?=set_value('firstname', $firstname);?>" />
|
||||
<?=form_error('firstname');?>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<?=form_label(_('Last name'), 'lastname');?>
|
||||
<span class="req">*</span>
|
||||
<div>
|
||||
<input type="text" name="lastname" id="lastname" class="short text" value="<?=set_value('lastname', $lastname);?>" />
|
||||
<?=form_error('lastname');?>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<?=form_label(_('Email address'), 'email');?>
|
||||
<span class="req">*</span>
|
||||
<div>
|
||||
<input type="text" name="email" id="email" class="medium text" value="<?=set_value('email', $email);?>" />
|
||||
<?=form_error('email');?>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<?=form_label(_('Institution'), 'institution');?>
|
||||
<div>
|
||||
<input type="text" name="institution" id="institution" class="medium text" value="<?=set_value('institution', $institution);?>" />
|
||||
<?=form_error('institution');?>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<?=form_label(_('Phone number'), 'phone');?>
|
||||
<div>
|
||||
<input type="text" name="phone" id="phone" class="short text" value="<?=set_value('phone', $phone);?>" />
|
||||
<?=form_error('phone');?>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="settings" class="tab_content">
|
||||
<ul>
|
||||
<li>
|
||||
<input type="checkbox" id="projects_sortrecently" name="projects_sortrecently" value="1" class="checkbox"/>
|
||||
<label for="projects_sortrecently"><?=_('Sort projects by date of the last access');?></label><br />
|
||||
<label class="note"><?=_('If the projects are sorted by the data of the last access, the rarely used projects "slip" to the end of the list.');?></label>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="password" class="tab_content">
|
||||
<ul>
|
||||
<li>
|
||||
<?=form_label(_('Current password'), 'old_password');?>
|
||||
<div>
|
||||
<input type="password" name="old_password" id="old_password" class="short text" value="<?=set_value('old_password');?>" />
|
||||
<?=form_error('old_password');?>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<?=form_label(_('New password'), 'new_password');?>
|
||||
<div>
|
||||
<input type="password" name="new_password" id="new_password" class="short text" />
|
||||
<?=form_error('new_password');?>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<?=form_label(_('Confirm new password'), 'new_password_confirm');?>
|
||||
<div>
|
||||
<input type="password" name="new_password_confirm" id="new_password_confirm" class="short text" />
|
||||
<?=form_error('new_password_confirm');?>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="tab_buttons">
|
||||
<p>
|
||||
<a class="button save" href="javascript:void(0);" onclick="$('form[name=settings]').submit();"><?=_('Save settings');?></a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<?php $this->load->view('footer'); ?>
|
||||
@@ -21,7 +21,7 @@
|
||||
<div class="box">
|
||||
<h3><?=_('Administration');?></h3>
|
||||
<p>
|
||||
<a class="button left big" href="#"><?=_('Manage servers');?></a><a class="button middle big" href="#"><?=_('Manage applications');?></a><a class="button right big" href="<?=site_url('users');?>"><?=_('Manage users');?></a>
|
||||
<a class="button left big" href="#"><?=_('Manage servers');?></a><a class="button middle big" href="<?=site_url('admin/programs');?>"><?=_('Manage programs');?></a><a class="button right big" href="<?=site_url('admin/users');?>"><?=_('Manage users');?></a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<div id="footer">
|
||||
<?
|
||||
if($this->session->userdata('group') == 'admins'):
|
||||
if ($this->access->isAdmin()):
|
||||
?>
|
||||
<span class="left"><strong><?=_('Administration')?> - </strong>
|
||||
<a href="<?=site_url('admin/settings')?>"><?=_('Global settings')?></a> |
|
||||
<a href="<?=site_url('admin/servers')?>"><?=_('Manage calculation servers')?></a> |
|
||||
<a href="<?=site_url('admin/users')?>"><?=_('Manage users')?></a> |
|
||||
<a href="<?=site_url('admin/programs')?>"><?=_('Manage applications')?></a>
|
||||
<a href="<?=site_url('admin/programs')?>"><?=_('Manage programs')?></a>
|
||||
</span>
|
||||
<?
|
||||
endif;
|
||||
|
||||
@@ -1,33 +1,16 @@
|
||||
<?
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011 Karsten Heiken <karsten@disposed.de>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
if (is_array($messages)):
|
||||
foreach ($messages as $type => $msgs):
|
||||
if (count($msgs > 0)):
|
||||
foreach ($msgs as $message):
|
||||
echo ('<div class="' . $type .'">' . $message . '</div>');
|
||||
endforeach;
|
||||
endif;
|
||||
endforeach;
|
||||
endif;
|
||||
<?php
|
||||
if (is_array($messages)):
|
||||
foreach ($messages as $type => $msgs):
|
||||
if (count($msgs > 0)):
|
||||
foreach ($msgs as $message):
|
||||
?>
|
||||
<div class="<?=$type;?>">
|
||||
<?=$message;?>
|
||||
<a href="javascript:void(0);" onclick="$(this).parent().hide()" class="cross"><span>X</span></a>
|
||||
</div>
|
||||
<?php
|
||||
endforeach;
|
||||
endif;
|
||||
endforeach;
|
||||
endif;
|
||||
?>
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"><head>
|
||||
<!DOCTYPE html>
|
||||
<html lang="<?=substr($this->config->item('language'), 0, 2);?>">
|
||||
<head>
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta charset="utf-8" />
|
||||
|
||||
<title>ScattPort</title>
|
||||
|
||||
@@ -13,10 +14,12 @@
|
||||
<?=script_tag('https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js');?>
|
||||
<?=script_tag('assets/js/scattport.js');?>
|
||||
<?=script_tag('assets/js/tablednd.jquery.js');?>
|
||||
<?=script_tag('assets/js/jtip.js');?>
|
||||
<script type="text/javascript">
|
||||
var SITE_URL = '<?=site_url()?>';
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div id="header">
|
||||
@@ -27,7 +30,7 @@
|
||||
<option value="<?=site_url('projects');?>">Projekte verwalten</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="menu"><?= _('Hello,') ?> <a href="<?=site_url('');?>"><?=$this->user->profile()->firstname;?> <?=$this->user->profile()->lastname;?></a>! | <?=lang_select('assets/images');?> | <a href="#"><?=_('Help')?></a> | <?=anchor('settings', _('Settings'));?> | <?=anchor('auth/logout', _('Logout'));?></div>
|
||||
<div class="menu"><?= _('Hello,') ?> <a href="<?=site_url('');?>"><?=$this->user->profile()->firstname;?> <?=$this->user->profile()->lastname;?></a>! | <?=lang_select('assets/images');?> | <a href="#"><?=_('Help')?></a> | <?=anchor('auth/settings', _('Settings'));?> | <?=anchor('auth/logout', _('Logout'));?></div>
|
||||
</div>
|
||||
|
||||
<div id="wrapper">
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,48 +0,0 @@
|
||||
<?php $this->load->view('header');?>
|
||||
|
||||
<div id="content">
|
||||
<form action="#" method="post">
|
||||
<div class="title">
|
||||
<h2><?=_('Settings');?></h2>
|
||||
</div>
|
||||
<ul class="tabs">
|
||||
<li class="active"><a href="#personal"><?=_('Personal Information');?></a></li>
|
||||
<li><a href="#settings"><?=_('Settings');?></a></li>
|
||||
</ul>
|
||||
|
||||
<div class="tab_container">
|
||||
<div id="personal" class="tab_content">
|
||||
<ul>
|
||||
<?php foreach($profile_fields as $field):?>
|
||||
<li>
|
||||
<label><?=$field[1]?></label>
|
||||
<div>
|
||||
<input type="<?=$field[2]?>" name="<?=$field[0]?>" class="short text" />
|
||||
</div>
|
||||
</li>
|
||||
<?php endforeach;?>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="settings" class="tab_content">
|
||||
<ul>
|
||||
<li>
|
||||
<label><?=_('Language');?></label>
|
||||
<div>
|
||||
<select id="language_select" name="language_select" class="drop">
|
||||
<option value="de">Deutsch</option>
|
||||
<option value="en">Englisch</option>
|
||||
</select>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<input type="checkbox" id="projects_sortrecently" name="projects_sortrecently" value="1" class="checkbox"/>
|
||||
<label for="projects_sortrecently"><?=_('Sort projects by date of the last access');?></label><br />
|
||||
<label class="note"><?=_('If the projects are sorted by the data of the last access, the rarely used projects "slip" to the end of the list.');?></label>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<?php $this->load->view('footer'); ?>
|
||||
Reference in New Issue
Block a user