Friends 1.x

Legacy documentation for Friends 1.x.

The Friends:Message_Move function is part of the Private Messaging system and allows your users to move messages from one folder to another. This can be done individually or with multiples at a time.

{exp:friends:message_move} content {/exp:friends:message_move}

Parameters

The following parameters are available for use:

dynamic=

dynamic="off"

This parameter is available to stop the loop from looking into the URI for a message ID.

message_id=

message_id="{segment_3}"

The Friends:Message_Move loop automatically grabs the message ID from the URI, but this parameter is available to use, should you be doing something crazy.

Variables

The following variables are available for use:

friends_message

{friends_message}

This variable will output the success message or any errors upon loading the Friends:Message_Move template.

Conditionals

The following conditionals are available for use:

failure

{if failure}
    Error!
{/if}

This conditional shows its contents if the requested action DOES NOT execute successfully.

success

{if success}
    Successful!
{/if}

This conditional shows its contents if the requested action executes successfully.

Form Fields

The following form fields are available for use:

ajax

<input type="hidden" name="ajax" value="yes" />

This form field tells the method to behave nicely with AJAX calls.

csrf_token

<input type="hidden" name="csrf_token" value="{csrf_token}" />

As of EE 2.7+, this field is required when constructing forms that aren't created using {exp:friends:...} tags. EE 2.7.x uses {XID_HASH} (and name="XID"), and EE 2.8.x and above uses {csrf_token}.

friends_message_id[]

<input type="checkbox" name="friends_message_id[]" value="{friends_message_id}" />

This form field allows you to have multiple check boxes within a list of messages so a user can select multiple messages and move them.

Examples

The following code should be a complete example for using this function:

{exp:friends:message_move}

    {if success}
        <h3>Successful!</h3>
    {/if}
    {if failure}
        <h3>Error!</h3>
    {/if}

<p>{friends_message}</p>

{/exp:friends:message_move}

Setup

Multiple Select from Folder View

To implement this feature into a multi-select feature in your Folder-view list of messages page, your code would look like this:

<form method="post" action="{path='friends/message_move'}">

<input type="hidden" name="csrf_token" value="{csrf_token}">

<ul>
{exp:friends:messages
    message_folder="inbox"
}
    <li>
        <input type="checkbox" name="friends_message_id[]" value="{friends_message_id}" />

        <a href="{path='friends/message_view'}/{friends_message_id}">
            {friends_message_subject}
        </a>
        from
        {friends_message_sender}
            {friends_message_sender_screen_name}
        {/friends_message_sender}
        on
        {friends_message_date format="%F %j, %Y at %g:%i %a"}
        {if friends_message_read == "y"}
            (read on {friends_message_time_read format="%F %j, %Y"})
        {if:else}
            (unread)
        {/if}
    </li>

    {if friends_no_results}
        <li>You currently have no messages for this folder.</li>
    {/if}
{/exp:friends:messages}
</ul>

<p>
    Move Selected Messages to
    <select name="friends_message_folder_id">
    {friends_message_folders}
        <option value="{friends_message_folder_id}">{friends_message_folder}</option>
    {/friends_message_folders}
    </select>
    <input type="submit" name="submit" value="Move" />
</p>

</form>

Single Message View

To implement this feature into a template for viewing a single message, your code would look like this:

<form method="post" action="{path='friends/message_move'}/{segment_3}/">

    <input type="hidden" name="csrf_token" value="{csrf_token}">

    Move Messages to
    <select name="friends_message_folder_id">
    {friends_message_folders}
        <option value="{friends_message_folder_id}">{friends_message_folder}</option>
    {/friends_message_folders}
    </select>
    <input type="submit" name="submit" value="Move" />

</form>