diff --git a/module/git/model.php b/module/git/model.php index 70867f6d24..8ace7470df 100644 --- a/module/git/model.php +++ b/module/git/model.php @@ -370,12 +370,14 @@ class gitModel extends model public function iconvComment($comment) { /* Get encodings. */ - $encoding = str_replace(' ', '', $this->config->git->encodings); - if($encoding == '') return $comment; + $encodings = str_replace(' ', '', isset($this->config->git->encodings) ? $this->config->git->encodings : ''); + if($encodings == '') return $comment; + $encodings = explode(',', $encodings); /* Try convert. */ - if($encoding != 'utf-8') + foreach($encodings as $encoding) { + if($encoding == 'utf-8') continue; $result = @iconv($encoding, 'utf-8', $comment); if($result) return $result; } @@ -556,7 +558,14 @@ class gitModel extends model if($changes) { $historyID = $this->dao->findByAction($record->id)->from(TABLE_HISTORY)->fetch('id'); - $this->dao->update(TABLE_HISTORY)->data($changes)->where('id')->eq($historyID)->exec(); + if($historyID) + { + $this->dao->update(TABLE_HISTORY)->data($changes)->where('id')->eq($historyID)->exec(); + } + else + { + $this->action->logHistory($record->id, array($changes)); + } } } else diff --git a/module/svn/control.php b/module/svn/control.php index 1b680e0190..14031f8696 100644 --- a/module/svn/control.php +++ b/module/svn/control.php @@ -95,4 +95,45 @@ class svn extends control exit; } } + + /** + * Ajax save log. + * + * @access public + * @return void + */ + public function ajaxSaveLog() + { + $repoUrl = trim($this->post->repoUrl); + $repoRoot = str_replace('\\', '/', trim($this->post->repoRoot)); + $message = trim($this->post->message); + $revision = trim($this->post->revision); + $files = $this->post->files; + + /* Ignore git. */ + if(strpos($repoUrl, '://') === false) die(); + + $parsedFiles = array(); + foreach($files as $file) + { + $file = trim($file); + if(empty($file)) continue; + $path = str_replace($repoRoot, '', $file); + $parsedFiles[''][] = $path; + } + + $objects = $this->svn->parseComment($message); + if($objects) + { + $log = new stdclass(); + $log->author = $this->app->user->account; + $log->date = helper::now(); + $log->msg = $message; + $log->revision = $revision; + $log->files = $parsedFiles; + $this->svn->saveAction2PMS($objects, $log, $repoUrl); + if($revision) $this->svn->saveLastRevision($revision); + } + die(); + } } diff --git a/module/svn/model.php b/module/svn/model.php index 35a32902e2..e7aa3250d6 100644 --- a/module/svn/model.php +++ b/module/svn/model.php @@ -361,13 +361,14 @@ class svnModel extends model public function iconvComment($comment) { /* Get encodings. */ - $encodings = str_replace(' ', '', trim($comment)); + $encodings = str_replace(' ', '', isset($this->config->svn->encodings) ? $this->config->svn->encodings : ''); if($encodings == '') return $comment; $encodings = explode(',', $encodings); /* Try convert. */ foreach($encodings as $encoding) { + if($encoding == 'utf-8') continue; $result = @iconv($encoding, 'utf-8', $comment); if($result) return $result; } @@ -540,7 +541,14 @@ class svnModel extends model if($changes) { $historyID = $this->dao->findByAction($record->id)->from(TABLE_HISTORY)->fetch('id'); - $this->dao->update(TABLE_HISTORY)->data($changes)->where('id')->eq($historyID)->exec(); + if($historyID) + { + $this->dao->update(TABLE_HISTORY)->data($changes)->where('id')->eq($historyID)->exec(); + } + else + { + $this->action->logHistory($record->id, array($changes)); + } } } else @@ -583,6 +591,7 @@ class svnModel extends model $diff .= $action == 'M' ? "$diffLink\n" : "\n" ; } } + $changes = new stdclass(); $changes->field = 'subversion'; $changes->old = ''; $changes->new = '';