Add create() and delete() to project model

This commit is contained in:
Karsten Heiken
2011-05-08 20:00:27 +02:00
parent 4b0f9f8099
commit 0bfad8004d

View File

@@ -139,4 +139,30 @@ class Project extends CI_Model {
return array_merge($own_results, $shared_results);
}
/**
* Create a new project.
*
* @param array $data array with "name" and "description"
*/
public function create($data) {
$this->load->helper(array('hash', 'date'));
$data['owner'] = $this->session->userdata('user_id');
$data['created'] = mysql_now();
$data['lastaccess'] = mysql_now();
$data['id'] = random_hash();
return $this->db->insert('projects', $data);
}
/**
* Delete a project.
*
* There is no security check in here to verify if the user has the
* rights to do so. This needs to be done in the controller!
*/
public function delete($project_id) {
return $this->db->delete('projects', array('id' => $project_id));
}
}