diff --git a/module/repo/config.php b/module/repo/config.php index b5e1de4207..ddaa97e8cf 100644 --- a/module/repo/config.php +++ b/module/repo/config.php @@ -30,3 +30,7 @@ $config->repo->binary = '|pdf|'; $config->repo->editor = new stdclass(); $config->repo->editor->view = array('id' => 'commentText', 'tools' => 'simpleTools'); $config->repo->editor->diff = array('id' => 'commentText', 'tools' => 'simpleTools'); + +$config->repo->create->requiredFields = 'SCM,name,path,encoding,client'; +$config->repo->edit->requiredFields = 'SCM,name,path,encoding,client'; +$config->repo->svn->requiredFields = 'account,password'; \ No newline at end of file diff --git a/module/repo/control.php b/module/repo/control.php index b027e2cf3f..c27ad99adb 100644 --- a/module/repo/control.php +++ b/module/repo/control.php @@ -114,7 +114,7 @@ class repo extends control $repoID = $this->session->repoID; $this->repo->setMenu($this->repos, $repoID, false); - $repo = $this->repo->getByID($repoID); + $repo = $this->repo->getRepoByID($repoID); if($_POST) { $noNeedSync = $this->repo->update($repoID); diff --git a/module/repo/lang/zh-cn.php b/module/repo/lang/zh-cn.php index 96b630ae5b..4439d927e7 100644 --- a/module/repo/lang/zh-cn.php +++ b/module/repo/lang/zh-cn.php @@ -106,8 +106,8 @@ $lang->repo->logStyles['D'] = '删除'; $lang->repo->encodingList['utf_8'] = 'UTF-8'; $lang->repo->encodingList['gbk'] = 'GBK'; -//$lang->repo->scmList['Subversion'] = 'Subversion'; $lang->repo->scmList['Git'] = 'Git'; +$lang->repo->scmList['Subversion'] = 'Subversion'; $lang->repo->notice = new stdclass(); $lang->repo->notice->syncing = '正在同步中, 请稍等...'; @@ -119,6 +119,7 @@ $lang->repo->notice->commentContent = '输入回复内容'; $lang->repo->notice->deleteBug = '确认删除该Bug?'; $lang->repo->notice->deleteComment = '确认删除该回复?'; $lang->repo->notice->lastSyncTime = '最后更新于:'; +$lang->repo->notice->passwordTips = '密码已加密存储,需修改请重新输入。'; $lang->repo->error = new stdclass(); $lang->repo->error->useless = '你的服务器禁用了exec,shell_exec方法,无法使用该功能'; diff --git a/module/repo/model.php b/module/repo/model.php index 8f6f48fccb..701bf0a1bc 100644 --- a/module/repo/model.php +++ b/module/repo/model.php @@ -154,19 +154,6 @@ class repoModel extends model return $repos; } - /** - * Get a repo by id. - * - * @param int $id - * @access public - * @return object - */ - public function getByID($id) - { - $repo = $this->dao->select('*')->from(TABLE_REPO)->where('id')->eq($id)->fetch(); - return $repo; - } - /** * Create a repo. * @@ -175,19 +162,8 @@ class repoModel extends model */ public function create() { - $data = fixer::input('post')->skipSpecial('path,client,account,password')->get(); - if ($data->SCM === 'Subversion') { - $credentials = $this->loadModel('cicredentials')->getByID($data->credentials); - if ($credentials->type != 'account') { - dao::$errors['credentials'][] = $this->repo->svnCredentialsLimt; - - return; - } - } - $this->checkConnection(); $data = fixer::input('post')->skipSpecial('path,client,account,password')->get(); - $data->acl = empty($data->acl) ? '' : json_encode($data->acl); if(empty($data->client)) $data->client = 'svn'; @@ -200,9 +176,10 @@ class repoModel extends model if($data->prefix) $data->prefix = '/' . $data->prefix; } - if($data->encrypt == 'base64') $data->password = base64_encode($data->password); + $data->password = base64_encode($data->password); $this->dao->insert(TABLE_REPO)->data($data) ->batchCheck($this->config->repo->create->requiredFields, 'notempty') + ->checkIF($data->SCM == 'Subversion', $this->config->repo->svn->requiredFields, 'notempty') ->autoCheck() ->exec(); return $this->dao->lastInsertID(); @@ -222,7 +199,7 @@ class repoModel extends model $data->acl = empty($data->acl) ? '' : json_encode($data->acl); if(empty($data->client)) $data->client = 'svn'; - $repo = $this->getByID($id); + $repo = $this->getRepoByID($id); $data->prefix = $repo->prefix; if($data->SCM == 'Subversion' and $data->path != $repo->path) { @@ -238,11 +215,14 @@ class repoModel extends model } if($data->path != $repo->path) $data->synced = 0; - if($data->encrypt == 'base64') $data->password = base64_encode($data->password); + + $data->password = base64_encode($data->password); $this->dao->update(TABLE_REPO)->data($data) - ->batchCheck($this->config->repo->create->requiredFields, 'notempty') + ->batchCheck($this->config->repo->edit->requiredFields, 'notempty') + ->checkIF($data->SCM == 'Subversion', $this->config->repo->svn->requiredFields, 'notempty') ->autoCheck() ->where('id')->eq($id)->exec(); + if($repo->path != $data->path) { $this->dao->delete()->from(TABLE_REPOHISTORY)->where('repo')->eq($id)->exec(); @@ -285,7 +265,7 @@ class repoModel extends model $repo = $this->dao->select('*')->from(TABLE_REPO)->where('id')->eq($repoID)->fetch(); if(!$repo) return false; - if($repo->encrypt == 'base64') $repo->password = base64_decode($repo->password); + $repo->password = base64_decode($repo->password); $repo->acl = json_decode($repo->acl); return $repo; } @@ -551,74 +531,6 @@ class repoModel extends model return substr($revision, 0, 10) . ' (' . $commit . ') '; } -// /** -// * create -// * -// * @access public -// * @return int -// */ -// public function create() -// { -// $this->checkConnection(); -// $data = fixer::input('post')->skipSpecial('path,client,account,password')->get(); -// $data->acl = empty($data->acl) ? '' : json_encode($data->acl); -// if(empty($data->client)) $data->client = 'svn'; -// -// if($data->SCM == 'Subversion') -// { -// $scm = $this->app->loadClass('scm'); -// $scm->setEngine($data); -// $info = $scm->info(''); -// $data->prefix = empty($info->root) ? '' : trim(str_ireplace($info->root, '', str_replace('\\', '/', $data->path)), '/'); -// if($data->prefix) $data->prefix = '/' . $data->prefix; -// } -// -// if($data->encrypt == 'base64') $data->password = base64_encode($data->password); -// $this->dao->insert(TABLE_REPO)->data($data)->exec(); -// return $this->dao->lastInsertID(); -// } -// -// /** -// * Save settings. -// * -// * @param int $repoID -// * @access public -// * @return bool -// */ -// public function saveSettings($repoID) -// { -// $this->checkConnection(); -// $data = fixer::input('post')->skipSpecial('path,client,account,password')->get(); -// $data->acl = empty($data->acl) ? '' : json_encode($data->acl); -// -// if(empty($data->client)) $data->client = 'svn'; -// $repo = $this->getRepoByID($repoID); -// $data->prefix = $repo->prefix; -// if($data->SCM == 'Subversion' and $data->path != $repo->path) -// { -// $scm = $this->app->loadClass('scm'); -// $scm->setEngine($data); -// $info = $scm->info(''); -// $data->prefix = empty($info->root) ? '' : trim(str_ireplace($info->root, '', str_replace('\\', '/', $data->path)), '/'); -// if($data->prefix) $data->prefix = '/' . $data->prefix; -// } -// elseif($data->SCM != $repo->SCM and $data->SCM == 'Git') -// { -// $data->prefix = ''; -// } -// -// if($data->path != $repo->path) $data->synced = 0; -// if($data->encrypt == 'base64') $data->password = base64_encode($data->password); -// $this->dao->update(TABLE_REPO)->data($data)->where('id')->eq($repoID)->exec(); -// if($repo->path != $data->path) -// { -// $this->dao->delete()->from(TABLE_REPOHISTORY)->where('repo')->eq($repoID)->exec(); -// $this->dao->delete()->from(TABLE_REPOFILES)->where('repo')->eq($repoID)->exec(); -// return false; -// } -// return true; -// } - /** * Save commit. * diff --git a/module/repo/view/create.html.php b/module/repo/view/create.html.php index 5c431b3e98..0668f898bf 100644 --- a/module/repo/view/create.html.php +++ b/module/repo/view/create.html.php @@ -49,20 +49,16 @@