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); } }
/** * Load all of the alert types currently in the system from the database. * Should only be used to refresh the cache. * * @return MybbStuff_MyAlerts_Entity_AlertType[] All of the alert types * currently in the database. */ private function loadAlertTypes() { $tablePrefix = TABLE_PREFIX; $queryString = "SELECT * FROM {$tablePrefix}alert_types;"; $query = $this->db->write_query($queryString); $alertTypes = array(); if ($this->db->num_rows($query) > 0) { while ($row = $this->db->fetch_array($query)) { $alertType = new MybbStuff_MyAlerts_Entity_AlertType(); $alertType->setId($row['id']); $alertType->setCode($row['code']); $alertType->setEnabled((int) $row['enabled'] == 1); $alertType->setCanBeUserDisabled((int) $row['can_be_user_disabled'] == 1); $alertTypes[$row['code']] = $alertType->toArray(); } } return $alertTypes; }
function ffplugin_activate() { global $db; if (!$db->table_exists("ffplugin")) { $db->write_query("CREATE TABLE " . TABLE_PREFIX . "ffplugin (following VARCHAR(100), follower VARCHAR(100))"); } //MyAlerts stuff 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('ffplugin_myalerts'); $alertType->setEnabled(true); $alertType->setCanBeUserDisabled(true); $alertTypeManager->add($alertType); } }
function myalerts_upgrade_105_200() { global $db, $lang, $cache, $plugins; if (!$db->field_exists('alert_type_id', 'alerts')) { $db->add_column('alerts', 'alert_type_id', 'INT(10) unsigned'); } if ($db->field_exists('alert_type', 'alerts')) { $db->drop_column('alerts', 'alert_type'); } $db->modify_column('alerts', 'dateline', 'DATETIME'); if ($db->field_exists('tid', 'alerts')) { $db->rename_column('alerts', 'tid', 'object_id', 'INT(10)'); } if ($db->field_exists('from_id', 'alerts')) { $db->rename_column('alerts', 'from_id', 'from_user_id', 'INT(10)'); } // Check if the 'forced' column exists due to earlier issues with the upgrade script in past releases if (!$db->field_exists('forced', 'alerts')) { $db->add_column('alerts', 'forced', "INT(1) NOT NULL DEFAULT '0'"); } if ($db->field_exists('content', 'alerts')) { $db->rename_column('alerts', 'content', 'extra_details', 'TEXT'); } if ($db->table_exists('alert_settings')) { $db->drop_table('alert_settings'); } if ($db->table_exists('alert_setting_values')) { $db->drop_table('alert_setting_values'); } $collation = $db->build_create_table_collation(); if (!$db->table_exists('alert_types')) { $db->write_query("CREATE TABLE " . TABLE_PREFIX . "alert_types(\n `id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n `code` varchar(100) NOT NULL DEFAULT '',\n `enabled` tinyint(4) NOT NULL DEFAULT '1',\n `can_be_user_disabled` tinyint(4) NOT NULL DEFAULT '1',\n PRIMARY KEY (`id`),\n UNIQUE KEY `unique_code` (`code`)\n ) ENGINE=MyISAM{$collation};"); } if (!$db->field_exists('myalerts_disabled_alert_types', 'users')) { $db->add_column('users', 'myalerts_disabled_alert_types', 'TEXT NOT NULL'); } $alertTypeManager = MybbStuff_MyAlerts_AlertTypeManager::createInstance($db, $cache); $insertArray = array('rep', 'pm', 'buddylist', 'quoted', 'post_threadauthor', 'subscribed_thread'); $alertTypesToAdd = array(); foreach ($insertArray as $type) { $alertType = new MybbStuff_MyAlerts_Entity_AlertType(); $alertType->setCode($type); $alertType->setEnabled(true); $alertType->setCanBeUserDisabled(true); $alertTypesToAdd[] = $alertType; } $alertTypeManager->addTypes($alertTypesToAdd); $plugins->run_hooks('myalerts_install'); flash_message($lang->myalerts_upgraded, 'success'); }
/** * 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); }