PDA

View Full Version : Conversation Attachments



s0ct0j0c
21-04-2011, 07:22 PM
This add-on enables users to attach files to personal conversations. It works exactly the same as attaching files to posts.

To note:
There are no quota restrictions.
Attachments remain on the server until all members leave the conversation.
There are 2 permissions, one to upload attachments, and another to view them.

I coded this for my own forum a little while back, I do not plan on developing it much further, as it suits my needs. Nevertheless, feel free to post any suggestions/feedback.


If your templates are not modified, you may simply replace them with the versions in the TemplateEdits.zip instead of performing the edits.

Installation


Upload the contents of the upload folder to the root of your forum.
Go to your Admin CP > Install Add-on and upload the addon-conversationAttachments.xml file.
Apply the template edits that follow.
Set permissions for "View attachments" and "Add attachments" under "Personal Conversation Permissions"

Template Edits

In conversation_add:

Find:


<input type="submit" value="{xen:phrase start_conversation}" accesskey="s" class="button primary" />


Add below:



<xen:include template="attachment_upload_button" />


Find:



<input type="hidden" name="_xfToken" value="{$visitor.csrf_token_page}" />



Add above:



<xen:if is="{$attachmentParams}">
<dl class="ctrlUnit AttachedFilesUnit">
<dt><label for="ctrl_uploader">{xen:phrase attached_files}:</label></dt>
<dd><xen:include template="attachment_editor" /></dd>
</dl>
</xen:if>

In conversation_reply:

Find:


<input type="submit" value="{xen:phrase reply_to_conversation}" accesskey="s" class="button primary" />


Add below:



<xen:include template="attachment_upload_button" />



Find:



<input type="hidden" name="_xfToken" value="{$visitor.csrf_token_page}" />



Add above:



<xen:if is="{$attachmentParams}">
<dl class="ctrlUnit AttachedFilesUnit">
<dt><label for="ctrl_uploader">{xen:phrase attached_files}:</label></dt>
<dd><xen:include template="attachment_editor" /></dd>
</dl>
</xen:if>

In conversation_message_edit:

Find:



<input type="submit" value="{xen:phrase save_changes}" accesskey="s" class="button primary" />



Add below:



<xen:include template="attachment_upload_button" />


Find:



<input type="hidden" name="_xfToken" value="{$visitor.csrf_token_page}" />


Add above:





<xen:if is="{$attachmentParams}">
<dl class="ctrlUnit AttachedFilesUnit">
<dt><label for="ctrl_uploader">{xen:phrase attached_files}:</label></dt>
<dd><xen:include template="attachment_editor" /></dd>
</dl>
</xen:if>

In conversation_message:

Add at top:


<xen:require css="conversationAttachments_conversation_message.css" />


Find:



<xen:set var="$messageId">message-{$message.message_id}</xen:set>


Add below:



<xen:set var="$messageContentAfterTemplate"><xen:if is="{$message.attachments}"><xen:include template="attached_files"><xen:map from="$message" to="$post" /></xen:include></xen:if></xen:set>


Uninstallation
Please note all attachments will be unassociated upon uninstallation, and will subsequently be deleted.


Revert all your template edits.
Go to your Admin CP > Manage Add-ons > Conversation Attachments > Controls > Uninstall
Remove the ConversationAttachments folder from the /library directory of your XenForo installation.