[OzzModz] Start Conversations With Yourself

[OzzModz] Start Conversations With Yourself 1.0.1

No permission to download

ozzy47

Well-known member
ozzy47 submitted a new resource:

[OzzModz] Start Conversations With Yourself - Users can start conversatios with themselves

Another addon brought to you by:
View attachment 203225

This simple addon will allow users with the proper permission to start conversations with themselves.

Many times you or your users may find the need to leave themselves a note or a reminder about something. XenoForo does not allow someone to start a conversation with themselves, it is seen as having no recipients. Oddly enough though, if you are in a conversation with a user, and they leave the conversation, you...
Read more about this resource...
 
Last edited:

kick

Active member
Outstanding add-ons! And it's don't work:
1563191734428.png
And it seems that a plugin from the extension of one function consists, but for some reason a dog turned out in the hay.
Received the result of the parent function:
$parent = parent::setRecipients($recipients, $checkPrivacy = true, $triggerErrors = true);
Everything is good, but the trouble is - if the user has a recipents, you will no longer return the result of the parent function. It would seem a trifle, but if some addition will expand the same function, the addition will simply overlook those changes and will dictate their conditions. So to do with the unlimited extensibility of the engine is at least incorrect.
And of course, the code is just something...
PHP:
<?php

namespace OzzModz\SelfConversations\XF\Service\Conversation;

class Creator extends XFCP_Creator
{
    public function setRecipients($recipients, $checkPrivacy = true, $triggerErrors = true)
    {
          // Set the parent
          $parent = parent::setRecipients($recipients, $checkPrivacy = true, $triggerErrors = true);
          // Get options
        $options = \XF::options();
          // Get visitor
        $visitor = \XF::visitor();
        //Get starter
        $starter = $this->starter;
    
          //No recipents and user has permission, if not they get sent back to the parent
          if ($recipients == '' && $visitor->hasPermission('selfConversations', 'use'))
        {
            $this->recipients = [$starter->user_id => $starter];
            return;
        }
        // We are done, send them to the parent
          return $parent;
    }
}
Allocated memory for variables and use them once. This is bad practice for the sake of one time to allocate memory.
Okay, past additions were from modifications, but when it came to something more serious with the expansion of something, then we get not only a useless addition, but also a harmful one. In addition to all this, the code is not formatted.
Template modification....
Code:
<?xml version="1.0" encoding="utf-8"?>
<template_modifications>
  <modification type="public" template="conversation_add" modification_key="selfconversation_checkbox" execution_order="10" enabled="1" action="str_replace">
    <find><![CDATA[            <xf:tokeninputrow name="recipients" value="{$to}" href="{{ link('members/find') }}"
                rowtype="fullWidth"
                label="{{ phrase('recipients') }}"
                explain="{{ phrase('separate_names_with_comma') }}" />]]></find>
    <replace><![CDATA[        <xf:if is="{{ $xf.visitor.hasPermission('selfConversations', 'use') }}">
            <xf:checkboxrow label="{{ phrase('selfconversations_label') }}" standalone="true">
                <xf:option type="checkbox" id="chkselfConversations" onclick="ShowHideDiv(this)" hint="{{ phrase('selfconversations_hint') }}">{{ phrase('selfconversations_text') }}</xf:option>
            </xf:checkboxrow>
          
            <div id="recipients" style="display: block">
                <xf:tokeninputrow name="recipients" style="display:none" value="{$to}" href="{{ link('members/find') }}"
                    rowtype="fullWidth"
                    label="{{ phrase('recipients') }}"
                    explain="{{ phrase('separate_names_with_comma') }}" />
            </div>
          
            <script type="text/javascript">
                 function ShowHideDiv(chkselfConversations) {
                    var recipients = document.getElementById("recipients");
                    recipients.style.display = chkselfConversations.checked ? "none" : "block";
                }
            </script>         
        <xf:else />
            <xf:tokeninputrow name="recipients" value="{$to}" href="{{ link('members/find') }}"
                rowtype="fullWidth"
                label="{{ phrase('recipients') }}"
                explain="{{ phrase('separate_names_with_comma') }}" />
        </xf:if>]]></replace>
  </modification>
  <modification type="public" template="conversation_add" modification_key="selfconversation_script" execution_order="10" enabled="0" action="str_replace">
    <find><![CDATA[<xf:title>{{ phrase('start_conversation') }}</xf:title>]]></find>
    <replace><![CDATA[$0

<script type="text/javascript">
     function ShowHideDiv(chkPassport) {
        var dvPassport = document.getElementById("dvPassport");
        dvPassport.style.display = chkPassport.checked ? "none" : "block";
    }
</script> 
]]></replace>
  </modification>
</template_modifications>
This is bad practices. So also the use of the inline style, where everything should be divided and in which case your javascript should be picked up
 
Top