fix connection failed when view empty category, add list order column, add detecting change of package.inc.php

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@8738 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
flyskyko 2011-08-10 02:10:55 +00:00
parent aa7b7de8f5
commit b574bdffe9
17 changed files with 99 additions and 32 deletions

View file

@ -210,12 +210,14 @@
{
$xmlDoc->response->categorylist->item = array($xmlDoc->response->categorylist->item);
}
$list_order = 0;
foreach($xmlDoc->response->categorylist->item as $item)
{
$args = null;
$args->category_srl = $item->category_srl->body;
$args->parent_srl = $item->parent_srl->body;
$args->title = $item->title->body;
$args->list_order = $list_order++;
$output = executeQuery("autoinstall.insertCategory", $args);
}
}

View file

@ -229,6 +229,11 @@
$lUpdateDoc = $xml_lUpdate->parse($buff);
$updateDate = $lUpdateDoc->response->updatedate->body;
if (!$updateDate)
{
return $this->stop('msg_connection_fail');
}
$oModel = &getModel('autoinstall');
$item = $oModel->getLatestPackage();
if(!$item || $item->updatedate < $updateDate || count($this->categories) < 1)
@ -323,7 +328,7 @@
}
else
{
return $this->stop('Connection failed');
return $this->stop('msg_connection_fail');
}
}
}

View file

@ -33,10 +33,24 @@
class autoinstall extends ModuleObject {
var $tmp_dir = './files/cache/autoinstall/';
function autoinstall()
{
$oModuleModel = &getModel('module');
$config = $oModuleModel->getModuleConfig('autoinstall');
if ($config->downloadServer != _XE_DOWNLOAD_SERVER_)
{
$this->stop('msg_not_match_server');
}
}
/**
* @brief for additional tasks required when installing
**/
function moduleInstall() {
$oModuleController = &getController('module');
$config->downloadServer = _XE_DOWNLOAD_SERVER_;
$oModuleController->insertModuleConfig('autoinstall', $config);
}
/**
@ -44,17 +58,26 @@
**/
function checkUpdate() {
$oDB =& DB::getInstance();
if(!file_exists(FileHandler::getRealPath("./modules/autoinstall/schemas/autoinstall_installed_packages.xml"))
$oModuleModel = &getModel('module');
if(!file_exists(FileHandler::getRealPath("./modules/autoinstall/schemas/autoinstall_installed_packages.xml"))
&& $oDB->isTableExists("autoinstall_installed_packages"))
{
return true;
}
if(!file_exists(FileHandler::getRealPath("./modules/autoinstall/schemas/autoinstall_remote_categories.xml"))
if(!file_exists(FileHandler::getRealPath("./modules/autoinstall/schemas/autoinstall_remote_categories.xml"))
&& $oDB->isTableExists("autoinstall_remote_categories"))
{
return true;
}
// 2011.08.08 add column 'list_order' in ai_remote_categories
if (!$oDB->isColumnExists('ai_remote_categories', 'list_order')) return true;
// 2011.08.08 set _XE_DOWNLOAD_SERVER_ at module config
$config = $oModuleModel->getModuleConfig('autoinstall');
if (!isset($config->downloadServer)) return true;
return false;
}
@ -63,16 +86,34 @@
**/
function moduleUpdate() {
$oDB =& DB::getInstance();
if(!file_exists(FileHandler::getRealPath("./modules/autoinstall/schemas/autoinstall_installed_packages.xml"))
$oModuleModel = &getModel('module');
$oModuleController = &getController('module');
if(!file_exists(FileHandler::getRealPath("./modules/autoinstall/schemas/autoinstall_installed_packages.xml"))
&& $oDB->isTableExists("autoinstall_installed_packages"))
{
$oDB->dropTable("autoinstall_installed_packages");
}
if(!file_exists(FileHandler::getRealPath("./modules/autoinstall/schemas/autoinstall_remote_categories.xml"))
if(!file_exists(FileHandler::getRealPath("./modules/autoinstall/schemas/autoinstall_remote_categories.xml"))
&& $oDB->isTableExists("autoinstall_remote_categories"))
{
$oDB->dropTable("autoinstall_remote_categories");
}
// 2011.08.08 add column 'list_order' in 'ai_remote_categories
if (!$oDB->isColumnExists('ai_remote_categories', 'list_order'))
{
$oDB->addColumn('ai_remote_categories', 'list_order', 'number', 11, null, true);
$oDB->addIndex('ai_remote_categories', 'idx_list_order', array('list_order'));
}
// 2011. 08. 08 set _XE_DOWNLOAD_SERVER_ at module config
$config = $oModuleModel->getModuleConfig('autoinstall');
if (!isset($config->downloadServer)){
$config->downloadServer = _XE_DOWNLOAD_SERVER_;
$oModuleController->insertModuleConfig('autoinstall', $config);
}
return new Object(0, 'success_updated');
}

View file

@ -10,7 +10,7 @@
var $download_path;
var $ftp_password;
function setServerUrl($url)
function setServerUrl($url)
{
$this->base_url = $url;
}
@ -18,18 +18,18 @@
function uninstall()
{
$oModel =& getModel('autoinstall');
$type = $oModel->getTypeFromPath($this->package->path);
$type = $oModel->getTypeFromPath($this->package->path);
if($type == "module") {
$output = $this->uninstallModule();
if(!$output->toBool()) return $output;
}
$output = $this->_connect();
if(!$output->toBool()) return $output;
$output = $this->_connect();
if(!$output->toBool()) return $output;
$output = $this->_removeDir($this->package->path);
$this->_close();
return $output;
return $output;
}
function setPassword($ftp_password)
@ -42,7 +42,7 @@
if($this->package->path == ".")
{
$this->download_file = $this->temp_dir."xe.tar";
$this->target_path = "";
$this->target_path = "";
$this->download_path = $this->temp_dir;
}
else
@ -68,11 +68,11 @@
$path_array = explode("/", $this->package->path);
$target_name = array_pop($path_array);
$oModule =& getModule($target_name, "class");
if(!$oModule) return new Object(-1, 'msg_invalid_request');
if(!method_exists($oModule, "moduleUninstall")) return new Object(-1, 'msg_invalid_request');
if(!$oModule) return new Object(-1, 'msg_invalid_request');
if(!method_exists($oModule, "moduleUninstall")) return new Object(-1, 'msg_invalid_request');
$output = $oModule->moduleUninstall();
if(!$output->toBool()) return $output;
if(is_subclass_of($output, 'Object') && !$output->toBool()) return $output;
$schema_dir = sprintf('%s/schemas/', $this->package->path);
$schema_files = FileHandler::readDir($schema_dir);
@ -165,7 +165,7 @@
}
else
{
$output = $this->_removeFile($file_path);
$output = $this->_removeFile($file_path);
if(!$output->toBool()) return $output;
}
}
@ -188,7 +188,7 @@
function _connect() {
if(!$this->ftp_info->ftp_user || !$this->ftp_info->sftp || $this->ftp_info->sftp != 'Y') return new Object(-1,'msg_ftp_invalid_auth_info');
if($this->ftp_info->ftp_host)
{
$ftp_host = $this->ftp_info->ftp_host;
@ -243,7 +243,7 @@
foreach($file_list as $k => $file){
$org_file = $file;
if($this->package->path == ".")
if($this->package->path == ".")
{
$file = substr($file,3);
}
@ -256,7 +256,7 @@
}
ssh2_scp_send($this->connection, FileHandler::getRealPath($this->download_path."/".$org_file), $target_dir."/".$file);
}
}
return new Object();
}
}
@ -286,7 +286,7 @@
$this->connection = ftp_connect($ftp_host, $this->ftp_info->ftp_port);
if(!$this->connection) return new Object(-1, 'msg_ftp_not_connected');
$login_result = @ftp_login($this->connection, $this->ftp_info->ftp_user, $this->ftp_password);
$login_result = @ftp_login($this->connection, $this->ftp_info->ftp_user, $this->ftp_password);
if(!$login_result)
{
$this->_close();
@ -294,7 +294,7 @@
}
$_SESSION['ftp_password'] = $this->ftp_password;
if($this->ftp_info->ftp_pasv != "N")
if($this->ftp_info->ftp_pasv != "N")
{
ftp_pasv($this->connection, true);
}
@ -333,13 +333,13 @@
function _copyDir(&$file_list) {
if(!$this->ftp_password) return new Object(-1,'msg_ftp_password_input');
$output = $this->_connect();
$output = $this->_connect();
if(!$output->toBool()) return $output;
$target_dir = $this->ftp_info->ftp_root_path.$this->target_path;
foreach($file_list as $k => $file){
$org_file = $file;
if($this->package->path == ".")
if($this->package->path == ".")
{
$file = substr($file,3);
}
@ -358,7 +358,7 @@
{
if(!@ftp_mkdir($this->connection, $ftp_path))
{
return new Object(-1, "msg_make_directory_failed");
return new Object(-1, "msg_make_directory_failed");
}
if(!stristr(PHP_OS, 'win'))
@ -383,7 +383,7 @@
{
return new Object(-1, "msg_ftp_upload_failed");
}
}
}
$this->_close();
return new Object();
@ -452,7 +452,7 @@
if(!$this->ftp_password) return new Object(-1,'msg_ftp_password_input');
require_once(_XE_PATH_.'libs/ftp.class.php');
$output = $this->_connect();
if(!$output->toBool()) return $output;
@ -461,7 +461,7 @@
foreach($file_list as $k => $file){
$org_file = $file;
if($this->package->path == ".")
if($this->package->path == ".")
{
$file = substr($file,3);
}
@ -483,7 +483,7 @@
}
}
$oFtp->ftp_put($target_dir .'/'. $file, FileHandler::getRealPath($this->download_path."/".$org_file));
}
}
$this->_close();

View file

@ -37,4 +37,6 @@
$lang->dependant_list = "Dependant package list of the current package";
$lang->msg_avail_update = 'There is available update for this item.';
$lang->msg_do_you_like_update = 'Would you like to update?';
$lang->msg_connection_fail = 'Connection failed.';
$lang->msg_not_match_server = 'Server settings are incorrect.';
?>

View file

@ -36,4 +36,6 @@
$lang->dependant_list = "このパッケージに依存するパッケージのリスト";
$lang->msg_avail_update = 'There is available update for this item.';
$lang->msg_do_you_like_update = 'Would you like to update?';
$lang->msg_connection_fail = 'Connection failed.';
$lang->msg_not_match_server = 'Server settings are incorrect.';
?>

View file

@ -36,4 +36,6 @@
$lang->dependant_list = "이 패키지에 의존하는 패키지 목록";
$lang->msg_avail_update = '이 항목 업데이트가 가능합니다.';
$lang->msg_do_you_like_update = '업데이트 하시겠습니까?';
$lang->msg_connection_fail = '서버 접속이 원할하지 않습니다.';
$lang->msg_not_match_server = '서버 설정이 올바르지 않습니다.';
?>

View file

@ -36,4 +36,6 @@
$lang->dependant_list = "Dependant package list of the current package";
$lang->msg_avail_update = 'There is available update for this item.';
$lang->msg_do_you_like_update = 'Would you like to update?';
$lang->msg_connection_fail = 'Connection failed.';
$lang->msg_not_match_server = 'Server settings are incorrect.';
?>

View file

@ -36,4 +36,6 @@
$lang->dependant_list = "Mevcut pakete bağlı paket listesi";
$lang->msg_avail_update = 'There is available update for this item.';
$lang->msg_do_you_like_update = 'Would you like to update?';
$lang->msg_connection_fail = 'Connection failed.';
$lang->msg_not_match_server = 'Server settings are incorrect.';
?>

View file

@ -36,4 +36,6 @@
$lang->dependant_list = "Gói cài đặt này phụ thuộc vào các gói khác trong danh sách";
$lang->msg_avail_update = 'There is available update for this item.';
$lang->msg_do_you_like_update = 'Would you like to update?';
$lang->msg_connection_fail = 'Connection failed.';
$lang->msg_not_match_server = 'Server settings are incorrect.';
?>

View file

@ -36,4 +36,6 @@
$lang->dependant_list = "联动数据包列表";
$lang->msg_avail_update = 'There is available update for this item.';
$lang->msg_do_you_like_update = 'Would you like to update?';
$lang->msg_connection_fail = 'Connection failed.';
$lang->msg_not_match_server = 'Server settings are incorrect.';
?>

View file

@ -37,4 +37,6 @@
$lang->dependant_list = "與此程式相關程式列表";
$lang->msg_avail_update = 'There is available update for this item.';
$lang->msg_do_you_like_update = 'Would you like to update?';
$lang->msg_connection_fail = 'Connection failed.';
$lang->msg_not_match_server = 'Server settings are incorrect.';
?>

View file

@ -5,4 +5,7 @@
<columns>
<column name="*" />
</columns>
<navigation>
<index default="list_order" var="list_order" order="asc" />
</navigation>
</query>

View file

@ -6,5 +6,6 @@
<column name="category_srl" var="category_srl" filter="number" notnull="notnull" />
<column name="parent_srl" var="parent_srl" filter="number" notnull="notnull" />
<column name="title" var="title" minlength="1" maxlength="250" />
<column name="list_order" var="list_order" filter="number" notnull="notnull" />
</columns>
</query>

View file

@ -2,4 +2,5 @@
<column name="category_srl" type="number" size="11" default="0" notnull="notnull" primary_key="primary_key" />
<column name="parent_srl" type="number" size="11" default="0" notnull="notnull" index="idx_parent_srl" />
<column name="title" type="varchar" size="250" notnull="notnull" />
<column name="list_order" type="number" size="11" notnull="notnull" index="idx_list_order" />
</table>

View file

@ -11,11 +11,9 @@
<form action="" method="post">
<input type="hidden" name="module" value="autoinstall" />
<input type="hidden" name="act" value="procAutoinstallAdminUpdateinfo" />
{@$btnUpdate = sprintf('<input type="submit" value="%s" />', $lang->status_update)}
{@$btnUpdate = sprintf('<input type="submit" value="%s" class="text" />', $lang->status_update)}
{sprintf($lang->description_update, $btnUpdate)}
</form>
</p>
<block cond="$item_list">
<include target="list.html" />
</block>
<include target="list.html" />

View file

@ -68,7 +68,7 @@
</table>
</div>
<div class="search">
<form action="./" class="pagination">
<form action="./" class="pagination" cond="$page_navigation">
<input type="hidden" name="error_return_url" value="" />
<input type="hidden" name="module" value="{$module}" />
<input type="hidden" name="act" value="{$act}" />