Merge branch 'feature-projectmanagement' of disposed.de:scattport

This commit is contained in:
Karsten Heiken
2011-05-26 18:07:51 +02:00
13 changed files with 1365 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
<?php
class Fields extends CI_Controller {
public function __construct() {
parent::__construct();
}
public function upload_csv() {
$this->load-view('web/configurations/upload_csv');
}
}

View File

@@ -0,0 +1,31 @@
<?php
/**
* Configurations are used to store different variations of the same project.
*
* @author Karsten Heiken, karsten@disposed.de
*/
class Configurations extends CI_Controller {
/**
* Constructor.
*/
public function __construct() {
parent::__construct();
$this->load->model('configuration');
// load language file
// $this->lang->load(strtolower($this->router->class));
}
/**
* Get a specific configuration from the database.
*
* @param string $config_id The configuration id to get.
*/
public function detail($config_id) {
$configs = $this->configuration->get($config_id);
$this->load->view('web/configurations/detail', $configs);
}
}

View File

@@ -0,0 +1,83 @@
<?php
/**
* @author Karsten Heiken, karsten@disposed.de
*/
class Projects extends CI_Controller {
/**
* Constructor.
*/
public function __construct() {
parent::__construct();
$this->load->model('project');
$this->load->helper('tree');
// load language file
$this->lang->load(strtolower($this->router->class));
}
/**
* Lists all projects the user has access to.
*/
public function getAll() {
$projects = $this->db->get('projects')->result_array();
$this->load->view('web/projects/list',
array('projects' => $projects));
}
public function detail($project_id) {
$project = $this->project->get($project_id);
$project['configs'] = $this->project->getConfigurations($project_id);
$this->load->view('web/projects/detail', $project);
}
public function create() {
$this->load->library('form_validation');
$this->load->helper('date');
$this->form_validation->set_rules('f_name', "Projektname",
'required|max_length[100]|xss_clean|callback_unique');
$this->form_validation->set_rules('f_description', "Beschreibung", 'required|xss_clean');
if ($this->form_validation->run() == true) {
// populate fields for the new project
$project['name'] = $this->form_validation->set_value('f_name');
$project['description'] = $this->form_validation->set_value('f_description');
$foo = $this->project->create($project);
redirect('web/projects/getAll', 'refresh');
} else {
$this->data['message'] = validation_errors() ? validation_errors() : null;
$this->data['name'] = $this->form_validation->set_value('f_name');
$this->data['description'] = $this->form_validation->set_value('f_description');
$this->load->view('web/projects/create', $this->data);
}
}
/**
* Checks if the user already has a project with the given name.
*
* It's okay if different users have the same project - even if that
* will complicate sharing.
*
* @param string $project_name
* @return boolean
*/
function unique($project_name) {
$query = $this->db->get_where('projects',
array(
'name' => $project_name,
'owner' => $this->session->userdata('user_id'))
);
if($query->num_rows() > 0)
return false;
else
return true;
}
}

View File

@@ -0,0 +1,6 @@
<?php
$lang['unique'] = "A project with this name already exists.";
/* End of file projects_lang.php */
/* Location: ./application/language/english/form_validation_lang.php */

View File

@@ -0,0 +1,6 @@
<?php
$lang['unique'] = "Ein Projekt mit diesem Namen existiert bereits";
/* End of file projects_lang.php */
/* Location: ./application/language/german/form_validation_lang.php */

View File

@@ -0,0 +1,37 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Configuration <?=$name?></title>
<link rel="stylesheet" href="<?=base_url()?>/assets/css/inuit.css" />
</head>
<body>
<div class="grids">
<div class="grid grid-10">
<table>
<tr>
<th colspan="2">
Konfigurationsdetails
</th>
</tr>
<tr>
<td>ID</td><td><?=$id?></td>
</tr>
<tr>
<td>Name</td><td><?=$name?></td>
</tr>
</table>
</div>
<div class="grid grid-6">
<table>
<tr>
<th>Beschreibung</th>
</tr>
<tr>
<td><?=nl2br($description)?></td>
</tr>
</table>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,4 @@
<?php echo $this->load->view('web/header'); ?>
<?=form_open_multipart();?>
<?=form_close();?>

View File

@@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Scattport</title>
<?=link_tag('assets/css/inuit.css');?>
</head>
<body>

View File

@@ -0,0 +1,40 @@
<!DOCTYPE html5>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Create Project</title>
<link rel="stylesheet" href="/ScattPort/assets/css/inuit.css" />
</head>
<body>
<div class="grids">
<div class="grid grid-8">
<?=form_open('web/projects/create')?>
<table>
<tr><th colspan="2">Create a new project</th></tr>
<tr>
<td>
Name:
</td>
<td>
<input type="text" name="f_name" value="<?=$name?>"/><?=form_error('f_name')?>
</td>
</tr>
<tr>
<td>
Beschreibung:
</td>
<td>
<input type="text" name="f_description" value="<?=$description?>"/><?=form_error('description')?>
</td>
</tr>
<tr>
<td align="right" colspan="2">
<input type="submit" />
</td>
</tr>
</table>
<?=form_close()?>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,41 @@
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Project <?=$name?></title>
<link rel="stylesheet" href="<?=base_url();?>/assets/css/inuit.css" />
</head>
<body>
<div class="grids">
<div class="grid grid-8">
<table>
<tr><th colspan="2">Projektdetails</th></tr>
<tr>
<td>ID</td>
<td><?=$id?></td>
</tr>
<tr>
<td>Name</td>
<td><?=$name?></td>
</tr>
<tr>
<td>Beschreibung</td>
<td><?=$description?></td>
</tr>
</table>
</div>
<div class="grid grid-8">
<table>
<tr><th>Konfigurationen</th></tr>
<? foreach($configs as $config): ?>
<tr><td><?=anchor('web/configurations/detail/'.$config['id'], $config['name'])?></td></tr>
<? endforeach; ?>
</table>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,24 @@
<!DOCTYPE html5>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>List of projects</title>
<link rel="stylesheet" href="<?=base_url();?>/assets/css/inuit.css" />
</head>
<body>
<table>
<tr>
<td><b>id</b></td>
<td><b>name</b></td>
<td><b>owner</b></td>
</tr>
<? foreach($projects as $project): ?>
<tr>
<td><?=anchor('web/projects/detail/'.$project['id'], $project['id'])?></td>
<td><?=$project['name']?></td>
<td><?=$project['owner']?></td>
</tr>
<? endforeach; ?>
</table>
</body>
</html>