- Remove unused methods.

This commit is contained in:
caoyanyi
2023-12-16 17:16:06 +08:00
parent 1d04c38fc0
commit f9c9a997e3
9 changed files with 21 additions and 132 deletions
+5 -5
View File
@@ -92,7 +92,7 @@ class gitea extends control
*/
public function view($giteaID)
{
$gitea = $this->gitea->getByID($giteaID);
$gitea = $this->gitea->fetchByID($giteaID);
$this->view->title = $this->lang->gitea->common . $this->lang->colon . $this->lang->gitea->view;
$this->view->gitea = $gitea;
@@ -111,7 +111,7 @@ class gitea extends control
*/
public function edit($giteaID)
{
$oldGitea = $this->gitea->getByID($giteaID);
$oldGitea = $this->gitea->fetchByID($giteaID);
if($_POST)
{
@@ -120,7 +120,7 @@ class gitea extends control
$this->loadModel('pipeline')->update($giteaID, $gitea);
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
$gitea = $this->gitea->getByID($giteaID);
$gitea = $this->gitea->fetchByID($giteaID);
$actionID = $this->loadModel('action')->create('gitea', $giteaID, 'edited');
$changes = common::createChanges($oldGitea, $gitea);
$this->action->logHistory($actionID, $changes);
@@ -143,7 +143,7 @@ class gitea extends control
*/
public function delete($giteaID)
{
$oldGitea = $this->loadModel('pipeline')->getByID($giteaID);
$oldGitea = $this->loadModel('pipeline')->fetchByID($giteaID);
$actionID = $this->pipeline->deleteByObject($giteaID, 'gitea');
if(!$actionID)
{
@@ -152,7 +152,7 @@ class gitea extends control
return $this->send($response);
}
$gitea = $this->pipeline->getByID($giteaID);
$gitea = $this->pipeline->fetchByID($giteaID);
$changes = common::createChanges($oldGitea, $gitea);
$this->loadModel('action')->logHistory($actionID, $changes);
+3 -15
View File
@@ -20,18 +20,6 @@ class giteaModel extends model
public $developerAccess = 30;
public $maintainerAccess = 40;
/**
* Get a gitea by id.
*
* @param int $id
* @access public
* @return object
*/
public function getByID($id)
{
return $this->loadModel('pipeline')->getByID($id);
}
/**
* Get gitea list.
*
@@ -68,7 +56,7 @@ class giteaModel extends model
*/
public function getApiRoot($giteaID, $sudo = true)
{
$gitea = $this->getByID($giteaID);
$gitea = $this->fetchByID($giteaID);
if(!$gitea) return '';
$sudoParam = '';
@@ -331,7 +319,7 @@ class giteaModel extends model
$project->http_url_to_repo = $project->html_url;
$project->name_with_namespace = $project->full_name;
$gitea = $this->getByID($giteaID);
$gitea = $this->fetchByID($giteaID);
$oauth = "oauth2:{$gitea->token}@";
$project->tokenCloneUrl = preg_replace('/(http(s)?:\/\/)/', "\$1$oauth", $project->html_url);
$project->tokenCloneUrl = str_replace(array('https://', 'http://'), strstr($url, ':', true) . '://', $project->tokenCloneUrl);
@@ -525,7 +513,7 @@ class giteaModel extends model
$branch = json_decode(commonModel::http($url));
if($branch)
{
$gitea = $this->getByID($giteaID);
$gitea = $this->fetchByID($giteaID);
$branch->web_url = "{$gitea->url}/$project/src/branch/$branchName";
}
+2 -16
View File
@@ -10,20 +10,6 @@ class giteaTest
$this->gitea = $this->tester->loadModel('gitea');
}
/**
* Get by id.
*
* @param int $id
* @access public
* @return object
*/
public function getByID($id)
{
$gitea = $this->gitea->getByID($id);
if(empty($gitea)) return 0;
return $gitea;
}
/**
* Get gitea list.
*
@@ -78,7 +64,7 @@ class giteaTest
return key($errors);
}
return $this->gitea->getById($giteaID);
return $this->gitea->fetchByID($giteaID);
}
/**
@@ -97,6 +83,6 @@ class giteaTest
return key($errors);
}
return $this->gitea->getById($id);
return $this->gitea->fetchByID($id);
}
}
-29
View File
@@ -1,29 +0,0 @@
#!/usr/bin/env php
<?php
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/gitea.class.php';
su('admin');
/**
title=测试giteaModel->gitById();
cid=1
pid=1
使用存在的ID >> 4
使用空的ID >> 0
使用不存在的ID >> 0
*/
$gitea = new giteaTest();
$giteaID = 4;
r($gitea->getById($giteaID)) && p('id') && e('4'); // 使用存在的ID
$giteaID = 0;
r($gitea->getById($giteaID)) && p() && e(0); // 使用空的ID
$giteaID = 111;
r($gitea->getById($giteaID)) && p() && e(0); // 使用不存在的ID
+5 -5
View File
@@ -90,7 +90,7 @@ class gogs extends control
*/
public function view($gogsID)
{
$gogs = $this->gogs->getByID($gogsID);
$gogs = $this->gogs->fetchByID($gogsID);
$this->view->title = $this->lang->gogs->common . $this->lang->colon . $this->lang->gogs->view;
$this->view->gogs = $gogs;
@@ -109,7 +109,7 @@ class gogs extends control
*/
public function edit($gogsID)
{
$oldGogs = $this->gogs->getByID($gogsID);
$oldGogs = $this->gogs->fetchByID($gogsID);
if($_POST)
{
@@ -118,7 +118,7 @@ class gogs extends control
$this->gogs->update($gogsID, $gogs);
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
$gogs = $this->gogs->getByID($gogsID);
$gogs = $this->gogs->fetchByID($gogsID);
$actionID = $this->loadModel('action')->create('gogs', $gogsID, 'edited');
$changes = common::createChanges($oldGogs, $gogs);
$this->action->logHistory($actionID, $changes);
@@ -141,7 +141,7 @@ class gogs extends control
*/
public function delete($gogsID)
{
$oldGogs = $this->loadModel('pipeline')->getByID($gogsID);
$oldGogs = $this->loadModel('pipeline')->fetchByID($gogsID);
$actionID = $this->pipeline->deleteByObject($gogsID, 'gogs');
if(!$actionID)
{
@@ -151,7 +151,7 @@ class gogs extends control
return $this->send($response);
}
$gogs = $this->pipeline->getByID($gogsID);
$gogs = $this->pipeline->fetchByID($gogsID);
$changes = common::createChanges($oldGogs, $gogs);
$this->loadModel('action')->logHistory($actionID, $changes);
+3 -16
View File
@@ -12,18 +12,6 @@
class gogsModel extends model
{
/**
* Get a gogs by id.
*
* @param int $id
* @access public
* @return object
*/
public function getByID($id)
{
return $this->loadModel('pipeline')->getByID($id);
}
/**
* Get gogs list.
*
@@ -59,7 +47,7 @@ class gogsModel extends model
*/
public function getApiRoot($gogsID)
{
$gogs = $this->getByID($gogsID);
$gogs = $this->fetchByID($gogsID);
if(!$gogs) return '';
return rtrim($gogs->url, '/') . '/api/v1%s' . "?token={$gogs->token}";
@@ -290,8 +278,7 @@ class gogsModel extends model
$project->http_url_to_repo = $project->html_url;
$project->name_with_namespace = $project->full_name;
$gogs = $this->getByID($gogsID);
$oauth = "{$gogs->token}@";
$gogs = $this->fetchByID($gogsID);
$project->tokenCloneUrl = preg_replace('/(http(s)?:\/\/)/', '${1}' . $gogs->token . '@', $project->html_url);
}
@@ -463,7 +450,7 @@ class gogsModel extends model
$branch = json_decode(commonModel::http($url));
if($branch)
{
$gogs = $this->getByID($gogsID);
$gogs = $this->fetchByID($gogsID);
$branch->web_url = "{$gogs->url}/$project/src/$branchName";
}
+2 -16
View File
@@ -10,20 +10,6 @@ class gogsTest
$this->gogs = $this->tester->loadModel('gogs');
}
/**
* Get by id.
*
* @param int $id
* @access public
* @return object
*/
public function getByID($id)
{
$gogs = $this->gogs->getByID($id);
if(empty($gogs)) return 0;
return $gogs;
}
/**
* Get gogs list.
*
@@ -64,7 +50,7 @@ class gogsTest
return key($errors);
}
return $this->gogs->getById($gogsID);
return $this->gogs->fetchByID($gogsID);
}
/**
@@ -83,6 +69,6 @@ class gogsTest
return key($errors);
}
return $this->gogs->getById($id);
return $this->gogs->fetchByID($id);
}
}
-29
View File
@@ -1,29 +0,0 @@
#!/usr/bin/env php
<?php
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/gogs.class.php';
su('admin');
/**
title=测试gogsModel->gitById();
cid=1
pid=1
使用存在的ID >> 5
使用空的ID >> 0
使用不存在的ID >> 0
*/
$gogs = new gogsTest();
$gogsID = 5;
r($gogs->getById($gogsID)) && p('id') && e('5'); // 使用存在的ID
$gogsID = 0;
r($gogs->getById($gogsID)) && p() && e(0); // 使用空的ID
$gogsID = 111;
r($gogs->getById($gogsID)) && p() && e(0); // 使用不存在的ID
+1 -1
View File
@@ -46,7 +46,7 @@ class instance extends control
}
else
{
$instance = $this->loadModel('gitea')->getByID($id);
$instance = $this->loadModel('gitea')->fetchByID($id);
$instance->status = '';
$instance->source = 'user';
$instance->externalID = $instance->id;