OneSignal webpush 1.0.1 Плагин отправки сообщений для vb4.2

Нашел плагин для vBulletin 4.2 OneSignal_webpush_1.0.1, а у меня стоит версия 3.8.7 и PHP 5.4 облазив весь интернет, так ничего и не нашел. Вообщем изменив в коде версию, мне удалось залить плагин без ошибок. В настройках прописал ключи, но в итоги ничего не работает. Обновляться до 4.2 версии форума нет возможности. Вопрос в следующем: может кто знает, где исправить модуль, что бы тот заработал под мою версию? Вот код модуля: '''

<?xml version="1.0" encoding="ISO-8859-1"?>

<product productid="onesignal_notifications" active="1">
    <title>Web Push notifications using OneSignal</title>
    <description>Send web push notifications to your members using OneSignal</description>
    <version>1.0.1</version>
    <url />
    <versioncheckurl />
    <dependencies>
        <dependency dependencytype="vbulletin" minversion="4.2.0" maxversion="" />
    </dependencies>
    <codes>
    </codes>
    <templates>
    </templates>
    <stylevardfns>
    </stylevardfns>
    <stylevars>
    </stylevars>
    <plugins>
        <plugin active="1" executionorder="5">
            <title>DBTECH likes notification</title>
            <hookname>dbtech_thanks_postsave</hookname>
            <phpcode><![CDATA[if(isset($vbulletin->products['dbtech_thanks']) && $vbulletin->products['dbtech_thanks']
    && isset($vbulletin->options['dbtech_thanks_features']) && $vbulletin->options['dbtech_thanks_features'] && class_exists('THANKS')
    && isset($vbulletin->options['dbtech_thanks_notifications']) && $vbulletin->options['dbtech_thanks_notifications'] == 1
    )
    {
        include_once(DIR . '/includes/functions_OneSignal.php'); 

        $alertUserId[0] = $post['userid'];
        $fromUID = ''; 
        $fromUname = $vbulletin->userinfo['username']; 
        $contentType = 'post'; 
        $contentId = $post['postid']; 
        $action = 'like';         
        $extraData = array('title' => $threadinfo['title'], 'appid' => $vbulletin->options['iA1_onesignal_notif_appid'], 'authkey' => $vbulletin->options['iA1_onesignal_notif_authkey']);  

        $ret = sendAlert($alertUserId, $fromUID, $fromUname, $contentType, $contentId, $action, $extraData); 

    }]]></phpcode>
        </plugin>
        <plugin active="1" executionorder="5">
            <title>Send newpost notification</title>
            <hookname>newpost_complete</hookname>
            <phpcode><![CDATA[$alertUserIds = $vbulletin->db->query_read('SELECT userid from ' . TABLE_PREFIX . 'subscribethread WHERE threadid = '.$threadinfo['threadid'] . ' AND canview = 1');

    $uid = 0;
    while ($alertUId = $vbulletin->db->fetch_array($alertUserIds)) {
        if ($alertUId['userid'] != $vbulletin->userinfo['userid']) {
            $alertUserId[$uid++] = $alertUId['userid'];
        }
    }

    if ($uid > 0) {
        include_once(DIR . '/includes/functions_OneSignal.php');

        $fromUID = '';
        $fromUname = $vbulletin->userinfo['username'];
        $contentType = 'post';
        $contentId = $post['postid'];
        $action = 'insert';
        $msg = substr(strip_bbcode($post['message'], true, true), 0, 250);
        $extraData = array('title' => $threadinfo['title'], 'message' => $msg, 'appid' => $vbulletin->options['iA1_onesignal_notif_appid'], 'authkey' => $vbulletin->options['iA1_onesignal_notif_authkey']); 

        $ret = sendAlert($alertUserId, $fromUID, $fromUname, $contentType, $contentId, $action, $extraData);
    }]]></phpcode>
        </plugin>
        <plugin active="1" executionorder="5">
            <title>Add script to header</title>
            <hookname>parse_templates</hookname>
            <phpcode><![CDATA[if ( ($vbulletin->userinfo[userid]) AND (THIS_SCRIPT != 'login')) {
$pushscript = '
    <link rel="manifest" href="/manifest.json" />
    <script src="https://cdn.onesignal.com/sdks/OneSignalSDK.js" async></script>
    <script>

  var OneSignal = window.OneSignal || [];
  OneSignal.push(function() {
    OneSignal.init({
      appId: "'. $vbulletin->options['iA1_onesignal_notif_appid'] .'",
      autoRegister: false,
    });
  });

OneSignal.push(function() {               
  OneSignal.sendTags({
    uid: "'. $vbulletin->userinfo[userid] .'",
    uname: "'. $vbulletin->userinfo[username] .'",
  });
});
</script>
';
$template_hook['headinclude_javascript'] .= $pushscript;
}

if ($vbulletin->options['copyrighttext']) 
    $vbulletin->options['copyrighttext'] .= ' <a title="Web Push Notifications" href="https://vbulletin.org/forum/showthread.php?t=326558">Web Push Notifications</a> by iA1.'; 
else 
    $vbulletin->options['copyrighttext'] = ' <a title="Web Push Notifications" href="https://vbulletin.org/forum/showthread.php?t=326558">Web Push Notifications</a> by iA1.';]]></phpcode>
        </plugin>
        <plugin active="1" executionorder="5">
            <title>Send PM notification</title>
            <hookname>pmdata_postsave</hookname>
            <phpcode><![CDATA[$uid = 0;
    foreach ($this->info['recipients'] AS $alertUId) {
        if ($alertUId['userid'] != $vbulletin->userinfo['userid']) { 
            $alertUserId[$uid++] = $alertUId['userid']; 
        } 
    } 
    
    if ($uid > 0) {
        include_once(DIR . '/includes/functions_OneSignal.php');  
        $fromUID = ''; 
        $fromUname = $fromusername; 
        $contentType = 'pm'; 
        $contentId = $post['postid']; 
        $action = 'insert'; 
        // $msg = substr(strip_bbcode(strip_quotes($this->fetch_field('message')), true, true), 0, 250); 
        $msg = "View Message";

        $extraData = array('title' => $plaintext_title, 'message' => $msg, 'appid' => $vbulletin->options['iA1_onesignal_notif_appid'], 'authkey' => $vbulletin->options['iA1_onesignal_notif_authkey']); 

        $ret = sendAlert($alertUserId, $fromUID, $fromUname, $contentType, $contentId, $action, $extraData); 
    }]]></phpcode>
        </plugin>
    </plugins>
    <phrases>
        <phrasetype name="vBulletin Settings" fieldname="vbsettings">
            <phrase name="setting_iA1_onesignal_notif_active_desc" date="1404068994" username="iA1" version="1.0.0"><![CDATA[Set this to "Yes" to enable the product.]]></phrase>
            <phrase name="setting_iA1_onesignal_notif_active_title" date="1404068994" username="iA1" version="1.0.0"><![CDATA[Product Is Active]]></phrase>
            <phrase name="setting_iA1_onesignal_notif_appid_desc" date="1404049979" username="iA1" version="1.0.0"><![CDATA[Enter the App ID from OneSignal]]></phrase>
            <phrase name="setting_iA1_onesignal_notif_appid_title" date="1404049979" username="iA1" version="1.0.0"><![CDATA[OneSignal AppID]]></phrase>
            <phrase name="setting_iA1_onesignal_notif_authkey_desc" date="1404050022" username="iA1" version="1.0.0"><![CDATA[Enter the authentication key from OneSignal]]></phrase>
            <phrase name="setting_iA1_onesignal_notif_authkey_title" date="1404050022" username="iA1" version="1.0.0"><![CDATA[Authentication Key]]></phrase>
            <phrase name="settinggroup_iA1_onesignal_notif_settings" date="1404049827" username="iA1" version="1.0.0"><![CDATA[Web and Push Notifications using OneSignal]]></phrase>
        </phrasetype>
    </phrases>
    <options>
        <settinggroup name="iA1_onesignal_notif_settings" displayorder="65535">
            <setting varname="iA1_onesignal_notif_active" displayorder="10">
                <datatype>boolean</datatype>
                <optioncode>yesno</optioncode>
                <defaultvalue>0</defaultvalue>
            </setting>
            <setting varname="iA1_onesignal_notif_appid" displayorder="20">
                <datatype>free</datatype>
            </setting>
            <setting varname="iA1_onesignal_notif_authkey" displayorder="30">
                <datatype>free</datatype>
            </setting>
        </settinggroup>
    </options>
    <helptopics>
    </helptopics>
    <cronentries>
    </cronentries>
    <faqentries>
    </faqentries>
    <navigation>
    </navigation>
</product>

'''

А если у кого есть такой,рабочий, можете поделиться? [email protected]


Ответы (0 шт):