Beispiel #1
0
/**
 * Check whether MyAlerts is activated. Useful for 3rd parties. Example usage:
 *
 * <pre>
 * if (function_exists('myalerts_is_activated') && myalerts_is_activated()) {
 *  // Do work with MyAlerts.
 * }
 * </pre>
 *
 * @return bool Whether MyAlerts is activated and installed.
 */
function myalerts_is_activated()
{
    global $cache;
    $plugins = $cache->read('plugins');
    $activePlugins = $plugins['active'];
    $isActive = false;
    if (in_array('myalerts', $activePlugins)) {
        $isActive = true;
    }
    return myalerts_is_installed() && $isActive;
}
Beispiel #2
0
    if ($wiki['watching'] != null) {
        $watching = explode(',', $wiki['watching']);
        if (in_array($mybb->user['uid'], $watching)) {
            error($lang->wiki_already_watching);
        }
    }
    if ($wiki['watching'] == null) {
        $wiki['watching'] = $mybb->user['uid'];
    } else {
        $wiki['watching'] .= ",{$mybb->user['uid']}";
    }
    $db->write_query(sprintf("UPDATE `%swiki` SET `watching`='{$wiki['watching']}' WHERE `id`='{$id}'", TABLE_PREFIX));
    $plugins->run_hooks('wiki_watch_end');
    redirect("wiki.php", $lang->wiki_now_watching);
} elseif ($mybb->input['action'] == 'unwatch') {
    if (!function_exists('myalerts_is_installed') || !myalerts_is_installed()) {
        error($lang->wiki_myalerts_not_installed);
    }
    $id = (int) $mybb->input['id'];
    $query = $db->write_query(sprintf("SELECT watching FROM `%swiki` WHERE `id`='{$id}'", TABLE_PREFIX));
    if ($db->num_rows($query) === 0) {
        error($lang->doesntexist);
    }
    $wiki = $db->fetch_array($query);
    $plugins->run_hooks('wiki_unwatch_start');
    if ($wiki['watching'] != null) {
        $watching = explode(',', $wiki['watching']);
        if (!in_array($mybb->user['uid'], $watching)) {
            error($lang->wiki_not_already_watching);
        }
        $pointer = array_search($mybb->user['uid'], $watching);
 /**
  * Check if MyAlerts 2.0 exists.
  */
 public static function myalerts_exists()
 {
     return function_exists("myalerts_is_installed") && myalerts_is_installed();
 }