Пример #1
0
function editUserProfile($option, $uid)
{
    if (empty($uid[0])) {
        echo JText::_('COM_KUNENA_PROFILE_NO_USER');
        return;
    }
    $kunena_db =& JFactory::getDBO();
    $kunena_acl =& JFactory::getACL();
    $kunena_db->setQuery("SELECT * FROM #__kunena_users LEFT JOIN #__users on #__users.id=#__kunena_users.userid WHERE userid={$uid['0']}");
    $userDetails = $kunena_db->loadObjectList();
    if (KunenaError::checkDatabaseError()) {
        return;
    }
    $user = $userDetails[0];
    //Mambo userids are unique, so we don't worry about that
    $prefview = $user->view;
    $ordering = $user->ordering;
    $moderator = $user->moderator;
    $userRank = $user->rank;
    //grab all special ranks
    $kunena_db->setQuery("SELECT * FROM #__kunena_ranks WHERE rank_special = '1'");
    $specialRanks = $kunena_db->loadObjectList();
    if (KunenaError::checkDatabaseError()) {
        return;
    }
    //build select list options
    $yesnoRank[] = JHTML::_('select.option', '0', JText::_('COM_KUNENA_RANK_NO_ASSIGNED'));
    foreach ($specialRanks as $ranks) {
        $yesnoRank[] = JHTML::_('select.option', $ranks->rank_id, $ranks->rank_title);
    }
    //build special ranks select list
    $selectRank = JHTML::_('select.genericlist', $yesnoRank, 'newrank', 'class="inputbox" size="5"', 'value', 'text', $userRank);
    // make the select list for the view type
    $yesno[] = JHTML::_('select.option', 'flat', JText::_('COM_KUNENA_A_FLAT'));
    $yesno[] = JHTML::_('select.option', 'threaded', JText::_('COM_KUNENA_A_THREADED'));
    // build the html select list
    $selectPref = JHTML::_('select.genericlist', $yesno, 'newview', 'class="inputbox" size="2"', 'value', 'text', $prefview);
    // make the select list for the moderator flag
    $yesnoMod[] = JHTML::_('select.option', '1', JText::_('COM_KUNENA_ANN_YES'));
    $yesnoMod[] = JHTML::_('select.option', '0', JText::_('COM_KUNENA_ANN_NO'));
    // build the html select list
    $selectMod = JHTML::_('select.genericlist', $yesnoMod, 'moderator', 'class="inputbox" size="2"', 'value', 'text', $moderator);
    // make the select list for the moderator flag
    $yesnoOrder[] = JHTML::_('select.option', '0', JText::_('COM_KUNENA_USER_ORDER_ASC'));
    $yesnoOrder[] = JHTML::_('select.option', '1', JText::_('COM_KUNENA_USER_ORDER_DESC'));
    // build the html select list
    $selectOrder = JHTML::_('select.genericlist', $yesnoOrder, 'neworder', 'class="inputbox" size="2"', 'value', 'text', $ordering);
    //get all subscriptions for this user
    $kunena_db->setQuery("select thread from #__kunena_subscriptions where userid={$uid['0']}");
    $subslist = $kunena_db->loadObjectList();
    if (KunenaError::checkDatabaseError()) {
        return;
    }
    //get all categories subscriptions for this user
    $kunena_db->setQuery("select catid from #__kunena_subscriptions_categories where userid={$uid['0']}");
    $subscatslist = $kunena_db->loadObjectList();
    if (KunenaError::checkDatabaseError()) {
        return;
    }
    //get all moderation category ids for this user
    $kunena_db->setQuery("select catid from #__kunena_moderation where userid=" . $uid[0]);
    $modCatList = $kunena_db->loadResultArray();
    if (KunenaError::checkDatabaseError()) {
        return;
    }
    if ($moderator && empty($modCatList)) {
        $modCatList[] = 0;
    }
    $categoryList = array();
    $categoryList[] = JHTML::_('select.option', 0, JText::_('COM_KUNENA_GLOBAL_MODERATOR'));
    $modCats = CKunenaTools::KSelectList('catid[]', $categoryList, 'class="inputbox" multiple="multiple"', false, 'kforums', $modCatList);
    //get all IPs used by this user
    $kunena_db->setQuery("SELECT ip FROM #__kunena_messages WHERE userid={$uid['0']} GROUP BY ip");
    $iplist = implode("','", $kunena_db->loadResultArray());
    if (KunenaError::checkDatabaseError()) {
        return;
    }
    $list = array();
    if ($iplist) {
        $iplist = "'{$iplist}'";
        $kunena_db->setQuery("SELECT m.ip,m.userid,u.username,COUNT(*) as mescnt FROM #__kunena_messages AS m INNER JOIN #__users AS u ON m.userid=u.id WHERE m.ip IN ({$iplist}) GROUP BY m.userid,m.ip");
        $list = $kunena_db->loadObjectlist();
        if (KunenaError::checkDatabaseError()) {
            return;
        }
    }
    $useridslist = array();
    foreach ($list as $item) {
        $useridslist[$item->ip][] = $item;
    }
    html_Kunena::editUserProfile($option, $user, $subslist, $subscatslist, $selectRank, $selectPref, $selectMod, $selectOrder, $uid[0], $modCats, $useridslist);
}
Пример #2
0
function editUserProfile($uid)
{
    $kunena_db =& JFactory::getDBO();
    $kunena_acl =& JFactory::getACL();
    $kunena_db->setQuery("SELECT * FROM #__fb_users LEFT JOIN #__users on #__users.id=#__fb_users.userid WHERE userid={$uid['0']}");
    $userDetails = $kunena_db->loadObjectList();
    check_dberror('Unable to load user profile.');
    $user = $userDetails[0];
    //Mambo userids are unique, so we don't worry about that
    $prefview = $user->view;
    $ordering = $user->ordering;
    $moderator = $user->moderator;
    $userRank = $user->rank;
    //check to see if this is an administrator
    $result = '';
    //$kunena_db->setQuery("select usertype from #__users where id=$uid[0]");
    //$result=$kunena_db->loadResult();
    $result = $kunena_acl->getAroGroup($uid[0]);
    //grab all special ranks
    $kunena_db->setQuery("SELECT * FROM #__fb_ranks WHERE rank_special = '1'");
    $specialRanks = $kunena_db->loadObjectList();
    check_dberror('Unable to load special ranks.');
    //build select list options
    $yesnoRank[] = JHTML::_('select.option', '0', _KUNENA_RANK_NO_ASSIGNED);
    foreach ($specialRanks as $ranks) {
        $yesnoRank[] = JHTML::_('select.option', $ranks->rank_id, $ranks->rank_title);
    }
    //build special ranks select list
    $selectRank = JHTML::_('select.genericlist', $yesnoRank, 'newrank', 'class="inputbox" size="5"', 'value', 'text', $userRank);
    // make the select list for the view type
    $yesno[] = JHTML::_('select.option', 'flat', _COM_A_FLAT);
    $yesno[] = JHTML::_('select.option', 'threaded', _COM_A_THREADED);
    // build the html select list
    $selectPref = JHTML::_('select.genericlist', $yesno, 'newview', 'class="inputbox" size="2"', 'value', 'text', $prefview);
    // make the select list for the moderator flag
    $yesnoMod[] = JHTML::_('select.option', '1', _ANN_YES);
    $yesnoMod[] = JHTML::_('select.option', '0', _ANN_NO);
    // build the html select list
    $selectMod = JHTML::_('select.genericlist', $yesnoMod, 'moderator', 'class="inputbox" size="2"', 'value', 'text', $moderator);
    // make the select list for the moderator flag
    $yesnoOrder[] = JHTML::_('select.option', '0', _USER_ORDER_ASC);
    $yesnoOrder[] = JHTML::_('select.option', '1', _USER_ORDER_DESC);
    // build the html select list
    $selectOrder = JHTML::_('select.genericlist', $yesnoOrder, 'neworder', 'class="inputbox" size="2"', 'value', 'text', $ordering);
    //get all subscriptions for this user
    $kunena_db->setQuery("select thread from #__fb_subscriptions where userid={$uid['0']}");
    $subslist = $kunena_db->loadObjectList();
    check_dberror('Unable to load subscriptions for user.');
    //get all moderation category ids for this user
    $kunena_db->setQuery("select catid from #__fb_moderation where userid=" . $uid[0]);
    $_modCats = $kunena_db->loadResultArray();
    check_dberror('Unable to moderation category ids for user.');
    $__modCats = array();
    foreach ($_modCats as $_v) {
        $__modCats[] = JHTML::_('select.option', $_v);
    }
    $modCats = KUNENA_GetAvailableModCats($__modCats);
    html_Kunena::editUserProfile($user, $subslist, $selectRank, $selectPref, $selectMod, $selectOrder, $uid[0], $modCats);
}