forked from iamacarpet/cloud9php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprojects.php
More file actions
49 lines (42 loc) · 1.57 KB
/
projects.php
File metadata and controls
49 lines (42 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Projects extends CI_Model {
public function isUsersProject($projectid, $userid){
$query = $this->db->query("SELECT ID FROM projects WHERE ID = " . $this->db->escape($projectid) . " AND UserID = " . $this->db->escape($userid));
if ($query->num_rows() > 0){
return true;
} else {
return false;
}
}
public function getProjName($projectid){
$query = $this->db->query("SELECT ProjectName FROM projects WHERE ID = " . $this->db->escape($projectid));
if ($query->num_rows() > 0){
$row = $query->row_array();
return $row['ProjectName'];
} else {
return false;
}
}
public function checkProjDir($projectid){
if ($this->c9config->checkWorkspaceDir()){
if ($this->isUsersProject($projectid, $this->c9auth->currUserID())){
if (is_dir($this->localProjDir($projectid))){
return true;
} else {
if (mkdir($this->localProjDir($projectid), 0755)){
return true;
} else {
return false;
}
}
} else {
return false;
}
} else {
return false;
}
}
public function localProjDir($projectid){
return $this->c9config->currWorkspaceDir() . '/' . $this->getProjName($projectid);
}
}