public function alert_comment($user, $commentor, $cid)
 {
     global $mybb, $db, $settings, $cache, $plugins;
     /* if the admin choosed alertbar, or "MyAlerts or Alert bar" but MyAlerts don't exist, notify the user */
     if ($settings["mpcommentsnotification"] == "alertbar" || $settings["mpcommentsnotification"] == "myalertsoralertbar" && !MyProfileUtils::myalerts_exists()) {
         $update_array = array("mpnewcomments" => $user["mpnewcomments"] + 1);
         $db->update_query("users", $update_array, "uid='{$user['uid']}'", "1");
         $user["mpnewcomments"]++;
     } elseif (($settings["mpcommentsnotification"] == "myalerts" || $settings["mpcommentsnotification"] == "myalertsoralertbar") && MyProfileUtils::myalerts_exists()) {
         $myalerts_plugins = $cache->read('mybbstuff_myalerts_alert_types');
         if (isset($myalerts_plugins[MyProfileCommentsMyAlertsFormatter::alert_type_code()]) && $myalerts_plugins[MyProfileCommentsMyAlertsFormatter::alert_type_code()]['enabled'] == 1) {
             $alertType = MybbStuff_MyAlerts_AlertTypeManager::createInstance($db, $cache)->getByCode(MyProfileCommentsMyAlertsFormatter::alert_type_code());
             $alert = MybbStuff_MyAlerts_Entity_Alert::make($user["uid"], $alertType, null, array("cid" => $cid));
             MybbStuff_MyAlerts_AlertManager::createInstance($mybb, $db, $cache, $plugins, $alertType)->addAlert($alert);
         }
     }
 }
Пример #2
0
function myalerts_create_instances()
{
    global $mybb, $db, $cache, $lang, $plugins;
    if (!isset($lang->myalerts)) {
        $lang->load('myalerts');
    }
    $alertTypeManager = MybbStuff_MyAlerts_AlertTypeManager::createInstance($db, $cache);
    MybbStuff_MyAlerts_AlertManager::createInstance($mybb, $db, $cache, $plugins, $alertTypeManager);
    MybbStuff_MyAlerts_AlertFormatterManager::createInstance($mybb, $lang);
    myalerts_register_core_formatters($mybb, $lang);
    register_shutdown_function(array(MybbStuff_MyAlerts_AlertManager::getInstance(), 'commit'));
}