From d9121598aa6bfbdd1e0a956af6e7c5e2a76f5735 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Mon, 8 Mar 2010 13:51:36 +0000 Subject: [PATCH] enhanced the wiki controller renamed 'source' to 'code' created the incomplete issue controller. --- codepot/etc/codepot.sql | 21 + codepot/src/codepot/controllers/Makefile.am | 3 +- codepot/src/codepot/controllers/Makefile.in | 3 +- codepot/src/codepot/controllers/api.php | 13 + .../controllers/{source.php => code.php} | 30 +- codepot/src/codepot/controllers/issue.php | 363 ++++++++++++++++++ codepot/src/codepot/controllers/project.php | 2 + codepot/src/codepot/controllers/site.php | 2 + codepot/src/codepot/controllers/wiki.php | 112 ++++-- .../codepot/language/english/common_lang.php | 13 +- .../language/indonesian/common_lang.php | 13 +- .../codepot/language/korean/common_lang.php | 15 +- codepot/src/codepot/models/Makefile.am | 1 + codepot/src/codepot/models/Makefile.in | 1 + codepot/src/codepot/models/issuemodel.php | 114 ++++++ codepot/src/codepot/views/Makefile.am | 14 +- codepot/src/codepot/views/Makefile.in | 14 +- .../{source_blame.php => code_blame.php} | 54 +-- .../views/{source_diff.php => code_diff.php} | 44 +-- .../views/{source_file.php => code_file.php} | 50 +-- .../{source_folder.php => code_folder.php} | 40 +- .../{source_history.php => code_history.php} | 34 +- ...{source_revision.php => code_revision.php} | 44 +-- codepot/src/codepot/views/issue_edit.php | 88 +++++ codepot/src/codepot/views/issue_home.php | 68 ++++ codepot/src/codepot/views/log.php | 4 +- codepot/src/codepot/views/project_home.php | 2 +- codepot/src/codepot/views/projectbar.php | 5 +- codepot/src/codepot/views/site_home.php | 20 +- codepot/src/css/project.css | 76 ++-- 30 files changed, 1016 insertions(+), 247 deletions(-) rename codepot/src/codepot/controllers/{source.php => code.php} (92%) create mode 100644 codepot/src/codepot/controllers/issue.php create mode 100644 codepot/src/codepot/models/issuemodel.php rename codepot/src/codepot/views/{source_blame.php => code_blame.php} (69%) rename codepot/src/codepot/views/{source_diff.php => code_diff.php} (79%) rename codepot/src/codepot/views/{source_file.php => code_file.php} (72%) rename codepot/src/codepot/views/{source_folder.php => code_folder.php} (79%) rename codepot/src/codepot/views/{source_history.php => code_history.php} (78%) rename codepot/src/codepot/views/{source_revision.php => code_revision.php} (63%) create mode 100644 codepot/src/codepot/views/issue_edit.php create mode 100644 codepot/src/codepot/views/issue_home.php diff --git a/codepot/etc/codepot.sql b/codepot/etc/codepot.sql index 9d72a071..e01ea4b6 100644 --- a/codepot/etc/codepot.sql +++ b/codepot/etc/codepot.sql @@ -50,6 +50,27 @@ CREATE TABLE wiki ( ON DELETE RESTRICT ON UPDATE CASCADE ) charset=utf8 engine=InnoDB; +CREATE TABLE issue ( + projectid VARCHAR(32) NOT NULL, +# id BIGINT NOT NULL AUTO_INCREMENT, + id BIGINT NOT NULL, + summary VARCHAR(255) NOT NULL, + type VARCHAR(32) NOT NULL, + status VARCHAR(32) NOT NULL, + assignedto VARCHAR(255) NOT NULL, + description TEXT NOT NULL, + + createdon DATETIME, + updatedon DATETIME, + createdby VARCHAR(32), + updatedby VARCHAR(32), + + PRIMARY KEY (projectid, id), + UNIQUE KEY issue_id (projectid, summary), + + CONSTRAINT issue_projectid FOREIGN KEY (projectid) REFERENCES project(id) + ON DELETE RESTRICT ON UPDATE CASCADE +) charset=utf8 engine=InnoDB; CREATE TABLE file ( projectid VARCHAR(32) NOT NULL, diff --git a/codepot/src/codepot/controllers/Makefile.am b/codepot/src/codepot/controllers/Makefile.am index fcf9eaa5..872b768c 100644 --- a/codepot/src/codepot/controllers/Makefile.am +++ b/codepot/src/codepot/controllers/Makefile.am @@ -1,12 +1,13 @@ wwwdir=$(WWWDIR)/codepot/controllers www_DATA = \ api.php \ + code.php \ file.php \ index.html \ + issue.php \ main.php \ project.php \ site.php \ - source.php \ wiki.php EXTRA_DIST = $(www_DATA) diff --git a/codepot/src/codepot/controllers/Makefile.in b/codepot/src/codepot/controllers/Makefile.in index 3de51c05..fbeaaaf6 100644 --- a/codepot/src/codepot/controllers/Makefile.in +++ b/codepot/src/codepot/controllers/Makefile.in @@ -164,12 +164,13 @@ top_srcdir = @top_srcdir@ wwwdir = $(WWWDIR)/codepot/controllers www_DATA = \ api.php \ + code.php \ file.php \ index.html \ + issue.php \ main.php \ project.php \ site.php \ - source.php \ wiki.php EXTRA_DIST = $(www_DATA) diff --git a/codepot/src/codepot/controllers/api.php b/codepot/src/codepot/controllers/api.php index a1b49600..0fa41cd5 100644 --- a/codepot/src/codepot/controllers/api.php +++ b/codepot/src/codepot/controllers/api.php @@ -7,8 +7,17 @@ class API extends Controller parent::Controller(); } + function check_access () + { + $server_name = $_SERVER['SERVER_NAME']; + if ($server_name != 'localhost' && + $server_name != '127.0.0.1') die; + } + function projectHasMember ($projectid, $userid) { + $this->check_access (); + if (!isset($projectid) || !isset($userid)) return 'NO'; // TODO: access control - may allow localhost only @@ -18,6 +27,8 @@ class API extends Controller function projectIsOwnedBy ($projectid, $userid) { + $this->check_access (); + if (!isset($projectid) || !isset($userid)) return 'NO'; // TODO: access control - may allow localhost only @@ -27,6 +38,8 @@ class API extends Controller function logCodeCommit ($type, $repo, $rev) { + $this->check_access (); + if (!isset($repo) || !isset($rev)) return; // TODO: access control - may allow localhost only diff --git a/codepot/src/codepot/controllers/source.php b/codepot/src/codepot/controllers/code.php similarity index 92% rename from codepot/src/codepot/controllers/source.php rename to codepot/src/codepot/controllers/code.php index 9f124495..f3956f8c 100644 --- a/codepot/src/codepot/controllers/source.php +++ b/codepot/src/codepot/controllers/code.php @@ -1,16 +1,16 @@ load->helper ('url'); @@ -39,6 +39,7 @@ class Source extends Controller $path = $this->converter->HexToAscii ($path); if ($path == '.') $path = ''; /* treat a period specially */ + $path = $this->_normalize_path ($path); $project = $this->projects->get ($projectid); if ($project === FALSE) @@ -113,6 +114,7 @@ class Source extends Controller $path = $this->converter->HexToAscii ($path); if ($path == '.') $path = ''; /* treat a period specially */ + $path = $this->_normalize_path ($path); $project = $this->projects->get ($projectid); if ($project === FALSE) @@ -174,6 +176,7 @@ class Source extends Controller $path = $this->converter->HexToAscii ($path); if ($path == '.') $path = ''; /* treat a period specially */ + $path = $this->_normalize_path ($path); $project = $this->projects->get ($projectid); if ($project === FALSE) @@ -225,6 +228,7 @@ class Source extends Controller $path = $this->converter->HexToAscii ($path); if ($path == '.') $path = ''; /* treat a period specially */ + $path = $this->_normalize_path ($path); $project = $this->projects->get ($projectid); if ($project === FALSE) @@ -275,6 +279,8 @@ class Source extends Controller $data['login'] = $login; $path = $this->converter->HexToAscii ($path); + if ($path == '.') $path = ''; /* treat a period specially */ + $path = $this->_normalize_path ($path); $project = $this->projects->get ($projectid); if ($project === FALSE) @@ -318,4 +324,12 @@ class Source extends Controller } } } + + function _normalize_path ($path) + { + $path = preg_replace('/[\/]+/', '/', $path); + if ($path == '/') $path = ''; + return $path; + } + } diff --git a/codepot/src/codepot/controllers/issue.php b/codepot/src/codepot/controllers/issue.php new file mode 100644 index 00000000..2676cf6b --- /dev/null +++ b/codepot/src/codepot/controllers/issue.php @@ -0,0 +1,363 @@ +load->helper ('url'); + $this->load->helper ('form'); + $this->load->library ('Converter', 'converter'); + $this->load->model (CODEPOT_LOGIN_MODEL, 'login'); + + $this->load->library ('Language', 'lang'); + $this->lang->load ('common', CODEPOT_LANG); + + } + + function home ($projectid = '') + { + $this->load->model ('ProjectModel', 'projects'); + $this->load->model ('IssueModel', 'issues'); + + $login = $this->login->getUser (); + if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '') + redirect ('main/signin'); + $data['login'] = $login; + + $project = $this->projects->get ($projectid); + if ($project === FALSE) + { + $data['message'] = 'DATABASE ERROR'; + $this->load->view ($this->VIEW_ERROR, $data); + } + else if ($project === NULL) + { + $data['message'] = + $this->lang->line('MSG_NO_SUCH_PROJECT') . + " - {$projectid}"; + $this->load->view ($this->VIEW_ERROR, $data); + } + else + { + $issues = $this->issues->getAll ($login['id'], $project); + if ($issues === FALSE) + { + $data['message'] = 'DATABASE ERROR'; + $this->load->view ($this->VIEW_ERROR, $data); + } + else + { + $data['project'] = $project; + $data['issues'] = $issues; + $this->load->view ($this->VIEW_HOME, $data); + } + } + } + + function _show_issue ($projectid, $name, $create) + { + $this->load->model ('ProjectModel', 'projects'); + $this->load->model ('IssueModel', 'issues'); + + $login = $this->login->getUser (); + if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '') + redirect ('main/signin'); + $data['login'] = $login; + + if ($name == '') + { + $data['message'] = 'INVALID PARAMETERS'; + $this->load->view ($this->VIEW_ERROR, $data); + return; + } + + $name = $this->converter->HexToAscii ($name); + + $project = $this->projects->get ($projectid); + if ($project === FALSE) + { + $data['message'] = 'DATABASE ERROR'; + $this->load->view ($this->VIEW_ERROR, $data); + } + else if ($project === NULL) + { + $data['message'] = + $this->lang->line('MSG_NO_SUCH_PROJECT') . + " - {$projectid}"; + $this->load->view ($this->VIEW_ERROR, $data); + } + else + { + $issue = $this->issues->get ($login['id'], $project, $name); + if ($issue === FALSE) + { + $data['message'] = 'DATABASE ERROR'; + $this->load->view ($this->VIEW_ERROR, $data); + } + else if ($issue === NULL) + { + if ($create) + { + redirect ("issue/create/{$projectid}/". + $this->converter->AsciiToHex($name)); + } + else + { + $data['message'] = + $this->lang->line('MSG_NO_SUCH_ISSUE') . + " - {$name}"; + $this->load->view ($this->VIEW_ERROR, $data); + } + } + else + { + $data['project'] = $project; + $data['issue'] = $issue; + $this->load->view ($this->VIEW_SHOW, $data); + } + } + } + + function show ($projectid = '' , $name = '') + { + $this->_show_issue ($projectid, $name, TRUE); + } + + function show_r ($projectid = '' , $name = '') + { + $this->_show_issue ($projectid, $name, FALSE); + } + + function _edit_issue ($projectid, $name, $mode) + { + $this->load->helper ('form'); + $this->load->library ('form_validation'); + $this->load->model ('ProjectModel', 'projects'); + $this->load->model ('IssueModel', 'issues'); + + $login = $this->login->getUser (); + if ($login['id'] == '') redirect ('main'); + $data['login'] = $login; + + $name = $this->converter->HexToAscii ($name); + + $project = $this->projects->get ($projectid); + if ($project === FALSE) + { + $data['message'] = 'DATABASE ERROR'; + $this->load->view ($this->VIEW_ERROR, $data); + } + else if ($project === NULL) + { + $data['message'] = + $this->lang->line('MSG_NO_SUCH_PROJECT') . + " - {$projectid}"; + $this->load->view ($this->VIEW_ERROR, $data); + } + else if (!$login['sysadmin?'] && + $this->projects->projectHasMember($project->id, $login['id']) === FALSE) + { + $data['message'] = "NO PERMISSION - $projectid"; + $this->load->view ($this->VIEW_ERROR, $data); + } + else + { + $this->form_validation->set_rules ( + 'issue_projectid', 'project ID', 'required|alpha_dash|max_length[32]'); + $this->form_validation->set_rules ( + 'issue_name', 'name', 'required|max_length[255]'); + $this->form_validation->set_rules ( + 'issue_text', 'text', 'required'); + $this->form_validation->set_error_delimiters ( + '',''); + + $data['mode'] = $mode; + $data['message'] = ''; + $data['project'] = $project; + + if ($this->input->post('issue')) + { + $issue->projectid = $this->input->post('issue_projectid'); + $issue->name = $this->input->post('issue_name'); + $issue->text = $this->input->post('issue_text'); + + if ($this->form_validation->run()) + { + $result = ($mode == 'update')? + $this->issues->update ($login['id'], $issue): + $this->issues->create ($login['id'], $issue); + if ($result === FALSE) + { + $data['message'] = 'DATABASE ERROR'; + $data['issue'] = $issue; + $this->load->view ($this->VIEW_EDIT, $data); + } + else + { + redirect ('issue/show/' . $project->id . '/' . + $this->converter->AsciiToHex($issue->name)); + } + } + else + { + $data['message'] = "Your input is not complete, Bro"; + $data['issue'] = $issue; + $this->load->view ($this->VIEW_EDIT, $data); + } + } + else + { + if ($mode == 'update') + { + $issue = $this->issues->get ($login['id'], $project, $name); + if ($issue === FALSE) + { + $data['message'] = 'DATABASE ERROR'; + $this->load->view ($this->VIEW_ERROR, $data); + } + else if ($issue == NULL) + { + $data['message'] = + $this->lang->line('MSG_NO_SUCH_ISSUE') . + " - {$name}"; + $this->load->view ($this->VIEW_ERROR, $data); + } + else + { + $data['issue'] = $issue; + $this->load->view ($this->VIEW_EDIT, $data); + } + } + else + { + $issue->projectid = $projectid; + $issue->name = $name; + $issue->text = ''; + + $data['issue'] = $issue; + $this->load->view ($this->VIEW_EDIT, $data); + } + } + + } + } + + function create ($projectid = '', $name = '') + { + return $this->_edit_issue ($projectid, $name, 'create'); + } + + function update ($projectid = '', $name = '') + { + return $this->_edit_issue ($projectid, $name, 'update'); + } + + function delete ($projectid = '', $name = '') + { + $this->load->helper ('form'); + $this->load->library ('form_validation'); + $this->load->model ('ProjectModel', 'projects'); + $this->load->model ('IssueModel', 'issues'); + + $login = $this->login->getUser (); + if ($login['id'] == '') redirect ('main'); + $data['login'] = $login; + + $name = $this->converter->HexToAscii ($name); + + $project = $this->projects->get ($projectid); + if ($project === FALSE) + { + $data['message'] = 'DATABASE ERROR'; + $this->load->view ($this->VIEW_ERROR, $data); + } + else if ($project === NULL) + { + $data['message'] = + $this->lang->line('MSG_NO_SUCH_PROJECT') . + " - {$projectid}"; + $this->load->view ($this->VIEW_ERROR, $data); + } + else if (!$login['sysadmin?'] && + $this->projects->projectHasMember($project->id, $login['id']) === FALSE) + { + $data['message'] = "NO PERMISSION - $projectid"; + $this->load->view ($this->VIEW_ERROR, $data); + } + else + { + $data['message'] = ''; + $data['project'] = $project; + + $this->form_validation->set_rules ('issue_confirm', 'confirm', 'alpha'); + $this->form_validation->set_error_delimiters('',''); + + if($this->input->post('issue')) + { + $issue->projectid = $this->input->post('issue_projectid'); + $issue->name = $this->input->post('issue_name'); + $data['issue_confirm'] = $this->input->post('issue_confirm'); + + if ($this->form_validation->run()) + { + if ($data['issue_confirm'] == 'yes') + { + $result = $this->issues->delete ($login['id'], $issue); + if ($result === FALSE) + { + $data['message'] = 'DATABASE ERROR'; + $data['issue'] = $issue; + $this->load->view ($this->VIEW_DELETE, $data); + } + else + { + redirect ("issue/home/{$project->id}"); + } + } + else + { + redirect ("issue/show/{$project->id}/" . + $this->converter->AsciiToHex($issue->name)); + } + } + else + { + $data['message'] = "Your input is not complete, Bro."; + $data['issue'] = $issue; + $this->load->view ($this->VIEW_DELETE, $data); + } + } + else + { + $issue = $this->issues->get ($login['id'], $project, $name); + if ($issue === FALSE) + { + $data['message'] = 'DATABASE ERROR'; + $this->load->view ($this->VIEW_ERROR, $data); + } + else if ($issue === NULL) + { + $data['message'] = + $this->lang->line('MSG_NO_SUCH_ISSUE') . + " - {$name}"; + $this->load->view ($this->VIEW_ERROR, $data); + } + else + { + $data['issue_confirm'] = 'no'; + $data['issue'] = $issue; + $this->load->view ($this->VIEW_DELETE, $data); + } + } + + } + } +} diff --git a/codepot/src/codepot/controllers/project.php b/codepot/src/codepot/controllers/project.php index b5fd998a..185ac894 100644 --- a/codepot/src/codepot/controllers/project.php +++ b/codepot/src/codepot/controllers/project.php @@ -327,6 +327,8 @@ class Project extends Controller $pagecfg['total_rows'] = $num_log_entries; $pagecfg['per_page'] = CODEPOT_MAX_LOGS_PER_PAGE; $pagecfg['uri_segment'] = 4; + $pagecfg['first_link'] = $this->lang->line('First'); + $pagecfg['last_link'] = $this->lang->line('Last'); $log_entries = $this->logs->getEntries ($offset, $pagecfg['per_page'], $projectid); if ($log_entries === FALSE) diff --git a/codepot/src/codepot/controllers/site.php b/codepot/src/codepot/controllers/site.php index 999f5d7a..7b4e50e4 100644 --- a/codepot/src/codepot/controllers/site.php +++ b/codepot/src/codepot/controllers/site.php @@ -314,6 +314,8 @@ class Site extends Controller $pagecfg['total_rows'] = $num_log_entries; $pagecfg['per_page'] = CODEPOT_MAX_LOGS_PER_PAGE; $pagecfg['uri_segment'] = 3; + $pagecfg['first_link'] = $this->lang->line('First'); + $pagecfg['last_link'] = $this->lang->line('Last'); $log_entries = $this->logs->getEntries ($offset, $pagecfg['per_page']); if ($log_entries === FALSE) diff --git a/codepot/src/codepot/controllers/wiki.php b/codepot/src/codepot/controllers/wiki.php index 1445856b..343db79d 100644 --- a/codepot/src/codepot/controllers/wiki.php +++ b/codepot/src/codepot/controllers/wiki.php @@ -96,26 +96,55 @@ class Wiki extends Controller } else { - if ($name == '__PROJECT_HOME__') + if ($this->_is_reserved ($name, TRUE)) { - redirect ("project/home/{$projectid}"); - } - else if ($name == '__WIKI_HOME__') - { - redirect ("wiki/home/{$projectid}"); + $ex0 = $this->_trans_reserved ($name); + redirect ("{$ex0}/home/{$projectid}"); } else { $ex = explode (':', $name); - if (count($ex) == 2) + $cnt = count($ex); + if ($cnt == 2) { - if ($ex[0] == '__PROJECT_HOME__') + if ($this->_is_reserved ($ex[0], TRUE)) { - redirect ("project/home/{$ex[1]}"); + $ex0 = $this->_trans_reserved ($ex[0]); + $ex1 = ($ex[1] == '')? $projectid: $ex[1]; + redirect ("{$ex0}/home/{$ex1}"); } - else if ($ex[0] == '__WIKI_HOME__') + } + else if ($cnt == 3) + { + if ($this->_is_reserved ($ex[0], TRUE) && + $ex[0] != '__PROJECT__' && $ex[0] != '__CODE__') { - redirect ("wiki/home/{$ex[1]}"); + $ex0 = $this->_trans_reserved ($ex[0]); + $ex1 = ($ex[1] == '')? $projectid: $ex[1]; + $ex2 = $this->converter->AsciiToHex ($ex[2]); + redirect ("{$ex0}/show/{$ex1}/{$ex2}"); + } + } + else if ($cnt == 4) + { + if ($ex[0] == '__CODE__') + { + $ex0 = $this->_trans_reserved ($ex[0]); + $ex1 = ($ex[1] == '')? $projectid: $ex[1]; + if ($ex[2] == 'file' || $ex[2] == 'history' || + $ex[2] == 'blame' || $ex[2] == 'diff') + { + $ex3 = $this->converter->AsciiToHex ($ex[3]); + redirect ("{$ex0}/{$ex[2]}/{$ex1}/{$ex3}"); + } + else + { + $data['message'] = + "WRONG ACTION NAME FOR CODE - {$name}"; + $this->load->view ($this->VIEW_ERROR, $data); + + return; + } } } @@ -192,12 +221,6 @@ class Wiki extends Controller $data['message'] = "NO PERMISSION - $projectid"; $this->load->view ($this->VIEW_ERROR, $data); } - else if ($name == '__PROJECT_HOME__' || - $name == '__WIKI_HOME__') - { - $data['message'] = "RESERVED WIKI PAGE - $name "; - $this->load->view ($this->VIEW_ERROR, $data); - } else { $this->form_validation->set_rules ( @@ -221,19 +244,28 @@ class Wiki extends Controller if ($this->form_validation->run()) { - $result = ($mode == 'update')? - $this->wikis->update ($login['id'], $wiki): - $this->wikis->create ($login['id'], $wiki); - if ($result === FALSE) + if ($this->_is_reserved ($wiki->name, FALSE)) { - $data['message'] = 'DATABASE ERROR'; + $data['message'] = "RESERVED WIKI NAME - {$wiki->name}"; $data['wiki'] = $wiki; - $this->load->view ($this->VIEW_EDIT, $data); + $this->load->view ($this->VIEW_EDIT, $data); } else { - redirect ('wiki/show/' . $project->id . '/' . - $this->converter->AsciiToHex($wiki->name)); + $result = ($mode == 'update')? + $this->wikis->update ($login['id'], $wiki): + $this->wikis->create ($login['id'], $wiki); + if ($result === FALSE) + { + $data['message'] = 'DATABASE ERROR'; + $data['wiki'] = $wiki; + $this->load->view ($this->VIEW_EDIT, $data); + } + else + { + redirect ("wiki/show/{$project->id}/" . + $this->converter->AsciiToHex($wiki->name)); + } } } else @@ -280,6 +312,31 @@ class Wiki extends Controller } } + function _trans_reserved ($name) + { + return substr (strtolower ($name), 2, strlen($name) - 4); + } + + function _is_reserved ($name, $exact) + { + if ($exact) + { + return $name == '__PROJECT__' || + $name == '__WIKI__' || + $name == '__FILE__' || + $name == '__CODE__' || + $name == '__ISSUE__'; + } + else + { + return substr ($name, 0, 11) == '__PROJECT__' || + substr ($name, 0, 8) == '__WIKI__' || + substr ($name, 0, 8) == '__FILE__' || + substr ($name, 0, 8) == '__CODE__' || + substr ($name, 0, 9) == '__ISSUE__'; + } + } + function create ($projectid = '', $name = '') { return $this->_edit_wiki ($projectid, $name, 'create'); @@ -322,15 +379,14 @@ class Wiki extends Controller $data['message'] = "NO PERMISSION - $projectid"; $this->load->view ($this->VIEW_ERROR, $data); } - else if ($name == '__PROJECT_HOME__' || - $name == '__WIKI_HOME__') + else if ($this->_is_reserved ($name, FALSE)) { $data['message'] = "RESERVED WIKI PAGE - $name "; $this->load->view ($this->VIEW_ERROR, $data); } else { - $data['message'] = ""; + $data['message'] = ''; $data['project'] = $project; $this->form_validation->set_rules ('wiki_confirm', 'confirm', 'alpha'); diff --git a/codepot/src/codepot/language/english/common_lang.php b/codepot/src/codepot/language/english/common_lang.php index 2d3809c2..ccfa1ec3 100644 --- a/codepot/src/codepot/language/english/common_lang.php +++ b/codepot/src/codepot/language/english/common_lang.php @@ -16,13 +16,17 @@ $lang['Directory'] = 'Directory'; $lang['Download'] = 'Download'; $lang['Edit'] = 'Edit'; $lang['Error'] = 'Error'; +$lang['File'] = 'File'; +$lang['Files'] = 'Files'; +$lang['First'] = 'First'; +$lang['Folder'] = 'Folder'; $lang['Head revision'] = 'Head revision'; $lang['History'] = 'History'; $lang['Home'] = 'Home'; -$lang['File'] = 'File'; -$lang['Files'] = 'Files'; -$lang['Folder'] = 'Folder'; $lang['ID'] = 'ID'; +$lang['Issue'] = 'Issue'; +$lang['Issues'] = 'Issues'; +$lang['Last'] = 'Last'; $lang['MD5'] = 'MD5'; $lang['Member'] = 'Member'; $lang['Members'] = 'Members'; @@ -62,8 +66,9 @@ $lang['MSG_LOG_DELETE_BY'] = 'Deleted by %s'; $lang['MSG_LOG_UPDATE_BY'] = 'Updated by %s'; $lang['MSG_NO_DIFF'] = 'No difference found'; +$lang['MSG_NO_CODE_AVAIL'] = 'No source code available'; $lang['MSG_NO_FILES_AVAIL'] = 'No files available'; -$lang['MSG_NO_SOURCE_CODE_AVAIL'] = 'No source code available'; +$lang['MSG_NO_ISSUES_AVAIL'] = 'No outstanding issues'; $lang['MSG_NO_SUCH_PROJECT'] = 'No such project'; $lang['MSG_NO_SUCH_WIKI_PAGE'] = 'No such wiki page'; $lang['MSG_NO_WIKIS_AVAIL'] = 'No wiki pages available'; diff --git a/codepot/src/codepot/language/indonesian/common_lang.php b/codepot/src/codepot/language/indonesian/common_lang.php index d00de863..7cdb095c 100644 --- a/codepot/src/codepot/language/indonesian/common_lang.php +++ b/codepot/src/codepot/language/indonesian/common_lang.php @@ -16,13 +16,17 @@ $lang['Directory'] = 'Direktori'; $lang['Download'] = 'Download'; $lang['Edit'] = 'Rubah'; $lang['Error'] = 'Error'; +$lang['File'] = 'File'; +$lang['Files'] = 'File'; +$lang['First'] = 'Pertama'; +$lang['Folder'] = 'Folder'; $lang['Head revision'] = 'Kepala revisi'; $lang['History'] = 'Sejarah'; $lang['Home'] = 'Beranda'; -$lang['File'] = 'File'; -$lang['Files'] = 'File'; -$lang['Folder'] = 'Folder'; $lang['ID'] = 'ID'; +$lang['Issue'] = 'Issue'; +$lang['Issues'] = 'Issue'; +$lang['Last'] = 'Terakhir'; $lang['MD5'] = 'MD5'; $lang['Member'] = 'Anggota'; $lang['Members'] = 'Anggota'; @@ -61,8 +65,9 @@ $lang['MSG_LOG_DELETE_BY'] = 'Dihapus oleh %s'; $lang['MSG_LOG_UPDATE_BY'] = 'Diupdate oleh %s'; $lang['MSG_NO_DIFF'] = 'Tidak ada bedanya'; +$lang['MSG_NO_CODE_AVAIL'] = 'Tidak ada kode sumber tersedia'; $lang['MSG_NO_FILES_AVAIL'] = 'Tidak ada file tersedia'; -$lang['MSG_NO_SOURCE_CODE_AVAIL'] = 'Tidak ada kode sumber tersedia'; +$lang['MSG_NO_ISSUES_AVAIL'] = 'Tidak ada issue'; $lang['MSG_NO_SUCH_PROJECT'] = 'No such project'; $lang['MSG_NO_SUCH_WIKI_PAGE'] = 'No such wiki page'; $lang['MSG_NO_WIKIS_AVAIL'] = 'Tidak ada halaman wiki tersedia'; diff --git a/codepot/src/codepot/language/korean/common_lang.php b/codepot/src/codepot/language/korean/common_lang.php index 5c5a09d4..77b63f80 100644 --- a/codepot/src/codepot/language/korean/common_lang.php +++ b/codepot/src/codepot/language/korean/common_lang.php @@ -16,13 +16,17 @@ $lang['Directory'] = '디렉토리'; $lang['Download'] = '내려받기'; $lang['Edit'] = '수정'; $lang['Error'] = '오류'; +$lang['File'] = '파일'; +$lang['Files'] = '파일'; +$lang['First'] = '처음'; +$lang['Folder'] = '폴더'; $lang['Head revision'] = '최신리비전'; $lang['History'] = '변경기록'; $lang['Home'] = '홈'; -$lang['File'] = '파일'; -$lang['Files'] = '파일'; -$lang['Folder'] = '폴더'; $lang['ID'] = '아이디'; +$lang['Issue'] = '이슈'; +$lang['Issues'] = '이슈'; +$lang['Last'] = '마지막'; $lang['MD5'] = 'MD5'; $lang['Member'] = '구성원'; $lang['Members'] = '구성원'; @@ -61,8 +65,9 @@ $lang['MSG_LOG_DELETE_BY'] = '%s에 의해 삭제되었습니다'; $lang['MSG_LOG_UPDATE_BY'] = '%s에 의해 갱신되었습니다'; $lang['MSG_NO_DIFF'] = '차이점이 없습니다'; -$lang['MSG_NO_FILES_AVAIL'] = '사용가능한 파일이 없습니다'; -$lang['MSG_NO_SOURCE_CODE_AVAIL'] = '사용가능한 소스코드가 없습니다'; +$lang['MSG_NO_CODE_AVAIL'] = '소스코드가 없습니다'; +$lang['MSG_NO_FILES_AVAIL'] = '파일이 없습니다'; +$lang['MSG_NO_ISSUES_AVAIL'] = '이슈항목이 없습니다'; $lang['MSG_NO_SUCH_PROJECT'] = '프로젝트가 없습니다'; $lang['MSG_NO_SUCH_WIKI_PAGE'] = '위키페이지가 없습니다'; $lang['MSG_NO_WIKIS_AVAIL'] = '사용가능한 위키페이지가 없습니다'; diff --git a/codepot/src/codepot/models/Makefile.am b/codepot/src/codepot/models/Makefile.am index 8149ca80..e24de072 100644 --- a/codepot/src/codepot/models/Makefile.am +++ b/codepot/src/codepot/models/Makefile.am @@ -2,6 +2,7 @@ wwwdir=$(WWWDIR)/codepot/models www_DATA = \ filemodel.php \ index.html \ + issuemodel.php \ ldaploginmodel.php \ loginmodel.php \ logmodel.php \ diff --git a/codepot/src/codepot/models/Makefile.in b/codepot/src/codepot/models/Makefile.in index 99b73f1f..0d7673eb 100644 --- a/codepot/src/codepot/models/Makefile.in +++ b/codepot/src/codepot/models/Makefile.in @@ -165,6 +165,7 @@ wwwdir = $(WWWDIR)/codepot/models www_DATA = \ filemodel.php \ index.html \ + issuemodel.php \ ldaploginmodel.php \ loginmodel.php \ logmodel.php \ diff --git a/codepot/src/codepot/models/issuemodel.php b/codepot/src/codepot/models/issuemodel.php new file mode 100644 index 00000000..d75e7a83 --- /dev/null +++ b/codepot/src/codepot/models/issuemodel.php @@ -0,0 +1,114 @@ +load->database (); + } + + function get ($userid, $project, $id) + { + $this->db->trans_start (); + $this->db->where ('projectid', $project->id); + $this->db->where ('id', $id); + $query = $this->db->get ('issue'); + $this->db->trans_complete (); + + if ($this->db->trans_status() === FALSE) return FALSE; + + $result = $query->result (); + return empty($result)? NULL: $result[0]; + } + + function getAll ($userid, $project) + { + $this->db->trans_start (); + $this->db->where ('projectid', $project->id); + $query = $this->db->get ('issue'); + $this->db->trans_complete (); + + if ($this->db->trans_status() === FALSE) return FALSE; + return $query->result (); + } + + function create ($userid, $issue) + { + // TODO: check if userid can do this.. + $this->db->trans_start (); + $this->db->set ('projectid', $issue->projectid); + $this->db->set ('summary', $issue->summary); + $this->db->set ('type', $issue->type); + $this->db->set ('status', $issue->status); + $this->db->set ('description', $issue->description); + $this->db->set ('assignedto', $issue->assignedto); + $this->db->set ('createdon', date('Y-m-d H:i:s')); + $this->db->set ('updatedon', date('Y-m-d H:i:s')); + $this->db->set ('createdby', $userid); + $this->db->set ('updatedby', $userid); + $this->db->insert ('issue'); + + $this->db->set ('createdon', date('Y-m-d H:i:s')); + $this->db->set ('type', 'issue'); + $this->db->set ('action', 'create'); + $this->db->set ('projectid', $issue->projectid); + $this->db->set ('userid', $userid); + //$this->db->set ('message', 'LAST_INSERT_ID()'); + $this->db->set ('message', 'CONVERT(LAST_INSERT_ID(),CHAR)'); + $this->db->insert ('log'); + + $this->db->trans_complete (); + return $this->db->trans_status(); + } + + function update ($userid, $issue) + { + // TODO: check if userid can do this.. + $this->db->trans_start (); + $this->db->where ('projectid', $issue->projectid); + $this->db->where ('id', $issue->id); + $this->db->set ('summary', $issue->summary); + $this->db->set ('type', $issue->type); + $this->db->set ('status', $issue->status); + $this->db->set ('description', $issue->description); + $this->db->set ('assignedto', $issue->assignedto); + $this->db->set ('updatedon', date('Y-m-d H:i:s')); + $this->db->set ('updatedby', $userid); + $this->db->update ('issue'); + + $this->db->set ('createdon', date('Y-m-d H:i:s')); + $this->db->set ('type', 'issue'); + $this->db->set ('action', 'update'); + $this->db->set ('projectid', $issue->projectid); + $this->db->set ('userid', $userid); + $this->db->set ('message', $issue->id); + $this->db->insert ('log'); + + $this->db->trans_complete (); + return $this->db->trans_status(); + } + + function delete ($userid, $issue) + { + // TODO: check if userid can do this.. + $this->db->trans_start (); + $this->db->where ('projectid', $issue->projectid); + $this->db->where ('id', $issue->id); + $this->db->delete ('issue'); + + $this->db->set ('createdon', date('Y-m-d H:i:s')); + $this->db->set ('type', 'issue'); + $this->db->set ('action', 'delete'); + $this->db->set ('projectid', $issue->projectid); + $this->db->set ('userid', $userid); + $this->db->set ('message', $issue->id); + + $this->db->insert ('log'); + $this->db->trans_complete (); + return $this->db->trans_status(); + } + +} + +?> diff --git a/codepot/src/codepot/views/Makefile.am b/codepot/src/codepot/views/Makefile.am index 14a5880c..705696cc 100644 --- a/codepot/src/codepot/views/Makefile.am +++ b/codepot/src/codepot/views/Makefile.am @@ -1,12 +1,20 @@ wwwdir=$(WWWDIR)/codepot/views www_DATA = \ error.php \ + code_blame.php \ + code_diff.php \ + code_file.php \ + code_folder.php \ + code_history.php \ + code_revision.php \ file_delete.php \ file_edit.php \ file_home.php \ file_show.php \ footer.php \ index.html \ + issue_edit.php \ + issue_home.php \ log.php \ login.php \ project_delete.php \ @@ -17,12 +25,6 @@ www_DATA = \ site_edit.php \ site_delete.php \ site_home.php \ - source_blame.php \ - source_diff.php \ - source_file.php \ - source_folder.php \ - source_history.php \ - source_revision.php \ taskbar.php \ wiki_delete.php \ wiki_edit.php \ diff --git a/codepot/src/codepot/views/Makefile.in b/codepot/src/codepot/views/Makefile.in index 43ac6db5..4036304e 100644 --- a/codepot/src/codepot/views/Makefile.in +++ b/codepot/src/codepot/views/Makefile.in @@ -164,12 +164,20 @@ top_srcdir = @top_srcdir@ wwwdir = $(WWWDIR)/codepot/views www_DATA = \ error.php \ + code_blame.php \ + code_diff.php \ + code_file.php \ + code_folder.php \ + code_history.php \ + code_revision.php \ file_delete.php \ file_edit.php \ file_home.php \ file_show.php \ footer.php \ index.html \ + issue_edit.php \ + issue_home.php \ log.php \ login.php \ project_delete.php \ @@ -180,12 +188,6 @@ www_DATA = \ site_edit.php \ site_delete.php \ site_home.php \ - source_blame.php \ - source_diff.php \ - source_file.php \ - source_folder.php \ - source_history.php \ - source_revision.php \ taskbar.php \ wiki_delete.php \ wiki_edit.php \ diff --git a/codepot/src/codepot/views/source_blame.php b/codepot/src/codepot/views/code_blame.php similarity index 69% rename from codepot/src/codepot/views/source_blame.php rename to codepot/src/codepot/views/code_blame.php index 940d64a4..cefe7d6b 100644 --- a/codepot/src/codepot/views/source_blame.php +++ b/codepot/src/codepot/views/code_blame.php @@ -15,7 +15,7 @@ -
+
@@ -28,7 +28,7 @@ $this->load->view ( 'projectbar', array ( 'site' => NULL, - 'pageid' => 'source', + 'pageid' => 'code', 'ctxmenuitems' => array () ) ); @@ -36,9 +36,9 @@ $this->load->view ( -
+
-
+
load->view ( } print anchor ( - "/source/file/{$project->id}{$revreqroot}", + "code/file/{$project->id}{$revreqroot}", htmlspecialchars($project->name)); $exps = explode ('/', $headpath); @@ -67,13 +67,13 @@ $this->load->view ( if ($i == $expsize - 1) { print anchor ( - "source/blame/{$project->id}/{$xpar}{$revreq}", + "code/blame/{$project->id}/{$xpar}{$revreq}", htmlspecialchars($exps[$i])); } else { print anchor ( - "source/file/{$project->id}/{$xpar}{$revreq}", + "code/file/{$project->id}/{$xpar}{$revreq}", htmlspecialchars($exps[$i])); } } @@ -84,44 +84,44 @@ $this->load->view ( print htmlspecialchars($file['fullpath']); } ?> -
+
- -
- id}/${xpar}/{$file['prev_rev']}", '<<')?> +
+ id}/${xpar}/{$file['prev_rev']}", '<<')?> lang->line('Revision')?>: - id}/${xpar}/{$file['next_rev']}", '>>')?> | + id}/${xpar}/{$file['next_rev']}", '>>')?> | lang->line('Author')?>: | lang->line('Size')?>: | lang->line('Last updated on')?>:
-
+
-
+
 id}/{$xpar}", $this->lang->line('Histor
 			$rev_padded = str_pad ($rev, 6, ' ', STR_PAD_LEFT);
 	
 			$xpar = $this->converter->AsciiTohex ($headpath);
-			$rev_padded = anchor ("/source/blame/{$project->id}/{$xpar}/{$rev}", $rev_padded);
+			$rev_padded = anchor ("code/blame/{$project->id}/{$xpar}/{$rev}", $rev_padded);
 		}
 		else
 		{
@@ -167,11 +167,11 @@ print anchor ("source/history/{$project->id}/{$xpar}", $this->lang->line('Histor
 ?>
 
-
+