MyBB Community Forums

Full Version: DVZ Mentions 1.0.6
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
(2016-03-13, 08:57 AM).m. Wrote: [ -> ]^ have you checked error log at web host panel ?

The server does not have a cPanel, but I looked at the error log file in /var/log/apache2/.

Here is the PHP error.

[Sun Mar 13 09:00:20.211124 2016] [:error] [pid 23811] [client *****] PHP Fatal error:  Class 'DVZMentions_Alerts' not found in /usr/share/mediawiki/forum/inc/plugins/dvz_mentions/alerts.php on line 6, referer: ******

[Sun Mar 13 09:00:48.078883 2016] [:error] [pid 23697] [client *****] PHP Fatal error:  Class 'DVZMentions_Alerts' not found in /usr/share/mediawiki/forum/inc/plugins/dvz_mentions/alerts.php on line 6, referer: ******

Here is the beginning portion of the alerts.php file.

<?php
/* by Tomasz 'Devilshakerz' Mlynski [devilshakerz.com]; Copyright (C) 2014-2015
 released under Creative Commons BY-NC-SA 4.0 license: http://creativecommons.org/licenses/by-nc-sa/4.0/ */

// skip if MyAlerts is not installed or its version is not within the 2.0 branch
if (!DVZMentions_Alerts::myalerts_integrable()) return;

DVZMentions_Alerts::myalerts_init();

// default locations
include MYBB_ROOT . 'inc/plugins/dvz_mentions/alerts.posts.php';

// core hooks
$plugins->add_hook('global_start', ['DVZMentions_Alerts', 'myalerts_register_formatters']);
$plugins->add_hook('admin_config_plugins_begin', ['DVZMentions_Alerts', 'admin_plugins']);

class DVZMentions_Alerts extends DVZMentions
{

This is the default alerts.php file so it isn't a result of my tampering. What do I do to define the class specifically on line 6? Where is line 6? Comments and the beginning portion don't count towards the lines, right?

Would that make this line 6?

$plugins->add_hook('admin_config_plugins_begin', ['DVZMentions_Alerts', 'admin_plugins']);
Try moving
// default locations
include MYBB_ROOT . 'inc/plugins/dvz_mentions/alerts.posts.php';
to the top of inc/plugins/dvz_mentions/alerts.php so it's executed as the first instruction.
(2016-03-13, 08:38 PM)Devilshakerz Wrote: [ -> ]Try moving
// default locations
include MYBB_ROOT . 'inc/plugins/dvz_mentions/alerts.posts.php';
to the top of inc/plugins/dvz_mentions/alerts.php so it's executed as the first instruction.

Thank you! This changed the error log, so I think we're making progress? The old error no longer appears.

Here is the error log now.

[Sun Mar 13 20:42:31.365967 2016] [:error] [pid 28570] [client *****] PHP Fatal error:  Class 'DVZMentions_Alerts' not found in /usr/share/mediawiki/forum/inc/plugins/dvz_mentions/alerts.posts.php on line 13, referer: *****

Here is the beginning portion of my alerts.posts.php file.

<?php
/* by Tomasz 'Devilshakerz' Mlynski [devilshakerz.com]; Copyright (C) 2014-2015
 released under Creative Commons BY-NC-SA 4.0 license: http://creativecommons.org/licenses/by-nc-sa/4.0/ */

// hooks
$plugins->add_hook('myalerts_load_lang', ['DVZMentions_Alerts_Post', 'myalerts_load_lang']);

$plugins->add_hook('editpost_do_editpost_start', ['DVZMentions_Alerts_Post', 'editpost_start']);
$plugins->add_hook('datahandler_post_update', ['DVZMentions_Alerts_Post', 'post_update']);
$plugins->add_hook('newreply_do_newreply_end', ['DVZMentions_Alerts_Post', 'new_reply']);
$plugins->add_hook('newthread_do_newthread_end', ['DVZMentions_Alerts_Post', 'new_thread']);

DVZMentions_Alerts::register_location('post');

class DVZMentions_Alerts_Post extends DVZMentions_Alerts
{

    static function new_thread()
    {
        global $mybb, $new_thread, $uid, $thread_info;

        $message = $new_thread['message'];

        $alertDetails = [
            'tid'     => (int)$thread_info['tid'],
            'pid'     => (int)$thread_info['pid'],
            'subject' => $new_thread['subject'],
        ];

        $locationData = [
            'fid'     => (int)$new_thread['fid'],
            'tid'     => (int)$thread_info['tid'],
            'pid'     => (int)$thread_info,
            'author'  => $uid,
            'subject' => $new_thread['subject'],
        ];
Try moving the whole class DVZMentions_Alerts extends DVZMentions block to the beginning of alerts.php like previously (so 1. class, 2. include, 3. other instructions).

The plugin could have been coded better, but it seems like your server/PHP configuration is customized in a way that's causing it (you can PM me the output of your PHP Info available in the ACP if you have the opportunity some time).
(2016-03-13, 09:05 PM)Devilshakerz Wrote: [ -> ]Try moving the whole class DVZMentions_Alerts extends DVZMentions block to the beginning of alerts.php like previously (so 1. class, 2. include, 3. other instructions).

The plugin could have been coded better, but it seems like your server/PHP configuration is customized in a way that's causing it (you can PM me the output of your PHP Info available in the ACP if you have the opportunity some time).

Thank you once again. I no longer get a fatal error... now I get a syntax error. I'm curious if I moved too much or too little?

Here is the error.

[Sun Mar 13 21:11:24.593020 2016] [:error] [pid 28864] [client *****] PHP Parse error:  syntax error, unexpected 'include' (T_INCLUDE), expecting function (T_FUNCTION) in /usr/share/mediawiki/forum/inc/plugins/dvz_mentions/alerts.php on line 30, referer: *****

Here is the alerts.php file.

<?php

class DVZMentions_Alerts extends DVZMentions
{

    static $locations = [];

    static function register_location($location)
    {
        self::$locations[] = $location;
    }

    static function myalerts_register_formatters()
    {
        global $mybb, $lang;

        if ($mybb->user['uid']) {

            $formatterManager = MybbStuff_MyAlerts_AlertFormatterManager::getInstance();

            foreach (self::$locations as $location) {
                $class = 'MybbStuff_MyAlerts_Formatter_DVZMentions' . ucfirst($location) . 'Formatter';
                $formatterManager->registerFormatter(new $class($mybb, $lang, 'dvz_mentions_' . $location));
            }

        }
    }

// default locations
include MYBB_ROOT . 'inc/plugins/dvz_mentions/alerts.posts.php';

/* by Tomasz 'Devilshakerz' Mlynski [devilshakerz.com]; Copyright (C) 2014-2015
 released under Creative Commons BY-NC-SA 4.0 license: http://creativecommons.org/licenses/by-nc-sa/4.0/ */

// skip if MyAlerts is not installed or its version is not within the 2.0 branch
if (!DVZMentions_Alerts::myalerts_integrable()) return;

DVZMentions_Alerts::myalerts_init();

// core hooks
$plugins->add_hook('global_start', ['DVZMentions_Alerts', 'myalerts_register_formatters']);
$plugins->add_hook('admin_config_plugins_begin', ['DVZMentions_Alerts', 'admin_plugins']);

    static function admin_plugins()
    {
        global $mybb, $lang;

        if (self::$locations) {

            $lang->load('dvz_mentions');

            $alertTypeManager = MybbStuff_MyAlerts_AlertTypeManager::getInstance();

            // location installation handling
            if (($location = $mybb->get_input('dvz_me_alerts_install')) && verify_post_check($mybb->get_input('my_post_key'))) {
                if (in_array($location, self::$locations)) {
                    if (!$alertTypeManager->getByCode('dvz_mentions_' . $location)) {
                        self::install_location($location);
                        flash_message($lang->dvz_me_alerts_installed, 'success');
                        admin_redirect("index.php?module=config-plugins");
                    }
                }
            }

I'll PM you the PHP info shortly.

Oops, yeah, I moved too little. I moved most of the file and the Plugins page now works and there are no more DVZ Mentions errors in the error log. You're a life-saver!
There are still bits left - replace full content with this:
<?php
/* by Tomasz 'Devilshakerz' Mlynski [devilshakerz.com]; Copyright (C) 2014-2015
 released under Creative Commons BY-NC-SA 4.0 license: http://creativecommons.org/licenses/by-nc-sa/4.0/ */

class DVZMentions_Alerts extends DVZMentions
{

    static $locations = [];

    static function register_location($location)
    {
        self::$locations[] = $location;
    }

    static function myalerts_register_formatters()
    {
        global $mybb, $lang;

        if ($mybb->user['uid']) {

            $formatterManager = MybbStuff_MyAlerts_AlertFormatterManager::getInstance();

            foreach (self::$locations as $location) {
                $class = 'MybbStuff_MyAlerts_Formatter_DVZMentions' . ucfirst($location) . 'Formatter';
                $formatterManager->registerFormatter(new $class($mybb, $lang, 'dvz_mentions_' . $location));
            }

        }
    }

    static function admin_plugins()
    {
        global $mybb, $lang;

        if (self::$locations) {

            $lang->load('dvz_mentions');

            $alertTypeManager = MybbStuff_MyAlerts_AlertTypeManager::getInstance();

            // location installation handling
            if (($location = $mybb->get_input('dvz_me_alerts_install')) && verify_post_check($mybb->get_input('my_post_key'))) {
                if (in_array($location, self::$locations)) {
                    if (!$alertTypeManager->getByCode('dvz_mentions_' . $location)) {
                        self::install_location($location);
                        flash_message($lang->dvz_me_alerts_installed, 'success');
                        admin_redirect("index.php?module=config-plugins");
                    }
                }
            }

            // location uninstallation handling
            if (($location = $mybb->get_input('dvz_me_alerts_uninstall')) && verify_post_check($mybb->get_input('my_post_key'))) {
                if (in_array($location, self::$locations)) {
                    if ($alertTypeManager->getByCode('dvz_mentions_' . $location)) {
                        self::uninstall_location($location);
                        flash_message($lang->dvz_me_alerts_uninstalled, 'success');
                        admin_redirect("index.php?module=config-plugins");
                    }
                }
            }

            // location list
            $appendix = $lang->dvz_me_alerts;

            $locationList = [];

            foreach (self::$locations as $location) {

                $installed = $alertTypeManager->getByCode('dvz_mentions_' . $location);

                $locationName = $installed ? '<b>' . $location . '</b>' : $location;
                $actionUrl = 'index.php?module=config-plugins&amp;dvz_me_alerts_' . ($installed ? 'uninstall' : 'install') . '=' . htmlspecialchars_uni($location) . '&amp;my_post_key=' . $mybb->post_code;
                $actionText = $installed ? $lang->dvz_me_alerts_uninstall : $lang->dvz_me_alerts_install;

                $locationList[] = $locationName . ' <a href="' . $actionUrl . '">[' . $actionText . ']</a>';

            }

            $appendix .= ' ' . implode(' &middot; ', $locationList) . '<br>';

            DVZMentions::$descriptionAppendix .= $appendix;

        }

    }

    static function install_location($location)
    {
        global $db, $cache;

        $alertTypeManager = MybbStuff_MyAlerts_AlertTypeManager::getInstance();

        $alertType = new MybbStuff_MyAlerts_Entity_AlertType();
        $alertType->setCode('dvz_mentions_' . $location);

        $alertTypeManager->add($alertType);
    }

    static function uninstall_location($location)
    {
        global $db, $cache;

        $alertTypeManager = MybbStuff_MyAlerts_AlertTypeManager::getInstance();

        $alertTypeManager->deleteByCode('dvz_mentions_' . $location);
    }

    static function queue_alerts($location, $alertDetails, $locationData, $calledUids, $selfUid = false)
    {

        if ($selfUid) {
            // remove self calls
            if (in_array($selfUid, $calledUids)) {
                unset($calledUids[ $selfUid ]);
            }
        }

        $alertType = MybbStuff_MyAlerts_AlertTypeManager::getInstance()->getByCode('dvz_mentions_' . $location);

        $alerts = [];

        foreach ($calledUids as $uid) {

            if (call_user_func_array(['DVZMentions_Alerts_' . ucfirst($location), 'alert_possible'], [$locationData, $uid])) {

                if ($alertType && $alertType->getEnabled()) {

                    $alert = new MybbStuff_MyAlerts_Entity_Alert();

                    $alert
                        ->setType($alertType)
                        ->setUserId($uid)
                        ->setExtraDetails($alertDetails)
                    ;

                    if (isset($locationData['author']) && $locationData['author']) {
                        $alert->setFromUserId($locationData['author']);
                    }

                    $alerts[] = $alert;

                }

            }

        }

        if ($alerts) {
            MybbStuff_MyAlerts_AlertManager::getInstance()->addAlerts($alerts);
        }
    }

    static function myalerts_init()
    {
        defined('MYBBSTUFF_CORE_PATH') or define('MYBBSTUFF_CORE_PATH', MYBB_ROOT . 'inc/plugins/MybbStuff/Core/');
        defined('MYALERTS_PLUGIN_PATH') or define('MYALERTS_PLUGIN_PATH', MYBB_ROOT . 'inc/plugins/MybbStuff/MyAlerts');
        defined('PLUGINLIBRARY') or define('PLUGINLIBRARY', MYBB_ROOT . 'inc/plugins/pluginlibrary.php');
        require_once MYBBSTUFF_CORE_PATH . 'ClassLoader.php';

        $classLoader = new MybbStuff_Core_ClassLoader();
        $classLoader->registerNamespace('MybbStuff_MyAlerts', [MYALERTS_PLUGIN_PATH . '/src']);
        $classLoader->register();
    }

    static function myalerts_integrable()
    {
        global $cache;

        $pluginsCache = $cache->read('plugins');

        if (in_array('myalerts', $pluginsCache['active'])) {
            if ($euantor_plugins = $cache->read('euantor_plugins')) {
                if (isset($euantor_plugins['myalerts']['version'])) {
                    $version = explode('.', $euantor_plugins['myalerts']['version']);
                    if ($version[0] == '2' && $version[1] == '0') {
                        return true;
                    }
                }
            }
        }

        return false;
    }

}

// default locations
include MYBB_ROOT . 'inc/plugins/dvz_mentions/alerts.posts.php';

// skip if MyAlerts is not installed or its version is not within the 2.0 branch
if (!DVZMentions_Alerts::myalerts_integrable()) return;

DVZMentions_Alerts::myalerts_init();

// core hooks
$plugins->add_hook('global_start', ['DVZMentions_Alerts', 'myalerts_register_formatters']);
$plugins->add_hook('admin_config_plugins_begin', ['DVZMentions_Alerts', 'admin_plugins']);
Yeah, I edited my post just a moment before you posted your reply, that was the issue. Thank you so much! I also PM'd you the PHP Info as you requested. Smile
Is it possible to get alerts (MyAlerts plugin) for dvz mentions in the calendar?
(2015-09-23, 11:02 PM)stardust342 Wrote: [ -> ]Would it be possible to add the functionality of mentioning with their user id instead of their name, so when they change their name, it still works? Also could we have it so if you do @@username it doesn't show the at, but if you only have @username it still shows it? These two additions would make dvz mentions perfect imo. Thanks.

^ Not a bad idea.
Hi, i am using this plugin and i am having problems. If you want to help me please read: http://community.mybb.com/thread-190194.html

Thanks!
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29