From 61be4c76953b78b9ca6da4488db81beb2f8e7586 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Sat, 14 Jun 2014 15:02:51 +0000 Subject: [PATCH] finished revision log message editing --- codepot/src/codepot/controllers/code.php | 35 ++++++++++++++++ .../src/codepot/models/subversionmodel.php | 18 ++++++++ codepot/src/codepot/views/code_revision.php | 42 ++++++++++++++++--- codepot/src/css/code.css | 2 +- codepot/src/css/jquery-ui.css | 14 +++++-- 5 files changed, 101 insertions(+), 10 deletions(-) diff --git a/codepot/src/codepot/controllers/code.php b/codepot/src/codepot/controllers/code.php index 60542ec9..42899959 100644 --- a/codepot/src/codepot/controllers/code.php +++ b/codepot/src/codepot/controllers/code.php @@ -246,6 +246,7 @@ class Code extends Controller { $this->load->model ('ProjectModel', 'projects'); $this->load->model ('SubversionModel', 'subversion'); + $login = $this->login->getUser (); if (CODEPOT_SIGNIN_COMPULSORY && $login['id'] == '') @@ -277,6 +278,40 @@ class Code extends Controller redirect ("main/signin/" . $this->converter->AsciiTohex(current_url())); } + $data['edit_error_message'] = ''; + if ($login['id'] != '' && + $login['id'] == $this->subversion->getRevProp($projectid, $rev, 'svn:author')) + { + // the current user must be the author of the revision to be able to + // change the log message. + $this->load->helper ('form'); + $this->load->library ('form_validation'); + + $this->form_validation->set_rules ('edit_log_message', 'Message', 'required|min_length[2]'); + $this->form_validation->set_error_delimiters('',''); + + if ($this->input->post('edit_log_message')) + { + $logmsg = $this->input->post('edit_log_message'); + if ($this->form_validation->run()) + { + if ($logmsg != $this->subversion->getRevProp ($projectid, $rev, 'svn:log')) + { + $actual_rev = $this->subversion->setRevProp ( + $projectid, $rev, 'svn:log', $logmsg, $login['id']); + if ($actual_rev === FALSE) + { + $data['edit_error_message'] = 'Cannot change revision log message'; + } + } + } + else + { + $data['edit_error_message'] = 'Invalid revision log message'; + } + } + } + $file = $this->subversion->getRevHistory ($projectid, $path, $rev); if ($file === FALSE) { diff --git a/codepot/src/codepot/models/subversionmodel.php b/codepot/src/codepot/models/subversionmodel.php index ecb76d3e..d55cb2db 100644 --- a/codepot/src/codepot/models/subversionmodel.php +++ b/codepot/src/codepot/models/subversionmodel.php @@ -768,6 +768,24 @@ class SubversionModel extends Model return $log[0]['rev']; } + function getRevProp ($projectid, $rev, $prop) + { + $url = 'file://'.$this->_canonical_path(CODEPOT_SVNREPO_DIR."/{$projectid}"); + return @svn_revprop_get ($url, $rev, $prop); + } + + function setRevProp ($projectid, $rev, $prop, $propval, $user) + { + $url = 'file://'.$this->_canonical_path(CODEPOT_SVNREPO_DIR."/{$projectid}"); + + $orguser = @svn_auth_get_parameter (SVN_AUTH_PARAM_DEFAULT_USERNAME); + @svn_auth_set_parameter (SVN_AUTH_PARAM_DEFAULT_USERNAME, $user); + + $result = @svn_revprop_set ($url, $rev, $prop, $propval); + + @svn_auth_set_parameter (SVN_AUTH_PARAM_DEFAULT_USERNAME, $orguser); + return $result; + } } ?> diff --git a/codepot/src/codepot/views/code_revision.php b/codepot/src/codepot/views/code_revision.php index 3178a7c0..e719f423 100644 --- a/codepot/src/codepot/views/code_revision.php +++ b/codepot/src/codepot/views/code_revision.php @@ -12,6 +12,9 @@ <?=htmlspecialchars($project->name)?> @@ -155,13 +176,14 @@ $history = $file['history'];
-
lang->line('Message')?> -    +
lang->line('Message')?>  + lang->line('Edit'), array ('id' => 'code_revision_edit_logmsg_button')); ?> +
@@ -215,17 +237,27 @@ $history = $file['history'];
 
 
+
id}${revreqroot}", 'id="code_revision_edit_logmsg_form"')?> 'code_revision_edit_logmsg', - 'value' => $history['msg'], 'rows'=> 10, 'cols' => 70) - ); + array ('name' => 'edit_log_message', + 'value' => $history['msg'], 'rows'=> 10, 'cols' => 70, + 'id' => 'code_revision_edit_log_message') + ) ?>
+ 0): ?> +
+ +
+ + + diff --git a/codepot/src/css/code.css b/codepot/src/css/code.css index e43efdaa..a0ce28b7 100644 --- a/codepot/src/css/code.css +++ b/codepot/src/css/code.css @@ -185,7 +185,7 @@ } #code_revision_mainarea_result .title .anchor { - font-size: 9pt; + font-size: 70%; } #code_revision_mainarea_result_msg { diff --git a/codepot/src/css/jquery-ui.css b/codepot/src/css/jquery-ui.css index 1507d3a3..585a30dd 100644 --- a/codepot/src/css/jquery-ui.css +++ b/codepot/src/css/jquery-ui.css @@ -349,12 +349,15 @@ button.ui-button-icons-only { width: 3.7em; } /*button text element */ .ui-button .ui-button-text { display: block; line-height: 1.4; } -.ui-button-text-only .ui-button-text { padding: .4em 1em; } +//.ui-button-text-only .ui-button-text { padding: .4em 1em; } +.ui-button-text-only .ui-button-text { padding: .2em .5em; } .ui-button-icon-only .ui-button-text, .ui-button-icons-only .ui-button-text { padding: .4em; text-indent: -9999999px; } -.ui-button-text-icon .ui-button-text, .ui-button-text-icons .ui-button-text { padding: .4em 1em .4em 2.1em; } +//.ui-button-text-icon .ui-button-text, .ui-button-text-icons .ui-button-text { padding: .4em 1em .4em 2.1em; } +.ui-button-text-icon .ui-button-text, .ui-button-text-icons .ui-button-text { padding: .2em 1em .2em 2.1em; } .ui-button-text-icons .ui-button-text { padding-left: 2.1em; padding-right: 2.1em; } /* no icon support for input elements, provide padding by default */ -input.ui-button { padding: .4em 1em; } +//input.ui-button { padding: .4em 1em; } +input.ui-button { padding: .2em .5em; } /*button icon element(s) */ .ui-button-icon-only .ui-icon, .ui-button-text-icon .ui-icon, .ui-button-text-icons .ui-icon, .ui-button-icons-only .ui-icon { position: absolute; top: 50%; margin-top: -8px; } @@ -383,7 +386,10 @@ button.ui-button::-moz-focus-inner { border: 0; padding: 0; } /* reset extra pad .ui-dialog .ui-dialog-titlebar-close:hover, .ui-dialog .ui-dialog-titlebar-close:focus { padding: 0; } .ui-dialog .ui-dialog-content { border: 0; padding: .5em 1em; background: none; overflow: auto; zoom: 1; } .ui-dialog .ui-dialog-buttonpane { text-align: left; border-width: 1px 0 0 0; background-image: none; margin: .5em 0 0 0; padding: .1em 1em .3em .4em; } -.ui-dialog .ui-dialog-buttonpane button { float: right; margin: .5em .4em .5em 0; cursor: pointer; padding: .2em .6em .3em .6em; line-height: 1.4em; width:auto; overflow:visible; } + +//.ui-dialog .ui-dialog-buttonpane button { float: right; margin: .5em .4em .5em 0; cursor: pointer; padding: .2em .6em .3em .6em; line-height: 1.4em; width:auto; overflow:visible; } +.ui-dialog .ui-dialog-buttonpane button { float: right; margin: .5em .4em .5em 0; cursor: pointer; padding: .2em .5em .2em .5em; line-height: 1.4em; width:auto; overflow:visible; } + .ui-dialog .ui-resizable-se { width: 14px; height: 14px; right: 3px; bottom: 3px; } .ui-draggable .ui-dialog-titlebar { cursor: move; } /* Slider