                                                                                                                                                                                
                                                                                                                                                                                
tmpl/userblock.php                                                                                  0000705                 00000007542 15242037135 0010232 0                                                                                                    ustar 00                                                                                                                                                                                                                                                       <?php
/**
 * @version    2.11 (rolling release)
 * @package    K2
 * @author     JoomlaWorks https://www.joomlaworks.net
 * @copyright  Copyright (c) 2009 - 2024 JoomlaWorks Ltd. All rights reserved.
 * @license    GNU/GPL: https://gnu.org/licenses/gpl.html
 */

// no direct access
defined('_JEXEC') or die;

?>

<div id="k2ModuleBox<?php echo $module->id; ?>" class="k2UserBlock<?php if ($params->get('moduleclass_sfx')) echo ' '.$params->get('moduleclass_sfx'); ?>">
    <?php if ($userGreetingText): ?>
    <p class="ubGreeting"><?php echo $userGreetingText; ?></p>
    <?php endif; ?>

    <div class="k2UserBlockDetails">
        <?php if ($params->get('userAvatar')): ?>
        <a class="k2Avatar ubAvatar" href="<?php echo JRoute::_(K2HelperRoute::getUserRoute($user->id)); ?>" title="<?php echo JText::_('K2_MY_PAGE'); ?>">
            <img src="<?php echo K2HelperUtilities::getAvatar($user->id, $user->email); ?>" alt="<?php echo K2HelperUtilities::cleanHtml($user->name); ?>" style="width:<?php echo $avatarWidth; ?>px;height:auto;" />
        </a>
        <?php endif; ?>
        <span class="ubName"><?php echo $user->name; ?></span>
        <span class="ubCommentsCount"><?php echo JText::_('K2_YOU_HAVE'); ?> <b><?php echo $user->numOfComments; ?></b> <?php if ($user->numOfComments==1) echo JText::_('K2_PUBLISHED_COMMENT'); else echo JText::_('K2_PUBLISHED_COMMENTS'); ?></span>
        <div class="clr"></div>
    </div>

    <ul class="k2UserBlockActions">
        <?php if (isset($addItemLink)): ?>
        <li>
            <a data-k2-modal="edit" href="<?php echo $addItemLink; ?>"><?php echo JText::_('K2_ADD_NEW_ITEM'); ?></a>
        </li>
        <?php endif; ?>
        <li>
            <a href="<?php echo $viewProfileLink; ?>"><?php echo JText::_('K2_MY_PAGE'); ?></a>
        </li>
        <li>
            <a href="<?php echo $editProfileLink; ?>"><?php echo JText::_('K2_MY_ACCOUNT'); ?></a>
        </li>
        <?php if ($K2CommentsEnabled): ?>
        <li>
            <a data-k2-modal="iframe" href="<?php echo $editCommentsLink; ?>"><?php echo JText::_('K2_MODERATE_COMMENTS_TO_MY_PUBLISHED_ITEMS'); ?></a>
        </li>
        <?php endif; ?>
    </ul>

    <ul class="k2UserBlockRenderedMenu">
        <?php $level = 1; foreach($menu as $key => $link): $level++; ?>
        <li class="linkItemId<?php echo $link->id; ?>">
            <?php if ($link->type=='url' && $link->browserNav==0): ?>
            <a href="<?php echo $link->route; ?>"><?php echo $link->name; ?></a>
            <?php elseif (strpos($link->link,'option=com_k2&view=item&layout=itemform') || $link->browserNav==2): ?>
            <a data-k2-modal="edit" href="<?php echo $link->route; ?>"><?php echo $link->name; ?></a>
            <?php else: ?>
            <a href="<?php echo $link->route; ?>" <?php if ($link->browserNav==1) echo ' target="_blank"'; ?>><?php echo $link->name; ?></a>
            <?php endif; ?>

            <?php if (isset($menu[$key+1]) && $menu[$key]->level < $menu[$key+1]->level): ?>
            <ul>
            <?php endif; ?>

            <?php if (isset($menu[$key+1]) && $menu[$key]->level > $menu[$key+1]->level): ?>
            <?php echo str_repeat('</li></ul>', $menu[$key]->level - $menu[$key+1]->level); ?>
            <?php endif; ?>

        <?php if (isset($menu[$key+1]) && $menu[$key]->level == $menu[$key+1]->level): ?>
        </li>
        <?php endif; ?>
        <?php endforeach; ?>
    </ul>

    <form action="<?php echo JURI::root(true); ?>/index.php" method="post">
        <input type="submit" name="Submit" class="button ubLogout" value="<?php echo JText::_('K2_LOGOUT'); ?>" />
        <input type="hidden" name="option" value="<?php echo $option; ?>" />
        <input type="hidden" name="task" value="<?php echo $task; ?>" />
        <input type="hidden" name="return" value="<?php echo $return; ?>" />
        <?php echo JHTML::_('form.token'); ?>
    </form>
</div>
                                                                                                                                                              tmpl/login.php                                                                                      0000705                 00000005215 15242037135 0007344 0                                                                                                    ustar 00                                                                                                                                                                                                                                                       <?php
/**
 * @version    2.11 (rolling release)
 * @package    K2
 * @author     JoomlaWorks https://www.joomlaworks.net
 * @copyright  Copyright (c) 2009 - 2024 JoomlaWorks Ltd. All rights reserved.
 * @license    GNU/GPL: https://gnu.org/licenses/gpl.html
 */

// no direct access
defined('_JEXEC') or die;

?>

<div id="k2ModuleBox<?php echo $module->id; ?>" class="k2LoginBlock<?php if ($params->get('moduleclass_sfx')) echo ' '.$params->get('moduleclass_sfx'); ?>">
    <form action="<?php echo JRoute::_('index.php', true, $params->get('usesecure')); ?>" method="post" name="login" id="form-login">
        <?php if ($params->get('pretext')): ?>
        <p class="preText"><?php echo $params->get('pretext'); ?></p>
        <?php endif; ?>

        <fieldset class="input">
            <p id="form-login-username">
                <label for="modlgn_username"><?php echo JText::_('K2_USERNAME') ?></label>
                <input id="modlgn_username" type="text" name="username" class="inputbox" size="18" />
            </p>
            <p id="form-login-password">
                <label for="modlgn_passwd"><?php echo JText::_('K2_PASSWORD') ?></label>
                <input id="modlgn_passwd" type="password" name="<?php echo $passwordFieldName; ?>" class="inputbox" size="18" />
            </p>
            <?php if (JPluginHelper::isEnabled('system', 'remember')): ?>
            <p id="form-login-remember">
                <label for="modlgn_remember"><?php echo JText::_('K2_REMEMBER_ME') ?></label>
                <input id="modlgn_remember" type="checkbox" name="remember" class="inputbox" value="yes" />
            </p>
            <?php endif; ?>
            <input type="submit" name="Submit" class="button" value="<?php echo JText::_('K2_LOGIN') ?>" />
        </fieldset>

        <ul>
            <li><a href="<?php echo $resetLink; ?>"><?php echo JText::_('K2_FORGOT_YOUR_PASSWORD'); ?></a></li>
            <li><a href="<?php echo $remindLink ?>"><?php echo JText::_('K2_FORGOT_YOUR_USERNAME'); ?></a></li>
            <?php if ($usersConfig->get('allowUserRegistration')): ?>
            <li><a href="<?php echo $registrationLink; ?>"><?php echo JText::_('K2_CREATE_AN_ACCOUNT'); ?></a></li>
            <?php endif; ?>
        </ul>

        <?php if ($params->get('posttext')): ?>
        <p class="postText"><?php echo $params->get('posttext'); ?></p>
        <?php endif; ?>

        <input type="hidden" name="option" value="<?php echo $option; ?>" />
        <input type="hidden" name="task" value="<?php echo $task; ?>" />
        <input type="hidden" name="return" value="<?php echo $return; ?>" />
        <?php echo JHTML::_('form.token'); ?>
    </form>
</div>
                                                                                                                                                                                                                                                                                                                                                                                   helper.php                                                                                          0000705                 00000014515 15242037135 0006542 0                                                                                                    ustar 00                                                                                                                                                                                                                                                       <?php
/**
 * @version    2.11 (rolling release)
 * @package    K2
 * @author     JoomlaWorks https://www.joomlaworks.net
 * @copyright  Copyright (c) 2009 - 2024 JoomlaWorks Ltd. All rights reserved.
 * @license    GNU/GPL: https://gnu.org/licenses/gpl.html
 */

// no direct access
defined('_JEXEC') or die;

JLoader::register('K2HelperRoute', JPATH_SITE.'/components/com_k2/helpers/route.php');
JLoader::register('K2HelperUtilities', JPATH_SITE.'/components/com_k2/helpers/utilities.php');

class modK2UserHelper
{
    public static function getReturnURL($params, $type)
    {
        if ($itemid = $params->get($type)) {
            $app = JFactory::getApplication();
            $menu = $app->getMenu();
            $item = $menu->getItem($itemid);
            if (K2_JVERSION != '15') {
                $url = 'index.php?Itemid=' . $item->id;
            } else {
                $url = JRoute::_($item->link.'&Itemid='.$itemid, false);
            }
        } else {
            // stay on the same page
            $uri = JFactory::getURI();
            $url = $uri->toString(array('path', 'query', 'fragment'));
        }

        return base64_encode($url);
    }

    public static function getType()
    {
        $user = JFactory::getUser();
        return (!$user->get('guest')) ? 'logout' : 'login';
    }

    public static function getProfile(&$params)
    {
        $user = JFactory::getUser();
        $db = JFactory::getDbo();
        $query = "SELECT * FROM #__k2_users WHERE userID=".(int)$user->id;
        $db->setQuery($query, 0, 1);
        $profile = $db->loadObject();

        if ($profile) {
            if ($profile->image != '') {
                $profile->avatar = JURI::root().'media/k2/users/'.$profile->image;
            }
            require_once(JPATH_SITE.'/components/com_k2/helpers/permissions.php');
            if (JRequest::getCmd('option') != 'com_k2') {
                K2HelperPermissions::setPermissions();
            }
            if (K2HelperPermissions::canAddItem()) {
                $profile->addLink = JRoute::_('index.php?option=com_k2&view=item&task=add&tmpl=component&template=system&context=modalselector');
            }
            return $profile;
        }
    }

    public static function countUserComments($userID)
    {
        $db = JFactory::getDbo();
        $query = "SELECT COUNT(*) FROM #__k2_comments WHERE userID=".(int)$userID." AND published=1";
        $db->setQuery($query);
        $result = $db->loadResult();
        return $result;
    }

    public static function getMenu($params)
    {
        $items = array();
        $children = array();
        if ($params->get('menu')) {
            $app = JFactory::getApplication();
            $menu = $app->getMenu();
            $items = $menu->getItems('menutype', $params->get('menu'));
        }
        foreach ($items as $item) {
            if (K2_JVERSION != '15') {
                $item->name = $item->title;
                $item->parent = $item->parent_id;
            }
            $index = $item->parent;
            $list = @$children[$index] ? $children[$index] : array();
            array_push($list, $item);
            $children[$index] = $list;
        }
        if (K2_JVERSION != '15') {
            $items = JHTML::_('menu.treerecurse', 1, '', array(), $children, 9999, 0, 0);
        } else {
            $items = JHTML::_('menu.treerecurse', 0, '', array(), $children, 9999, 0, 0);
        }
        $links = array();
        foreach ($items as $item) {
            if (K2_JVERSION == '15') {
                $item->level = $item->sublevel;
                switch ($item->type) {
                    case 'separator':
                        continue 2;
                        break;
                    case 'url':
                        if ((strpos($item->link, 'index.php?') === 0) && (strpos($item->link, 'Itemid=') === false)) {
                            $item->url = $item->link.'&amp;Itemid='.$item->id;
                        } else {
                            $item->url = $item->link;
                        }
                        break;
                    default:
                        $router = JSite::getRouter();
                        $item->url = $router->getMode() == JROUTER_MODE_SEF ? 'index.php?Itemid='.$item->id : $item->link.'&Itemid='.$item->id;
                        break;
                }
                $iParams = class_exists('JParameter') ? new JParameter($item->params) : new JRegistry($item->params);
                $iSecure = $iParams->def('secure', 0);
                if ($item->home == 1) {
                    $item->url = JURI::base();
                } elseif (strcasecmp(substr($item->url, 0, 4), 'http') && (strpos($item->link, 'index.php?') !== false)) {
                    $item->url = JRoute::_($item->url, true, $iSecure);
                } else {
                    $item->url = str_replace('&', '&amp;', $item->url);
                }
                $item->route = $item->url;
            } else {
                $item->flink = $item->link;
                switch ($item->type) {
                    case 'separator':
                        continue 2;
                    case 'url':
                        if ((strpos($item->link, 'index.php?') === 0) && (strpos($item->link, 'Itemid=') === false)) {
                            $item->flink = $item->link.'&Itemid='.$item->id;
                        }
                        break;
                    case 'alias':
                        $item->flink = 'index.php?Itemid='.$item->params->get('aliasoptions');
                        break;
                    default:
                        $router = JSite::getRouter();
                        if ($router->getMode() == JROUTER_MODE_SEF) {
                            $item->flink = 'index.php?Itemid='.$item->id;
                        } else {
                            $item->flink .= '&Itemid='.$item->id;
                        }
                        break;
                }
                if (strcasecmp(substr($item->flink, 0, 4), 'http') && (strpos($item->flink, 'index.php?') !== false)) {
                    $item->flink = JRoute::_($item->flink, true, $item->params->get('secure'));
                } else {
                    $item->flink = JRoute::_($item->flink);
                }
                $item->route = $item->flink;
            }
            $links[] = $item;
        }
        return $links;
    }
}
                                                                                                                                                                                   index.html                                                                                          0000705                 00000000054 15242037135 0006540 0                                                                                                    ustar 00                                                                                                                                                                                                                                                       <html><body bgcolor="#FFFFFF"></body></html>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    mod_k2_user.php                                                                                     0000705                 00000007415 15242037135 0007475 0                                                                                                    ustar 00                                                                                                                                                                                                                                                       <?php
/**
 * @version    2.11 (rolling release)
 * @package    K2
 * @author     JoomlaWorks https://www.joomlaworks.net
 * @copyright  Copyright (c) 2009 - 2024 JoomlaWorks Ltd. All rights reserved.
 * @license    GNU/GPL: https://gnu.org/licenses/gpl.html
 */

// no direct access
defined('_JEXEC') or die;

$language = JFactory::getLanguage();

if (K2_JVERSION != '15') {
    $language->load('com_k2.dates', JPATH_ADMINISTRATOR, null, true);
    require_once JPATH_SITE.'/components/com_users/helpers/route.php';
}

require_once(dirname(__FILE__).'/helper.php');

$moduleclass_sfx = $params->get('moduleclass_sfx', '');
$userGreetingText = $params->get('userGreetingText', '');
$userAvatarWidthSelect = $params->get('userAvatarWidthSelect', 'custom');
$userAvatarWidth = $params->get('userAvatarWidth', 50);

// Legacy params
$greeting = 0;

$type = modK2UserHelper::getType();
$return = modK2UserHelper::getReturnURL($params, $type);
$user = JFactory::getUser();

$componentParams = JComponentHelper::getParams('com_k2');
$K2CommentsEnabled = $componentParams->get('comments');

// User avatar
if ($userAvatarWidthSelect == 'inherit') {
    $avatarWidth = $componentParams->get('userImageWidth');
} else {
    $avatarWidth = $userAvatarWidth;
}

// Load the right template
if ($user->guest) {
    // OpenID stuff (do not edit)
    if (JPluginHelper::isEnabled('authentication', 'openid')) {
        $language->load('plg_authentication_openid', JPATH_ADMINISTRATOR);
        $document = JFactory::getDocument();
        $document->addScriptDeclaration("
            var JLanguage = {};
            JLanguage.WHAT_IS_OPENID = '".JText::_('K2_WHAT_IS_OPENID')."';
            JLanguage.LOGIN_WITH_OPENID = '".JText::_('K2_LOGIN_WITH_OPENID')."';
            JLanguage.NORMAL_LOGIN = '".JText::_('K2_NORMAL_LOGIN')."';
            var modlogin = 1;
        ");
        JHTML::_('script', 'openid.js');
    }

    // Get user stuff (do not edit)
    $usersConfig = JComponentHelper::getParams('com_users');

    // Define some variables depending on Joomla version
    $passwordFieldName = (K2_JVERSION != '15') ? 'password' : 'passwd';
    $resetLink = JRoute::_((K2_JVERSION != '15') ? 'index.php?option=com_users&view=reset&Itemid='.UsersHelperRoute::getResetRoute() : 'index.php?option=com_user&view=reset');
    $remindLink = JRoute::_((K2_JVERSION != '15') ? 'index.php?option=com_users&view=remind&Itemid='.UsersHelperRoute::getRemindRoute() : 'index.php?option=com_user&view=remind');
    $registrationLink = JRoute::_((K2_JVERSION != '15') ? 'index.php?option=com_users&view=registration&Itemid='.UsersHelperRoute::getRegistrationRoute() : 'index.php?option=com_user&view=register');

    $option = (K2_JVERSION != '15') ? 'com_users' : 'com_user';
    $task = K2_JVERSION != '15' ? 'user.login' : 'login';

    require(JModuleHelper::getLayoutPath('mod_k2_user', 'login'));
} else {
    $user->profile = modK2UserHelper::getProfile($params);
    $user->numOfComments = modK2UserHelper::countUserComments($user->id);
    $menu = modK2UserHelper::getMenu($params);

    if (is_object($user->profile) && isset($user->profile->addLink)) {
        $addItemLink = $user->profile->addLink;
    }
    $viewProfileLink = JRoute::_(K2HelperRoute::getUserRoute($user->id));
    $editProfileLink = JRoute::_((K2_JVERSION != '15') ? 'index.php?option=com_users&view=profile&layout=edit&Itemid='.UsersHelperRoute::getProfileRoute() : 'index.php?option=com_user&view=user&task=edit');
    $profileLink = $editProfileLink; // B/C
    $editCommentsLink = JRoute::_('index.php?option=com_k2&view=comments&tmpl=component&template=system&context=modalselector');

    $option = (K2_JVERSION != '15') ? 'com_users' : 'com_user';
    $task = (K2_JVERSION != '15') ? 'user.logout' : 'logout';

    require(JModuleHelper::getLayoutPath('mod_k2_user', 'userblock'));
}
                                                                                                                                                                                                                                                   mod_k2_user.xml                                                                                     0000705                 00000010603 15242037135 0007477 0                                                                                                    ustar 00                                                                                                                                                                                                                                                       <?xml version="1.0" encoding="utf-8"?>
<extension type="module" client="site" version="2.5" method="upgrade">
    <name>K2 User</name>
    <author>JoomlaWorks</author>
    <creationDate>(see K2 component)</creationDate>
    <copyright>Copyright (c) 2009 - 2024 JoomlaWorks Ltd. All rights reserved.</copyright>
    <authorEmail>please-use-the-contact-form@joomlaworks.net</authorEmail>
    <authorUrl>https://www.joomlaworks.net</authorUrl>
    <version>(see K2 component)</version>
    <license>https://gnu.org/licenses/gpl.html</license>
    <description>K2_MOD_K2_USER_DESCRIPTION</description>
    <files>
        <filename module="mod_k2_user">mod_k2_user.php</filename>
        <filename>helper.php</filename>
        <folder>tmpl</folder>
    </files>
    <config>
        <fields name="params">
            <fieldset name="basic" addfieldpath="/administrator/components/com_k2/elements/">
                <field name="moduleclass_sfx" type="text" default="" label="K2_MODULE_CLASS_SUFFIX" description="K2_MODULE_CLASS_SUFFIX_DESCRIPTION" />
                <field name="pretext" type="textarea" cols="30" rows="5" default="" label="K2_PRETEXT" description="" />
                <field name="posttext" type="textarea" cols="30" rows="5" label="K2_POSTTEXT" description="" />
                <field name="" type="header" default="K2_OPTIONS_FOR_LOGGED_IN_USERS" label="" description="" />
                <field name="userGreetingText" type="textarea" cols="30" rows="5" label="K2_GREETING_TEXT" description="K2_WRITE_A_CUSTOM_TEXT_TO_DISPLAY_TO_YOUR_USERS_WHEN_THEY_ARE_LOGGED_IN" />
                <field name="name" type="list" default="1" label="K2_DISPLAY_USERNAME_OR_NAME" description="">
                    <option value="0">K2_USERNAME</option>
                    <option value="1">K2_NAME</option>
                </field>
                <field name="userAvatar" type="radio" default="1" label="K2_USER_AVATAR" description="" class="btn-group btn-group-yesno">
                    <option value="0">K2_HIDE</option>
                    <option value="1">K2_SHOW</option>
                </field>
                <field name="userAvatarWidthSelect" type="list" default="custom" label="K2_USER_AVATAR_WIDTH" description="">
                    <option value="inherit">K2_INHERIT_FROM_COMPONENT_PARAMETERS</option>
                    <option value="custom">K2_USE_CUSTOM_WIDTH</option>
                </field>
                <field name="userAvatarWidth" type="text" default="50" size="4" label="K2_CUSTOM_WIDTH_FOR_USER_AVATAR_IN_PX" description="" />
                <field name="" type="header" default="K2_MENU_RENDER_OPTION" label="" description="" />
                <field name="menu" type="menus" default="" label="K2_MENU_TO_RENDER" description="K2_MENU_TO_RENDER_DESC" />
                <field name="" type="header" default="K2_LOGIN_LOGOUT_REDIRECTION" label="" description="" />
                <field name="login" type="menuitem" default="" disable="separator" label="K2_LOGIN_REDIRECTION_URL" description="K2_LOGIN_REDIRECTION_URL_DESCRIPTION">
                	<option value="">K2_NONE_ONSELECTLISTS</option>
                </field>
                <field name="logout" type="menuitem" default="" disable="separator" label="K2_LOGOUT_REDIRECTION_URL" description="K2_LOGOUT_REDIRECTION_URL_DESCRIPTION">
                	<option value="">K2_NONE_ONSELECTLISTS</option>
                </field>
                <field name="usesecure" type="radio" default="0" label="K2_ENCRYPT_LOGIN_FORM" description="K2_SUBMIT_ENCRYPTED_LOGIN_DATA_REQUIRES_SSL" class="btn-group btn-group-yesno">
                    <option value="0">K2_NO</option>
                    <option value="1">K2_YES</option>
                </field>
            </fieldset>
            <fieldset name="advanced">
                <field name="cache" type="list" default="0" label="K2_CACHING" description="K2_SELECT_WHETHER_TO_CACHE_THE_CONTENT_OF_THIS_MODULE">
                    <option value="1">K2_USE_GLOBAL</option>
                    <option value="0">K2_NO_CACHING</option>
                </field>
                <field name="cache_time" type="text" default="" label="K2_CACHE_TIME" description="K2_THE_TIME_IN_SECONDS_BEFORE_THE_MODULE_IS_RECACHED" />
                <field name="cachemode" type="hidden" default="static">
                    <option value="static"></option>
                </field>
            </fieldset>
        </fields>
    </config>
</extension>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             