function wiki_uninstall() { global $db, $cache; // Template Deletion $db->delete_query("templategroups", "title = 'Wiki'"); // Table deletion $db->drop_table('wiki'); $db->drop_table('wiki_edits'); $db->drop_table('wiki_categories'); $db->drop_table('wiki_perms'); $db->drop_table('wiki_settings'); $db->drop_table('wiki_templates'); // Clear caches $db->delete_query("datacache", 'title="wiki_articles"'); $db->delete_query("datacache", 'title="wiki_permissions"'); require_once MYBB_ADMIN_DIR . "inc/functions_themes.php"; // Stylesheet Deletion $query = $db->simple_select("themes", "tid"); while ($tid = $db->fetch_field($query, "tid")) { $css_file = MYBB_ROOT . "cache/themes/theme{$tid}/wiki.css"; if (file_exists($css_file)) { unlink($css_file); } } update_theme_stylesheet_list("1"); if (class_exists('MybbStuff_MyAlerts_AlertTypeManager')) { $alertTypeManager = MybbStuff_MyAlerts_AlertTypeManager::getInstance(); if (!$alertTypeManager) { $alertTypeManager = MybbStuff_MyAlerts_AlertTypeManager::createInstance($db, $cache); } $alertTypeManager->deleteByCode('mybb_wiki_alert_code'); } }
private function handleMyAlerts() { global $db, $cache; if (class_exists('MybbStuff_MyAlerts_AlertTypeManager')) { $alertTypeManager = MybbStuff_MyAlerts_AlertTypeManager::getInstance(); if (!$alertTypeManager) { $alertTypeManager = MybbStuff_MyAlerts_AlertTypeManager::createInstance($db, $cache); } $alertType = new MybbStuff_MyAlerts_Entity_AlertType(); $alertType->setCode('mybb_wiki_alert_code'); // The codename for your alert type. Can be any unique string. $alertType->setEnabled(true); $alertType->setCanBeUserDisabled(true); $alertTypeManager->add($alertType); } }
function trader_install() { global $db, $cache; $db->write_query("CREATE TABLE IF NOT EXISTS " . TABLE_PREFIX . "trade_feedback (\n `fid` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,\n `giver` INT UNSIGNED DEFAULT 1,\n `receiver` INT UNSIGNED NOT NULL DEFAULT 1,\n `dateline` BIGINT NOT NULL,\n `approved` TINYINT(1),\n `comments` TEXT,\n `type` VARCHAR(15) DEFAULT 'receiver',\n `value` TINYINT(1) DEFAULT 0,\n `reported` TINYINT(1) DEFAULT 0,\n `threadlink` TEXT,\n `tid` INT NOT NULL DEFAULT 0,\n `forum_id` INT NOT NULL DEFAULT 0,\n KEY giver(giver),\n KEY receiver(receiver)\n ) ENGINE=Innodb " . $db->build_create_table_collation()); // Now alter the users table if (!$db->field_exists("posreps", "users")) { $db->write_query("ALTER TABLE " . TABLE_PREFIX . "users \n ADD posreps INT UNSIGNED DEFAULT 0,\n ADD neutreps INT UNSIGNED DEFAULT 0,\n ADD negreps INT UNSIGNED DEFAULT 0"); } // Usergroup Permissions if (!$db->field_exists("cantradefeedback", "usergroups")) { $db->write_query("ALTER TABLE " . TABLE_PREFIX . "usergroups\n ADD cantradefeedback INT UNSIGNED DEFAULT 1"); } // Banned usergroups can't leave feedback $db->write_query("UPDATE " . TABLE_PREFIX . "usergroups SET cantradefeedback=0 WHERE isbannedgroup=1"); $cache->update_usergroups(); // MyAlerts Integration // Check if MyAlerts exists and is compatible 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") { // Load cache data and compare if version is the same or not $myalerts_plugins = $cache->read('mybbstuff_myalerts_alert_types'); if ($myalerts_plugins['tradefeedback']['code'] != 'tradefeedback') { $alertTypeManager = MybbStuff_MyAlerts_AlertTypeManager::createInstance($db, $cache); $alertType = new MybbStuff_MyAlerts_Entity_AlertType(); $alertType->setCode("tradefeedback"); $alertType->setEnabled(true); $alertTypeManager->add($alertType); } } } }
function ffplugin_deactivate() { //MyAlerts stuff if (class_exists('MybbStuff_MyAlerts_AlertTypeManager')) { $alertTypeManager = MybbStuff_MyAlerts_AlertTypeManager::getInstance(); if (!$alertTypeManager) { $alertTypeManager = MybbStuff_MyAlerts_AlertTypeManager::createInstance($db, $cache); } $alertTypeManager->deleteByCode('ffplugin_myalerts'); } }
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); } } }
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')); }
/** * MyAlerts 2.0 integration. * */ function accountswitcher_alerts_integrate() { global $db, $cache, $lang; if (!isset($lang->aj_name)) { $lang->load('accountswitcher'); } $alertTypeManager = MybbStuff_MyAlerts_AlertTypeManager::createInstance($db, $cache); $alertType = new MybbStuff_MyAlerts_Entity_AlertType(); $alertType->setCode("accountswitcher_author"); $alertType->setEnabled(true); $alertType->setCanBeUserDisabled(true); $alertTypeManager->add($alertType); $alertType->setCode("accountswitcher_pm"); $alertType->setEnabled(true); $alertType->setCanBeUserDisabled(true); $alertTypeManager->add($alertType); }
function thankyoulike_activate() { global $mybb, $db, $cache, $lang; $lang->load('config_thankyoulike'); $codename = basename(__FILE__, ".php"); $prefix = 'g33k_' . $codename . '_'; // Insert settings in to the database $query = $db->query("SELECT disporder FROM " . TABLE_PREFIX . "settinggroups ORDER BY `disporder` DESC LIMIT 1"); $disporder = $db->fetch_field($query, 'disporder') + 1; $setting_group = array('name' => $prefix . 'settings', 'title' => $db->escape_string($lang->tyl_title), 'description' => $db->escape_string($lang->tyl_desc), 'disporder' => intval($disporder), 'isdefault' => 0); $db->insert_query('settinggroups', $setting_group); $gid = $db->insert_id(); $settings = array('enabled' => array('title' => $lang->tyl_enabled_title, 'description' => $lang->tyl_enabled_desc, 'optionscode' => 'onoff', 'value' => '1'), 'thankslike' => array('title' => $lang->tyl_thankslike_title, 'description' => $lang->tyl_thankslike_desc, 'optionscode' => 'radio thanks=Use Thank You like=Use Like', 'value' => 'thanks'), 'firstall' => array('title' => $lang->tyl_firstall_title, 'description' => $lang->tyl_firstall_desc, 'optionscode' => 'radio first=First Post Only all=All Posts', 'value' => 'first'), 'firstalloverwrite' => array('title' => $lang->tyl_firstalloverwrite_title, 'description' => $lang->tyl_firstalloverwrite_desc, 'optionscode' => 'forumselect', 'value' => ''), 'removing' => array('title' => $lang->tyl_removing_title, 'description' => $lang->tyl_removing_desc, 'optionscode' => 'yesno', 'value' => '0'), 'closedthreads' => array('title' => $lang->tyl_closedthreads_title, 'description' => $lang->tyl_closedthreads_desc, 'optionscode' => 'yesno', 'value' => '0'), 'exclude' => array('title' => $lang->tyl_exclude_title, 'description' => $lang->tyl_exclude_desc, 'optionscode' => 'forumselect', 'value' => ''), 'unameformat' => array('title' => $lang->tyl_unameformat_title, 'description' => $lang->tyl_unameformat_desc, 'optionscode' => 'yesno', 'value' => '1'), 'hideforgroups' => array('title' => $lang->tyl_hideforgroups_title, 'description' => $lang->tyl_hideforgroups_desc, 'optionscode' => 'groupselect', 'value' => '1,7'), 'showdt' => array('title' => $lang->tyl_showdt_title, 'description' => $lang->tyl_showdt_desc, 'optionscode' => 'radio none=Not Display nexttoname=Display next to user name astitle=Display on mouse over username', 'value' => 'astitle'), 'dtformat' => array('title' => $lang->tyl_dtformat_title, 'description' => $lang->tyl_dtformat_desc, 'optionscode' => 'text', 'value' => 'm-d-Y'), 'sortorder' => array('title' => $lang->tyl_sortorder_title, 'description' => $lang->tyl_sortorder_desc, 'optionscode' => 'select userasc=Username Ascending userdesc=Username Descending dtasc=Date/Time Added Ascending dtdesc=Date/Time Added Descending', 'value' => 'userasc'), 'collapsible' => array('title' => $lang->tyl_collapsible_title, 'description' => $lang->tyl_collapsible_desc, 'optionscode' => 'yesno', 'value' => '1'), 'colldefault' => array('title' => $lang->tyl_colldefault_title, 'description' => $lang->tyl_colldefault_desc, 'optionscode' => 'radio open=List Shown closed=List Hidden (Collapsed)', 'value' => 'open'), 'hidelistforgroups' => array('title' => $lang->tyl_hidelistforgroups_title, 'description' => $lang->tyl_hidelistforgroups_desc, 'optionscode' => 'groupselect', 'value' => ''), 'displaygrowl' => array('title' => $lang->tyl_displaygrowl_title, 'description' => $lang->tyl_displaygrowl_desc, 'optionscode' => 'onoff', 'value' => '1')); $x = 1; foreach ($settings as $name => $setting) { $insert_settings = array('name' => $db->escape_string($prefix . $name), 'title' => $db->escape_string($setting['title']), 'description' => $db->escape_string($setting['description']), 'optionscode' => $db->escape_string($setting['optionscode']), 'value' => $db->escape_string($setting['value']), 'disporder' => $x, 'gid' => $gid, 'isdefault' => 0); $db->insert_query('settings', $insert_settings); $x++; } rebuild_settings(); require_once MYBB_ROOT . "/inc/adminfunctions_templates.php"; find_replace_templatesets("showthread", "#" . preg_quote('</head>') . "#i", '<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>'); find_replace_templatesets("postbit_classic", "#" . preg_quote('<div class="post_controls">') . "#i", "<div style=\"{\$post['tyl_display']}\" id=\"tyl_{\$post['pid']}\">{\$post['thankyoulike_data']}</div>\n<div class=\"post_controls\">"); find_replace_templatesets("postbit", "#" . preg_quote('<div class="post_controls">') . "#i", "<div style=\"{\$post['tyl_display']}\" id=\"tyl_{\$post['pid']}\">{\$post['thankyoulike_data']}</div>\n<div class=\"post_controls\">"); find_replace_templatesets("postbit", "#" . preg_quote('{$post[\'button_edit\']}') . "#i", '{$post[\'button_tyl\']}{$post[\'button_edit\']}'); find_replace_templatesets("postbit_classic", "#" . preg_quote('{$post[\'button_edit\']}') . "#i", '{$post[\'button_tyl\']}{$post[\'button_edit\']}'); find_replace_templatesets("postbit_author_user", "#" . preg_quote('{$lang->postbit_threads} {$post[\'threadnum\']}<br />') . "#i", '{$lang->postbit_threads} {$post[\'threadnum\']}<br /> %%TYL_NUMTHANKEDLIKED%%<br />'); if (!find_replace_templatesets("member_profile", '#{\\$reputation}(\\r?)\\n#', "{\$tyl_memprofile}\n{\$reputation}\n")) { find_replace_templatesets("member_profile", '#{\\$reputation}(\\r?)\\n#', "{\$tyl_memprofile}\n{\$reputation}\n"); } // Verify if myalerts exists and if it is compatible with 1.8.x, then add alert type 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") { // Load cache data and compare if version is the same or not $myalerts_plugins = $cache->read('mybbstuff_myalerts_alert_types'); if ($myalerts_plugins['tyl']['code'] != 'tyl') { //Adding alert type to db $alertTypeManager = MybbStuff_MyAlerts_AlertTypeManager::createInstance($db, $cache); $alertType = new MybbStuff_MyAlerts_Entity_AlertType(); $alertType->setCode('tyl'); $alertType->setEnabled(true); $alertTypeManager->add($alertType); } } } }