Simple Machines Community Forum

Customizing SMF => Modifications and Packages => Topic started by: emanuele on August 23, 2011, 09:39:17 PM

Title: Sticky any post
Post by: emanuele on August 23, 2011, 09:39:17 PM
Link to Mod (http://custom.simplemachines.org/mods/index.php?mod=3110)

When installed a new option is provided that allows setting any post of any topic (also non-sticky) as "sticky".

Once set sticky the message will be shown as the first of the topic and it will be repeated on all the pages of the topic.

A user must have the Make topics sticky permission in order to be able to use this function.

The option can be turned on and off through the admin panel in Forum > Posts and Topics > Topic Settings

Available also at https://github.com/emanuele45/Sticky-any-post

To do list:

Change log
Title: Re: Sticky any post
Post by: _Newbie_ on August 23, 2011, 10:05:09 PM
Nice job...

I'll use this for sure, thanks!
Title: Re: Sticky any post problem
Post by: Hank Scott on September 03, 2011, 06:43:36 PM
I installed this mod as directed (under SMF 2.0 running the default theme Curve), but when attempting to modify a post (to set it as sticky) I get the following error:

Database Error: Operand should contain 1 column(s)
File: /home/.../public_html/forum/Sources/Post.php
Line: 149

I have no idea what is causing this, but I checked all the files to be sure all changes were made correctly.

This problem stopped once I reinstalled the original files.

Also, there were no instructions on where to install or how to run or use installScript_SMF2.php and installHooks.php files, so I put them in the folder where the forum in installed and tried to run them from my browser, which resulted in a black page for each attempt.

Please advise how to install properly.

Thanks,

Hank
Title: Re: Sticky any post
Post by: emanuele on September 04, 2011, 05:51:56 AM
Quote from: Hank Scott on September 03, 2011, 06:43:36 PM
I installed this mod as directed (under SMF 2.0 running the default theme Curve), but when attempting to modify a post (to set it as sticky) I get the following error:

Database Error: Operand should contain 1 column(s)
File: /home/.../public_html/forum/Sources/Post.php
Line: 149

I have no idea what is causing this, but I checked all the files to be sure all changes were made correctly.

This problem stopped once I reinstalled the original files.
So now you have the mod installed or not?
Not exactly sure what can cause this error... :-[

Quote from: Hank Scott on September 03, 2011, 06:43:36 PM
Also, there were no instructions on where to install or how to run or use installScript_SMF2.php and installHooks.php files, so I put them in the folder where the forum in installed and tried to run them from my browser, which resulted in a black page for each attempt.

Please advise how to install properly.
Thanks for the suggestion, I'll put something. ;)
Title: Re: Sticky any post
Post by: andershz on September 26, 2011, 03:08:26 PM
When a post is made sticky it will show both first on every page and in the place where it would normally show. 
This has the side effect that if the first post of any page is made sticky it will appear duplicated.
Maybe it would be better to suppress the additional appearance if the post is first on the page anyway.
Title: Re: Sticky any post
Post by: emanuele on September 26, 2011, 03:55:59 PM
Yep, this is a weak point... I would first give a different aspect and better separate the sticked post from all the others.
Title: Re: Sticky any post
Post by: vkbr on October 01, 2011, 01:41:40 AM
changing background color perhaps...
Title: Re: Sticky any post
Post by: emanuele on October 01, 2011, 08:34:11 AM
Yep, definitely is one of the things to do. :)
Title: Re: Sticky any post
Post by: Apostaganha on October 25, 2011, 01:41:44 PM
When you stick the 1ยบ post of a topic the second post disappears!
Title: Re: Sticky any post
Post by: emanuele on October 27, 2011, 09:03:14 AM
Thank you for the report and sorry for the late reply!

Fixed

But more I look at this mod less I like it. I've to rewrite it...it will take a while...a long while (computer problems ::)).
Title: Re: Sticky any post
Post by: Apostaganha on October 27, 2011, 09:48:45 AM
Quote from: emanuele on October 27, 2011, 09:03:14 AM
Thank you for the report and sorry for the late reply!

Fixed

But more I look at this mod less I like it. I've to rewrite it...it will take a while...a long while (computer problems ::)).

Ant it messes with the links for the last post of each topic :s
Title: Re: Sticky any post
Post by: emanuele on October 27, 2011, 09:54:12 AM
How?
Title: Re: Sticky any post
Post by: chinaren on October 29, 2011, 08:21:31 AM
This seems to work fine for me as an Admin, but doesn't show up for other users. 


Am I doing anything wrong? 
Title: Re: Sticky any post
Post by: emanuele on October 30, 2011, 10:19:29 AM
Do you mean the possibility to "stick" a post?
It relies on the "make_sticky" permission (Make topics sticky), so AFAIR normally only moderators should have it.

Quote from: Apostaganha on October 27, 2011, 09:48:45 AM
Quote from: emanuele on October 27, 2011, 09:03:14 AM
Thank you for the report and sorry for the late reply!

Fixed

But more I look at this mod less I like it. I've to rewrite it...it will take a while...a long while (computer problems ::)).

Ant it messes with the links for the last post of each topic :s
Finally I got it, sorry.
Not it should be fixed.
Title: Re: Sticky any post
Post by: chinaren on October 30, 2011, 06:35:13 PM
Quote from: emanuele on October 30, 2011, 10:19:29 AM
Do you mean the possibility to "stick" a post?
It relies on the "make_sticky" permission (Make topics sticky), so AFAIR normally only moderators should have it.


Oh, that's a bummer.  Any chance of adding a permission that allows other groups to do this?


Also I have the bug that if you sticky the first post it repeats the first post on the second post, essentially overwriting the second post, though if you un-sticky the first post the second post reverts back to what it was.

Title: Re: Sticky any post
Post by: emanuele on November 01, 2011, 09:22:03 AM
Quote from: chinaren on October 30, 2011, 06:35:13 PM
Oh, that's a bummer.  Any chance of adding a permission that allows other groups to do this?
I'm not particularly keen on adding another permission just for this.

It can be added quite easily (I forgot to remove the hook that I added a while ago, so it's even easier). Oh well... look at this one (https://github.com/emanuele45/Sticky-any-post/downloads).

If you want you can:
1) add the following code to Subs-StickyMessage.php
function stickymessage_add_permissions(&$permissionGroups, &$permissionList, &$leftPermissionGroups, &$hiddenPermissions, &$relabelPermissions){
global $context;

$context['non_guest_permissions'][] = 'make_post_sticky';
$permissionList['board']['make_post_sticky'] = array(false, 'topic', 'moderate');
}


2) in modification_SMF2.xml replace almost all the:
allowedTo('make_sticky')
with
allowedTo('make_post_sticky')

the only exception is:
<operation><!-- 7 -->
<search position="after"><![CDATA[
if (isset($_POST['sticky']) && (empty($modSettings['enableStickyTopics']) || empty($_POST['sticky']) || !allowedTo('make_sticky')))]]></search>
<add><![CDATA[
if (isset($_POST['sticky_message']) && (empty($modSettings['enable_sticky_message']) || empty($_POST['sticky_message']) || !allowedTo('make_sticky')))
unset($_POST['sticky_message']);
]]></add>
</operation>


that must become:
<operation><!-- 7 -->
<search position="after"><![CDATA[
if (isset($_POST['sticky']) && (empty($modSettings['enableStickyTopics']) || empty($_POST['sticky']) || !allowedTo('make_sticky')))]]></search>
<add><![CDATA[
if (isset($_POST['sticky_message']) && (empty($modSettings['enable_sticky_message']) || empty($_POST['sticky_message']) || !allowedTo('make_post_sticky')))
unset($_POST['sticky_message']);
]]></add>
</operation>


3) to lang.xml and lang-UTF8.xml add:
$txt['permissionname_make_post_sticky'] = 'Make posts sticky';


Quote from: chinaren on October 30, 2011, 06:35:13 PM
Also I have the bug that if you sticky the first post it repeats the first post on the second post, essentially overwriting the second post, though if you un-sticky the first post the second post reverts back to what it was.
This is fixed (see here (http://www.simplemachines.org/community/index.php?topic=449935.msg3195369#msg3195369)), just uninstall the version you are using, download the last one and re-install it. ;)
Title: Re: Sticky any post
Post by: chinaren on November 02, 2011, 05:50:27 AM
Thanks for all that Em!


My forum is being worked on atm, but I'll do all the above as soon as the other stuff is done. :)
Title: Re: Sticky any post
Post by: emanuele on November 02, 2011, 07:18:08 PM
Quote from: emanuele on November 01, 2011, 09:22:03 AM
It can be added quite easily (I forgot to remove the hook that I added a while ago, so it's even easier). Oh well... look at this one (https://github.com/emanuele45/Sticky-any-post/downloads).
Quoting because it was partially hidden in the middle of a lot of changes, so I don't know if you have seen it or not. ;)
Title: Re: Sticky any post
Post by: Geor'G on November 24, 2011, 10:24:24 AM
1. If disabled:
(http://www.simplemachines.org/community/index.php?action=dlattach;topic=449935.0;attach=191201)

Then the message disappears:
(http://www.simplemachines.org/community/index.php?action=dlattach;topic=449935.0;attach=191203)

2. Variable is not used. Probably forgot about it.
$txt['sticky_message_disabled'] = 'Sorry, the sticky topic function is disabled';

---------------------------------
Sorry for my english
Title: Re: Sticky any post
Post by: emanuele on November 24, 2011, 05:28:35 PM
I have a pretty messy test forum at the moment, but I can't replicate the issue...I'll try again with a clean install tomorrow.
Are you using the latest version of the mod?
Title: Re: Sticky any post
Post by: Geor'G on November 25, 2011, 04:39:10 AM
Quote from: emanuele on November 24, 2011, 05:28:35 PM
Are you using the latest version of the mod?
Yes, downloaded from here - http://custom.simplemachines.org/mods/index.php?mod=3110 and https://github.com/emanuele45/Sticky-any-post/downloads

The problem is not only to me, more on the Russian Forum SMF - http://www.simplemachines.ru/index.php?topic=13779.0
Title: Re: Sticky any post
Post by: emanuele on November 25, 2011, 11:46:18 AM
Ok, got it.

I'll update the package as soon as possible, if you don't want to upgrade the package, the fix is: in Display.php search:
Code (search) Select
} elseif (!empty($context['id_message_list'])) {

and replace it with:
Code (replace with) Select
} elseif (!empty($context['id_message_list']) || empty($modSettings['enable_sticky_message'])) {

Package updated.

And thank you for the report! :D
Title: Re: Sticky any post
Post by: Geor'G on November 25, 2011, 03:06:02 PM
Thank you for mod :)
Title: Re: Sticky any post
Post by: Sapozhnik on November 27, 2011, 10:56:57 AM
Hi Emanuele,

1. Thanks for the mod
2. Lang-files with russian are attached
3. If topic contains some pages and you stick the first message on the last page, this message will be displayed (duplicated) at the end of topic. Please check.
Example: fomenko.kiev.ua/forum/index.php?topic=2.30
Look on the time of first and last messages on the third page.
Title: Re: Sticky any post
Post by: emanuele on November 28, 2011, 08:04:03 AM
Hi Sapozhnik,

I though I fixed this problem a while ago, but it seems I didn't... :-\
I'll check as soon as possible.

Thanks for the Russian translation! ;D
Title: Re: Sticky any post
Post by: BlackMato on December 05, 2011, 01:55:51 AM
Hi emanuele,

what is the name and the path of the sticky icon?  I installed your mod and it works great but the icon near sticky/not sticky command not appear. I'm using a custom theme.

Thanks
Title: Re: Sticky any post
Post by: emanuele on December 05, 2011, 04:29:14 PM
It's /images/icons/quick_sticky.gif :)
Title: Re: Sticky any post
Post by: Geor'G on January 24, 2012, 02:36:37 AM
When you install the mod, the "notifications" (notifications by email) function stops working.
Title: Re: Sticky any post
Post by: blamed on February 18, 2012, 11:17:08 AM
Quote from: Geor'G on January 24, 2012, 02:36:37 AM
When you install the mod, the "notifications" (notifications by email) function stops working.
Confirm.
Also "new" button stop working correctly.
In smf 2.0.2 atleast.
Title: Re: Sticky any post
Post by: emanuele on February 18, 2012, 03:16:34 PM
Easy solution: the mod is removed.
Sorry but at the moment I don't have time to check it... :(