public function onUserLogout($options) { // No remember me for admin if ($this->app->isAdmin()) { return false; } $cookieName = JUserHelper::getShortHashedUserAgent(); // Check for the cookie if ($this->app->input->cookie->get($cookieName)) { // Make sure authentication group is loaded to process onUserAfterLogout event JPluginHelper::importPlugin('authentication'); } }
function onUserLogout($user, $options = array()) { $mainframe = JFactory::getApplication('site'); if (array_key_exists('skip_joomdlehooks', $options)) { return true; } if ($mainframe->isAdmin()) { return true; } $comp_params = JComponentHelper::getParams('com_joomdle'); $redirectless_logout = $comp_params->get('redirectless_logout'); if (!$redirectless_logout) { // Delete "remember me" cookie if present $cookieName = JUserHelper::getShortHashedUserAgent(); $cookieValue = $this->app->input->cookie->get($cookieName); if ($cookieValue) { $cookieArray = explode('.', $cookieValue); // Filter series since we're going to use it in the query $filter = new JFilterInput(); $series = $filter->clean($cookieArray[1], 'ALNUM'); // Remove the record from the database $query = $this->db->getQuery(true); $query->delete('#__user_keys')->where($this->db->quoteName('series') . ' = ' . $this->db->quote($series)); $this->db->setQuery($query)->execute(); // Destroy the cookie $this->app->input->cookie->set($cookieName, false, time() - 42000, $this->app->get('cookie_path', '/'), $this->app->get('cookie_domain')); } $moodle_url = $comp_params->get('MOODLE_URL'); $app = JFactory::getApplication(); $app->redirect($moodle_url . "/auth/joomdle/land_logout.php"); return; } // if (!array_key_exists ('MoodleSession', $_COOKIE)) // return; $cookie_path = $comp_params->get('cookie_path', "/"); $old_session = session_id(); session_name("MoodleSession"); session_id(""); @session_destroy(); // session_unregister("USER"); // session_unregister("SESSION"); unset($_SESSION['USER']); unset($_SESSION['SESSION']); setcookie('MoodleSession', '', time() - 3600, $cookie_path, '', '', 0); unset($_SESSION); return true; }
public function onUserAfterLogin($options) { $jcookie = JFactory::getApplication()->input->cookie; $jcookie->set('fc_uid', JUserHelper::getShortHashedUserAgent(), 0); }
/** * This is where we delete any authentication cookie when a user logs out * * @param array $options Array holding options (length, timeToExpiration) * * @return boolean True on success * * @since 3.2 */ public function onUserAfterLogout($options) { // No remember me for admin if ($this->app->isAdmin()) { return false; } $cookieName = JUserHelper::getShortHashedUserAgent(); $cookieValue = $this->app->input->cookie->get($cookieName); // There are no cookies to delete. if (!$cookieValue) { return true; } $cookieArray = explode('.', $cookieValue); // Filter series since we're going to use it in the query $filter = new JFilterInput(); $series = $filter->clean($cookieArray[1], 'ALNUM'); // Remove the record from the database $query = $this->db->getQuery(true); $query->delete('#__user_keys')->where($this->db->quoteName('series') . ' = ' . $this->db->quote($series)); $this->db->setQuery($query)->execute(); // Destroy the cookie $this->app->input->cookie->set($cookieName, false, time() - 42000, $this->app->get('cookie_path', '/'), $this->app->get('cookie_domain')); return true; }
/** * Utility function to load each JS Frameworks once * * @param string $text * @param int $nb * @return string * @since 1.5 */ static function loadFramework($framework, $mode = '') { // Detect already loaded framework static $_loaded = array(); if (isset($_loaded[$framework])) { return $_loaded[$framework]; } $_loaded[$framework] = false; // Get frameworks that are configured to be loaded manually in frontend (e.g. via the Joomla template) $app = JFactory::getApplication(); static $load_frameworks = null; static $load_jquery = null; if (!isset($load_frameworks[$framework])) { $flexiparams = JComponentHelper::getParams('com_flexicontent'); //$load_frameworks = $flexiparams->get('load_frameworks', array('jQuery','image-picker','masonry','select2','inputmask','prettyCheckable','fancybox')); //$load_frameworks = FLEXIUtilities::paramToArray($load_frameworks); //$load_frameworks = array_flip($load_frameworks); //$load_jquery = isset($load_frameworks['jQuery']) || !$app->isSite(); if ($load_jquery === null) { $load_jquery = $flexiparams->get('loadfw_jquery', 1) == 1 || !$app->isSite(); } $load_framework = $flexiparams->get('loadfw_' . strtolower(str_replace('-', '_', $framework)), 1); $load_frameworks[$framework] = $load_framework == 1 || $load_framework == 2 && !$app->isSite(); } // Set loaded flag $_loaded[$framework] = $load_frameworks[$framework]; // Do not progress further if it is disabled if (!$load_frameworks[$framework]) { return false; } // Load Framework $document = JFactory::getDocument(); $lib_path = '/components/com_flexicontent/librairies'; $js = ""; $css = ""; switch ($framework) { case 'jQuery': if ($load_jquery) { flexicontent_html::loadJQuery(); } break; case 'mCSB': if ($load_jquery) { flexicontent_html::loadJQuery(); } $framework_path = JURI::root(true) . $lib_path . '/mCSB'; $document->addScript($framework_path . '/jquery.mCustomScrollbar.min.js'); $document->addStyleSheet($framework_path . '/jquery.mCustomScrollbar.css'); $js .= "\n\t\t\t\t\tjQuery(document).ready(function(){\n\t\t\t\t\t\tjQuery('.fc_add_scroller').mCustomScrollbar({\n\t\t\t\t\t\t\ttheme:'dark-thick',\n\t\t\t\t\t\t\tadvanced:{updateOnContentResize: true}\n\t\t\t\t\t\t});\n\t\t\t\t\t\tjQuery('.fc_add_scroller_horizontal').mCustomScrollbar({\n\t\t\t\t\t\t\ttheme:'dark-thick',\n\t\t\t\t\t\t\thorizontalScroll:true,\n\t\t\t\t\t\t\tadvanced:{updateOnContentResize: true}\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t"; break; case 'image-picker': if ($load_jquery) { flexicontent_html::loadJQuery(); } $framework_path = JURI::root(true) . $lib_path . '/image-picker'; $document->addScript($framework_path . '/image-picker.min.js'); $document->addStyleSheet($framework_path . '/image-picker.css'); break; case 'masonry': $framework_path = JURI::root(true) . $lib_path . '/masonry'; $document->addScript($framework_path . '/masonry.pkgd.min.js'); break; case 'select2': if ($load_jquery) { flexicontent_html::loadJQuery(); } // Replace chosen function (if loaded) //JHtml::_('formbehavior.chosen', '#_some_iiidddd_'); $js .= "\n\t\t\t\tif (typeof jQuery.fn.chosen == 'function') { \n\t\t\t\t\tjQuery.fn.chosen_fc = jQuery.fn.chosen;\n\t\t\t\t\tjQuery.fn.chosen = function(){\n\t\t\t\t\t\tvar args = arguments;\n\t\t\t\t\t\tjQuery(this).each(function() {\n\t\t\t\t\t\t\tif (jQuery(this).hasClass('use_select2_lib')) return;\n\t\t\t\t\t\t\tjQuery(this).chosen_fc(args);\n\t\t\t\t\t\t});\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\t"; $ver = '3.5.4'; $framework_path = JURI::root(true) . $lib_path . '/select2'; $framework_folder = JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'librairies' . DS . 'select2'; $document->addScriptVersion($framework_path . '/select2.min.js', $ver); $document->addStyleSheetVersion($framework_path . '/select2.css', $ver); $lang_code = flexicontent_html::getUserCurrentLang(); if ($lang_code && $lang_code != 'en') { // Try language shortcode if (file_exists($framework_folder . DS . 'select2_locale_' . $lang_code . '.js')) { $document->addScriptVersion($framework_path . '/select2_locale_' . $lang_code . '.js', $ver); } else { $country_code = flexicontent_html::getUserCurrentLang($short_tag = false); if ($country_code && file_exists($framework_folder . DS . 'select2_locale_' . $country_code . '.js')) { $document->addScriptVersion($framework_path . '/select2_locale_' . $country_code . '.js', $ver); } } } $js .= "\n\t\t\t\t\tjQuery(document).ready(function() {\n\t\t\t\t\t\t\n\t\t\t\t\t\t" . "\n\t\t\t\t\t\tjQuery('select.use_select2_lib').select2({\n\t\t\t\t\t\t\t/*hideSelectionFromResult: function(selectedObject) { selectedObject.removeClass('select2-result-selectable').addClass('select2-result-unselectable').addClass('select2-disabled'); return false; },*/\n\t\t\t\t\t\t\tminimumResultsForSearch: 10\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\n\t\t\t\t\t\tjQuery('div.use_select2_lib').each(function() {\n\t\t\t\t\t\t\tvar el_container = jQuery(this);\n\t\t\t\t\t\t\tvar el_select = el_container.next('select');\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t" . "\n\t\t\t\t\t\t\tvar fc_label_text = el_select.attr('data-fc_label_text');\n\t\t\t\t\t\t\tif (!fc_label_text) fc_label_text = el_select.attr('fc_label_text');\n\t\t\t\t\t\t\tif (fc_label_text) {\n\t\t\t\t\t\t\t\tvar _label = (fc_label_text.length >= 30) ? fc_label_text.substring(0, 28) + '...' : fc_label_text;\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tjQuery('<span/>', {\n\t\t\t\t\t\t\t\t\t'class': 'fc_has_inner_label fc_has_inner_label_select2',\n\t\t\t\t\t\t\t\t\t'text': _label\n\t\t\t\t\t\t\t\t}).prependTo(el_container.find('.select2-search-field'));\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t" . "\n\t\t\t\t\t\t\tvar fc_prompt_text = el_select.attr('data-fc_prompt_text');\n\t\t\t\t\t\t\tif (!fc_prompt_text) fc_prompt_text = el_select.attr('fc_prompt_text');\n\t\t\t\t\t\t\tif (fc_prompt_text) {\n\t\t\t\t\t\t\t\tvar _prompt = (fc_prompt_text.length >= 30) ? fc_prompt_text.substring(0, 28) + '...' : fc_prompt_text;\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\tjQuery('<span/>', {\n\t\t\t\t\t\t\t\t\t'class': 'fc_has_inner_prompt fc_has_inner_prompt_select2',\n\t\t\t\t\t\t\t\t\t'text': _prompt\n\t\t\t\t\t\t\t\t}).prependTo(el_container.find('.select2-search-field')).hide();\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t" . "\n\t\t\t\t\t\t\tif ( ! el_select.attr('multiple') && !el_select.hasClass('fc_skip_highlight') ) {\n\t\t\t\t\t\t\t\tvar el = el_container.find('.select2-choice');\n\t\t\t\t\t\t\t\tvar val = el_select.val();\n\t\t\t\t\t\t\t\tif (val === null) {\n\t\t\t\t\t\t\t\t\t//el.addClass('fc_highlight_disabled');\n\t\t\t\t\t\t\t\t} else if (!!val && val.length) {\n\t\t\t\t\t\t\t\t\tel.addClass('fc_highlight');\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tel.removeClass('fc_highlight');\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\n\t\t\t\t\t\t" . "\n\t\t\t\t\t\tjQuery('select.use_select2_lib').on('select2-open', function() {\n\t\t\t\t\t\t\t" . "\n\t\t\t\t\t\t\tvar el_container = jQuery(this).parent();\n\t\t\t\t\t\t\tvar el = jQuery(this).parent().find('.select2-input');\n\t\t\t\t\t\t\tvar el_label = el.prevAll('.fc_has_inner_label');\n\t\t\t\t\t\t\tif (el_label) el_label.hide();\n\t\t\t\t\t\t\tvar el_prompt = el.prevAll('.fc_has_inner_prompt');\n\t\t\t\t\t\t\tif (el_prompt) el_prompt.show();\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t" . "\n\t\t\t\t\t\t\tif (jQuery(this).hasClass('select2_list_selected')) {\n\t\t\t\t\t\t\t\tvar els = jQuery('#select2-drop').find('.select2-selected');\n\t\t\t\t\t\t\t\tels.addClass('select2-selected-highlight').addClass('select2-disabled').removeClass('select2-selected').removeClass('select2-result-selectable');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}).on('select2-close', function() {\n\t\t\t\t\t\t\t" . "\n\t\t\t\t\t\t\tvar el_container = jQuery(this).parent();\n\t\t\t\t\t\t\tvar el = jQuery(this).parent().find('.select2-input');\n\t\t\t\t\t\t\tvar el_label = el.prevAll('.fc_has_inner_label');\n\t\t\t\t\t\t\tif (el_label) el_label.show();\n\t\t\t\t\t\t\tvar el_prompt = el.prevAll('.fc_has_inner_prompt');\n\t\t\t\t\t\t\tif (el_prompt) el_prompt.hide();\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t" . "\n\t\t\t\t\t\t\tif (jQuery(this).hasClass('select2_list_selected')) {\n\t\t\t\t\t\t\t\tvar els = jQuery('#select2-drop').find('.select2-selected-highlight');\n\t\t\t\t\t\t\t\tels.removeClass('select2-selected-highlight').removeClass('select2-disabled').addClass('select2-result-selectable');\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}).on\n\t\t\t\t\t\t\n\t\t\t\t\t\t" . "\n\t\t\t\t\t\t('change', function() {\n\t\t\t\t\t\t\tvar el_select = jQuery(this);\n\t\t\t\t\t\t\tif ( ! el_select.attr('multiple') && !el_select.hasClass('fc_skip_highlight') ) {\n\t\t\t\t\t\t\t\tvar el = jQuery(this).prev('div').find('.select2-choice');\n\t\t\t\t\t\t\t\tvar val = el_select.val();\n\t\t\t\t\t\t\t\tif (!!val && val.length) {\n\t\t\t\t\t\t\t\t\tel.addClass('fc_highlight');\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tel.removeClass('fc_highlight');\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\n\t\t\t\t\t\t" . "\n\t\t\t\t\t\tjQuery('div.use_select2_lib.select2-container-multi input').on('keydown', function() {\n\t\t\t\t\t\t\tvar el = jQuery(this);\n\t\t\t\t\t\t\tsetTimeout(function() {\n\t\t\t\t\t\t\t\tvar val = el.val();\n\t\t\t\t\t\t\t\tif (!!val && val.length) {\n\t\t\t\t\t\t\t\t\tvar el_prompt = el.prevAll('.fc_has_inner_prompt');\n\t\t\t\t\t\t\t\t\tif (el_prompt) el_prompt.hide();\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tvar el_prompt = el.prevAll('.fc_has_inner_prompt');\n\t\t\t\t\t\t\t\t\tif (el_prompt) el_prompt.show();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}, 0);\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\n\t\t\t\t\t\t" . "\n\t\t\t\t\t\tjQuery('select.use_select2_lib').on('loaded open', function() {\n\t\t\t\t\t\t\tvar ul = jQuery('#select2-drop ul.select2-results');\n\t\t\t\t\t\t\tvar needsScroll= ul.prop('scrollHeight') > ul.prop('clientHeight');\n\t\t\t\t\t\t\tif (needsScroll) ul.css('overflow-y', 'scroll');\n\t\t\t\t\t\t\telse ul.css('overflow-y', 'auto');\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\n\t\t\t\t\t});\n\t\t\t\t"; break; case 'inputmask': if ($load_jquery) { flexicontent_html::loadJQuery(); } $framework_path = JURI::root(true) . $lib_path . '/inputmask'; $document->addScript($framework_path . '/jquery.inputmask.bundle.min.js'); // Extra inputmask declarations definitions, e.g. ... $js .= "\n\t\t\t\t"; // Attach inputmask to all input fields that have appropriate tag parameters $js .= "\n\t\t\t\t\tjQuery(document).ready(function(){\n\t\t\t\t\t\tInputmask.extendAliases({\n\t\t\t\t\t\t\tdecimal: {\n\t\t\t\t\t\t\t\talias: 'numeric',\n\t\t\t\t\t\t\t\tplaceholder: '_',\n\t\t\t\t\t\t\t\tautoGroup: true,\n\t\t\t\t\t\t\t\tradixPoint: '.',\n\t\t\t\t\t\t\t\tgroupSeparator: ',',\n\t\t\t\t\t\t\t\tclearMaskOnLostFocus: true,\n\t\t\t\t\t\t\t\tremoveMaskOnSubmit: true,\n\t\t\t\t\t\t\t\tunmaskAsNumber: false\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tdecimal_comma: {\n\t\t\t\t\t\t\t\talias: 'numeric',\n\t\t\t\t\t\t\t\tplaceholder: '_',\n\t\t\t\t\t\t\t\tautoGroup: true,\n\t\t\t\t\t\t\t\tradixPoint: ',',\n\t\t\t\t\t\t\t\tgroupSeparator: '.',\n\t\t\t\t\t\t\t\tclearMaskOnLostFocus: true,\n\t\t\t\t\t\t\t\tremoveMaskOnSubmit: true,\n\t\t\t\t\t\t\t\tunmaskAsNumber: false\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tcurrency: {\n\t\t\t\t\t\t\t\talias: 'numeric',\n\t\t\t\t\t\t\t\tplaceholder: '_',\n\t\t\t\t\t\t\t\tprefix: '\$ ',\n\t\t\t\t\t\t\t\tgroupSeparator: ',',\n\t\t\t\t\t\t\t\tautoGroup: true,\n\t\t\t\t\t\t\t\tdigits: 2,\n\t\t\t\t\t\t\t\tdigitsOptional: false,\n\t\t\t\t\t\t\t\tclearMaskOnLostFocus: true,\n\t\t\t\t\t\t\t\tremoveMaskOnSubmit: true,\n\t\t\t\t\t\t\t\tunmaskAsNumber: false\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tcurrency_euro: {\n\t\t\t\t\t\t\t\talias: 'currency',\n\t\t\t\t\t\t\t\tplaceholder: '_',\n\t\t\t\t\t\t\t\tprefix: '\\u20ac ',\n\t\t\t\t\t\t\t\tgroupSeparator: ',',\n\t\t\t\t\t\t\t\tautoGroup: true,\n\t\t\t\t\t\t\t\tdigits: 2,\n\t\t\t\t\t\t\t\tdigitsOptional: false,\n\t\t\t\t\t\t\t\tclearMaskOnLostFocus: false,\n\t\t\t\t\t\t\t\tremoveMaskOnSubmit: true,\n\t\t\t\t\t\t\t\tunmaskAsNumber: false\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tpercentage_zero_nolimit: {\n\t\t\t\t\t\t\t\talias: 'percentage',\n\t\t\t\t\t\t\t\tplaceholder: '_',\n\t\t\t\t\t\t\t\tdigits: 2,\n\t\t\t\t\t\t\t\tradixPoint: '.',\n\t\t\t\t\t\t\t\tautoGroup: true,\n\t\t\t\t\t\t\t\tmin: 0,\n\t\t\t\t\t\t\t\tmax: '',\n\t\t\t\t\t\t\t\tsuffix: ' %',\n\t\t\t\t\t\t\t\tallowPlus: false,\n\t\t\t\t\t\t\t\tallowMinus: false,\n\t\t\t\t\t\t\t\tclearMaskOnLostFocus: true,\n\t\t\t\t\t\t\t\tremoveMaskOnSubmit: true,\n\t\t\t\t\t\t\t\tunmaskAsNumber: false\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tpercentage_nolimit_nolimit: {\n\t\t\t\t\t\t\t\talias: 'percentage',\n\t\t\t\t\t\t\t\tplaceholder: '_',\n\t\t\t\t\t\t\t\tdigits: 2,\n\t\t\t\t\t\t\t\tradixPoint: '.',\n\t\t\t\t\t\t\t\tautoGroup: true,\n\t\t\t\t\t\t\t\tmin: '',\n\t\t\t\t\t\t\t\tmax: '',\n\t\t\t\t\t\t\t\tsuffix: ' %',\n\t\t\t\t\t\t\t\tallowPlus: false,\n\t\t\t\t\t\t\t\tallowMinus: true,\n\t\t\t\t\t\t\t\tclearMaskOnLostFocus: true,\n\t\t\t\t\t\t\t\tremoveMaskOnSubmit: true,\n\t\t\t\t\t\t\t\tunmaskAsNumber: false\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tinteger: {\n\t\t\t\t\t\t\t\talias: 'numeric',\n\t\t\t\t\t\t\t\tplaceholder: '_',\n\t\t\t\t\t\t\t\tdigits: 0,\n\t\t\t\t\t\t\t\tradixPoint: '',\n\t\t\t\t\t\t\t\tclearMaskOnLostFocus: true,\n\t\t\t\t\t\t\t\tremoveMaskOnSubmit: true,\n\t\t\t\t\t\t\t\tunmaskAsNumber: false\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tunsigned: {\n\t\t\t\t\t\t\t\talias: 'numeric',\n\t\t\t\t\t\t\t\tplaceholder: '_',\n\t\t\t\t\t\t\t\tdigits: 0,\n\t\t\t\t\t\t\t\tradixPoint: '',\n\t\t\t\t\t\t\t\tallowPlus: false,\n\t\t\t\t\t\t\t\tallowMinus: false,\n\t\t\t\t\t\t\t\tclearMaskOnLostFocus: true,\n\t\t\t\t\t\t\t\tremoveMaskOnSubmit: true,\n\t\t\t\t\t\t\t\tunmaskAsNumber: false\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t'mobile': {\n\t\t\t\t\t\t\t\t'mask': '9999 999 999',\n\t\t\t\t\t\t\t\t'autounmask': true,\n\t\t\t\t\t\t\t\t'insertMode': true,\n\t\t\t\t\t\t\t\tplaceholder: '_',\n\t\t\t\t\t\t\t\tclearMaskOnLostFocus: true,\n\t\t\t\t\t\t\t\tremoveMaskOnSubmit: true,\n\t\t\t\t\t\t\t\tunmaskAsNumber: false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t\t\n\t\t\t\t\t\tjQuery('input.has_inputmask').inputmask();\n\t\t\t\t\t\tjQuery('input.inputmask-regex').inputmask('Regex');\n\t\t\t\t\t});\n\t\t\t\t"; break; case 'prettyCheckable': if ($load_jquery) { flexicontent_html::loadJQuery(); } $framework_path = JURI::root(true) . $lib_path . '/prettyCheckable'; $document->addScript($framework_path . '/dev/prettyCheckable.js'); $document->addStyleSheet($framework_path . '/dist/prettyCheckable.css'); $js .= "\n\t\t\t\t\tjQuery(document).ready(function(){\n\t\t\t\t\t\tjQuery('input.use_prettycheckable').each(function() {\n\t\t\t\t\t\t\tvar elem = jQuery(this);\n\t\t\t\t\t\t\tvar lbl = elem.next('label');\n\t\t\t\t\t\t\tvar lbl_html = elem.next('label').html();\n\t\t\t\t\t\t\tlbl.remove();\n\t\t\t\t\t\t\telem.prettyCheckable({\n\t\t\t\t\t\t\t\tcolor: 'blue',\n\t\t\t\t\t\t\t\tlabel: lbl_html\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t"; break; case 'multibox': case 'jmultibox': if ($load_jquery) { flexicontent_html::loadJQuery(); } $framework_path = JURI::root(true) . $lib_path . '/jmultibox'; // Add JS $document->addScript($framework_path . '/js/jmultibox.js'); $document->addScript($framework_path . '/js/jquery.vegas.js'); // Add CSS $document->addStyleSheet($framework_path . '/styles/multibox.css'); $document->addStyleSheet($framework_path . '/styles/jquery.vegas.css'); if (substr($_SERVER['HTTP_USER_AGENT'], 0, 34) == "Mozilla/4.0 (compatible; MSIE 6.0;") { $document->addStyleSheet($framework_path . '/styles/multibox-ie6.css'); } // Attach multibox to ... this will be left to the caller so that it will create a multibox object with custom options //$js .= ""; break; case 'fancybox': if ($load_jquery) { flexicontent_html::loadJQuery(); } $document->addScript(JURI::root(true) . '/components/com_flexicontent/assets/js/jquery-easing.js'); $framework_path = JURI::root(true) . $lib_path . '/fancybox'; // Add mousewheel plugin (this is optional) $document->addScript($framework_path . '/lib/jquery.mousewheel-3.0.6.pack.js'); // Add fancyBox CSS / JS $document->addStyleSheet($framework_path . '/source/jquery.fancybox.css'); $document->addScript($framework_path . '/source/jquery.fancybox.pack.js'); // Optionally add helpers - button, thumbnail and/or media $document->addStyleSheet($framework_path . '/source/helpers/jquery.fancybox-buttons.css'); $document->addScript($framework_path . '/source/helpers/jquery.fancybox-buttons.js'); $document->addScript($framework_path . '/source/helpers/jquery.fancybox-media.js'); $document->addStyleSheet($framework_path . '/source/helpers/jquery.fancybox-thumbs.css'); $document->addScript($framework_path . '/source/helpers/jquery.fancybox-thumbs.js'); // Attach fancybox to all elements having a specific CSS class $js .= "\n\t\t\t\t\tjQuery(document).ready(function(){\n\t\t\t\t\t\tjQuery('.fancybox').fancybox({\n\t\t\t\t\t\t\t'openEffect'\t: 'elastic',\n\t\t\t\t\t\t\t'closeEffect'\t: 'elastic',\n\t\t\t\t\t\t\t'openEasing' : 'easeOutCubic',\n\t\t\t\t\t\t\t'closeEasing' : 'easeInCubic',\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t"; break; case 'galleriffic': if ($load_jquery) { flexicontent_html::loadJQuery(); } //flexicontent_html::loadFramework('fancybox'); $framework_path = JURI::root(true) . $lib_path . '/galleriffic'; //$document->addStyleSheet($framework_path.'/css/basic.css'); // This is too generic and should not be loaded $document->addStyleSheet($framework_path . '/css/galleriffic-3.css'); $document->addScript($framework_path . '/js/jquery.galleriffic.js'); $document->addScript($framework_path . '/js/jquery.opacityrollover.js'); break; case 'elastislide': if ($load_jquery) { flexicontent_html::loadJQuery(); } $framework_path = JURI::root(true) . $lib_path . '/elastislide'; $document->addStyleSheet($framework_path . '/css/style.css'); $document->addStyleSheet($framework_path . '/css/elastislide.css'); $document->addScript($framework_path . '/js/jquery.tmpl.min.js'); $document->addScript($framework_path . '/js/jquery.easing.1.3.js'); $document->addScript($framework_path . '/js/jquery.elastislide.js'); //$document->addScript($framework_path.'/js/gallery.js'); // replace with field specific: gallery_tmpl.js break; case 'photoswipe': if ($load_jquery) { flexicontent_html::loadJQuery(); } $framework_path = JURI::root(true) . $lib_path . '/photoswipe'; //$document->addStyleSheet($framework_path.'/lib/jquery.mobile/jquery.mobile.css'); $document->addStyleSheet($framework_path . '/photoswipe.css'); //$document->addScript($framework_path.'/lib/jquery.mobile/jquery.mobile.js'); $document->addScript($framework_path . '/lib/simple-inheritance.min.js'); //$document->addScript($framework_path.'/lib/jquery.animate-enhanced.min.js'); $document->addScript($framework_path . '/code.photoswipe.min.js'); $js .= "\n\t\t\t\tjQuery(document).ready(function() {\n\t\t\t\t\tvar myPhotoSwipe = jQuery('.photoswipe_fccontainer a').photoSwipe(); \n\t\t\t\t});\n\t\t\t\t"; break; case 'fcxSlide': if ($load_jquery) { flexicontent_html::loadJQuery(); } $framework_path = JURI::root(true) . $lib_path . '/fcxSlide'; $document->addScriptVersion($framework_path . '/class.fcxSlide.js', FLEXI_VERSION); $document->addStyleSheetVersion($framework_path . '/fcxSlide.css', FLEXI_VERSION); //$document->addScriptVersion($framework_path.'/class.fcxSlide.packed.js', FLEXI_VERSION); break; case 'imagesLoaded': $framework_path = JURI::root(true) . $lib_path . '/imagesLoaded'; $document->addScript($framework_path . '/imagesloaded.pkgd.min.js'); break; case 'noobSlide': // Make sure mootools are loaded FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools'); $framework_path = JURI::root(true) . $lib_path . '/noobSlide'; //$document->addScript($framework_path.'/_class.noobSlide.js'); $document->addScript($framework_path . '/_class.noobSlide.packed.js'); break; case 'zTree': if ($load_jquery) { flexicontent_html::loadJQuery(); } $framework_path = JURI::root(true) . $lib_path . '/zTree'; $document->addStyleSheet($framework_path . '/css/flexi_ztree.css'); $document->addStyleSheet($framework_path . '/css/zTreeStyle/zTreeStyle.css'); $document->addScript($framework_path . '/js/jquery.ztree.all-3.5.min.js'); //$document->addScript($framework_path.'/js/jquery.ztree.core-3.5.js'); //$document->addScript($framework_path.'/js/jquery.ztree.excheck-3.5.js'); //$document->addScript($framework_path.'/js/jquery.ztree.exedit-3.5.js'); break; case 'plupload': if ($load_jquery) { flexicontent_html::loadJQuery(); } $framework_path = JURI::root(true) . $lib_path . '/plupload'; $document->addScript($framework_path . '/js/plupload.full.min.js'); if ($mode == 'ui') { $document->addStyleSheet($framework_path . '/js/jquery.ui.plupload/css/jquery.ui.plupload.css'); $document->addScript($framework_path . '/js/jquery.ui.plupload/jquery.ui.plupload.min.js'); $document->addScript($framework_path . '/js/themeswitcher.js'); } else { $document->addStyleSheet($framework_path . '/js/jquery.plupload.queue/css/jquery.plupload.queue.css'); $document->addScript($framework_path . '/js/jquery.plupload.queue/jquery.plupload.queue.js'); } $lang_code = flexicontent_html::getUserCurrentLang(); if ($lang_code && $lang_code != 'en') { // Try language shortcode if (file_exists($framework_folder . DS . 'js' . DS . $lang_code . '.js')) { $document->addScript($framework_path . '/js/' . $lang_code . '.js'); } else { $country_code = flexicontent_html::getUserCurrentLang($short_tag = false); if ($country_code && file_exists($framework_folder . DS . 'js' . DS . $country_code . '.js')) { $document->addScript($framework_path . '/js/' . $country_code . '.js'); } } } // For debugging //$document->addScript($framework_path.'/js/moxie.min.js'); //$document->addScript($framework_path.'/js/plupload.dev.js'); break; case 'nouislider': $framework_path = JURI::root(true) . $lib_path . '/nouislider'; $document->addStyleSheet($framework_path . '/nouislider.min.css'); $document->addScript($framework_path . '/nouislider.min.js'); break; case 'flexi_tmpl_common': if ($load_jquery) { flexicontent_html::loadJQuery(); } flexicontent_html::loadFramework('select2'); // make sure select2 is loaded // Make sure user cookie is set $jcookie = $app->input->cookie; $fc_uid = $jcookie->get('fc_uid', null); $hashedUA = JFactory::getUser()->id ? JUserHelper::getShortHashedUserAgent() : 'p'; if ($fc_uid != $hashedUA) { $jcookie->set('fc_uid', $hashedUA, 0); } $js .= "\n\t\t\t\t\tvar _FC_GET = " . json_encode($_GET) . ";\n\t\t\t\t"; $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/tmpl-common.js', FLEXI_VERSION); $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/jquery-easing.js', FLEXI_VERSION); JText::script("FLEXI_APPLYING_FILTERING", true); JText::script("FLEXI_TYPE_TO_LIST", true); JText::script("FLEXI_TYPE_TO_FILTER", true); JText::script("FLEXI_UPDATING_CONTENTS", true); break; case 'flexi-lib': if ($load_jquery) { flexicontent_html::loadJQuery(); } $document->addScriptVersion(JURI::root(true) . '/components/com_flexicontent/assets/js/flexi-lib.js', FLEXI_VERSION); JText::script("FLEXI_NOT_AN_IMAGE_FILE", true); break; default: JFactory::getApplication()->enqueueMessage(__FUNCTION__ . ' Cannot load unknown Framework: ' . $framework, 'error'); break; } // Add custom JS & CSS code if ($js) { $document->addScriptDeclaration($js); } if ($css) { $document->addStyleDeclaration($css); } return $_loaded[$framework]; }
/** * Helper wrapper method for getShortHashedUserAgent * * @return string A hashed user agent string with version replaced by 'abcd' * * @see JUserHelper::getShortHashedUserAgent() * @since 3.4 */ public function getShortHashedUserAgent() { return JUserHelper::getShortHashedUserAgent(); }
/** * This method should handle any authentication and report back to the subject * * @param array $credentials Array holding the user credentials * @param array $options Array of extra options * @param object &$response Authentication response object * * @return boolean * * @since 3.2 */ public function onUserAuthenticate($credentials, $options, &$response) { // No remember me for admin if ($this->app->isAdmin()) { return false; } JLoader::register('JAuthentication', JPATH_LIBRARIES . '/joomla/user/authentication.php'); $response->type = 'Cookie'; // We need to validate the cookie data because there may be no Remember Me plugin to do it. // Create the cookie name and data. $rememberArray = JUserHelper::getRememberCookieData(); if ($rememberArray == false) { return false; } list($privateKey, $series, $uastring) = $rememberArray; // Find the matching record if it exists. $query = $this->db->getQuery(true)->select($this->db->quoteName(array('user_id', 'token', 'series', 'time', 'invalid')))->from($this->db->quoteName('#__user_keys'))->where($this->db->quoteName('series') . ' = ' . $this->db->quote(base64_encode($series)))->where($this->db->quoteName('uastring') . ' = ' . $this->db->quote($uastring))->order($this->db->quoteName('time') . ' DESC'); $results = $this->db->setQuery($query)->loadObjectList(); $countResults = count($results); if ($countResults !== 1) { $response->status = JAuthentication::STATUS_FAILURE; return; } else { if (substr($results[0]->token, 0, 4) === '$2y$') { if (JCrypt::hasStrongPasswordSupport()) { $match = password_verify($privateKey, $results[0]->token); } } else { if (JCrypt::timingSafeCompare($results[0]->token, $privateKey)) { $match = true; } } if (empty($match)) { JUserHelper::invalidateCookie($results[0]->user_id, $uastring); JLog::add(JText::sprintf('PLG_SYSTEM_REMEMBER_ERROR_LOG_LOGIN_FAILED', $user->username), JLog::WARNING, 'security'); $response->status = JAuthentication::STATUS_FAILURE; return false; } } // Set cookie params. if (!empty($options['lifetime']) && !empty($options['length']) && !empty($options['secure'])) { $response->lifetime = $options['lifetime']; $response->length = $options['length']; $response->secure = $options['secure']; } // Make sure there really is a user with this name and get the data for the session. $query = $this->db->getQuery(true)->select($this->db->quoteName(array('id', 'username', 'password')))->from($this->db->quoteName('#__users'))->where($this->db->quoteName('username') . ' = ' . $this->db->quote($credentials['username'])); $result = $this->db->setQuery($query)->loadObject(); if ($result) { // Bring this in line with the rest of the system $user = JUser::getInstance($result->id); $cookieName = JUserHelper::getShortHashedUserAgent(); // If there is no cookie, bail out if (!$this->app->input->cookie->get($cookieName)) { return; } // Set response data. $response->username = $result->username; $response->email = $user->email; $response->fullname = $user->name; $response->password = $result->password; $response->language = $user->getParam('language'); // Set response status. $response->status = JAuthentication::STATUS_SUCCESS; $response->error_message = ''; } else { $response->status = JAuthentication::STATUS_FAILURE; $response->error_message = JText::_('JGLOBAL_AUTH_NO_USER'); } }
/** * We set the authentication cookie only after login is successfullly finished. * We set a new cookie either for a user with no cookies or one * where the user used a cookie to authenticate. * * @param array $options Array holding options * * @return boolean True on success * * @since 3.2 */ public function onUserAfterLogin($options) { // Currently this portion of the method only applies to Cookie based login. if (!isset($options['responseType']) || $options['responseType'] != 'Cookie' && empty($options['remember'])) { return true; } // We get the parameter values differently for cookie and non-cookie logins. $cookieLifetime = empty($options['lifetime']) ? $this->app->rememberCookieLifetime : $options['lifetime']; $length = empty($options['length']) ? $this->app->rememberCookieLength : $options['length']; $secure = empty($options['secure']) ? $this->app->rememberCookieSecure : $options['secure']; // We need the old data to match against the current database $rememberArray = JUserHelper::getRememberCookieData(); $privateKey = JUserHelper::genRandomPassword($length); // We are going to concatenate with . so we need to remove it from the strings. $privateKey = str_replace('.', '', $privateKey); $cryptedKey = JUserHelper::getCryptedPassword($privateKey, '', 'bcrypt', false); $cookieName = JUserHelper::getShortHashedUserAgent(); // Create an identifier and make sure that it is unique. $unique = false; do { // Unique identifier for the device-user $series = JUserHelper::genRandomPassword(20); // We are going to concatenate with . so we need to remove it from the strings. $series = str_replace('.', '', $series); $query = $this->db->getQuery(true)->select($this->db->quoteName('series'))->from($this->db->quoteName('#__user_keys'))->where($this->db->quoteName('series') . ' = ' . $this->db->quote(base64_encode($series))); $results = $this->db->setQuery($query)->loadResult(); if (is_null($results)) { $unique = true; } } while ($unique === false); // If a user logs in with non cookie login and remember me checked we will // delete any invalid entries so that he or she can use remember once again. if ($options['responseType'] !== 'Cookie') { $query = $this->db->getQuery(true)->delete('#__user_keys')->where($this->db->quoteName('uastring') . ' = ' . $this->db->quote($cookieName))->where($this->db->quoteName('user_id') . ' = ' . $this->db->quote($options['user']->username)); $this->db->setQuery($query)->execute(); } $cookieValue = $cryptedKey . '.' . $series . '.' . $cookieName; // Destroy the old cookie. $this->app->input->cookie->set($cookieName, false, time() - 42000, $this->app->get('cookie_path'), $this->app->get('cookie_domain')); // And make a new one. $this->app->input->cookie->set($cookieName, $cookieValue, $cookieLifetime, $this->app->get('cookie_path'), $this->app->get('cookie_domain'), $secure); $query = $this->db->getQuery(true); if (empty($options['user']->cookieLogin) || $options['responseType'] != 'Cookie') { // For users doing login from Joomla or other systems $query->insert($this->db->quoteName('#__user_keys')); } else { $query->update($this->db->quoteName('#__user_keys'))->where($this->db->quoteName('user_id') . ' = ' . $this->db->quote($options['user']->username))->where($this->db->quoteName('series') . ' = ' . $this->db->quote(base64_encode($rememberArray[1])))->where($this->db->quoteName('uastring') . ' = ' . $this->db->quote($cookieName)); } $query->set($this->db->quoteName('user_id') . ' = ' . $this->db->quote($options['user']->username))->set($this->db->quoteName('time') . ' = ' . $cookieLifetime)->set($this->db->quoteName('token') . ' = ' . $this->db->quote($cryptedKey))->set($this->db->quoteName('series') . ' = ' . $this->db->quote(base64_encode($series)))->set($this->db->quoteName('invalid') . ' = 0')->set($this->db->quoteName('uastring') . ' = ' . $this->db->quote($cookieName)); $this->db->setQuery($query)->execute(); return true; }