Additional Authors

Started by Diego Andrés, August 09, 2014, 07:36:48 PM

Previous topic - Next topic

Diego Andrés

Link to the mod

Additional Authors
If you need to report a bug, please do so on GitHub!

Ever wanted to collaborate on a first post with less privileged users? Didn't feel like giving them more permissions? Then this is the mod for you!
Additional Authors allows you to add any registered user to a first post. He/she can edit it like any other post.
Additionally, the mod displays a nice overview of mini-profiles of everyone involved in the post.

Features
- Additional mini-profiles on first post
- Easy to use interface
- Integration with the Display Additional Membergroups mod by margarett
* (if this feature is not available, the mod will still work correctly)
- Allow co-authors to edit the post

Changelog
v0.1
- Initial release

Planned features
- Switch for first/any post (currently only first post)

License:
This mod is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.

Permissions added
Yes, and disabled by default.

Files modified
- Sources/Display.php
- Sources/ManagePermissions.php
- Sources/Subs-Post.php
- Sources/Post.php
- Themes/default/Display.template.php
- Themes/default/Post.template.php
- Themes/default/css/index.css
- Themes/default/languages/Modifications.{language}.php

Tables added/modified
- {db_prefix}topics
* Column add_authors (text) will be added.

Languages available
- English
Translations are welcome!

SMF Tricks - Free & Premium Responsive Themes for SMF.

Mstcool


NanoSector

My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

Mstcool


Skaty

Nice mod. I have installed with no errors. When i tried to open a new topic it is given me this error:


NanoSector

#5
Can you attach your Post.php file in your next post please?
ETA: Nevermind, found the bug. Will push a new package out in a few minutes, please uninstall the mod in the meantime :)

ETA2: Sorry for the delay, my home server was/is making weird noises so I had to create a backup. New package is attached to the mod page.
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

Jade Elizabeth

This is really neat! Does it work with avatars? What about member colour link? :)
Once proud Documentation Writer and Help Squad Leader | Check out my new adult coloring career: Color With Jade/Patreon.

NanoSector

Thanks Jade :)

Yes it works with avatars. Might make it work with member colours in the paid version, if that's a mod.
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

Jade Elizabeth

Sweet, I am considering using it and molesting my display template. I think it would work exceptionally well on my forum :D.
Once proud Documentation Writer and Help Squad Leader | Check out my new adult coloring career: Color With Jade/Patreon.

Ninja ZX-10RR

Nice MOD NanoSector!
I would like to install it as well but it fails here in sources/post.php
Code (find) Select

t.id_first_msg, mf.subject,


Code (add after) Select

t.add_authors,


and also here in Themes/default/post.template.php

Code (find) Select

', $context['show_approval'] ? '<li><label for="approve"><input type="checkbox" name="approve" id="approve" value="2" class="input_check" ' . ($context['show_approval'] === 2 ? 'checked="checked"' : '') . ' /> ' . $txt['approve_this_post'] . '</label></li>' : '', '
</ul>
</div>';


Code (replace) Select

', $context['show_approval'] ? '<li><label for="approve"><input type="checkbox" name="approve" id="approve" value="2" class="input_check" ' . ($context['show_approval'] === 2 ? 'checked="checked"' : '') . ' /> ' . $txt['approve_this_post'] . '</label></li>' : '', '
', $context['can_add_authors'] ? '<li><label for="addAuthors">Additional authors: <input type="text" name="addAuthors" id="addAuthors" class="input_text"></input></label><div id="author_container"></div></li>' : '', '
</ul>
</div>';

// Additional authors mod - JavaScript
if ($context['can_add_authors'])
{
echo '<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?fin20"></script>
<script type="text/javascript"><!-- // -->
var oAuthorSuggest = new smc_AutoSuggest({
sSelf: \'oAuthorSuggest\',
sSessionId: \'', $context['session_id'], '\',
sSessionVar: \'', $context['session_var'], '\',
sSuggestId: \'addAuthors\',
sControlId: \'addAuthors\',
sSearchType: \'member\',
bItemList: true,
sPostName: \'add_authors\',
sURLMask: \'action=profile;u=%item_id%\',
sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '\',
sItemListContainerId: \'author_container\',
aListItems: [';

if (!empty($context['add_authors']))
foreach ($context['add_authors'] as $id_member => $member_name)
echo '
{
sItemId: ', JavaScriptEscape($id_member), ',
sItemName: ', JavaScriptEscape($member_name), '
}', $id_member == $context['add_authors'] ? '' : ',';

echo '
]
});
// ]]></script>';
}


I can't figure out how to fix those errors and it's probably due to the other 90+ mods installed, can you help me if you have some time? :)
*attached both faulty files*
Thanks in advance anyway!
Quote from: BeastMode topic=525177.msg3720020#msg3720020
It's so powerful that on this post and even in the two PMs you sent me,you still answered my question very quickly and you're apologizing for the delay. You're the #1 support I've probably ever encountered man, so much respect for that. Thank you, and get better soon.

I'll keep this in my siggy for a while just to remind me that someone appreciated what I did while others didn't.

♥ Jess ♥

STOP EDITING MY PROFILE

ryan_dwight

Thank you for this great mod.

I installed on my forum with blacknblack theme. I managed to edit the display template and it was successfully appeard on the post but how can I change the color or the background fo the additional author? It is a white box same as the default theme but I am using a black theme. Is it possible to make it same as my theme?

NanoSector

Sure, what colour would you like it to be?
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

NanoSector

Quote from: ♦ Ninja ZX-10RR ♦ on August 26, 2014, 08:46:10 PM
Nice MOD NanoSector!
I would like to install it as well but it fails here in sources/post.php
Code (find) Select

t.id_first_msg, mf.subject,


Code (add after) Select

t.add_authors,


and also here in Themes/default/post.template.php

Code (find) Select

', $context['show_approval'] ? '<li><label for="approve"><input type="checkbox" name="approve" id="approve" value="2" class="input_check" ' . ($context['show_approval'] === 2 ? 'checked="checked"' : '') . ' /> ' . $txt['approve_this_post'] . '</label></li>' : '', '
</ul>
</div>';


Code (replace) Select

', $context['show_approval'] ? '<li><label for="approve"><input type="checkbox" name="approve" id="approve" value="2" class="input_check" ' . ($context['show_approval'] === 2 ? 'checked="checked"' : '') . ' /> ' . $txt['approve_this_post'] . '</label></li>' : '', '
', $context['can_add_authors'] ? '<li><label for="addAuthors">Additional authors: <input type="text" name="addAuthors" id="addAuthors" class="input_text"></input></label><div id="author_container"></div></li>' : '', '
</ul>
</div>';

// Additional authors mod - JavaScript
if ($context['can_add_authors'])
{
echo '<script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?fin20"></script>
<script type="text/javascript"><!-- // -->
var oAuthorSuggest = new smc_AutoSuggest({
sSelf: \'oAuthorSuggest\',
sSessionId: \'', $context['session_id'], '\',
sSessionVar: \'', $context['session_var'], '\',
sSuggestId: \'addAuthors\',
sControlId: \'addAuthors\',
sSearchType: \'member\',
bItemList: true,
sPostName: \'add_authors\',
sURLMask: \'action=profile;u=%item_id%\',
sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '\',
sItemListContainerId: \'author_container\',
aListItems: [';

if (!empty($context['add_authors']))
foreach ($context['add_authors'] as $id_member => $member_name)
echo '
{
sItemId: ', JavaScriptEscape($id_member), ',
sItemName: ', JavaScriptEscape($member_name), '
}', $id_member == $context['add_authors'] ? '' : ',';

echo '
]
});
// ]]></script>';
}


I can't figure out how to fix those errors and it's probably due to the other 90+ mods installed, can you help me if you have some time? :)
*attached both faulty files*
Thanks in advance anyway!
Try the attached files. It was indeed a mod conflict.
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

ryan_dwight


Ninja ZX-10RR

Quote from: NanoSector on August 28, 2014, 10:49:57 AM
Try the attached files. It was indeed a mod conflict.
Awesome dude, it was a bit too complicated for me to solve it, it seems to be working perfectly now :D thanks a lot! I will tell you if something appears in the error log ;) thanks again!
Quote from: BeastMode topic=525177.msg3720020#msg3720020
It's so powerful that on this post and even in the two PMs you sent me,you still answered my question very quickly and you're apologizing for the delay. You're the #1 support I've probably ever encountered man, so much respect for that. Thank you, and get better soon.

I'll keep this in my siggy for a while just to remind me that someone appreciated what I did while others didn't.

♥ Jess ♥

STOP EDITING MY PROFILE

Ninja ZX-10RR

Got another problem while using "Delete spam post" mod, I don't know if it is a conflict between the 2 but I got this:
Quote
index.php?action=deletespampost;topic=86.1;msg=147
Undefined index: add_authorsApply Filter:
File: /Sources/Subs-Post.php
Line: 2563
Any clues? >_< thanks in advance, sorry for being criptic, gotta go in a minute
Quote from: BeastMode topic=525177.msg3720020#msg3720020
It's so powerful that on this post and even in the two PMs you sent me,you still answered my question very quickly and you're apologizing for the delay. You're the #1 support I've probably ever encountered man, so much respect for that. Thank you, and get better soon.

I'll keep this in my siggy for a while just to remind me that someone appreciated what I did while others didn't.

♥ Jess ♥

STOP EDITING MY PROFILE

NanoSector

Seems to be an issue in both :)
Delete spam post doesn't fill in the add_authors key in $topicOptions causing this error because my mod doesn't check it the proper way. :)
I'll fix it tomorrow but it's not high priority.
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

Ninja ZX-10RR

Yup, thanks again, no problem :D sorry for being so much annoying about it xD
Quote from: BeastMode topic=525177.msg3720020#msg3720020
It's so powerful that on this post and even in the two PMs you sent me,you still answered my question very quickly and you're apologizing for the delay. You're the #1 support I've probably ever encountered man, so much respect for that. Thank you, and get better soon.

I'll keep this in my siggy for a while just to remind me that someone appreciated what I did while others didn't.

♥ Jess ♥

STOP EDITING MY PROFILE

NanoSector

To probably fix it yourself in the meantime, change:
|| $topicOptions['add_authors'] !== null)
to
|| !empty($topicOptions['add_authors']))
in that file.
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

Ninja ZX-10RR

Indeed it worked I just tested it :D thanks a lot for the ultra-fast fix!!!
Quote from: BeastMode topic=525177.msg3720020#msg3720020
It's so powerful that on this post and even in the two PMs you sent me,you still answered my question very quickly and you're apologizing for the delay. You're the #1 support I've probably ever encountered man, so much respect for that. Thank you, and get better soon.

I'll keep this in my siggy for a while just to remind me that someone appreciated what I did while others didn't.

♥ Jess ♥

STOP EDITING MY PROFILE

Bugo

Hardcoded text (install.xml):
<label for="addAuthors">Additional authors: <input type="text" name="addAuthors" id="addAuthors" class="input_text">

NanoSector

Ups, left over from my testing. I'll fix it later.
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

Ninja ZX-10RR

Nice catch though it didn't throw any errors so nothing too bad anyway :)
Quote from: BeastMode topic=525177.msg3720020#msg3720020
It's so powerful that on this post and even in the two PMs you sent me,you still answered my question very quickly and you're apologizing for the delay. You're the #1 support I've probably ever encountered man, so much respect for that. Thank you, and get better soon.

I'll keep this in my siggy for a while just to remind me that someone appreciated what I did while others didn't.

♥ Jess ♥

STOP EDITING MY PROFILE

Zennia

Link the to GitHub doesn't work. I'm having issues with this not working. Probably a conflict with other mods. Is this still supported or is there somewhere I can go for help with this?

NanoSector

Quote from: Zennia on July 23, 2016, 02:37:42 PM
Link the to GitHub doesn't work. I'm having issues with this not working. Probably a conflict with other mods. Is this still supported or is there somewhere I can go for help with this?
Hi Zennia, I've created the repository for the mod. Please let me know what issues you are having!
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

Zennia

thank you so much! I'll go over to Github then and let you know.

Big Game

Anyway to give standard members the ability to use this also?

Sigyn

I am using 2.0.12 forum version and I was attempting to add new authors to a post and it seems to not be working any longer. I had thought to uninstall the mod but several tests failed... I went into my FTP, found the files to edit and the areas it is missing aren't able to be found even for a manual uninstall.

I don't really want to get rid it; ideally I'd like for it to work again.

Here are the failed tests; two of them when I check to see what to remove are actually blank.

Code: (Find) [Select]
m.icon, m.approved,t.add_authors,

Code: (Replace) [Select]
m.icon, m.approved,

That line cannot be found in the file, the second two are blank and the third says
Code (find):
            'locked' => $topicOptions['lock_mode'] === null ? 'locked' : (int) $topicOptions['lock_mode'],
                                'add_authors' => $topicOptions['add_authors'] === null ? 'add_authors' : ('\'' . $topicOptions['add_authors'] . '\''),

Code (replace):
            'locked' => $topicOptions['lock_mode'] === null ? 'locked' : (int) $topicOptions['lock_mode'],

In the post.template but it's not there in the file requested either. Is there anything I can do to either fix this, or remove it?

jack001

I have upgraded from smf 2.0.15 to 2.1 beta4 but whenever i am trying to post new or save draft i am getting below error.

Field 'add_authors' doesn't have a default value
File: /*..*/Sources/SplitTopics.php
Line: 646

Can someone help me with this? No mods are installed but in 2.0.15 additional authors was installed.
https://www.edufor.xyz Edutainment forum - Education with Entertainment!

GigaWatt

You should have uninstalled the mod before you did the upgrade.

And 2.1 is still in beta, it's not recommended for a production site.

That being said, if you'd still like to use 2.1 beta, you'll have to do the upgrade procedure again, but without the mod. Upload the backup before the 2.1 upgrade along with the database. Uninstall the mod and delete the mod file, then do the upgrade again.
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

Arantor

Uninstalling the mod would only be relevant if the option to remove all data was taken. As it turns out the person requesting help got help by me pointing out how to fix this without having to uninstall the mod by making the text column nullable so it wouldn't hurt anything else.

GigaWatt

Quote from: Arantor on June 27, 2018, 04:48:24 PM
Uninstalling the mod would only be relevant if the option to remove all data was taken.

I didn't know how the mod was written... I hoped it did this (as you pointed out in some of your previous posts, pointing out HelpDesk as an example of how to do things right).

In any case, glad the problem is sorted ;).
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

jack001

Quote from: Arantor on June 27, 2018, 04:48:24 PM
Uninstalling the mod would only be relevant if the option to remove all data was taken. As it turns out the person requesting help got help by me pointing out how to fix this without having to uninstall the mod by making the text column nullable so it wouldn't hurt anything else.
Thanks to @arantor his method worked.
https://www.edufor.xyz Edutainment forum - Education with Entertainment!

Advertisement: