public static function myalerts_can_deintegrate()
 {
     global $db;
     if (function_exists("myalerts_info")) {
         $info = myalerts_info();
         return $info["version"] >= "2.0.0" && $db->table_exists("alert_types");
     }
     return false;
 }
if (isset($mybb->input['action']) && isset($mybb->input['uid'])) {
    if (strtolower($mybb->input['action']) == "follow") {
        if (get_user($mybb->input['uid'], MyBB::INPUT_INT)['uid'] == null) {
            if (isset($mybb->input['ajax'])) {
                header("Content-type: application/json;");
                echo json_encode(array("status" => "false", "followers" => 0));
            } else {
                error("Can't add this user to your followers list: User not found.");
            }
        } else {
            if ($db->num_rows($db->simple_select("ffplugin", "*", "following='" . get_user($mybb->input['uid'], MyBB::INPUT_INT)['uid'] . "' AND follower='" . $mybb->user['uid'] . "'")) == 0) {
                $insert_array = array("following" => get_user($mybb->input['uid'], MyBB::INPUT_INT)['uid'], "follower" => $mybb->user['uid']);
                $db->insert_query("ffplugin", $insert_array);
                if ($mybb->settings['ffplugin_em'] == 1) {
                    if (function_exists("myalerts_info")) {
                        $myalertsinfo = myalerts_info();
                        if ($myalertsinfo['version'] >= "2.0.0") {
                            $alertType = MybbStuff_MyAlerts_AlertTypeManager::getInstance()->getByCode('ffplugin_myalerts');
                            if ($alertType != null && $alertType->getEnabled()) {
                                $alert = new MybbStuff_MyAlerts_Entity_Alert(get_user($mybb->input['uid'], MyBB::INPUT_INT)['uid'], $alertType, 0);
                                MybbStuff_MyAlerts_AlertManager::getInstance()->addAlert($alert);
                            }
                        }
                    }
                }
                if (isset($mybb->input['ajax'])) {
                    header("Content-type: application/json;");
                    echo json_encode(array("status" => "true", "followers" => countf(get_user($mybb->input['uid'], MyBB::INPUT_INT)['uid'], false)));
                } else {
                    redirect("member.php?action=profile&uid=" . get_user($mybb->input['uid'], MyBB::INPUT_INT)['uid'], "You are now following " . getName(get_user($mybb->input['uid'], MyBB::INPUT_INT)['uid']) . ".");
                }
示例#3
0
function myalerts_activate()
{
    global $db, $lang, $PL, $plugins, $cache;
    if (!isset($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() && pathinfo($file->getPathname(), PATHINFO_EXTENSION) === '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');
}
 }
 // Check if user has already thanked/liked this post.
 $options = array("limit" => 1);
 $query_check = $db->simple_select($prefix . "thankyoulike", "*", "pid='" . $pid . "' AND uid='" . $mybb->user['uid'] . "'", $options);
 $utyl = $db->fetch_array($query_check);
 if (isset($utyl['tlid'])) {
     error($lang->sprintf($lang->tyl_error_already_tyled, $pre1));
 }
 // Add ty/l to db
 $tyl_data = array("pid" => intval($post['pid']), "uid" => intval($mybb->user['uid']), "puid" => intval($post['uid']), "dateline" => TIME_NOW);
 $tlid = $db->insert_query($prefix . "thankyoulike", $tyl_data);
 // Verify if myalerts exists and if compatible with 1.8.x then add alert type
 include_once 'inc/plugins/thankyoulike.php';
 if (function_exists("myalerts_info")) {
     // Load myalerts info into an array
     $my_alerts_info = myalerts_info();
     // Set version info to a new var
     $verify = $my_alerts_info['version'];
     // If MyAlerts 2.0 or better then do this !!!
     if ($verify >= "2.0.0") {
         global $cache;
         // Load cache data and compare if version is the same or don't
         $myalerts_plugins = $cache->read('mybbstuff_myalerts_alert_types');
         if ($myalerts_plugins['tyl']['code'] == 'tyl') {
             tyl_recordAlertThankyou();
         }
     }
 }
 if ($tlid) {
     // Update tyl count in posts and threads and users and total
     if ($post['tyl_pnumtyls'] == 0) {
function thankyoulike_deactivate()
{
    global $db, $cache;
    $codename = basename(__FILE__, ".php");
    $prefix = 'g33k_' . $codename . '_';
    // Remove settings
    $result = $db->simple_select('settinggroups', 'gid', "name = '{$prefix}settings'", array('limit' => 1));
    $group = $db->fetch_array($result);
    if (!empty($group['gid'])) {
        $db->delete_query('settinggroups', "gid='{$group['gid']}'");
        $db->delete_query('settings', "gid='{$group['gid']}'");
        rebuild_settings();
    }
    require_once MYBB_ROOT . "/inc/adminfunctions_templates.php";
    find_replace_templatesets("showthread", "#" . preg_quote('<script type="text/javascript" src="{$mybb->settings[\'bburl\']}/jscripts/thankyoulike.min.js"></script>
<script type="text/javascript">
<!--
	var tylEnabled = "{$mybb->settings[\'g33k_thankyoulike_enabled\']}";
	var tylDisplayGrowl = "{$mybb->settings[\'g33k_thankyoulike_displaygrowl\']}";
	var tylCollapsible = "{$mybb->settings[\'g33k_thankyoulike_collapsible\']}";
	var tylUser = "******";
	var tylSend = "{$lang->tyl_send}";
	var tylRemove = "{$lang->tyl_remove}";
// -->
</script>
</head>') . "#i", '</head>', 0);
    find_replace_templatesets("postbit", "#" . preg_quote('<div style="{$post[\'tyl_display\']}" id="tyl_{$post[\'pid\']}">{$post[\'thankyoulike_data\']}</div>') . "(\r?)\n#", '', 0);
    find_replace_templatesets("postbit_classic", "#" . preg_quote('<div style="{$post[\'tyl_display\']}" id="tyl_{$post[\'pid\']}">{$post[\'thankyoulike_data\']}</div>') . "(\r?)\n#", '', 0);
    find_replace_templatesets("postbit", "#" . preg_quote('{$post[\'button_tyl\']}') . "#i", '', 0);
    find_replace_templatesets("postbit_classic", "#" . preg_quote('{$post[\'button_tyl\']}') . "#i", '', 0);
    find_replace_templatesets("postbit_author_user", "#" . preg_quote('
	%%TYL_NUMTHANKEDLIKED%%<br />') . "#i", '', 0);
    find_replace_templatesets("member_profile", '#{\\$tyl_memprofile}(\\r?)\\n#', "", 0);
    if (function_exists("myalerts_info")) {
        // Load myalerts info into an array
        $my_alerts_info = myalerts_info();
        // Set version info to a new var
        $verify = $my_alerts_info['version'];
        // If MyAlerts is v2.0 or better then do this!!!
        if ($verify >= "2.0.0") {
            if ($db->table_exists("alert_types")) {
                $alertTypeManager = MybbStuff_MyAlerts_AlertTypeManager::getInstance();
                $alertTypeManager->deleteByCode('tyl');
            }
        }
    }
}
示例#6
0
function trader_uninstall()
{
    global $db, $cache;
    $db->drop_table("trade_feedback");
    $db->drop_column("users", "posreps");
    $db->drop_column("users", "neutreps");
    $db->drop_column("users", "negreps");
    // MyAlerts Integration
    // Check if MyAlerts exists and remove tradefeedback alert
    if (function_exists("myalerts_info")) {
        // Load myalerts info into an array
        $my_alerts_info = myalerts_info();
        // Set version info to a new var
        $verify = $my_alerts_info['version'];
        // If MyAlerts 2.0 or better then do this !!!
        if ($verify >= "2.0.0") {
            $alertTypeManager = MybbStuff_MyAlerts_AlertTypeManager::getInstance();
            $alertTypeManager->deleteByCode("tradefeedback");
        }
    }
}