diff --git a/codepot/README b/codepot/README
index 7cf63a3b..f2b5d510 100644
--- a/codepot/README
+++ b/codepot/README
@@ -24,6 +24,8 @@ UPGRADING FROM 0.2.0
mysql> ALTER TABLE project ADD COLUMN (codecharset VARCHAR(32));
mysql> DROP TABLE issue_attachment;
mysql> create the issue_file_list table according to the definition found in codepot.mysql
+ mysql> ALTER TABLE issue_change ADD COLUMN(createdon datetime not null, createdby varchar(32) not null);
+ mysql> UPDATE issue_change SET createdby=updatedby, createdon=updatedon;
INSTALLATION ON CENTOS
diff --git a/codepot/etc/codepot.mysql b/codepot/etc/codepot.mysql
index 0c4fb671..a7f904b5 100644
--- a/codepot/etc/codepot.mysql
+++ b/codepot/etc/codepot.mysql
@@ -134,7 +134,9 @@ CREATE TABLE issue_change (
priority VARCHAR(32) NOT NULL,
comment TEXT NOT NULL,
+ createdon DATETIME NOT NULL,
updatedon DATETIME NOT NULL,
+ createdby VARCHAR(32) NOT NULL,
updatedby VARCHAR(32) NOT NULL,
PRIMARY KEY (projectid, id, sno),
diff --git a/codepot/etc/codepot.oracle b/codepot/etc/codepot.oracle
index 4ff81379..929f31bc 100644
--- a/codepot/etc/codepot.oracle
+++ b/codepot/etc/codepot.oracle
@@ -14,9 +14,9 @@
-- DROP TABLE "cpot_log";
-- DROP TABLE "cpot_code_review";
-- DROP TABLE "cpot_file";
--- DROP TABLE "cpot_issue_change_attachment";
+-- DROP TABLE "cpot_issue_change_file_list";
-- DROP TABLE "cpot_issue_change";
--- DROP TABLE "cpot_issue_attachment";
+-- DROP TABLE "cpot_issue_file_list";
-- DROP TABLE "cpot_issue";
-- DROP TABLE "cpot_wiki_attachment";
-- DROP TABLE "cpot_wiki";
@@ -130,8 +130,10 @@ CREATE TABLE "cpot_issue_change" (
"owner" VARCHAR(255) NOT NULL,
"priority" VARCHAR(32) NOT NULL,
"comment" CLOB NOT NULL,
- "updatedon" TIMESTAMP NOT NULL,
- "updatedby" VARCHAR(32) NOT NULL,
+ "createdon" TIMESTAMP NOT NULL,
+ "updatedon" TIMESTAMP NOT NULL,
+ "createdby" VARCHAR(32) NOT NULL,
+ "updatedby" VARCHAR(32) NOT NULL,
PRIMARY KEY ("projectid", "id", "sno"),
CONSTRAINT issue_update_id FOREIGN KEY ("projectid","id") REFERENCES "cpot_issue"("projectid","id")
);
diff --git a/codepot/etc/codepot.pgsql b/codepot/etc/codepot.pgsql
index 73470943..bc351f0d 100644
--- a/codepot/etc/codepot.pgsql
+++ b/codepot/etc/codepot.pgsql
@@ -152,8 +152,10 @@ CREATE TABLE issue_change (
priority VARCHAR(32) NOT NULL,
comment TEXT NOT NULL,
- updatedon TIMESTAMP NOT NULL,
- updatedby VARCHAR(32) NOT NULL,
+ createdon TIMESTAMP NOT NULL,
+ updatedon TIMESTAMP NOT NULL,
+ createdby VARCHAR(32) NOT NULL,
+ updatedby VARCHAR(32) NOT NULL,
PRIMARY KEY (projectid, id, sno),
diff --git a/codepot/src/codepot/controllers/issue.php b/codepot/src/codepot/controllers/issue.php
index 1f09a8a0..af0e3196 100644
--- a/codepot/src/codepot/controllers/issue.php
+++ b/codepot/src/codepot/controllers/issue.php
@@ -663,6 +663,67 @@ class Issue extends Controller
print $status;
}
+
+ function xhr_edit_comment ($projectid = '', $issueid = '')
+ {
+ $this->load->model ('ProjectModel', 'projects');
+ $this->load->model ('IssueModel', 'issues');
+
+ $login = $this->login->getUser ();
+ $revision_saved = -1;
+
+ if ($login['id'] == '')
+ {
+ $status = 'error - anonymous user';
+ }
+ else
+ {
+ $issueid = $this->converter->HexToAscii ($issueid);
+
+ $project = $this->projects->get ($projectid);
+ if ($project === FALSE)
+ {
+ $status = "error - failed to get the project {$projectid}";
+ }
+ else if ($project === NULL)
+ {
+ $status = "error - no such project {$projectid}";
+ }
+ else if (($comment_sno = $this->input->post('issue_edit_comment_sno')) === FALSE || $comment_sno <= 0)
+ {
+ $status = "error - invalid comment number";
+ }
+ else if (!$login['sysadmin?'] &&
+ /*$this->projects->projectHasMember($projectid, $login['id']) === FALSE &&*/
+ $this->issues->isIssueChangeCreatedBy($projectid, $issueid, $comment_sno, $login['id']) === FALSE)
+ {
+ $status = "error - comment not created by {$login['id']}";
+ }
+ else
+ {
+ $text = $this->input->post('issue_edit_comment_text');
+
+ if ($text === FALSE ||$text == '')
+ {
+ $status = "error - empty comment text";
+ }
+ else
+ {
+ if ($this->issues->editComment ($login['id'], $projectid, $issueid, $comment_sno, $text) === FALSE)
+ {
+ $status = 'error - ' . $this->issues->getErrorMessage();
+ }
+ else
+ {
+ $status = 'ok';
+ }
+ }
+ }
+ }
+
+ print $status;
+ }
+
////////////////////////////////////////////////////////////////////////
// Handling of attached files share the (almost) same code
// between issue.php and wiki.php. It would be way better
@@ -884,6 +945,25 @@ class Issue extends Controller
}
if ($part[2] != '') $filename = $part[2];
}
+ else if (count($part) == 2)
+ {
+ //$target => wikiname:attachment
+ //$target => #I1:file
+ if ($part[0] != '')
+ {
+ if ($part[0][0] == '#' && $part[0][1] == 'I')
+ {
+ $issueid = substr ($part[0],2);
+ $wikiname = '';
+ }
+ else
+ {
+ $wikiname = $part[0];
+ $issueid = '';
+ }
+ }
+ if ($part[1] != '') $filename = $part[1];
+ }
if ($wikiname != '')
$this->_handle_wiki_attachment ($login, $projectid, $wikiname, $filename);
diff --git a/codepot/src/codepot/language/english/issue_lang.php b/codepot/src/codepot/language/english/issue_lang.php
index 98eaf46b..b05b27ad 100644
--- a/codepot/src/codepot/language/english/issue_lang.php
+++ b/codepot/src/codepot/language/english/issue_lang.php
@@ -25,7 +25,6 @@ $lang['ISSUE_PRIORITY_OTHER'] = 'Other';
$lang['ISSUE_MSG_CHANGED_X_TO_Z'] = "Changed %s to %s";
$lang['ISSUE_MSG_CHANGED_X_FROM_Y_TO_Z'] = "Changed %s from %s to %s";
$lang['ISSUE_MSG_CONFIRM_UNDO'] = 'Are you sure to undo the last change?';
-$lang['ISSUE_MSG_CREATED'] = 'Created';
$lang['ISSUE_MSG_NO_ISSUES_AVAILABLE'] = 'No outstanding issues';
$lang['ISSUE_MSG_NO_SUCH_ISSUE'] = 'No such issue - %s';
$lang['ISSUE_MSG_TOTAL_NUM_ISSUES'] = 'Total %d issues';
diff --git a/codepot/src/codepot/language/korean/issue_lang.php b/codepot/src/codepot/language/korean/issue_lang.php
index b7bb9eb0..15307657 100644
--- a/codepot/src/codepot/language/korean/issue_lang.php
+++ b/codepot/src/codepot/language/korean/issue_lang.php
@@ -24,7 +24,6 @@ $lang['ISSUE_PRIORITY_OTHER'] = '기타';
$lang['ISSUE_MSG_CHANGED_X_TO_Z'] = "%s을/를 %s(으)로 변경";
$lang['ISSUE_MSG_CHANGED_X_FROM_Y_TO_Z'] = "%s을/를 %s에서 %s(으)로 변경";
$lang['ISSUE_MSG_CONFIRM_UNDO'] = '마지막 변경내용을 취소할까요?';
-$lang['ISSUE_MSG_CREATED'] = '생성됨';
$lang['ISSUE_MSG_NO_ISSUES_AVAILABLE'] = '처리해야 할 이슈가 없습니다';
$lang['ISSUE_MSG_NO_SUCH_ISSUE'] = '해당 이슈가 없습니다 - %s';
$lang['ISSUE_MSG_TOTAL_NUM_ISSUES'] = '전체 이슈 %d개';
diff --git a/codepot/src/codepot/models/issuemodel.php b/codepot/src/codepot/models/issuemodel.php
index ec59bacf..f629ed5c 100644
--- a/codepot/src/codepot/models/issuemodel.php
+++ b/codepot/src/codepot/models/issuemodel.php
@@ -181,6 +181,8 @@ class IssueModel extends Model
function create ($userid, $issue)
{
+ $now = codepot_nowtodbdate();
+
// TODO: check if userid can do this..
$this->db->trans_start ();
@@ -206,8 +208,8 @@ class IssueModel extends Model
$this->db->set ('status', $issue->status);
$this->db->set ('owner', $issue->owner);
$this->db->set ('priority', $issue->priority);
- $this->db->set ('createdon', codepot_nowtodbdate());
- $this->db->set ('updatedon', codepot_nowtodbdate());
+ $this->db->set ('createdon', $now);
+ $this->db->set ('updatedon', $now);
$this->db->set ('createdby', $userid);
$this->db->set ('updatedby', $userid);
$this->db->insert ('issue');
@@ -220,11 +222,13 @@ class IssueModel extends Model
$this->db->set ('owner', $issue->owner);
$this->db->set ('comment', '');
$this->db->set ('priority', $issue->priority);
- $this->db->set ('updatedon', codepot_nowtodbdate());
+ $this->db->set ('createdon', $now);
+ $this->db->set ('createdby', $userid);
+ $this->db->set ('updatedon', $now);
$this->db->set ('updatedby', $userid);
$this->db->insert ('issue_change');
- $this->db->set ('createdon', codepot_nowtodbdate());
+ $this->db->set ('createdon', $now);
$this->db->set ('type', 'issue');
$this->db->set ('action', 'create');
$this->db->set ('projectid', $issue->projectid);
@@ -240,16 +244,18 @@ class IssueModel extends Model
function update_partial ($userid, $issue)
{
+ $now = codepot_nowtodbdate();
+
$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 ('description', $issue->description);
- $this->db->set ('updatedon', codepot_nowtodbdate());
+ $this->db->set ('updatedon', $now);
$this->db->set ('updatedby', $userid);
$this->db->update ('issue');
- $this->db->set ('createdon', codepot_nowtodbdate());
+ $this->db->set ('createdon', $now);
$this->db->set ('type', 'issue');
$this->db->set ('action', 'update');
$this->db->set ('projectid', $issue->projectid);
@@ -265,6 +271,8 @@ class IssueModel extends Model
function update ($userid, $issue)
{
+ $now = codepot_nowtodbdate();
+
// TODO: check if userid can do this..
$this->db->trans_start ();
$this->db->where ('projectid', $issue->projectid);
@@ -275,7 +283,7 @@ class IssueModel extends Model
$this->db->set ('status', $issue->status);
$this->db->set ('owner', $issue->owner);
$this->db->set ('priority', $issue->priority);
- $this->db->set ('updatedon', codepot_nowtodbdate());
+ $this->db->set ('updatedon', $now);
$this->db->set ('updatedby', $userid);
$this->db->update ('issue');
@@ -287,11 +295,11 @@ class IssueModel extends Model
$this->db->set ('owner', $issue->owner);
$this->db->set ('priority', $issue->priority);
$this->db->set ('comment', '');
- $this->db->set ('updatedon', codepot_nowtodbdate());
+ $this->db->set ('updatedon', $now);
$this->db->set ('updatedby', $userid);
$this->db->update ('issue_change');
- $this->db->set ('createdon', codepot_nowtodbdate());
+ $this->db->set ('createdon', $now);
$this->db->set ('type', 'issue');
$this->db->set ('action', 'update');
$this->db->set ('projectid', $issue->projectid);
@@ -307,6 +315,8 @@ class IssueModel extends Model
function change ($userid, $project, $id, $change)
{
+ $now = codepot_nowtodbdate();
+
$this->db->trans_start ();
$this->db->where ('projectid', $project->id);
@@ -330,7 +340,9 @@ class IssueModel extends Model
$this->db->set ('owner', $change->owner);
$this->db->set ('priority', $change->priority);
$this->db->set ('comment', $change->comment);
- $this->db->set ('updatedon', codepot_nowtodbdate());
+ $this->db->set ('createdon', $now);
+ $this->db->set ('createdby', $userid);
+ $this->db->set ('updatedon', $now);
$this->db->set ('updatedby', $userid);
$this->db->insert ('issue_change');
@@ -340,11 +352,11 @@ class IssueModel extends Model
$this->db->set ('status', $change->status);
$this->db->set ('owner', $change->owner);
$this->db->set ('priority', $change->priority);
- $this->db->set ('updatedon', codepot_nowtodbdate());
+ $this->db->set ('updatedon', $now);
$this->db->set ('updatedby', $userid);
$this->db->update ('issue');
- $this->db->set ('createdon', codepot_nowtodbdate());
+ $this->db->set ('createdon', $now);
$this->db->set ('type', 'issue');
$this->db->set ('action', 'change');
$this->db->set ('projectid', $project->id);
@@ -505,6 +517,8 @@ class IssueModel extends Model
$this->db->set ('owner', $issue->owner);
$this->db->set ('comment', '');
$this->db->set ('priority', $issue->priority);
+ $this->db->set ('createdon', $now);
+ $this->db->set ('createdby', $userid);
$this->db->set ('updatedon', $now);
$this->db->set ('updatedby', $userid);
$this->db->insert ('issue_change');
@@ -888,7 +902,7 @@ class IssueModel extends Model
}
}
- $this->db->set ('createdon', codepot_nowtodbdate());
+ $this->db->set ('createdon', $now);
$this->db->set ('type', 'issue');
$this->db->set ('action', 'update');
$this->db->set ('projectid', $projectid);
@@ -917,6 +931,55 @@ class IssueModel extends Model
return $x;
}
+ private function _edit_comment ($userid, $projectid, $issueid, $sno, $text)
+ {
+ $this->db->trans_begin (); // manual transaction. not using trans_start().
+
+ $now = codepot_nowtodbdate();
+
+ $this->db->where ('projectid', $projectid);
+ $this->db->where ('id', $issueid);
+ $this->db->where ('sno', $sno);
+ $this->db->set ('comment', $text);
+ $this->db->set ('updatedon', $now);
+ $this->db->set ('updatedby', $userid);
+ $this->db->update ('issue_change');
+ if ($this->db->trans_status() === FALSE)
+ {
+ $this->errmsg = $this->db->_error_message();
+ $this->db->trans_rollback ();
+ return FALSE;
+ }
+
+ /*
+ $this->db->set ('createdon', codepot_nowtodbdate());
+ $this->db->set ('type', 'issue');
+ $this->db->set ('action', 'update');
+ $this->db->set ('projectid', $projectid);
+ $this->db->set ('userid', $userid);
+ $this->db->set ('message', $issueid);
+ $this->db->insert ('log');
+
+ if ($this->db->trans_status() === FALSE)
+ {
+ $this->errmsg = $this->db->_error_message();
+ $this->db->trans_rollback ();
+ return FALSE;
+ }*/
+
+ $this->db->trans_commit ();
+ return TRUE;
+ }
+
+ function editComment ($userid, $projectid, $issueid, $sno, $text)
+ {
+ set_error_handler (array ($this, 'capture_error'));
+ $errmsg = '';
+ $x = $this->_edit_comment ($userid, $projectid, $issueid, $sno, $text);
+ restore_error_handler ();
+ return $x;
+ }
+
function isIssueCreatedBy ($projectid, $issueid, $userid)
{
$this->db->trans_begin (); // manual transaction. not using trans_start().
@@ -926,6 +989,7 @@ class IssueModel extends Model
$query = $this->db->get ('issue');
if ($this->db->trans_status() === FALSE)
{
+ $this->errmsg = $this->db->_error_message();
$this->db->trans_rollback ();
return FALSE;
}
@@ -940,7 +1004,63 @@ class IssueModel extends Model
$this->db->trans_commit ();
$issue = &$result[0];
- return ($issue->created_by == $userid);
+ return ($issue->createdby == $userid);
+ }
+
+ function isIssueChangeCreatedBy ($projectid, $issueid, $sno, $userid)
+ {
+ $this->db->trans_begin (); // manual transaction. not using trans_start().
+
+ $this->db->where ('projectid', $projectid);
+ $this->db->where ('id', $issueid);
+ $this->db->where ('sno', $sno);
+ $query = $this->db->get ('issue_change');
+ if ($this->db->trans_status() === FALSE)
+ {
+ $this->errmsg = $this->db->_error_message();
+ $this->db->trans_rollback ();
+ return FALSE;
+ }
+
+ $result = $query->result ();
+ if (empty($result))
+ {
+ $this->db->trans_commit ();
+ return FALSE;
+ }
+
+ $this->db->trans_commit ();
+
+ $issue = &$result[0];
+ return $issue->createdby == $userid;
+ }
+
+ function isIssueChangeMadeBy ($projectid, $issueid, $sno, $userid)
+ {
+ $this->db->trans_begin (); // manual transaction. not using trans_start().
+
+ $this->db->where ('projectid', $projectid);
+ $this->db->where ('id', $issueid);
+ $this->db->where ('sno', $sno);
+ $query = $this->db->get ('issue_change');
+ if ($this->db->trans_status() === FALSE)
+ {
+ $this->errmsg = $this->db->_error_message();
+ $this->db->trans_rollback ();
+ return FALSE;
+ }
+
+ $result = $query->result ();
+ if (empty($result))
+ {
+ $this->db->trans_commit ();
+ return FALSE;
+ }
+
+ $this->db->trans_commit ();
+
+ $issue = &$result[0];
+ return ($issue->createdby == $userid || $issue->updatedby == $userid);
}
}
diff --git a/codepot/src/codepot/views/code_history.php b/codepot/src/codepot/views/code_history.php
index 68c7947f..178b6faa 100644
--- a/codepot/src/codepot/views/code_history.php
+++ b/codepot/src/codepot/views/code_history.php
@@ -147,7 +147,7 @@ $this->load->view (
if (array_key_exists('author', $h))
{
$user_icon_url = codepot_merge_path (site_url(), '/user/icon/' . $this->converter->AsciiToHex($h['author']));
- print "";
+ print "
";
print htmlspecialchars($h['author']);
}
diff --git a/codepot/src/codepot/views/issue_home.php b/codepot/src/codepot/views/issue_home.php
index 1917d04d..eb8957ca 100644
--- a/codepot/src/codepot/views/issue_home.php
+++ b/codepot/src/codepot/views/issue_home.php
@@ -42,7 +42,7 @@ function show_alert (outputMsg, titleMsg)
width: 'auto',
height: 'auto',
buttons: {
- "OK": function () {
+ 'lang->line('OK')?>': function () {
$(this).dialog("close");
}
}
diff --git a/codepot/src/codepot/views/issue_show.php b/codepot/src/codepot/views/issue_show.php
index ec0fcca7..3debc02c 100644
--- a/codepot/src/codepot/views/issue_show.php
+++ b/codepot/src/codepot/views/issue_show.php
@@ -27,6 +27,8 @@ $issue_file_count = count ($issue->files);
$creole_base = site_url() . "/wiki/show/{$project->id}/";
$creole_file_base = site_url() . "/issue/file/{$project->id}/{$issue->id}/";
+
+$change_count = count($issue->changes);
?>
@@ -736,48 +870,57 @@ $this->load->view (
'; - print htmlspecialchars($new->updatedby); - print ' | '; - print '';
- if ($new->comment != "")
+
+ print " ";
+ print " ";
+
+ $escaped_comment = htmlspecialchars($new->comment);
+ if(isset($login['id']) && $login['id'] != '')
{
- print "";
+ $user_icon_url = codepot_merge_path (site_url(), '/user/icon/' . $this->converter->AsciiToHex($new->updatedby));
+ print " ";
+ printf ("", $i, $this->lang->line('Edit'));
+ print "";
+ print "";
- print " "; - print htmlspecialchars($new->comment); - print ''; + print " ";
+ printf ('', $i, addslashes($new->sno));
+ printf ('', $i, $escaped_comment);
print ' ';
- $commentno++;
}
+ print "";
+ printf (" ';
+
print '%s", $i, $escaped_comment); + print ' ';
print '
| |
'; - print codepot_dbdatetodispdate($issue->createdon); - print ' | '; - - print ''; - print htmlspecialchars($issue->createdby); - print ' | '; - - print ''; - print $this->lang->line('ISSUE_MSG_CREATED'); - print ' | '; - - print '