Simple Machines Community Forum

Customizing SMF => Modifications and Packages => Topic started by: NanoSector on August 09, 2014, 07:36:48 PM

Title: Additional Authors
Post by: NanoSector on August 09, 2014, 07:36:48 PM
Link to Mod (http://custom.simplemachines.org/mods/index.php?mod=3903)

Additional Authors
If you need to report a bug, please do so on GitHub! (https://github.com/Yoshi2889/AdditionalAuthors)

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 (http://custom.simplemachines.org/mods/index.php?mod=3805) 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. (http://creativecommons.org/licenses/by-sa/3.0/)

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!
Title: Re: Additional Authors
Post by: Mstcool on August 09, 2014, 07:47:46 PM
Nice Modification!! :)
Title: Re: Additional Authors
Post by: NanoSector on August 10, 2014, 04:06:57 AM
Thank you :)
Title: Re: Additional Authors
Post by: Mstcool on August 10, 2014, 05:13:42 AM
Anytime. :)
Title: Re: Additional Authors
Post by: Skaty on August 11, 2014, 06:54:54 AM
Nice mod. I have installed with no errors. When i tried to open a new topic it is given me this error:

(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fi.imgur.com%2FtPERpKs.png&hash=43f4346377d85e9436018c354ac2bc90)
Title: Re: Additional Authors
Post by: NanoSector on August 11, 2014, 07:34:14 AM
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.
Title: Re: Additional Authors
Post by: Jade Elizabeth on August 21, 2014, 01:12:20 AM
This is really neat! Does it work with avatars? What about member colour link? :)
Title: Re: Additional Authors
Post by: NanoSector on August 21, 2014, 04:13:48 AM
Thanks Jade :)

Yes it works with avatars. Might make it work with member colours in the paid version, if that's a mod.
Title: Re: Additional Authors
Post by: Jade Elizabeth on August 21, 2014, 05:41:20 AM
Sweet, I am considering using it and molesting my display template. I think it would work exceptionally well on my forum :D.
Title: Re: Additional Authors
Post by: 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!
Title: Re: Additional Authors
Post by: ryan_dwight on August 28, 2014, 10:39:17 AM
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?
Title: Re: Additional Authors
Post by: NanoSector on August 28, 2014, 10:44:49 AM
Sure, what colour would you like it to be?
Title: Re: Additional Authors
Post by: NanoSector on August 28, 2014, 10:49:57 AM
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.
Title: Re: Additional Authors
Post by: ryan_dwight on August 28, 2014, 10:59:47 AM
Sure, what colour would you like it to be?

I am using this theme
http://custom.simplemachines.org/themes/index.php?lemma=126

I think black BG ang blue font.

Thanks
Title: Re: Additional Authors
Post by: Ninja ZX-10RR on August 28, 2014, 11:37:23 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!
Title: Re: Additional Authors
Post by: Ninja ZX-10RR on September 23, 2014, 01:27:56 PM
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
Title: Re: Additional Authors
Post by: NanoSector on September 23, 2014, 02:36:43 PM
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.
Title: Re: Additional Authors
Post by: Ninja ZX-10RR on September 23, 2014, 03:18:41 PM
Yup, thanks again, no problem :D sorry for being so much annoying about it xD
Title: Re: Additional Authors
Post by: NanoSector on September 23, 2014, 03:54:13 PM
To probably fix it yourself in the meantime, change:
Code: [Select]
|| $topicOptions['add_authors'] !== null)to
Code: [Select]
|| !empty($topicOptions['add_authors']))in that file.
Title: Re: Additional Authors
Post by: Ninja ZX-10RR on September 23, 2014, 04:14:36 PM
Indeed it worked I just tested it :D thanks a lot for the ultra-fast fix!!!
Title: Re: Additional Authors
Post by: Bugo on September 30, 2014, 06:04:58 PM
Hardcoded text (install.xml):
Code: [Select]
<label for="addAuthors">Additional authors: <input type="text" name="addAuthors" id="addAuthors" class="input_text">
Title: Re: Additional Authors
Post by: NanoSector on October 01, 2014, 06:48:39 AM
Ups, left over from my testing. I'll fix it later.
Title: Re: Additional Authors
Post by: Ninja ZX-10RR on October 01, 2014, 08:00:31 AM
Nice catch though it didn't throw any errors so nothing too bad anyway :)
Title: Re: Additional Authors
Post by: 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?
Title: Re: Additional Authors
Post by: NanoSector on July 23, 2016, 04:01:40 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!
Title: Re: Additional Authors
Post by: Zennia on July 23, 2016, 04:26:46 PM
thank you so much! I'll go over to Github then and let you know.
Title: Re: Additional Authors
Post by: Big Game on August 21, 2016, 02:28:08 AM
Anyway to give standard members the ability to use this also?
Title: Re: Additional Authors
Post by: Sigyn on December 26, 2016, 12:58:49 PM
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.
(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fimage.prntscr.com%2Fimage%2Fa100445150484656b0dd0326a3b7aa5f.png&hash=da1f1cbe72313dcb3e305f00d3fc4dec)
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?
Title: Re: Additional Authors
Post by: jack001 on June 27, 2018, 09:57:00 AM
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.
Title: Re: Additional Authors
Post by: GigaWatt on June 27, 2018, 04:46:49 PM
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.
Title: Re: Additional Authors
Post by: 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.
Title: Re: Additional Authors
Post by: GigaWatt on June 27, 2018, 04:58:10 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 ;).
Title: Re: Additional Authors
Post by: jack001 on June 27, 2018, 09:26:17 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.