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); $xmlDoc->response->categorylist->item = array($xmlDoc->response->categorylist->item);
} }
$list_order = 0;
foreach($xmlDoc->response->categorylist->item as $item) foreach($xmlDoc->response->categorylist->item as $item)
{ {
$args = null; $args = null;
$args->category_srl = $item->category_srl->body; $args->category_srl = $item->category_srl->body;
$args->parent_srl = $item->parent_srl->body; $args->parent_srl = $item->parent_srl->body;
$args->title = $item->title->body; $args->title = $item->title->body;
$args->list_order = $list_order++;
$output = executeQuery("autoinstall.insertCategory", $args); $output = executeQuery("autoinstall.insertCategory", $args);
} }
} }

View file

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

View file

@ -33,10 +33,24 @@
class autoinstall extends ModuleObject { class autoinstall extends ModuleObject {
var $tmp_dir = './files/cache/autoinstall/'; 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 * @brief for additional tasks required when installing
**/ **/
function moduleInstall() { function moduleInstall() {
$oModuleController = &getController('module');
$config->downloadServer = _XE_DOWNLOAD_SERVER_;
$oModuleController->insertModuleConfig('autoinstall', $config);
} }
/** /**
@ -44,17 +58,26 @@
**/ **/
function checkUpdate() { function checkUpdate() {
$oDB =& DB::getInstance(); $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")) && $oDB->isTableExists("autoinstall_installed_packages"))
{ {
return true; 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")) && $oDB->isTableExists("autoinstall_remote_categories"))
{ {
return true; 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; return false;
} }
@ -63,16 +86,34 @@
**/ **/
function moduleUpdate() { function moduleUpdate() {
$oDB =& DB::getInstance(); $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->isTableExists("autoinstall_installed_packages"))
{ {
$oDB->dropTable("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->isTableExists("autoinstall_remote_categories"))
{ {
$oDB->dropTable("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'); return new Object(0, 'success_updated');
} }

View file

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

View file

@ -37,4 +37,6 @@
$lang->dependant_list = "Dependant package list of the current package"; $lang->dependant_list = "Dependant package list of the current package";
$lang->msg_avail_update = 'There is available update for this item.'; $lang->msg_avail_update = 'There is available update for this item.';
$lang->msg_do_you_like_update = 'Would you like to update?'; $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->dependant_list = "このパッケージに依存するパッケージのリスト";
$lang->msg_avail_update = 'There is available update for this item.'; $lang->msg_avail_update = 'There is available update for this item.';
$lang->msg_do_you_like_update = 'Would you like to update?'; $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->dependant_list = "이 패키지에 의존하는 패키지 목록";
$lang->msg_avail_update = '이 항목 업데이트가 가능합니다.'; $lang->msg_avail_update = '이 항목 업데이트가 가능합니다.';
$lang->msg_do_you_like_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->dependant_list = "Dependant package list of the current package";
$lang->msg_avail_update = 'There is available update for this item.'; $lang->msg_avail_update = 'There is available update for this item.';
$lang->msg_do_you_like_update = 'Would you like to update?'; $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->dependant_list = "Mevcut pakete bağlı paket listesi";
$lang->msg_avail_update = 'There is available update for this item.'; $lang->msg_avail_update = 'There is available update for this item.';
$lang->msg_do_you_like_update = 'Would you like to update?'; $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->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_avail_update = 'There is available update for this item.';
$lang->msg_do_you_like_update = 'Would you like to update?'; $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->dependant_list = "联动数据包列表";
$lang->msg_avail_update = 'There is available update for this item.'; $lang->msg_avail_update = 'There is available update for this item.';
$lang->msg_do_you_like_update = 'Would you like to update?'; $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->dependant_list = "與此程式相關程式列表";
$lang->msg_avail_update = 'There is available update for this item.'; $lang->msg_avail_update = 'There is available update for this item.';
$lang->msg_do_you_like_update = 'Would you like to update?'; $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> <columns>
<column name="*" /> <column name="*" />
</columns> </columns>
<navigation>
<index default="list_order" var="list_order" order="asc" />
</navigation>
</query> </query>

View file

@ -6,5 +6,6 @@
<column name="category_srl" var="category_srl" filter="number" notnull="notnull" /> <column name="category_srl" var="category_srl" filter="number" notnull="notnull" />
<column name="parent_srl" var="parent_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="title" var="title" minlength="1" maxlength="250" />
<column name="list_order" var="list_order" filter="number" notnull="notnull" />
</columns> </columns>
</query> </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="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="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="title" type="varchar" size="250" notnull="notnull" />
<column name="list_order" type="number" size="11" notnull="notnull" index="idx_list_order" />
</table> </table>

View file

@ -11,11 +11,9 @@
<form action="" method="post"> <form action="" method="post">
<input type="hidden" name="module" value="autoinstall" /> <input type="hidden" name="module" value="autoinstall" />
<input type="hidden" name="act" value="procAutoinstallAdminUpdateinfo" /> <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)} {sprintf($lang->description_update, $btnUpdate)}
</form> </form>
</p> </p>
<block cond="$item_list"> <include target="list.html" />
<include target="list.html" />
</block>

View file

@ -68,7 +68,7 @@
</table> </table>
</div> </div>
<div class="search"> <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="error_return_url" value="" />
<input type="hidden" name="module" value="{$module}" /> <input type="hidden" name="module" value="{$module}" />
<input type="hidden" name="act" value="{$act}" /> <input type="hidden" name="act" value="{$act}" />