diff --git a/application/controllers/web/configurations.php b/application/controllers/web/configurations.php new file mode 100644 index 0000000..2dd0f99 --- /dev/null +++ b/application/controllers/web/configurations.php @@ -0,0 +1,31 @@ +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); + } +} \ No newline at end of file diff --git a/application/controllers/web/projects.php b/application/controllers/web/projects.php new file mode 100644 index 0000000..a09801b --- /dev/null +++ b/application/controllers/web/projects.php @@ -0,0 +1,83 @@ +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; + } + +} diff --git a/application/language/english/form_validation_lang.php b/application/language/english/form_validation_lang.php new file mode 100644 index 0000000..ca9df3a --- /dev/null +++ b/application/language/english/form_validation_lang.php @@ -0,0 +1,6 @@ + + + + + Configuration <?=$name?> + + + +
+
+ + + + + + + + + + +
+ Konfigurationsdetails +
ID
Name
+
+
+ + + + + + + +
Beschreibung
+
+
+ + diff --git a/application/views/web/projects/create.php b/application/views/web/projects/create.php new file mode 100644 index 0000000..3c208a6 --- /dev/null +++ b/application/views/web/projects/create.php @@ -0,0 +1,40 @@ + + + + + Create Project + + + +
+
+ + + + + + + + + + + + + + +
Create a new project
+ Name: + + +
+ Beschreibung: + + +
+ +
+ +
+
+ + diff --git a/application/views/web/projects/detail.php b/application/views/web/projects/detail.php new file mode 100644 index 0000000..3717d38 --- /dev/null +++ b/application/views/web/projects/detail.php @@ -0,0 +1,41 @@ + + + + + + Project <?=$name?> + + + +
+
+ + + + + + + + + + + + + + +
Projektdetails
ID
Name
Beschreibung
+
+
+ + + + + +
Konfigurationen
+
+
+ + diff --git a/application/views/web/projects/list.php b/application/views/web/projects/list.php new file mode 100644 index 0000000..c8bfbfa --- /dev/null +++ b/application/views/web/projects/list.php @@ -0,0 +1,24 @@ + + + + + List of projects + + + + + + + + + + + + + + + + +
idnameowner
+ +