diff --git a/module/tree/control.php b/module/tree/control.php
index af23381787..2f535e5cc8 100644
--- a/module/tree/control.php
+++ b/module/tree/control.php
@@ -53,6 +53,7 @@ class tree extends control
if($viewType == 'story')
{
$this->product->setMenu($this->product->getPairs(), $rootID, 'story');
+ $this->view->allProduct = $this->product->getPairs();
$this->lang->tree->menu = $this->lang->product->menu;
$this->lang->set('menugroup.tree', 'product');
@@ -200,6 +201,8 @@ class tree extends control
*/
public function ajaxGetOptionMenu($rootID, $viewType = 'story', $rootModuleID = 0)
{
+
+ $this->view->productModules = $this->tree->getOptionMenu($rootID, 'story');
$optionMenu = $this->tree->getOptionMenu($rootID, $viewType, $rootModuleID);
die( html::select("module", $optionMenu, '', 'onchange=setAssignedTo()'));
}
@@ -223,4 +226,17 @@ class tree extends control
foreach($modules as $key => $name) $modules[$key] = str_replace(" "," ","$name");
die(json_encode($modules));
}
+ /**
+ * AJAX: get modules.
+ *
+ * @param int $moduleID
+ * @param int $rootID
+ * @access public
+ * @return string json_encoded modules.
+ */
+ public function ajaxGetModules($rootID = 0, $type='story')
+ {
+ $modules = $this->tree->getOptionMenu($rootID, 'story');
+ die(json_encode($modules));
+ }
}
diff --git a/module/tree/js/browse.js b/module/tree/js/browse.js
index 92e111dec0..d0eaf27266 100644
--- a/module/tree/js/browse.js
+++ b/module/tree/js/browse.js
@@ -1,4 +1,4 @@
-function syncModule()
+function syncModule(rootID)
{
link = createLink('tree', 'ajaxGetSonModules', 'moduleID=' + $('#productModule').val() + '&rootID=' + rootID);
$.getJSON(link, function(modules)
@@ -19,6 +19,20 @@ function syncModule()
})
})
}
+function syncProduct(obj)
+{
+ link = createLink('tree', 'ajaxGetModules', 'rootID=' + obj.value);
+ $.getJSON(link, function(modules)
+ {
+ $('.helplink').addClass('hidden');
+ $('#productModule').empty();
+ $.each(modules, function(key, value)
+ {
+ $('#productModule').append('tree->syncFromProduct, 'onclick=syncModule()');
+ echo html::commonButton($lang->tree->syncFromProduct, 'onclick=syncModule('.$rootID.')');
+ echo '
';
+ }
+ else if($viewType == 'story')
+ {
+ echo html::select('allProduct', $allProduct, $rootID, 'class=select-3 onchange=syncProduct(this)');
+ echo '
';
+ echo html::select('productModule', $productModules, '', 'class=select-3');
+ echo html::commonButton($lang->tree->syncFromProduct, 'id=copyModule onclick=syncModule('.$rootID.')');
echo '
';
}
$maxOrder = 0;