addon module not yet complete

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@9029 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
flyskyko 2011-09-05 07:51:52 +00:00
parent a9cc4543fe
commit 425b02531f
14 changed files with 352 additions and 209 deletions

View file

@ -14,6 +14,88 @@
function init() {
}
/**
* @brief Set addon activate
**/
function procAddonAdminSaveActivate()
{
$pc = Context::get('pc');
$mobile = Context::get('mobile');
$fixed = Context::get('fixed');
$favorite = Context::get('favorite');
if (!$pc) $pc = array();
if (!$mobile) $mobile = array();
if (!$fixed) $fixed = array();
if (!$favorite) $favorite = array();
// get current addon info
$oModel = &getAdminModel('addon');
$currentAddonList = $oModel->getAddonList(0, 'global');
// get need update addon list
$updateList = array();
foreach($currentAddonList as $addon)
{
if ($addon->activated !== in_array($addon->addon_name, $pc))
{
$updateList[] = $addon->addon_name;
continue;
}
if ($addon->mactivated !== in_array($addon->addon_name, $mobile))
{
$updateList[] = $addon->addon_name;
continue;
}
if ($addon->fixed !== in_array($addon->addon_name, $fixed))
{
$updateList[] = $addon->addon_name;
continue;
}
}
// update
foreach($updateList as $targetAddon)
{
unset($args);
if (in_array($targetAddon, $pc))
$args->is_used = 'Y';
else
$args->is_used = 'N';
if (in_array($targetAddon, $mobile))
$args->is_used_m = 'Y';
else
$args->is_used_m = 'N';
if (in_array($targetAddon, $fixed))
$args->fixed = 'Y';
else
$args->fixed = 'N';
$args->addon = $targetAddon;
$output = executeQuery('addon.updateAddon', $args);
if (!$output->toBool()) return $output;
}
if (count($updateList))
{
$this->makeCacheFile(0, 'pc', 'global');
$this->makeCacheFile(0, 'mobile', 'global');
}
// set favorite
$oAdminController = &getAdminController('admin');
$output = $oAdminController->setFavoritesByModule(-1, 'addon', $favorite);
if (!$output->toBool()) return $output;
$this->setRedirectUrl(getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAddonAdminIndex'));
}
/**
* @brief Add active/inactive change
**/
@ -45,13 +127,17 @@
unset($args->act);
unset($args->addon_name);
unset($args->body);
unset($args->error_return_url);
$site_module_info = Context::get('site_module_info');
$this->doSetup($addon_name, $args, $site_module_info->site_srl);
$output = $this->doSetup($addon_name, $args, $site_module_info->site_srl, 'global');
if (!$output->toBool()) return $output;
$this->makeCacheFile($site_module_info->site_srl, "pc");
$this->makeCacheFile($site_module_info->site_srl, "mobile");
$this->makeCacheFile($site_module_info->site_srl, "pc", 'global');
$this->makeCacheFile($site_module_info->site_srl, "mobile", 'global');
$this->setRedirectUrl(getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAddonAdminSetup', 'selected_addon', $addon_name));
}
@ -60,10 +146,10 @@
* @brief Add-on
* Adds Add to DB
**/
function doInsert($addon, $site_srl = 0) {
function doInsert($addon, $site_srl = 0, $gtype = 'site') {
$args->addon = $addon;
$args->is_used = 'N';
if(!$site_srl) return executeQuery('addon.insertAddon', $args);
if($gtype == 'global') return executeQuery('addon.insertAddon', $args);
$args->site_srl = $site_srl;
return executeQuery('addon.insertSiteAddon', $args);
}
@ -72,11 +158,11 @@
* @brief Add-activated
* addons add-ons to the table on the activation state sikyeojum
**/
function doActivate($addon, $site_srl = 0, $type = "pc") {
function doActivate($addon, $site_srl = 0, $type = "pc", $gtype = 'site') {
$args->addon = $addon;
if($type == "pc") $args->is_used = 'Y';
else $args->is_used_m = "Y";
if(!$site_srl) return executeQuery('addon.updateAddon', $args);
if($gtype == 'global') return executeQuery('addon.updateAddon', $args);
$args->site_srl = $site_srl;
return executeQuery('addon.updateSiteAddon', $args);
}
@ -86,11 +172,11 @@
*
* addons add a table to remove the name of the deactivation is sikige
**/
function doDeactivate($addon, $site_srl = 0, $type = "pc") {
function doDeactivate($addon, $site_srl = 0, $type = "pc", $gtype = 'site') {
$args->addon = $addon;
if($type == "pc") $args->is_used = 'N';
else $args->is_used_m = 'N';
if(!$site_srl) return executeQuery('addon.updateAddon', $args);
if($gtype == 'global') return executeQuery('addon.updateAddon', $args);
$args->site_srl = $site_srl;
return executeQuery('addon.updateSiteAddon', $args);
}