function onAfterDispatch() { $mainframe =& JFactory::getApplication(); if ($mainframe->isAdmin()) { return; } JPlugin::loadLanguage('com_k2'); $params =& JComponentHelper::getParams('com_k2'); if (!$params->get('K2UserProfile')) { return; } $option = JRequest::getCmd('option'); $view = JRequest::getCmd('view'); $task = JRequest::getCmd('task'); $layout = JRequest::getCmd('layout'); $user =& JFactory::getUser(); if ($option == 'com_user' && $view == 'register') { if (!$user->guest) { $mainframe->redirect(JURI::root(), JText::_('You are already registered as a member.'), 'notice'); $mainframe->close(); } require_once JPATH_SITE . DS . 'components' . DS . 'com_user' . DS . 'controller.php'; $controller = new UserController(); $view = $controller->getView('register', 'html'); $view->_addPath('template', JPATH_SITE . DS . 'components' . DS . 'com_k2' . DS . 'templates'); $view->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'templates'); $view->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2'); $view->setLayout('register'); $K2User = new JObject(); $K2User->description = ''; $K2User->gender = 'm'; $K2User->image = ''; $K2User->url = ''; $K2User->plugins = ''; $wysiwyg =& JFactory::getEditor(); $editor = $wysiwyg->display('description', $K2User->description, '100%', '250', '40', '5', false); $view->assignRef('editor', $editor); $lists = array(); $genderOptions[] = JHTML::_('select.option', 'm', JText::_('Male')); $genderOptions[] = JHTML::_('select.option', 'f', JText::_('Female')); $lists['gender'] = JHTML::_('select.radiolist', $genderOptions, 'gender', '', 'value', 'text', $K2User->gender); $view->assignRef('lists', $lists); JPluginHelper::importPlugin('k2'); $dispatcher =& JDispatcher::getInstance(); $K2Plugins = $dispatcher->trigger('onRenderAdminForm', array(&$K2User, 'user')); $view->assignRef('K2Plugins', $K2Plugins); $view->assignRef('K2User', $K2User); $pathway =& $mainframe->getPathway(); $pathway->setPathway(NULL); ob_start(); $view->display(); $contents = ob_get_clean(); $document =& JFactory::getDocument(); $document->setBuffer($contents, 'component'); } if ($option == 'com_user' && $view == 'user' && ($task == 'edit' || $layout == 'form')) { require_once JPATH_SITE . DS . 'components' . DS . 'com_user' . DS . 'controller.php'; $controller = new UserController(); $view = $controller->getView('user', 'html'); $view->_addPath('template', JPATH_SITE . DS . 'components' . DS . 'com_k2' . DS . 'templates'); $view->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'templates'); $view->_addPath('template', JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2'); $view->setLayout('profile'); require_once JPATH_SITE . DS . 'components' . DS . 'com_k2' . DS . 'models' . DS . 'itemlist.php'; $model = new K2ModelItemlist(); $K2User = $model->getUserProfile($user->id); if (!is_object($K2User)) { $K2User = new Jobject(); $K2User->description = ''; $K2User->gender = 'm'; $K2User->url = ''; $K2User->image = NULL; } $wysiwyg =& JFactory::getEditor(); $editor = $wysiwyg->display('description', $K2User->description, '100%', '250', '40', '5', false); $view->assignRef('editor', $editor); $lists = array(); $genderOptions[] = JHTML::_('select.option', 'm', JText::_('Male')); $genderOptions[] = JHTML::_('select.option', 'f', JText::_('Female')); $lists['gender'] = JHTML::_('select.radiolist', $genderOptions, 'gender', '', 'value', 'text', $K2User->gender); $view->assignRef('lists', $lists); JPluginHelper::importPlugin('k2'); $dispatcher =& JDispatcher::getInstance(); $K2Plugins = $dispatcher->trigger('onRenderAdminForm', array(&$K2User, 'user')); $view->assignRef('K2Plugins', $K2Plugins); $view->assignRef('K2User', $K2User); ob_start(); $view->_displayForm(); $contents = ob_get_clean(); $document =& JFactory::getDocument(); $document->setBuffer($contents, 'component'); } }
function onAfterDispatch() { $mainframe =& JFactory::getApplication(); if ($mainframe->isAdmin()) { return; } $params =& JComponentHelper::getParams('com_k2'); if (!$params->get('K2UserProfile')) { return; } $option = JRequest::getCmd('option'); $view = JRequest::getCmd('view'); $task = JRequest::getCmd('task'); $layout = JRequest::getCmd('layout'); $user =& JFactory::getUser(); if ($option == 'com_user' && $view == 'register' || $option == 'com_users' && $view == 'registration') { if ($params->get('recaptchaOnRegistration') && $params->get('recaptcha_public_key')) { $document =& JFactory::getDocument(); $document->addScript('http://api.recaptcha.net/js/recaptcha_ajax.js'); $js = ' function showRecaptcha(){ Recaptcha.create("' . $params->get('recaptcha_public_key') . '", "recaptcha", { theme: "' . $params->get('recaptcha_theme', 'clean') . '" }); } $K2(document).ready(function() { showRecaptcha(); }); '; $document->addScriptDeclaration($js); } if (!$user->guest) { $mainframe->redirect(JURI::root(), JText::_('K2_YOU_ARE_ALREADY_REGISTERED_AS_A_MEMBER'), 'notice'); $mainframe->close(); } if (K2_JVERSION == '16') { require_once JPATH_SITE . DS . 'components' . DS . 'com_users' . DS . 'controller.php'; $controller = new UsersController(); } else { require_once JPATH_SITE . DS . 'components' . DS . 'com_user' . DS . 'controller.php'; $controller = new UserController(); } $view = $controller->getView($view, 'html'); $view->addTemplatePath(JPATH_SITE . DS . 'components' . DS . 'com_k2' . DS . 'templates'); $view->addTemplatePath(JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'templates'); $view->addTemplatePath(JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2'); $view->setLayout('register'); $K2User = new JObject(); $K2User->description = ''; $K2User->gender = 'm'; $K2User->image = ''; $K2User->url = ''; $K2User->plugins = ''; $wysiwyg =& JFactory::getEditor(); $editor = $wysiwyg->display('description', $K2User->description, '100%', '250px', '', '', false); $view->assignRef('editor', $editor); $lists = array(); $genderOptions[] = JHTML::_('select.option', 'm', JText::_('K2_MALE')); $genderOptions[] = JHTML::_('select.option', 'f', JText::_('K2_FEMALE')); $lists['gender'] = JHTML::_('select.radiolist', $genderOptions, 'gender', '', 'value', 'text', $K2User->gender); $view->assignRef('lists', $lists); $view->assignRef('K2Params', $params); JPluginHelper::importPlugin('k2'); $dispatcher =& JDispatcher::getInstance(); $K2Plugins = $dispatcher->trigger('onRenderAdminForm', array(&$K2User, 'user')); $view->assignRef('K2Plugins', $K2Plugins); $view->assignRef('K2User', $K2User); if (K2_JVERSION == '16') { $view->assignRef('user', $user); } $pathway =& $mainframe->getPathway(); $pathway->setPathway(NULL); ob_start(); $view->display(); $contents = ob_get_clean(); $document =& JFactory::getDocument(); $document->setBuffer($contents, 'component'); } if ($option == 'com_user' && $view == 'user' && ($task == 'edit' || $layout == 'form') || $option == 'com_users' && $view == 'profile' && $layout == 'edit') { if ($user->guest) { JError::raiseError(403, JText::_('K2_ALERTNOTAUTH')); } if (K2_JVERSION == '16') { require_once JPATH_SITE . DS . 'components' . DS . 'com_users' . DS . 'controller.php'; $controller = new UsersController(); } else { require_once JPATH_SITE . DS . 'components' . DS . 'com_user' . DS . 'controller.php'; $controller = new UserController(); } /* // TO DO - We open the profile editing page in a modal, so let's define some CSS $document = &JFactory::getDocument(); $document->addStyleSheet(JURI::root(true).'/media/k2/assets/css/k2.frontend.css'); $document->addStyleSheet(JURI::root(true).'/templates/system/css/general.css'); $document->addStyleSheet(JURI::root(true).'/templates/system/css/system.css'); if(K2_JVERSION == '16') { $document->addStyleSheet(JURI::root(true).'/administrator/templates/bluestork/css/template.css'); $document->addStyleSheet(JURI::root(true).'/media/system/css/system.css'); } else { $document->addStyleSheet(JURI::root(true).'/administrator/templates/khepri/css/general.css'); } */ $view = $controller->getView($view, 'html'); $view->addTemplatePath(JPATH_SITE . DS . 'components' . DS . 'com_k2' . DS . 'templates'); $view->addTemplatePath(JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2' . DS . 'templates'); $view->addTemplatePath(JPATH_SITE . DS . 'templates' . DS . $mainframe->getTemplate() . DS . 'html' . DS . 'com_k2'); $view->setLayout('profile'); require_once JPATH_SITE . DS . 'components' . DS . 'com_k2' . DS . 'models' . DS . 'itemlist.php'; $model = new K2ModelItemlist(); $K2User = $model->getUserProfile($user->id); if (!is_object($K2User)) { $K2User = new Jobject(); $K2User->description = ''; $K2User->gender = 'm'; $K2User->url = ''; $K2User->image = NULL; } $wysiwyg =& JFactory::getEditor(); $editor = $wysiwyg->display('description', $K2User->description, '100%', '250px', '', '', false); $view->assignRef('editor', $editor); $lists = array(); $genderOptions[] = JHTML::_('select.option', 'm', JText::_('K2_MALE')); $genderOptions[] = JHTML::_('select.option', 'f', JText::_('K2_FEMALE')); $lists['gender'] = JHTML::_('select.radiolist', $genderOptions, 'gender', '', 'value', 'text', $K2User->gender); $view->assignRef('lists', $lists); JPluginHelper::importPlugin('k2'); $dispatcher =& JDispatcher::getInstance(); $K2Plugins = $dispatcher->trigger('onRenderAdminForm', array(&$K2User, 'user')); $view->assignRef('K2Plugins', $K2Plugins); $view->assignRef('K2User', $K2User); ob_start(); if (K2_JVERSION == '16') { $view->assignRef('user', $user); $view->display(); } else { $view->_displayForm(); } $contents = ob_get_clean(); $document =& JFactory::getDocument(); $document->setBuffer($contents, 'component'); } }