Simple Machines Community Forum

Customizing SMF => Modifications and Packages => Topic started by: The Craw on March 06, 2012, 02:22:44 PM

Title: Ajax Profile Comments
Post by: The Craw on March 06, 2012, 02:22:44 PM
Link to Mod (http://custom.simplemachines.org/mods/index.php?mod=3292)

Current Version: 1.0

As the title suggests, Ajax Profile Comments makes it possible for users to leave comments on their profiles. It uses a nice sliding interface that doesn't require page loads for things like posting new comments, modifying, or deleting.

This mod uses a few icons from the LED icon (http://led24.de/iconset/) set.

License:
I release this mod and all the code in it to anyone who wants to use it in hopes that it may be found useful. Attribution is not necessary, nor do you need to provide a link back to my website. You are free to use this mod for any purpose, including commercial works, redistribution and derivative works. The only contingency is that the link back to the LED icon set (http://led24.de/iconset/) must remain, as this mod uses two icons from that set. Namely comment_delete.png and comment_edit.png. Both images are found in the root directory of the package. All other images are made by myself and can be used freely. Lastly, this mod comes with no guarantees that it will work well on all servers and configurations, and I will not be held responsible for damages, expenses or problems that may have been caused by the mod's use.


This mod is now updated and stored on GitHub. All updates and releases will be committed there, where you can download a zipped package with the latest code.

(http://i.imgur.com/DTLIV.png) (https://github.com/The-Craw/Ajax-Profile-Comments)
Title: Re: Ajax Profile Comments
Post by: OCJ on March 06, 2012, 06:58:43 PM
Installed with no errors but on viewing a members profile it failed to load the page ... with this error:

Unknown column 'comment_id' in 'field list'
File: /.../.../public_html/Sources/Profile-View.php
Line: 256


SMF 2.0.2, Simple Portal 2.3.4

Title: Re: Ajax Profile Comments
Post by: Matthew K. on March 06, 2012, 07:39:11 PM
Then make sure the install was run successfully.
Title: Re: Ajax Profile Comments
Post by: The Craw on March 06, 2012, 07:41:05 PM
Looks like the database table didn't get applied. Try uninstalling the mod and reinstalling it again.
Title: Re: Ajax Profile Comments
Post by: Matthew K. on March 06, 2012, 07:43:24 PM
Or he can just upload your db install file via FTP, and run it in his browser :)
Title: Re: Ajax Profile Comments
Post by: Jessica. on March 06, 2012, 08:57:12 PM
cool mod :) works perfectly
Title: Re: Ajax Profile Comments
Post by: The Craw on March 06, 2012, 09:03:25 PM
Thank you. ;D
Title: Re: Ajax Profile Comments
Post by: OCJ on March 06, 2012, 09:27:13 PM
After a second install it worked ...thanks.
Title: Re: Ajax Profile Comments
Post by: The Craw on March 07, 2012, 03:05:20 PM
Quote from: igirisjin on March 06, 2012, 09:27:13 PM
After a second install it worked ...thanks.

Oh good. I'm glad it works for you now. :)
Title: Re: Ajax Profile Comments
Post by: Bugo on March 08, 2012, 10:35:48 AM
Permissions on Manage Permissions area (in the Simple View mode) are the same. Error?
Title: Re: Ajax Profile Comments
Post by: The Craw on March 08, 2012, 03:00:17 PM
I probably goofed something up with this being the first time I attempted permissions. Thanks for the report, Bugo
Title: Re: Ajax Profile Comments
Post by: Matthew K. on March 08, 2012, 03:17:37 PM
It's most likely just a text-string issue...
Title: Re: Ajax Profile Comments
Post by: Bugo on March 08, 2012, 10:28:44 PM
What about hardcode text in profile_comments.js? For example:

var okay = confirm('Delete comment?');
Title: Re: Ajax Profile Comments
Post by: Matthew K. on March 08, 2012, 10:29:17 PM
There is no text-string loader for JavaScript built-in to SMF.
Title: Re: Ajax Profile Comments
Post by: The Craw on March 08, 2012, 10:42:38 PM
Quote from: Bugo on March 08, 2012, 10:28:44 PM
What about hardcode text in profile_comments.js? For example:

var okay = confirm('Delete comment?');


Good catch. I'll make sure to fix that, too. You da man, Bugo.  ::)
Title: Re: Ajax Profile Comments
Post by: Jessica. on March 16, 2012, 04:16:50 PM
when you get a comment, is there a notification? if not, there should be one...though I would like it if it's not by PM or email but instead there's a message in the top of the forum like

1 New Comments
Title: Re: Ajax Profile Comments
Post by: The Craw on March 16, 2012, 04:56:43 PM
Quote from: Jessica. on March 16, 2012, 04:16:50 PM
when you get a comment, is there a notification? if not, there should be one...though I would like it if it's not by PM or email but instead there's a message in the top of the forum like

1 New Comments

That's a good suggestion, Jessica. Shouldn't be hard to implement, so I might put that in the next release. Thanks for the feedback.
Title: Re: Ajax Profile Comments
Post by: The Craw on April 19, 2012, 12:00:02 AM
Just so everyone knows, I'm aware that when you first install the mod and go to view a profile, the comments section doesn't look... good. For some reason after installing the mod, the css file doesn't like to load right away. The solution is to leave the profile page and return to it. Or if that doens't work, try closing the browser and opening the profile page again. The problem should not return after that.
Title: Re: Ajax Profile Comments
Post by: Matthew K. on April 19, 2012, 12:01:40 AM
Love your siggy :P
Title: Re: Ajax Profile Comments
Post by: live627 on April 19, 2012, 01:06:33 AM
Quote from: The Craw on April 19, 2012, 12:00:02 AM
Just so everyone knows, I'm aware that when you first install the mod and go to view a profile, the comments section doesn't look... good. For some reason after installing the mod, the css file doesn't like to load right away. The solution is to leave the profile page and return to it. Or if that doens't work, try closing the browser and opening the profile page again. The problem should not return after that.
Why not put the extra styles in a separate file? That''ll beat the cache for sure :)
Title: Re: Ajax Profile Comments
Post by: Matthew K. on April 19, 2012, 01:12:12 AM
/me likes live627's idea.
Title: Re: Ajax Profile Comments
Post by: The Craw on April 19, 2012, 12:17:16 PM
Quote from: live627 on April 19, 2012, 01:06:33 AM
Quote from: The Craw on April 19, 2012, 12:00:02 AM
Just so everyone knows, I'm aware that when you first install the mod and go to view a profile, the comments section doesn't look... good. For some reason after installing the mod, the css file doesn't like to load right away. The solution is to leave the profile page and return to it. Or if that doens't work, try closing the browser and opening the profile page again. The problem should not return after that.
Why not put the extra styles in a separate file? That''ll beat the cache for sure :)

Might as well. Thanks for the suggestion. :D
Title: Re: Ajax Profile Comments
Post by: live627 on April 20, 2012, 04:38:30 PM
You're welcome. Always good to help out a fellow coder.
Title: Re: Ajax Profile Comments
Post by: trabacho on June 12, 2012, 11:57:03 AM
I've made an addon for this to notificate my users.

So I share it with you, to the Mod Creater I would be happy if you take it in.

Here the changes:

SQL:


ALTER TABLE `prefix_profile_comments` ADD `date` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ;



CREATE TABLE prefix_profile_visits (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`v_id` INT( 11 ) NOT NULL ,
`p_id` INT( 11 ) NOT NULL ,
`lastvisit` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE = InnoDB


Edits:

Profile-View.php:

INSERT BEFORE:


$q =$smcFunc['db_query']('', '
SELECT comment_id, comment_poster_id, comment_poster, comment_title, comment_body
FROM {db_prefix}profile_comments
WHERE comment_profile= {int:profile_id}
ORDER BY comment_id DESC
LIMIT 20',
array ('profile_id' => $memID)
);


-------------------


$q =$smcFunc['db_query']('', '
SELECT p_id
FROM {db_prefix}profile_visits
WHERE v_id= {int:visitor_id} AND p_id={int:profile_id}',
array ('visitor_id' => $user_info['id'], 'profile_id' => $memID)
);

if( $smcFunc['db_num_rows']($q) != 0 )
$smcFunc['db_query']('', '
UPDATE {db_prefix}profile_visits
SET lastvisit = CURRENT_TIMESTAMP
WHERE p_id= {int:profile_id} AND v_id= {int:visitor_id}',
array ('profile_id' => $memID, 'visitor_id' => $user_info['id'])
);
else
$smcFunc['db_insert']('insert',
            '{db_prefix}profile_visits',
            array(
                'v_id' => 'int', 'p_id' => 'int',
            ),
            array(
                $user_info['id'], $memID,
            ),
            array()
        );


Subs.php:

Replace:


function setupMenuContext()
{
global $context, $modSettings, $user_info, $txt, $scripturl;


---------------------


function setupMenuContext()
{
global $smcFunc, $context, $modSettings, $user_info, $txt, $scripturl;


:::::::::::::::::::::::::::::::

Replace:


if (!$user_info['is_guest'] && ($context['user']['unread_messages'] > 0) && isset($context['menu_buttons']['pm']))
{
$context['menu_buttons']['pm']['alttitle'] = $context['menu_buttons']['pm']['title'] . ' [' . $context['user']['unread_messages'] . ']';
$context['menu_buttons']['pm']['title'] .= ' [<strong>' . $context['user']['unread_messages'] . '</strong>]';
}


--------------------


$query =$smcFunc['db_query']('', '
SELECT lastvisit
FROM {db_prefix}profile_visits WHERE
p_id={int:visitor_id} AND v_id={int:visitor_id}',
array ('visitor_id' => $user_info['id'])
);

$lastvisited = $smcFunc['db_fetch_assoc']($query);

if($lastvisited != NULL)
$query =$smcFunc['db_query']('', '
SELECT *
FROM {db_prefix}profile_comments WHERE
comment_poster_id!={int:visitor_id} AND comment_profile={int:visitor_id} AND date > "'.$lastvisited['lastvisit'].'"',
array ('visitor_id' => $user_info['id'])
);
else
$query =$smcFunc['db_query']('', '
SELECT *
FROM {db_prefix}profile_comments WHERE
comment_poster_id!={int:visitor_id} AND comment_profile={int:visitor_id}',
array ('visitor_id' => $user_info['id'])
);

$commentscount = $smcFunc['db_num_rows']($query);

if (!$user_info['is_guest'] && ($context['user']['unread_messages'] > 0 || $commentscount > 0) && isset($context['menu_buttons']['pm']))
{
$context['menu_buttons']['pm']['alttitle'] = $context['menu_buttons']['pm']['title'] . ' [' . ($context['user']['unread_messages']+$commentscount) . ']';
$context['menu_buttons']['pm']['title'] .= ' [<strong>' . ($context['user']['unread_messages']+$commentscount) . '</strong>]';
if($context['user']['unread_messages'] != 0)
$context['menu_buttons']['pm']['sub_buttons']['pm_read']['title'] .= ' [<strong>' . $context['user']['unread_messages'] . '</strong>]';
$context['menu_buttons']['pm']['sub_buttons']['profile_read']['title'] .= ' [<strong>' . $commentscount . '</strong>]';
}


:::::::::::::::::::::::::::::::

Replace:

'pm' => array(
'title' => $txt['pm_short'],
'href' => $scripturl . '?action=pm',
'show' => $context['allow_pm'],
'sub_buttons' => array(
'pm_read' => array(
'title' => $txt['pm_menu_read'],
'href' => $scripturl . '?action=pm',
'show' => allowedTo('pm_read'),
),
'pm_send' => array(
'title' => $txt['pm_menu_send'],
'href' => $scripturl . '?action=pm;sa=send',
'show' => allowedTo('pm_send'),
'is_last' => true,
),
),
),


---------------------------


'pm' => array(
'title' => $txt['pm_short'],
'href' => $scripturl . '?action=pm',
'show' => $context['allow_pm'],
'sub_buttons' => array(
'pm_read' => array(
'title' => $txt['pm_menu_read'],
'href' => $scripturl . '?action=pm',
'show' => allowedTo('pm_read'),
),
'pm_send' => array(
'title' => $txt['pm_menu_send'],
'href' => $scripturl . '?action=pm;sa=send',
'show' => allowedTo('pm_send'),
),
'profile_read' => array(
'title' => $txt['profile_read'],
'href' => $scripturl . '?action=profile',
'show' => true,
'is_last' => true,
),
),
),


index.german.php:

Add:


$txt['profile_read'] = 'Profilkommentare';


index.english.php:

Add:


$txt['profile_read'] = 'Read your Comments';


The positive of the new profile_visits is, you can use it for a box on the Profile which is like the Who visited my Profile in vBulletin!
Title: Re: Ajax Profile Comments
Post by: Matthew K. on June 12, 2012, 12:48:24 PM
Very nice! A suggestion would be to use $smcFunc['db_insert'] rather than $smcFunc['db_query'].
Title: Re: Ajax Profile Comments
Post by: trabacho on June 12, 2012, 01:17:02 PM
Quote from: Labradoodle-360 on June 12, 2012, 12:48:24 PM
Very nice! A suggestion would be to use $smcFunc['db_insert'] rather than $smcFunc['db_query'].

Thanks, thats was my first look at the Code of SMF, I should have reviewed the docs -.-
I will edit it...
Title: Re: Ajax Profile Comments
Post by: Matthew K. on June 12, 2012, 01:58:47 PM
It was a very good job =)
Title: Re: Ajax Profile Comments
Post by: trabacho on June 12, 2012, 04:04:02 PM
One addition to mod owner, if you release an update please integrate this little change too.

ProfileComments.template.php
Replace:

<h2>', $c['poster_name'], '</h2>
<img class="comment_avatar" src="', $c['poster_avatar'], '" alt="" />


With:

<h2><a href="'.$scripturl.'?action=profile;u='.$c['poster_id'].'">', $c['poster_name'], '</a></h2>
<a href="'.$scripturl.'?action=profile;u='.$c['poster_id'].'"><img class="comment_avatar" src="', $c['poster_avatar'], '" alt="" /></a>



It's  just much more beatiful, if you can answere on the opponent Profile by just clicking his Username  or Avatar on your Profile ;)
Title: Re: Ajax Profile Comments
Post by: The Craw on June 12, 2012, 06:52:52 PM
Wow, I'm very glad to see that this mod is still attracting attention. And thank you for contributing, trabacho!
Title: Re: Ajax Profile Comments
Post by: trabacho on June 15, 2012, 12:44:32 PM
Surely it does!

Out of one simple reason. The Profile Comments are builtin in vBulletins Systems, but I don't want to use this crappy code for my Boards...
So as the Profile Comments are one part of the Community that should not be underestimated, it should attract attention! As it does make a major part of the overall ambience. So thank you for your great work The Craw
Title: Re: Ajax Profile Comments
Post by: The Craw on June 15, 2012, 02:41:26 PM
Quote from: trabacho on June 15, 2012, 12:44:32 PM
Surely it does!

Out of one simple reason. The Profile Comments are builtin in vBulletins Systems, but I don't want to use this crappy code for my Boards...
So as the Profile Comments are one part of the Community that should not be underestimated, it should attract attention! As it does make a major part of the overall ambience. So thank you for your great work The Craw

You're welcome. :) I'm glad you're getting some good use out of this mod.
Title: Re: Ajax Profile Comments
Post by: Dylert on June 20, 2012, 05:35:08 PM
I have tried to install this mod, but it will not work for me. The installation went well and I got no errors. When I go into a profile page I got this error:

Unknown column 'comment_id' in 'field list'
Fil: /customers/d/7/7/hellasforum.net/httpd.www/Sources/Profile-View.php
Line: 256

I have tried to uninstall the mod and installed it again, but I get the same error in the profile pages.
What can I do to make it work?
Title: Re: Ajax Profile Comments
Post by: live627 on June 20, 2012, 06:08:08 PM
When you uninstall it again, check the box marked 'Remove all data...' and that will clear its db tables. My guess is that you had another comment mod earlier that you dumped.
Title: Re: Ajax Profile Comments
Post by: Ashelia on June 22, 2012, 08:06:51 PM
Installed this manually (due to issues with the package manager) and it seemingly went fine, but whenever I go to profile pages I too get this error:

QuoteUnknown column 'comment_id' in 'field list'
Fil: ************/Sources/Profile-View.php
Line: 256

I did attempt to run the database_install.php via my browser, but nothing in particular seems to happen.

Any tips?
Title: Re: Ajax Profile Comments
Post by: The Craw on June 24, 2012, 03:31:20 AM
Was the database_install.php file in the root directory of your forum when you ran it? If so, did it just output a blank page?
Title: Re: Ajax Profile Comments
Post by: Matthew K. on June 24, 2012, 10:41:49 AM
There are almost positively conditions in the install file that kill the script with a die message if it's in the wrong directory and can't get SSI.php.

Try running the script again or run the query via phpMyAdmin.
Title: Re: Ajax Profile Comments
Post by: Ashelia on June 25, 2012, 11:48:55 AM
Quote from: The Craw on June 24, 2012, 03:31:20 AM
Was the database_install.php file in the root directory of your forum when you ran it? If so, did it just output a blank page?

Yep and yep!
Title: Re: Ajax Profile Comments
Post by: The Craw on June 25, 2012, 02:21:43 PM
Did you have another profile comments mod installed? It's sounding like maybe there is another table with the name "profile_comments" in your database.
Title: Re: Ajax Profile Comments
Post by: Ashelia on June 26, 2012, 10:19:20 AM
My memory is a bit fuzzy, but it is definitely possible that I've attempted to install something similar before.

How can I fix this?
Title: Re: Ajax Profile Comments
Post by: The Craw on June 26, 2012, 01:35:36 PM
You'll have to check if that table exists in your database, and if it does, drop it and run the install file again. Although you might check the contents of that table and make sure it's not important. Backing up would be smart, too. :)
Title: Re: Ajax Profile Comments
Post by: Ashelia on June 26, 2012, 06:48:00 PM
I'll report back here once that has been taken care of, thanks!
Title: Re: Ajax Profile Comments
Post by: The Craw on June 26, 2012, 07:24:14 PM
No problem. Without actually checking, I suspect what's happening here is that $smcFunc is adding an IF NOT EXISTS to my install query, so the old profile_comments table is being preserved.
Title: Re: Ajax Profile Comments
Post by: live627 on June 28, 2012, 05:45:01 PM
Good guess! But nope.

What it does is does a SHOW TABLES, looks for the table in question, and if found, do nothing. If it's sett to overwrite, drop and then create. Default is ignore.
Title: Re: Ajax Profile Comments
Post by: The Craw on June 28, 2012, 06:06:00 PM
Thanks for the info, that will come in handy. :)
Title: Re: Ajax Profile Comments
Post by: gasyoun on July 13, 2012, 03:22:12 AM
Quote from: The Craw on March 06, 2012, 02:22:44 PM
This mod uses a few icons from the LED icon (http://led24.de/iconset/) set.

I see you still use my LED icons. Would you consider FatCow's? Other set, if something is missing, I'm ready to draw it personally for you @ http://webhostingw.com/icon-window/.
Title: Re: Ajax Profile Comments
Post by: The Craw on July 13, 2012, 06:14:02 PM
Those do look nice, however I think if I do change the icons I will draw them myself to avoid outsourcing. At the moment, the mod uses a mixture of icons, some I did myself, and some LED icons.

If you're looking to change your personal mod install to use that set, I'd be willing to help you out there.  :)
Title: Re: Ajax Profile Comments
Post by: FrizzleFried on July 20, 2012, 01:00:04 PM
I install with no errors but I get this error when I attempt to visit my profile:

QuoteUnknown column 'comment_id' in 'field list'
File: /home/ahaforum/public_html/Sources/Profile-View.php
Line: 256
Title: Re: Ajax Profile Comments
Post by: FrizzleFried on July 20, 2012, 01:39:55 PM
I read the solution is to uninstall and re-install.  This did not work for me until I uninstalled FULLY (including the database info) then re-installed... now it's working.
Title: Re: Ajax Profile Comments
Post by: The Craw on July 21, 2012, 11:41:02 AM
Was there another profile comments mod installed before this one? That seems to have been the problem for a lot of people, as the database tables don't play nice with each other.
Title: Re: Ajax Profile Comments
Post by: Diego Andrés on July 21, 2012, 11:50:44 AM
Quote from: The Craw on July 21, 2012, 11:41:02 AM
Was there another profile comments mod installed before this one? That seems to have been the problem for a lot of people, as the database tables don't play nice with each other.

Maybe you can try to use another name, like profile_ajax_comments
Title: Re: Ajax Profile Comments
Post by: The Craw on July 21, 2012, 12:32:21 PM
Quote from: Diego Andrés on July 21, 2012, 11:50:44 AM
Quote from: The Craw on July 21, 2012, 11:41:02 AM
Was there another profile comments mod installed before this one? That seems to have been the problem for a lot of people, as the database tables don't play nice with each other.

Maybe you can try to use another name, like profile_ajax_comments

I could, but then my support thread would be empty, wouldn't it? Strategy, man. ;)
Title: Re: Ajax Profile Comments
Post by: FrizzleFried on July 21, 2012, 05:56:58 PM
I would guess that I did try out the Ultimate Profile mod.  I am guessing that is where the issue would be...
Title: Re: Ajax Profile Comments
Post by: The Craw on July 21, 2012, 06:34:46 PM
That is most likely the problem. I'll have to put warnings about that in the next version. Either that, or pick a unique table name as Diego Andrés suggested.
Title: Re: Ajax Profile Comments
Post by: mahmoudgamal on August 05, 2012, 09:19:24 PM
I Got Error Unknown column 'comment_id' in 'field list'
File: /home/a6497166/public_html/Sources/Profile-View.php
Line: 256

i triad to reinstall it 2 times
Title: Re: Ajax Profile Comments
Post by: The Craw on August 06, 2012, 01:50:07 AM
Quote from: mahmoudgamal on August 05, 2012, 09:19:24 PM
I Got Error Unknown column 'comment_id' in 'field list'
File: /home/a6497166/public_html/Sources/Profile-View.php
Line: 256

i triad to reinstall it 2 times

Most likely you had/have another profile comments mod installed. If it is still installed, try uninstalling that one making sure to also remove its database table by checking "Remove all data associated with this modification." If you've already uninstalled that mod and forgot to remove its database table, open phpmyadmin and run the following query in your SMF database.


DROP TABLE `smf_profile_comments`;


That is of course assuming that your db_prefix is set to "smf_"

Also, you could have saved yourself a heap of time by reading the previous pages of this topic, as this problem has come for a number of people.  ::)
Title: Re: Ajax Profile Comments
Post by: Jessica. on August 18, 2012, 09:29:29 PM
Quote from: trabacho on June 12, 2012, 11:57:03 AM
I've made an addon for this to notificate my users.

So I share it with you, to the Mod Creater I would be happy if you take it in.

Here the changes:

SQL:


ALTER TABLE `prefix_profile_comments` ADD `date` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ;



CREATE TABLE prefix_profile_visits (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`v_id` INT( 11 ) NOT NULL ,
`p_id` INT( 11 ) NOT NULL ,
`lastvisit` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE = InnoDB


Edits:

Profile-View.php:

INSERT BEFORE:


$q =$smcFunc['db_query']('', '
SELECT comment_id, comment_poster_id, comment_poster, comment_title, comment_body
FROM {db_prefix}profile_comments
WHERE comment_profile= {int:profile_id}
ORDER BY comment_id DESC
LIMIT 20',
array ('profile_id' => $memID)
);


-------------------


$q =$smcFunc['db_query']('', '
SELECT p_id
FROM {db_prefix}profile_visits
WHERE v_id= {int:visitor_id} AND p_id={int:profile_id}',
array ('visitor_id' => $user_info['id'], 'profile_id' => $memID)
);

if( $smcFunc['db_num_rows']($q) != 0 )
$smcFunc['db_query']('', '
UPDATE {db_prefix}profile_visits
SET lastvisit = CURRENT_TIMESTAMP
WHERE p_id= {int:profile_id} AND v_id= {int:visitor_id}',
array ('profile_id' => $memID, 'visitor_id' => $user_info['id'])
);
else
$smcFunc['db_insert']('insert',
            '{db_prefix}profile_visits',
            array(
                'v_id' => 'int', 'p_id' => 'int',
            ),
            array(
                $user_info['id'], $memID,
            ),
            array()
        );


Subs.php:

Replace:


function setupMenuContext()
{
global $context, $modSettings, $user_info, $txt, $scripturl;


---------------------


function setupMenuContext()
{
global $smcFunc, $context, $modSettings, $user_info, $txt, $scripturl;


:::::::::::::::::::::::::::::::

Replace:


if (!$user_info['is_guest'] && ($context['user']['unread_messages'] > 0) && isset($context['menu_buttons']['pm']))
{
$context['menu_buttons']['pm']['alttitle'] = $context['menu_buttons']['pm']['title'] . ' [' . $context['user']['unread_messages'] . ']';
$context['menu_buttons']['pm']['title'] .= ' [<strong>' . $context['user']['unread_messages'] . '</strong>]';
}


--------------------


$query =$smcFunc['db_query']('', '
SELECT lastvisit
FROM {db_prefix}profile_visits WHERE
p_id={int:visitor_id} AND v_id={int:visitor_id}',
array ('visitor_id' => $user_info['id'])
);

$lastvisited = $smcFunc['db_fetch_assoc']($query);

if($lastvisited != NULL)
$query =$smcFunc['db_query']('', '
SELECT *
FROM {db_prefix}profile_comments WHERE
comment_poster_id!={int:visitor_id} AND comment_profile={int:visitor_id} AND date > "'.$lastvisited['lastvisit'].'"',
array ('visitor_id' => $user_info['id'])
);
else
$query =$smcFunc['db_query']('', '
SELECT *
FROM {db_prefix}profile_comments WHERE
comment_poster_id!={int:visitor_id} AND comment_profile={int:visitor_id}',
array ('visitor_id' => $user_info['id'])
);

$commentscount = $smcFunc['db_num_rows']($query);

if (!$user_info['is_guest'] && ($context['user']['unread_messages'] > 0 || $commentscount > 0) && isset($context['menu_buttons']['pm']))
{
$context['menu_buttons']['pm']['alttitle'] = $context['menu_buttons']['pm']['title'] . ' [' . ($context['user']['unread_messages']+$commentscount) . ']';
$context['menu_buttons']['pm']['title'] .= ' [<strong>' . ($context['user']['unread_messages']+$commentscount) . '</strong>]';
if($context['user']['unread_messages'] != 0)
$context['menu_buttons']['pm']['sub_buttons']['pm_read']['title'] .= ' [<strong>' . $context['user']['unread_messages'] . '</strong>]';
$context['menu_buttons']['pm']['sub_buttons']['profile_read']['title'] .= ' [<strong>' . $commentscount . '</strong>]';
}


:::::::::::::::::::::::::::::::

Replace:

'pm' => array(
'title' => $txt['pm_short'],
'href' => $scripturl . '?action=pm',
'show' => $context['allow_pm'],
'sub_buttons' => array(
'pm_read' => array(
'title' => $txt['pm_menu_read'],
'href' => $scripturl . '?action=pm',
'show' => allowedTo('pm_read'),
),
'pm_send' => array(
'title' => $txt['pm_menu_send'],
'href' => $scripturl . '?action=pm;sa=send',
'show' => allowedTo('pm_send'),
'is_last' => true,
),
),
),


---------------------------


'pm' => array(
'title' => $txt['pm_short'],
'href' => $scripturl . '?action=pm',
'show' => $context['allow_pm'],
'sub_buttons' => array(
'pm_read' => array(
'title' => $txt['pm_menu_read'],
'href' => $scripturl . '?action=pm',
'show' => allowedTo('pm_read'),
),
'pm_send' => array(
'title' => $txt['pm_menu_send'],
'href' => $scripturl . '?action=pm;sa=send',
'show' => allowedTo('pm_send'),
),
'profile_read' => array(
'title' => $txt['profile_read'],
'href' => $scripturl . '?action=profile',
'show' => true,
'is_last' => true,
),
),
),


index.german.php:

Add:


$txt['profile_read'] = 'Profilkommentare';


index.english.php:

Add:


$txt['profile_read'] = 'Read your Comments';


The positive of the new profile_visits is, you can use it for a box on the Profile which is like the Who visited my Profile in vBulletin!

for some reason I don't understand your edits. for the first step, which one is the one I have to insert?
Title: Re: Ajax Profile Comments
Post by: The Craw on August 20, 2012, 01:34:20 PM
This part:


ALTER TABLE `prefix_profile_comments` ADD `date` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ;


And this part:


CREATE TABLE prefix_profile_visits (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`v_id` INT( 11 ) NOT NULL ,
`p_id` INT( 11 ) NOT NULL ,
`lastvisit` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE = InnoDB


Are both applied to your SMF database in PHPMyAdmin. You can run those in a query window.

The rest of the edits are done in SMF files and should be somewhat easy to follow.
Title: Re: Ajax Profile Comments
Post by: ocmdiaz714 on August 27, 2012, 04:13:30 AM
Quote from: The Craw on August 20, 2012, 01:34:20 PM
This part:


ALTER TABLE `prefix_profile_comments` ADD `date` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ;


And this part:


CREATE TABLE prefix_profile_visits (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`v_id` INT( 11 ) NOT NULL ,
`p_id` INT( 11 ) NOT NULL ,
`lastvisit` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE = InnoDB


Are both applied to your SMF database in PHPMyAdmin. You can run those in a query window.

The rest of the edits are done in SMF files and should be somewhat easy to follow.

How does it modify users they have new comments? Also can somebody tell me how to make the avatars bigger without ruining the template? I tried doing so manually, and messed up. If not possible to fetch the default max. avatar size I would like to have a max display of 160x160. Also can somebody tell me how to wrap the table around a border so it can look like the table above? Ex:

(http://i49.tinypic.com/nzkjyc.png)

Thanks.
Title: Re: Ajax Profile Comments
Post by: ocmdiaz714 on August 27, 2012, 04:21:17 AM
Quote from: trabacho on June 12, 2012, 11:57:03 AM
I've made an addon for this to notificate my users.

So I share it with you, to the Mod Creater I would be happy if you take it in.

Here the changes:

SQL:


ALTER TABLE `prefix_profile_comments` ADD `date` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ;



CREATE TABLE prefix_profile_visits (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`v_id` INT( 11 ) NOT NULL ,
`p_id` INT( 11 ) NOT NULL ,
`lastvisit` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE = InnoDB


Edits:

Profile-View.php:

INSERT BEFORE:


$q =$smcFunc['db_query']('', '
SELECT comment_id, comment_poster_id, comment_poster, comment_title, comment_body
FROM {db_prefix}profile_comments
WHERE comment_profile= {int:profile_id}
ORDER BY comment_id DESC
LIMIT 20',
array ('profile_id' => $memID)
);


-------------------


$q =$smcFunc['db_query']('', '
SELECT p_id
FROM {db_prefix}profile_visits
WHERE v_id= {int:visitor_id} AND p_id={int:profile_id}',
array ('visitor_id' => $user_info['id'], 'profile_id' => $memID)
);

if( $smcFunc['db_num_rows']($q) != 0 )
$smcFunc['db_query']('', '
UPDATE {db_prefix}profile_visits
SET lastvisit = CURRENT_TIMESTAMP
WHERE p_id= {int:profile_id} AND v_id= {int:visitor_id}',
array ('profile_id' => $memID, 'visitor_id' => $user_info['id'])
);
else
$smcFunc['db_insert']('insert',
            '{db_prefix}profile_visits',
            array(
                'v_id' => 'int', 'p_id' => 'int',
            ),
            array(
                $user_info['id'], $memID,
            ),
            array()
        );


Subs.php:

Replace:


function setupMenuContext()
{
global $context, $modSettings, $user_info, $txt, $scripturl;


---------------------


function setupMenuContext()
{
global $smcFunc, $context, $modSettings, $user_info, $txt, $scripturl;


:::::::::::::::::::::::::::::::

Replace:


if (!$user_info['is_guest'] && ($context['user']['unread_messages'] > 0) && isset($context['menu_buttons']['pm']))
{
$context['menu_buttons']['pm']['alttitle'] = $context['menu_buttons']['pm']['title'] . ' [' . $context['user']['unread_messages'] . ']';
$context['menu_buttons']['pm']['title'] .= ' [<strong>' . $context['user']['unread_messages'] . '</strong>]';
}


--------------------


$query =$smcFunc['db_query']('', '
SELECT lastvisit
FROM {db_prefix}profile_visits WHERE
p_id={int:visitor_id} AND v_id={int:visitor_id}',
array ('visitor_id' => $user_info['id'])
);

$lastvisited = $smcFunc['db_fetch_assoc']($query);

if($lastvisited != NULL)
$query =$smcFunc['db_query']('', '
SELECT *
FROM {db_prefix}profile_comments WHERE
comment_poster_id!={int:visitor_id} AND comment_profile={int:visitor_id} AND date > "'.$lastvisited['lastvisit'].'"',
array ('visitor_id' => $user_info['id'])
);
else
$query =$smcFunc['db_query']('', '
SELECT *
FROM {db_prefix}profile_comments WHERE
comment_poster_id!={int:visitor_id} AND comment_profile={int:visitor_id}',
array ('visitor_id' => $user_info['id'])
);

$commentscount = $smcFunc['db_num_rows']($query);

if (!$user_info['is_guest'] && ($context['user']['unread_messages'] > 0 || $commentscount > 0) && isset($context['menu_buttons']['pm']))
{
$context['menu_buttons']['pm']['alttitle'] = $context['menu_buttons']['pm']['title'] . ' [' . ($context['user']['unread_messages']+$commentscount) . ']';
$context['menu_buttons']['pm']['title'] .= ' [<strong>' . ($context['user']['unread_messages']+$commentscount) . '</strong>]';
if($context['user']['unread_messages'] != 0)
$context['menu_buttons']['pm']['sub_buttons']['pm_read']['title'] .= ' [<strong>' . $context['user']['unread_messages'] . '</strong>]';
$context['menu_buttons']['pm']['sub_buttons']['profile_read']['title'] .= ' [<strong>' . $commentscount . '</strong>]';
}


:::::::::::::::::::::::::::::::

Replace:

'pm' => array(
'title' => $txt['pm_short'],
'href' => $scripturl . '?action=pm',
'show' => $context['allow_pm'],
'sub_buttons' => array(
'pm_read' => array(
'title' => $txt['pm_menu_read'],
'href' => $scripturl . '?action=pm',
'show' => allowedTo('pm_read'),
),
'pm_send' => array(
'title' => $txt['pm_menu_send'],
'href' => $scripturl . '?action=pm;sa=send',
'show' => allowedTo('pm_send'),
'is_last' => true,
),
),
),


---------------------------


'pm' => array(
'title' => $txt['pm_short'],
'href' => $scripturl . '?action=pm',
'show' => $context['allow_pm'],
'sub_buttons' => array(
'pm_read' => array(
'title' => $txt['pm_menu_read'],
'href' => $scripturl . '?action=pm',
'show' => allowedTo('pm_read'),
),
'pm_send' => array(
'title' => $txt['pm_menu_send'],
'href' => $scripturl . '?action=pm;sa=send',
'show' => allowedTo('pm_send'),
),
'profile_read' => array(
'title' => $txt['profile_read'],
'href' => $scripturl . '?action=profile',
'show' => true,
'is_last' => true,
),
),
),


index.german.php:

Add:


$txt['profile_read'] = 'Profilkommentare';


index.english.php:

Add:


$txt['profile_read'] = 'Read your Comments';


The positive of the new profile_visits is, you can use it for a box on the Profile which is like the Who visited my Profile in vBulletin!

Could you tell me what I'm doing wrong? I get this error when I try to run the first query.

Quote#1146 - Table 'mytable.prefix_profile_comments' doesn't exist
Title: Re: Ajax Profile Comments
Post by: Rain Forest on August 29, 2012, 07:32:50 AM
Quote from: Jessica. on March 16, 2012, 04:16:50 PM
when you get a comment, is there a notification? if not, there should be one...though I would like it if it's not by PM or email but instead there's a message in the top of the forum like

1 New Comments

I agree! #2
Title: Re: Ajax Profile Comments
Post by: The Craw on September 12, 2012, 05:05:08 PM
This mod is now updated and stored on GitHub. All updates and releases will be committed there, where you can download a zipped package with the latest code.

(http://i.imgur.com/DTLIV.png) (https://github.com/The-Craw/Ajax-Profile-Comments)


The latest update automatically links the comment poster's username to their profile, allowing for faster navigation between friend's profiles.
Title: Re: Ajax Profile Comments
Post by: trabacho on September 20, 2012, 07:26:32 AM
Quote from: Jessica. on August 18, 2012, 09:29:29 PM
for some reason I don't understand your edits. for the first step, which one is the one I have to insert?

both, just execute it in console or phpmyadmin. Don't forget to replace the prefix with your table prefix!

Quote from: giovannie_1 on August 29, 2012, 07:32:50 AM
Quote from: Jessica. on March 16, 2012, 04:16:50 PM
when you get a comment, is there a notification? if not, there should be one...though I would like it if it's not by PM or email but instead there's a message in the top of the forum like

1 New Comments

I agree! #2

Look in the Addon i've posted. It does exactly, what you're looking for.

Quote from: ocmdiaz714 on August 27, 2012, 04:21:17 AM
Could you tell me what I'm doing wrong? I get this error when I try to run the first query.

Quote#1146 - Table 'mytable.prefix_profile_comments' doesn't exist

Sure I will answere this:
mytable.prefix_profile_comments

You still don't notice your failure?
Ok, change the prefix to ur used one ;)


I've looked up this post after a long time again and I'm glad to see that The Craw is working at it again.

Umm, before i forget. The Craw if some help is needed, or asks in case of security (protect against sqli lfi rfi csrf xss and so on), as I'm specialised in this you can ask me. Just pm me here, with your jabber id if you want to.


Ah before i end here, a sidekick against the developers of smf (i think i will went into a ticket for this next).
Really you should set the http only boolean always to true AS DEFAULT. Because as yet i have to modfiy it to this settings. And xss is totally dead to http only cookies, the only possibility is to attack with XST scenario. Which is just not as effective as the normal xss scenario.
Title: Re: Ajax Profile Comments
Post by: JFS on October 08, 2012, 02:14:21 PM
I'm experiencing a small bug. Comments can only be seen after posting a comment, and after a page reload the comments are again hidden.

(http://content.screencast.com/users/JakkFrosted/folders/Jing/media/ce882643-1512-40ea-8926-d6d1e57da1d4/2012-10-08_1348.png)

After posting a comment:

(http://content.screencast.com/users/JakkFrosted/folders/Jing/media/cb1f860f-0e4b-4618-a000-e5331f9b53cb/2012-10-08_1348.png)
Title: Re: Ajax Profile Comments
Post by: JFS on October 08, 2012, 04:49:29 PM
Nevermind. I fixed it.
Title: Re: Ajax Profile Comments
Post by: Jessica. on October 29, 2012, 01:33:16 PM
Quote from: The Craw on September 12, 2012, 05:05:08 PM
This mod is now updated and stored on GitHub. All updates and releases will be committed there, where you can download a zipped package with the latest code.

(http://i.imgur.com/DTLIV.png) (https://github.com/The-Craw/Ajax-Profile-Comments)

I need to update...can I just replace files to update? or what?


The latest update automatically links the comment poster's username to their profile, allowing for faster navigation between friend's profiles.
Title: Re: Ajax Profile Comments
Post by: The Craw on October 29, 2012, 09:35:42 PM
If you click the Zip button at the top left, that will download the code in SMF Mod form. Then it's just as easy as doing any other mod update. Remove the existing package and upload the updated one.
Title: Re: Ajax Profile Comments
Post by: mahmoudgamal on February 15, 2013, 04:18:53 AM
Quote from: The Craw on August 06, 2012, 01:50:07 AM
Quote from: mahmoudgamal on August 05, 2012, 09:19:24 PM
I Got Error Unknown column 'comment_id' in 'field list'
File: /home/a6497166/public_html/Sources/Profile-View.php
Line: 256

i triad to reinstall it 2 times

Most likely you had/have another profile comments mod installed. If it is still installed, try uninstalling that one making sure to also remove its database table by checking "Remove all data associated with this modification." If you've already uninstalled that mod and forgot to remove its database table, open phpmyadmin and run the following query in your SMF database.


DROP TABLE `smf_profile_comments`;


That is of course assuming that your db_prefix is set to "smf_"

Also, you could have saved yourself a heap of time by reading the previous pages of this topic, as this problem has come for a number of people.  ::)
sry for late reply i unstalled it and removed it and i opened phpmyadmin and i dont know what to do next
Title: Re: Ajax Profile Comments
Post by: The Craw on February 15, 2013, 01:26:27 PM
On the left sidebar of PHPMyAdmin, there should be a list of databases associated with your hosting account. Click the one that your forum uses to store information. If you don't know which on that is, there isn't much I can do to help you.

After selecting the forum database, find the icon at the top of the left sidebar that is titled "Query Window" and click that. A text box should pop up. Paste in the following and press "Okay" or "Continue" or whatever is says (I don't use PHPMyAdmin anymore).


DROP TABLE `smf_profile_comments`;


That should remove all data connected to previous profile comment modifications, and allow you to reinstall this one. Good luck.
Title: Re: Ajax Profile Comments
Post by: Kolya on July 27, 2013, 03:23:33 AM
Have the changes by Trabacho ever been integrated?
Title: Re: Ajax Profile Comments
Post by: Matthew K. on July 27, 2013, 10:54:15 AM
My guess is no...but The Craw could answer that better than myself obviously.
Title: Re: Ajax Profile Comments
Post by: The Craw on July 27, 2013, 01:25:23 PM
No, they haven't. I don't have plans to update this mod, and probably never will. Thanks for the interest though. :P
Title: Re: Ajax Profile Comments
Post by: NIAB on October 10, 2013, 09:24:01 PM
Anyway to make it so only the profile owner can post on their profile, and visitors could reply/comment ?
Title: Re: Ajax Profile Comments
Post by: Matthew K. on October 10, 2013, 10:33:24 PM
I do not believe that is implemented currently, it definitely would be in a future version. I am now the one maintaining this modification, as The Craw has moved on.
Title: Re: Ajax Profile Comments
Post by: DeroZ on October 21, 2013, 12:34:20 AM
nice mod, but how can i limit the nomber of comments per page and characters per each comment?
Title: Re: Ajax Profile Comments
Post by: Biology Forums on May 09, 2014, 05:03:00 PM
The graphics are a little bit outdated, but excellent modification, nonetheless.
Title: Re: Ajax Profile Comments
Post by: Matthew K. on May 27, 2014, 09:52:13 AM
Quote from: DeroZ on October 21, 2013, 12:34:20 AM
nice mod, but how can i limit the nomber of comments per page and characters per each comment?
Right now, you aren't able to. If I ever do anything with this, beyond what The Craw did, I would expand the feature set a lot.

Quote from: Liam_michael on May 09, 2014, 05:03:00 PM
The graphics are a little bit outdated, but excellent modification, nonetheless.
I agree.
Title: Re: Ajax Profile Comments
Post by: Sabre™ on September 11, 2015, 08:41:15 PM
Although you've left this community "The Craw", I would like to applaud the generous freedom you've allowed with this mod.
It is quite rare 'these days' to see someone who offers their work without attachment, without restraint.

I have only skimmed over your code, but am going to use sections of your .js in my base smf package, and thank you for the leg work, as it allows me to move steadily into other sections.
Although you never asked for it, I would be glad to leave your addition in the 'credits' section.

I found a couple of developers also implementing your code in their paid mods(didn't buy them, just took a peak under the hood), and I'm sure they're thankful for your generosity.

Cheers buddy, where ever you are :)