diff --git a/source/plg_system_t3/admin/megamenu/js/megamenu.js b/source/plg_system_t3/admin/megamenu/js/megamenu.js
index 78bcf783b7..f06524ac76 100644
--- a/source/plg_system_t3/admin/megamenu/js/megamenu.js
+++ b/source/plg_system_t3/admin/megamenu/js/megamenu.js
@@ -708,10 +708,44 @@ var T3AdminMegamenu = window.T3AdminMegamenu || {};
url: T3AdminMegamenu.site,
data: {
t3action: 'module',
- mid: value
+ mid: value,
+ styleid: T3AdminMegamenu.styleid,
+ template: T3AdminMegamenu.template,
+
+ t3menu: $('#menu-type').val(),
+ t3acl: $('#access-level').val(),
+ t3lang: $('#menu-type :selected').attr('data-language') || '*'
}
}).done(function ( data ) {
- currentSelected.find('.mega-inner').html(data).find(':input').removeAttr('name');
+ if(data){
+ if(data.charAt(0) == '{' || data.charAt(0) == '['){
+ try {
+ data = $.parseJSON(data);
+ } catch(e){
+ data = false;
+ }
+
+ if(data && data.message){
+ clearTimeout($('#ajax-message').data('sid'));
+ $('#ajax-message')
+ .removeClass('alert-error alert-success')
+ .addClass('alert-error')
+ .addClass('in')
+ .data('sid', setTimeout(function(){
+ $('#ajax-message').removeClass('in')
+ }, 5000))
+ .find('strong')
+ .html(data.message);
+ }
+
+ //not valid value => we set to empty
+ $(input).val('').trigger('liszt:updated');
+ currentSelected.data (name, '');
+
+ } else {
+ currentSelected.find('.mega-inner').html(data).find(':input').removeAttr('name');
+ }
+ }
});
} else {
currentSelected.find('.mega-inner').html('');
diff --git a/source/plg_system_t3/includes/core/action.php b/source/plg_system_t3/includes/core/action.php
index d49425fdce..3be627b24a 100644
--- a/source/plg_system_t3/includes/core/action.php
+++ b/source/plg_system_t3/includes/core/action.php
@@ -178,35 +178,57 @@ public static function megamenu() {
}
public static function module () {
- $input = JFactory::getApplication()->input;
- $id = $input->getInt ('mid');
+ $user = JFactory::getUser();
+ $input = JFactory::getApplication()->input;
+ $id = $input->getInt('mid');
+ $t3acl = (int)$input->get('t3acl', 1);
+ $groups = $user->getAuthorisedViewLevels();
$module = null;
+ $buffer = null;
+
+ array_push($groups, $t3acl);
+
+ if (is_array($groups) && in_array(3, $groups)) {
+ //we assume, if a user is special, they should be registered also
+ $groups[] = 2;
+ }
+
if ($id) {
// load module
$db = JFactory::getDbo();
$query = $db->getQuery(true);
- $query->select('m.id, m.title, m.module, m.position, m.content, m.showtitle, m.params')
+ $query
+ ->select('m.id, m.title, m.module, m.position, m.content, m.showtitle, m.params')
->from('#__modules AS m')
->where('m.id = '.$id)
- ->where('m.published = 1');
+ ->where('m.published = 1')
+ ->where('m.access IN ('.implode(',', array_unique($groups)).')');
$db->setQuery($query);
- $module = $db->loadObject ();
+ $module = $db->loadObject();
}
if (!empty ($module)) {
- $style = $input->getCmd ('style', 'T3Xhtml');
+ $style = $input->getCmd ('style', 'T3Xhtml');
$buffer = JModuleHelper::renderModule($module, array('style'=>$style));
+
// replace relative images url
- $base = JURI::base(true).'/';
+ $base = JURI::base(true).'/';
$protocols = '[a-zA-Z0-9]+:'; //To check for all unknown protocals (a protocol must contain at least one alpahnumeric fillowed by :
$regex = '#(src)="(?!/|' . $protocols . '|\#|\')([^"]*)"#m';
$buffer = preg_replace($regex, "$1=\"$base\$2\"", $buffer);
}
- //remove invisibile content, there are more ... but ...
- $buffer = preg_replace(array( '@@siu', '@@siu'), array('', ''), $buffer);
+ if($buffer){
+ //remove invisibile content, there are more ... but ...
+ $buffer = preg_replace(array( '@@siu', '@@siu'), array('', ''), $buffer);
- echo $buffer;
+ echo $buffer;
+ } else {
+ die(json_encode(array(
+ 'message' => JText::_('T3_MSG_MODULE_NOT_AVAIL')
+ )));
+ }
+
}
//translate param name to new name, from jvalue => to desired param name
diff --git a/source/plg_system_t3/includes/menu/megamenu.php b/source/plg_system_t3/includes/menu/megamenu.php
index b541dc6819..47e521450c 100644
--- a/source/plg_system_t3/includes/menu/megamenu.php
+++ b/source/plg_system_t3/includes/menu/megamenu.php
@@ -19,8 +19,8 @@ class T3MenuMegamenu {
/**
* Internal variables
*/
- protected $children = array();
protected $_items = array();
+ protected $children = array();
protected $settings = null;
protected $params = null;
protected $menu = '';
@@ -43,6 +43,8 @@ function __construct($menutype = 'mainmenu', $settings = array(), $params = null
if(isset($settings['access'])){
$attributes[] = 'access';
$values[] = $settings['access'];
+ } else {
+ $settings['access'] = array(1);
}
if(isset($settings['language'])){
@@ -310,10 +312,12 @@ function module($module) {
$id = intval($module);
$db = JFactory::getDbo();
$query = $db->getQuery(true);
- $query->select('m.id, m.title, m.module, m.position, m.content, m.showtitle, m.params');
- $query->from('#__modules AS m');
- $query->where('m.id = ' . $id);
- $query->where('m.published = 1');
+ $query
+ ->select('m.id, m.title, m.module, m.position, m.content, m.showtitle, m.params')
+ ->from('#__modules AS m')
+ ->where('m.id = ' . $id)
+ ->where('m.published = 1')
+ ->where('m.access IN ('.implode(',', $this->settings['access']).')');
$db->setQuery($query);
$module = $db->loadObject();
diff --git a/source/plg_system_t3/language/en-GB/en-GB.plg_system_t3.ini b/source/plg_system_t3/language/en-GB/en-GB.plg_system_t3.ini
index 6266795d08..30db29e4c8 100644
--- a/source/plg_system_t3/language/en-GB/en-GB.plg_system_t3.ini
+++ b/source/plg_system_t3/language/en-GB/en-GB.plg_system_t3.ini
@@ -472,3 +472,4 @@ T3_MSG_FILE_NOT_WRITABLE ="File system Not writable. Please check again server
T3_MSG_PACKAGE_DAMAGED ="The framework has not been installed correctly"
T3_MSG_DEVFOLDER_NOT_WRITABLE ="Cannot create css cached file in development folder: %s"
T3_MSG_LESS_NOT_VALID ="Template Less structure was not compatible with T3 compiler"
+T3_MSG_MODULE_NOT_AVAIL ="This module might not available with current Access Level"