diff --git a/codepot/etc/codepot.mysql b/codepot/etc/codepot.mysql index c88d493c..d79f26cb 100644 --- a/codepot/etc/codepot.mysql +++ b/codepot/etc/codepot.mysql @@ -17,6 +17,7 @@ CREATE TABLE project ( name VARCHAR(255) UNIQUE NOT NULL, summary VARCHAR(255) NOT NULL, description TEXT NOT NULL, + commitable CHAR(1) NOT NULL DEFAULT 'Y', createdon DATETIME NOT NULL, updatedon DATETIME NOT NULL, diff --git a/codepot/etc/start-commit b/codepot/etc/start-commit index 6664d1e8..a100f14a 100755 --- a/codepot/etc/start-commit +++ b/codepot/etc/start-commit @@ -3,17 +3,17 @@ REPOBASE="`basename "${1}"`" USER="${2}" -ans="`wget -q -O- "%API%/projectHasMember/${REPOBASE}/${USER}" 2>/dev/null`" +ans="`wget -q -O- "%API%/projectIsCommitable/${REPOBASE}/${USER}" 2>/dev/null`" [ "${ans}" = "YES" ] && exit 0 [ "${ans}" = "NO" ] && { echo "-------------------------------------------------------------" >&2 - echo " ${USER} is not a member of ${REPOBASE}" >&2 + echo " ${REPOBASE} is read-only or ${USER} is not a member of ${REPOBASE}" >&2 echo "-------------------------------------------------------------" >&2 exit 1 } echo "---------------------------------------------------------------------" >&2 -echo " Failed to check membership of ${REPOBASE} for ${USER}" >&2 +echo " Failed to check commitability of ${REPOBASE} for ${USER}" >&2 echo "---------------------------------------------------------------------" >&2 exit 1 diff --git a/codepot/src/codepot/controllers/api.php b/codepot/src/codepot/controllers/api.php index b9a84d6a..9eb9f1ea 100644 --- a/codepot/src/codepot/controllers/api.php +++ b/codepot/src/codepot/controllers/api.php @@ -34,6 +34,18 @@ class API extends Controller print ($this->projects->projectIsOwnedBy ($projectid, $userid) === FALSE)? 'NO': 'YES'; } + function projectIsCommitable ($projectid, $userid) + { + $this->check_access (); + + if (!isset($projectid) || !isset($userid)) return 'NO'; + + $this->load->model ('ProjectModel', 'projects'); + print ($this->projects->projectIsOwnedBy ($projectid, $userid) === FALSE || + $this->projects->projectIsCommitable ($projectid) === FALSE)? 'NO': 'YES'; + } + + function logCodeCommit ($type, $repo, $rev) { $this->check_access (); diff --git a/codepot/src/codepot/controllers/project.php b/codepot/src/codepot/controllers/project.php index c113e58b..6d0918d2 100644 --- a/codepot/src/codepot/controllers/project.php +++ b/codepot/src/codepot/controllers/project.php @@ -168,6 +168,8 @@ class Project extends Controller 'project_summary', 'summary', 'required|max_length[255]'); $this->form_validation->set_rules ( 'project_description', 'description', 'required'); + $this->form_validation->set_rules ( + 'project_commitable', 'commitable', 'alpha'); $this->form_validation->set_rules ( 'project_members', 'members', 'required'); $this->form_validation->set_error_delimiters( @@ -187,6 +189,7 @@ class Project extends Controller $project->name = $this->input->post('project_name'); $project->summary = $this->input->post('project_summary'); $project->description = $this->input->post('project_description'); + $project->commitable = $this->input->post('project_commitable'); $project->members = $this->input->post('project_members'); // validate the form @@ -244,6 +247,7 @@ class Project extends Controller $project->name = ''; $project->summary = ''; $project->description = ''; + $project->commitable = 'Y'; $project->members = $login['id']; $this->_edit_project ($project, 'create', $login); diff --git a/codepot/src/codepot/language/english/common_lang.php b/codepot/src/codepot/language/english/common_lang.php index 778884a6..061fa377 100644 --- a/codepot/src/codepot/language/english/common_lang.php +++ b/codepot/src/codepot/language/english/common_lang.php @@ -11,6 +11,7 @@ $lang['Change log'] = 'Change log'; $lang['Code'] = 'Code'; $lang['Code changes'] = 'Code changes'; $lang['Comment'] = 'Comment'; +$lang['Commitable'] = 'Commitable'; $lang['Create'] = 'Create'; $lang['Created by'] = 'Created by'; $lang['Created on'] = 'Created on'; diff --git a/codepot/src/codepot/language/indonesian/common_lang.php b/codepot/src/codepot/language/indonesian/common_lang.php index 342272fb..da69bda5 100644 --- a/codepot/src/codepot/language/indonesian/common_lang.php +++ b/codepot/src/codepot/language/indonesian/common_lang.php @@ -9,6 +9,7 @@ $lang['Change log'] = 'Change log'; $lang['Code'] = 'Kode'; $lang['Code changes'] = 'Kode changes' $lang['Comment'] = 'Comment'; +$lang['Commitable'] = 'Commitable'; $lang['Create'] = 'Dibuat'; $lang['Created by'] = 'Dibuat oleh'; $lang['Created on'] = 'Waktu dibuat'; diff --git a/codepot/src/codepot/language/korean/common_lang.php b/codepot/src/codepot/language/korean/common_lang.php index 94aa1b41..07067b13 100644 --- a/codepot/src/codepot/language/korean/common_lang.php +++ b/codepot/src/codepot/language/korean/common_lang.php @@ -11,6 +11,7 @@ $lang['Change log'] = '변경기록'; $lang['Code'] = '코드'; $lang['Code changes'] = '코드변경'; $lang['Comment'] = '소견'; +$lang['Commitable'] = '커밋가능'; $lang['Create'] = '생성'; $lang['Created by'] = '최초생성인'; $lang['Created on'] = '최초생성시간'; diff --git a/codepot/src/codepot/models/projectmodel.php b/codepot/src/codepot/models/projectmodel.php index 611a322d..f1be016d 100644 --- a/codepot/src/codepot/models/projectmodel.php +++ b/codepot/src/codepot/models/projectmodel.php @@ -99,6 +99,7 @@ class ProjectModel extends Model $this->db->set ('name', $project->name); $this->db->set ('summary', $project->summary); $this->db->set ('description', $project->description); + $this->db->set ('commitable', $project->commitable); $this->db->set ('createdon', date('Y-m-d H:i:s')); $this->db->set ('createdby', $userid); $this->db->set ('updatedon', date('Y-m-d H:i:s')); @@ -207,6 +208,7 @@ class ProjectModel extends Model $this->db->set ('name', $project->name); $this->db->set ('summary', $project->summary); $this->db->set ('description', $project->description); + $this->db->set ('commitable', $project->commitable); $this->db->set ('updatedon', date('Y-m-d H:i:s')); $this->db->set ('updatedby', $userid); $this->db->update ('project'); @@ -422,6 +424,16 @@ class ProjectModel extends Model return ($count == 1)? TRUE: FALSE; } + function projectIsCommitable ($projectid) + { + $this->db->trans_start (); + $this->db->where ('id', $projectid); + $this->db->where ('commitable', 'Y'); + $count = $this->db->count_all_results ('project'); + $this->db->trans_complete (); + if ($this->db->trans_status() === FALSE) return FALSE; + return ($count == 1)? TRUE: FALSE; + } function _delete_files_uploaded ($files) { diff --git a/codepot/src/codepot/views/project_edit.php b/codepot/src/codepot/views/project_edit.php index 3c7b79f3..de81673c 100644 --- a/codepot/src/codepot/views/project_edit.php +++ b/codepot/src/codepot/views/project_edit.php @@ -104,6 +104,14 @@ $this->load->view ( +