Create directory structure when creating a project or trial
This commit is contained in:
@@ -27,17 +27,17 @@
|
|||||||
*/
|
*/
|
||||||
class Projects extends CI_Controller {
|
class Projects extends CI_Controller {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->load->model('project');
|
$this->load->model('project');
|
||||||
$this->load->model('trial');
|
$this->load->model('trial');
|
||||||
|
|
||||||
// load language file
|
// load language file
|
||||||
$this->lang->load(strtolower($this->router->class));
|
$this->lang->load(strtolower($this->router->class));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new project.
|
* Create a new project.
|
||||||
@@ -70,12 +70,9 @@ class Projects extends CI_Controller {
|
|||||||
$this->form_validation->set_rules($config);
|
$this->form_validation->set_rules($config);
|
||||||
|
|
||||||
|
|
||||||
if ($this->form_validation->run() == FALSE)
|
if ($this->form_validation->run() == FALSE) {
|
||||||
{
|
|
||||||
$this->load->view('project/new');
|
$this->load->view('project/new');
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO: handle file upload
|
// TODO: handle file upload
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
@@ -85,15 +82,23 @@ class Projects extends CI_Controller {
|
|||||||
'defaultconfig' => "todo",
|
'defaultconfig' => "todo",
|
||||||
);
|
);
|
||||||
|
|
||||||
$result = $this->project->create($data);
|
$data['project_id'] = $this->project->create($data);
|
||||||
if($result)
|
if ($data['project_id']) {
|
||||||
redirect('/projects/detail/' . $result, 301);
|
$userpath = FCPATH . 'uploads/' . $this->session->userdata('user_id') . '/';
|
||||||
else {
|
$projectpath = $userpath . $data['project_id'] . '/';
|
||||||
|
if (!is_dir($projectpath))
|
||||||
|
if(!is_dir($userpath))
|
||||||
|
mkdir($userpath, 0777);
|
||||||
|
mkdir($projectpath, 0777);
|
||||||
|
chmod($userpath, 0777);
|
||||||
|
chmod($projectpath, 0777);
|
||||||
|
$this->messages->add($projectpath, 'notice');
|
||||||
|
redirect('/projects/detail/' . $data['project_id'], 301);
|
||||||
|
} else {
|
||||||
$this->messages->add('Das Projekt konnte nicht gespeichert werden.', 'error');
|
$this->messages->add('Das Projekt konnte nicht gespeichert werden.', 'error');
|
||||||
$this->load->view('project/new');
|
$this->load->view('project/new');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index() {
|
public function index() {
|
||||||
@@ -105,7 +110,7 @@ class Projects extends CI_Controller {
|
|||||||
|
|
||||||
public function detail($prj_id) {
|
public function detail($prj_id) {
|
||||||
$project = $this->project->getById($prj_id);
|
$project = $this->project->getById($prj_id);
|
||||||
if(!$project) {
|
if (!$project) {
|
||||||
$this->messages->add('Das Projekt konnte nicht geladen werden.', 'error');
|
$this->messages->add('Das Projekt konnte nicht geladen werden.', 'error');
|
||||||
redirect('/projects/', 301);
|
redirect('/projects/', 301);
|
||||||
}
|
}
|
||||||
@@ -118,4 +123,5 @@ class Projects extends CI_Controller {
|
|||||||
$tpl['jobsDone'] = null;
|
$tpl['jobsDone'] = null;
|
||||||
$this->load->view('project/detail', $tpl);
|
$this->load->view('project/detail', $tpl);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,17 +30,17 @@
|
|||||||
class Trials extends CI_Controller {
|
class Trials extends CI_Controller {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->load->model('trial');
|
$this->load->model('trial');
|
||||||
$this->load->model('program');
|
$this->load->model('program');
|
||||||
$this->load->model('project');
|
$this->load->model('project');
|
||||||
|
|
||||||
// load language file
|
// load language file
|
||||||
// $this->lang->load(strtolower($this->router->class));
|
// $this->lang->load(strtolower($this->router->class));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new project.
|
* Create a new project.
|
||||||
@@ -52,7 +52,7 @@ class Trials extends CI_Controller {
|
|||||||
$programs = $this->program->getAll();
|
$programs = $this->program->getAll();
|
||||||
|
|
||||||
// Get the parameters for a specific program
|
// Get the parameters for a specific program
|
||||||
foreach($programs as $program)
|
foreach ($programs as $program)
|
||||||
$parameters[$program['id']] = $this->program->getParameters($program['id']);
|
$parameters[$program['id']] = $this->program->getParameters($program['id']);
|
||||||
|
|
||||||
$config = array(
|
$config = array(
|
||||||
@@ -71,14 +71,11 @@ class Trials extends CI_Controller {
|
|||||||
$this->form_validation->set_rules($config);
|
$this->form_validation->set_rules($config);
|
||||||
|
|
||||||
|
|
||||||
if ($this->form_validation->run() == FALSE)
|
if ($this->form_validation->run() == FALSE) {
|
||||||
{
|
|
||||||
$tpl['parameters'] = $parameters;
|
$tpl['parameters'] = $parameters;
|
||||||
$tpl['programs'] = $programs;
|
$tpl['programs'] = $programs;
|
||||||
$this->load->view('trial/new', $tpl);
|
$this->load->view('trial/new', $tpl);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// TODO: handle file upload
|
// TODO: handle file upload
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
@@ -89,13 +86,25 @@ class Trials extends CI_Controller {
|
|||||||
);
|
);
|
||||||
|
|
||||||
$result = $this->trial->create($data);
|
$result = $this->trial->create($data);
|
||||||
if($result)
|
if ($result) {
|
||||||
|
$userpath = FCPATH . 'uploads/' . $this->session->userdata('user_id') . '/';
|
||||||
|
$projectpath = $userpath . $data['project_id'] . '/';
|
||||||
|
$trialpath = $projectpath . $data['trial_id'] . '/';
|
||||||
|
if(!is_dir($trialpath))
|
||||||
|
if (!is_dir($projectpath))
|
||||||
|
if(!is_dir($userpath))
|
||||||
|
mkdir($userpath);
|
||||||
|
mkdir($projectpath);
|
||||||
|
mkdir($trialpath);
|
||||||
|
chmod($userpath, 0777);
|
||||||
|
chmod($projectpath, 0777);
|
||||||
|
chmod($trialpath, 0777);
|
||||||
|
|
||||||
redirect('/trial/detail/' . $result, 'refresh');
|
redirect('/trial/detail/' . $result, 'refresh');
|
||||||
else {
|
} else {
|
||||||
$tpl['error'][] = "Der Versuch konnte nicht gespeichert werden.";
|
$tpl['error'][] = "Der Versuch konnte nicht gespeichert werden.";
|
||||||
$this->load->view('trial/new', $tpl);
|
$this->load->view('trial/new', $tpl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user