Merge branch 'master' of disposed.de:scattport
This commit is contained in:
@@ -4,7 +4,7 @@ class Jobs extends CI_Controller {
|
|||||||
|
|
||||||
public function getOwn() {
|
public function getOwn() {
|
||||||
$query = $this->db->order_by('progress', 'desc')
|
$query = $this->db->order_by('progress', 'desc')
|
||||||
->get_where('jobs', array('started_by' => $this->session->user_data('id')));
|
->get_where('jobs', array('started_by' => $this->session->user_data('user_id')));
|
||||||
$count = $query->num_rows();
|
$count = $query->num_rows();
|
||||||
$jobs = $query->result_array();
|
$jobs = $query->result_array();
|
||||||
|
|
||||||
@@ -39,7 +39,7 @@ class Jobs extends CI_Controller {
|
|||||||
|
|
||||||
public function listResultsNotSeen() {
|
public function listResultsNotSeen() {
|
||||||
$query = $this->db->order_by('started_at', 'asc')
|
$query = $this->db->order_by('started_at', 'asc')
|
||||||
->get_where('jobs', array('started_by' => $this->session->user_data('id'), 'seen' => '0'));
|
->get_where('jobs', array('started_by' => $this->session->user_data('user_id'), 'seen' => '0'));
|
||||||
$count = $query->num_rows();
|
$count = $query->num_rows();
|
||||||
$jobs = $query->result_array();
|
$jobs = $query->result_array();
|
||||||
|
|
||||||
|
|||||||
@@ -65,10 +65,10 @@ class Projects extends CI_Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function detail($projects, $area, $id) {
|
public function detail($projects, $area, $id) {
|
||||||
$result = $this->db->get_where('projects', array('id' => $id))->row_array();
|
$project = $this->project->get($id);
|
||||||
$this->output
|
$this->output
|
||||||
->set_content_type('application/json')
|
->set_content_type('application/json')
|
||||||
->set_output(json_encode(array('result' => $result)));
|
->set_output(json_encode($project));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class Project extends CI_Model {
|
|||||||
* @return array The user's projects.
|
* @return array The user's projects.
|
||||||
*/
|
*/
|
||||||
public function getOwn() {
|
public function getOwn() {
|
||||||
$query = $this->db->where(array('owner' => $this->session->user_data('id')))
|
$query = $this->db->where(array('owner' => $this->session->user_data('user_id')))
|
||||||
->order_by('lastaccess', 'desc')
|
->order_by('lastaccess', 'desc')
|
||||||
->get('projects');
|
->get('projects');
|
||||||
$projects = $query->result_array();
|
$projects = $query->result_array();
|
||||||
@@ -38,7 +38,7 @@ class Project extends CI_Model {
|
|||||||
* @return array The shared projects.
|
* @return array The shared projects.
|
||||||
*/
|
*/
|
||||||
public function getShared() {
|
public function getShared() {
|
||||||
$this->db->select('*')->from('shares')->order_by('lastaccess', 'desc')->where(array('user_id' => $this->session->user_data('id')));
|
$this->db->select('*')->from('shares')->order_by('lastaccess', 'desc')->where(array('user_id' => $this->session->user_data('user_id')));
|
||||||
$this->db->join('projects', 'projects.id = shares.project_id');
|
$this->db->join('projects', 'projects.id = shares.project_id');
|
||||||
$query = $this->db->get();
|
$query = $this->db->get();
|
||||||
|
|
||||||
@@ -80,6 +80,18 @@ class Project extends CI_Model {
|
|||||||
|
|
||||||
return $publicProjects;
|
return $publicProjects;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a specific project from the database.
|
||||||
|
*
|
||||||
|
* @param type $project_id The project to get.
|
||||||
|
*/
|
||||||
|
public function get($project_id) {
|
||||||
|
$result = $this->db->get_where('projects', array('id' => $project_id))->row_array();
|
||||||
|
|
||||||
|
$this->db->query('UPDATE `projects` SET `lastaccess` = NOW() WHERE `id`='.$this->db->escape($project_id).';');
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all available configurations from a specific project.
|
* Get all available configurations from a specific project.
|
||||||
@@ -102,21 +114,25 @@ class Project extends CI_Model {
|
|||||||
*/
|
*/
|
||||||
public function search($needle) {
|
public function search($needle) {
|
||||||
|
|
||||||
// get matching projects that are public or belong directly to the user
|
// get matching projects that are public
|
||||||
$query = $this->db->where('public','1')
|
$query = $this->db->query("SELECT * FROM `projects` WHERE `public`='1' AND `name` LIKE ".$this->db->escape('%'.$needle.'%'));
|
||||||
->or_where('owner', $this->session->userdata('id'))
|
$public_results = $query->result_array();
|
||||||
->like('name', $needle)->get('projects');
|
|
||||||
$results = $query->result_array();
|
// or belong directly to the user
|
||||||
|
$query = $this->db->query("SELECT * FROM `projects` WHERE `owner`=".$this->db->escape($this->session->userdata('user_id'))
|
||||||
|
." AND `name` LIKE ".$this->db->escape('%'.$needle.'%'));
|
||||||
|
$own_results = $query->result_array();
|
||||||
|
|
||||||
|
|
||||||
// get matching projects that are shared to the user
|
// get matching projects that are shared to the user
|
||||||
$this->db->select('*')->from('shares')
|
$this->db->select('*')->from('shares')
|
||||||
->where(array('user_id' => $this->session->userdata('id')))
|
->where(array('user_id' => $this->session->userdata('user_id')))
|
||||||
->like('name', $needle);
|
->like('name', $needle);
|
||||||
$this->db->join('projects', 'projects.id = shares.project_id');
|
$this->db->join('projects', 'projects.id = shares.project_id');
|
||||||
$query = $this->db->get();
|
$query = $this->db->get();
|
||||||
|
|
||||||
$own_results = $query->result_array();
|
$shared_results = $query->result_array();
|
||||||
|
|
||||||
return array_merge($results, $own_results);
|
return array_merge($own_results, $shared_results);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user