From b574bdffe9dfe2876fff6c7e247e69aaf2b73682 Mon Sep 17 00:00:00 2001
From: flyskyko
Date: Wed, 10 Aug 2011 02:10:55 +0000
Subject: [PATCH] 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
---
.../autoinstall.admin.controller.php | 2 +
.../autoinstall/autoinstall.admin.view.php | 7 ++-
modules/autoinstall/autoinstall.class.php | 49 +++++++++++++++++--
modules/autoinstall/autoinstall.lib.php | 44 ++++++++---------
modules/autoinstall/lang/en.lang.php | 2 +
modules/autoinstall/lang/jp.lang.php | 2 +
modules/autoinstall/lang/ko.lang.php | 2 +
modules/autoinstall/lang/ru.lang.php | 2 +
modules/autoinstall/lang/tr.lang.php | 2 +
modules/autoinstall/lang/vi.lang.php | 2 +
modules/autoinstall/lang/zh-CN.lang.php | 2 +
modules/autoinstall/lang/zh-TW.lang.php | 2 +
modules/autoinstall/queries/getCategories.xml | 3 ++
.../autoinstall/queries/insertCategory.xml | 1 +
.../schemas/ai_remote_categories.xml | 1 +
modules/autoinstall/tpl/index.html | 6 +--
modules/autoinstall/tpl/list.html | 2 +-
17 files changed, 99 insertions(+), 32 deletions(-)
diff --git a/modules/autoinstall/autoinstall.admin.controller.php b/modules/autoinstall/autoinstall.admin.controller.php
index 643c59b24..5af20aebe 100644
--- a/modules/autoinstall/autoinstall.admin.controller.php
+++ b/modules/autoinstall/autoinstall.admin.controller.php
@@ -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);
}
}
diff --git a/modules/autoinstall/autoinstall.admin.view.php b/modules/autoinstall/autoinstall.admin.view.php
index 2cccb20e4..420f9aec7 100644
--- a/modules/autoinstall/autoinstall.admin.view.php
+++ b/modules/autoinstall/autoinstall.admin.view.php
@@ -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');
}
}
}
diff --git a/modules/autoinstall/autoinstall.class.php b/modules/autoinstall/autoinstall.class.php
index 070806026..648ff56f6 100644
--- a/modules/autoinstall/autoinstall.class.php
+++ b/modules/autoinstall/autoinstall.class.php
@@ -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');
}
diff --git a/modules/autoinstall/autoinstall.lib.php b/modules/autoinstall/autoinstall.lib.php
index 958ef1d20..b3d903394 100644
--- a/modules/autoinstall/autoinstall.lib.php
+++ b/modules/autoinstall/autoinstall.lib.php
@@ -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();
diff --git a/modules/autoinstall/lang/en.lang.php b/modules/autoinstall/lang/en.lang.php
index 87a4fa05b..f136d56ec 100644
--- a/modules/autoinstall/lang/en.lang.php
+++ b/modules/autoinstall/lang/en.lang.php
@@ -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.';
?>
diff --git a/modules/autoinstall/lang/jp.lang.php b/modules/autoinstall/lang/jp.lang.php
index 4296a540d..29c38438e 100644
--- a/modules/autoinstall/lang/jp.lang.php
+++ b/modules/autoinstall/lang/jp.lang.php
@@ -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.';
?>
diff --git a/modules/autoinstall/lang/ko.lang.php b/modules/autoinstall/lang/ko.lang.php
index f58020900..f54107416 100644
--- a/modules/autoinstall/lang/ko.lang.php
+++ b/modules/autoinstall/lang/ko.lang.php
@@ -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 = '서버 설정이 올바르지 않습니다.';
?>
diff --git a/modules/autoinstall/lang/ru.lang.php b/modules/autoinstall/lang/ru.lang.php
index 47a8c2bfd..02c005be3 100644
--- a/modules/autoinstall/lang/ru.lang.php
+++ b/modules/autoinstall/lang/ru.lang.php
@@ -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.';
?>
diff --git a/modules/autoinstall/lang/tr.lang.php b/modules/autoinstall/lang/tr.lang.php
index e3b7ee750..c6c9bafd6 100644
--- a/modules/autoinstall/lang/tr.lang.php
+++ b/modules/autoinstall/lang/tr.lang.php
@@ -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.';
?>
diff --git a/modules/autoinstall/lang/vi.lang.php b/modules/autoinstall/lang/vi.lang.php
index 61a5a963c..826532566 100644
--- a/modules/autoinstall/lang/vi.lang.php
+++ b/modules/autoinstall/lang/vi.lang.php
@@ -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.';
?>
diff --git a/modules/autoinstall/lang/zh-CN.lang.php b/modules/autoinstall/lang/zh-CN.lang.php
index 084d329dc..ef4e50f28 100644
--- a/modules/autoinstall/lang/zh-CN.lang.php
+++ b/modules/autoinstall/lang/zh-CN.lang.php
@@ -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.';
?>
diff --git a/modules/autoinstall/lang/zh-TW.lang.php b/modules/autoinstall/lang/zh-TW.lang.php
index 91a625926..749b24af4 100644
--- a/modules/autoinstall/lang/zh-TW.lang.php
+++ b/modules/autoinstall/lang/zh-TW.lang.php
@@ -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.';
?>
diff --git a/modules/autoinstall/queries/getCategories.xml b/modules/autoinstall/queries/getCategories.xml
index 8c680a7b3..977fb6e04 100644
--- a/modules/autoinstall/queries/getCategories.xml
+++ b/modules/autoinstall/queries/getCategories.xml
@@ -5,4 +5,7 @@
+
+
+
diff --git a/modules/autoinstall/queries/insertCategory.xml b/modules/autoinstall/queries/insertCategory.xml
index ef09fec86..e993dd262 100644
--- a/modules/autoinstall/queries/insertCategory.xml
+++ b/modules/autoinstall/queries/insertCategory.xml
@@ -6,5 +6,6 @@
+
diff --git a/modules/autoinstall/schemas/ai_remote_categories.xml b/modules/autoinstall/schemas/ai_remote_categories.xml
index f35939259..27b390f82 100644
--- a/modules/autoinstall/schemas/ai_remote_categories.xml
+++ b/modules/autoinstall/schemas/ai_remote_categories.xml
@@ -2,4 +2,5 @@
+
diff --git a/modules/autoinstall/tpl/index.html b/modules/autoinstall/tpl/index.html
index bfc82301a..5874661f9 100644
--- a/modules/autoinstall/tpl/index.html
+++ b/modules/autoinstall/tpl/index.html
@@ -11,11 +11,9 @@
-
-
-
+
diff --git a/modules/autoinstall/tpl/list.html b/modules/autoinstall/tpl/list.html
index b31b6f641..589348e7d 100644
--- a/modules/autoinstall/tpl/list.html
+++ b/modules/autoinstall/tpl/list.html
@@ -68,7 +68,7 @@
-