Remove hash helper and use existing string helper instead

This commit is contained in:
Eike Foken
2011-09-21 01:08:43 +02:00
parent 11ee2107f6
commit 4439fa9dfe
11 changed files with 113 additions and 140 deletions

View File

@@ -182,26 +182,25 @@ class Project extends CI_Model {
}
/**
* Create a new project.
* Creates a new project.
*
* @param array $data array with "name" and "description"
* @param array $data An array with "name" and "description"
* @return mixed Returns the ID of the created project, or FALSE if the
* insert was unsuccessful.
*/
public function create($data) {
$this->load->helper(array('hash', 'date'));
$data['owner'] = $this->session->userdata('user_id');
$data['created'] = mysql_now();
$data['last_access'] = mysql_now();
do {
$data['id'] = random_hash();
do { // generate unique hash
$data['id'] = random_string('sha1', 40);
} while ($this->db->where('id', $data['id'])->from('projects')->count_all_results() > 0);
if ($this->db->insert('projects', $data)) {
return $data['id'];
} else {
return FALSE;
return false;
}
}