MyBB Community Forums

Full Version: MyAlerts v2.0.4
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Mine is working very well now, however i still see a little bug which is when you click my alert and it says i.e John mentioned you in XXX then at the end it has () ... what's () for? does it mean . . . .
Just fix your lang file
sorry for being noob how do i fix it .. is it the one in plugins/lang/ i opened the file and looked for () couldnt find it.
(2015-06-04, 10:09 AM)Adamas Wrote: [ -> ]Euan, when I install MyAlerts, I get a white page when I try to activate it. Do you have any clue what might be going on here?
Hi,

Can you check your server error log and post any errors contained in there?
(2015-06-04, 10:50 AM)pandabb Wrote: [ -> ]Mine is working very well now, however i still see a little bug which is when you click my alert and it says  i.e John mentioned you in XXX then at the end it has () ... what's () for? does it mean . . . .

Hi,

You'll need to change the language file for the mention plugin. It should be in inc/languages/english/mention.lang.php. Just search for "(".
thank you again.. got it
(2015-06-04, 11:29 AM)Euan T Wrote: [ -> ]
(2015-06-04, 10:09 AM)Adamas Wrote: [ -> ]Euan, when I install MyAlerts, I get a white page when I try to activate it. Do you have any clue what might be going on here?
Hi,

Can you check your server error log and post any errors contained in there?

None of my error logs indicate there's any problem, which is odd. I opened up the Network tab in Chrome's Dev Tools, it's an error 500. All I can tell ATM. *scratches head*

Edit: Narrowed down. It's something within the _activate() function, but I don't know what. I put code at the start and end, then activated: the code at the start ran but the end didn't. My activate function is below.

    global $db, $lang, $PL, $plugins, $cache;

    if (!$lang->myalerts) {
        $lang->load('myalerts');
    }

    if (!file_exists(PLUGINLIBRARY)) {
        flash_message($lang->myalerts_pluginlibrary_missing, 'error');
        admin_redirect('index.php?module=config-plugins');
    }

    $PL or require_once PLUGINLIBRARY;

    if ($PL->version < 9) {
        flash_message('This plugin requires PluginLibrary 9 or newer', 'error');
        admin_redirect('index.php?module=config-plugins');
    }

    $plugin_info = myalerts_info();

    $euantorPlugins = $cache->read('euantor_plugins');

	if (!empty($euantorPlugins) && isset($euantorPlugins['myalerts'])) {
		$oldVersion = $euantorPlugins['myalerts'];

		if ($oldVersion['version'] == '1.05') {
			myalerts_upgrade_105_200();
		}
	}

    $euantorPlugins['myalerts'] = array(
        'title' => 'MyAlerts',
        'version' => $plugin_info['version'],
    );
    $cache->update('euantor_plugins', $euantorPlugins);

    $PL->settings(
        'myalerts',
        $lang->setting_group_myalerts,
        $lang->setting_group_myalerts_desc,
        array(
            'perpage' => array(
                'title' => $lang->setting_myalerts_perpage,
                'description' => $lang->setting_myalerts_perpage_desc,
                'value' => '10',
                'optionscode' => 'text',
            ),
            'dropdown_limit' => array(
                'title' => $lang->setting_myalerts_dropdown_limit,
                'description' => $lang->setting_myalerts_dropdown_limit_desc,
                'value' => '5',
                'optionscode' => 'text',
            ),
            'autorefresh' => array(
                'title' => $lang->setting_myalerts_autorefresh,
                'description' => $lang->setting_myalerts_autorefresh_desc,
                'value' => '0',
                'optionscode' => 'text',
            ),
            'avatar_size' => array(
                'title' => $lang->setting_myalerts_avatar_size,
                'description' => $lang->setting_myalerts_avatar_size_desc,
                'optionscode' => 'text',
                'value' => '64|64',
            ),
        )
    );

    $dir = new DirectoryIterator(MYALERTS_PLUGIN_PATH . '/templates');
    $templates = array();
    foreach ($dir as $file) {
        if (!$file->isDot() && !$file->isDir() && $file->getExtension() == 'html') {
	        $templateName = $file->getPathname();
	        $templateName = basename($templateName, '.html');
            $templates[$templateName] = file_get_contents($file->getPathName());
        }
    }

    $PL->templates(
        'myalerts',
        'MyAlerts',
        $templates
    );

    $stylesheet = file_get_contents(MYALERTS_PLUGIN_PATH . '/stylesheets/alerts.css');

    $PL->stylesheet('alerts.css', $stylesheet);

    // Attach usercp.css to alerts.php
    $query = $db->simple_select('themestylesheets', 'sid,attachedto,tid', "name = 'usercp.css'");

    while ($userCpStylesheet = $db->fetch_array($query)) {
        $sid = (int) $userCpStylesheet['sid'];

        $db->update_query('themestylesheets', array(
            'attachedto' => $db->escape_string($userCpStylesheet['attachedto'] . '|alerts.php'),
        ), "sid = {$sid}"
        );

        update_theme_stylesheet_list((int) $userCpStylesheet['tid']);
    }

    require_once MYBB_ROOT . '/inc/adminfunctions_templates.php';


    find_replace_templatesets('headerinclude', '/$/', '{$myalerts_js}');
    find_replace_templatesets(
        'header_welcomeblock_member',
        "#" . preg_quote('{$modcplink}') . "#i",
        '{$myalerts_headericon}{$modcplink}'
    );
	find_replace_templatesets(
		'footer',
		'/$/',
		'{$myalerts_modal}'
	);

    $taskExists = $db->simple_select('tasks', 'tid', 'file = \'myalerts\'', array('limit' => '1'));
    if ($db->num_rows($taskExists) == 0) {
        require_once MYBB_ROOT . '/inc/functions_task.php';

        $myTask = array(
            'title' => $lang->myalerts_task_title,
            'file' => 'myalerts',
            'description' => $lang->myalerts_task_description,
            'minute' => 0,
            'hour' => 1,
            'day' => '*',
            'weekday' => 1,
            'month' => '*',
            'nextrun' => TIME_NOW + 3600,
            'lastrun' => 0,
            'enabled' => 1,
            'logging' => 1,
            'locked' => 0,
        );

        $task_id = $db->insert_query('tasks', $myTask);
        $theTask = $db->fetch_array($db->simple_select('tasks', '*', 'tid = ' . (int) $task_id, 1));
        $nextrun = fetch_next_run($theTask);
        $db->update_query('tasks', 'nextrun = ' . $nextrun, 'tid = ' . (int) $task_id);
        $plugins->run_hooks('admin_tools_tasks_add_commit');
        $cache->update_tasks();
    } else {
        require_once MYBB_ROOT . '/inc/functions_task.php';
        $theTask = $db->fetch_array($db->simple_select('tasks', '*', 'file = \'myalerts\'', 1));
        $db->update_query('tasks', array('enabled' => 1, 'nextrun' => fetch_next_run($theTask)), 'file = \'myalerts\'');
        $cache->update_tasks();
    }

    $plugins->run_hooks('myalerts_activate');

Edit again: It's in the GitHub repo too. Ran that code, no dice. I'm about to go to sleep, so if it's of any use, my PHP version is 5.3.23, Apache 2.2.27.
Me admin panel , I now have the following error . What should I do , I work .
[Image: RYpbvG.png]

and page error :
[Image: 0qp4o9.png]
Hi Euan,

thanks for this awesome plugin.

I wanted to ask if you removed the dropdown menu functionality as I can't seem to find it anywhere in the code. On the other side, clicking on "Alerts" brings up a nice pop-up with all the alerts.

Other than the dropdown menu, everything's working great. Big Grin

Is there any chance to bring the dropdown menu back?
Hi again and thank you for updating this!

I have a minor problem though, when I click on the alerts link it doesn't have any kind of drop down, it just goes to this page and can't scroll nor is JS working on that page:

https://www.evernote.com/l/ASdhUVWdcuJM2.../image.png

I have tried uninstalling, then installing it again.

I just tried with the default skin and same issue
(2015-06-04, 12:27 PM)Adamas Wrote: [ -> ]
(2015-06-04, 11:29 AM)Euan T Wrote: [ -> ]
(2015-06-04, 10:09 AM)Adamas Wrote: [ -> ]Euan, when I install MyAlerts, I get a white page when I try to activate it. Do you have any clue what might be going on here?
Hi,

Can you check your server error log and post any errors contained in there?

None of my error logs indicate there's any problem, which is odd. I opened up the Network tab in Chrome's Dev Tools, it's an error 500. All I can tell ATM. *scratches head*

Edit: Narrowed down. It's something within the _activate() function, but I don't know what. I put code at the start and end, then activated: the code at the start ran but the end didn't. My activate function is below.

    global $db, $lang, $PL, $plugins, $cache;

    if (!$lang->myalerts) {
        $lang->load('myalerts');
    }

    if (!file_exists(PLUGINLIBRARY)) {
        flash_message($lang->myalerts_pluginlibrary_missing, 'error');
        admin_redirect('index.php?module=config-plugins');
    }

    $PL or require_once PLUGINLIBRARY;

    if ($PL->version < 9) {
        flash_message('This plugin requires PluginLibrary 9 or newer', 'error');
        admin_redirect('index.php?module=config-plugins');
    }

    $plugin_info = myalerts_info();

    $euantorPlugins = $cache->read('euantor_plugins');

	if (!empty($euantorPlugins) && isset($euantorPlugins['myalerts'])) {
		$oldVersion = $euantorPlugins['myalerts'];

		if ($oldVersion['version'] == '1.05') {
			myalerts_upgrade_105_200();
		}
	}

    $euantorPlugins['myalerts'] = array(
        'title' => 'MyAlerts',
        'version' => $plugin_info['version'],
    );
    $cache->update('euantor_plugins', $euantorPlugins);

    $PL->settings(
        'myalerts',
        $lang->setting_group_myalerts,
        $lang->setting_group_myalerts_desc,
        array(
            'perpage' => array(
                'title' => $lang->setting_myalerts_perpage,
                'description' => $lang->setting_myalerts_perpage_desc,
                'value' => '10',
                'optionscode' => 'text',
            ),
            'dropdown_limit' => array(
                'title' => $lang->setting_myalerts_dropdown_limit,
                'description' => $lang->setting_myalerts_dropdown_limit_desc,
                'value' => '5',
                'optionscode' => 'text',
            ),
            'autorefresh' => array(
                'title' => $lang->setting_myalerts_autorefresh,
                'description' => $lang->setting_myalerts_autorefresh_desc,
                'value' => '0',
                'optionscode' => 'text',
            ),
            'avatar_size' => array(
                'title' => $lang->setting_myalerts_avatar_size,
                'description' => $lang->setting_myalerts_avatar_size_desc,
                'optionscode' => 'text',
                'value' => '64|64',
            ),
        )
    );

    $dir = new DirectoryIterator(MYALERTS_PLUGIN_PATH . '/templates');
    $templates = array();
    foreach ($dir as $file) {
        if (!$file->isDot() && !$file->isDir() && $file->getExtension() == 'html') {
	        $templateName = $file->getPathname();
	        $templateName = basename($templateName, '.html');
            $templates[$templateName] = file_get_contents($file->getPathName());
        }
    }

    $PL->templates(
        'myalerts',
        'MyAlerts',
        $templates
    );

    $stylesheet = file_get_contents(MYALERTS_PLUGIN_PATH . '/stylesheets/alerts.css');

    $PL->stylesheet('alerts.css', $stylesheet);

    // Attach usercp.css to alerts.php
    $query = $db->simple_select('themestylesheets', 'sid,attachedto,tid', "name = 'usercp.css'");

    while ($userCpStylesheet = $db->fetch_array($query)) {
        $sid = (int) $userCpStylesheet['sid'];

        $db->update_query('themestylesheets', array(
            'attachedto' => $db->escape_string($userCpStylesheet['attachedto'] . '|alerts.php'),
        ), "sid = {$sid}"
        );

        update_theme_stylesheet_list((int) $userCpStylesheet['tid']);
    }

    require_once MYBB_ROOT . '/inc/adminfunctions_templates.php';


    find_replace_templatesets('headerinclude', '/$/', '{$myalerts_js}');
    find_replace_templatesets(
        'header_welcomeblock_member',
        "#" . preg_quote('{$modcplink}') . "#i",
        '{$myalerts_headericon}{$modcplink}'
    );
	find_replace_templatesets(
		'footer',
		'/$/',
		'{$myalerts_modal}'
	);

    $taskExists = $db->simple_select('tasks', 'tid', 'file = \'myalerts\'', array('limit' => '1'));
    if ($db->num_rows($taskExists) == 0) {
        require_once MYBB_ROOT . '/inc/functions_task.php';

        $myTask = array(
            'title' => $lang->myalerts_task_title,
            'file' => 'myalerts',
            'description' => $lang->myalerts_task_description,
            'minute' => 0,
            'hour' => 1,
            'day' => '*',
            'weekday' => 1,
            'month' => '*',
            'nextrun' => TIME_NOW + 3600,
            'lastrun' => 0,
            'enabled' => 1,
            'logging' => 1,
            'locked' => 0,
        );

        $task_id = $db->insert_query('tasks', $myTask);
        $theTask = $db->fetch_array($db->simple_select('tasks', '*', 'tid = ' . (int) $task_id, 1));
        $nextrun = fetch_next_run($theTask);
        $db->update_query('tasks', 'nextrun = ' . $nextrun, 'tid = ' . (int) $task_id);
        $plugins->run_hooks('admin_tools_tasks_add_commit');
        $cache->update_tasks();
    } else {
        require_once MYBB_ROOT . '/inc/functions_task.php';
        $theTask = $db->fetch_array($db->simple_select('tasks', '*', 'file = \'myalerts\'', 1));
        $db->update_query('tasks', array('enabled' => 1, 'nextrun' => fetch_next_run($theTask)), 'file = \'myalerts\'');
        $cache->update_tasks();
    }

    $plugins->run_hooks('myalerts_activate');

Edit again: It's in the GitHub repo too. Ran that code, no dice. I'm about to go to sleep, so if it's of any use, my PHP version is 5.3.23, Apache 2.2.27.
Strange. If it's an error 500, it should be logged by the server explaining what the actual error is. Without the error message, it's very difficult to establish the cause.
(2015-06-04, 06:03 PM)ziya3400 Wrote: [ -> ]Me admin panel , I now have the following error . What should I do , I work .
[Image: RYpbvG.png]

and page error :
[Image: 0qp4o9.png]
Hi,

Which version of MyBB are you using? It sounds like it's not a current version using the newish DB_Base interface that was added in MyBB 1.8.4.
(2015-06-04, 06:56 PM)donluca Wrote: [ -> ]Hi Euan,

thanks for this awesome plugin.

I wanted to ask if you removed the dropdown menu functionality as I can't seem to find it anywhere in the code. On the other side, clicking on "Alerts" brings up a nice pop-up with all the alerts.

Other than the dropdown menu, everything's working great. Big Grin

Is there any chance to bring the dropdown menu back?
Hi,

Yes I removed the dropdown as it caused issues with almost every theme out there and the new modal pop-up is much easier to use and should be supported by all 1.8 themes Smile

It would be possible to use a dropdown, but would require several template edits and JS edits that I won't support (due to a lack of time to do so).
(2015-06-04, 07:44 PM)Edwin Wrote: [ -> ]Hi again and thank you for updating this!

I have a minor problem though, when I click on the alerts link it doesn't have any kind of drop down, it just goes to this page and can't scroll nor is JS working on that page:

https://www.evernote.com/l/ASdhUVWdcuJM2.../image.png

I have tried uninstalling, then installing it again.

I just tried with the default skin and same issue

Hi,

That's strange, there should be a modal box. Can you send me a link to your site and details of a test account?