Topics_Started_by_a_user_0.1.2.zip

Started by Yio, February 13, 2007, 10:38:17 AM

Previous topic - Next topic

Yio

Link to Mod

This mod adds a "Topics Started by this user" link in Profile and Topic Display (with icon beside the profile icon).
It shows only the first message from each post that the user began.
The speaker´s icon was a modification that I made to the profile´s icon.

Spanish version is included.

2006-12-25 bugfixed
If the visitor is the profile´s owner then table on the left shows Show Posts / Show Posts Started, instead Show Posts / Show Posts (that was my bug)


Este mod agrega un vinculo en el Perfil de un usuario que muestra los temas iniciados por él así como un ícono en el cuerpo del mensaje, bajo los datos del usuario, junto al ícono del perfil.
Incluye versión en español.

Shadow Queen

I have a error on this mod now. How do I fix this?

Fatal error: Cannot redeclare tpsummary() (previously declared in /home/darkness/public_html/Sources/Profile.php:3176) in /home/darkness/public_html/Sources/Profile.php on line 3226

Kirill Krasnov

Yio,
I have this error in forum-log

8: Use of undefined constant started_by_this_u - assumed 'started_by_this_u'
File: XXXXXXXXXX\smf\Themes\default\Display.template.php
Line: 374

Why? How I can fix?
in Modifications.english.php and Modifications.russian-utf8.php I have this lines

$txt['topics_started_by_this_user'] = 'Темы начатые пользователем';
$txt['started_by_this_u'] = 'Показать сообщения начатые этим пользователем.';


pulkit

Ok, with TP, is shows "topics started by this user" instead of "Total posts" on the front page.

Can this be fixed ??

pulkit


falguni1


SAMm

when i install the mod
i click in the .gif and appears a message saying that "sorry, no found posts"

but i've 400 posts :(

can you sayme whats wrong? :(

edi67

CrazyZone - My SMF Forum


From the difficult the hardening of the man you can see

klra

#8
Ok, here how I got this to work on 1.1.4 -

First I unzipped the package.

Then I opened the package-info.xml file 

Find -

   <install for="1.1, 1.1.1, 1.1.2">

Changed to-

   <install for="1.1, 1.1.1, 1.1.2, 1.1.3, 1.1.4">

Now it installed and unistalled just fine on my test forum.

But I wanted it to show "Topics Started" instead of "Posts Started" in a users Profile Info box.

So I modified the Topics_started_by_a_user_0.1.3.xml file -

Find -

$txt['showPostsini'] = 'Show Posts Started';

Change to -

$txt['showPostsini'] = 'Show Topics Started';

Works great!


Basie


klra


klra

One thing that I may change is what is displayed when you select this.

It shows the Topic list, but also shows the content of the first post.

I'd like to it to show just a list of topics, and show a list of 50.

So I'm working on that right now-

klra

Ok, I'm not sure what I have to delete/mod from the Topics_started_by_a_user_0.1.3.xml  file in order to just show a list of started topics with the first post info being displayed.

But I did find something else-

When looking at the member info box in any post, right below the Profile icon, it showed-

Show the posts started by this member.

Like this-



As you can see, it didn't display all of the words unless I zoomed out the browser view-



So I made this editd to the Topics_started_by_a_user_0.1.3.xml    file -

Find -

$txt['started_by_this_u'] = 'Show the posts started by this member.';

Change to - (or whatever you want to be displayed) -

$txt['started_by_this_u'] = 'Topics Started by Member.';

Here's what I ended up with in the default browser zoom view-



So can somebody help me figure out what to edit in the Topics_started_by_a_user_0.1.3.xml   file to show the list without displaying the content of the first post?

Thanks-  :)

klra

#13
ok, here's the Topics_started_by user_0.1.3.xml file -

<?xml version="1.0"?>
<!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification">
<modification xmlns="http://www.simplemachines.org/xml/modification" xmlns:smf="http://www.simplemachines.org/">
<id>Yio:Topics_Started_by_a_user-v0.1.3</id>
<version>0.1.2</version>
<homepage>http://www.yio.com.ar</homepage>
<file name="$sourcedir/Profile.php">
<operation>
<search position="before"><![CDATA[
// Clean up after posts that cannot be deleted.
foreach ($context['posts'] as $counter => $dummy)
$context['posts'][$counter]['can_delete'] &= $context['posts'][$counter]['delete_possible'];
}
]]></search>
<add><![CDATA[
// Show all posts started by the current user
function showPostsini($memID)
{
global $txt, $user_info, $scripturl, $modSettings, $db_prefix;
global $context, $user_profile, $ID_MEMBER, $sourcedir;

// If just deleting a message, do it and then redirect back.
if (isset($_GET['delete']))
{
checkSession('get');

// We can be lazy, since removeMessage() will check the permissions for us.
require_once($sourcedir . '/RemoveTopic.php');
removeMessage((int) $_GET['delete']);

// Back to... where we are now ;).
redirectexit('action=profile;u=' . $memID . ';sa=showPostsini;start=' . $_GET['start']);
}

// Is the load average too high to allow searching just now?
if (!empty($context['load_average']) && !empty($modSettings['loadavg_show_posts']) && $context['load_average'] >= $modSettings['loadavg_show_posts'])
fatal_lang_error('loadavg_show_posts_disabled', false);

// Default to 10.
if (empty($_REQUEST['viewscount']) || !is_numeric($_REQUEST['viewscount']))
$_REQUEST['viewscount'] = '10';


$request = db_query("SELECT COUNT(*)
FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
LEFT JOIN {$db_prefix}categories AS c ON (c.ID_CAT = b.ID_CAT)
WHERE m.ID_MEMBER = $memID
AND m.ID_TOPIC = t.ID_TOPIC
AND m.ID_MSG = t.ID_FIRST_MSG
AND t.ID_MEMBER_STARTED = $memID

AND t.ID_BOARD = b.ID_BOARD" . (empty($range_limit) ? '' : "
AND $range_limit") . "
AND $user_info[query_see_board]", __FILE__, __LINE__);
list ($msgCount) = mysql_fetch_row($request);
mysql_free_result($request);

$request = db_query("
SELECT MIN(ID_MSG), MAX(ID_MSG)
FROM {$db_prefix}messages AS m
WHERE m.ID_MEMBER = $memID", __FILE__, __LINE__);
list ($min_msg_member, $max_msg_member) = mysql_fetch_row($request);
mysql_free_result($request);


$reverse = false;
$range_limit = '';
$maxIndex = (int) $modSettings['defaultMaxMessages'];

// Make sure the starting place makes sense and construct our friend the page index.
$context['start'] = (int) $_REQUEST['start'];
$context['page_index'] = constructPageIndex($scripturl . '?action=profile;u=' . $memID . ';sa=showPostsini', $context['start'], $msgCount, $maxIndex);
$context['current_page'] = $context['start'] / $maxIndex;
$context['current_member'] = $memID;

// Reverse the query if we're past 50% of the pages for better performance.
$start = $context['start'];
$reverse = $_REQUEST['start'] > $msgCount / 2;
if ($reverse)
{
$maxIndex = $msgCount < $context['start'] + $modSettings['defaultMaxMessages'] + 1 && $msgCount > $context['start'] ? $msgCount - $context['start'] : (int) $modSettings['defaultMaxMessages'];
$start = $msgCount < $context['start'] + $modSettings['defaultMaxMessages'] + 1 || $msgCount < $context['start'] + $modSettings['defaultMaxMessages'] ? 0 : $msgCount - $context['start'] - $modSettings['defaultMaxMessages'];
}

// Guess the range of messages to be shown.
if ($msgCount > 1000)
{
$margin = floor(($max_msg_member - $min_msg_member) * (($start + $modSettings['defaultMaxMessages']) / $msgCount) + .1 * ($max_msg_member - $min_msg_member));
$range_limit = $reverse ? 'ID_MSG < ' . ($min_msg_member + $margin) : 'ID_MSG > ' . ($max_msg_member - $margin);
}

$context['page_title'] = $txt[458] . ' ' . $user_profile[$memID]['realName'];

// Find this user's posts.  The left join on categories somehow makes this faster, weird as it looks.
$looped = false;
while (true)
{

$request = db_query("
SELECT
b.ID_BOARD, b.name AS bname, c.ID_CAT, c.name AS cname, m.ID_TOPIC, m.ID_MSG,
t.ID_MEMBER_STARTED, t.ID_FIRST_MSG, t.ID_LAST_MSG, m.body, m.smileysEnabled,
m.subject, m.posterTime
FROM ({$db_prefix}messages AS m, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
LEFT JOIN {$db_prefix}categories AS c ON (c.ID_CAT = b.ID_CAT)
WHERE m.ID_MEMBER = $memID
AND m.ID_TOPIC = t.ID_TOPIC
AND m.ID_MSG = t.ID_FIRST_MSG
AND t.ID_MEMBER_STARTED = $memID

AND t.ID_BOARD = b.ID_BOARD" . (empty($range_limit) ? '' : "
AND $range_limit") . "
AND $user_info[query_see_board]
ORDER BY m.ID_MSG " . ($reverse ? 'ASC' : 'DESC') . "
LIMIT $start, $maxIndex", __FILE__, __LINE__);


// Make sure we quit this loop.
if (mysql_num_rows($request) === $maxIndex || $looped)
break;
$looped = true;
$range_limit = '';
}

// Start counting at the number of the first message displayed.
$counter = $reverse ? $context['start'] + $maxIndex + 1 : $context['start'];
$context['posts'] = array();
$board_ids = array('own' => array(), 'any' => array());
while ($row = mysql_fetch_assoc($request))
{
// Censor....
censorText($row['body']);
censorText($row['subject']);

// Do the code.
$row['body'] = parse_bbc($row['body'], $row['smileysEnabled'], $row['ID_MSG']);

// And the array...
$context['posts'][$counter += $reverse ? -1 : 1] = array(
'body' => $row['body'],
'counter' => $counter,
'category' => array(
'name' => $row['cname'],
'id' => $row['ID_CAT']
),
'board' => array(
'name' => $row['bname'],
'id' => $row['ID_BOARD']
),
'topic' => $row['ID_TOPIC'],
'subject' => $row['subject'],
'start' => 'msg' . $row['ID_MSG'],
'time' => timeformat($row['posterTime']),
'timestamp' => forum_time(true, $row['posterTime']),
'id' => $row['ID_MSG'],
'can_reply' => false,
'can_mark_notify' => false,
'can_delete' => false,
'delete_possible' => ($row['ID_FIRST_MSG'] != $row['ID_MSG'] || $row['ID_LAST_MSG'] == $row['ID_MSG']) && (empty($modSettings['edit_disable_time']) || $row['posterTime'] + $modSettings['edit_disable_time'] * 60 >= time()),
);

if ($ID_MEMBER == $row['ID_MEMBER_STARTED'])
$board_ids['own'][$row['ID_BOARD']][] = $counter;
$board_ids['any'][$row['ID_BOARD']][] = $counter;
}
mysql_free_result($request);

// All posts were retrieved in reverse order, get them right again.
if ($reverse)
$context['posts'] = array_reverse($context['posts'], true);

// These are all the permissions that are different from board to board..
$permissions = array(
'own' => array(
'post_reply_own' => 'can_reply',
'delete_own' => 'can_delete',
),
'any' => array(
'post_reply_any' => 'can_reply',
'mark_any_notify' => 'can_mark_notify',
'delete_any' => 'can_delete',
)
);

// For every permission in the own/any lists...
foreach ($permissions as $type => $list)
{
foreach ($list as $permission => $allowed)
{
// Get the boards they can do this on...
$boards = boardsAllowedTo($permission);

// Hmm, they can do it on all boards, can they?
if (!empty($boards) && $boards[0] == 0)
$boards = array_keys($board_ids[$type]);

// Now go through each board they can do the permission on.
foreach ($boards as $board_id)
{
// There aren't any posts displayed from this board.
if (!isset($board_ids[$type][$board_id]))
continue;

// Set the permission to true ;).
foreach ($board_ids[$type][$board_id] as $counter)
$context['posts'][$counter][$allowed] = true;
}
}
}

// Clean up after posts that cannot be deleted.
foreach ($context['posts'] as $counter => $dummy)
$context['posts'][$counter]['can_delete'] &= $context['posts'][$counter]['delete_possible'];
}
]]></add>
</operation>
<operation>
<search position="before"><![CDATA[
'summary' => array(array('profile_view_any', 'profile_view_own'), array('profile_view_any')),
'statPanel' => array(array('profile_view_any', 'profile_view_own'), array('profile_view_any')),
'showPosts' => array(array('profile_view_any', 'profile_view_own'), array('profile_view_any')),
]]></search>
<add><![CDATA[
'showPostsini' => array(array('profile_view_any', 'profile_view_own'), array('profile_view_any')),
]]></add>
</operation>
<operation>
<search position="before"><![CDATA[
$context['profile_areas']['info']['areas']['summary'] = '<a href="' . $scripturl . '?action=profile;u=' . $memID . ';sa=summary">' . $txt['summary'] . '</a>';
$context['profile_areas']['info']['areas']['statPanel'] = '<a href="' . $scripturl . '?action=profile;u=' . $memID . ';sa=statPanel">' . $txt['statPanel'] . '</a>';
$context['profile_areas']['info']['areas']['showPosts'] = '<a href="' . $scripturl . '?action=profile;u=' . $memID . ';sa=showPosts">' . $txt['showPosts'] . '</a>';
]]></search>
<add><![CDATA[
$context['profile_areas']['info']['areas']['showPostsini'] = '<a href="' . $scripturl . '?action=profile;u=' . $memID . ';sa=showPostsini">' . $txt['showPostsini'] . '</a>';
]]></add>
</operation>
</file>
<file name="$themedir/Profile.template.php">
        <operation>
                <search position="before"><![CDATA[
// Small template for showing an error message upon a save problem in the profile.
function template_error_message()
{
global $context, $txt;

echo '
<div class="windowbg" style="margin: 1ex; padding: 1ex 2ex; border: 1px dashed red; color: red;">
<span style="text-decoration: underline;">', $txt['profile_errors_occurred'], ':</span>
<ul>';

// Cycle through each error and display an error message.
foreach ($context['post_errors'] as $error)
//if (isset($txt['profile_error_' . $error]))
echo '
<li>', $txt['profile_error_' . $error], '.</li>';

echo '
</ul>
</div>';
}
]]></search>
                        <add><![CDATA[
// Template for showing all the posts started by a user, in chronological order.
function template_showPostsini()
{
global $context, $settings, $options, $scripturl, $modSettings, $txt;

echo '
<table border="0" width="85%" cellspacing="1" cellpadding="4" class="bordercolor" align="center">
<tr class="titlebg">
<td colspan="3" height="26">
&nbsp;<img src="', $settings['images_url'], '/icons/profile_sm.gif" alt="" align="top" />&nbsp;', $txt['showPosts'], '
</td>
</tr>';

// Only show posts if they have made some!
if (!empty($context['posts']))
{
// Page numbers.
echo '
<tr class="catbg3">
<td colspan="3">
', $txt[139], ': ', $context['page_index'], '
</td>
</tr>
</table>';

// Button shortcuts
$quote_button = create_button('quote.gif', 145, 'smf240', 'align="middle"');
$reply_button = create_button('reply_sm.gif', 146, 146, 'align="middle"');
$remove_button = create_button('delete.gif', 121, 31, 'align="middle"');
$notify_button = create_button('notify_sm.gif', 131, 125, 'align="middle"');

// For every post to be displayed, give it its own subtable, and show the important details of the post.
foreach ($context['posts'] as $post)
{
echo '
<table border="0" width="85%" cellspacing="1" cellpadding="0" class="bordercolor" align="center">
<tr>
<td width="100%">
<table border="0" width="100%" cellspacing="0" cellpadding="4" class="bordercolor" align="center">
<tr class="titlebg2">
<td style="padding: 0 1ex;">
', $post['counter'], '
</td>
<td width="75%" class="middletext">
&nbsp;<a href="', $scripturl, '#', $post['category']['id'], '">', $post['category']['name'], '</a> / <a href="', $scripturl, '?board=', $post['board']['id'], '.0">', $post['board']['name'], '</a> / <a href="', $scripturl, '?topic=', $post['topic'], '.', $post['start'], '#msg', $post['id'], '">', $post['subject'], '</a>
</td>
<td class="middletext" align="right" style="padding: 0 1ex; white-space: nowrap;">
', $txt[30], ': ', $post['time'], '
</td>
</tr>
<tr>
<td width="100%" height="80" colspan="3" valign="top" class="windowbg2">
<div class="post">', $post['body'], '</div>
</td>
</tr>
<tr>
<td colspan="3" class="windowbg2" align="', !$context['right_to_left'] ? 'right' : 'left', '"><span class="middletext">';

if ($post['can_delete'])
echo '
<a href="', $scripturl, '?action=profile;u=', $context['current_member'], ';sa=showPosts;start=', $context['start'], ';delete=', $post['id'], ';sesc=', $context['session_id'], '" onclick="return confirm(\'', $txt[154], '?\');">', $remove_button, '</a>';
if ($post['can_delete'] && ($post['can_mark_notify'] || $post['can_reply']))
echo '
', $context['menu_separator'];
if ($post['can_reply'])
echo '
<a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], '">', $reply_button, '</a>', $context['menu_separator'], '
<a href="', $scripturl, '?action=post;topic=', $post['topic'], '.', $post['start'], ';quote=', $post['id'], ';sesc=', $context['session_id'], '">', $quote_button, '</a>';
if ($post['can_reply'] && $post['can_mark_notify'])
echo '
', $context['menu_separator'];
if ($post['can_mark_notify'])
echo '
<a href="' . $scripturl . '?action=notify;topic=' . $post['topic'] . '.' . $post['start'] . '">' . $notify_button . '</a>';

echo '
</span></td>
</tr>
</table>
</td>
</tr>
</table>';
}

// Show more page numbers.
echo '
<table border="0" width="85%" cellspacing="1" cellpadding="4" class="bordercolor" align="center">
<tr>
<td colspan="3" class="catbg3">
', $txt[139], ': ', $context['page_index'], '
</td>
</tr>
</table>';
}
// No posts? Just end the table with a informative message.
else
echo '
<tr class="windowbg2">
<td>
', $txt[170], '
</td>


</tr>
</table>';
}
]]></add>
</operation>
    <operation>
                <search position="before"><![CDATA[
<a href="', $scripturl, '?action=profile;u=', $context['member']['id'], ';sa=showPosts">', $txt[460], ' ', $txt[461], '.</a><br />
]]></search>
                        <add><![CDATA[
<a href="', $scripturl, '?action=profile;u=', $context['member']['id'], ';sa=showPostsini">', $txt[460], ' ', $txt[489], '.</a><br />
]]></add>
</operation>
</file>
<file name="$themedir/Display.template.php">
        <operation>
                <search position="replace"><![CDATA[
<a href="', $message['member']['href'], '">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/icons/profile_sm.gif" alt="' . $txt[27] . '" title="' . $txt[27] . '" border="0" />' : $txt[27]), '</a>';
]]></search>
                        <add><![CDATA[
<a href="', $message['member']['href'], '">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/icons/profile_sm.gif" alt="' . $txt[27] . '" title="' . $txt[27] . '" border="0" />' : $txt[27]), '</a>
<a href="', $message['member']['href'], ';sa=showPostsini"><img src="' . $settings['images_url'] . '/icons/speaker.gif" alt="' . $txt['started_by_this_u'] . '" title="' . $txt['started_by_this_u'] . '" border="0" /></a>';
]]></add>
                </operation>
        </file>
<file name="$themedir/languages/Modifications.english.php" error="ignore">
                <operation error="ignore">
                        <search position="end"></search>
                        <add><![CDATA[
$txt[489] = 'topics started by this user';
$txt['started_by_this_u'] = 'Topics Started by Member';
]]></add>
                </operation>
        </file>
<file name="$themedir/languages/Modifications.spanish_es.php" error="ignore">
                <operation error="ignore">
                        <search position="end"></search>
                        <add><![CDATA[
$txt[489] = 'temas iniciados por este usuario';
$txt['started_by_this_u'] = 'Ver temas iniciados por este usuario';
]]></add>
                </operation>
        </file>
<file name="$themedir/languages/Modifications.dutch.php" error="ignore">
                <operation error="ignore">
                        <search position="end"></search>
                        <add><![CDATA[
$txt[489] = 'Topics gestart door dit lid';
$txt['started_by_this_u'] = 'Toon de topics welke gestart zijn door dit lid';
]]></add>
                </operation>
        </file>

<file name="$themedir/languages/Profile.english.php" error="ignore">
                <operation error="ignore">
                        <search position="end"></search>
                        <add><![CDATA[
$txt['showPostsini'] = 'Show Topics Started';
]]></add>
                </operation>
        </file>
<file name="$themedir/languages/Profile.spanish_es.php" error="ignore">
                <operation error="ignore">
                        <search position="end"></search>
                        <add><![CDATA[
$txt['showPostsini'] = 'Mostrar Mensajes Iniciados';
]]></add>
                </operation>
        </file>
<file name="$themedir/languages/Profile.dutch.php" error="ignore">
                <operation error="ignore">
                        <search position="end"></search>
                        <add><![CDATA[
$txt['showPostsini'] = 'Toon gestarte topics';
]]></add>
                </operation>
        </file>
</modification>







What I think needs to be modified starts at -

// For every post to be displayed, give it its own subtable, and show the important details of the post.

klra

Having problems with this, as the icon that is suppsed to be next to the text does not display in IE7, but shows up in Opera.

Con

I can't seem to be able to download it.. which 'manual' am I suppose to select with it?

And is there a way to edit it into it showing all the topics the person has posted in, not just the ones they posted themselfs?

jepot5

how can u use this that it will show posts only from specific boards/ categories?

Mo786

Does anyone know if this works in SMF 1.1.7? I really want this but I want to make sure that it works before I give it a try incase it screws it up my forum.

Thanks.


R.Bourne

Quote from: Mo786 on December 18, 2008, 09:56:48 PM
Anyone?

I am a noob myself but here it is. Not sure if you already got it to work though :D

FYI, updated the XML file to install for 1.1.7 & 1.1.8.

Advertisement: