#17588107 : added a feature setting user id and password for svn authentication

git-svn-id: http://xe-core.googlecode.com/svn/sandbox@5193 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
haneul 2008-12-29 16:42:27 +00:00
parent ae1081df80
commit c02b420613
10 changed files with 72 additions and 11 deletions

View file

@ -14,8 +14,10 @@
var $tmp_dir = '/tmp';
var $oXml = null;
var $userid = null;
var $passwd = null;
function Svn($url, $svn_cmd='/usr/bin/svn', $diff_cmd='/usr/bin/diff') {
function Svn($url, $svn_cmd='/usr/bin/svn', $diff_cmd='/usr/bin/diff', $userid=null, $passwd=null) {
if(substr($url,-1)!='/') $url .= '/';
$this->url = $url;
@ -26,14 +28,29 @@
$this->tmp_dir = _XE_PATH_.'files/cache/tmp';
if(!is_dir($this->tmp_dir)) FileHandler::makeDir($this->tmp_dir);
$this->userid = $userid;
$this->passwd = $passwd;
$this->oXml = new XmlParser();
}
function _getAuthInfo()
{
if($this->userid && $this->passwd)
{
return sprintf("--username %s --password %s", $this->userid, $this->passwd);
}
else
{
return '';
}
}
function getStatus($path = '/') {
if(substr($path,0,1)=='/') $path = substr($path,1);
if(strpos($path,'..')!==false) return;
$command = sprintf("%s --non-interactive --config-dir %s log --xml --limit 1 %s%s", $this->svn_cmd, $this->tmp_dir, $this->url, $path);
$command = sprintf("%s --non-interactive --config-dir %s log --xml --limit 1 %s %s%s", $this->svn_cmd, $this->tmp_dir, $this->_getAuthInfo(), $this->url, $path);
$buff = $this->execCmd($command, $error);
$xmlDoc = $this->oXml->parse($buff);
@ -53,8 +70,9 @@
if(strpos($path,'..')!==false) return;
$command = sprintf(
'%s --non-interactive --config-dir %s list %s%s%s',
'%s --non-interactive %s --config-dir %s list %s%s%s',
$this->svn_cmd,
$this->_getAuthInfo(),
$this->tmp_dir,
$this->url,
$path,
@ -95,8 +113,9 @@
if(strpos($path,'..')!==false) return;
$command = sprintf(
'%s --non-interactive --config-dir %s cat %s%s%s',
'%s --non-interactive %s --config-dir %s cat %s%s%s',
$this->svn_cmd,
$this->_getAuthInfo(),
$this->tmp_dir,
$this->url,
$path,
@ -179,15 +198,16 @@
function getComp($path, $brev, $erev) {
if(!$brev) {
$command = sprintf('%s --non-interactive --config-dir %s log --xml --limit 2 %s%s@%d', $this->svn_cmd, $this->tmp_dir, $this->url, $path, $erev);
$command = sprintf('%s --non-interactive %s --config-dir %s log --xml --limit 2 %s%s@%d', $this->svn_cmd, $this->_getAuthInfo(), $this->tmp_dir, $this->url, $path, $erev);
$buff = $this->execCmd($command, $error);
$xmlDoc = $this->oXml->parse($buff);
$brev = $xmlDoc->log->logentry[1]->attrs->revision;
if(!$brev) return;
}
$command = sprintf('%s --non-interactive --config-dir %s diff %s%s@%d %s%s@%d',
$command = sprintf('%s --non-interactive %s --config-dir %s diff %s%s@%d %s%s@%d',
$this->svn_cmd,
$this->_getAuthInfo(),
$this->tmp_dir,
$this->url,
$path,
@ -250,8 +270,9 @@
if(strpos($path,'..')!==false) return;
$command = sprintf(
'%s --non-interactive --config-dir %s log --xml %s %s %s %s%s',
'%s --non-interactive %s --config-dir %s log --xml %s %s %s %s%s',
$this->svn_cmd,
$this->_getAuthInfo(),
$this->tmp_dir,
$quiet?'--quiet':'--verbose',
$limit?'--limit '.$limit:'',

View file

@ -388,7 +388,7 @@
function syncChangeset($module_info)
{
require_once($this->module_path.'classes/svn.class.php');
$oSvn = new Svn($module_info->svn_url, $module_info->svn_cmd, $module_info->diff_cmd);
$oSvn = new Svn($module_info->svn_url, $module_info->svn_cmd, $module_info->diff_cmd, $module_info->svn_userid, $module_info->svn_passwd);
$oModel = &getModel('issuetracker');
$status = $oSvn->getStatus();
if(!$status || !$status->revision) return;

View file

@ -27,6 +27,10 @@
$lang->about_svn_cmd = 'Please input the location of svn client to link with SVN. (ex: /usr/bin/svn)';
$lang->diff_cmd = 'DIFF Command Location';
$lang->about_diff_cmd = 'Please input the location of diff to compare SVN revisions. (ex: /usr/bin/diff)';
$lang->svn_userid = 'SVN ID';
$lang->about_svn_userid = 'If authentication is necessary, input userid for accessing the SVN repository';
$lang->svn_passwd = 'SVN password';
$lang->about_svn_passwd = 'If authentication is necessary, input password for accessing the SVN repository';
$lang->issue = 'Issue';
$lang->total_issue = 'All Issues';

View file

@ -27,6 +27,10 @@
$lang->about_svn_cmd = 'SVN連動のためのsvn clientファイルのロケーションを入力して下さい。 (ex: /usr/bin/svn)';
$lang->diff_cmd = 'DIFFファイルのロケーション';
$lang->about_diff_cmd = 'SVN revision間の比較のためのdiffファイルのロケーションを入力して下さい。(ex: /usr/bin/diff)';
$lang->svn_userid = 'SVN ID';
$lang->about_svn_userid = 'If authentication is necessary, input userid for accessing the SVN repository';
$lang->svn_passwd = 'SVN password';
$lang->about_svn_passwd = 'If authentication is necessary, input password for accessing the SVN repository';
$lang->issue = 'イシュー';
$lang->total_issue = 'イシュー全体';

View file

@ -27,6 +27,10 @@
$lang->about_svn_cmd = 'SVN 연동을 위해 svn client 실행파일의 위치를 입력해주세요. (ex: /usr/bin/svn)';
$lang->diff_cmd = 'DIFF 실행파일 위치';
$lang->about_diff_cmd = 'SVN revision들의 비교를 위한 diff 실행파일의 위치를 입력해주세요. (ex: /usr/bin/diff)';
$lang->svn_userid = 'SVN 인증 아이디';
$lang->about_svn_userid = '인증이 필요한 경우 아이디를 입력해주세요';
$lang->svn_passwd = 'SVN 인증 패스워드';
$lang->about_svn_passwd = '인증이 필요한 경우 패스워드를 입력해주세요';
$lang->issue = '문제';
$lang->total_issue = '전체 문제';

View file

@ -27,6 +27,10 @@
$lang->about_svn_cmd = '请输入svn clien应用程序位置。(ex: /usr/bin/svn)';
$lang->diff_cmd = 'DIF应用程序位置';
$lang->about_diff_cmd = '为比较SVN revision请输入diff应用程序位置。 (ex: /usr/bin/diff)';
$lang->svn_userid = 'SVN ID';
$lang->about_svn_userid = 'If authentication is necessary, input userid for accessing the SVN repository';
$lang->svn_passwd = 'SVN password';
$lang->about_svn_passwd = 'If authentication is necessary, input password for accessing the SVN repository';
$lang->issue = '问题';
$lang->total_issue = '全部问题';

View file

@ -27,6 +27,10 @@
$lang->about_svn_cmd = '請輸入 SVN Client應用程式位置。(ex: /usr/bin/svn)';
$lang->diff_cmd = 'DIFF應用程式位置';
$lang->about_diff_cmd = '為了比較 SVN revisions請輸入diff應用程式位置。 (ex: /usr/bin/diff)';
$lang->svn_userid = 'SVN ID';
$lang->about_svn_userid = 'If authentication is necessary, input userid for accessing the SVN repository';
$lang->svn_passwd = 'SVN password';
$lang->about_svn_passwd = 'If authentication is necessary, input password for accessing the SVN repository';
$lang->issue = '問題';
$lang->total_issue = '所有問題';

View file

@ -16,6 +16,8 @@
<param name="svn_url" target="svn_url" />
<param name="svn_cmd" target="svn_cmd" />
<param name="diff_cmd" target="diff_cmd" />
<param name="svn_userid" target="svn_userid" />
<param name="svn_passwd" target="svn_passwd" />
<param name="extra_vars_1_name" target="extra_vars_1_name" />
<param name="extra_vars_1_type" target="extra_vars_1_type" />
<param name="extra_vars_1_is_required" target="extra_vars_1_is_required" />

View file

@ -42,11 +42,15 @@
<td>{$module_info->diff_cmd}&nbsp;</td>
</tr>
<tr>
<th scope="row"><div>{$lang->description}</div></th>
<th scope="row"><div>{$lang->svn_userid}</div></th>
<td>{$module_info->svn_userid}&nbsp;</td>
</tr>
<tr>
<th scope="row2"><div>{$lang->description}</div></th>
<td>{nl2br(htmlspecialchars($module_info->description))}&nbsp;</td>
</tr>
<tr class="row2">
<th scope="row"><div>{$lang->admin_id}</div></th>
<tr class="row">
<th scope="row2"><div>{$lang->admin_id}</div></th>
<td>{implode(",",$module_info->admin_id)}&nbsp;</td>
</tr>
<tr>

View file

@ -96,6 +96,20 @@
<p>{$lang->about_diff_cmd}</p>
</td>
</tr>
<tr>
<th scope="row"><div>{$lang->svn_userid}</div></th>
<td>
<input type="text" name="svn_userid" value="{$module_info->svn_userid}" class="inputTypeText w300" />
<p>{$lang->about_svn_userid}</p>
</td>
</tr>
<tr class="row2">
<th scope="row"><div>{$lang->svn_passwd}</div></th>
<td>
<input type="password" name="svn_passwd" value="{$module_info->svn_passwd}" class="inputTypeText w300" />
<p>{$lang->about_svn_passwd}</p>
</td>
</tr>
<tr>
<th scope="row"><div>{$lang->description}</div></th>
<td>